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:
陈维伟 2023-09-11 11:33:43 +08:00
commit e25cc8f8a4
6 changed files with 103 additions and 4 deletions

View File

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
* 角色分组
*/
@FeignClient(name = "tyr", url = "${axzo.service.maokai:http://tyr:8080/api/saasRoleGroup}")
public interface SaasRoleGoupApi {
public interface SaasRoleGroupApi {
/**
* 保存/更新

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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, productModule.getId())
.set(ProductModule::getIsDelete, productModule.getId())
.update();
return ApiResult.ok(BeanMapper.copyBean(productModule, ProductVO.class));
}
}

View File

@ -130,6 +130,9 @@ 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()

View File

@ -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;
}
}