feat(system-server): 添加 DataBus MapStruct 数据转换器
- 新增 DatabusDeptConvert (DeptDO → DatabusDeptData) - 新增 DatabusUserConvert (AdminUserDO → DatabusAdminUserData) - 新增 DatabusPostConvert (PostDO → DatabusPostData) 说明: - 转换器忽略了需要额外查询的复杂字段(如 deptType, leaderUserName, depts, posts) - PostDO 不包含 tenantId,已配置忽略该字段映射 - 验证 system-server 编译通过 Ref: docs/databus/implementation-checklist.md 任务 20-22
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.zt.plat.module.system.convert.databus;
|
||||
|
||||
import com.zt.plat.module.databus.api.data.DatabusDeptData;
|
||||
import com.zt.plat.module.system.dal.dataobject.dept.DeptDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门数据转换器
|
||||
* <p>
|
||||
* 用于将 DeptDO 转换为 DatabusDeptData
|
||||
*
|
||||
* @author ZT
|
||||
*/
|
||||
@Mapper
|
||||
public interface DatabusDeptConvert {
|
||||
|
||||
DatabusDeptConvert INSTANCE = Mappers.getMapper(DatabusDeptConvert.class);
|
||||
|
||||
/**
|
||||
* DeptDO → DatabusDeptData
|
||||
* <p>
|
||||
* 注意:deptType 和 leaderUserName 字段需要额外处理,这里不做映射
|
||||
*/
|
||||
@Mapping(target = "deptType", ignore = true)
|
||||
@Mapping(target = "leaderUserName", ignore = true)
|
||||
DatabusDeptData convert(DeptDO dept);
|
||||
|
||||
/**
|
||||
* List<DeptDO> → List<DatabusDeptData>
|
||||
*/
|
||||
List<DatabusDeptData> convertList(List<DeptDO> deptList);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.zt.plat.module.system.convert.databus;
|
||||
|
||||
import com.zt.plat.module.databus.api.data.DatabusPostData;
|
||||
import com.zt.plat.module.system.dal.dataobject.dept.PostDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 岗位数据转换器
|
||||
* <p>
|
||||
* 用于将 PostDO 转换为 DatabusPostData
|
||||
*
|
||||
* @author ZT
|
||||
*/
|
||||
@Mapper
|
||||
public interface DatabusPostConvert {
|
||||
|
||||
DatabusPostConvert INSTANCE = Mappers.getMapper(DatabusPostConvert.class);
|
||||
|
||||
/**
|
||||
* PostDO → DatabusPostData
|
||||
* <p>
|
||||
* 注意:tenantId 字段在 PostDO 中不存在,需要额外处理
|
||||
*/
|
||||
@Mapping(target = "tenantId", ignore = true)
|
||||
DatabusPostData convert(PostDO post);
|
||||
|
||||
/**
|
||||
* List<PostDO> → List<DatabusPostData>
|
||||
*/
|
||||
List<DatabusPostData> convertList(List<PostDO> postList);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.zt.plat.module.system.convert.databus;
|
||||
|
||||
import com.zt.plat.module.databus.api.data.DatabusAdminUserData;
|
||||
import com.zt.plat.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户数据转换器
|
||||
* <p>
|
||||
* 用于将 AdminUserDO 转换为 DatabusAdminUserData
|
||||
*
|
||||
* @author ZT
|
||||
*/
|
||||
@Mapper
|
||||
public interface DatabusUserConvert {
|
||||
|
||||
DatabusUserConvert INSTANCE = Mappers.getMapper(DatabusUserConvert.class);
|
||||
|
||||
/**
|
||||
* AdminUserDO → DatabusAdminUserData
|
||||
* <p>
|
||||
* 注意:depts 和 posts 字段需要额外查询和处理,这里不做映射
|
||||
*/
|
||||
@Mapping(target = "depts", ignore = true)
|
||||
@Mapping(target = "posts", ignore = true)
|
||||
DatabusAdminUserData convert(AdminUserDO user);
|
||||
|
||||
/**
|
||||
* List<AdminUserDO> → List<DatabusAdminUserData>
|
||||
*/
|
||||
List<DatabusAdminUserData> convertList(List<AdminUserDO> userList);
|
||||
}
|
||||
Reference in New Issue
Block a user