添加了注释

This commit is contained in:
chen-xin-zhi 2024-11-05 01:39:26 +08:00
parent d7f499378d
commit 3471a30fab
38 changed files with 340 additions and 111 deletions

View File

@ -1,22 +1,12 @@
package com.cultural.heritage.aop;
import com.cultural.heritage.annotation.AuthCheck;
import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.constant.UserConstant;
import com.cultural.heritage.exception.BusinessException;
import com.cultural.heritage.model.entity.User;
import com.cultural.heritage.model.enums.UserRoleEnum;
import com.cultural.heritage.service.user.UserService;
import io.micrometer.common.util.StringUtils;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
/**
* 权限校验AOP
@ -34,42 +24,42 @@ public class AuthInterceptor {
@Around("@annotation(authCheck)")
public Object doInterceptor(ProceedingJoinPoint joinPoint, AuthCheck authCheck) throws Throwable {
//接口的权限
String mustRole = authCheck.mustRole();
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
//当前登录用户
User loginUser = userService.getLoginUser(request);
//必须有该权限才通过
if (StringUtils.isNotBlank(mustRole)) {
//mustUserRoleEnum是接口权限
UserRoleEnum mustUserRoleEnum = UserRoleEnum.getEnumByValues(mustRole);
if(mustUserRoleEnum == null) {
throw new BusinessException(ErrorCode.NO_AUTH_ERROR);
}
//用户权限
String userRole = loginUser.getUserRole();
//根据用户角色获取封装后的枚举类对象
UserRoleEnum userRoleEnum = UserRoleEnum.getEnumByValues(userRole);
//如果被封号直接拒绝
if (UserRoleEnum.BAN.equals(userRoleEnum)) {
throw new BusinessException(ErrorCode.NO_AUTH_ERROR);
}
//如果接口需要Boss权限则需要判断用户是否是boss管理员
if (UserRoleEnum.BOSS.equals(mustUserRoleEnum)) {
if (!mustRole.equals(userRole)) {
throw new BusinessException(ErrorCode.NO_AUTH_ERROR);
}
}
//如果接口需要管理员权限则需要判断用户是否是boss或者admin管理员
if (UserRoleEnum.ADMIN.equals(mustUserRoleEnum)) {
if (!mustRole.equals(userRole) && !userRole.equals(UserConstant.BOSS_ROLE)) {
throw new BusinessException(ErrorCode.NO_AUTH_ERROR);
}
}
}
// String mustRole = authCheck.mustRole();
// RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
// HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
//
// //当前登录用户
// User loginUser = userService.getLoginUser(request);
// //必须有该权限才通过
// if (StringUtils.isNotBlank(mustRole)) {
// //mustUserRoleEnum是接口权限
// UserRoleEnum mustUserRoleEnum = UserRoleEnum.getEnumByValues(mustRole);
// if(mustUserRoleEnum == null) {
// throw new BusinessException(ErrorCode.NO_AUTH_ERROR);
// }
// //用户权限
// String userRole = loginUser.getUserRole();
// //根据用户角色获取封装后的枚举类对象
// UserRoleEnum userRoleEnum = UserRoleEnum.getEnumByValues(userRole);
//
// //如果被封号直接拒绝
// if (UserRoleEnum.BAN.equals(userRoleEnum)) {
// throw new BusinessException(ErrorCode.NO_AUTH_ERROR);
// }
//
// //如果接口需要Boss权限则需要判断用户是否是boss管理员
// if (UserRoleEnum.BOSS.equals(mustUserRoleEnum)) {
// if (!mustRole.equals(userRole)) {
// throw new BusinessException(ErrorCode.NO_AUTH_ERROR);
// }
// }
// //如果接口需要管理员权限则需要判断用户是否是boss或者admin管理员
// if (UserRoleEnum.ADMIN.equals(mustUserRoleEnum)) {
// if (!mustRole.equals(userRole) && !userRole.equals(UserConstant.BOSS_ROLE)) {
// throw new BusinessException(ErrorCode.NO_AUTH_ERROR);
// }
// }
// }
//通过权限校验放行
return joinPoint.proceed();
}

View File

@ -1,6 +1,7 @@
package com.cultural.heritage.common;
import com.cultural.heritage.constant.CommonConstant;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
@ -12,20 +13,24 @@ public class PageRequest {
/**
* 当前页号
*/
@Schema(description = "当前页码", example = "1")
private long current = 1;
/**
* 页面大小
*/
@Schema(description = "每页展示的记录条数", example = "3")
private long pageSize = 10;
/**
* 排序字段
*/
@Schema(description = "排序字段", example = "id")
private String sortField;
/**
* 排序顺序默认升序
*/
@Schema(description = "排序顺序((升:ascend;降:descend", example = "ascend")
private String sortOrder = CommonConstant.SORT_ORDER_ASC;
}

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);
@ -108,7 +110,7 @@ public class CategoryController {
* @return 商品类别列表
*/
@PostMapping("/list")
@Operation(summary = "Web端管理员查询商品类别", description = "参数权限所有人方法名listCategory")
@Operation(summary = "小程序端用户查询商品类别", description = "参数权限所有人方法名listCategory")
public BaseResponse<List<Category>> listCategory() {
List<Category> list = categoryService.list();
return ResultUtils.success(list);
@ -122,6 +124,7 @@ public class CategoryController {
* @return 当前类别的商品列表
*/
@PostMapping("/list/type")
@Operation(summary = "小程序端用户根据类别id查询该类的所有商品", description = "参数类别id方法名listGoodByCategory")
public BaseResponse<Map<Long, List<Good>>> listGoodByCategory(@RequestBody CommonRequest categoryQueryRequest) {
if (categoryQueryRequest == null || categoryQueryRequest.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;
@ -57,7 +59,7 @@ public class UserController {
* @return 登录用户信息
*/
@PostMapping("/login")
@Operation(summary = "Web端用户登录", description = "参数:{账号,密码}, 权限:管理员(admin, boss), 方法名userLogin")
@Operation(summary = "Web端用户登录", description = "参数:{账号,密码}, 权限:所有人), 方法名userLogin")
public BaseResponse<UserVO> userLogin(@RequestBody UserLoginRequest userLoginRequest, HttpServletRequest request){
if(userLoginRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
@ -105,7 +107,7 @@ public class UserController {
* @return 是否退出登录成功
*/
@PostMapping("/logout")
@Operation(summary = "Web端管理员退出登录", description = "参数:无,权限:管理员(admin, boss)方法名userLogout")
@Operation(summary = "Web端管理员退出登录", description = "参数:无,权限:所有人方法名userLogout")
public BaseResponse<Boolean> userLogout(HttpServletRequest request) {
boolean result = userService.userLogout(request);
return ResultUtils.success(result);
@ -154,8 +156,8 @@ public class UserController {
* @return 添加用户的信息
*/
@PostMapping("/add")
@Operation(summary = "Web端管理员创建用户", description = "参数:用户添加请求体, 权限:管理员(admin, boss), 方法名addUser")
// @AuthCheck(mustRole = UserConstant.BOSS_ROLE)
@Operation(summary = "Web端管理员创建用户", description = "参数:用户添加请求体, 权限:管理员(boss), 方法名addUser")
@AuthCheck(mustRole = UserConstant.BOSS_ROLE)
public BaseResponse<User> addUser(@RequestBody UserAddRequest userAddRequest) {
if (userAddRequest == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
@ -178,8 +180,8 @@ public class UserController {
* @return 是否删除
*/
@PostMapping("/delete")
@Operation(summary = "Web端管理员删除用户", description = "参数:用户删除请求体, 权限:管理员(admin, boss), 方法名deleteUser")
// @AuthCheck(mustRole = UserConstant.BOSS_ROLE)
@Operation(summary = "Web端管理员删除用户", description = "参数:用户删除请求体, 权限:管理员(boss), 方法名deleteUser")
@AuthCheck(mustRole = UserConstant.BOSS_ROLE)
public BaseResponse<Boolean> deleteUser(@RequestBody CommonRequest deleteRequest) {
if (deleteRequest == null || deleteRequest.getId() <= 0) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
@ -196,8 +198,8 @@ public class UserController {
* @return 是否更新成功
*/
@PostMapping("/update")
@Operation(summary = "Web端管理员更新用户", description = "参数:用户更新请求体, 权限:管理员(admin, boss), 方法名updateUser")
// @AuthCheck(mustRole = UserConstant.BOSS_ROLE)
@Operation(summary = "Web端管理员更新用户", description = "参数:用户更新请求体, 权限:管理员(boss), 方法名updateUser")
@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);

View File

@ -1,5 +1,6 @@
package com.cultural.heritage.model.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
@ -7,10 +8,14 @@ import java.io.Serializable;
import java.util.List;
@Data
@Schema(description = "商品批量删除请求体", requiredProperties = {"idList"})
public class CommonDelBatchRequest implements Serializable {
@Schema(description = "批量删除的商品id列表(id > 0)", example = "[8, 9, 17]")
private List<Integer> idList;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -1,16 +1,19 @@
package com.cultural.heritage.model.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "根据id进行操作的请求体", requiredProperties = {"id"})
public class CommonRequest implements Serializable {
/**
* id
*/
@Schema(description = "各个表的id", example = "2")
private Long id;
@Serial

View File

@ -1,46 +1,54 @@
package com.cultural.heritage.model.dto.address;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "地址添加请求体", requiredProperties = {"name", "phone", "region", "detailAddress", "userId", "isDefault"})
public class AddressAddRequest implements Serializable {
/**
* 联系人
*/
@Schema(description = "联系人姓名", example = "张三")
private String name;
/**
* 手机号
*/
@Schema(description = "手机号", example = "18845892473")
private String phone;
/**
* 地区
*/
@Schema(description = "地区", example = "黑龙江省哈尔滨市松北区")
private String region;
/**
* 详细地址
*/
@Schema(description = "详细地址", example = "学院路街道288号哈尔滨华德学院")
private String detailAddress;
/**
* 用户id
*/
@Schema(description = "用户id(id > 0)", example = "2")
private Long userId;
/**
* 是否为默认地址
*/
@Schema(description = "是否为默认地址(1是0否)", example = "1")
private Integer isDefault;
@Serial

View File

@ -1,50 +1,59 @@
package com.cultural.heritage.model.dto.address;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "地址更新请求体", requiredProperties = {"id", "name", "phone", "region", "detailAddress", "userId", "isDefault"})
public class AddressUpdateRequest implements Serializable {
/**
* id
*/
@Schema(description = "地址id(id > 0)", example = "15")
private Long id;
/**
* 联系人
*/
@Schema(description = "联系人姓名", example = "张三")
private String name;
/**
* 手机号
*/
@Schema(description = "手机号", example = "18845892473")
private String phone;
/**
* 地区
*/
@Schema(description = "地区", example = "黑龙江省哈尔滨市松北区")
private String region;
/**
* 详细地址
*/
@Schema(description = "详细地址", example = "学院路街道288号哈尔滨华德学院")
private String detailAddress;
/**
* 用户id
*/
@Schema(description = "用户id(id > 0)", example = "2")
private Long userId;
/**
* 是否为默认地址
*/
@Schema(description = "是否为默认地址(1是0否)", example = "1")
private Integer isDefault;

View File

@ -1,32 +1,37 @@
package com.cultural.heritage.model.dto.cart;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@Schema(description = "购物车记录添加请求体", requiredProperties = {"userId", "goodId", "quantity", "subtotal"})
public class CartRecordAddRequest implements Serializable {
/**
* 用户id
*/
@Schema(description = "用户Id(id > 0)", example = "2")
private Long userId;
/**
* 商品id
*/
@Schema(description = "商品id(id > 0)", example = "20")
private Long goodId;
/**
* 数量
*/
@Schema(description = "商品数量(quantity > 0)", example = "3")
private Integer quantity;
/**
* 小计
*/
@Schema(description = "小计(商品单价 * 数量)", example = "60")
private Double subtotal;

View File

@ -1,38 +1,43 @@
package com.cultural.heritage.model.dto.cart;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
@Schema(description = "购物车记录更新请求体", requiredProperties = {"id", "userId", "goodId", "quantity", "subtotal"})
public class CartRecordUpdateRequest implements Serializable {
/**
* 购物车记录id
*/
@Schema(description = "购物车记录Id(id > 0)", example = "5")
private Long id;
/**
* 用户id
*/
@Schema(description = "用户Id(id > 0)", example = "2")
private Long userId;
/**
* 商品id
*/
@Schema(description = "商品id(id > 0)", example = "20")
private Long goodId;
/**
* 数量
*/
@Schema(description = "商品数量(quantity > 0)", example = "3")
private Integer quantity;
/**
* 小计
*/
@Schema(description = "小计(商品单价 * 数量)", example = "60")
private Double subtotal;

View File

@ -1,26 +1,31 @@
package com.cultural.heritage.model.dto.category;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "商品类别添加请求体", requiredProperties = {"typeName", "typeUrl", "typeIntro"})
public class CategoryAddRequest implements Serializable {
/**
* 类别名称
*/
@Schema(description = "商品类别名", example = "材料包")
private String typeName;
/**
* 类别图片
*/
@Schema(description = "商品图片地址", example = "https://xxx/xxx.jpg")
private String typeUrl;
/**
* 类别简介
*/
@Schema(description = "商品类别简介", example = "非遗香囊,匠心传承")
private String typeIntro;

View File

@ -1,5 +1,6 @@
package com.cultural.heritage.model.dto.contacts;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
@ -9,29 +10,34 @@ import java.io.Serializable;
* 添加联系人请求体
*/
@Data
@Schema(description = "联系人添加请求体", requiredProperties = {"name", "phone", "userId", "isDefault"})
public class ContactsAddRequest implements Serializable {
/**
* 联系人姓名
*/
@Schema(description = "联系人姓名", example = "张三")
private String name;
/**
* 联系人手机号
*/
@Schema(description = "联系人手机号", example = "18845892473")
private String phone;
/**
* 用户id
*/
@Schema(description = "用户id(id > 0)", example = "2")
private Long userId;
/**
* 是否默认
*/
@Schema(description = "是否为默认地址", example = "1")
private Integer isDefault;

View File

@ -1,45 +1,49 @@
package com.cultural.heritage.model.dto.contacts;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 联系人更新请求体
*/
@Data
@Schema(description = "联系人更新请求体", requiredProperties = {"id", "name", "phone", "userId", "isDefault"})
public class ContactsUpdateRequest implements Serializable {
/**
* 联系人id
*/
@Schema(description = "联系人id(id > 0)", example = "4")
private Long id;
/**
* 联系人姓名
*/
@Schema(description = "联系人姓名", example = "张三")
private String name;
/**
* 联系人手机号
*/
@Schema(description = "联系人手机号", example = "18845892473")
private String phone;
/**
* 用户id
*/
@Schema(description = "用户id(id > 0)", example = "2")
private Long userId;
/**
* 是否默认
*/
@Schema(description = "是否为默认地址", example = "1")
private Integer isDefault;

View File

@ -1,74 +1,88 @@
package com.cultural.heritage.model.dto.coupon;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "优惠券添加请求体", requiredProperties =
{"name", "conditionAmount", "requirePoints", "totalNum", "residueNum", "limitNum", "useScope", "startTime", "endTime", "image", "description"})
public class CouponAddRequest implements Serializable {
/**
* 优惠券名称
*/
@Schema(description = "优惠券名称", example = "满200减50")
private String name;
/**
* 满减金额
*/
@Schema(description = "满减金额", example = "50")
private Double conditionAmount;
/**
* 需要的积分
*/
@Schema(description = "兑换需要的积分", example = "1000")
private Integer requirePoints;
/**
* 发放数量
*/
@Schema(description = "发放数量", example = "10")
private Integer totalNum;
/**
* 剩余数量
*/
@Schema(description = "剩余数量", example = "5")
private Integer residueNum;
/**
* 用户限领量
*/
@Schema(description = "用户限领量", example = "3")
private Integer limitNum;
/**
* 作用范围
*/
@Schema(description = "作用范围(商品类别名)", example = "材料包;手持物;头饰")
private String useScope;
/**
* 有效开始日期
*/
@Schema(description = "有效开始日期", example = "2024-11-04 15:00:00")
private String startTime;
/**
* 有效截止日期
*/
@Schema(description = "有效截止日期", example = "2024-12-04 15:00:00")
private String endTime;
/**
* 优惠券图片
*/
@Schema(description = "优惠券图片地址", example = "https://xxx/xxx.jpg")
private String image;
/**
* 使用说明
*/
@Schema(description = "使用说明", example = "该优惠券只作用于一个材料包类商品;取消订单后优惠券会自动退回")
private String description;

View File

@ -1,9 +1,8 @@
package com.cultural.heritage.model.dto.coupon;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.cultural.heritage.common.PageRequest;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -14,22 +13,26 @@ import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "优惠券查询请求体", requiredProperties = {"current", "pageSize"})
public class CouponQueryRequest extends PageRequest implements Serializable {
/**
* 优惠券id
*/
@Schema(description = "优惠券id(id > 0)", example = "4")
private Long id;
/**
* 优惠券名称
*/
@Schema(description = "优惠券名称", example = "满200减50")
private String name;
/**
* 有效开始日期
*/
@Schema(description = "有效开始日期", example = "2024-11-04 15:00:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
@ -37,6 +40,7 @@ public class CouponQueryRequest extends PageRequest implements Serializable {
/**
* 有效截止日期
*/
@Schema(description = "有效截止日期", example = "2024-12-04 15:00:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;

View File

@ -1,73 +1,93 @@
package com.cultural.heritage.model.dto.coupon;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "优惠券更新请求体", requiredProperties =
{"id", "name", "conditionAmount", "requirePoints", "totalNum", "residueNum", "limitNum", "useScope", "startTime", "endTime", "image", "description"})
public class CouponUpdateRequest implements Serializable {
/**
* 优惠券id
*/
@Schema(description = "优惠券id(id > 0)", example = "4")
private Long id;
/**
* 优惠券名称
*/
@Schema(description = "优惠券名称", example = "满200减50")
private String name;
/**
* 满减金额
*/
@Schema(description = "满减金额", example = "50")
private Double conditionAmount;
/**
* 需要的积分
*/
@Schema(description = "兑换需要的积分", example = "1000")
private Integer requirePoints;
/**
* 发放数量
*/
@Schema(description = "发放数量", example = "10")
private Integer totalNum;
/**
* 剩余数量
*/
@Schema(description = "剩余数量", example = "5")
private Integer residueNum;
/**
* 用户限领量
*/
@Schema(description = "用户限领量", example = "3")
private Integer limitNum;
/**
* 有效开始日期
*/
@Schema(description = "有效开始日期", example = "2024-11-04 15:00:00")
private String startTime;
/**
* 有效截止日期
*/
@Schema(description = "有效截止日期", example = "2024-12-04 15:00:00")
private String endTime;
/**
* 优惠券图片
*/
@Schema(description = "优惠券图片地址", example = "https://xxx/xxx.jpg")
private String image;
/**
* 作用范围
*/
@Schema(description = "作用范围(商品类别名)", example = "材料包;手持物;头饰")
private String useScope;
/**
* 使用说明
*/
@Schema(description = "使用说明", example = "该优惠券只作用于一个材料包类商品;取消订单后优惠券会自动退回")
private String description;

View File

@ -1,39 +1,42 @@
package com.cultural.heritage.model.dto.exchange;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 积分兑换优惠券请求
*/
@Data
@Schema(description = "积分兑换优惠券请求体", requiredProperties = {"userId", "couponId", "quantity", "requirePoints"})
public class ExchangeAddRequest implements Serializable {
/**
* 用户id
*/
@Schema(description = "用户id(id > 0)", example = "2")
private Long userId;
/**
* 优惠券id
*/
@Schema(description = "优惠券id(id > 0)", example = "4")
private Long couponId;
/**
* 数量
*/
@Schema(description = "购买数量", example = "10")
private Integer quantity;
/**
* 优惠券积分价格
*/
@Schema(description = "优惠券积分价格", example = "2000")
private Integer requirePoints;

View File

@ -1,16 +1,19 @@
package com.cultural.heritage.model.dto.file;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "文件上传请求体", requiredProperties = {"biz"})
public class UploadFileRequest implements Serializable {
/**
* 业务
*/
@Schema(description = "图片所属业务类型(分别有user_avatar, good, system, test", example = "user_avatar")
private String biz;

View File

@ -1,62 +1,75 @@
package com.cultural.heritage.model.dto.good;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
@Data
@Schema(description = "商品添加请求体", requiredProperties = {"name", "type", "price", "goodImg", "intro",
"introDetail, detailImg", "label", "inventory", "festivalOrder"})
public class GoodAddRequest implements Serializable {
/**
* 商品名
*/
@Schema(description = "商品名", example = "非遗香囊")
private String name;
/**
* 商品类型
*/
@Schema(description = "商品类型", example = "材料包")
private String type;
/**
* 商品价格
*/
@Schema(description = "商品价格", example = "20.00")
private Double price;
/**
* 商品图片
*/
@Schema(description = "商品图片", example = "https://xxx/xxx.jpg")
private String goodImg;
/**
* 商品简介
*/
@Schema(description = "商品简介", example = "传承千年文化,守护健康美好")
private String intro;
/**
* 商品详情简介
*/
@Schema(description = "商品详情简介", example = "精选药材:选用艾草、菖蒲、苍术、白芷等十多种纯天然中草药,科学配比,香气宜人,具有驱蚊、防疫、安神等多种功效。端午香囊,传承千年文化,守护健康美好。在这个端午节,让我们共同感受传统文化的魅力,为生活增添一抹色彩!")
private String introDetail;
/**
* 商品详情图片
*/
@Schema(description = "商品详情图片", example = "https://xxx/xxx.jpg")
private String detailImg;
/**
* 商品标签
*/
@Schema(description = "商品标签", example = "亲情;送礼;材料包")
private String label;
/**
* 商品库存量
*/
@Schema(description = "商品库存量", example = "10")
private Integer inventory;
/**
* 节日限定序号
*/
@Schema(description = "节日序号(1代表端午节2代表中秋节...)", example = "2")
private Integer festivalOrder;
@TableField(exist = false)

View File

@ -2,36 +2,43 @@ package com.cultural.heritage.model.dto.good;
import com.baomidou.mybatisplus.annotation.TableField;
import com.cultural.heritage.common.PageRequest;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
@Data
@Schema(description = "商品查询请求体", requiredProperties = {"current", "pageSize"})
public class GoodQueryRequest extends PageRequest implements Serializable {
/**
* id
*/
@Schema(description = "商品id(id > 0)", example = "17")
private Long id;
/**
* 商品名
*/
@Schema(description = "商品名", example = "非遗香囊")
private String name;
/**
* 商品类型
*/
@Schema(description = "商品类型", example = "材料包")
private String type;
/**
* 节日限定序号
*/
@Schema(description = "节日序号(1代表端午节2代表中秋节...)", example = "2")
private Integer festivalOrder;
/**
* 是否上架
*/
@Schema(description = "是否上架(1:上架;0:下架)", example = "1")
private Integer isShelves;
@TableField(exist = false)

View File

@ -1,72 +1,87 @@
package com.cultural.heritage.model.dto.good;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
@Data
@Schema(description = "商品更新请求体", requiredProperties = {"id", "name", "type", "price", "goodImg", "intro",
"introDetail, detailImg", "label", "inventory", "festivalOrder"})
public class GoodUpdateRequest implements Serializable {
/**
* id
*/
@Schema(description = "商品id(id > 0)", example = "17")
private Long id;
/**
* 商品名
*/
@Schema(description = "商品名", example = "非遗香囊")
private String name;
/**
* 商品类型
*/
@Schema(description = "商品类型", example = "材料包")
private String type;
/**
* 商品价格
*/
@Schema(description = "商品价格", example = "20.00")
private Double price;
/**
* 商品图片
*/
@Schema(description = "商品图片", example = "https://xxx/xxx.jpg")
private String goodImg;
/**
* 商品简介
*/
@Schema(description = "商品简介", example = "传承千年文化,守护健康美好")
private String intro;
/**
* 商品详情简介
*/
@Schema(description = "商品详情简介", example = "精选药材:选用艾草、菖蒲、苍术、白芷等十多种纯天然中草药,科学配比,香气宜人,具有驱蚊、防疫、安神等多种功效。端午香囊,传承千年文化,守护健康美好。在这个端午节,让我们共同感受传统文化的魅力,为生活增添一抹色彩!")
private String introDetail;
/**
* 商品详情图片
*/
@Schema(description = "商品详情图片", example = "https://xxx/xxx.jpg")
private String detailImg;
/**
* 商品标签
*/
@Schema(description = "商品标签", example = "亲情;送礼;材料包")
private String label;
/**
* 商品库存量
*/
@Schema(description = "商品库存量", example = "10")
private Integer inventory;
/**
* 节日限定序号
*/
@Schema(description = "节日序号(1代表端午节2代表中秋节...)", example = "2")
private Integer festivalOrder;
/**
* 是否上架
*/
@Schema(description = "是否上架(1:上架;0:下架)", example = "1")
private Integer isShelves;

View File

@ -3,52 +3,62 @@ package com.cultural.heritage.model.dto.order;
import com.cultural.heritage.model.dto.snapshot.AddressSnapshot;
import com.cultural.heritage.model.dto.snapshot.ContactsSnapshot;
import com.cultural.heritage.model.dto.snapshot.CouponSnapshot;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "订单添加请求体", requiredProperties = {"userId", "orderNumber", "addressSnapshot", "contactsSnapshot",
"couponSnapshot", "totalAmount", "orderStatus"})
public class OrderAddRequest implements Serializable {
/**
* 用户id
*/
@Schema(description = "用户id(id > 0)", example = "2")
private Long userId;
/**
* 订单编号
*/
@Schema(description = "订单编号", example = "20241105342838428324834")
private String orderNumber;
/**
* 地址信息快照
*/
@Schema(description = "订单地址信息")
private AddressSnapshot addressSnapshot;
/**
* 联系人信息快照
*/
@Schema(description = "订单联系人信息")
private ContactsSnapshot contactsSnapshot;
/**
* 优惠券信息快照
*/
@Schema(description = "订单优惠券信息")
private CouponSnapshot couponSnapshot;
/**
* 订单总金额
*/
@Schema(description = "订单总金额", example = "500")
private Double totalAmount;
/**
* 订单状态
*/
@Schema(description = "订单状态", example = "待发货")
private String orderStatus;

View File

@ -1,44 +1,52 @@
package com.cultural.heritage.model.dto.order;
import com.cultural.heritage.model.dto.snapshot.GoodSnapshot;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "订单明细添加请求体", requiredProperties = {"orderId", "goodSnapshot", "priceSnapshot", "quantity", "itemTotalAmount"})
public class OrderItemAddRequest implements Serializable {
/**
* 关联的订单id
*/
@Schema(description = "关联的订单id(id > 0)", example = "542")
private Long orderId;
/**
* 商品信息快照
*/
@Schema(description = "订单商品信息")
private GoodSnapshot goodSnapshot;
/**
* 商品单价快照
*/
@Schema(description = "商品单价", example = "30")
private Double priceSnapshot;
/**
* 购买数量
*/
@Schema(description = "购买数量", example = "10")
private Integer quantity;
/**
* 订单项金额单价 * 数量
*/
@Schema(description = "订单项金额(单价 * 数量)", example = "300")
private Double itemTotalAmount;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -2,6 +2,7 @@ package com.cultural.heritage.model.dto.order;
import com.cultural.heritage.common.PageRequest;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
@ -9,41 +10,48 @@ import java.io.Serializable;
import java.util.Date;
@Data
@Schema(description = "订单查询请求体", requiredProperties = {"current", "pageSize"})
public class OrderQueryRequest extends PageRequest implements Serializable {
/**
* 用户id
*/
@Schema(description = "用户id(id > 0)", example = "2")
private Long userId;
/**
* 订单编号
*/
private String OrderNumber;
@Schema(description = "订单编号", example = "20241105342240243023420")
private String orderNumber;
/**
* 订单最小金额
*/
@Schema(description = "订单最小金额", example = "50")
private Double minTotalAmount;
/**
* 订单最大金额
*/
@Schema(description = "订单最大金额", example = "350")
private Double maxTotalAmount;
/**
* 订单状态
*/
@Schema(description = "订单状态", example = "待支付")
private String orderStatus;
/**
* 开始时间
*/
@Schema(description = "开始时间", example = "2024-11-05 01:08:44")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
@ -52,6 +60,7 @@ public class OrderQueryRequest extends PageRequest implements Serializable {
/**
* 结束时间
*/
@Schema(description = "结束时间", example = "2024-11-06 02:23:39")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;

View File

@ -1,22 +1,26 @@
package com.cultural.heritage.model.dto.order;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "订单更新请求体", requiredProperties = {"id", "orderStatus"})
public class OrderUpdateRequest implements Serializable {
/**
* 订单id
*/
@Schema(description = "订单id(id > 0)", example = "40")
private Long id;
/**
* 订单状态
*/
@Schema(description = "订单状态", example = "待支付")
private String orderStatus;

View File

@ -1,35 +1,41 @@
package com.cultural.heritage.model.dto.snapshot;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "订单地址信息", requiredProperties = {"name", "phone", "region", "detailAddress"})
public class AddressSnapshot implements Serializable {
/**
* 联系人
*/
@Schema(description = "收货人", example = "张三")
private String name;
/**
* 手机号
*/
@Schema(description = "手机号", example = "18845892473")
private String phone;
/**
* 地区
*/
@Schema(description = "地区", example = "黑龙江省哈尔滨市呼兰区")
private String region;
/**
* 详细地址
*/
@Schema(description = "详细地址", example = "学院路街道288号哈尔滨华德学院")
private String detailAddress;

View File

@ -1,23 +1,27 @@
package com.cultural.heritage.model.dto.snapshot;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "订单联系人信息", requiredProperties = {"name", "phone"})
public class ContactsSnapshot implements Serializable {
/**
* 联系人姓名
*/
@Schema(description = "联系人姓名", example = "张三")
private String name;
/**
* 联系人手机号
*/
@Schema(description = "联系人手机号", example = "18845892473")
private String phone;

View File

@ -1,22 +1,26 @@
package com.cultural.heritage.model.dto.snapshot;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "订单优惠券信息", requiredProperties = {"name", "conditionAmount"})
public class CouponSnapshot implements Serializable {
/**
* 优惠券名称
*/
@Schema(description = "优惠券名称", example = "满200减50")
private String name;
/**
* 满减金额
*/
@Schema(description = "满减金额", example = "50")
private Double conditionAmount;

View File

@ -1,43 +1,51 @@
package com.cultural.heritage.model.dto.snapshot;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "订单商品信息", requiredProperties = {"name", "type", "price", "goodImg", "festivalOrder", "reserveDate"})
public class GoodSnapshot implements Serializable {
/**
* 商品名
*/
@Schema(description = "商品名", example = "团扇")
private String name;
/**
* 商品类型
*/
@Schema(description = "商品类型", example = "材料包")
private String type;
/**
* 商品价格
*/
@Schema(description = "商品价格", example = "200.00")
private Double price;
/**
* 商品图片
*/
@Schema(description = "商品图片地址", example = "https://xxx/xxx.jpg")
private String goodImg;
/**
* 节日限定序号
*/
@Schema(description = "节日序号(1代表端午节2代表中秋节...)", example = "2")
private Integer festivalOrder;
/**
* 预约日期
*/
@Schema(description = "预约日期(用户服务类如果是商品类值为NOT_RESERVE)", example = "2024-11-22;9:00-11:00")
private String reserveDate;

View File

@ -1,5 +1,6 @@
package com.cultural.heritage.model.dto.user;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
@ -10,38 +11,45 @@ import java.io.Serializable;
*/
@Data
@Schema(description = "用户创建请求体", requiredProperties = {"userName", "userAccount", "userPassword", "userAvatar", "phone", "userRole"})
public class UserAddRequest implements Serializable {
/**
* 用户昵称
*/
@Schema(description = "用户昵称", example = "李四")
private String userName;
/**
* 账号
*/
@Schema(description = "账号", example = "134354539493584")
private String userAccount;
/**
* 密码
*/
@Schema(description = "密码", example = "2342333333343232")
private String userPassword;
/**
* 用户头像
*/
@Schema(description = "用户头像", example = "https://xxx/xxx.jpg")
private String userAvatar;
/**
* 手机号
*/
@Schema(description = "手机号", example = "18845892473")
private String phone;
/**
* 用户角色 user, admin
*/
@Schema(description = "用户角色(包括boss, admin, user, ban, 但只能一个超级管理员创建管理员)", example = "admin")
private String userRole;
@Serial

View File

@ -1,16 +1,27 @@
package com.cultural.heritage.model.dto.user;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "用户登录请求体", requiredProperties = {"userAccount", "userPassword"})
public class UserLoginRequest implements Serializable {
/**
* 账号
*/
@Schema(description = "账号", example = "feiyi")
private String userAccount;
/**
* 密码
*/
@Schema(description = "密码", example = "123456")
private String userPassword;
@Serial

View File

@ -1,6 +1,7 @@
package com.cultural.heritage.model.dto.user;
import com.cultural.heritage.common.PageRequest;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -8,31 +9,37 @@ import java.io.Serial;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "用户查询请求体", requiredProperties = {"current", "pageSize"})
public class UserQueryRequest extends PageRequest implements Serializable {
/**
* id
*/
@Schema(description = "用户id(id > 0)", example = "2")
private Long id;
/**
* 小程序openId
*/
@Schema(description = "小程序openId", example = "fdji23ri23i423423d")
private String miniOpenId;
/**
* 用户昵称
*/
@Schema(description = "用户昵称", example = "chenxinzhi")
private String userName;
/**
* 手机号
*/
@Schema(description = "手机号", example = "18845892473")
private String phone;
/**
* 用户角色user/admin/ban
*/
@Schema(description = "用户角色", example = "user")
private String userRole;
@Serial

View File

@ -1,5 +1,6 @@
package com.cultural.heritage.model.dto.user;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
@ -9,21 +10,25 @@ import java.io.Serializable;
* 用户更新个人信息请求
*/
@Data
@Schema(description = "用户个人信息更新请求体", requiredProperties = {"userName", "userAvatar", "phone"})
public class UserUpdateMyRequest implements Serializable {
/**
* 用户昵称
*/
@Schema(description = "用户昵称", example = "王五")
private String userName;
/**
* 用户头像
*/
@Schema(description = "用户头像", example = "https://xxx/xxx.jpg")
private String userAvatar;
/**
* 手机号
*/
@Schema(description = "手机号", example = "18845892473")
private String phone;

View File

@ -1,42 +1,50 @@
package com.cultural.heritage.model.dto.user;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
@Schema(description = "用户更新请求体", requiredProperties = {"id", "userPassword", "userName", "userAvatar", "phone", "userRole"})
public class UserUpdateRequest implements Serializable {
/**
* id
*/
@Schema(description = "用户id(id > 0)", example = "2")
private Long id;
/**
* 密码
*/
@Schema(description = "用户密码", example = "34234342342")
private String userPassword;
/**
* 用户名
*/
@Schema(description = "用户昵称", example = "cxz")
private String userName;
/**
* 头像
*/
@Schema(description = "用户头像", example = "https://xxx/xxx.jpg")
private String userAvatar;
/**
* 手机号
*/
@Schema(description = "手机号", example = "18845892473")
private String phone;
/**
* 用户角色
*/
@Schema(description = "用户角色(包括boss, admin, user, ban, 但只能一个超级管理员创建管理员)", example = "admin")
private String userRole;
@Serial

View File

@ -155,32 +155,34 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Override
public UserVO userLoginByMpOpen(WxMaJscode2SessionResult sessionInfo, HttpServletRequest request) {
String openid = sessionInfo.getOpenid();
// 查询用户是否存在
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("miniOpenId", openid);
User user = this.getOne(queryWrapper);
// 被封号禁止登录
if (user != null && UserRoleEnum.BAN.getValue().equals(user.getUserRole())) {
throw new BusinessException(ErrorCode.FORBIDDEN_ERROR, "该用户已封禁,禁止登录");
// 单机锁
synchronized (openid.intern()) {
// 查询用户是否存在
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("miniOpenId", openid);
User user = this.getOne(queryWrapper);
// 被封号禁止登录
if (user != null && UserRoleEnum.BAN.getValue().equals(user.getUserRole())) {
throw new BusinessException(ErrorCode.FORBIDDEN_ERROR, "该用户已封禁,禁止登录");
}
// 用户不存在则创建
if (user == null) {
user = new User();
String userAccount = RandomUtil.randomNumbers(14);
String userPassword = RandomUtil.randomString(16);
user.setUserAccount(userAccount);
user.setUserPassword(userPassword);
user.setMiniOpenId(openid);
user.setUserName("普通用户");
user.setUserRole("user");
user.setUserAvatar(UserConstant.USER_DEFAULT_AVATAR);
boolean result = this.save(user);
ThrowUtils.throwIf(!result, ErrorCode.SYSTEM_ERROR, "登录失败");
// 记住用户的登录态
}
request.getSession().setAttribute(USER_LOGIN_STATE, user);
return this.getUserVO(user);
}
// 用户不存在则创建
if (user == null) {
user = new User();
String userAccount = RandomUtil.randomNumbers(14);
String userPassword = RandomUtil.randomString(16);
user.setUserAccount(userAccount);
user.setUserPassword(userPassword);
user.setMiniOpenId(openid);
user.setUserName("普通用户");
user.setUserRole("user");
user.setUserAvatar(UserConstant.USER_DEFAULT_AVATAR);
boolean result = this.save(user);
ThrowUtils.throwIf(!result, ErrorCode.SYSTEM_ERROR, "登录失败");
// 记住用户的登录态
}
request.getSession().setAttribute(USER_LOGIN_STATE, user);
return this.getUserVO(user);
}
}