1.授权或者取消授权平台班组长和项目内班组长角色
2.oms 预设角色管理 添加 productRoleType 字段
This commit is contained in:
parent
0ac6eecde7
commit
81c09770d3
@ -31,6 +31,12 @@ public interface TyrSaasRoleUserApi {
|
|||||||
ApiResult<Void> saveOrUpdate(@RequestBody @Valid RoleUserReq req);
|
ApiResult<Void> saveOrUpdate(@RequestBody @Valid RoleUserReq req);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权或者取消授权平台班组长和项目内班组长角色
|
||||||
|
*/
|
||||||
|
@PostMapping("/api/saas-role-user/grant-or-ungrant-worker-leader")
|
||||||
|
ApiResult<Void> grantOrUngrantWorkerLeader(@RequestBody @Valid GantOrUnGantaWorkerLeaderRoleReq req);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存/更新 用户的角色,每次传入新的角色ID时都会覆盖原来的所有角色
|
* 保存/更新 用户的角色,每次传入新的角色ID时都会覆盖原来的所有角色
|
||||||
* 此接口不能修改非管理员角色
|
* 此接口不能修改非管理员角色
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
package cn.axzo.tyr.client.model.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public enum WorkerLeaderRoleEnum {
|
||||||
|
ENT_TEAM_MANAGER(1, "平台班组长"),
|
||||||
|
PROJ_TEAM_MANAGER(2, "项目内班组长");
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
private static final Map<Integer, WorkerLeaderRoleEnum> MAPPING = new HashMap<>();
|
||||||
|
static {
|
||||||
|
for (WorkerLeaderRoleEnum workerLeaderRoleEnum : WorkerLeaderRoleEnum.values()) {
|
||||||
|
MAPPING.put(workerLeaderRoleEnum.code, workerLeaderRoleEnum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WorkerLeaderRoleEnum apply(Integer code) {
|
||||||
|
return code == null ? null :MAPPING.get(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package cn.axzo.tyr.client.model.roleuser.req;
|
||||||
|
|
||||||
|
import cn.axzo.tyr.client.model.enums.WorkerLeaderRoleEnum;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权或者取消授权接口
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GantOrUnGantaWorkerLeaderRoleReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作台id
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private Long workspaceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单位id
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private Long ouId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 身份id
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private Long identityId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自然人id
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private Long personId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* true 授权
|
||||||
|
* false 取消授权
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
private Boolean grant;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private WorkerLeaderRoleEnum workerLeaderRoleEnum;
|
||||||
|
}
|
||||||
@ -40,6 +40,12 @@ public class RoleUserController implements TyrSaasRoleUserApi {
|
|||||||
return ApiResult.ok();
|
return ApiResult.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiResult<Void> grantOrUngrantWorkerLeader(GantOrUnGantaWorkerLeaderRoleReq req) {
|
||||||
|
saasRoleUserService.grantOrUngrantWorkerLeader(req);
|
||||||
|
return ApiResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResult<Void> batchSaveOrUpdate(List<RoleUserReq> req) {
|
public ApiResult<Void> batchSaveOrUpdate(List<RoleUserReq> req) {
|
||||||
for (RoleUserReq roleUserReq : req) {
|
for (RoleUserReq roleUserReq : req) {
|
||||||
|
|||||||
@ -79,5 +79,18 @@ public class SaasRoleUserRelationDao extends ServiceImpl<SaasRoleUserRelationMap
|
|||||||
.setSql(" is_delete = id")
|
.setSql(" is_delete = id")
|
||||||
.update();
|
.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除平台班组长项目内班组长角色
|
||||||
|
*/
|
||||||
|
public void removeWorkerLeaderRole(Long identityId, IdentityType identityType, Long workspaceId, Long ouId) {
|
||||||
|
lambdaUpdate()
|
||||||
|
.eq(SaasRoleUserRelation::getIdentityId, identityId)
|
||||||
|
.eq(SaasRoleUserRelation::getIdentityType, identityType)
|
||||||
|
.eq(SaasRoleUserRelation::getWorkspaceId, workspaceId)
|
||||||
|
.eq(SaasRoleUserRelation::getOuId, ouId)
|
||||||
|
.setSql(" is_delete = id")
|
||||||
|
.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -47,6 +47,11 @@ public class SaasRole extends BaseEntity<SaasRole> {
|
|||||||
|
|
||||||
private Long ownerOuId;
|
private Long ownerOuId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品单位类型
|
||||||
|
* 1:总包 2:建设单位 3:监理单位 4:劳务分包 5:专业分包 6:OMS通用 7:企业通用 8:企业内班组 9:项目内班组
|
||||||
|
*/
|
||||||
|
private Integer productUnitType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建者
|
* 创建者
|
||||||
|
|||||||
@ -71,4 +71,10 @@ public interface SaasRoleUserService {
|
|||||||
* 删除单位参与的工作台的所有的人员与角色。 目前主要是用于移除参与单位的地方
|
* 删除单位参与的工作台的所有的人员与角色。 目前主要是用于移除参与单位的地方
|
||||||
*/
|
*/
|
||||||
void removeWorkspaceOuAllUserRole(Long workspaceId, Long ouId);
|
void removeWorkspaceOuAllUserRole(Long workspaceId, Long ouId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权或者取消授权平台班组长和项目内班组长角色
|
||||||
|
*/
|
||||||
|
void grantOrUngrantWorkerLeader(GantOrUnGantaWorkerLeaderRoleReq req);
|
||||||
}
|
}
|
||||||
@ -376,6 +376,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
saasRole.setWorkspaceId(saveOrUpdateRole.getWorkspaceId());
|
saasRole.setWorkspaceId(saveOrUpdateRole.getWorkspaceId());
|
||||||
saasRole.setOwnerOuId(saveOrUpdateRole.getOwnerOuId());
|
saasRole.setOwnerOuId(saveOrUpdateRole.getOwnerOuId());
|
||||||
saasRole.setWorkspaceType(Integer.parseInt(saveOrUpdateRole.getGroupTree().get(0).getWorkspaceTypeCode()));
|
saasRole.setWorkspaceType(Integer.parseInt(saveOrUpdateRole.getGroupTree().get(0).getWorkspaceTypeCode()));
|
||||||
|
saasRole.setProductUnitType(setProductUnitType(saveOrUpdateRole.getGroupTree().get(0)));
|
||||||
saasRole.setUpdateBy(saveOrUpdateRole.getOperatorId());
|
saasRole.setUpdateBy(saveOrUpdateRole.getOperatorId());
|
||||||
saasRole.setUpdateAt(now);
|
saasRole.setUpdateAt(now);
|
||||||
String message = "角色校验异常";
|
String message = "角色校验异常";
|
||||||
@ -429,6 +430,16 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
return saasRole;
|
return saasRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品单位类型
|
||||||
|
*/
|
||||||
|
private Integer setProductUnitType(SaveOrUpdateRoleVO.GroupInfoVO groupInfoVO) {
|
||||||
|
SaasRoleGroup saasRoleGroup = saasRoleGroupDao.lambdaQuery()
|
||||||
|
.in(SaasRoleGroup::getId, groupInfoVO.getId())
|
||||||
|
.eq(SaasRoleGroup::getIsDelete, TableIsDeleteEnum.NORMAL.value).one();
|
||||||
|
return Integer.parseInt(saasRoleGroup.getOuTypeCode());
|
||||||
|
}
|
||||||
|
|
||||||
private void validFeature(List<Long> featureIds) {
|
private void validFeature(List<Long> featureIds) {
|
||||||
if (CollectionUtils.isEmpty(featureIds)) {
|
if (CollectionUtils.isEmpty(featureIds)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -6,8 +6,10 @@ import cn.axzo.basics.common.util.AssertUtil;
|
|||||||
import cn.axzo.tyr.client.common.enums.RoleTypeEnum;
|
import cn.axzo.tyr.client.common.enums.RoleTypeEnum;
|
||||||
import cn.axzo.tyr.client.model.BaseWorkspaceModel;
|
import cn.axzo.tyr.client.model.BaseWorkspaceModel;
|
||||||
import cn.axzo.tyr.client.model.enums.IdentityType;
|
import cn.axzo.tyr.client.model.enums.IdentityType;
|
||||||
|
import cn.axzo.tyr.client.model.enums.WorkerLeaderRoleEnum;
|
||||||
import cn.axzo.tyr.client.model.roleuser.dto.SuperAminInfoResp;
|
import cn.axzo.tyr.client.model.roleuser.dto.SuperAminInfoResp;
|
||||||
import cn.axzo.tyr.client.model.roleuser.req.CreateSuperAdminRoleParam;
|
import cn.axzo.tyr.client.model.roleuser.req.CreateSuperAdminRoleParam;
|
||||||
|
import cn.axzo.tyr.client.model.roleuser.req.GantOrUnGantaWorkerLeaderRoleReq;
|
||||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
||||||
import cn.axzo.tyr.client.model.roleuser.req.SuperAdminParam;
|
import cn.axzo.tyr.client.model.roleuser.req.SuperAdminParam;
|
||||||
import cn.axzo.tyr.server.repository.dao.SaasRoleDao;
|
import cn.axzo.tyr.server.repository.dao.SaasRoleDao;
|
||||||
@ -49,6 +51,10 @@ public class RoleUserService implements SaasRoleUserService {
|
|||||||
// 单位类型默认角色关系,后面可以座位管理员的逻辑进行迭代
|
// 单位类型默认角色关系,后面可以座位管理员的逻辑进行迭代
|
||||||
@Value("#{${participateUnitDefaultRoleId:{}}}")
|
@Value("#{${participateUnitDefaultRoleId:{}}}")
|
||||||
public Map<Integer,Long> participateUnitDefaultRoleId;
|
public Map<Integer,Long> participateUnitDefaultRoleId;
|
||||||
|
@Value("${platWorkerLeaderRoleId:100000}")
|
||||||
|
private Long entWorkerLeaderRoleId;
|
||||||
|
@Value("${platWorkerLeaderRoleId:100001}")
|
||||||
|
private Long projWorkerLeaderRoleId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取分包负责人等特殊角色
|
* 获取分包负责人等特殊角色
|
||||||
@ -276,4 +282,28 @@ public class RoleUserService implements SaasRoleUserService {
|
|||||||
roleUserRelationDao.removeWorkspaceOuAllUserRole(workspaceId, ouId);
|
roleUserRelationDao.removeWorkspaceOuAllUserRole(workspaceId, ouId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void grantOrUngrantWorkerLeader(GantOrUnGantaWorkerLeaderRoleReq req) {
|
||||||
|
Boolean grant = req.getGrant();
|
||||||
|
// 授权
|
||||||
|
if(Objects.equals(grant, Boolean.TRUE)){
|
||||||
|
SaasRoleUserRelation saasRoleUserRelation = new SaasRoleUserRelation();
|
||||||
|
saasRoleUserRelation.setIdentityId(req.getIdentityId());
|
||||||
|
saasRoleUserRelation.setIdentityType(IdentityType.WORKER_LEADER.getCode());
|
||||||
|
saasRoleUserRelation.setNaturalPersonId(req.getPersonId());
|
||||||
|
saasRoleUserRelation.setOuId(req.getOuId());
|
||||||
|
saasRoleUserRelation.setWorkspaceId(req.getWorkspaceId());
|
||||||
|
if(Objects.equals(req.getWorkerLeaderRoleEnum(), WorkerLeaderRoleEnum.ENT_TEAM_MANAGER)){
|
||||||
|
// 平台班组长
|
||||||
|
saasRoleUserRelation.setRoleId(entWorkerLeaderRoleId);
|
||||||
|
}else{
|
||||||
|
// 项目内班组长
|
||||||
|
saasRoleUserRelation.setRoleId(projWorkerLeaderRoleId);
|
||||||
|
}
|
||||||
|
roleUserRelationDao.save(saasRoleUserRelation);
|
||||||
|
}else{
|
||||||
|
// 取消授权
|
||||||
|
roleUserRelationDao.removeWorkerLeaderRole(req.getIdentityId(), IdentityType.WORKER_LEADER, req.getWorkspaceId(), req.getOuId());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user