Merge remote-tracking branch 'origin/feature/REQ-1502' into feature/REQ-1502
This commit is contained in:
commit
2a3132b665
@ -1,19 +1,16 @@
|
||||
package cn.axzo.tyr.client.feign;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SuperAdminInfoDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.*;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.CreateAdminRoleDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SuperAdminInfoDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.*;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
@ -80,5 +77,12 @@ public interface TyrSaasRoleUserApi {
|
||||
@PostMapping("/api/saas-role-user/super-admin-list")
|
||||
ApiResult<List<SuperAdminInfoDTO>> superAdminList(@RequestBody @Valid SuperAdminParam param);
|
||||
|
||||
/**
|
||||
* 批量查询超管, 多工作台
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/saas-role-user/batch-super-admin-list")
|
||||
ApiResult<List<SuperAdminInfoDTO>> batchSuperAdminList(@RequestBody @Valid List<SuperAdminParam> param);
|
||||
|
||||
}
|
||||
|
||||
@ -1,12 +1,18 @@
|
||||
package cn.axzo.tyr.client.model.base;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author tanjie@axzo.cn
|
||||
* @date 2023/10/14 11:35
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BaseWorkspaceAndOuModel {
|
||||
|
||||
private Long workspaceId;
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
package cn.axzo.tyr.client.model.req;
|
||||
|
||||
import cn.axzo.tyr.client.common.enums.WorkspaceJoinType;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
@ -14,10 +13,10 @@ import javax.validation.constraints.NotNull;
|
||||
* @author honghao.zhang
|
||||
* @since 2023/10/18 17:17
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FeaturePermissionReq {
|
||||
|
||||
/**
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
package cn.axzo.tyr.client.model.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author honghao.zhang
|
||||
* @since 2023/10/18 17:50
|
||||
*/
|
||||
@Data
|
||||
public class FeatureTreeReq {
|
||||
|
||||
/**
|
||||
* 身份Id
|
||||
*/
|
||||
private Long identityId;
|
||||
|
||||
private Integer identityType;
|
||||
|
||||
/**
|
||||
* 工作台Id
|
||||
*/
|
||||
private Long workspaceId;
|
||||
|
||||
/**
|
||||
* 工作台类型
|
||||
*/
|
||||
private Integer workspaceType;
|
||||
|
||||
/**
|
||||
* 单位类型
|
||||
*/
|
||||
private Integer ouTypeCode;
|
||||
|
||||
/**
|
||||
* 单位Id
|
||||
*/
|
||||
private Long ouId;
|
||||
|
||||
/**
|
||||
* 指定端的权限
|
||||
*/
|
||||
private String terminal;
|
||||
|
||||
/**
|
||||
* FeatureType: 类型 0.模块 1.菜单 2页面 3功能
|
||||
* 此字段=0,只返回模块,=1,返回到菜单级,=2,返回到页面级,=3,到功能级。
|
||||
* 此字段默认到功能级, (会做为递归的深度限制)
|
||||
* ------
|
||||
*/
|
||||
private Integer limitFeatureTypeLevel = 3;
|
||||
}
|
||||
@ -1,8 +1,11 @@
|
||||
package cn.axzo.tyr.client.model.req;
|
||||
|
||||
import cn.axzo.tyr.client.model.base.BaseWorkspaceAndOuModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
@ -13,13 +16,16 @@ import java.util.List;
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class QueryRoleByNameReq extends BaseWorkspaceAndOuModel {
|
||||
|
||||
@NotEmpty(message = "角色名字不能为空")
|
||||
private List<String> roleNames;
|
||||
|
||||
/**
|
||||
* 单位类型字典code
|
||||
* 单位类型字典code {@link cn.axzo.tyr.client.common.enums.WorkspaceJoinType}
|
||||
*/
|
||||
private List<String> ouTypeCode;
|
||||
|
||||
|
||||
@ -26,12 +26,17 @@ public class QuerySaasRoleGroupReq {
|
||||
private List<Long> ouIds;
|
||||
|
||||
/**
|
||||
* 工作台类型字典code
|
||||
* 工作台类型字典code {@link WorkspaceType}
|
||||
*
|
||||
* 请看workspace的 GENERAL_ENT(1,"总包企业级"),
|
||||
* GENERAL_PROJECT(2,"总包项目级"),
|
||||
* AGENCY_ENT(4,"分包企业级"),
|
||||
* OMS(6,"OMS工作台");
|
||||
*/
|
||||
private List<String> workspaceTypeCode;
|
||||
|
||||
/**
|
||||
* 单位类型字典code
|
||||
* 单位类型字典code {@link cn.axzo.tyr.client.common.enums.WorkspaceJoinType}
|
||||
*/
|
||||
private List<String> ouTypeCode;
|
||||
|
||||
|
||||
@ -1,21 +1,22 @@
|
||||
package cn.axzo.tyr.server.controller.roleuser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserDTO;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.feign.TyrSaasRoleUserApi;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SuperAdminInfoDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.*;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author tanjie@axzo.cn
|
||||
@ -82,4 +83,12 @@ public class RoleUserController implements TyrSaasRoleUserApi {
|
||||
public ApiResult<List<SuperAdminInfoDTO>> superAdminList(SuperAdminParam param) {
|
||||
return ApiResult.ok(saasRoleUserService.superAdminList(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<List<SuperAdminInfoDTO>> batchSuperAdminList(List<SuperAdminParam> param) {
|
||||
if (CollectionUtils.isEmpty(param)) {
|
||||
return ApiResult.ok(Collections.EMPTY_LIST);
|
||||
}
|
||||
return ApiResult.ok(param.stream().map(saasRoleUserService::superAdminList).flatMap(x -> x.stream()).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,6 +147,41 @@ public class CMSRoleJobHandler extends IJobHandler {
|
||||
roleGroupDao.save(roleGroup);
|
||||
|
||||
saasPreRoles.forEach(preRole -> {
|
||||
// 创建角色:根据预设角色创建新的角色
|
||||
SaasRole newRole = new SaasRole();
|
||||
newRole.setRoleType(RoleTypeEnum.INIT.getValue());
|
||||
newRole.setName(preRole.getName());
|
||||
newRole.setCreateBy(-1l);
|
||||
newRole.setUpdateBy(-1l);
|
||||
newRole.setOwnerOuId(-1l);
|
||||
newRole.setWorkspaceId(-1l);
|
||||
roleDao.save(newRole);
|
||||
|
||||
// 创建角色分组关联关系
|
||||
SaasRoleGroupRelation saasRoleGroupRelation = new SaasRoleGroupRelation();
|
||||
saasRoleGroupRelation.setRoleId(newRole.getId());
|
||||
saasRoleGroupRelation.setSaasRoleGroupId(roleGroup.getId());
|
||||
roleGroupRelationDao.save(saasRoleGroupRelation);
|
||||
|
||||
// 更新用户关联关系表(根据老的fromRoleId更新至新roldId)
|
||||
// 根据fromeRoleId查询老的roleId
|
||||
// fromRoleId的角色未关联具体角色分组和权限点,可以直接丢弃,已经和产品确认过
|
||||
// SELECT * FROM `saas_pgroup_role_relation` WHERE `role_id` in (
|
||||
// SELECT id FROM saas_role WHERE is_delete=0 and workspace_id != -1 and from_pre_role_id = 0 and role_type!='super_admin' and `NAME` not like '%代班长%' and `NAME` not like '%带班长%')
|
||||
List<SaasRole> oldRoleList = roleDao.lambdaQuery()
|
||||
.eq(SaasRole::getFromPreRoleId, preRole.getId())
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(oldRoleList)) {
|
||||
log.info("未找到preRole下发的role preRole:{}", JSONUtil.toJsonStr(preRole));
|
||||
return;
|
||||
}
|
||||
List<Long> oldRoleId = oldRoleList.stream().map(BaseEntity::getId).collect(Collectors.toList());
|
||||
// 更新用户角色关联关系
|
||||
roleUserRelationDao.lambdaUpdate()
|
||||
.in(SaasRoleUserRelation::getRoleId,oldRoleId)
|
||||
.set(SaasRoleUserRelation::getRoleId,newRole.getId())
|
||||
.update();
|
||||
|
||||
// 根据角色id查询角色权限集关联关系
|
||||
List<SaasPreGroupRoleRelation> pgroupRoleRelation = saasPreGroupRoleRelationDao.lambdaQuery()
|
||||
.eq(SaasPreGroupRoleRelation::getPreRoleId, preRole.getId())
|
||||
@ -197,16 +232,6 @@ public class CMSRoleJobHandler extends IJobHandler {
|
||||
}).collect(Collectors.toList());
|
||||
pgroupPermissionRelationDao.saveBatch(saasPgroupPermissionRelationList);
|
||||
|
||||
// 创建角色:根据预设角色创建新的角色
|
||||
SaasRole newRole = new SaasRole();
|
||||
newRole.setRoleType(RoleTypeEnum.INIT.getValue());
|
||||
newRole.setName(preRole.getName());
|
||||
newRole.setCreateBy(-1l);
|
||||
newRole.setUpdateBy(-1l);
|
||||
newRole.setOwnerOuId(-1l);
|
||||
newRole.setWorkspaceId(-1l);
|
||||
roleDao.save(newRole);
|
||||
|
||||
// 创建新的角色权限集关联关系
|
||||
SaasPgroupRoleRelation saasPgroupRoleRelation = new SaasPgroupRoleRelation();
|
||||
saasPgroupRoleRelation.setRoleId(newRole.getId());
|
||||
@ -215,33 +240,8 @@ public class CMSRoleJobHandler extends IJobHandler {
|
||||
saasPgroupRoleRelation.setUpdateBy(-1L);
|
||||
pgroupRoleRelationDao.save(saasPgroupRoleRelation);
|
||||
|
||||
// 创建角色分组关联关系
|
||||
SaasRoleGroupRelation saasRoleGroupRelation = new SaasRoleGroupRelation();
|
||||
saasRoleGroupRelation.setRoleId(newRole.getId());
|
||||
saasRoleGroupRelation.setSaasRoleGroupId(roleGroup.getId());
|
||||
roleGroupRelationDao.save(saasRoleGroupRelation);
|
||||
|
||||
// 更新用户关联关系表(根据老的fromRoleId更新至新roldId)
|
||||
// 根据fromeRoleId查询老的roleId
|
||||
// fromRoleId的角色未关联具体角色分组和权限点,可以直接丢弃,已经和产品确认过
|
||||
// SELECT * FROM `saas_pgroup_role_relation` WHERE `role_id` in (
|
||||
// SELECT id FROM saas_role WHERE is_delete=0 and workspace_id != -1 and from_pre_role_id = 0 and role_type!='super_admin' and `NAME` not like '%代班长%' and `NAME` not like '%带班长%')
|
||||
List<SaasRole> list = roleDao.lambdaQuery()
|
||||
.eq(SaasRole::getFromPreRoleId, preRole.getId())
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
log.info("未找到preRole下发的role preRole:{}", JSONUtil.toJsonStr(preRole));
|
||||
return;
|
||||
}
|
||||
List<Long> oldRoleId = list.stream().map(BaseEntity::getId).collect(Collectors.toList());
|
||||
// 更新用户角色关联关系
|
||||
roleUserRelationDao.lambdaUpdate()
|
||||
.in(SaasRoleUserRelation::getRoleId,oldRoleId)
|
||||
.set(SaasRoleUserRelation::getRoleId,newRole.getId())
|
||||
.update();
|
||||
|
||||
// 补充待删除数据
|
||||
deleteRoleId.addAll(list.stream().map(BaseEntity::getId).collect(Collectors.toSet()));
|
||||
deleteRoleId.addAll(oldRoleList.stream().map(BaseEntity::getId).collect(Collectors.toSet()));
|
||||
deleteSaasPermissionGroupId.addAll(oldPermissionGroup.stream().map(BaseEntity::getId).collect(Collectors.toSet()));
|
||||
deletePgroupPermissionRelationId.addAll(oldPgroupPermissionRelation.stream().map(BaseEntity::getId).collect(Collectors.toSet()));
|
||||
});
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package cn.axzo.tyr.server.repository.dao;
|
||||
|
||||
import cn.axzo.tyr.client.model.req.FeatureTreeReq;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeature;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@ -26,10 +25,4 @@ public interface SaasFeatureDao extends IService<SaasFeature> {
|
||||
|
||||
List<SaasFeature> listByParentIdAndTerminal(Long parentId, String terminal);
|
||||
|
||||
List<SaasFeature> listFeatureByTerminal(String terminal);
|
||||
|
||||
List<String> listCodeByProductIds(FeatureTreeReq req, List<Long> productIds);
|
||||
|
||||
List<String> listByProductIdsAndTerminal(List<Long> productIds, String terminal);
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,11 @@
|
||||
package cn.axzo.tyr.server.repository.dao.impl;
|
||||
|
||||
import cn.axzo.tyr.client.model.req.FeatureTreeReq;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasFeatureDao;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeature;
|
||||
import cn.axzo.tyr.server.repository.mapper.SaasFeatureMapper;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasFeatureDao;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -50,18 +48,4 @@ public class SaasFeatureDaoImpl extends ServiceImpl<SaasFeatureMapper, SaasFeatu
|
||||
.eq(SaasFeature::getTerminal, terminal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SaasFeature> listFeatureByTerminal(String terminal) {
|
||||
return lambdaQuery().eq(StringUtils.isNotEmpty(terminal), SaasFeature::getTerminal, terminal).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listCodeByProductIds(FeatureTreeReq req, List<Long> productIds) {
|
||||
return this.baseMapper.listCodeByProductIds(req, productIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listByProductIdsAndTerminal(List<Long> productIds, String terminal) {
|
||||
return this.baseMapper.listCodeByProductIdsAndTerminal(productIds, terminal);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,9 @@
|
||||
package cn.axzo.tyr.server.repository.mapper;
|
||||
|
||||
import cn.axzo.tyr.client.model.req.FeatureTreeReq;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeature;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
@ -23,7 +19,4 @@ public interface SaasFeatureMapper extends BaseMapper<SaasFeature> {
|
||||
"WHERE path LIKE CONCAT(#{pathPrefix},'%') ")
|
||||
void updateChildrenPath(Long updater, String pathPrefix, String newPathPrefix);
|
||||
|
||||
List<String> listCodeByProductIds(@Param("req") FeatureTreeReq req, @Param("productIds") List<Long> productIds);
|
||||
|
||||
List<String> listCodeByProductIdsAndTerminal(@Param("productIds") List<Long> productIds, @Param("terminal") String terminal);
|
||||
}
|
||||
@ -526,6 +526,7 @@ public class RoleServiceImpl implements RoleService {
|
||||
|
||||
@Override
|
||||
public List<QueryRoleByNameResp> findRoleByName(QueryRoleByNameReq req) {
|
||||
// TODO jhy 这个方法有问题
|
||||
List<Long> relationRoleIds = Lists.newArrayList();
|
||||
if (CollectionUtils.isNotEmpty(req.getOuTypeCode())) {
|
||||
List<SaasRoleGroup> roleGroup = saasRoleGroupDao.query(QuerySaasRoleGroupReq.builder()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user