From 173147b9edaa446dba9928eef5a23622c90957c4 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Mon, 4 Nov 2024 16:55:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BA=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/good/CategoryController.java | 8 +++++--- .../controller/good/CouponController.java | 10 ++++++---- .../heritage/controller/good/GoodController.java | 12 +++++++----- .../controller/order/OrderController.java | 8 +++++--- .../heritage/controller/user/UserController.java | 16 +++++++++------- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/cultural/heritage/controller/good/CategoryController.java b/src/main/java/com/cultural/heritage/controller/good/CategoryController.java index 8a1b6e6..ce8a8d9 100644 --- a/src/main/java/com/cultural/heritage/controller/good/CategoryController.java +++ b/src/main/java/com/cultural/heritage/controller/good/CategoryController.java @@ -1,9 +1,11 @@ package com.cultural.heritage.controller.good; +import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.model.dto.CommonRequest; @@ -50,7 +52,7 @@ public class CategoryController { */ @PostMapping("/add") @Operation(summary = "Web端管理员添加商品类别", description = "参数:类别添加请求体,权限:管理员(admin, boss),方法名:addCategory") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse addCategory(@RequestBody CategoryAddRequest categoryAddRequest) { if (categoryAddRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -71,7 +73,7 @@ public class CategoryController { */ @PostMapping("/delete") @Operation(summary = "Web端管理员删除商品类别", description = "参数:类别删除请求体,权限:管理员(admin, boss),方法名:deleteCategory") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse deleteCategory(@RequestBody CommonRequest deleteCategoryRequest) { if (deleteCategoryRequest == null || deleteCategoryRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -91,7 +93,7 @@ public class CategoryController { */ @PostMapping("/update") @Operation(summary = "Web端管理员更新商品类别", description = "参数:类别更新请求体,权限:管理员(admin, boss),方法名:updateCategory") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse updateCategory(@RequestBody Category category) { if (category == null || category.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); diff --git a/src/main/java/com/cultural/heritage/controller/good/CouponController.java b/src/main/java/com/cultural/heritage/controller/good/CouponController.java index 90ce497..2d185da 100644 --- a/src/main/java/com/cultural/heritage/controller/good/CouponController.java +++ b/src/main/java/com/cultural/heritage/controller/good/CouponController.java @@ -2,9 +2,11 @@ package com.cultural.heritage.controller.good; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.model.dto.CommonRequest; @@ -61,7 +63,7 @@ public class CouponController { */ @PostMapping("/add") @Operation(summary = "Web端管理员添加优惠券", description = "参数:优惠券添加请求体,权限:管理员(admin, boss),方法名:addCoupon") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse addCoupon(@RequestBody CouponAddRequest couponAddRequest) { if (couponAddRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -82,7 +84,7 @@ public class CouponController { */ @PostMapping("/update") @Operation(summary = "Web端管理员更新优惠券", description = "参数:优惠券更新请求体,权限:管理员(admin, boss),方法名:updateCoupon") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse updateCoupon(@RequestBody CouponUpdateRequest couponUpdateRequest) { if (couponUpdateRequest == null || couponUpdateRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -103,7 +105,7 @@ public class CouponController { */ @PostMapping("/delete") @Operation(summary = "Web端管理员删除优惠券", description = "参数:优惠券删除请求体,权限:管理员(admin, boss),方法名:deleteCoupon") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse deleteCoupon(@RequestBody CommonRequest couponDeleteRequest) { if (couponDeleteRequest == null || couponDeleteRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -123,7 +125,7 @@ public class CouponController { */ @PostMapping("/list/page") @Operation(summary = "Web端管理员分页查询优惠券", description = "参数:优惠券查询请求体,权限:管理员(admin, boss),方法名:listCouponVOByPage") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse> listCouponVOByPage(@RequestBody CouponQueryRequest couponQueryRequest) { if (couponQueryRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); diff --git a/src/main/java/com/cultural/heritage/controller/good/GoodController.java b/src/main/java/com/cultural/heritage/controller/good/GoodController.java index fc3f228..54c91c7 100644 --- a/src/main/java/com/cultural/heritage/controller/good/GoodController.java +++ b/src/main/java/com/cultural/heritage/controller/good/GoodController.java @@ -3,9 +3,11 @@ package com.cultural.heritage.controller.good; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.model.dto.CommonDelBatchRequest; @@ -53,7 +55,7 @@ public class GoodController { */ @PostMapping("/add") @Operation(summary = "Web端管理员添加商品", description = "参数:商品添加请求体,权限:管理员(admin, boss),方法名:addGood") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse addGood(@RequestBody GoodAddRequest goodAddRequest) { if (goodAddRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -73,7 +75,7 @@ public class GoodController { */ @PostMapping("/delete") @Operation(summary = "Web端管理员删除商品", description = "参数:商品删除请求体,权限:管理员(admin, boss),方法名:deleteGood") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse deleteGood(@RequestBody CommonRequest deleteRequest) { if (deleteRequest == null || deleteRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -91,7 +93,7 @@ public class GoodController { */ @PostMapping("/update") @Operation(summary = "Web端管理员更新商品", description = "参数:商品更新请求体,权限:管理员(admin, boss),方法名:updateGoods") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse updateGoods(@RequestBody GoodUpdateRequest goodUpdateRequest) { if (goodUpdateRequest == null || goodUpdateRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -113,7 +115,7 @@ public class GoodController { */ @PostMapping("/list/page") @Operation(summary = "Web端管理员分页查询商品", description = "参数:商品查询请求体,权限:管理员(admin, boss),方法名:listGoodByPage") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse> listGoodByPage(@RequestBody GoodQueryRequest goodQueryRequest) { long current = goodQueryRequest.getCurrent(); long pageSize = goodQueryRequest.getPageSize(); @@ -132,7 +134,7 @@ public class GoodController { */ @PostMapping("/delBatch") @Operation(summary = "Web端管理员批量删除商品", description = "参数:商品批量删除请求体,权限:管理员(admin, boss),方法名:delBatchGoods") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse delBatchGoods(@RequestBody CommonDelBatchRequest commonDelBatchRequest) { List idList = commonDelBatchRequest.getIdList(); boolean result = goodService.removeBatchByIds(idList); diff --git a/src/main/java/com/cultural/heritage/controller/order/OrderController.java b/src/main/java/com/cultural/heritage/controller/order/OrderController.java index 0bb42a6..7b87e69 100644 --- a/src/main/java/com/cultural/heritage/controller/order/OrderController.java +++ b/src/main/java/com/cultural/heritage/controller/order/OrderController.java @@ -3,9 +3,11 @@ package com.cultural.heritage.controller.order; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.model.dto.CommonRequest; @@ -95,7 +97,7 @@ public class OrderController { */ @PostMapping("/list/page") @Operation(summary = "Web端管理员分页查询订单", description = "参数:订单查询请求体,权限:管理员(admin, boss),方法名:listOrder") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse> listOrder(@RequestBody OrderQueryRequest orderQueryRequest) { if (orderQueryRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -116,7 +118,7 @@ public class OrderController { */ @PostMapping("/list/item") @Operation(summary = "Web端管理员查询订单明细", description = "参数:订单编号请求体,权限:管理员(admin, boss),方法名:listOrderItem") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse> listOrderItem(@RequestBody CommonRequest orderIdRequest) { if (orderIdRequest == null || orderIdRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -138,7 +140,7 @@ public class OrderController { */ @PostMapping("/update") @Operation(summary = "Web端管理员更新订单状态", description = "参数:订单状态更新请求体,权限:管理员(admin, boss),方法名:updateOrderStatus") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse updateOrderStatus(@RequestBody OrderUpdateRequest orderUpdateRequest) { if (orderUpdateRequest == null || orderUpdateRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); diff --git a/src/main/java/com/cultural/heritage/controller/user/UserController.java b/src/main/java/com/cultural/heritage/controller/user/UserController.java index 8e20d23..a60a1e3 100644 --- a/src/main/java/com/cultural/heritage/controller/user/UserController.java +++ b/src/main/java/com/cultural/heritage/controller/user/UserController.java @@ -5,10 +5,12 @@ import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; import com.cultural.heritage.config.WxOpenConfig; +import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.model.dto.CommonRequest; @@ -155,7 +157,7 @@ public class UserController { */ @PostMapping("/add") @Operation(summary = "Web端管理员创建用户", description = "参数:用户添加请求体, 权限:管理员(admin, boss), 方法名:addUser") -// @AuthCheck(mustRole = UserConstant.BOSS_ROLE) + @AuthCheck(mustRole = UserConstant.BOSS_ROLE) public BaseResponse addUser(@RequestBody UserAddRequest userAddRequest) { if (userAddRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -179,7 +181,7 @@ public class UserController { */ @PostMapping("/delete") @Operation(summary = "Web端管理员删除用户", description = "参数:用户删除请求体, 权限:管理员(admin, boss), 方法名:deleteUser") -// @AuthCheck(mustRole = UserConstant.BOSS_ROLE) + @AuthCheck(mustRole = UserConstant.BOSS_ROLE) public BaseResponse deleteUser(@RequestBody CommonRequest deleteRequest) { if (deleteRequest == null || deleteRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -197,7 +199,7 @@ public class UserController { */ @PostMapping("/update") @Operation(summary = "Web端管理员更新用户", description = "参数:用户更新请求体, 权限:管理员(admin, boss), 方法名:updateUser") -// @AuthCheck(mustRole = UserConstant.BOSS_ROLE) + @AuthCheck(mustRole = UserConstant.BOSS_ROLE) public BaseResponse updateUser(@RequestBody UserUpdateRequest userUpdateRequest) { if (userUpdateRequest == null || userUpdateRequest.getId() <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -217,7 +219,7 @@ public class UserController { */ @GetMapping("/get") @Operation(summary = "Web端管理员根据id获取用户信息", description = "参数:用户id, 权限:管理员(admin, boss), 方法名:getUserById") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse getUserById(long id) { if (id <= 0) { throw new BusinessException(ErrorCode.PARAMS_ERROR); @@ -233,7 +235,7 @@ public class UserController { */ @GetMapping("/count") @Operation(summary = "Web端管理员获取用户数量", description = "参数:无, 权限:管理员(admin, boss), 方法名:getUserCount") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse getUserCount() { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("userRole", "user"); @@ -250,7 +252,7 @@ public class UserController { */ @PostMapping("/list/page") @Operation(summary = "Web端管理员分页获取用户信息", description = "参数:用户查询请求体, 权限:管理员(admin, boss), 方法名:listUserByPage") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse> listUserByPage(@RequestBody UserQueryRequest userQueryRequest) { long current = userQueryRequest.getCurrent(); long pageSize = userQueryRequest.getPageSize(); @@ -269,7 +271,7 @@ public class UserController { */ @PostMapping("/list/page/vo") @Operation(summary = "Web端管理员分页获取脱敏用户信息", description = "参数:用户查询请求体, 权限:管理员(admin, boss), 方法名:listUserVOByPage") -// @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse> listUserVOByPage(@RequestBody UserQueryRequest userQueryRequest) { if (userQueryRequest == null) { throw new BusinessException(ErrorCode.PARAMS_ERROR);