修改标准代码结构
This commit is contained in:
parent
f0f8603550
commit
1a7c7caa71
|
|
@ -5,10 +5,10 @@ import com.ruoyi.common.core.web.controller.BaseController;
|
|||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
import com.ruoyi.common.security.annotation.InnerAuth;
|
||||
import com.ruoyi.device.api.domain.DeviceTemp;
|
||||
import com.ruoyi.device.domain.vo.DeviceTempVO;
|
||||
import com.ruoyi.device.service.IDeviceTempService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import com.ruoyi.device.api.domain.DeviceTempVO;
|
||||
import com.ruoyi.device.controller.convert.DeviceTempConvert;
|
||||
import com.ruoyi.device.service.api.IDeviceTempService;
|
||||
import com.ruoyi.device.service.dto.DeviceTempDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
|
@ -16,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 设备临时表Controller
|
||||
|
|
@ -35,13 +34,15 @@ public class DeviceTempController extends BaseController
|
|||
* 查询设备临时表列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(DeviceTemp deviceTemp)
|
||||
public TableDataInfo list(DeviceTempVO deviceTemp)
|
||||
{
|
||||
startPage();
|
||||
List<DeviceTemp> list = deviceTempService.selectDeviceTempList(deviceTemp);
|
||||
// 将 Domain 转换为 VO
|
||||
List<DeviceTempVO> voList = list.stream().map(this::convertToVO).collect(Collectors.toList());
|
||||
return getDataTable(voList);
|
||||
// API Domain → Service DTO
|
||||
DeviceTempDTO dto = DeviceTempConvert.toDTO(deviceTemp);
|
||||
List<DeviceTempDTO> dtoList = deviceTempService.selectDeviceTempList(dto);
|
||||
// Service DTO → API Domain
|
||||
List<DeviceTempVO> list = DeviceTempConvert.toApiDomainList(dtoList);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -49,35 +50,21 @@ public class DeviceTempController extends BaseController
|
|||
*/
|
||||
@InnerAuth
|
||||
@GetMapping(value = "/{id}")
|
||||
public R<DeviceTemp> getDeviceById(@PathVariable("id") String id)
|
||||
public R<DeviceTempVO> getDeviceById(@PathVariable("id") String id)
|
||||
{
|
||||
DeviceTemp deviceTemp = deviceTempService.selectDeviceTempById(id);
|
||||
DeviceTempDTO dto = deviceTempService.selectDeviceTempById(id);
|
||||
DeviceTempVO deviceTemp = DeviceTempConvert.toVO(dto);
|
||||
return R.ok(deviceTemp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备临时表详细信息(外部调用,返回VO)
|
||||
* 获取设备临时表详细信息(外部调用)
|
||||
*/
|
||||
@GetMapping(value = "/info/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id)
|
||||
{
|
||||
DeviceTemp deviceTemp = deviceTempService.selectDeviceTempById(id);
|
||||
// 将 Domain 转换为 VO
|
||||
DeviceTempVO vo = convertToVO(deviceTemp);
|
||||
return success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Domain 实体转换为 VO
|
||||
*/
|
||||
private DeviceTempVO convertToVO(DeviceTemp deviceTemp)
|
||||
{
|
||||
if (deviceTemp == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DeviceTempVO vo = new DeviceTempVO();
|
||||
BeanUtils.copyProperties(deviceTemp, vo);
|
||||
return vo;
|
||||
DeviceTempDTO dto = deviceTempService.selectDeviceTempById(id);
|
||||
DeviceTempVO deviceTemp = DeviceTempConvert.toVO(dto);
|
||||
return success(deviceTemp);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.ruoyi.device.controller.convert;
|
||||
|
||||
import com.ruoyi.device.api.domain.DeviceTempVO;
|
||||
import com.ruoyi.device.service.dto.DeviceTempDTO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 设备临时表Controller层转换器
|
||||
* API Domain ↔ Service DTO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
public class DeviceTempConvert
|
||||
{
|
||||
/**
|
||||
* DTO 转 API Domain
|
||||
*/
|
||||
public static DeviceTempVO toVO(DeviceTempDTO dto)
|
||||
{
|
||||
if (dto == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DeviceTempVO apiDomain = new DeviceTempVO();
|
||||
BeanUtils.copyProperties(dto, apiDomain);
|
||||
return apiDomain;
|
||||
}
|
||||
|
||||
/**
|
||||
* API Domain 转 DTO
|
||||
*/
|
||||
public static DeviceTempDTO toDTO(DeviceTempVO apiDomain)
|
||||
{
|
||||
if (apiDomain == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DeviceTempDTO dto = new DeviceTempDTO();
|
||||
BeanUtils.copyProperties(apiDomain, dto);
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* DTO List 转 API Domain List
|
||||
*/
|
||||
public static List<DeviceTempVO> toApiDomainList(List<DeviceTempDTO> dtoList)
|
||||
{
|
||||
if (dtoList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return dtoList.stream().map(DeviceTempConvert::toVO).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.ruoyi.device.domain.api;
|
||||
|
||||
import com.ruoyi.device.domain.model.DeviceTemp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备临时表Domain接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
public interface IDeviceTempDomain
|
||||
{
|
||||
/**
|
||||
* 查询设备临时表列表
|
||||
*
|
||||
* @param deviceTemp 设备临时表
|
||||
* @return 设备临时表集合
|
||||
*/
|
||||
List<DeviceTemp> selectDeviceTempList(DeviceTemp deviceTemp);
|
||||
|
||||
/**
|
||||
* 根据ID查询设备临时表
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return 设备临时表
|
||||
*/
|
||||
DeviceTemp selectDeviceTempById(String id);
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.ruoyi.device.domain.convert;
|
||||
|
||||
import com.ruoyi.device.domain.model.DeviceTemp;
|
||||
import com.ruoyi.device.mapper.entity.DeviceTempEntity;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 设备临时表Domain层转换器
|
||||
* Domain Model ↔ Mapper Entity
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
public class DeviceTempConvert
|
||||
{
|
||||
/**
|
||||
* Entity 转 Model
|
||||
*/
|
||||
public static DeviceTemp toModel(DeviceTempEntity entity)
|
||||
{
|
||||
if (entity == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DeviceTemp model = new DeviceTemp();
|
||||
BeanUtils.copyProperties(entity, model);
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model 转 Entity
|
||||
*/
|
||||
public static DeviceTempEntity toEntity(DeviceTemp model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DeviceTempEntity entity = new DeviceTempEntity();
|
||||
BeanUtils.copyProperties(model, entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity List 转 Model List
|
||||
*/
|
||||
public static List<DeviceTemp> toModelList(List<DeviceTempEntity> entityList)
|
||||
{
|
||||
if (entityList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return entityList.stream().map(DeviceTempConvert::toModel).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.ruoyi.device.domain.impl;
|
||||
|
||||
import com.ruoyi.device.domain.api.IDeviceTempDomain;
|
||||
import com.ruoyi.device.domain.convert.DeviceTempConvert;
|
||||
import com.ruoyi.device.domain.model.DeviceTemp;
|
||||
import com.ruoyi.device.mapper.DeviceTempMapper;
|
||||
import com.ruoyi.device.mapper.entity.DeviceTempEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备临时表Domain实现
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
@Component
|
||||
public class DeviceTempDomainImpl implements IDeviceTempDomain
|
||||
{
|
||||
@Autowired
|
||||
private DeviceTempMapper deviceTempMapper;
|
||||
|
||||
@Override
|
||||
public List<DeviceTemp> selectDeviceTempList(DeviceTemp deviceTempModel)
|
||||
{
|
||||
DeviceTempEntity entity = DeviceTempConvert.toEntity(deviceTempModel);
|
||||
List<DeviceTempEntity> entityList = deviceTempMapper.selectDeviceTempList(entity);
|
||||
return DeviceTempConvert.toModelList(entityList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceTemp selectDeviceTempById(String id)
|
||||
{
|
||||
DeviceTempEntity entity = deviceTempMapper.selectDeviceTempById(id);
|
||||
return DeviceTempConvert.toModel(entity);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,16 @@
|
|||
package com.ruoyi.device.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
package com.ruoyi.device.domain.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 设备临时表视图对象 DeviceTempVO
|
||||
* 设备临时表领域模型
|
||||
* Domain 层对外暴露的对象
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
public class DeviceTempVO implements Serializable
|
||||
public class DeviceTemp implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
|
@ -19,11 +18,9 @@ public class DeviceTempVO implements Serializable
|
|||
private String id;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
public String getId()
|
||||
|
|
@ -55,14 +52,4 @@ public class DeviceTempVO implements Serializable
|
|||
{
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "DeviceTempVO{" +
|
||||
"id='" + id + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ruoyi.device.mapper;
|
||||
|
||||
import com.ruoyi.device.api.domain.DeviceTemp;
|
||||
import com.ruoyi.device.mapper.entity.DeviceTempEntity;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -14,10 +14,10 @@ public interface DeviceTempMapper
|
|||
/**
|
||||
* 查询设备临时表列表
|
||||
*
|
||||
* @param deviceTemp 设备临时表
|
||||
* @param deviceTempEntity 设备临时表
|
||||
* @return 设备临时表集合
|
||||
*/
|
||||
public List<DeviceTemp> selectDeviceTempList(DeviceTemp deviceTemp);
|
||||
public List<DeviceTempEntity> selectDeviceTempList(DeviceTempEntity deviceTempEntity);
|
||||
|
||||
/**
|
||||
* 根据ID查询设备临时表
|
||||
|
|
@ -25,5 +25,5 @@ public interface DeviceTempMapper
|
|||
* @param id 主键ID
|
||||
* @return 设备临时表
|
||||
*/
|
||||
public DeviceTemp selectDeviceTempById(String id);
|
||||
public DeviceTempEntity selectDeviceTempById(String id);
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.ruoyi.device.mapper.entity;
|
||||
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 设备临时表实体对象 tuoheng_device_temp
|
||||
* Mapper 层实体,对应数据库表
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
public class DeviceTempEntity extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private String id;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "DeviceTempEntity{" +
|
||||
"id='" + id + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ruoyi.device.service;
|
||||
package com.ruoyi.device.service.api;
|
||||
|
||||
import com.ruoyi.device.api.domain.DeviceTemp;
|
||||
import com.ruoyi.device.service.dto.DeviceTempDTO;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -14,10 +14,10 @@ public interface IDeviceTempService
|
|||
/**
|
||||
* 查询设备临时表列表
|
||||
*
|
||||
* @param deviceTemp 设备临时表
|
||||
* @param deviceTempDTO 设备临时表
|
||||
* @return 设备临时表集合
|
||||
*/
|
||||
public List<DeviceTemp> selectDeviceTempList(DeviceTemp deviceTemp);
|
||||
List<DeviceTempDTO> selectDeviceTempList(DeviceTempDTO deviceTempDTO);
|
||||
|
||||
/**
|
||||
* 根据ID查询设备临时表
|
||||
|
|
@ -25,5 +25,5 @@ public interface IDeviceTempService
|
|||
* @param id 主键ID
|
||||
* @return 设备临时表
|
||||
*/
|
||||
public DeviceTemp selectDeviceTempById(String id);
|
||||
DeviceTempDTO selectDeviceTempById(String id);
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.ruoyi.device.service.convert;
|
||||
|
||||
import com.ruoyi.device.domain.model.DeviceTemp;
|
||||
import com.ruoyi.device.service.dto.DeviceTempDTO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 设备临时表Service层转换器
|
||||
* Service DTO ↔ Domain Model
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
public class DeviceTempConvert
|
||||
{
|
||||
/**
|
||||
* Model 转 DTO
|
||||
*/
|
||||
public static DeviceTempDTO toDTO(DeviceTemp model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DeviceTempDTO dto = new DeviceTempDTO();
|
||||
BeanUtils.copyProperties(model, dto);
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* DTO 转 Model
|
||||
*/
|
||||
public static DeviceTemp toModel(DeviceTempDTO dto)
|
||||
{
|
||||
if (dto == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DeviceTemp model = new DeviceTemp();
|
||||
BeanUtils.copyProperties(dto, model);
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model List 转 DTO List
|
||||
*/
|
||||
public static List<DeviceTempDTO> toDTOList(List<DeviceTemp> modelList)
|
||||
{
|
||||
if (modelList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return modelList.stream().map(DeviceTempConvert::toDTO).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.ruoyi.device.service.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 设备临时表服务层DTO
|
||||
* Service 层对外暴露的对象
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-01-15
|
||||
*/
|
||||
public class DeviceTempDTO implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private String id;
|
||||
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
|
||||
/** 更新时间 */
|
||||
private Date updateTime;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime()
|
||||
{
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime)
|
||||
{
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
package com.ruoyi.device.service.impl;
|
||||
|
||||
import com.ruoyi.device.api.domain.DeviceTemp;
|
||||
import com.ruoyi.device.mapper.DeviceTempMapper;
|
||||
import com.ruoyi.device.service.IDeviceTempService;
|
||||
import com.ruoyi.device.domain.api.IDeviceTempDomain;
|
||||
import com.ruoyi.device.domain.model.DeviceTemp;
|
||||
import com.ruoyi.device.service.api.IDeviceTempService;
|
||||
import com.ruoyi.device.service.convert.DeviceTempConvert;
|
||||
import com.ruoyi.device.service.dto.DeviceTempDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -18,18 +20,20 @@ import java.util.List;
|
|||
public class DeviceTempServiceImpl implements IDeviceTempService
|
||||
{
|
||||
@Autowired
|
||||
private DeviceTempMapper deviceTempMapper;
|
||||
private IDeviceTempDomain deviceTempDomain;
|
||||
|
||||
/**
|
||||
* 查询设备临时表列表
|
||||
*
|
||||
* @param deviceTemp 设备临时表
|
||||
* @return 设备临时表
|
||||
* @param deviceTempDTO 设备临时表
|
||||
* @return 设备临时表集合
|
||||
*/
|
||||
@Override
|
||||
public List<DeviceTemp> selectDeviceTempList(DeviceTemp deviceTemp)
|
||||
public List<DeviceTempDTO> selectDeviceTempList(DeviceTempDTO deviceTempDTO)
|
||||
{
|
||||
return deviceTempMapper.selectDeviceTempList(deviceTemp);
|
||||
DeviceTemp model = DeviceTempConvert.toModel(deviceTempDTO);
|
||||
List<DeviceTemp> modelList = deviceTempDomain.selectDeviceTempList(model);
|
||||
return DeviceTempConvert.toDTOList(modelList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -39,8 +43,9 @@ public class DeviceTempServiceImpl implements IDeviceTempService
|
|||
* @return 设备临时表
|
||||
*/
|
||||
@Override
|
||||
public DeviceTemp selectDeviceTempById(String id)
|
||||
public DeviceTempDTO selectDeviceTempById(String id)
|
||||
{
|
||||
return deviceTempMapper.selectDeviceTempById(id);
|
||||
DeviceTemp model = deviceTempDomain.selectDeviceTempById(id);
|
||||
return DeviceTempConvert.toDTO(model);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.device.mapper.DeviceTempMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.device.domain.DeviceTemp" id="DeviceTempResult">
|
||||
<resultMap type="com.ruoyi.device.mapper.entity.DeviceTempEntity" id="DeviceTempResult">
|
||||
<result property="id" column="id" />
|
||||
</resultMap>
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select id from tuoheng_device_temp
|
||||
</sql>
|
||||
|
||||
<select id="selectDeviceTempList" parameterType="com.ruoyi.device.domain.DeviceTemp" resultMap="DeviceTempResult">
|
||||
<select id="selectDeviceTempList" parameterType="com.ruoyi.device.mapper.entity.DeviceTempEntity" resultMap="DeviceTempResult">
|
||||
<include refid="selectDeviceTempVo"/>
|
||||
<where>
|
||||
<if test="id != null and id != ''"> and id = #{id}</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue