feat: (feature/REQ-3010) 迁移超管查询接口

This commit is contained in:
lilong 2024-10-14 10:07:07 +08:00
parent 3501abf019
commit 18605180ce
17 changed files with 317 additions and 0 deletions

View File

@ -12,10 +12,13 @@ import cn.axzo.tyr.client.model.product.ProductSearchListReq;
import cn.axzo.tyr.client.model.product.ProductSearchPageReq;
import cn.axzo.tyr.client.model.product.ProductUpdateReq;
import cn.axzo.tyr.client.model.product.ProductVO;
import cn.axzo.tyr.client.model.req.ProductQueryReq;
import cn.axzo.tyr.client.model.req.ProductSaveReq;
import cn.axzo.tyr.client.model.req.UpdateProductStatusReq;
import cn.axzo.tyr.client.model.res.GovernmentTerminalResp;
import cn.axzo.tyr.client.model.res.ProductQueryResp;
import cn.axzo.tyr.client.model.res.WorkspaceProductResp;
import cn.azxo.framework.common.model.CommonResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
@ -174,4 +178,10 @@ public interface ProductApi {
*/
@PostMapping("api/auth/product/getDetail")
ApiResult<ProductVO> getDetail(@Validated @RequestBody ProductDetailReq req);
/**
* 获取产品列表
*/
@PostMapping("api/product/listWithOutDelete")
CommonResponse<List<ProductQueryResp>> listWithOutDelete(@RequestBody @Valid ProductQueryReq req);
}

View File

@ -3,7 +3,9 @@ package cn.axzo.tyr.client.feign;
import cn.axzo.tyr.client.model.permission.IdentityAndAccountResp;
import cn.axzo.tyr.client.model.permission.WorkspaceGrantAdminRoleByPhoneReq;
import cn.axzo.tyr.client.model.permission.WorkspaceGrantAdminRoleReq;
import cn.axzo.tyr.client.model.req.QuerySuperAdminReq;
import cn.axzo.tyr.client.model.req.UpdateUserJobReq;
import cn.axzo.tyr.client.model.res.SuperAminInfoResp;
import cn.azxo.framework.common.model.CommonResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
@ -40,4 +42,12 @@ public interface SaasRoleApi {
@PostMapping("api/saas/role/user/update")
CommonResponse<Boolean> updateUserRole(@RequestBody @Valid UpdateUserJobReq req);
/**
*
* @param adminReqs
* @return
*/
@PostMapping("api/saas/role/batchFindSuperAdmin")
CommonResponse<List<SuperAminInfoResp>> batchFindSuperAdmin(@RequestBody @Valid List<QuerySuperAdminReq> adminReqs);
}

View File

@ -0,0 +1,27 @@
package cn.axzo.tyr.client.model.req;
import lombok.Data;
import java.util.List;
@Data
public class ProductQueryReq {
/**
* 1总包企业产品 2:总包项目产品 3:政企产品 4:分包企业产品 5:班组产品
*/
// @NotNull(message = "产品类型不能为空")
private Integer productType;
/**
* 基础产品与否 0:基础产品 1:普通产品
*/
private Integer commonProduct;
/**
* 产品列表
*/
private List<Long> productIds;
}

View File

@ -0,0 +1,33 @@
package cn.axzo.tyr.client.model.req;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
/**
* @author : liuchuntao
* @date : 2022/6/17 16:28
* @description : 查询超管信息
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class QuerySuperAdminReq {
/**
* 工作台Id
*/
@NotNull(message = "工作台Id不能为空")
private Long workspaceId;
/**
* 单位Id
*/
@NotNull(message = "单位Id不能为空")
private Long ouId;
}

View File

@ -0,0 +1,34 @@
package cn.axzo.tyr.client.model.req;
import cn.axzo.basics.common.page.PageRequest;
import lombok.Data;
import java.util.List;
/**
* @author : liuchuntao
* @date : 2022/5/16 15:13
* @description : 查询产品类型列表
*/
@Data
public class SaasProductQueryReq extends PageRequest {
/**
* 1总包企业产品 2:总包项目产品 3:政企产品 4:分包企业产品 5:班组产品
*/
private Integer productType;
/**
* 产品板块名字
*/
private String productName;
/**
* 基础产品与否 0:基础产品 1:普通产品
*/
private Integer commonProduct;
/**
* 产品Id列表
*/
private List<Long> productIds;
}

