Merge remote-tracking branch 'origin/feature/REQ-1102' into feature/REQ-1102
This commit is contained in:
commit
a2f2471193
3
Dockerfile
Normal file
3
Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/axzo-k8s/jdk1.8-fc:v1
|
||||
COPY tyr-server/target/tyr.jar ./tyr.jar
|
||||
ENTRYPOINT [{ENTRYPOINT}]
|
||||
@ -35,13 +35,13 @@ public interface SaasBasicDictApi {
|
||||
ApiResult<List<BasicDictNodeResp>> getBasicDictNodeList(@RequestBody @Validated BasicDictQueryReq req);
|
||||
|
||||
/**
|
||||
* 获取字典树,需要单测树时才传type
|
||||
* 获取字典树,需要单侧树时才传type
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("api/dict/node-tree")
|
||||
ApiResult<BasicDictTreeResp> getBasicDictNodeTree(@RequestBody
|
||||
ApiResult<List<BasicDictTreeResp>> getBasicDictNodeTree(
|
||||
@EnumValidator(enumClass = DictTypeFiledEnum.class, message = "枚举类型错误")
|
||||
DictTypeFiledEnum type);
|
||||
|
||||
@ -83,4 +83,5 @@ public interface SaasBasicDictApi {
|
||||
|
||||
@GetMapping("api/dict/get")
|
||||
ApiResult<BasicDictNodeResp> get(@RequestParam Long id);
|
||||
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
/**
|
||||
* 权限集
|
||||
*/
|
||||
@FeignClient(name = "tyr", url = "${axzo.service.maokai:http://tyr:8080/api/saasPermissionGoup}")
|
||||
@FeignClient(name = "tyr", url = "${axzo.service.tyr:http://tyr:8080/api/saasPermissionGoup}")
|
||||
public interface SaasPermissionGroupApi {
|
||||
|
||||
/**
|
||||
|
||||
@ -5,7 +5,7 @@ import org.springframework.cloud.openfeign.FeignClient;
|
||||
/**
|
||||
* 权限集作用范围 TODO
|
||||
*/
|
||||
@FeignClient(name = "tyr", url = "${axzo.service.maokai:http://tyr:8080/api/saasPermissionGroup}")
|
||||
@FeignClient(name = "tyr", url = "${axzo.service.tyr:http://tyr:8080/api/saasPermissionGroup}")
|
||||
public interface SaasPermissionGroupScopeApi {
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package cn.axzo.tyr.client.feign;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleReq;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
@ -10,11 +11,12 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
@FeignClient(name = "tyr", url = "${axzo.service.maokai:http://tyr:8080}")
|
||||
@FeignClient(name = "tyr", url = "${axzo.service.tyr:http://tyr:8080}")
|
||||
public interface SaasRoleApi {
|
||||
|
||||
/**
|
||||
@ -39,10 +41,20 @@ public interface SaasRoleApi {
|
||||
ApiResult<List<SaasRoleVO>> query(@RequestBody QuerySaasRoleReq req);
|
||||
|
||||
/**
|
||||
* 根据身份id 身份类型查询权限列表
|
||||
* 根据身份id身份类型查询权限列表(批量)
|
||||
* @param identityType 身份类型 1:工人 2:班组长 3:从业人员 4:监管人员 5:运营人员
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/api/saasRole/queryByIdentityIdType")
|
||||
ApiResult<List<SaasRoleVO>> queryByIdentityIdType(@RequestParam(required = true) Long identityId,@RequestParam(required = true) Integer identityType);
|
||||
ApiResult<List<SaasRoleVO>> queryByIdentityIdType(@RequestParam(required = true) Long identityId,@RequestParam(required = true) Integer identityType,@RequestParam(required = true) Long workspaceId,@RequestParam(required = true) Long ouId);
|
||||
|
||||
/**
|
||||
* 根据身份id身份类型查询权限列表(批量)
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/api/saasRole/queryBatchByIdentityIdType")
|
||||
ApiResult<Map<QueryByIdentityIdTypeReq, List<SaasRoleVO>>> queryBatchByIdentityIdType(@RequestBody List<QueryByIdentityIdTypeReq> req);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -12,8 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
/**
|
||||
* 角色分组
|
||||
*/
|
||||
@FeignClient(name = "tyr", url = "${axzo.service.maokai:http://tyr:8080/api/saasRoleGroup}")
|
||||
public interface SaasRoleGoupApi {
|
||||
@FeignClient(name = "tyr", url = "${axzo.service.tyr:http://tyr:8080/api/saasRoleGroup}")
|
||||
public interface SaasRoleGroupApi {
|
||||
|
||||
/**
|
||||
* 保存/更新
|
||||
@ -4,6 +4,8 @@ import cn.axzo.tyr.client.common.annotation.EnumValidator;
|
||||
import cn.axzo.tyr.client.model.DictTypeFiledEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/6 15:46
|
||||
@ -17,9 +19,11 @@ public class BasicDictNodeReq {
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@NotNull(message = "type不能为空")
|
||||
@EnumValidator(enumClass = DictTypeFiledEnum.class, message = "枚举类型错误")
|
||||
private DictTypeFiledEnum type;
|
||||
|
||||
@NotNull(message = "code不能为空")
|
||||
private String code;
|
||||
|
||||
}
|
||||
|
||||
@ -3,7 +3,12 @@ package cn.axzo.tyr.client.model.dict.request;
|
||||
import cn.axzo.tyr.client.common.annotation.EnumValidator;
|
||||
import cn.axzo.tyr.client.model.DictTypeFiledEnum;
|
||||
import cn.axzo.tyr.client.model.DictWorkSpaceTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
@ -13,20 +18,25 @@ import lombok.Data;
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BasicDictQueryReq {
|
||||
|
||||
private List<Long> ids;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* workspace
|
||||
*/
|
||||
@EnumValidator(enumClass = DictWorkSpaceTypeEnum.class, message = "枚举类型错误")
|
||||
// @EnumValidator(enumClass = DictWorkSpaceTypeEnum.class, message = "枚举类型错误")
|
||||
private DictWorkSpaceTypeEnum workspaceType;
|
||||
|
||||
/**
|
||||
* type
|
||||
*/
|
||||
@EnumValidator(enumClass = DictTypeFiledEnum.class, message = "枚举类型错误")
|
||||
// @EnumValidator(enumClass = DictTypeFiledEnum.class, message = "枚举类型错误")
|
||||
private DictTypeFiledEnum type;
|
||||
|
||||
/**
|
||||
|
||||
@ -16,6 +16,8 @@ public class BasicDictTreeResp {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
package cn.axzo.tyr.client.model.req;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@EqualsAndHashCode
|
||||
public class QueryByIdentityIdTypeReq {
|
||||
|
||||
Long identityId;
|
||||
|
||||
/**
|
||||
* 身份类型 1:工人 2:班组长 3:从业人员 4:监管人员 5:运营人员
|
||||
*/
|
||||
Integer identityType;
|
||||
|
||||
Long workspaceId;
|
||||
|
||||
Long ouId;
|
||||
}
|
||||
@ -38,7 +38,7 @@ public class SaasRoleGroupVO {
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
private List<SaasRoleVO> role;
|
||||
private List<Long> roleIds;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
|
||||
@ -70,6 +70,13 @@
|
||||
<groupId>cn.axzo.basics</groupId>
|
||||
<artifactId>basics-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package cn.axzo.tyr.server.config.exception;
|
||||
|
||||
|
||||
import cn.axzo.basics.common.exception.ServiceException;
|
||||
import cn.axzo.framework.autoconfigure.web.exception.RespErrorCodeMappingProperties;
|
||||
import cn.axzo.framework.autoconfigure.web.exception.handler.AbstractExceptionApiResultHandler;
|
||||
import cn.axzo.framework.domain.web.code.IRespCode;
|
||||
import cn.axzo.framework.domain.web.code.RespCode;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 目前整体框架中 ServiceException 有多种,而常用的 {@link cn.axzo.basics.common.util.AssertUtil} 抛出的是 {@link cn.axzo.basics.common.exception.ServiceException}
|
||||
* 与框架默认的异常处理器不兼容,所以新增加一个处理该异常的处理器
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2023/9/11 11:39
|
||||
*/
|
||||
@Component
|
||||
public class ServiceExceptionResultHandler extends AbstractExceptionApiResultHandler<ServiceException> {
|
||||
public ServiceExceptionResultHandler(RespErrorCodeMappingProperties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IRespCode decode(ServiceException error, IRespCode fallbackCode) {
|
||||
return new RespCode(String.valueOf(error.getErrorCode()), error.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@ -16,7 +16,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/8 14:32
|
||||
* @description:
|
||||
* @description: 字典controller
|
||||
* @modifiedBy:
|
||||
* @version: 1.0
|
||||
*/
|
||||
@ -33,32 +33,33 @@ public class SaasBasicDictController implements SaasBasicDictApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<BasicDictTreeResp> getBasicDictNodeTree(DictTypeFiledEnum type) {
|
||||
public ApiResult<List<BasicDictTreeResp>> getBasicDictNodeTree(DictTypeFiledEnum type) {
|
||||
return saasBasicDictService.getBasicDictNodeTree(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<BasicDictNodeResp> getBasicDictNode(BasicDictNodeReq req) {
|
||||
return null;
|
||||
return saasBasicDictService.getBasicDictNode(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Long> create(BasicDictCreateReq req) {
|
||||
return null;
|
||||
return saasBasicDictService.create(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Boolean> update(BasicDictUpdateReq req) {
|
||||
return null;
|
||||
return saasBasicDictService.update(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Boolean> updateStatus(BasicDictUpdateStatusReq req) {
|
||||
return null;
|
||||
return saasBasicDictService.updateStauts(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<BasicDictNodeResp> get(Long id) {
|
||||
return saasBasicDictService.getById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package cn.axzo.tyr.server.controller.role;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.feign.SaasRoleApi;
|
||||
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleReq;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleVO;
|
||||
import cn.axzo.tyr.server.service.RoleService;
|
||||
@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 权限
|
||||
@ -43,7 +45,13 @@ public class SaasRoleController implements SaasRoleApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<List<SaasRoleVO>> queryByIdentityIdType(Long identityId, Integer identityType) {
|
||||
return ApiResult.ok(roleService.queryByIdentityIdType(identityId, identityType));
|
||||
public ApiResult<List<SaasRoleVO>> queryByIdentityIdType(Long identityId, Integer identityType,Long workspaceId,Long ouId) {
|
||||
return ApiResult.ok(roleService.queryByIdentityIdType(identityId, identityType,workspaceId,ouId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Map<QueryByIdentityIdTypeReq, List<SaasRoleVO>>> queryBatchByIdentityIdType(List<QueryByIdentityIdTypeReq> req) {
|
||||
return ApiResult.ok(roleService.queryBatchByIdentityIdType(req));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
package cn.axzo.tyr.server.controller.role;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiListResult;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.feign.SaasRoleGroupApi;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||
import cn.axzo.tyr.server.service.SaasRoleGroupService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class SaasRoleGroupController implements SaasRoleGroupApi {
|
||||
private final SaasRoleGroupService saasRoleGroupService;
|
||||
|
||||
@Override
|
||||
public ApiResult<Void> saveOrUpdate(SaasRoleGroupVO req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiListResult<SaasRoleGroupVO> getList(QuerySaasRoleGroupReq req) {
|
||||
return ApiListResult.ok(saasRoleGroupService.getList(req));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Void> delete(Long id) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,18 @@
|
||||
package cn.axzo.tyr.server.repository;
|
||||
|
||||
import cn.axzo.basics.common.BeanMapper;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictNodeReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictQueryReq;
|
||||
import cn.axzo.tyr.client.model.dict.response.BasicDictNodeResp;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasBasicDict;
|
||||
import cn.axzo.tyr.server.repository.mapper.SaasBasicDictMapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
@ -15,4 +24,26 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class SaasBasicDictDao extends ServiceImpl<SaasBasicDictMapper, SaasBasicDict> {
|
||||
|
||||
public List<BasicDictNodeResp> getBasicDictNodeList(BasicDictQueryReq req) {
|
||||
LambdaQueryChainWrapper<SaasBasicDict> queryChainWrapper = lambdaQuery();
|
||||
if (Objects.nonNull(req)) {
|
||||
queryChainWrapper
|
||||
.in(!CollectionUtils.isEmpty(req.getIds()), SaasBasicDict::getId, req.getIds())
|
||||
.eq(Objects.nonNull(req.getParentId()), SaasBasicDict::getParentId, req.getParentId())
|
||||
.eq(Objects.nonNull(req.getWorkspaceType()), SaasBasicDict::getWorkspaceType, Objects.nonNull(req.getWorkspaceType()) ? req.getWorkspaceType().getValue() : "")
|
||||
.eq(Objects.nonNull(req.getType()), SaasBasicDict::getType, Objects.nonNull(req.getType()) ? req.getType().getValue() : "")
|
||||
.eq(Objects.nonNull(req.getCode()), SaasBasicDict::getCode, req.getCode())
|
||||
.eq(Objects.nonNull(req.getStatus()), SaasBasicDict::getStatus, Boolean.TRUE.equals(req.getStatus()) ? 1 : 0)
|
||||
.like(Objects.nonNull(req.getName()), SaasBasicDict::getName, req.getName());
|
||||
}
|
||||
List<SaasBasicDict> basicDictList = queryChainWrapper.orderByDesc(SaasBasicDict::getSort).list();
|
||||
return BeanMapper.copyList(basicDictList, BasicDictNodeResp.class, (s, b) -> b.setStatus(s.getStatus() == 1));
|
||||
}
|
||||
|
||||
public BasicDictNodeResp getBasicDictNode(BasicDictNodeReq req) {
|
||||
SaasBasicDict saasBasicDict = lambdaQuery().eq(Objects.nonNull(req.getType()), SaasBasicDict::getType, req.getType().getValue())
|
||||
.eq(Objects.nonNull(req.getCode()), SaasBasicDict::getCode, req.getCode())
|
||||
.one();
|
||||
return BeanMapper.copyBean(saasBasicDict, BasicDictNodeResp.class, (s, b) -> b.setStatus(s.getStatus() == 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package cn.axzo.tyr.server.repository.service;
|
||||
|
||||
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
|
||||
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleUserRelation;
|
||||
import cn.axzo.tyr.server.repository.mapper.SaasRoleUserRelationMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -10,10 +12,13 @@ import java.util.List;
|
||||
@Repository
|
||||
public class SaasRoleUserRelationDao extends ServiceImpl<SaasRoleUserRelationMapper, SaasRoleUserRelation> {
|
||||
|
||||
public List<SaasRoleUserRelation> queryByIdentityIdType(Long identityId, Integer identityType) {
|
||||
public List<SaasRoleUserRelation> query(Long identityId, Integer identityType, Long workspaceId, Long ouId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(SaasRoleUserRelation::getIdentityId,identityId)
|
||||
.eq(SaasRoleUserRelation::getIdentityType,identityType)
|
||||
.eq(SaasRoleUserRelation::getWorkspaceId,workspaceId)
|
||||
.eq(SaasRoleUserRelation::getOuId,ouId)
|
||||
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||
.list();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
package cn.axzo.tyr.server.service;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiListResult;
|
||||
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleReq;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
@ -16,7 +17,9 @@ import java.util.List;
|
||||
public interface RoleService {
|
||||
|
||||
|
||||
List<SaasRoleVO> queryByIdentityIdType(Long identityId, Integer identityType);
|
||||
List<SaasRoleVO> queryByIdentityIdType(Long identityId, Integer identityType,Long workspaceId,Long ouId);
|
||||
|
||||
List<SaasRoleVO> query(QuerySaasRoleReq req);
|
||||
|
||||
Map<QueryByIdentityIdTypeReq, List<SaasRoleVO>> queryBatchByIdentityIdType(List<QueryByIdentityIdTypeReq> req);
|
||||
}
|
||||
|
||||
@ -2,15 +2,12 @@ package cn.axzo.tyr.server.service;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.DictTypeFiledEnum;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictQueryReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.*;
|
||||
import cn.axzo.tyr.client.model.dict.response.BasicDictNodeResp;
|
||||
import cn.axzo.tyr.client.model.dict.response.BasicDictTreeResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.dict.response.BasicDictNodeResp;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
* @date: 2023/9/7 17:54
|
||||
@ -21,6 +18,15 @@ import cn.axzo.tyr.client.model.dict.response.BasicDictNodeResp;
|
||||
public interface SaasBasicDictService {
|
||||
ApiResult<List<BasicDictNodeResp>> getBasicDictNodeList(BasicDictQueryReq req);
|
||||
|
||||
ApiResult<BasicDictTreeResp> getBasicDictNodeTree(DictTypeFiledEnum type);
|
||||
ApiResult<List<BasicDictTreeResp>> getBasicDictNodeTree(DictTypeFiledEnum type);
|
||||
ApiResult<BasicDictNodeResp> getById(Long id);
|
||||
|
||||
ApiResult<BasicDictNodeResp> getBasicDictNode(BasicDictNodeReq req);
|
||||
|
||||
ApiResult<Long> create(BasicDictCreateReq req);
|
||||
|
||||
ApiResult<Boolean> update(BasicDictUpdateReq req);
|
||||
|
||||
ApiResult<Boolean> updateStauts(BasicDictUpdateStatusReq req);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package cn.axzo.tyr.server.service;
|
||||
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SaasRoleGroupService {
|
||||
List<SaasRoleGroupVO> getList(QuerySaasRoleGroupReq req);
|
||||
}
|
||||
@ -71,7 +71,7 @@ public class ProductServiceImpl implements ProductService {
|
||||
@Override
|
||||
public ApiResult<ProductVO> update(ProductUpdateReq req) {
|
||||
ProductModule productModule = productModuleDao.getById(req.getId());
|
||||
BeanMapper.copyBeanIgnoreNull(req, ()-> productModule);
|
||||
BeanMapper.copyBeanIgnoreNull(req, () -> productModule);
|
||||
productModuleDao.updateById(productModule);
|
||||
return ApiResult.ok(BeanMapper.copyBeanIgnoreNull(productModule, ProductVO.class));
|
||||
}
|
||||
@ -80,8 +80,10 @@ public class ProductServiceImpl implements ProductService {
|
||||
public ApiResult<ProductVO> delete(Long id) {
|
||||
ProductModule productModule = productModuleDao.getById(id);
|
||||
AssertUtil.isTrue(Objects.nonNull(productModule), "产品不存在");
|
||||
productModule.setIsDelete(id);
|
||||
productModuleDao.updateById(productModule);
|
||||
productModuleDao.lambdaUpdate()
|
||||
.eq(ProductModule::getId, id)
|
||||
.set(ProductModule::getIsDelete, id)
|
||||
.update();
|
||||
return ApiResult.ok(BeanMapper.copyBean(productModule, ProductVO.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ package cn.axzo.tyr.server.service.impl;
|
||||
|
||||
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
|
||||
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||
import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
|
||||
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasPermissionGroupReq;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleReq;
|
||||
@ -13,7 +13,6 @@ import cn.axzo.tyr.server.repository.service.*;
|
||||
import cn.axzo.tyr.server.service.PermissionGroupService;
|
||||
import cn.axzo.tyr.server.service.RoleService;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
@ -50,9 +49,9 @@ public class RoleServiceImpl implements RoleService {
|
||||
SaasRoleGroupRelationDao roleGroupRelationDao;
|
||||
|
||||
@Override
|
||||
public List<SaasRoleVO> queryByIdentityIdType(Long identityId, Integer identityType) {
|
||||
public List<SaasRoleVO> queryByIdentityIdType(Long identityId, Integer identityType, Long workspaceId, Long ouId) {
|
||||
// 查询人关联的角色id
|
||||
List<Long> roleIds = roleUserRelationDao.queryByIdentityIdType(identityId, identityType).stream().map(SaasRoleUserRelation::getRoleId).collect(Collectors.toList());
|
||||
List<Long> roleIds = roleUserRelationDao.query(identityId, identityType, workspaceId, ouId).stream().map(SaasRoleUserRelation::getRoleId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(roleIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@ -61,6 +60,7 @@ public class RoleServiceImpl implements RoleService {
|
||||
|
||||
/**
|
||||
* 根据id查询权限详情包含权限组合权限集(底层基础方法)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<SaasRoleVO> getByIds(List<Long> roleIds) {
|
||||
@ -130,17 +130,29 @@ public class RoleServiceImpl implements RoleService {
|
||||
groupRelation = roleGroupRelationDao.lambdaQuery()
|
||||
.in(SaasRoleGroupRelation::getSaasRoleGroupId, roleGroup.stream().map(BaseEntity::getId).collect(Collectors.toList()))
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(groupRelation)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
// 查询角色
|
||||
List<SaasRole> list = saasRoleDao.lambdaQuery()
|
||||
.in(CollectionUtils.isNotEmpty(req.getIds()), BaseEntity::getId, req.getIds())
|
||||
.in(CollectionUtils.isNotEmpty(groupRelation), BaseEntity::getId, groupRelation.stream().map(SaasRoleGroupRelation::getRoleId).collect(Collectors.toList()))
|
||||
.eq(StringUtils.isNotBlank(req.getRoleType()),SaasRole::getRoleType,req.getRoleType())
|
||||
.eq(StringUtils.isNotBlank(req.getRoleType()), SaasRole::getRoleType, req.getRoleType())
|
||||
.orderByDesc(BaseEntity::getId)
|
||||
.list();
|
||||
return getByIds(list.stream().map(BaseEntity::getId).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<QueryByIdentityIdTypeReq, List<SaasRoleVO>> queryBatchByIdentityIdType(List<QueryByIdentityIdTypeReq> req) {
|
||||
HashMap<QueryByIdentityIdTypeReq, List<SaasRoleVO>> result = new HashMap<>();
|
||||
req.forEach(e -> {
|
||||
result.put(e,queryByIdentityIdType(e.getIdentityId(),e.getIdentityType(),e.getWorkspaceId(),e.getOuId()));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色id查询权限集关联关系
|
||||
*/
|
||||
|
||||
@ -3,16 +3,21 @@ package cn.axzo.tyr.server.service.impl;
|
||||
import cn.axzo.basics.common.BeanMapper;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.DictTypeFiledEnum;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictQueryReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.*;
|
||||
import cn.axzo.tyr.client.model.dict.response.BasicDictNodeResp;
|
||||
import cn.axzo.tyr.client.model.dict.response.BasicDictTreeResp;
|
||||
import cn.axzo.tyr.server.repository.SaasBasicDictDao;
|
||||
import cn.axzo.tyr.server.service.SaasBasicDictService;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author: chenwenjian
|
||||
@ -30,16 +35,90 @@ public class SaasBasicDictServiceImpl implements SaasBasicDictService {
|
||||
|
||||
@Override
|
||||
public ApiResult<List<BasicDictNodeResp>> getBasicDictNodeList(BasicDictQueryReq req) {
|
||||
return ApiResult.ok(saasBasicDictDao.getBasicDictNodeList(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取节点树
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ApiResult<List<BasicDictTreeResp>> getBasicDictNodeTree(DictTypeFiledEnum type) {
|
||||
// 获取所有节点
|
||||
List<BasicDictNodeResp> basicDictNodeList = saasBasicDictDao.getBasicDictNodeList(null);
|
||||
// 单侧树
|
||||
if (Objects.nonNull(type)){
|
||||
List<BasicDictNodeResp> unilateralTreeNodeList = basicDictNodeList.stream()
|
||||
.filter(b -> b.getType().equals(type.getValue()) || b.getType().equals(DictTypeFiledEnum.WORKSPACE.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
return ApiResult.ok(constructDictTree(unilateralTreeNodeList));
|
||||
}
|
||||
return ApiResult.ok(constructDictTree(basicDictNodeList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据节点列表构建节点树
|
||||
* @param nodeList 节点列表
|
||||
* @return 节点树
|
||||
*/
|
||||
public List<BasicDictTreeResp> constructDictTree(List<BasicDictNodeResp> nodeList) {
|
||||
if (CollectionUtil.isEmpty(nodeList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayList<BasicDictTreeResp> root = new ArrayList<>();
|
||||
LinkedHashMap<Long, BasicDictTreeResp> map = new LinkedHashMap<>();
|
||||
|
||||
nodeList.forEach(node -> {
|
||||
BasicDictTreeResp treeNode = BeanMapper.copyBean(node, BasicDictTreeResp.class);
|
||||
map.put(node.getId(), treeNode);
|
||||
if (node.getParentId() == 0){
|
||||
root.add(treeNode);
|
||||
}
|
||||
});
|
||||
map.values().forEach(treeNode -> {
|
||||
BasicDictTreeResp parent = map.get(treeNode.getParentId());
|
||||
if (Objects.nonNull(parent)){
|
||||
if (Objects.isNull(parent.getChildren())){
|
||||
parent.setChildren(new ArrayList<>());
|
||||
}
|
||||
parent.getChildren().add(treeNode);
|
||||
}
|
||||
});
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取节点详情
|
||||
*
|
||||
* @param req type和code
|
||||
* @return 一个字典节点
|
||||
*/
|
||||
@Override
|
||||
public ApiResult<BasicDictNodeResp> getBasicDictNode(BasicDictNodeReq req) {
|
||||
return ApiResult.ok(saasBasicDictDao.getBasicDictNode(req));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Long> create(BasicDictCreateReq req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<BasicDictTreeResp> getBasicDictNodeTree(DictTypeFiledEnum type) {
|
||||
public ApiResult<Boolean> update(BasicDictUpdateReq req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Boolean> updateStauts(BasicDictUpdateStatusReq req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<BasicDictNodeResp> getById(Long id) {
|
||||
return ApiResult.ok(BeanMapper.copyBean(saasBasicDictDao.getById(id), BasicDictNodeResp.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
package cn.axzo.tyr.server.service.impl;
|
||||
|
||||
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroupRelation;
|
||||
import cn.axzo.tyr.server.repository.service.SaasRoleGroupDao;
|
||||
import cn.axzo.tyr.server.repository.service.SaasRoleGroupRelationDao;
|
||||
import cn.axzo.tyr.server.service.SaasRoleGroupService;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
|
||||
private final SaasRoleGroupDao saasRoleGroupDao;
|
||||
private final SaasRoleGroupRelationDao saasRoleGroupRelationDao;
|
||||
|
||||
@Override
|
||||
public List<SaasRoleGroupVO> getList(QuerySaasRoleGroupReq req) {
|
||||
List<SaasRoleGroup> groups = saasRoleGroupDao.query(req);
|
||||
if (CollectionUtils.isEmpty(groups)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<SaasRoleGroupRelation> saasRoleGroupRelations = saasRoleGroupRelationDao.lambdaQuery().in(SaasRoleGroupRelation::getSaasRoleGroupId, groups.stream().map(SaasRoleGroup::getId))
|
||||
.eq(SaasRoleGroupRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
|
||||
Map<Long, List<Long>> groupRoleMap = saasRoleGroupRelations.stream().collect(Collectors.groupingBy(SaasRoleGroupRelation::getSaasRoleGroupId, Collectors.mapping(SaasRoleGroupRelation::getRoleId, Collectors.toList())));
|
||||
List<SaasRoleGroupVO> results = groups.stream().map(e -> {
|
||||
SaasRoleGroupVO target = BeanUtil.copyProperties(e, SaasRoleGroupVO.class);
|
||||
if (StringUtils.isNotBlank(e.getOuTypeCode())) {
|
||||
target.setOuTypeCode(Arrays.stream(e.getOuTypeCode().split(",")).filter(StringUtils::isNotBlank).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()));
|
||||
}
|
||||
target.setRoleIds(groupRoleMap.get(e.getId()));
|
||||
return target;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
@ -8,7 +8,7 @@ spring:
|
||||
file-extension: yaml
|
||||
namespace: ${NACOS_NAMESPACE_ID}
|
||||
profiles:
|
||||
active: ${NACOS_PROFILES_ACTIVE:local}
|
||||
active: ${NACOS_PROFILES_ACTIVE:dev}
|
||||
include: swagger
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
|
||||
Loading…
Reference in New Issue
Block a user