fix: 调整 workspace member 响应结果增加 username

This commit is contained in:
zhangshuai
2024-09-05 13:54:19 +08:00
parent 0f4c12b38e
commit 90301ae75e
2 changed files with 11 additions and 9 deletions

View File

@@ -37,31 +37,31 @@ public class WorkspaceMemberServiceImpl extends ServiceImpl<WorkspaceMemberDao,
} }
@Override @Override
public List<WorkspaceMemberEntity> saveMember(String workspaceId, List<WorkspaceMemberEntity> workspaces) { public List<WorkspaceMemberEntity> saveMember(String workspaceId, List<WorkspaceMemberEntity> memberList) {
validateInfo(workspaceId, workspaces); validateInfo(workspaceId, memberList);
workspaceMemberService.saveBatch(workspaces); workspaceMemberService.saveBatch(memberList);
Map params = T.MapUtil.builder("workspaceId", workspaceId).build(); Map params = T.MapUtil.builder("workspaceId", workspaceId).build();
List<WorkspaceMemberEntity> memberEntityList = workspaceMemberService.queryList(params); List<WorkspaceMemberEntity> memberEntityList = workspaceMemberService.queryList(params);
return memberEntityList; return memberEntityList;
} }
@Override @Override
public List<WorkspaceMemberEntity> updateMember(String workspaceId, List<WorkspaceMemberEntity> workspaces) { public List<WorkspaceMemberEntity> updateMember(String workspaceId, List<WorkspaceMemberEntity> memberList) {
validateInfo(workspaceId, workspaces); validateInfo(workspaceId, memberList);
workspaceMemberService.remove(new LambdaQueryWrapper<WorkspaceMemberEntity>().eq(WorkspaceMemberEntity::getWorkspaceId, workspaceId)); workspaceMemberService.remove(new LambdaQueryWrapper<WorkspaceMemberEntity>().eq(WorkspaceMemberEntity::getWorkspaceId, workspaceId));
workspaceMemberService.saveBatch(workspaces); workspaceMemberService.saveBatch(memberList);
Map params = T.MapUtil.builder("workspaceId", workspaceId).build(); Map params = T.MapUtil.builder("workspaceId", workspaceId).build();
List<WorkspaceMemberEntity> memberEntityList = workspaceMemberService.queryList(params); List<WorkspaceMemberEntity> memberEntityList = workspaceMemberService.queryList(params);
return memberEntityList; return memberEntityList;
} }
private void validateInfo(String workspaceId, List<WorkspaceMemberEntity> workspaces) { private void validateInfo(String workspaceId, List<WorkspaceMemberEntity> memberList) {
if (T.StrUtil.equalsIgnoreCase(workspaceId, "1")) { if (T.StrUtil.equalsIgnoreCase(workspaceId, "1")) {
throw new ASWException(RCode.WORKSPACE_BUILT_IN); throw new ASWException(RCode.WORKSPACE_BUILT_IN);
} }
List<String> userIds = userService.list().stream().map(x -> x.getId()).toList(); List<String> userIds = userService.list().stream().map(x -> x.getId()).toList();
List<String> roleIds = roleService.list().stream().map(x -> x.getId()).toList(); List<String> roleIds = roleService.list().stream().map(x -> x.getId()).toList();
for (WorkspaceMemberEntity workspace : workspaces) { for (WorkspaceMemberEntity workspace : memberList) {
VerifyUtil.is(workspace).notNull() VerifyUtil.is(workspace).notNull()
.and(workspace.getUserId()).notEmpty(RCode.USER_ID_CANNOT_EMPTY) .and(workspace.getUserId()).notEmpty(RCode.USER_ID_CANNOT_EMPTY)
.and(workspace.getRoleId()).notEmpty(RCode.ROLE_ID_CANNOT_EMPTY); .and(workspace.getRoleId()).notEmpty(RCode.ROLE_ID_CANNOT_EMPTY);
@@ -72,7 +72,7 @@ public class WorkspaceMemberServiceImpl extends ServiceImpl<WorkspaceMemberDao,
throw new ASWException(RCode.ROLE_NOT_EXIST); throw new ASWException(RCode.ROLE_NOT_EXIST);
} }
} }
workspaces.stream().forEach(x -> { memberList.stream().forEach(x -> {
x.setWorkspaceId(workspaceId); x.setWorkspaceId(workspaceId);
x.setCreateUserId(StpUtil.getLoginIdAsString()); x.setCreateUserId(StpUtil.getLoginIdAsString());
x.setCreateTimestamp(System.currentTimeMillis()); x.setCreateTimestamp(System.currentTimeMillis());

View File

@@ -13,6 +13,7 @@
<association property="createUser" columnPrefix="cu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity"> <association property="createUser" columnPrefix="cu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
<id property="id" column="id"/> <id property="id" column="id"/>
<result property="name" column="name"/> <result property="name" column="name"/>
<result property="userName" column="user_name"/>
</association> </association>
<association property="user" columnPrefix="su_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity"> <association property="user" columnPrefix="su_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
@@ -36,6 +37,7 @@
wm.*, wm.*,
cu.id AS cu_id, cu.id AS cu_id,
cu.name AS cu_name, cu.name AS cu_name,
cu.user_name AS cu_user_name,
su.id AS su_id, su.id AS su_id,
su.name AS su_name, su.name AS su_name,
sr.id AS sr_id, sr.id AS sr_id,