View File

@ -0,0 +1,44 @@
package cn.axzo.tyr.client.model.res;
import lombok.Data;
import java.util.Date;
/**
* @author : liuchuntao
* @date : 2022/5/18 18:50
* @description : 产品查询响应
*/
@Data
public class ProductQueryResp {
protected Long id;
/**
* 创建时间
*/
protected Date createAt;
/**
* 修改时间
*/
protected Date updateAt;
/**
* 1总包企业产品 2:总包项目产品 3:政企产品 4:分包企业产品 5:班组产品
*/
private Integer productType;
/**
* 产品板块名字
*/
private String productName;
/**
* 基础产品与否 0:基础产品 1:普通产品
*/
private Integer commonProduct;
/**
* 产品板块备注
*/
private String remark;
}

View File

@ -0,0 +1,42 @@
package cn.axzo.tyr.client.model.res;
import cn.axzo.basics.profiles.common.enums.IdentityType;
import lombok.Data;
/**
* @author : liuchuntao
* @date : 2022/6/17 16:20
* @description : 超管信息
*/
@Data
public class SuperAminInfoResp {
/**
* 身份ID
*/
private Long identityId;
private IdentityType identityType;
/**
* 手机号
*/
private String phone;
/**
* 姓名
*/
private String realName;
/**
* 工作台Id
*/
private Long workspaceId;
/**
* 单位Id
*/
private Long ouId;
}

View File

@ -21,12 +21,15 @@ import cn.axzo.tyr.client.model.permission.IdentityAndAccountResp;
import cn.axzo.tyr.client.model.permission.UpdateWorkspaceSupAdminDTO;
import cn.axzo.tyr.client.model.permission.WorkspaceGrantAdminRoleByPhoneReq;
import cn.axzo.tyr.client.model.permission.WorkspaceGrantAdminRoleReq;
import cn.axzo.tyr.client.model.req.QuerySuperAdminReq;
import cn.axzo.tyr.client.model.req.UpdateUserJobReq;
import cn.axzo.tyr.client.model.res.SuperAminInfoResp;
import cn.axzo.tyr.client.model.roleuser.req.CreateSuperAdminRoleParam;
import cn.axzo.tyr.server.controller.roleuser.RoleUserController;
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
import cn.axzo.tyr.server.util.RpcInternalUtil;
import cn.azxo.framework.common.model.CommonResponse;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
@ -35,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.List;
@Slf4j
@ -182,4 +186,15 @@ public class SaasRoleApiImpl implements SaasRoleApi {
saasRoleUserRelationService.updateWorkspaceUserRolesList(req);
return CommonResponse.success(Boolean.TRUE);
}
@Override
public CommonResponse<List<SuperAminInfoResp>> batchFindSuperAdmin(
List<QuerySuperAdminReq> adminReqs) {
if (CollUtil.isEmpty(adminReqs)) {
return CommonResponse.success(Collections.emptyList());
}
return CommonResponse.success(saasRoleUserRelationService.findBathSuperAdmin(adminReqs));
}
}

View File

