收音机页面路径配置

This commit is contained in:
张松
2025-04-02 14:22:52 +08:00
parent 3e3269e8bc
commit b976f041a3
14 changed files with 421 additions and 0 deletions

View File

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