refactor: mapstruct 方法名统一

This commit is contained in:
haoxianrui
2024-08-13 18:18:57 +08:00
parent 6f6658f7fe
commit dcfd92ed11
11 changed files with 18 additions and 19 deletions

View File

@@ -16,7 +16,7 @@ public interface DeptConverter {
DeptForm toForm(SysDept entity);
DeptVO convertToVo(SysDept entity);
DeptVO toVo(SysDept entity);
SysDept toEntity(DeptForm deptForm);

View File

@@ -15,7 +15,7 @@ import org.mapstruct.Mapper;
@Mapper(componentModel = "spring")
public interface DictConverter {
Page<DictPageVO> convertToPageVo(Page<SysDict> page);
Page<DictPageVO> toPageVo(Page<SysDict> page);
DictForm toForm(SysDict entity);

View File

@@ -5,7 +5,6 @@ import com.youlai.system.common.model.Option;
import com.youlai.system.model.entity.SysDictItem;
import com.youlai.system.model.form.DictForm;
import com.youlai.system.model.vo.DictPageVO;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
@@ -21,20 +20,20 @@ import java.util.List;
@Mapper(componentModel = "spring")
public interface DictItemConverter {
Page<DictPageVO> convertToPageVo(Page<SysDictItem> page);
Page<DictPageVO> toPageVo(Page<SysDictItem> page);
DictForm toForm(SysDictItem entity);
SysDictItem toEntity(DictForm.DictItem dictFormDictItems);
List<SysDictItem> toEntity(List<DictForm.DictItem> dictFormDictItems);
SysDictItem toEntity(DictForm.DictItem dictItems);
List<SysDictItem> toEntity(List<DictForm.DictItem> dictItems);
DictForm.DictItem convertToDictFormDictItem(SysDictItem entity);
List<DictForm.DictItem> convertToDictFormDictItem(List<SysDictItem> entities);
DictForm.DictItem toDictItem(SysDictItem entity);
List<DictForm.DictItem> toDictItem(List<SysDictItem> entities);
@Mappings({
@Mapping(target = "value", source = "id"),
@Mapping(target = "label", source = "name")
})
Option<Long> convertToOption(SysDictItem dictItem);
List<Option<Long>> convertToOption(List<SysDictItem> dictItems);
Option<Long> toOption(SysDictItem dictItem);
List<Option<Long>> toOption(List<SysDictItem> dictItems);
}

View File

@@ -15,7 +15,7 @@ import org.mapstruct.Mapping;
@Mapper(componentModel = "spring")
public interface MenuConverter {
MenuVO convertToVo(SysMenu entity);
MenuVO toVo(SysMenu entity);
@Mapping(target = "params", ignore = true)
MenuForm toForm(SysMenu entity);

View File

@@ -20,7 +20,7 @@ import java.util.List;
@Mapper(componentModel = "spring")
public interface RoleConverter {
Page<RolePageVO> convertToPageVo(Page<SysRole> page);
Page<RolePageVO> toPageVo(Page<SysRole> page);
@Mappings({
@Mapping(target = "value", source = "id"),

View File

@@ -15,7 +15,7 @@ import org.mapstruct.Mapper;
@Mapper(componentModel = "spring")
public interface SysConfigConverter {
Page<ConfigVO> convertToPageVo(Page<SysConfig> page);
Page<ConfigVO> toPageVo(Page<SysConfig> page);
SysConfig toEntity(ConfigForm configForm);

View File

@@ -66,7 +66,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
.like(SysConfig::getConfigName, keywords)
);
Page<SysConfig> pageList = this.page(page, query);
return sysConfigConverter.convertToPageVo(pageList);
return sysConfigConverter.toPageVo(pageList);
}
/**

View File

@@ -86,7 +86,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
return deptList.stream()
.filter(dept -> dept.getParentId().equals(parentId))
.map(dept -> {
DeptVO deptVO = deptConverter.convertToVo(dept);
DeptVO deptVO = deptConverter.toVo(dept);
List<DeptVO> children = recurDeptList(dept.getId(), deptList);
deptVO.setChildren(children);
return deptVO;

View File

@@ -98,7 +98,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
.eq(SysDictItem::getDictId, id)
);
// 转换数据项
List<DictForm.DictItem> dictItemList = dictItemConverter.convertToDictFormDictItem(dictItems);
List<DictForm.DictItem> dictItemList = dictItemConverter.toDictItem(dictItems);
dictForm.setDictItems(dictItemList);
return dictForm;
}
@@ -219,7 +219,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
);
// 转换为 Option
return dictItemConverter.convertToOption(dictItems);
return dictItemConverter.toOption(dictItems);
}
/**

View File

@@ -94,7 +94,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
.stream()
.filter(menu -> menu.getParentId().equals(parentId))
.map(entity -> {
MenuVO menuVO = menuConverter.convertToVo(entity);
MenuVO menuVO = menuConverter.toVo(entity);
List<MenuVO> children = buildMenuTree(entity.getId(), menuList);
menuVO.setChildren(children);
return menuVO;

View File

@@ -70,7 +70,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
);
// 实体转换
return roleConverter.convertToPageVo(rolePage);
return roleConverter.toPageVo(rolePage);
}
/**