@ -1,5 +1,6 @@
package cn.axzo.tyr.server.controller.product;
import cn.axzo.basics.common.BeanMapper;
import cn.axzo.framework.domain.web.result.ApiPageResult;
import cn.axzo.framework.domain.web.result.ApiResult;
import cn.axzo.tyr.client.feign.ProductApi;
@ -13,14 +14,19 @@ import cn.axzo.tyr.client.model.product.ProductSearchListReq;
import cn.axzo.tyr.client.model.product.ProductSearchPageReq;
import cn.axzo.tyr.client.model.product.ProductUpdateReq;
import cn.axzo.tyr.client.model.product.ProductVO;
import cn.axzo.tyr.client.model.req.ProductQueryReq;
import cn.axzo.tyr.client.model.req.ProductSaveReq;
import cn.axzo.tyr.client.model.req.SaasProductQueryReq;
import cn.axzo.tyr.client.model.req.UpdateProductStatusReq;
import cn.axzo.tyr.client.model.res.GovernmentTerminalResp;
import cn.axzo.tyr.client.model.res.ProductQueryResp;
import cn.axzo.tyr.client.model.res.WorkspaceProductResp;
import cn.axzo.tyr.server.model.PermissionCacheKey;
import cn.axzo.tyr.server.repository.entity.ProductModule;
import cn.axzo.tyr.server.service.PermissionCacheService;
import cn.axzo.tyr.server.service.ProductFeatureRelationService;
import cn.axzo.tyr.server.service.ProductService;
import cn.azxo.framework.common.model.CommonResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
@ -199,4 +205,12 @@ public class ProductController implements ProductApi {
public ApiResult<ProductVO> getDetail(ProductDetailReq req) {
return productService.getById(req.getProductId(), req.getQueryFeatureScope());
}
@Override
public CommonResponse<List<ProductQueryResp>> listWithOutDelete(ProductQueryReq req) {
SaasProductQueryReq queryReq = BeanMapper.copyBean(req, SaasProductQueryReq.class);
List<ProductModule> respList = productService.saasProductListWithOutDelete(queryReq);
List<ProductQueryResp> resps = BeanMapper.copyList(respList,ProductQueryResp.class);
return CommonResponse.success(resps);
}
}

View File

@ -1,10 +1,15 @@
package cn.axzo.tyr.server.repository.dao;
import cn.axzo.tyr.client.model.req.SaasProductQueryReq;
import cn.axzo.tyr.server.repository.entity.ProductModule;
import cn.axzo.tyr.server.repository.mapper.ProductModuleMapper;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* saas-产品表(SaasProduct)表服务实现类
*
@ -14,5 +19,15 @@ import org.springframework.stereotype.Service;
@Service
public class ProductModuleDao extends ServiceImpl<ProductModuleMapper, ProductModule> {
public List<ProductModule> listByNameTypeWithOutDelete(SaasProductQueryReq req) {
return lambdaQuery().like(StrUtil.isNotEmpty(req.getProductName()), ProductModule::getProductName,
req.getProductName())
.eq(req.getProductType() != null, ProductModule::getDictWorkspaceTypeCode, req.getProductType())
.eq(req.getCommonProduct() != null, ProductModule::getCommonProduct, req.getCommonProduct())
.eq(ProductModule::getIsDelete, 0)
.in(CollectionUtils.isNotEmpty(req.getProductIds()), ProductModule::getId, req.getProductIds())
.orderByDesc(ProductModule::getCreateAt)
.list();
}
}

View File

@ -1,6 +1,7 @@
package cn.axzo.tyr.server.repository.dao;
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
import cn.axzo.karma.client.model.dto.ProjectWorkBaseDTO;
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
import cn.axzo.tyr.client.common.enums.RoleResourceTypeEnum;
import cn.axzo.tyr.client.model.BaseWorkspaceModel;
@ -228,5 +229,9 @@ public class SaasRoleUserRelationDao extends ServiceImpl<SaasRoleUserRelationMap
// .eq(SaasRoleUserRelation::getOuId, ouId)
// .set(SaasRoleUserRelation::getIsDelete, TableIsDeleteEnum.DELETE.value).update();
}
public List<SaasRoleUserRelation> findBathSuperAdmin(List<ProjectWorkBaseDTO> req) {
return saasRoleUserRelationMapper.findBathSuperAdmin(req);
}
}

View File

@ -1,6 +1,7 @@
package cn.axzo.tyr.server.repository.mapper;
import cn.axzo.basics.profiles.common.enums.IdentityType;
import cn.axzo.karma.client.model.dto.ProjectWorkBaseDTO;
import cn.axzo.tyr.client.model.enums.SaasJobTypeEnum;
import cn.axzo.tyr.client.model.permission.IdentityAndAccountDTO;
import cn.axzo.tyr.client.model.permission.QueryIdentityByPermissionDTO;
@ -48,6 +49,8 @@ public interface SaasRoleUserRelationMapper extends BaseMapper<SaasRoleUserRelat
*/
void deleteButNotAdminAndNotLeader(@Param("workspaceId") Long workspaceId, @Param("ouId") Long ouId, @Param("identityId") Long identityId, @Param("identityType") IdentityType identityType, @Param("jobType") SaasJobTypeEnum jobType);
List<SaasRoleUserRelation> findBathSuperAdmin(@Param("req") List<ProjectWorkBaseDTO> req);
@Data
@Builder
@NoArgsConstructor

