Compare commits
No commits in common. "5855307c4651c9b6533455b3c404a99e6df437df" and "4a42e7ad5f6cdf1027137fbaaca26e6e120a867e" have entirely different histories.
5855307c46
...
4a42e7ad5f
|
|
@ -1,5 +0,0 @@
|
|||
-- 若已执行过仅含 code/name 的脚本,再执行本增量脚本补充角色ID
|
||||
-- 日期:2026-07-22
|
||||
|
||||
ALTER TABLE `org_position`
|
||||
ADD COLUMN `gbs_role_id` bigint DEFAULT NULL COMMENT '关联GBS角色ID' AFTER `duty_desc`;
|
||||
|
|
@ -1,234 +0,0 @@
|
|||
package org.qinan.safetyeval.adapter.web;
|
||||
|
||||
import com.alibaba.cola.dto.Response;
|
||||
import com.alibaba.cola.dto.SingleResponse;
|
||||
import com.jjb.saas.system.client.role.response.RoleCO;
|
||||
import com.jjb.saas.system.client.user.request.RoleDeptAddCmd;
|
||||
import com.jjb.saas.system.client.user.request.UserAppendRoleCmd;
|
||||
import com.jjb.saas.system.client.user.request.UserRoleUpdateCmd;
|
||||
import com.jjb.saas.system.client.user.response.UserDetailCO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.qinan.safetyeval.domain.exception.BizException;
|
||||
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserInfo;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.gbs.GbsRoleFacadeClient;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.gbs.GbsUserFacadeClient;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* GBS UserFacade / RoleFacade 联调测试(需携带登录 token,从 AuthContext 解析当前用户)。
|
||||
* <p>
|
||||
* 角色目标:code=f3efa93b2639429687dc7e4175500a74,名称=test02
|
||||
* </p>
|
||||
*/
|
||||
@Api(tags = "测试-GBS用户角色")
|
||||
@RestController
|
||||
@RequestMapping("/safetyEval/test/gbs-user")
|
||||
public class GbsUserFacadeTestController {
|
||||
|
||||
/** 目标角色编码(UserRoleUpdateCmd.roleCodes) */
|
||||
public static final String TARGET_ROLE_CODE = "f3efa93b2639429687dc7e4175500a74";
|
||||
|
||||
/** 目标角色名称(仅文档/回显,Cmd 无 name 字段传角色名) */
|
||||
public static final String TARGET_ROLE_NAME = "test02";
|
||||
|
||||
@Resource
|
||||
private GbsUserFacadeClient gbsUserFacadeClient;
|
||||
|
||||
@Resource
|
||||
private GbsRoleFacadeClient gbsRoleFacadeClient;
|
||||
|
||||
@Value("${auth.deptId.org:#{null}}")
|
||||
private Long defaultDeptId;
|
||||
|
||||
@ApiOperation("通过 token 查看当前登录用户(AuthContext)")
|
||||
@GetMapping("/current")
|
||||
public org.qinan.safetyeval.client.dto.SingleResponse<Map<String, Object>> current() {
|
||||
AuthUserInfo user = requireLogin();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("userId", user.getUserId());
|
||||
data.put("userName", user.getUserName());
|
||||
data.put("mobile", user.getMobile());
|
||||
data.put("account", user.getAccount());
|
||||
data.put("tenantId", user.getTenantId());
|
||||
data.put("orgId", user.getOrgId());
|
||||
return org.qinan.safetyeval.client.dto.SingleResponse.success(data);
|
||||
}
|
||||
|
||||
@ApiOperation("通过 token 拉取 GBS 用户详情(含角色)")
|
||||
@GetMapping("/detail")
|
||||
public org.qinan.safetyeval.client.dto.SingleResponse<UserDetailCO> detail() {
|
||||
AuthUserInfo user = requireLogin();
|
||||
SingleResponse<UserDetailCO> remote = gbsUserFacadeClient.getDetail(user.getUserId());
|
||||
return org.qinan.safetyeval.client.dto.SingleResponse.success(remote.getData());
|
||||
}
|
||||
|
||||
@ApiOperation("角色列表(RoleFacade.listRoles)")
|
||||
@GetMapping("/roles")
|
||||
public org.qinan.safetyeval.client.dto.SingleResponse<List<RoleCO>> listRoles() {
|
||||
requireLogin();
|
||||
return org.qinan.safetyeval.client.dto.SingleResponse.success(gbsRoleFacadeClient.listRoles());
|
||||
}
|
||||
|
||||
@ApiOperation("按角色编码查名称(RoleFacade.getRoleNameByCode)")
|
||||
@GetMapping("/role-name")
|
||||
public org.qinan.safetyeval.client.dto.SingleResponse<Map<String, Object>> roleNameByCode(
|
||||
@ApiParam(value = "角色编码", example = TARGET_ROLE_CODE)
|
||||
@RequestParam(value = "roleCode", required = false) String roleCode) {
|
||||
requireLogin();
|
||||
String code = (roleCode == null || roleCode.trim().isEmpty()) ? TARGET_ROLE_CODE : roleCode.trim();
|
||||
String name = gbsRoleFacadeClient.getRoleNameByCode(code);
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("roleCode", code);
|
||||
data.put("roleName", name);
|
||||
return org.qinan.safetyeval.client.dto.SingleResponse.success(data);
|
||||
}
|
||||
|
||||
@ApiOperation("将当前用户角色更新为 test02(覆盖式,roleCode=f3efa93b2639429687dc7e4175500a74)")
|
||||
@PostMapping("/update-role-to-test02")
|
||||
public org.qinan.safetyeval.client.dto.SingleResponse<Map<String, Object>> updateRoleToTest02() {
|
||||
AuthUserInfo user = requireLogin();
|
||||
UserRoleUpdateCmd cmd = buildRoleUpdateCmd(user, TARGET_ROLE_CODE);
|
||||
Response response = gbsUserFacadeClient.updateUserRole(cmd);
|
||||
return org.qinan.safetyeval.client.dto.SingleResponse.success(
|
||||
roleOpResult(response, user, TARGET_ROLE_CODE, TARGET_ROLE_NAME, "updateUserRole"));
|
||||
}
|
||||
|
||||
@ApiOperation("更新当前用户角色(覆盖式;roleCode 必填,roleName 仅回显)")
|
||||
@PostMapping("/update-role")
|
||||
public org.qinan.safetyeval.client.dto.SingleResponse<Map<String, Object>> updateRole(
|
||||
@ApiParam(value = "角色编码", required = true, example = TARGET_ROLE_CODE)
|
||||
@RequestParam("roleCode") String roleCode,
|
||||
@ApiParam(value = "角色名称(仅回显,不参与 GBS 更新)", example = TARGET_ROLE_NAME)
|
||||
@RequestParam(value = "roleName", required = false) String roleName) {
|
||||
AuthUserInfo user = requireLogin();
|
||||
if (roleCode == null || roleCode.trim().isEmpty()) {
|
||||
throw new BizException(ErrorCode.UNKNOWN_ERROR.getCode(), "roleCode 不能为空");
|
||||
}
|
||||
String code = roleCode.trim();
|
||||
String name = (roleName == null || roleName.trim().isEmpty()) ? null : roleName.trim();
|
||||
UserRoleUpdateCmd cmd = buildRoleUpdateCmd(user, code);
|
||||
Response response = gbsUserFacadeClient.updateUserRole(cmd);
|
||||
return org.qinan.safetyeval.client.dto.SingleResponse.success(
|
||||
roleOpResult(response, user, code, name, "updateUserRole"));
|
||||
}
|
||||
|
||||
@ApiOperation("追加角色 test02(按 roleCodes,UserFacade.updateUserAppendRole)")
|
||||
@PostMapping("/append-role-to-test02")
|
||||
public org.qinan.safetyeval.client.dto.SingleResponse<Map<String, Object>> appendRoleToTest02() {
|
||||
AuthUserInfo user = requireLogin();
|
||||
UserRoleUpdateCmd cmd = buildRoleUpdateCmd(user, TARGET_ROLE_CODE);
|
||||
Response response = gbsUserFacadeClient.updateUserAppendRole(cmd);
|
||||
return org.qinan.safetyeval.client.dto.SingleResponse.success(
|
||||
roleOpResult(response, user, TARGET_ROLE_CODE, TARGET_ROLE_NAME, "updateUserAppendRole"));
|
||||
}
|
||||
|
||||
@ApiOperation("追加角色(按 roleDepts,UserFacade.appendUserRole;默认角色 test02)")
|
||||
@PostMapping("/append-user-role")
|
||||
public org.qinan.safetyeval.client.dto.SingleResponse<Map<String, Object>> appendUserRole(
|
||||
@ApiParam(value = "角色编码,默认 test02 的 code")
|
||||
@RequestParam(value = "roleCode", required = false) String roleCode,
|
||||
@ApiParam(value = "部门id,默认 auth.deptId.org,其次当前用户 orgId")
|
||||
@RequestParam(value = "deptId", required = false) Long deptId) {
|
||||
AuthUserInfo user = requireLogin();
|
||||
String code = resolveRoleCode(roleCode);
|
||||
Long resolvedDeptId = resolveDeptId(user, deptId);
|
||||
|
||||
UserAppendRoleCmd cmd = new UserAppendRoleCmd();
|
||||
cmd.setId(user.getUserId());
|
||||
RoleDeptAddCmd roleDept = new RoleDeptAddCmd();
|
||||
roleDept.setRoleCode(code);
|
||||
roleDept.setDeptId(resolvedDeptId);
|
||||
cmd.setRoleDepts(Collections.singletonList(roleDept));
|
||||
|
||||
Response response = gbsUserFacadeClient.appendUserRole(cmd);
|
||||
Map<String, Object> data = roleOpResult(response, user, code,
|
||||
TARGET_ROLE_CODE.equals(code) ? TARGET_ROLE_NAME : null, "appendUserRole");
|
||||
data.put("deptId", resolvedDeptId);
|
||||
return org.qinan.safetyeval.client.dto.SingleResponse.success(data);
|
||||
}
|
||||
|
||||
@ApiOperation("追加角色按编码(UserFacade.appendUserRoleByRoleCode;默认角色 test02)")
|
||||
@PostMapping("/append-user-role-by-code")
|
||||
public org.qinan.safetyeval.client.dto.SingleResponse<Map<String, Object>> appendUserRoleByRoleCode(
|
||||
@ApiParam(value = "角色编码,默认 test02 的 code")
|
||||
@RequestParam(value = "roleCode", required = false) String roleCode,
|
||||
@ApiParam(value = "部门id,默认 auth.deptId.org,其次当前用户 orgId")
|
||||
@RequestParam(value = "deptId", required = false) Long deptId) {
|
||||
AuthUserInfo user = requireLogin();
|
||||
String code = resolveRoleCode(roleCode);
|
||||
Long resolvedDeptId = resolveDeptId(user, deptId);
|
||||
|
||||
UserAppendRoleCmd cmd = new UserAppendRoleCmd();
|
||||
cmd.setId(user.getUserId());
|
||||
RoleDeptAddCmd roleDept = new RoleDeptAddCmd();
|
||||
roleDept.setRoleCode(code);
|
||||
roleDept.setDeptId(resolvedDeptId);
|
||||
cmd.setRoleDepts(Collections.singletonList(roleDept));
|
||||
|
||||
Response response = gbsUserFacadeClient.appendUserRoleByRoleCode(cmd);
|
||||
Map<String, Object> data = roleOpResult(response, user, code,
|
||||
TARGET_ROLE_CODE.equals(code) ? TARGET_ROLE_NAME : null, "appendUserRoleByRoleCode");
|
||||
data.put("deptId", resolvedDeptId);
|
||||
return org.qinan.safetyeval.client.dto.SingleResponse.success(data);
|
||||
}
|
||||
|
||||
private UserRoleUpdateCmd buildRoleUpdateCmd(AuthUserInfo user, String roleCode) {
|
||||
UserRoleUpdateCmd cmd = new UserRoleUpdateCmd();
|
||||
cmd.setId(user.getUserId());
|
||||
cmd.setName(user.getUserName());
|
||||
cmd.setMobile(user.getMobile());
|
||||
cmd.setRoleCodes(Collections.singletonList(roleCode));
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private Map<String, Object> roleOpResult(Response response, AuthUserInfo user,
|
||||
String roleCode, String roleName, String api) {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("api", api);
|
||||
data.put("success", response.isSuccess());
|
||||
data.put("userId", user.getUserId());
|
||||
data.put("userName", user.getUserName());
|
||||
data.put("roleCode", roleCode);
|
||||
data.put("roleName", roleName);
|
||||
data.put("errCode", response.getErrCode());
|
||||
data.put("errMessage", response.getErrMessage());
|
||||
return data;
|
||||
}
|
||||
|
||||
private String resolveRoleCode(String roleCode) {
|
||||
return (roleCode == null || roleCode.trim().isEmpty()) ? TARGET_ROLE_CODE : roleCode.trim();
|
||||
}
|
||||
|
||||
private Long resolveDeptId(AuthUserInfo user, Long deptId) {
|
||||
if (deptId != null) {
|
||||
return deptId;
|
||||
}
|
||||
if (defaultDeptId != null) {
|
||||
return defaultDeptId;
|
||||
}
|
||||
return user.getOrgId();
|
||||
}
|
||||
|
||||
private AuthUserInfo requireLogin() {
|
||||
AuthUserInfo user = AuthUserContextAdapter.getCurrentUser();
|
||||
if (user == null || user.getUserId() == null) {
|
||||
throw new BizException(ErrorCode.UNKNOWN_ERROR.getCode(), "未登录或 token 无效,无法获取当前用户");
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import io.swagger.annotations.Api;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.qinan.safetyeval.client.api.OrgPositionApi;
|
||||
import org.qinan.safetyeval.client.co.GbsRoleOptionCO;
|
||||
import org.qinan.safetyeval.client.co.OrgPositionCO;
|
||||
import org.qinan.safetyeval.client.dto.*;
|
||||
import org.qinan.safetyeval.infrastructure.dataobject.base.Req;
|
||||
|
|
@ -12,7 +11,6 @@ import org.springframework.validation.annotation.Validated;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 岗位适配层(Controller)
|
||||
|
|
@ -56,16 +54,4 @@ public class OrgPositionController {
|
|||
public PageResponse<OrgPositionCO> page(@Validated OrgPositionPageQuery query) {
|
||||
return orgPositionApi.page(query);
|
||||
}
|
||||
|
||||
@ApiOperation("分配GBS角色(若岗位有人员则依次同步其GBS角色)")
|
||||
@PostMapping("/assign-gbs-role")
|
||||
public SingleResponse<OrgPositionCO> assignGbsRole(@Validated @RequestBody OrgPositionAssignGbsRoleCmd cmd) {
|
||||
return orgPositionApi.assignGbsRole(cmd);
|
||||
}
|
||||
|
||||
@ApiOperation("GBS角色列表(分配角色下拉)")
|
||||
@GetMapping("/gbs-roles")
|
||||
public SingleResponse<List<GbsRoleOptionCO>> listGbsRoles() {
|
||||
return orgPositionApi.listGbsRoles();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.qinan.safetyeval.app.executor;
|
||||
|
||||
import com.jjb.saas.system.client.user.request.UserAddCmd;
|
||||
import com.jjb.saas.system.client.user.request.UserRoleUpdateCmd;
|
||||
import com.jjb.saas.system.client.user.request.UserUpdatePasswordCmd;
|
||||
import com.zcloud.gbscommon.utils.MD5;
|
||||
import com.zcloud.gbscommon.utils.Sm2Util;
|
||||
|
|
@ -12,14 +11,12 @@ import org.qinan.safetyeval.client.api.OrgPersonnelApi;
|
|||
import org.qinan.safetyeval.client.co.OrgPersonnelCO;
|
||||
import org.qinan.safetyeval.client.dto.*;
|
||||
import org.qinan.safetyeval.domain.entity.OrgPersonnelEntity;
|
||||
import org.qinan.safetyeval.domain.entity.OrgPositionEntity;
|
||||
import org.qinan.safetyeval.domain.exception.BizException;
|
||||
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
||||
import org.qinan.safetyeval.domain.gateway.OrgResignApplyGateway;
|
||||
import org.qinan.safetyeval.domain.query.OrgPersonnelQuery;
|
||||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.domain.service.OrgPersonnelDomainService;
|
||||
import org.qinan.safetyeval.domain.service.OrgPositionDomainService;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.ThreadLocalUserInfoAdapter;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.gbs.GbsUserFacadeClient;
|
||||
|
|
@ -30,11 +27,8 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 人员信息执行器(App层)
|
||||
|
|
@ -63,9 +57,6 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
|
|||
@Autowired
|
||||
private GbsUserFacadeClient gbsUserFacadeClient;
|
||||
|
||||
@Autowired(required = false)
|
||||
private OrgPositionDomainService orgPositionDomainService;
|
||||
|
||||
@Value("${def.password:a123456}")
|
||||
private String defPassword;
|
||||
@Value("${def.publicKey:0402df2195296d4062ac85ad766994d73e871b887e18efb9a9a06b4cebc72372869b7da6c347c129dee2b46a0f279ff066b01c76208c2a052af75977c722a2ccee}")
|
||||
|
|
@ -90,12 +81,8 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
|
|||
userAddCmd.setName(result.getUserName());
|
||||
String encrypt = Sm2Util.encryptHex(MD5.md5(defPassword), publicKey);
|
||||
userAddCmd.setPassword(encrypt);
|
||||
OrgPositionEntity gbsRolePosition = resolveGbsRolePositionByPostId(result.getPostId());
|
||||
Long gbsRoleId = gbsRolePosition == null ? null : gbsRolePosition.getGbsRoleId();
|
||||
String gbsRoleCode = gbsRolePosition == null || !StringUtils.hasText(gbsRolePosition.getGbsRoleCode())
|
||||
? null : gbsRolePosition.getGbsRoleCode().trim();
|
||||
try {
|
||||
gbsUserFacadeClient.add(userAddCmd, gbsRoleId, gbsRoleCode);
|
||||
gbsUserFacadeClient.add(userAddCmd);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.warn("GBS user sync failed while adding personnel", ex);
|
||||
if (gbsUserSyncFailFast) {
|
||||
|
|
@ -121,11 +108,6 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
|
|||
entity.setId(cmd.getId());
|
||||
OrgPersonnelEntity result = orgPersonnelDomainService.modify(entity);
|
||||
orgPersonnelChangeRecorder.recordChanges(existing, result);
|
||||
// 岗位变更且新岗位已关联 GBS 角色时,同步该人员 GBS 角色
|
||||
if (result != null && !Objects.equals(
|
||||
existing == null ? null : existing.getPostId(), result.getPostId())) {
|
||||
syncPersonGbsRoleByPost(result);
|
||||
}
|
||||
OrgPersonnelCO co = orgPersonnelConvertor.toCO(result);
|
||||
enrich(co);
|
||||
return SingleResponse.success(co);
|
||||
|
|
@ -192,40 +174,6 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void syncPersonGbsRoleByPost(OrgPersonnelEntity person) {
|
||||
if (person == null || person.getPostId() == null || orgPositionDomainService == null) {
|
||||
return;
|
||||
}
|
||||
OrgPositionEntity position = orgPositionDomainService.get(person.getPostId());
|
||||
if (position == null || !StringUtils.hasText(position.getGbsRoleCode())) {
|
||||
return;
|
||||
}
|
||||
UserRoleUpdateCmd cmd = new UserRoleUpdateCmd();
|
||||
cmd.setId(person.getId());
|
||||
cmd.setName(person.getUserName());
|
||||
cmd.setMobile(person.getAccount());
|
||||
cmd.setRoleCodes(Collections.singletonList(position.getGbsRoleCode()));
|
||||
syncGbsUser("update personnel role by post", () -> gbsUserFacadeClient.updateUserRole(cmd));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按岗位解析已关联的 GBS 角色;无岗位或未关联时返回 null(创建用户走默认角色)。
|
||||
*/
|
||||
private OrgPositionEntity resolveGbsRolePositionByPostId(Long postId) {
|
||||
if (postId == null || orgPositionDomainService == null) {
|
||||
return null;
|
||||
}
|
||||
OrgPositionEntity position = orgPositionDomainService.get(postId);
|
||||
if (position == null) {
|
||||
return null;
|
||||
}
|
||||
if (position.getGbsRoleId() == null && !StringUtils.hasText(position.getGbsRoleCode())) {
|
||||
return null;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
private void enrich(OrgPersonnelCO co) {
|
||||
if (orgPersonnelViewEnricher != null) {
|
||||
orgPersonnelViewEnricher.enrichPersonnel(co);
|
||||
|
|
|
|||
|
|
@ -1,40 +1,21 @@
|
|||
package org.qinan.safetyeval.app.executor;
|
||||
|
||||
import com.jjb.saas.system.client.role.response.RoleCO;
|
||||
import com.jjb.saas.system.client.user.request.UserRoleUpdateCmd;
|
||||
import org.qinan.safetyeval.client.api.OrgPositionApi;
|
||||
import org.qinan.safetyeval.client.co.GbsRoleOptionCO;
|
||||
import org.qinan.safetyeval.client.co.OrgPositionCO;
|
||||
import org.qinan.safetyeval.client.dto.OrgPositionAddCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgPositionAssignGbsRoleCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgPositionModifyCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgPositionPageQuery;
|
||||
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||
import org.qinan.safetyeval.domain.entity.OrgPersonnelEntity;
|
||||
import org.qinan.safetyeval.client.co.OrgPositionCO;
|
||||
import org.qinan.safetyeval.client.dto.OrgPositionAddCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgPositionModifyCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgPositionPageQuery;
|
||||
import org.qinan.safetyeval.domain.entity.OrgPositionEntity;
|
||||
import org.qinan.safetyeval.domain.exception.BizException;
|
||||
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
||||
import org.qinan.safetyeval.domain.gateway.OrgPersonnelGateway;
|
||||
import org.qinan.safetyeval.domain.query.OrgPositionQuery;
|
||||
import org.qinan.safetyeval.domain.query.PageResult;
|
||||
import org.qinan.safetyeval.domain.service.OrgPositionDomainService;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.ThreadLocalUserInfoAdapter;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.gbs.GbsRoleFacadeClient;
|
||||
import org.qinan.safetyeval.infrastructure.adapter.gbs.GbsUserFacadeClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 岗位执行器(App层)
|
||||
|
|
@ -44,24 +25,10 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class OrgPositionExecutor implements OrgPositionApi {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OrgPositionExecutor.class);
|
||||
|
||||
@Lazy
|
||||
@Autowired(required = false)
|
||||
private OrgPositionDomainService orgPositionDomainService;
|
||||
|
||||
@Autowired
|
||||
private OrgPersonnelGateway orgPersonnelGateway;
|
||||
|
||||
@Autowired
|
||||
private GbsUserFacadeClient gbsUserFacadeClient;
|
||||
|
||||
@Autowired
|
||||
private GbsRoleFacadeClient gbsRoleFacadeClient;
|
||||
|
||||
@Value("${safety-eval.gbs-user-sync.fail-fast:true}")
|
||||
private boolean gbsUserSyncFailFast;
|
||||
|
||||
@Override
|
||||
public SingleResponse<OrgPositionCO> add(OrgPositionAddCmd cmd) {
|
||||
OrgPositionEntity entity = new OrgPositionEntity();
|
||||
|
|
@ -90,10 +57,6 @@ public class OrgPositionExecutor implements OrgPositionApi {
|
|||
entity.setRemark(cmd.getRemark());
|
||||
|
||||
OrgPositionEntity result = orgPositionDomainService.modify(entity);
|
||||
// 岗位已关联 GBS 角色且存在人员时,同步人员 GBS 角色
|
||||
if (result != null && (result.getGbsRoleId() != null || StringUtils.hasText(result.getGbsRoleCode()))) {
|
||||
syncPersonnelGbsRoles(result.getId(), result.getGbsRoleCode());
|
||||
}
|
||||
return SingleResponse.success(toCO(result));
|
||||
}
|
||||
|
||||
|
|
@ -118,115 +81,10 @@ public class OrgPositionExecutor implements OrgPositionApi {
|
|||
return PageResponse.of(
|
||||
pageResult.getRecords().stream()
|
||||
.map(this::toCO)
|
||||
.collect(Collectors.toList()),
|
||||
.collect(java.util.stream.Collectors.toList()),
|
||||
pageResult.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse<OrgPositionCO> assignGbsRole(OrgPositionAssignGbsRoleCmd cmd) {
|
||||
if (cmd == null || cmd.getId() == null) {
|
||||
throw new BizException(ErrorCode.ORG_POSITION_NOT_FOUND);
|
||||
}
|
||||
if (cmd.getGbsRoleId() == null) {
|
||||
throw new BizException(ErrorCode.ORG_POSITION_GBS_ROLE_REQUIRED);
|
||||
}
|
||||
if (!StringUtils.hasText(cmd.getGbsRoleCode())) {
|
||||
throw new BizException(ErrorCode.ORG_POSITION_GBS_ROLE_REQUIRED);
|
||||
}
|
||||
OrgPositionEntity existing = orgPositionDomainService.get(cmd.getId());
|
||||
if (existing == null) {
|
||||
throw new BizException(ErrorCode.ORG_POSITION_NOT_FOUND);
|
||||
}
|
||||
|
||||
Long roleId = cmd.getGbsRoleId();
|
||||
String roleCode = cmd.getGbsRoleCode().trim();
|
||||
String roleName = StringUtils.hasText(cmd.getGbsRoleName()) ? cmd.getGbsRoleName().trim() : null;
|
||||
if (!StringUtils.hasText(roleName)) {
|
||||
try {
|
||||
roleName = gbsRoleFacadeClient.getRoleNameByCode(roleCode);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.warn("resolve gbs role name by code failed, code={}", roleCode, ex);
|
||||
}
|
||||
}
|
||||
|
||||
OrgPositionEntity toUpdate = new OrgPositionEntity();
|
||||
toUpdate.setId(existing.getId());
|
||||
toUpdate.setDeptId(existing.getDeptId());
|
||||
toUpdate.setPositionName(existing.getPositionName());
|
||||
toUpdate.setDutyDesc(existing.getDutyDesc());
|
||||
toUpdate.setRemark(existing.getRemark());
|
||||
toUpdate.setOrgId(existing.getOrgId());
|
||||
toUpdate.setTenantId(existing.getTenantId());
|
||||
toUpdate.setGbsRoleId(roleId);
|
||||
toUpdate.setGbsRoleCode(roleCode);
|
||||
toUpdate.setGbsRoleName(roleName);
|
||||
|
||||
OrgPositionEntity result = orgPositionDomainService.modify(toUpdate);
|
||||
syncPersonnelGbsRoles(result.getId(), roleCode);
|
||||
return SingleResponse.success(toCO(result));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingleResponse<List<GbsRoleOptionCO>> listGbsRoles() {
|
||||
List<RoleCO> roles = gbsRoleFacadeClient.listRoles();
|
||||
List<GbsRoleOptionCO> options = new ArrayList<GbsRoleOptionCO>();
|
||||
if (roles != null) {
|
||||
for (RoleCO role : roles) {
|
||||
if (role == null) {
|
||||
continue;
|
||||
}
|
||||
GbsRoleOptionCO option = new GbsRoleOptionCO();
|
||||
option.setRoleId(role.getId());
|
||||
option.setRoleCode(role.getRoleCode());
|
||||
option.setRoleName(role.getRoleName());
|
||||
options.add(option);
|
||||
}
|
||||
}
|
||||
return SingleResponse.success(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 依次将岗位下人员的 GBS 角色更新为指定编码。
|
||||
* GBS UserFacade 无批量改角色接口,故逐人调用 updateUserRole。
|
||||
*/
|
||||
private void syncPersonnelGbsRoles(Long positionId, String gbsRoleCode) {
|
||||
if (positionId == null || !StringUtils.hasText(gbsRoleCode)) {
|
||||
return;
|
||||
}
|
||||
List<OrgPersonnelEntity> personnelList = orgPersonnelGateway.listByPostId(positionId);
|
||||
if (personnelList == null || personnelList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<UserRoleUpdateCmd> cmds = new ArrayList<UserRoleUpdateCmd>();
|
||||
for (OrgPersonnelEntity person : personnelList) {
|
||||
if (person == null || person.getId() == null) {
|
||||
continue;
|
||||
}
|
||||
UserRoleUpdateCmd cmd = new UserRoleUpdateCmd();
|
||||
cmd.setId(person.getId());
|
||||
cmd.setName(person.getUserName());
|
||||
// GBS mobile 字段在本系统通常对应账号
|
||||
cmd.setMobile(person.getAccount());
|
||||
cmd.setRoleCodes(Collections.singletonList(gbsRoleCode));
|
||||
cmds.add(cmd);
|
||||
}
|
||||
if (cmds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
gbsUserFacadeClient.updateUserRolesSequentially(cmds);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.warn("sync personnel gbs roles failed, positionId={}, roleCode={}, size={}",
|
||||
positionId, gbsRoleCode, cmds.size(), ex);
|
||||
if (gbsUserSyncFailFast) {
|
||||
if (ex instanceof BizException) {
|
||||
throw (BizException) ex;
|
||||
}
|
||||
throw new BizException(ErrorCode.ORG_POSITION_GBS_ROLE_SYNC_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private OrgPositionCO toCO(OrgPositionEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
|
|
@ -236,9 +94,6 @@ public class OrgPositionExecutor implements OrgPositionApi {
|
|||
co.setDeptId(entity.getDeptId());
|
||||
co.setPositionName(entity.getPositionName());
|
||||
co.setDutyDesc(entity.getDutyDesc());
|
||||
co.setGbsRoleId(entity.getGbsRoleId());
|
||||
co.setGbsRoleCode(entity.getGbsRoleCode());
|
||||
co.setGbsRoleName(entity.getGbsRoleName());
|
||||
co.setRemark(entity.getRemark());
|
||||
co.setTenantId(entity.getTenantId());
|
||||
return co;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package org.qinan.safetyeval.client.api;
|
||||
|
||||
import org.qinan.safetyeval.client.co.OrgPositionCO;
|
||||
import org.qinan.safetyeval.client.co.GbsRoleOptionCO;
|
||||
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||
import org.qinan.safetyeval.client.dto.OrgPositionAddCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgPositionAssignGbsRoleCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgPositionModifyCmd;
|
||||
import org.qinan.safetyeval.client.dto.OrgPositionPageQuery;
|
||||
|
||||
|
|
@ -25,14 +23,4 @@ public interface OrgPositionApi {
|
|||
SingleResponse<Void> delete(Long id);
|
||||
|
||||
PageResponse<OrgPositionCO> page(OrgPositionPageQuery query);
|
||||
|
||||
/**
|
||||
* 为岗位分配 GBS 角色;若岗位下有人员则依次更新其 GBS 角色。
|
||||
*/
|
||||
SingleResponse<OrgPositionCO> assignGbsRole(OrgPositionAssignGbsRoleCmd cmd);
|
||||
|
||||
/**
|
||||
* 拉取 GBS 角色列表(供分配角色下拉)。
|
||||
*/
|
||||
SingleResponse<java.util.List<GbsRoleOptionCO>> listGbsRoles();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,15 +23,6 @@ public class OrgPositionCO {
|
|||
@ApiModelProperty(value = "职责描述")
|
||||
private String dutyDesc;
|
||||
|
||||
@ApiModelProperty(value = "关联GBS角色ID")
|
||||
private Long gbsRoleId;
|
||||
|
||||
@ApiModelProperty(value = "关联GBS角色编码")
|
||||
private String gbsRoleCode;
|
||||
|
||||
@ApiModelProperty(value = "关联GBS角色名称")
|
||||
private String gbsRoleName;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,15 +25,6 @@ public class OrgPositionEntity {
|
|||
/** 岗位职责 */
|
||||
private String dutyDesc;
|
||||
|
||||
/** 关联 GBS 角色ID */
|
||||
private Long gbsRoleId;
|
||||
|
||||
/** 关联 GBS 角色编码 */
|
||||
private String gbsRoleCode;
|
||||
|
||||
/** 关联 GBS 角色名称 */
|
||||
private String gbsRoleName;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ public enum ErrorCode {
|
|||
|
||||
// ---- 岗位 ----
|
||||
ORG_POSITION_NOT_FOUND("01-08-001", "岗位不存在"),
|
||||
ORG_POSITION_GBS_ROLE_REQUIRED("01-08-002", "岗位关联GBS角色编码不能为空"),
|
||||
ORG_POSITION_GBS_ROLE_SYNC_ERROR("01-08-003", "岗位关联人员GBS角色同步失败"),
|
||||
|
||||
// ---- 机构资质证书 ----
|
||||
ORG_QUALIFICATION_NOT_FOUND("01-09-001", "机构资质证书不存在"),
|
||||
|
|
|
|||
|
|
@ -30,9 +30,4 @@ public interface OrgPersonnelGateway {
|
|||
PageResult<OrgPersonnelEntity> page(OrgPersonnelQuery query);
|
||||
|
||||
OrgPersonnelEntity findAnyByIdCardNo(String idCardNo);
|
||||
|
||||
/**
|
||||
* 查询岗位下未删除人员(post_id = positionId)。
|
||||
*/
|
||||
java.util.List<OrgPersonnelEntity> listByPostId(Long postId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
package org.qinan.safetyeval.infrastructure.adapter.gbs;
|
||||
|
||||
import com.alibaba.cola.dto.MultiResponse;
|
||||
import com.alibaba.cola.dto.SingleResponse;
|
||||
import com.jjb.saas.system.client.role.facade.RoleFacade;
|
||||
import com.jjb.saas.system.client.role.response.RoleCO;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.qinan.safetyeval.domain.exception.BizException;
|
||||
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* GBS {@link RoleFacade} 适配(与 UserFacade 同属 jjb-saas-system)。
|
||||
*/
|
||||
@Component
|
||||
public class GbsRoleFacadeClient {
|
||||
|
||||
@DubboReference(protocol = "dubbo", url = "${safety-eval.gbs-user-sync.user-facade-url:}")
|
||||
private RoleFacade roleFacade;
|
||||
|
||||
/**
|
||||
* 获取角色列表(全量)。
|
||||
*/
|
||||
public List<RoleCO> listRoles() {
|
||||
MultiResponse<RoleCO> response = roleFacade.listRoles();
|
||||
if (response == null || !response.isSuccess()) {
|
||||
String errCode = response == null ? ErrorCode.UNKNOWN_ERROR.getCode() : response.getErrCode();
|
||||
String errMsg = response == null ? "listRoles 无响应" : response.getErrMessage();
|
||||
throw new BizException(errCode, errMsg);
|
||||
}
|
||||
List<RoleCO> data = response.getData();
|
||||
return data == null ? Collections.<RoleCO>emptyList() : data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按用户+部门查询角色。
|
||||
*/
|
||||
public List<RoleCO> listByUserIdAndDeptId(Long userId, Long deptId) {
|
||||
MultiResponse<RoleCO> response = roleFacade.listByUserIdAndDeptId(userId, deptId);
|
||||
if (response == null || !response.isSuccess()) {
|
||||
String errCode = response == null ? ErrorCode.UNKNOWN_ERROR.getCode() : response.getErrCode();
|
||||
String errMsg = response == null ? "listByUserIdAndDeptId 无响应" : response.getErrMessage();
|
||||
throw new BizException(errCode, errMsg);
|
||||
}
|
||||
List<RoleCO> data = response.getData();
|
||||
return data == null ? Collections.<RoleCO>emptyList() : data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按角色编码查名称。
|
||||
*/
|
||||
public String getRoleNameByCode(String roleCode) {
|
||||
SingleResponse<String> response = roleFacade.getRoleNameByCode(roleCode);
|
||||
if (response == null || !response.isSuccess()) {
|
||||
String errCode = response == null ? ErrorCode.UNKNOWN_ERROR.getCode() : response.getErrCode();
|
||||
String errMsg = response == null ? "getRoleNameByCode 无响应" : response.getErrMessage();
|
||||
throw new BizException(errCode, errMsg);
|
||||
}
|
||||
return response.getData();
|
||||
}
|
||||
}
|
||||
|
|
@ -29,31 +29,12 @@ public class GbsUserFacadeClient {
|
|||
private Long roleId;
|
||||
|
||||
|
||||
/**
|
||||
* 创建 GBS 用户,使用配置默认角色 {@code auth.roleId.org}。
|
||||
*/
|
||||
public Integer add(UserAddCmd cmd) {
|
||||
return add(cmd, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 GBS 用户。
|
||||
*
|
||||
* @param gbsRoleId 岗位关联角色ID,可与编码同时传入
|
||||
* @param gbsRoleCode 岗位关联角色编码;id/code 皆空时使用默认 roleId
|
||||
*/
|
||||
public Integer add(UserAddCmd cmd, Long gbsRoleId, String gbsRoleCode) {
|
||||
//2069596397920849920{key: "1782463085576", deptId: "2069596397920849920", roleId: "2069671307598893058"}
|
||||
List<RoleDeptAddCmd> list = new ArrayList<>();
|
||||
RoleDeptAddCmd roleDeptAddCmd = new RoleDeptAddCmd();
|
||||
roleDeptAddCmd.setDeptId(deptId);
|
||||
boolean hasRoleId = gbsRoleId != null;
|
||||
boolean hasRoleCode = gbsRoleCode != null && !gbsRoleCode.trim().isEmpty();
|
||||
if (hasRoleId || hasRoleCode) {
|
||||
roleDeptAddCmd.setRoleId(gbsRoleId);
|
||||
roleDeptAddCmd.setRoleCode(gbsRoleCode);
|
||||
} else {
|
||||
roleDeptAddCmd.setRoleId(roleId);
|
||||
}
|
||||
list.add(roleDeptAddCmd);
|
||||
cmd.setRoleDepts(list);
|
||||
try {
|
||||
|
|
@ -93,87 +74,4 @@ public class GbsUserFacadeClient {
|
|||
public void updateStatusEnumBatch(FacadeUserUpdateStatusEnumBatchCmd cmd) {
|
||||
userFacade.updateStatusEnumBatch(cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户角色(覆盖式,对应 {@link UserFacade#updateUserRole})。
|
||||
* <p>GBS 无批量改角色接口时,请使用 {@link #updateUserRolesSequentially} 逐人调用。</p>
|
||||
*/
|
||||
public Response updateUserRole(UserRoleUpdateCmd cmd) {
|
||||
Response response = userFacade.updateUserRole(cmd);
|
||||
if (response == null || !response.isSuccess()) {
|
||||
String errCode = response == null ? ErrorCode.UNKNOWN_ERROR.getCode() : response.getErrCode();
|
||||
String errMsg = response == null ? "updateUserRole 无响应" : response.getErrMessage();
|
||||
throw new BizException(errCode, errMsg);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 依次更新多名用户角色。UserFacade 当前无批量改角色方法,故逐条调用 {@link #updateUserRole}。
|
||||
*
|
||||
* @return 成功更新人数
|
||||
*/
|
||||
public int updateUserRolesSequentially(List<UserRoleUpdateCmd> cmds) {
|
||||
if (cmds == null || cmds.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
int success = 0;
|
||||
for (UserRoleUpdateCmd cmd : cmds) {
|
||||
updateUserRole(cmd);
|
||||
success++;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* 追加用户角色(按 roleCodes,对应 {@link UserFacade#updateUserAppendRole})。
|
||||
*/
|
||||
public Response updateUserAppendRole(UserRoleUpdateCmd cmd) {
|
||||
Response response = userFacade.updateUserAppendRole(cmd);
|
||||
if (response == null || !response.isSuccess()) {
|
||||
String errCode = response == null ? ErrorCode.UNKNOWN_ERROR.getCode() : response.getErrCode();
|
||||
String errMsg = response == null ? "updateUserAppendRole 无响应" : response.getErrMessage();
|
||||
throw new BizException(errCode, errMsg);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 追加用户角色(按 roleDepts:roleId/roleCode + deptId,对应 {@link UserFacade#appendUserRole})。
|
||||
*/
|
||||
public Response appendUserRole(UserAppendRoleCmd cmd) {
|
||||
Response response = userFacade.appendUserRole(cmd);
|
||||
if (response == null || !response.isSuccess()) {
|
||||
String errCode = response == null ? ErrorCode.UNKNOWN_ERROR.getCode() : response.getErrCode();
|
||||
String errMsg = response == null ? "appendUserRole 无响应" : response.getErrMessage();
|
||||
throw new BizException(errCode, errMsg);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 追加用户角色(按角色编码,对应 {@link UserFacade#appendUserRoleByRoleCode})。
|
||||
*/
|
||||
public Response appendUserRoleByRoleCode(UserAppendRoleCmd cmd) {
|
||||
Response response = userFacade.appendUserRoleByRoleCode(cmd);
|
||||
if (response == null || !response.isSuccess()) {
|
||||
String errCode = response == null ? ErrorCode.UNKNOWN_ERROR.getCode() : response.getErrCode();
|
||||
String errMsg = response == null ? "appendUserRoleByRoleCode 无响应" : response.getErrMessage();
|
||||
throw new BizException(errCode, errMsg);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按用户 id 查询详情(测试/联调用)。
|
||||
*/
|
||||
public SingleResponse<com.jjb.saas.system.client.user.response.UserDetailCO> getDetail(Long userId) {
|
||||
SingleResponse<com.jjb.saas.system.client.user.response.UserDetailCO> response = userFacade.getDetail(userId);
|
||||
if (response == null || !response.isSuccess()) {
|
||||
String errCode = response == null ? ErrorCode.UNKNOWN_ERROR.getCode() : response.getErrCode();
|
||||
String errMsg = response == null ? "getDetail 无响应" : response.getErrMessage();
|
||||
throw new BizException(errCode, errMsg);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -19,12 +19,6 @@ public class OrgPositionDO {
|
|||
private Long deptId;
|
||||
private String positionName;
|
||||
private String dutyDesc;
|
||||
/** 关联 GBS 角色ID */
|
||||
private Long gbsRoleId;
|
||||
/** 关联 GBS 角色编码 */
|
||||
private String gbsRoleCode;
|
||||
/** 关联 GBS 角色名称 */
|
||||
private String gbsRoleName;
|
||||
|
||||
// ---- GBS默认字段 ----
|
||||
private String deleteEnum;
|
||||
|
|
|
|||
|
|
@ -173,20 +173,5 @@ public class OrgPersonnelGatewayImpl implements OrgPersonnelGateway {
|
|||
return orgPersonnelDoConvertor.converDoToEe(orgPersonnelDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgPersonnelEntity> listByPostId(Long postId) {
|
||||
if (postId == null) {
|
||||
return java.util.Collections.emptyList();
|
||||
}
|
||||
LambdaQueryWrapper<OrgPersonnelDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrgPersonnelDO::getPostId, postId);
|
||||
wrapper.eq(OrgPersonnelDO::getDeleteEnum, "false");
|
||||
Long orgId = orgContextResolver.resolveOrgId(null);
|
||||
if (orgId != null) {
|
||||
wrapper.eq(OrgPersonnelDO::getOrgId, orgId);
|
||||
}
|
||||
return orgPersonnelDoConvertor.converDosToEes(orgPersonnelMapper.selectList(wrapper));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,20 +49,6 @@ public class OrgPositionGatewayImpl implements OrgPositionGateway {
|
|||
|
||||
@Override
|
||||
public OrgPositionEntity modify(OrgPositionEntity entity) {
|
||||
OrgPositionEntity existing = get(entity.getId());
|
||||
if (existing == null) {
|
||||
return null;
|
||||
}
|
||||
// 普通编辑未传 GBS 角色时,保留原关联,避免被置空
|
||||
if (entity.getGbsRoleId() == null) {
|
||||
entity.setGbsRoleId(existing.getGbsRoleId());
|
||||
}
|
||||
if (entity.getGbsRoleCode() == null) {
|
||||
entity.setGbsRoleCode(existing.getGbsRoleCode());
|
||||
}
|
||||
if (entity.getGbsRoleName() == null) {
|
||||
entity.setGbsRoleName(existing.getGbsRoleName());
|
||||
}
|
||||
OrgPositionDO dataObject = toDO(entity);
|
||||
dataObject.setId(entity.getId());
|
||||
InsertFieldDefaults.applyForUpdate(dataObject);
|
||||
|
|
@ -105,9 +91,6 @@ public class OrgPositionGatewayImpl implements OrgPositionGateway {
|
|||
dataObject.setDeptId(entity.getDeptId());
|
||||
dataObject.setPositionName(entity.getPositionName());
|
||||
dataObject.setDutyDesc(entity.getDutyDesc());
|
||||
dataObject.setGbsRoleId(entity.getGbsRoleId());
|
||||
dataObject.setGbsRoleCode(entity.getGbsRoleCode());
|
||||
dataObject.setGbsRoleName(entity.getGbsRoleName());
|
||||
dataObject.setRemarks(entity.getRemark());
|
||||
dataObject.setTenantId(entity.getTenantId());
|
||||
return dataObject;
|
||||
|
|
@ -119,13 +102,9 @@ public class OrgPositionGatewayImpl implements OrgPositionGateway {
|
|||
}
|
||||
OrgPositionEntity entity = new OrgPositionEntity();
|
||||
entity.setId(dataObject.getId());
|
||||
entity.setOrgId(dataObject.getOrgId());
|
||||
entity.setDeptId(dataObject.getDeptId());
|
||||
entity.setPositionName(dataObject.getPositionName());
|
||||
entity.setDutyDesc(dataObject.getDutyDesc());
|
||||
entity.setGbsRoleId(dataObject.getGbsRoleId());
|
||||
entity.setGbsRoleCode(dataObject.getGbsRoleCode());
|
||||
entity.setGbsRoleName(dataObject.getGbsRoleName());
|
||||
entity.setRemark(dataObject.getRemarks());
|
||||
entity.setTenantId(dataObject.getTenantId());
|
||||
return entity;
|
||||
|
|
|
|||
Loading…
Reference in New Issue