This commit is contained in:
maimaishu
2026-01-12 11:06:07 +08:00
11 changed files with 132 additions and 60 deletions

View File

@@ -41,7 +41,7 @@ public class DatabusDeptProviderApiImpl implements DatabusDeptProviderApi {
public CommonResult<CursorPageResult<DatabusDeptData>> getPageByCursor(CursorPageReqDTO reqDTO) {
// 构建游标查询条件
LambdaQueryWrapper<DeptDO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DeptDO::getDeptSource, 3);
// 游标条件create_time > cursorTime OR (create_time = cursorTime AND id > cursorId)
if (!reqDTO.isFirstPage()) {
queryWrapper.and(w -> w
@@ -105,6 +105,7 @@ public class DatabusDeptProviderApiImpl implements DatabusDeptProviderApi {
Long total = null;
if (reqDTO.isFirstPage()) {
LambdaQueryWrapper<DeptDO> countWrapper = new LambdaQueryWrapper<>();
countWrapper.eq(DeptDO::getDeptSource, 3);
if (reqDTO.getTenantId() != null) {
countWrapper.eq(DeptDO::getTenantId, reqDTO.getTenantId());
}
@@ -175,6 +176,7 @@ public class DatabusDeptProviderApiImpl implements DatabusDeptProviderApi {
@Override
public CommonResult<Long> count(Long tenantId) {
LambdaQueryWrapper<DeptDO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DeptDO::getDeptSource, 3);
if (tenantId != null) {
queryWrapper.eq(DeptDO::getTenantId, tenantId);
}

View File

@@ -54,8 +54,8 @@ public class DatabusUserProviderApiImpl implements DatabusUserProviderApi {
// 构建游标查询条件
LambdaQueryWrapper<AdminUserDO> queryWrapper = new LambdaQueryWrapper<>();
// ⚠️ 只同步 userSource = 2 的用户
queryWrapper.eq(AdminUserDO::getUserSource, 2);
// ⚠️ 只同步 userSource = 3 的用户
queryWrapper.eq(AdminUserDO::getUserSource, 3);
// 游标条件create_time > cursorTime OR (create_time = cursorTime AND id > cursorId)
if (!reqDTO.isFirstPage()) {
@@ -103,8 +103,8 @@ public class DatabusUserProviderApiImpl implements DatabusUserProviderApi {
Long total = null;
if (reqDTO.isFirstPage()) {
LambdaQueryWrapper<AdminUserDO> countWrapper = new LambdaQueryWrapper<>();
// ⚠️ 只统计 userSource = 2 的用户
countWrapper.eq(AdminUserDO::getUserSource, 2);
// ⚠️ 只统计 userSource = 3 的用户
countWrapper.eq(AdminUserDO::getUserSource, 3);
if (reqDTO.getTenantId() != null) {
countWrapper.eq(AdminUserDO::getTenantId, reqDTO.getTenantId());
}
@@ -148,8 +148,8 @@ public class DatabusUserProviderApiImpl implements DatabusUserProviderApi {
@Override
public CommonResult<Long> count(Long tenantId) {
LambdaQueryWrapper<AdminUserDO> queryWrapper = new LambdaQueryWrapper<>();
// ⚠️ 只统计 userSource = 2 的用户
queryWrapper.eq(AdminUserDO::getUserSource, 2);
// ⚠️ 只统计 userSource = 3 的用户
queryWrapper.eq(AdminUserDO::getUserSource, 3);
if (tenantId != null) {
queryWrapper.eq(AdminUserDO::getTenantId, tenantId);
}

View File

@@ -58,6 +58,13 @@ public class UserRespVO{
@DictFormat(DictTypeConstants.USER_SEX)
private Integer sex;
@Schema(description = "用户来源,参见 UserSourceEnum 枚举类", example = "1")
private Integer userSource;
@Schema(description = "用户来源标签", example = "外部用户")
@ExcelProperty("用户来源")
private String userSourceLabel;
@Schema(description = "用户头像", example = "123456789")
private String avatar;

View File

@@ -12,6 +12,7 @@ import com.zt.plat.module.system.dal.dataobject.dept.DeptDO;
import com.zt.plat.module.system.dal.dataobject.dept.PostDO;
import com.zt.plat.module.system.dal.dataobject.permission.RoleDO;
import com.zt.plat.module.system.dal.dataobject.user.AdminUserDO;
import com.zt.plat.module.system.enums.user.UserSourceEnum;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@@ -32,6 +33,10 @@ public interface UserConvert {
default UserRespVO convert(AdminUserDO user) {
UserRespVO vo = BeanUtils.toBean(user, UserRespVO.class);
vo.setAvatar(user.getAvatar());
if (user.getUserSource() != null) {
UserSourceEnum sourceEnum = UserSourceEnum.of(user.getUserSource());
vo.setUserSourceLabel(sourceEnum != null ? sourceEnum.getName() : null);
}
if (user.getDeptIds() != null) {
vo.setDeptIds(CollectionUtils.convertList(user.getDeptIds(), Long::longValue));
}

View File

@@ -59,7 +59,7 @@ public interface UserDeptMapper extends BaseMapperX<UserDeptDO> {
@Select("<script>" +
"SELECT ud.* FROM system_user_dept ud " +
"INNER JOIN system_users u ON ud.user_id = u.id " +
"WHERE u.user_source = 2 " +
"WHERE u.user_source = 3 " +
"AND ud.deleted = 0 " +
"<if test='tenantId != null'> AND ud.tenant_id = #{tenantId} </if>" +
"<if test='cursorTime != null'>" +
@@ -75,17 +75,17 @@ public interface UserDeptMapper extends BaseMapperX<UserDeptDO> {
@Param("limit") Integer limit);
/**
* 统计用户-部门关系数量(只统计 userSource = 2 的用户)
* 统计用户-部门关系数量(只统计 userSource = 3 的用户)
* @param tenantId 租户ID可选
* @return 数量
*/
@Select("<script>" +
"SELECT COUNT(*) FROM system_user_dept ud " +
"INNER JOIN system_users u ON ud.user_id = u.id " +
"WHERE u.user_source = 2 " +
"WHERE u.user_source = 3 " +
"AND ud.deleted = 0 " +
"<if test='tenantId != null'> AND ud.tenant_id = #{tenantId} </if>" +
"</script>")
Long countWithUserSource(@Param("tenantId") Long tenantId);
}
}