View File

@ -8,9 +8,11 @@ import cn.axzo.tyr.client.model.product.ProductSearchPageReq;
import cn.axzo.tyr.client.model.product.ProductUpdateReq;
import cn.axzo.tyr.client.model.product.ProductVO;
import cn.axzo.tyr.client.model.req.ProductSaveReq;
import cn.axzo.tyr.client.model.req.SaasProductQueryReq;
import cn.axzo.tyr.client.model.req.UpdateProductStatusReq;
import cn.axzo.tyr.client.model.res.GovernmentTerminalResp;
import cn.axzo.tyr.client.model.res.WorkspaceProductResp;
import cn.axzo.tyr.server.repository.entity.ProductModule;
import java.util.List;
@ -41,4 +43,6 @@ public interface ProductService {
ApiResult<List<GovernmentTerminalResp>> getGovernmentTerminal(String terminal);
ApiResult<WorkspaceProductResp> getWorkspaceProduct(String workspaceType);
List<ProductModule> saasProductListWithOutDelete(SaasProductQueryReq queryReq);
}

View File

@ -4,7 +4,9 @@ import cn.axzo.basics.profiles.common.enums.IdentityType;
import cn.axzo.framework.domain.page.PageResp;
import cn.axzo.tyr.client.model.permission.IdentityAndAccountDTO;
import cn.axzo.tyr.client.model.permission.QueryIdentityByPermissionDTO;
import cn.axzo.tyr.client.model.req.QuerySuperAdminReq;
import cn.axzo.tyr.client.model.req.UpdateUserJobReq;
import cn.axzo.tyr.client.model.res.SuperAminInfoResp;
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserDTO;
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserV2DTO;
import cn.axzo.tyr.client.model.roleuser.req.ListRoleUserRelationParam;
@ -43,4 +45,6 @@ public interface SaasRoleUserRelationService extends IService<SaasRoleUserRelati
List<IdentityAndAccountDTO> findIdentityAndAccountInfosByParams(QueryIdentityByPermissionDTO req);
void updateWorkspaceUserRolesList(UpdateUserJobReq req);
List<SuperAminInfoResp> findBathSuperAdmin(List<QuerySuperAdminReq> req);
}

View File

@ -24,6 +24,7 @@ import cn.axzo.tyr.client.model.product.ProductUpdateReq;
import cn.axzo.tyr.client.model.product.ProductVO;
import cn.axzo.tyr.client.model.req.PermissionOperateLogReq;
import cn.axzo.tyr.client.model.req.ProductSaveReq;
import cn.axzo.tyr.client.model.req.SaasProductQueryReq;
import cn.axzo.tyr.client.model.req.UpdateProductStatusReq;
import cn.axzo.tyr.client.model.res.GovernmentTerminalResp;
import cn.axzo.tyr.client.model.res.WorkspaceProductResp;
@ -571,4 +572,10 @@ public class ProductServiceImpl implements ProductService {
.build();
saasPgroupPermissionRelationOperateLogService.batchSave(Lists.newArrayList(operateLog));
}
@Override
public List<ProductModule> saasProductListWithOutDelete(SaasProductQueryReq queryReq) {
return productModuleDao.listByNameTypeWithOutDelete(queryReq);
}
}

View File

