默认初始化页面权限
This commit is contained in:
parent
989945d85e
commit
7d311bb3a0
|
|
@ -56,12 +56,10 @@ public class ShopPagePermissionController {
|
|||
*/
|
||||
@GetMapping("/detail")
|
||||
public CzgResult<List<ShopPagePath>> detail(@RequestParam Long staffId) {
|
||||
Set<Long> pageIdList = shopStaffPagePermissionService.list(new QueryWrapper().eq(ShopStaffPagePermission::getShopId,
|
||||
StpKit.USER.getShopId()).eq(ShopStaffPagePermission::getStaffId, staffId)).stream().map(ShopStaffPagePermission::getPagePathId).collect(Collectors.toSet());
|
||||
if (pageIdList.isEmpty()) {
|
||||
return CzgResult.success(new ArrayList<>());
|
||||
if (StpKit.USER.isStaff() && StpKit.USER.getLoginIdAsLong() != staffId) {
|
||||
return CzgResult.failure("员工无权限");
|
||||
}
|
||||
return CzgResult.success(shopPagePathService.list(new QueryWrapper().in(ShopPagePath::getId, pageIdList)));
|
||||
return CzgResult.success(shopPagePathService.detail(staffId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.czg.account.service;
|
|||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.ShopPagePath;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务层。
|
||||
*
|
||||
|
|
@ -11,4 +13,5 @@ import com.czg.account.entity.ShopPagePath;
|
|||
*/
|
||||
public interface ShopPagePathService extends IService<ShopPagePath> {
|
||||
|
||||
List<ShopPagePath> detail(Long staffId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,22 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.czg.account.entity.ShopStaffPagePermission;
|
||||
import com.czg.account.service.ShopStaffPagePermissionService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopPagePath;
|
||||
import com.czg.account.service.ShopPagePathService;
|
||||
import com.czg.service.account.mapper.ShopPagePathMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
|
|
@ -14,5 +26,24 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service
|
||||
public class ShopPagePathServiceImpl extends ServiceImpl<ShopPagePathMapper, ShopPagePath> implements ShopPagePathService{
|
||||
@Resource
|
||||
private ShopStaffPagePermissionService shopStaffPagePermissionService;
|
||||
|
||||
@Override
|
||||
public List<ShopPagePath> detail(Long staffId) {
|
||||
Set<Long> pageIdList = shopStaffPagePermissionService.list(new QueryWrapper().eq(ShopStaffPagePermission::getShopId,
|
||||
StpKit.USER.getShopId()).eq(ShopStaffPagePermission::getStaffId, staffId)).stream().map(ShopStaffPagePermission::getPagePathId).collect(Collectors.toSet());
|
||||
if (pageIdList.isEmpty()) {
|
||||
list().forEach(item -> {
|
||||
ShopStaffPagePermission permission = new ShopStaffPagePermission();
|
||||
permission.setShopId(StpKit.USER.getShopId());
|
||||
permission.setStaffId(staffId);
|
||||
permission.setPagePathId(item.getId());
|
||||
shopStaffPagePermissionService.save(permission);
|
||||
pageIdList.add(permission.getPagePathId());
|
||||
});
|
||||
}
|
||||
|
||||
return list(new QueryWrapper().in(ShopPagePath::getId, pageIdList));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue