收音机页面路径配置
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.pagepath.PagePathPermissionAddDTO;
|
||||
import com.czg.account.entity.ShopPagePath;
|
||||
import com.czg.account.entity.ShopStaffPagePermission;
|
||||
import com.czg.account.service.ShopPagePathService;
|
||||
import com.czg.account.service.ShopStaffPagePermissionService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 收银机页面权限相关
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/shopPagePermission")
|
||||
public class ShopPagePermissionController {
|
||||
@Resource
|
||||
private ShopPagePathService shopPagePathService;
|
||||
@Resource
|
||||
private ShopStaffPagePermissionService shopStaffPagePermissionService;
|
||||
|
||||
/**
|
||||
* 获取所有页面路径
|
||||
* @return 页面路径
|
||||
*/
|
||||
@GetMapping
|
||||
public CzgResult<List<ShopPagePath>> page() {
|
||||
return CzgResult.success(shopPagePathService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存修改权限
|
||||
* @return 是否成功
|
||||
*/
|
||||
@PostMapping
|
||||
public CzgResult<Boolean> add(PagePathPermissionAddDTO pagePathPermissionAddDTO) {
|
||||
if (StpKit.USER.isStaff()) {
|
||||
return CzgResult.failure("员工无权限");
|
||||
}
|
||||
return CzgResult.success(shopStaffPagePermissionService.add(StpKit.USER.getShopId(), pagePathPermissionAddDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户已拥有页面路径
|
||||
*/
|
||||
@GetMapping("/mine")
|
||||
public CzgResult<List<ShopPagePath>> mine() {
|
||||
Set<Long> pageIdList = shopStaffPagePermissionService.list(new QueryWrapper().eq(ShopStaffPagePermission::getShopId, StpKit.USER.getShopId()).eq(ShopStaffPagePermission::getStaffId, StpKit.USER.getLoginIdAsLong())).stream().map(ShopStaffPagePermission::getPagePathId).collect(Collectors.toSet());
|
||||
if (pageIdList.isEmpty()) {
|
||||
return CzgResult.success(new ArrayList<>());
|
||||
}
|
||||
return CzgResult.success(shopPagePathService.list(new QueryWrapper().in(ShopPagePath::getId, pageIdList)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user