@ -14,6 +14,7 @@ import cn.axzo.foundation.dao.support.mysql.QueryWrapperHelper;
import cn.axzo.framework.auth.domain.ContextInfo;
import cn.axzo.framework.auth.domain.ContextInfoHolder;
import cn.axzo.framework.domain.page.PageResp;
import cn.axzo.karma.client.model.dto.ProjectWorkBaseDTO;
import cn.axzo.maokai.api.client.OrganizationalUnitApi;
import cn.axzo.maokai.api.vo.response.OrganizationalUnitVO;
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
@ -22,9 +23,11 @@ import cn.axzo.tyr.client.common.enums.RoleTypeEnum;
import cn.axzo.tyr.client.model.enums.SaasJobTypeEnum;
import cn.axzo.tyr.client.model.permission.IdentityAndAccountDTO;
import cn.axzo.tyr.client.model.permission.QueryIdentityByPermissionDTO;
import cn.axzo.tyr.client.model.req.QuerySuperAdminReq;
import cn.axzo.tyr.client.model.req.UpdateUserJobReq;
import cn.axzo.tyr.client.model.req.WorkspaceUpdateUserRoleDTO;
import cn.axzo.tyr.client.model.res.SaasRoleRes;
import cn.axzo.tyr.client.model.res.SuperAminInfoResp;
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserDTO;
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserV2DTO;
import cn.axzo.tyr.client.model.roleuser.req.ListRoleUserRelationParam;
@ -542,4 +545,38 @@ public class SaasRoleUserRelationServiceImpl extends ServiceImpl<SaasRoleUserRel
throw new ServiceException("单位为空");
return RpcInternalUtil.checkAndGetData(organizationalUnitApi.getById(ouId));
}
@Override
public List<SuperAminInfoResp> findBathSuperAdmin(List<QuerySuperAdminReq> req) {
if (CollectionUtil.isEmpty(req)) {
return new ArrayList<>();
}
// 查询超管
List<SaasRoleUserRelation> superAdmin = saasRoleUserRelationDao.findBathSuperAdmin(req.stream().map(e -> new ProjectWorkBaseDTO(e.getOuId(), e.getWorkspaceId())).collect(Collectors.toList()));
if (CollectionUtil.isEmpty(superAdmin)) {
return new ArrayList<>();
}
// 查询档案
// Map<Long, IdentityProfileDto> profile = identityProfileService.findProfileByIdSetV2(
// superAdmin.stream().map(SaasRoleUserRelation::getIdentityId)
// .collect(Collectors.toSet()), IdentityType.PRACTITIONER);
// 数据映射 目前工作台只会有一条超管且档案不支持多身份类型查询所以直接在map中查询了
return superAdmin.stream().map(e->{
IdentityProfileDto identityProfile = RpcInternalUtil.checkAndGetData(identityProfileApi.findIdentityProfile(FindIdentityProfileReq.builder()
.identityId(e.getIdentityId())
.identityType(IdentityType.getIdentityType(e.getIdentityType()))
.build()));
SuperAminInfoResp superAminInfoResp = new SuperAminInfoResp();
superAminInfoResp.setIdentityId(e.getIdentityId());
superAminInfoResp.setIdentityType(IdentityType.getIdentityType(e.getIdentityType()));
if (Objects.nonNull(identityProfile)) {
superAminInfoResp.setPhone(identityProfile.getPersonProfile().getPhone());
superAminInfoResp.setRealName(identityProfile.getPersonProfile().getRealName());
}
superAminInfoResp.setWorkspaceId(e.getWorkspaceId());
superAminInfoResp.setOuId(e.getOuId());
return superAminInfoResp;
}).collect(Collectors.toList());
}
}

View File

@ -148,4 +148,17 @@
and t1.job_type = #{jobType}
</if>
</update>
<select id="findBathSuperAdmin" resultType="cn.axzo.basics.auth.dto.SaasRoleUserRelation">
SELECT t1.* FROM saas_role_user_relation t1 inner join saas_role t2 on t1.role_id = t2.id
WHERE t2.role_type = 'super_admin'
AND
<foreach collection="req" index="index" item="ouIdAndWorkspaceId" open="(" close=")"
separator=" or ">
(t1.workspace_id = #{ouIdAndWorkspaceId.workspaceId}
and t1.ou_id = #{ouIdAndWorkspaceId.platOuId})
</foreach>
AND t1.is_delete = 0
AND t2.is_delete = 0
</select>
</mapper>