添加根据地图一键领权限功能
This commit is contained in:
parent
c802b2115f
commit
2d3a2f25ee
@ -106,6 +106,6 @@ public class GoodsController {
|
|||||||
@ApiOperation(value = "根据权限ids查询权限包商品")
|
@ApiOperation(value = "根据权限ids查询权限包商品")
|
||||||
@GetMapping(path = "/permissionIds")
|
@GetMapping(path = "/permissionIds")
|
||||||
public GoodsVO findGoodsByPermissionIds(Long[] ids) {
|
public GoodsVO findGoodsByPermissionIds(Long[] ids) {
|
||||||
return iGoodsService.findGoodsByPermissionIds(ids);
|
return iGoodsService.findGoodsByRelPermissionIds(ids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,4 +76,10 @@ public class UserPermissionController {
|
|||||||
return iUserPermissionService.queryPersonalUserPermission(user);
|
return iUserPermissionService.queryPersonalUserPermission(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("根据地图一键领取权限")
|
||||||
|
@PostMapping("/{mapId}/getPermissions")
|
||||||
|
public void getPermissions4Map(@PathVariable Long mapId, Integer count ,@RequestAttribute @ApiIgnore UserVO user) {
|
||||||
|
iUserPermissionService.getPermissions4Map(mapId, count, user);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package club.joylink.rtss.services;
|
package club.joylink.rtss.services;
|
||||||
|
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
|
||||||
import com.github.pagehelper.Page;
|
|
||||||
import com.github.pagehelper.PageHelper;
|
|
||||||
import club.joylink.rtss.constants.BusinessConsts;
|
import club.joylink.rtss.constants.BusinessConsts;
|
||||||
import club.joylink.rtss.constants.SaleGoodsTypeEnum;
|
import club.joylink.rtss.constants.SaleGoodsTypeEnum;
|
||||||
import club.joylink.rtss.constants.StatusEnum;
|
import club.joylink.rtss.constants.StatusEnum;
|
||||||
@ -13,6 +10,7 @@ import club.joylink.rtss.entity.Permission;
|
|||||||
import club.joylink.rtss.entity.PermissionExample;
|
import club.joylink.rtss.entity.PermissionExample;
|
||||||
import club.joylink.rtss.entity.SaleGoods;
|
import club.joylink.rtss.entity.SaleGoods;
|
||||||
import club.joylink.rtss.entity.SaleGoodsExample;
|
import club.joylink.rtss.entity.SaleGoodsExample;
|
||||||
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.vo.UserVO;
|
import club.joylink.rtss.vo.UserVO;
|
||||||
import club.joylink.rtss.vo.client.GoodsTryVO;
|
import club.joylink.rtss.vo.client.GoodsTryVO;
|
||||||
import club.joylink.rtss.vo.client.PageVO;
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
@ -22,14 +20,19 @@ import club.joylink.rtss.vo.client.goods.GoodsVO;
|
|||||||
import club.joylink.rtss.vo.client.permission.PermissionQueryVO;
|
import club.joylink.rtss.vo.client.permission.PermissionQueryVO;
|
||||||
import club.joylink.rtss.vo.client.permission.PermissionSelectVO;
|
import club.joylink.rtss.vo.client.permission.PermissionSelectVO;
|
||||||
import club.joylink.rtss.vo.client.permission.PermissionVO;
|
import club.joylink.rtss.vo.client.permission.PermissionVO;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -151,7 +154,7 @@ public class GoodsService implements IGoodsService {
|
|||||||
* 如果有权限包但没有对应的商品,返回一个只有permissionId和permissionName的goodsVO
|
* 如果有权限包但没有对应的商品,返回一个只有permissionId和permissionName的goodsVO
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public GoodsVO findGoodsByPermissionIds(Long[] relPermissionIds) {
|
public GoodsVO findGoodsByRelPermissionIds(Long[] relPermissionIds) {
|
||||||
List<PermissionVO> voList = iPermissionService.findPermissionByRelPermissionIds(Arrays.asList(relPermissionIds));
|
List<PermissionVO> voList = iPermissionService.findPermissionByRelPermissionIds(Arrays.asList(relPermissionIds));
|
||||||
if (voList.isEmpty()) {
|
if (voList.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
@ -238,6 +241,15 @@ public class GoodsService implements IGoodsService {
|
|||||||
return goods != null;
|
return goods != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GoodsVO> getByPermissionIds(List<Long> permissionIds) {
|
||||||
|
SaleGoodsExample example = new SaleGoodsExample();
|
||||||
|
example.createCriteria().andPermissionIdIn(permissionIds);
|
||||||
|
List<SaleGoods> saleGoods = saleGoodsDAO.selectByExample(example);
|
||||||
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(saleGoods);
|
||||||
|
return saleGoods.stream().map(GoodsVO::new).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
public SaleGoods findEntity(Long id) {
|
public SaleGoods findEntity(Long id) {
|
||||||
return saleGoodsDAO.selectByPrimaryKey(id);
|
return saleGoodsDAO.selectByPrimaryKey(id);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public interface IGoodsService {
|
|||||||
/**
|
/**
|
||||||
* 通过关联权限ids查询权限包商品
|
* 通过关联权限ids查询权限包商品
|
||||||
*/
|
*/
|
||||||
GoodsVO findGoodsByPermissionIds(Long[] relPermissionIds);
|
GoodsVO findGoodsByRelPermissionIds(Long[] relPermissionIds);
|
||||||
|
|
||||||
PageVO<GoodsVO> queryPagedGoodsByPermission(PermissionQueryVO queryVO);
|
PageVO<GoodsVO> queryPagedGoodsByPermission(PermissionQueryVO queryVO);
|
||||||
|
|
||||||
@ -65,4 +65,5 @@ public interface IGoodsService {
|
|||||||
|
|
||||||
boolean isExist(Long goodsId);
|
boolean isExist(Long goodsId);
|
||||||
|
|
||||||
|
List<GoodsVO> getByPermissionIds(List<Long> permissionIds);
|
||||||
}
|
}
|
||||||
|
@ -54,4 +54,6 @@ public interface IPermissionService {
|
|||||||
* 根据mapId查询教学权限
|
* 根据mapId查询教学权限
|
||||||
*/
|
*/
|
||||||
Permission findTeachPermissionEntity(Long mapId);
|
Permission findTeachPermissionEntity(Long mapId);
|
||||||
|
|
||||||
|
List<PermissionVO> getByMapId(Long mapId);
|
||||||
}
|
}
|
||||||
|
@ -87,4 +87,12 @@ public interface IUserPermissionService {
|
|||||||
* 查询有效的用户教学权限
|
* 查询有效的用户教学权限
|
||||||
*/
|
*/
|
||||||
List<UserPermission> findEntity(List<Long> userIds, Boolean valid);
|
List<UserPermission> findEntity(List<Long> userIds, Boolean valid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 给该用户领取该地图的权限
|
||||||
|
* @param mapId
|
||||||
|
* @param count
|
||||||
|
* @param user
|
||||||
|
*/
|
||||||
|
void getPermissions4Map(Long mapId, Integer count, UserVO user);
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,7 @@ public class PermissionService implements IPermissionService {
|
|||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
.andRelPermissionsEqualTo(ids);
|
.andRelPermissionsEqualTo(ids);
|
||||||
List<Permission> permissionList = permissionDAO.selectByExample(example);
|
List<Permission> permissionList = permissionDAO.selectByExample(example);
|
||||||
List<PermissionVO> voList = permissionList.stream().map(permission -> new PermissionVO(permission)).collect(Collectors.toList());
|
List<PermissionVO> voList = permissionList.stream().map(PermissionVO::new).collect(Collectors.toList());
|
||||||
return voList;
|
return voList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,8 +468,7 @@ public class PermissionService implements IPermissionService {
|
|||||||
PermissionExample example = new PermissionExample();
|
PermissionExample example = new PermissionExample();
|
||||||
example.createCriteria().andMapIdEqualTo(mapId);
|
example.createCriteria().andMapIdEqualTo(mapId);
|
||||||
List<Permission> permissionList = permissionDAO.selectByExample(example);
|
List<Permission> permissionList = permissionDAO.selectByExample(example);
|
||||||
List<PermissionVO> voList = permissionList.stream().map(permission -> new PermissionVO(permission)).collect(Collectors.toList());
|
return permissionList.stream().map(PermissionVO::new).collect(Collectors.toList());
|
||||||
return voList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -535,6 +534,13 @@ public class PermissionService implements IPermissionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PermissionVO> getByMapId(Long mapId) {
|
||||||
|
List<PermissionVO> permissions = findByMapId(mapId);
|
||||||
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(permissions, String.format("地图[%s]下没有权限", mapId));
|
||||||
|
return permissions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据mapId获取该地图下的综合演练权限
|
* 根据mapId获取该地图下的综合演练权限
|
||||||
*/
|
*/
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package club.joylink.rtss.services;
|
package club.joylink.rtss.services;
|
||||||
|
|
||||||
import club.joylink.rtss.constants.MapPrdTypeEnum;
|
import club.joylink.rtss.constants.*;
|
||||||
import club.joylink.rtss.constants.PermissionTypeEnum;
|
|
||||||
import club.joylink.rtss.constants.StatusEnum;
|
|
||||||
import club.joylink.rtss.constants.UserPermissionStatusEnum;
|
|
||||||
import club.joylink.rtss.dao.PermissionDAO;
|
import club.joylink.rtss.dao.PermissionDAO;
|
||||||
import club.joylink.rtss.dao.SysUserDAO;
|
import club.joylink.rtss.dao.SysUserDAO;
|
||||||
import club.joylink.rtss.dao.UserPermissionDAO;
|
import club.joylink.rtss.dao.UserPermissionDAO;
|
||||||
@ -13,7 +10,11 @@ import club.joylink.rtss.entity.UserPermission;
|
|||||||
import club.joylink.rtss.entity.UserPermissionExample;
|
import club.joylink.rtss.entity.UserPermissionExample;
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.vo.UserVO;
|
import club.joylink.rtss.vo.UserVO;
|
||||||
|
import club.joylink.rtss.vo.client.OrganizationVO;
|
||||||
import club.joylink.rtss.vo.client.PageVO;
|
import club.joylink.rtss.vo.client.PageVO;
|
||||||
|
import club.joylink.rtss.vo.client.goods.GoodsVO;
|
||||||
|
import club.joylink.rtss.vo.client.order.OrderCreateVO;
|
||||||
|
import club.joylink.rtss.vo.client.order.OrderDetailCreateVO;
|
||||||
import club.joylink.rtss.vo.client.permission.DistributeSelectVO;
|
import club.joylink.rtss.vo.client.permission.DistributeSelectVO;
|
||||||
import club.joylink.rtss.vo.client.permission.PermissionQueryVO;
|
import club.joylink.rtss.vo.client.permission.PermissionQueryVO;
|
||||||
import club.joylink.rtss.vo.client.permission.PermissionVO;
|
import club.joylink.rtss.vo.client.permission.PermissionVO;
|
||||||
@ -27,6 +28,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -59,6 +61,9 @@ public class UserPermissionService implements IUserPermissionService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IOrderService iOrderService;
|
private IOrderService iOrderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IOrganizationService iOrganizationService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageVO<UserPermissionVO> queryPagedPermission(PermissionQueryVO queryVO) {
|
public PageVO<UserPermissionVO> queryPagedPermission(PermissionQueryVO queryVO) {
|
||||||
List<Long> relDistributeIds = new ArrayList<>();
|
List<Long> relDistributeIds = new ArrayList<>();
|
||||||
@ -512,6 +517,33 @@ public class UserPermissionService implements IUserPermissionService {
|
|||||||
return userPermissionDAO.selectByExample(example);
|
return userPermissionDAO.selectByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getPermissions4Map(Long mapId, Integer count, UserVO user) {
|
||||||
|
if (count == null || count == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<OrganizationVO> organizations = iOrganizationService.queryOrganization();
|
||||||
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(organizations, "没有组织数据");
|
||||||
|
|
||||||
|
List<PermissionVO> permissions = iPermissionService.getByMapId(mapId);
|
||||||
|
List<GoodsVO> goods = iGoodsService.getByPermissionIds(permissions.stream().map(PermissionVO::getId).collect(Collectors.toList()));
|
||||||
|
List<OrderDetailCreateVO> orderDetails = goods.stream().map(goodsVO -> new OrderDetailCreateVO(goodsVO.getId(), count)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
OrderCreateVO orderCreate = new OrderCreateVO();
|
||||||
|
orderCreate.setOrganizationId(48L);
|
||||||
|
orderCreate.setOrderType(SaleOrderTypeEnum.Internal_Distribution.getCode());
|
||||||
|
orderCreate.setForever(true);
|
||||||
|
orderCreate.setStartTime(LocalDateTime.now());
|
||||||
|
orderCreate.setPayStatus(SaleOrderPayStatusEnum.No_Need.getCode());
|
||||||
|
orderCreate.setDetailCreateVOList(orderDetails);
|
||||||
|
//创建权限分发并领取权限
|
||||||
|
String orderCode = iOrderService.createOrder(orderCreate, user);
|
||||||
|
iPermissionDistributeService.distributeFromOrder(orderCode, user);
|
||||||
|
DistributeVO distribute = iPermissionDistributeService.getByOrderCode(orderCode);
|
||||||
|
Long distributeId = distribute.getId();
|
||||||
|
iPermissionDistributeService.getUserPermission(distributeId, user);
|
||||||
|
}
|
||||||
|
|
||||||
private List<UserPermissionVO> findByUserId(Long userId) {
|
private List<UserPermissionVO> findByUserId(Long userId) {
|
||||||
UserPermissionExample example = new UserPermissionExample();
|
UserPermissionExample example = new UserPermissionExample();
|
||||||
example.createCriteria().andUserIdEqualTo(userId);
|
example.createCriteria().andUserIdEqualTo(userId);
|
||||||
|
Loading…
Reference in New Issue
Block a user