Merge remote-tracking branch 'origin/feature/REQ-1102' into feature/REQ-1102
# Conflicts: # tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/RoleServiceImpl.java
This commit is contained in:
commit
e25cc8f8a4
@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
* 角色分组
|
* 角色分组
|
||||||
*/
|
*/
|
||||||
@FeignClient(name = "tyr", url = "${axzo.service.maokai:http://tyr:8080/api/saasRoleGroup}")
|
@FeignClient(name = "tyr", url = "${axzo.service.maokai:http://tyr:8080/api/saasRoleGroup}")
|
||||||
public interface SaasRoleGoupApi {
|
public interface SaasRoleGroupApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存/更新
|
* 保存/更新
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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
|
@Override
|
||||||
public ApiResult<ProductVO> update(ProductUpdateReq req) {
|
public ApiResult<ProductVO> update(ProductUpdateReq req) {
|
||||||
ProductModule productModule = productModuleDao.getById(req.getId());
|
ProductModule productModule = productModuleDao.getById(req.getId());
|
||||||
BeanMapper.copyBeanIgnoreNull(req, ()-> productModule);
|
BeanMapper.copyBeanIgnoreNull(req, () -> productModule);
|
||||||
productModuleDao.updateById(productModule);
|
productModuleDao.updateById(productModule);
|
||||||
return ApiResult.ok(BeanMapper.copyBeanIgnoreNull(productModule, ProductVO.class));
|
return ApiResult.ok(BeanMapper.copyBeanIgnoreNull(productModule, ProductVO.class));
|
||||||
}
|
}
|
||||||
@ -80,8 +80,10 @@ public class ProductServiceImpl implements ProductService {
|
|||||||
public ApiResult<ProductVO> delete(Long id) {
|
public ApiResult<ProductVO> delete(Long id) {
|
||||||
ProductModule productModule = productModuleDao.getById(id);
|
ProductModule productModule = productModuleDao.getById(id);
|
||||||
AssertUtil.isTrue(Objects.nonNull(productModule), "产品不存在");
|
AssertUtil.isTrue(Objects.nonNull(productModule), "产品不存在");
|
||||||
productModule.setIsDelete(id);
|
productModuleDao.lambdaUpdate()
|
||||||
productModuleDao.updateById(productModule);
|
.eq(ProductModule::getId, productModule.getId())
|
||||||
|
.set(ProductModule::getIsDelete, productModule.getId())
|
||||||
|
.update();
|
||||||
return ApiResult.ok(BeanMapper.copyBean(productModule, ProductVO.class));
|
return ApiResult.ok(BeanMapper.copyBean(productModule, ProductVO.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -130,6 +130,9 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
groupRelation = roleGroupRelationDao.lambdaQuery()
|
groupRelation = roleGroupRelationDao.lambdaQuery()
|
||||||
.in(SaasRoleGroupRelation::getSaasRoleGroupId, roleGroup.stream().map(BaseEntity::getId).collect(Collectors.toList()))
|
.in(SaasRoleGroupRelation::getSaasRoleGroupId, roleGroup.stream().map(BaseEntity::getId).collect(Collectors.toList()))
|
||||||
.list();
|
.list();
|
||||||
|
if (CollectionUtils.isEmpty(groupRelation)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 查询角色
|
// 查询角色
|
||||||
List<SaasRole> list = saasRoleDao.lambdaQuery()
|
List<SaasRole> list = saasRoleDao.lambdaQuery()
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user