完善了用户登录

This commit is contained in:
chen-xin-zhi 2024-11-04 16:55:22 +08:00
parent e0a4ea8db4
commit 173147b9ed
5 changed files with 32 additions and 22 deletions

View File

@ -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<Boolean> 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<Boolean> 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<Boolean> updateCategory(@RequestBody Category category) {
if (category == null || category.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);

View File

@ -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<Boolean> 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<Boolean> 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<Boolean> 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<Page<Coupon>> listCouponVOByPage(@RequestBody CouponQueryRequest couponQueryRequest) {
if (couponQueryRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);

View File

@ -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<Boolean> 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<Boolean> 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<Boolean> 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<Page<Good>> 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<Boolean> delBatchGoods(@RequestBody CommonDelBatchRequest commonDelBatchRequest) {
List<Integer> idList = commonDelBatchRequest.getIdList();
boolean result = goodService.removeBatchByIds(idList);

View File

@ -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<Page<Order>> 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<List<OrderItem>> 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<Boolean> updateOrderStatus(@RequestBody OrderUpdateRequest orderUpdateRequest) {
if (orderUpdateRequest == null || orderUpdateRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);

View File

@ -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<User> 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<Boolean> 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<Boolean> 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<User> 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<Long> getUserCount() {
QueryWrapper<User> 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<Page<User>> 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<Page<UserVO>> listUserVOByPage(@RequestBody UserQueryRequest userQueryRequest) {
if (userQueryRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);