<一键创建项目下所有地图的权限分发>接口自动给没有权限的地图生成权限

This commit is contained in:
joylink_zhangsai 2020-12-14 17:16:04 +08:00
parent 4e5cd4dce4
commit f2bea7bed0
2 changed files with 10 additions and 4 deletions

View File

@ -40,6 +40,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -668,6 +669,14 @@ public class PermissionDistributeService implements IPermissionDistributeService
String.format("项目[%s]下没有地图", project)); String.format("项目[%s]下没有地图", project));
List<Long> mapIds = maps.stream().map(MapVO::getId).collect(Collectors.toList()); List<Long> mapIds = maps.stream().map(MapVO::getId).collect(Collectors.toList());
List<Permission> permissions = iPermissionService.getJointAndTeachEntities(mapIds); List<Permission> permissions = iPermissionService.getJointAndTeachEntities(mapIds);
Map<Long, List<Permission>> groupByMapId = permissions.stream().collect(Collectors.groupingBy(Permission::getMapId));
List<Long> newMapIds = mapIds;
newMapIds.removeAll(groupByMapId.keySet());
if (!CollectionUtils.isEmpty(newMapIds)) {
newMapIds.forEach(mapId -> iPermissionService.generatePermission(mapId, user));
permissions = iPermissionService.getJointAndTeachEntities(mapIds);
}
List<GoodsVO> goodsList = iGoodsService.getByPermissionIds(permissions.stream().map(Permission::getId).collect(Collectors.toList())); List<GoodsVO> goodsList = iGoodsService.getByPermissionIds(permissions.stream().map(Permission::getId).collect(Collectors.toList()));
List<OrderDetailCreateVO> orderDetails = goodsList.stream().map(goodsVO -> new OrderDetailCreateVO(goodsVO.getId(), num)).collect(Collectors.toList()); List<OrderDetailCreateVO> orderDetails = goodsList.stream().map(goodsVO -> new OrderDetailCreateVO(goodsVO.getId(), num)).collect(Collectors.toList());
OrderCreateVO orderCreateVO = iOrderService.createInternalOrderCreateVO(null, orderDetails); OrderCreateVO orderCreateVO = iOrderService.createInternalOrderCreateVO(null, orderDetails);

View File

@ -554,10 +554,7 @@ public class PermissionService implements IPermissionService {
example.or() example.or()
.andMapIdIn(mapIds) .andMapIdIn(mapIds)
.andNameLike(String.format("%%%s%%", "Comprehensive exercise cloud platform")); .andNameLike(String.format("%%%s%%", "Comprehensive exercise cloud platform"));
List<Permission> permissions = permissionDAO.selectByExample(example); return permissionDAO.selectByExample(example);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(permissions,
"权限数据不存在");
return permissions;
} }
/** /**