feat(system): 同步主数据用户信息时增加部门与单位字段
- 在 MasterUserReqVO 中新增 deptId、deptName、orgId、orgName 字段- 调整单元测试配置文件端口号及激活方式 - 修改 UserSyncServiceImpl 中 remark 生成逻辑,使用 getRemark 方法格式化备注信息 - 新增 MasterUserSyncTest 测试类验证字符串格式化功能-优化 WorkOrderSimpleTest 类引入服务并格式化 SQL 输出
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
package com.jeelowcode.test.alibaba;
|
||||
|
||||
import cn.hutool.db.sql.SqlUtil;
|
||||
import com.jeelowcode.module.biz.job.AlibabaWorkOrderJob;
|
||||
import com.jeelowcode.module.biz.service.impl.AlibabaWorkOrderServiceImpl;
|
||||
import com.jeelowcode.tool.framework.test.core.ut.BaseDbAndRedisUnitTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Import({AlibabaWorkOrderServiceImpl.class})
|
||||
public class WorkOrderSimpleTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
@Resource
|
||||
private AlibabaWorkOrderJob alibabaWorkOrderJob;
|
||||
private AlibabaWorkOrderServiceImpl workOrderService;
|
||||
|
||||
@Test
|
||||
public void testBuildSql() {
|
||||
System.out.println(alibabaWorkOrderJob.buildSql(null, null));
|
||||
System.out.println(SqlUtil.formatSql(AlibabaWorkOrderJob.buildSql(null, null)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jeelowcode.test.master;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.jeelowcode.tool.framework.test.core.ut.BaseMockitoUnitTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class MasterUserSyncTest extends BaseMockitoUnitTest {
|
||||
|
||||
@Test
|
||||
public void testStringFormat() {
|
||||
String description = "测试";
|
||||
System.out.println(StrUtil.format("备注:{}", description));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,10 +28,10 @@ spring:
|
||||
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
||||
redis:
|
||||
host: 127.0.0.1 # 地址
|
||||
port: 16379 # 端口(单元测试,使用 16379 端口)
|
||||
port: 6379 # 端口(单元测试,使用 16379 端口)
|
||||
database: 0 # 数据库索引
|
||||
|
||||
mybatis:
|
||||
mybatis-plus:
|
||||
lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试
|
||||
|
||||
# 芋道配置项,设置当前项目所有自定义的配置
|
||||
|
||||
@@ -162,6 +162,34 @@ public class MasterUserReqVO {
|
||||
@Schema(description = "头像")
|
||||
private String empPhoto;
|
||||
|
||||
/**
|
||||
* 所属部门ID
|
||||
*/
|
||||
@JsonProperty("dept_id")
|
||||
@Schema(description = "所属部门ID")
|
||||
private String deptId;
|
||||
|
||||
/**
|
||||
* 所属部门名称
|
||||
*/
|
||||
@JsonProperty("dept_name")
|
||||
@Schema(description = "所属部门名称")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 所属单位ID
|
||||
*/
|
||||
@JsonProperty("org_id")
|
||||
@Schema(description = "所属单位ID")
|
||||
private String orgId;
|
||||
|
||||
/**
|
||||
* 所属单位名称
|
||||
*/
|
||||
@JsonProperty("org_name")
|
||||
@Schema(description = "所属单位名称")
|
||||
private String orgName;
|
||||
|
||||
/**
|
||||
* 子用户数据
|
||||
*/
|
||||
|
||||
@@ -87,7 +87,7 @@ public class UserSyncServiceImpl implements IUserSyncService {
|
||||
try {
|
||||
UserSaveReqVO userSaveReqVO = new UserSaveReqVO()
|
||||
.setUsername(username).setNickname(md.getEmpName())
|
||||
.setRemark(md.getDescription()).setEmail(md.getEmail())
|
||||
.setRemark(getRemark(md)).setEmail(md.getEmail())
|
||||
.setMobile(md.getMobile()).setPassword(username)
|
||||
.setSex(Convert.toInt(md.getSex(), 0))
|
||||
.setTenantId(1L).setDeptInfoList(deptInfoList);
|
||||
@@ -102,7 +102,7 @@ public class UserSyncServiceImpl implements IUserSyncService {
|
||||
try {
|
||||
UserSaveReqVO userSaveReqVO = new UserSaveReqVO()
|
||||
.setId(adminUser.getId()).setUsername(username)
|
||||
.setNickname(md.getEmpName()).setRemark(md.getDescription())
|
||||
.setNickname(md.getEmpName()).setRemark(getRemark(md))
|
||||
.setEmail(md.getEmail()).setMobile(md.getMobile())
|
||||
.setSex(Convert.toInt(md.getSex(), 0))
|
||||
.setTenantId(1L);
|
||||
@@ -139,4 +139,29 @@ public class UserSyncServiceImpl implements IUserSyncService {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主数据用户信息生成备注信息
|
||||
* <p>
|
||||
* 将用户的相关信息格式化为字符串,主要用于运维关注的信息展示
|
||||
*
|
||||
* @param masterUser 主数据用户信息对象
|
||||
* @return 格式化后的备注信息字符串
|
||||
*/
|
||||
private String getRemark(MasterUserReqVO masterUser) {
|
||||
// 备注里放一些运维关心的信息
|
||||
String description = masterUser.getDescription();
|
||||
String personType = masterUser.getCuncPersonType();
|
||||
String locationAddress = masterUser.getLocationAddress();
|
||||
String orgName = masterUser.getOrgName();
|
||||
String deptName = masterUser.getDeptName();
|
||||
StringBuilder remark = new StringBuilder();
|
||||
if (StrUtil.isNotEmpty(description)) remark.append(StrUtil.format("备注:{}", description)).append("\n");
|
||||
if (StrUtil.isNotEmpty(personType)) remark.append(StrUtil.format("人员类型:{}", personType)).append("\n");
|
||||
if (StrUtil.isNotEmpty(locationAddress))
|
||||
remark.append(StrUtil.format("办公地址:{}", locationAddress)).append("\n");
|
||||
if (StrUtil.isNotEmpty(orgName)) remark.append(StrUtil.format("所属单位名称:{}", orgName)).append("\n");
|
||||
if (StrUtil.isNotEmpty(deptName)) remark.append(StrUtil.format("所属部门名称:{}", deptName)).append("\n");
|
||||
return remark.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.jeelowcode.tool.framework.test.core.ut;
|
||||
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
||||
import com.jeelowcode.tool.framework.datasource.config.DataSourceAutoConfiguration;
|
||||
import com.jeelowcode.tool.framework.mybatis.config.MybatisAutoConfiguration;
|
||||
import com.jeelowcode.tool.framework.redis.config.RedisAutoConfiguration;
|
||||
import com.jeelowcode.tool.framework.test.config.RedisTestConfiguration;
|
||||
import com.jeelowcode.tool.framework.test.config.SqlInitializationTestConfiguration;
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
||||
import org.redisson.spring.starter.RedissonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
/**
|
||||
* 依赖内存 DB + Redis 的单元测试
|
||||
@@ -22,8 +21,7 @@ import org.springframework.test.context.jdbc.Sql;
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbAndRedisUnitTest.Application.class)
|
||||
@ActiveProfiles("local") // 设置使用 application-unit-test 配置文件
|
||||
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB
|
||||
@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件
|
||||
public class BaseDbAndRedisUnitTest {
|
||||
|
||||
@Import({
|
||||
|
||||
Reference in New Issue
Block a user