修改convert
This commit is contained in:
parent
edc8751162
commit
f3137ac76f
|
|
@ -1,11 +1,10 @@
|
||||||
package com.ruoyi.device.domain.convert;
|
package com.ruoyi.device.domain.convert;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.utils.BaseConvert;
|
||||||
import com.ruoyi.device.domain.model.Device;
|
import com.ruoyi.device.domain.model.Device;
|
||||||
import com.ruoyi.device.mapper.entity.DeviceEntity;
|
import com.ruoyi.device.mapper.entity.DeviceEntity;
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备Domain层转换器
|
* 设备Domain层转换器
|
||||||
|
|
@ -14,45 +13,27 @@ import java.util.stream.Collectors;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-01-16
|
* @date 2026-01-16
|
||||||
*/
|
*/
|
||||||
public class DeviceDomainEntityConvert
|
public class DeviceDomainEntityConvert extends BaseConvert<DeviceEntity, Device> {
|
||||||
{
|
|
||||||
/**
|
private static final DeviceDomainEntityConvert INSTANCE = new DeviceDomainEntityConvert();
|
||||||
* Entity 转 Model
|
|
||||||
*/
|
private DeviceDomainEntityConvert() {
|
||||||
public static Device toModel(DeviceEntity entity)
|
super(DeviceEntity.class, Device.class);
|
||||||
{
|
|
||||||
if (entity == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Device model = new Device();
|
|
||||||
BeanUtils.copyProperties(entity, model);
|
|
||||||
return model;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static Device from(DeviceEntity entity) {
|
||||||
* Model 转 Entity
|
return INSTANCE.innerFrom(entity);
|
||||||
*/
|
|
||||||
public static DeviceEntity toEntity(Device model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
DeviceEntity entity = new DeviceEntity();
|
|
||||||
BeanUtils.copyProperties(model, entity);
|
|
||||||
return entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static DeviceEntity to(Device model) {
|
||||||
* Entity List 转 Model List
|
return INSTANCE.innerTo(model);
|
||||||
*/
|
}
|
||||||
public static List<Device> toModelList(List<DeviceEntity> entityList)
|
|
||||||
{
|
public static List<Device> fromList(List<DeviceEntity> entityList) {
|
||||||
if (entityList == null)
|
return INSTANCE.innerFromList(entityList);
|
||||||
{
|
}
|
||||||
return null;
|
|
||||||
}
|
public static List<DeviceEntity> toList(List<Device> modelList) {
|
||||||
return entityList.stream().map(DeviceDomainEntityConvert::toModel).collect(Collectors.toList());
|
return INSTANCE.innerToList(modelList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
package com.ruoyi.device.domain.convert;
|
package com.ruoyi.device.domain.convert;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.utils.BaseConvert;
|
||||||
import com.ruoyi.device.domain.model.DockGroup;
|
import com.ruoyi.device.domain.model.DockGroup;
|
||||||
import com.ruoyi.device.mapper.entity.DockGroupEntity;
|
import com.ruoyi.device.mapper.entity.DockGroupEntity;
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机场分组关联Domain层转换器
|
* 机场分组关联Domain层转换器
|
||||||
|
|
@ -14,45 +13,27 @@ import java.util.stream.Collectors;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-01-16
|
* @date 2026-01-16
|
||||||
*/
|
*/
|
||||||
public class DockGroupDomainEntityConvert
|
public class DockGroupDomainEntityConvert extends BaseConvert<DockGroupEntity, DockGroup> {
|
||||||
{
|
|
||||||
/**
|
private static final DockGroupDomainEntityConvert INSTANCE = new DockGroupDomainEntityConvert();
|
||||||
* Entity 转 Model
|
|
||||||
*/
|
private DockGroupDomainEntityConvert() {
|
||||||
public static DockGroup toModel(DockGroupEntity entity)
|
super(DockGroupEntity.class, DockGroup.class);
|
||||||
{
|
|
||||||
if (entity == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
DockGroup model = new DockGroup();
|
|
||||||
BeanUtils.copyProperties(entity, model);
|
|
||||||
return model;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static DockGroup from(DockGroupEntity entity) {
|
||||||
* Model 转 Entity
|
return INSTANCE.innerFrom(entity);
|
||||||
*/
|
|
||||||
public static DockGroupEntity toEntity(DockGroup model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
DockGroupEntity entity = new DockGroupEntity();
|
|
||||||
BeanUtils.copyProperties(model, entity);
|
|
||||||
return entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static DockGroupEntity to(DockGroup model) {
|
||||||
* Entity List 转 Model List
|
return INSTANCE.innerTo(model);
|
||||||
*/
|
}
|
||||||
public static List<DockGroup> toModelList(List<DockGroupEntity> entityList)
|
|
||||||
{
|
public static List<DockGroup> fromList(List<DockGroupEntity> entityList) {
|
||||||
if (entityList == null)
|
return INSTANCE.innerFromList(entityList);
|
||||||
{
|
}
|
||||||
return null;
|
|
||||||
}
|
public static List<DockGroupEntity> toList(List<DockGroup> modelList) {
|
||||||
return entityList.stream().map(DockGroupDomainEntityConvert::toModel).collect(Collectors.toList());
|
return INSTANCE.innerToList(modelList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
package com.ruoyi.device.domain.convert;
|
package com.ruoyi.device.domain.convert;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.utils.BaseConvert;
|
||||||
import com.ruoyi.device.domain.model.Group;
|
import com.ruoyi.device.domain.model.Group;
|
||||||
import com.ruoyi.device.mapper.entity.GroupEntity;
|
import com.ruoyi.device.mapper.entity.GroupEntity;
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分组Domain层转换器
|
* 分组Domain层转换器
|
||||||
|
|
@ -14,45 +13,27 @@ import java.util.stream.Collectors;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2026-01-16
|
* @date 2026-01-16
|
||||||
*/
|
*/
|
||||||
public class GroupDomainEntityConvert
|
public class GroupDomainEntityConvert extends BaseConvert<GroupEntity, Group> {
|
||||||
{
|
|
||||||
/**
|
private static final GroupDomainEntityConvert INSTANCE = new GroupDomainEntityConvert();
|
||||||
* Entity 转 Model
|
|
||||||
*/
|
private GroupDomainEntityConvert() {
|
||||||
public static Group toModel(GroupEntity entity)
|
super(GroupEntity.class, Group.class);
|
||||||
{
|
|
||||||
if (entity == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Group model = new Group();
|
|
||||||
BeanUtils.copyProperties(entity, model);
|
|
||||||
return model;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static Group from(GroupEntity entity) {
|
||||||
* Model 转 Entity
|
return INSTANCE.innerFrom(entity);
|
||||||
*/
|
|
||||||
public static GroupEntity toEntity(Group model)
|
|
||||||
{
|
|
||||||
if (model == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
GroupEntity entity = new GroupEntity();
|
|
||||||
BeanUtils.copyProperties(model, entity);
|
|
||||||
return entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static GroupEntity to(Group model) {
|
||||||
* Entity List 转 Model List
|
return INSTANCE.innerTo(model);
|
||||||
*/
|
}
|
||||||
public static List<Group> toModelList(List<GroupEntity> entityList)
|
|
||||||
{
|
public static List<Group> fromList(List<GroupEntity> entityList) {
|
||||||
if (entityList == null)
|
return INSTANCE.innerFromList(entityList);
|
||||||
{
|
}
|
||||||
return null;
|
|
||||||
}
|
public static List<GroupEntity> toList(List<Group> modelList) {
|
||||||
return entityList.stream().map(GroupDomainEntityConvert::toModel).collect(Collectors.toList());
|
return INSTANCE.innerToList(modelList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,29 +28,29 @@ public class DeviceDomainImpl implements IDeviceDomain
|
||||||
@Override
|
@Override
|
||||||
public List<Device> selectDeviceList(Device device)
|
public List<Device> selectDeviceList(Device device)
|
||||||
{
|
{
|
||||||
DeviceEntity entity = DeviceDomainEntityConvert.toEntity(device);
|
DeviceEntity entity = DeviceDomainEntityConvert.to(device);
|
||||||
List<DeviceEntity> entityList = deviceMapper.selectDeviceList(entity);
|
List<DeviceEntity> entityList = deviceMapper.selectDeviceList(entity);
|
||||||
return DeviceDomainEntityConvert.toModelList(entityList);
|
return DeviceDomainEntityConvert.fromList(entityList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device selectDeviceByDeviceId(Long deviceId)
|
public Device selectDeviceByDeviceId(Long deviceId)
|
||||||
{
|
{
|
||||||
DeviceEntity entity = deviceMapper.selectDeviceByDeviceId(deviceId);
|
DeviceEntity entity = deviceMapper.selectDeviceByDeviceId(deviceId);
|
||||||
return DeviceDomainEntityConvert.toModel(entity);
|
return DeviceDomainEntityConvert.from(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device selectDeviceByIotDeviceId(String iotDeviceId)
|
public Device selectDeviceByIotDeviceId(String iotDeviceId)
|
||||||
{
|
{
|
||||||
DeviceEntity entity = deviceMapper.selectDeviceByIotDeviceId(iotDeviceId);
|
DeviceEntity entity = deviceMapper.selectDeviceByIotDeviceId(iotDeviceId);
|
||||||
return DeviceDomainEntityConvert.toModel(entity);
|
return DeviceDomainEntityConvert.from(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertDevice(Device device)
|
public int insertDevice(Device device)
|
||||||
{
|
{
|
||||||
DeviceEntity entity = DeviceDomainEntityConvert.toEntity(device);
|
DeviceEntity entity = DeviceDomainEntityConvert.to(device);
|
||||||
int result = deviceMapper.insertDevice(entity);
|
int result = deviceMapper.insertDevice(entity);
|
||||||
// MyBatis 会将自增主键回填到 entity 对象,需要同步回 device 对象
|
// MyBatis 会将自增主键回填到 entity 对象,需要同步回 device 对象
|
||||||
device.setDeviceId(entity.getDeviceId());
|
device.setDeviceId(entity.getDeviceId());
|
||||||
|
|
@ -60,7 +60,7 @@ public class DeviceDomainImpl implements IDeviceDomain
|
||||||
@Override
|
@Override
|
||||||
public int updateDevice(Device device)
|
public int updateDevice(Device device)
|
||||||
{
|
{
|
||||||
DeviceEntity entity = DeviceDomainEntityConvert.toEntity(device);
|
DeviceEntity entity = DeviceDomainEntityConvert.to(device);
|
||||||
return deviceMapper.updateDevice(entity);
|
return deviceMapper.updateDevice(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,36 +28,36 @@ public class DockGroupDomainImpl implements IDockGroupDomain
|
||||||
@Override
|
@Override
|
||||||
public List<DockGroup> selectDockGroupList(DockGroup dockGroup)
|
public List<DockGroup> selectDockGroupList(DockGroup dockGroup)
|
||||||
{
|
{
|
||||||
DockGroupEntity entity = DockGroupDomainEntityConvert.toEntity(dockGroup);
|
DockGroupEntity entity = DockGroupDomainEntityConvert.to(dockGroup);
|
||||||
List<DockGroupEntity> entityList = dockGroupMapper.selectDockGroupList(entity);
|
List<DockGroupEntity> entityList = dockGroupMapper.selectDockGroupList(entity);
|
||||||
return DockGroupDomainEntityConvert.toModelList(entityList);
|
return DockGroupDomainEntityConvert.fromList(entityList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DockGroup selectDockGroupById(Long id)
|
public DockGroup selectDockGroupById(Long id)
|
||||||
{
|
{
|
||||||
DockGroupEntity entity = dockGroupMapper.selectDockGroupById(id);
|
DockGroupEntity entity = dockGroupMapper.selectDockGroupById(id);
|
||||||
return DockGroupDomainEntityConvert.toModel(entity);
|
return DockGroupDomainEntityConvert.from(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DockGroup> selectDockGroupByDockId(Long dockId)
|
public List<DockGroup> selectDockGroupByDockId(Long dockId)
|
||||||
{
|
{
|
||||||
List<DockGroupEntity> entityList = dockGroupMapper.selectDockGroupListByDockId(dockId);
|
List<DockGroupEntity> entityList = dockGroupMapper.selectDockGroupListByDockId(dockId);
|
||||||
return DockGroupDomainEntityConvert.toModelList(entityList);
|
return DockGroupDomainEntityConvert.fromList(entityList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DockGroup> selectDockGroupByGroupId(Long groupId)
|
public List<DockGroup> selectDockGroupByGroupId(Long groupId)
|
||||||
{
|
{
|
||||||
List<DockGroupEntity> entityList = dockGroupMapper.selectDockGroupListByGroupId(groupId);
|
List<DockGroupEntity> entityList = dockGroupMapper.selectDockGroupListByGroupId(groupId);
|
||||||
return DockGroupDomainEntityConvert.toModelList(entityList);
|
return DockGroupDomainEntityConvert.fromList(entityList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertDockGroup(DockGroup dockGroup)
|
public int insertDockGroup(DockGroup dockGroup)
|
||||||
{
|
{
|
||||||
DockGroupEntity entity = DockGroupDomainEntityConvert.toEntity(dockGroup);
|
DockGroupEntity entity = DockGroupDomainEntityConvert.to(dockGroup);
|
||||||
int result = dockGroupMapper.insertDockGroup(entity);
|
int result = dockGroupMapper.insertDockGroup(entity);
|
||||||
// MyBatis 会将自增主键回填到 entity 对象,需要同步回 dockGroup 对象
|
// MyBatis 会将自增主键回填到 entity 对象,需要同步回 dockGroup 对象
|
||||||
dockGroup.setId(entity.getId());
|
dockGroup.setId(entity.getId());
|
||||||
|
|
@ -67,7 +67,7 @@ public class DockGroupDomainImpl implements IDockGroupDomain
|
||||||
@Override
|
@Override
|
||||||
public int updateDockGroup(DockGroup dockGroup)
|
public int updateDockGroup(DockGroup dockGroup)
|
||||||
{
|
{
|
||||||
DockGroupEntity entity = DockGroupDomainEntityConvert.toEntity(dockGroup);
|
DockGroupEntity entity = DockGroupDomainEntityConvert.to(dockGroup);
|
||||||
return dockGroupMapper.updateDockGroup(entity);
|
return dockGroupMapper.updateDockGroup(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,22 +28,22 @@ public class GroupDomainImpl implements IGroupDomain
|
||||||
@Override
|
@Override
|
||||||
public List<Group> selectGroupList(Group group)
|
public List<Group> selectGroupList(Group group)
|
||||||
{
|
{
|
||||||
GroupEntity entity = GroupDomainEntityConvert.toEntity(group);
|
GroupEntity entity = GroupDomainEntityConvert.to(group);
|
||||||
List<GroupEntity> entityList = groupMapper.selectGroupList(entity);
|
List<GroupEntity> entityList = groupMapper.selectGroupList(entity);
|
||||||
return GroupDomainEntityConvert.toModelList(entityList);
|
return GroupDomainEntityConvert.fromList(entityList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Group selectGroupByGroupId(Long groupId)
|
public Group selectGroupByGroupId(Long groupId)
|
||||||
{
|
{
|
||||||
GroupEntity entity = groupMapper.selectGroupByGroupId(groupId);
|
GroupEntity entity = groupMapper.selectGroupByGroupId(groupId);
|
||||||
return GroupDomainEntityConvert.toModel(entity);
|
return GroupDomainEntityConvert.from(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertGroup(Group group)
|
public int insertGroup(Group group)
|
||||||
{
|
{
|
||||||
GroupEntity entity = GroupDomainEntityConvert.toEntity(group);
|
GroupEntity entity = GroupDomainEntityConvert.to(group);
|
||||||
int result = groupMapper.insertGroup(entity);
|
int result = groupMapper.insertGroup(entity);
|
||||||
// MyBatis 会将自增主键回填到 entity 对象,需要同步回 group 对象
|
// MyBatis 会将自增主键回填到 entity 对象,需要同步回 group 对象
|
||||||
group.setGroupId(entity.getGroupId());
|
group.setGroupId(entity.getGroupId());
|
||||||
|
|
@ -53,7 +53,7 @@ public class GroupDomainImpl implements IGroupDomain
|
||||||
@Override
|
@Override
|
||||||
public int updateGroup(Group group)
|
public int updateGroup(Group group)
|
||||||
{
|
{
|
||||||
GroupEntity entity = GroupDomainEntityConvert.toEntity(group);
|
GroupEntity entity = GroupDomainEntityConvert.to(group);
|
||||||
return groupMapper.updateGroup(entity);
|
return groupMapper.updateGroup(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue