员工权限完善

This commit is contained in:
张松 2025-03-11 09:48:47 +08:00
parent 27635d7b0d
commit b6229f24e4
6 changed files with 54 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import com.czg.account.entity.HandoverRecord;
import com.czg.account.service.HandoverRecordService; import com.czg.account.service.HandoverRecordService;
import com.czg.account.vo.HandoverProductListVo; import com.czg.account.vo.HandoverProductListVo;
import com.czg.account.vo.HandoverTotalVo; import com.czg.account.vo.HandoverTotalVo;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.enums.YesNoEnum; import com.czg.enums.YesNoEnum;
import com.czg.log.annotation.OperationLog; import com.czg.log.annotation.OperationLog;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
@ -37,6 +38,7 @@ public class HandoverRecordController {
*/ */
@GetMapping("page") @GetMapping("page")
@OperationLog("交班记录-分页") @OperationLog("交班记录-分页")
@SaStaffCheckPermission("yun_xu_cha_kan_suo_you_jiao_ban_ji_lu")
//@SaAdminCheckPermission("handoverRecord:page") //@SaAdminCheckPermission("handoverRecord:page")
public CzgResult<Page<HandoverRecordDTO>> page(@RequestParam(required = false) String beginDate, @RequestParam(required = false) String endDate) { public CzgResult<Page<HandoverRecordDTO>> page(@RequestParam(required = false) String beginDate, @RequestParam(required = false) String endDate) {
Page<HandoverRecordDTO> page = handoverRecordService.getHandoverRecordPage(beginDate, endDate); Page<HandoverRecordDTO> page = handoverRecordService.getHandoverRecordPage(beginDate, endDate);
@ -50,6 +52,7 @@ public class HandoverRecordController {
*/ */
@GetMapping("{id}") @GetMapping("{id}")
@OperationLog("交班记录-查看") @OperationLog("交班记录-查看")
@SaStaffCheckPermission("yun_xu_cha_kan_suo_you_jiao_ban_ji_lu")
//@SaAdminCheckPermission("handoverRecord:info") //@SaAdminCheckPermission("handoverRecord:info")
public CzgResult<List<HandoverProductListVo>> info(@PathVariable Long id) { public CzgResult<List<HandoverProductListVo>> info(@PathVariable Long id) {
List<HandoverProductListVo> data = handoverRecordService.getHandoverProductListById(id); List<HandoverProductListVo> data = handoverRecordService.getHandoverProductListById(id);
@ -64,6 +67,7 @@ public class HandoverRecordController {
@ResponseExcel(name = "交班售出商品明细") @ResponseExcel(name = "交班售出商品明细")
@GetMapping("/export/{id}") @GetMapping("/export/{id}")
@OperationLog("交班记录-导出") @OperationLog("交班记录-导出")
@SaStaffCheckPermission("yun_xu_cha_kan_suo_you_jiao_ban_ji_lu")
//@SaAdminCheckPermission("handoverRecord:export") //@SaAdminCheckPermission("handoverRecord:export")
public List<HandoverProductListVo> export(@PathVariable Long id) { public List<HandoverProductListVo> export(@PathVariable Long id) {
return handoverRecordService.getHandoverProductListById(id); return handoverRecordService.getHandoverProductListById(id);
@ -74,6 +78,7 @@ public class HandoverRecordController {
*/ */
@GetMapping("total") @GetMapping("total")
@OperationLog("收银机-交班数据统计") @OperationLog("收银机-交班数据统计")
@SaStaffCheckPermission("yun_xu_cha_kan_suo_you_jiao_ban_ji_lu")
//@SaAdminCheckPermission("handoverRecord:total") //@SaAdminCheckPermission("handoverRecord:total")
public CzgResult<HandoverTotalVo> total() { public CzgResult<HandoverTotalVo> total() {
HandoverTotalVo data = handoverRecordService.totalHandoverData(); HandoverTotalVo data = handoverRecordService.totalHandoverData();
@ -87,6 +92,7 @@ public class HandoverRecordController {
*/ */
@PostMapping("handover") @PostMapping("handover")
@OperationLog("收银机-交班/关班") @OperationLog("收银机-交班/关班")
@SaStaffCheckPermission("yun_xu_jiao_ban")
//@SaAdminCheckPermission("handoverRecord:handover") //@SaAdminCheckPermission("handoverRecord:handover")
public CzgResult<Long> handover(@RequestParam Integer isPrint) { public CzgResult<Long> handover(@RequestParam Integer isPrint) {
Long id = handoverRecordService.handover(); Long id = handoverRecordService.handover();
@ -101,6 +107,7 @@ public class HandoverRecordController {
*/ */
@PostMapping("/network/print/{id}") @PostMapping("/network/print/{id}")
@OperationLog("收银机-交班/关班") @OperationLog("收银机-交班/关班")
@SaStaffCheckPermission("yun_xu_cha_kan_suo_you_jiao_ban_ji_lu")
//@SaAdminCheckPermission("handoverRecord:networkPrint") //@SaAdminCheckPermission("handoverRecord:networkPrint")
public CzgResult<Void> handover(@PathVariable Long id) { public CzgResult<Void> handover(@PathVariable Long id) {
handoverRecordService.printHandoverReceipt(id, YesNoEnum.YES.value()); handoverRecordService.printHandoverReceipt(id, YesNoEnum.YES.value());
@ -122,4 +129,4 @@ public class HandoverRecordController {
return CzgResult.success(data); return CzgResult.success(data);
} }
} }

View File

@ -43,6 +43,7 @@ public class ShopUserController {
*/ */
@SaAdminCheckPermission("shopUser:summary") @SaAdminCheckPermission("shopUser:summary")
@GetMapping("/summary") @GetMapping("/summary")
@SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
public CzgResult<ShopUserSummaryDTO> summary(Integer isVip) { public CzgResult<ShopUserSummaryDTO> summary(Integer isVip) {
return CzgResult.success(shopUserService.getSummary(StpKit.USER.getShopId(), isVip)); return CzgResult.success(shopUserService.getSummary(StpKit.USER.getShopId(), isVip));
} }
@ -64,6 +65,7 @@ public class ShopUserController {
*/ */
@SaAdminCheckPermission("shopUser:flow") @SaAdminCheckPermission("shopUser:flow")
@GetMapping("/flow") @GetMapping("/flow")
@SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
public CzgResult<Page<ShopUserFlow>> flow(@RequestParam Integer userId, String bizCode) { public CzgResult<Page<ShopUserFlow>> flow(@RequestParam Integer userId, String bizCode) {
QueryWrapper queryWrapper = new QueryWrapper().eq(ShopUserFlow::getShopId, StpKit.USER.getShopId()) QueryWrapper queryWrapper = new QueryWrapper().eq(ShopUserFlow::getShopId, StpKit.USER.getShopId())
.eq(ShopUserFlow::getUserId, userId); .eq(ShopUserFlow::getUserId, userId);
@ -80,6 +82,7 @@ public class ShopUserController {
* @param isVip 0 非vip 1 vip * @param isVip 0 非vip 1 vip
* @return 用户列表 * @return 用户列表
*/ */
@SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
@SaAdminCheckPermission("shopUser:list") @SaAdminCheckPermission("shopUser:list")
@GetMapping @GetMapping
public CzgResult<Page<ShopUser>> list(String key, Integer isVip) { public CzgResult<Page<ShopUser>> list(String key, Integer isVip) {
@ -92,6 +95,7 @@ public class ShopUserController {
* @param userId 用户id * @param userId 用户id
* @return 用户详情 * @return 用户详情
*/ */
@SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
@SaAdminCheckPermission("shopUser:detail") @SaAdminCheckPermission("shopUser:detail")
@GetMapping("/detail") @GetMapping("/detail")
public CzgResult<ShopUser> detail(Integer id, Integer userId) { public CzgResult<ShopUser> detail(Integer id, Integer userId) {
@ -106,6 +110,7 @@ public class ShopUserController {
* *
* @return 是否成功 * @return 是否成功
*/ */
@SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
@SaAdminCheckPermission("shopUser:add") @SaAdminCheckPermission("shopUser:add")
@PostMapping @PostMapping
public CzgResult<Boolean> add(@RequestBody @Validated ShopUserAddDTO shopUserAddDTO) { public CzgResult<Boolean> add(@RequestBody @Validated ShopUserAddDTO shopUserAddDTO) {
@ -117,6 +122,7 @@ public class ShopUserController {
* *
* @return 是否成功 * @return 是否成功
*/ */
@SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
@SaAdminCheckPermission("shopUser:edit") @SaAdminCheckPermission("shopUser:edit")
@PutMapping @PutMapping
public CzgResult<Boolean> edit(@RequestBody @Validated ShopUserEditDTO shopUserEditDTO) { public CzgResult<Boolean> edit(@RequestBody @Validated ShopUserEditDTO shopUserEditDTO) {

View File

@ -1,5 +1,6 @@
package com.czg.controller; package com.czg.controller;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.service.order.dto.VipPayParamDTO; import com.czg.service.order.dto.VipPayParamDTO;
import com.czg.service.order.dto.VipRefundDTO; import com.czg.service.order.dto.VipRefundDTO;
@ -33,6 +34,7 @@ public class VipPayController {
* 现金充值 * 现金充值
* 如果shop_info的 is_member_in_pwd=1 则pwd必填 店铺操作密码 * 如果shop_info的 is_member_in_pwd=1 则pwd必填 店铺操作密码
*/ */
@SaStaffCheckPermission("yun_xu_shou_kuan")
@PostMapping("/cashPayVip") @PostMapping("/cashPayVip")
public CzgResult<Object> cashPayVip(@Validated @RequestBody VipPayParamDTO payParam) { public CzgResult<Object> cashPayVip(@Validated @RequestBody VipPayParamDTO payParam) {
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id"); AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
@ -67,6 +69,7 @@ public class VipPayController {
/** /**
* 正扫 * 正扫
*/ */
@SaStaffCheckPermission("yun_xu_shou_kuan")
@PostMapping("/scanPayVip") @PostMapping("/scanPayVip")
public CzgResult<Map<String, Object>> scanPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) { public CzgResult<Map<String, Object>> scanPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id"); AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
@ -78,6 +81,7 @@ public class VipPayController {
* 反扫 * 反扫
* authCode 必填 扫描码 * authCode 必填 扫描码
*/ */
@SaStaffCheckPermission("yun_xu_shou_kuan")
@PostMapping("/microPayVip") @PostMapping("/microPayVip")
public CzgResult<Map<String, Object>> microPayVip(@Validated @RequestBody VipPayParamDTO payParam) { public CzgResult<Map<String, Object>> microPayVip(@Validated @RequestBody VipPayParamDTO payParam) {
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id"); AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
@ -89,6 +93,7 @@ public class VipPayController {
* 退款前置 * 退款前置
* 最大退款金额 充值金额 inAmount * 最大退款金额 充值金额 inAmount
*/ */
@SaStaffCheckPermission("yun_xu_tui_kuan")
@PostMapping("/refundVipBefore") @PostMapping("/refundVipBefore")
public CzgResult<Map<String, BigDecimal>> refundVipBefore(@Validated @RequestBody VipRefundDTO payParam) { public CzgResult<Map<String, BigDecimal>> refundVipBefore(@Validated @RequestBody VipRefundDTO payParam) {
return payService.refundVipBefore(payParam); return payService.refundVipBefore(payParam);
@ -103,6 +108,7 @@ public class VipPayController {
* 实际可退最大金额为 充值金额 * 实际可退最大金额为 充值金额
* 如果实际 大于 理论 需要勾选 outOfRange 超额退款 为true 默认为false * 如果实际 大于 理论 需要勾选 outOfRange 超额退款 为true 默认为false
*/ */
@SaStaffCheckPermission("yun_xu_tui_kuan")
@PostMapping("/refundVip") @PostMapping("/refundVip")
public CzgResult<Object> refundVip(HttpServletRequest request, @Validated @RequestBody VipRefundDTO payParam) { public CzgResult<Object> refundVip(HttpServletRequest request, @Validated @RequestBody VipRefundDTO payParam) {
AssertUtil.isNull(payParam.getRefAmount(), "退款金额不能为空"); AssertUtil.isNull(payParam.getRefAmount(), "退款金额不能为空");

View File

@ -1,5 +1,6 @@
package com.czg.controller.admin; package com.czg.controller.admin;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.order.dto.OrderInfoAddDTO; import com.czg.order.dto.OrderInfoAddDTO;
import com.czg.order.dto.OrderInfoPrintDTO; import com.czg.order.dto.OrderInfoPrintDTO;
import com.czg.order.dto.OrderInfoQueryDTO; import com.czg.order.dto.OrderInfoQueryDTO;
@ -62,6 +63,7 @@ public class AdminOrderController {
return CzgResult.success(orderInfoService.historyOrder(orderId, tableCode)); return CzgResult.success(orderInfoService.historyOrder(orderId, tableCode));
} }
@SaStaffCheckPermission("yun_xu_xia_dan")
@PostMapping("/createOrder") @PostMapping("/createOrder")
public CzgResult<OrderInfo> createOrder(@Validated @RequestBody OrderInfoAddDTO addDto) { public CzgResult<OrderInfo> createOrder(@Validated @RequestBody OrderInfoAddDTO addDto) {
addDto.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType")); addDto.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
@ -85,6 +87,7 @@ public class AdminOrderController {
* 订单全额退款 只传订单id * 订单全额退款 只传订单id
* 部分退款 传参refundDetail * 部分退款 传参refundDetail
*/ */
@SaStaffCheckPermission("yun_xu_tui_kuan")
@PostMapping("/refundOrder") @PostMapping("/refundOrder")
public CzgResult<Object> refundOrder(@Validated @RequestBody OrderInfoRefundDTO refundDTO) { public CzgResult<Object> refundOrder(@Validated @RequestBody OrderInfoRefundDTO refundDTO) {
return payService.refundOrderBefore(refundDTO); return payService.refundOrderBefore(refundDTO);

View File

@ -2,6 +2,7 @@ package com.czg.controller.admin;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.config.RabbitPublisher; import com.czg.config.RabbitPublisher;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.log.annotation.OperationLog; import com.czg.log.annotation.OperationLog;
@ -87,8 +88,20 @@ public class ProductController {
@PutMapping @PutMapping
@OperationLog("商品-修改") @OperationLog("商品-修改")
@SaStaffCheckPermission("yun_xu_xiu_gai_shang_pin")
//@SaAdminCheckPermission("product:update") //@SaAdminCheckPermission("product:update")
public CzgResult<Void> updateProduct(@RequestBody @Validated({UpdateGroup.class, DefaultGroup.class}) ProductDTO dto) { public CzgResult<Void> updateProduct(@RequestBody @Validated({UpdateGroup.class, DefaultGroup.class}) ProductDTO dto) {
if (dto.getCategoryId() != null) {
StpKit.USER.checkStaffPermission("yun_xu_xiu_gai_fen_lei");
}
if (dto.getGroupCategoryId() != null) {
StpKit.USER.checkStaffPermission("yun_xu_xiu_gai_fen_zu");
}
if (dto.getStockNumber() != null) {
StpKit.USER.checkStaffPermission("yun_xu_xiu_gai_shang_pin_ku_cun");
}
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId); dto.setShopId(shopId);
productService.updateProduct(dto); productService.updateProduct(dto);
@ -100,6 +113,7 @@ public class ProductController {
@DeleteMapping("{id}") @DeleteMapping("{id}")
@OperationLog("商品-删除") @OperationLog("商品-删除")
@SaStaffCheckPermission("yun_xu_xiu_gai_shang_pin")
//@SaAdminCheckPermission("product:delete") //@SaAdminCheckPermission("product:delete")
public CzgResult<Void> deleteProduct(@PathVariable("id") Long id) { public CzgResult<Void> deleteProduct(@PathVariable("id") Long id) {
//效验数据 //效验数据
@ -117,6 +131,7 @@ public class ProductController {
*/ */
@PostMapping("onOff") @PostMapping("onOff")
@OperationLog("商品-上下架") @OperationLog("商品-上下架")
@SaStaffCheckPermission("yun_xu_shang_xia_jia_shang_pin")
//@SaAdminCheckPermission("product:on-off") //@SaAdminCheckPermission("product:on-off")
public CzgResult<Void> onOffProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSaleParam param) { public CzgResult<Void> onOffProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSaleParam param) {
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId(0L);
@ -133,6 +148,7 @@ public class ProductController {
*/ */
@PostMapping("markIsSoldOut") @PostMapping("markIsSoldOut")
@OperationLog("商品-标记售罄") @OperationLog("商品-标记售罄")
@SaStaffCheckPermission("yun_xu_shou_qing_shang_pin")
//@SaAdminCheckPermission("product:markIsSoldOut") //@SaAdminCheckPermission("product:markIsSoldOut")
public CzgResult<Void> markIsSoldOutProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSoldOutParam param) { public CzgResult<Void> markIsSoldOutProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSoldOutParam param) {
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId(0L);
@ -193,4 +209,4 @@ public class ProductController {
return CzgResult.success(); return CzgResult.success();
} }
} }

View File

@ -40,6 +40,16 @@ public class MyStpLogic {
return ADMIN_LOGIC; return ADMIN_LOGIC;
} }
/**
* 校验员工权限
* @param code 权限码
*/
public void checkStaffPermission(String code) {
if (this.isStaff()) {
StpKit.USER.checkPermission(code);
}
}
/** /**
* @param id 登录账号id * @param id 登录账号id
* @param shopId 店铺id * @param shopId 店铺id
@ -152,6 +162,10 @@ public class MyStpLogic {
*/ */
public boolean isStaff() { public boolean isStaff() {
StpLogic logic = getLogic(); StpLogic logic = getLogic();
Object loginIdDefaultNull = logic.getLoginIdDefaultNull();
if (loginIdDefaultNull == null) {
return false;
}
Object object = logic.getSession().get("loginType"); Object object = logic.getSession().get("loginType");
return object instanceof LoginType t && t.equals(LoginType.STAFF); return object instanceof LoginType t && t.equals(LoginType.STAFF);
} }