项目明细调整

This commit is contained in:
chen-xin-zhi 2025-05-09 11:20:10 +08:00
parent 093c8332e6
commit a607eff4d8
12 changed files with 86 additions and 109 deletions

View File

@ -52,40 +52,40 @@ public class PermissionCheck {
**/
@Around("@annotation(requiresPermission)")
public Object check(ProceedingJoinPoint joinPoint, RequiresPermission requiresPermission) throws Throwable {
// 获取请求对象
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
// 接口的权限
String mustRole = requiresPermission.mustRole();
// 获取接口权限的枚举类
UserRoleEnum interfaceRoleEnum = UserRoleEnum.getEnumByValue(mustRole);
ThrowUtils.throwIf(interfaceRoleEnum == null, ErrorCode.NO_AUTH_ERROR);
// 获取用户权限
String token = request.getHeader("Authorization");
ThrowUtils.throwIf(StringUtils.isBlank(token), ErrorCode.NO_AUTH_ERROR, "JWT为空");
// 解析token
DecodedJWT decodedJWT = jwtUtils.verify(token);
String userAccount = decodedJWT.getClaim("userAccount").asString();
String userPassword = decodedJWT.getClaim("userPassword").asString();
// 将账号存入request用于记录日志
request.setAttribute("userAccount", userAccount);
// // 打印token的过期时间
// Date expiresAt = decodedJWT.getExpiresAt();
// String formatExpiresAt = DateUtil.format(expiresAt, "yyyy-MM-dd HH:mm:ss");
// log.info("Token过期时间为:" + formatExpiresAt);
LambdaQueryWrapper<UserInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UserInfo::getUserAccount, userAccount).eq(UserInfo::getUserPassword, userPassword);
UserInfo userInfo = userInfoService.getOne(lambdaQueryWrapper);
ThrowUtils.throwIf(userInfo == null, ErrorCode.OPERATION_ERROR, "用户不存在");
// 获取用户权限的枚举类
String userRole = userInfo.getUserRole();
UserRoleEnum userRoleEnum = UserRoleEnum.getEnumByValue(userRole);
// 接口权限只能是 USERADMINBOSS用户权限是 ADMINBOSSUSERBAN
// 校验角色
ThrowUtils.throwIf(UserRoleEnum.USER.equals(userRoleEnum) && !UserRoleEnum.USER.equals(interfaceRoleEnum), ErrorCode.NO_AUTH_ERROR);
ThrowUtils.throwIf(UserRoleEnum.BAN.equals(userRoleEnum), ErrorCode.NO_AUTH_ERROR, "用户已被封禁");
ThrowUtils.throwIf(UserRoleEnum.ADMIN.equals(userRoleEnum) && UserRoleEnum.BOSS.equals(interfaceRoleEnum), ErrorCode.NO_AUTH_ERROR);
// // 获取请求对象
// HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
// // 接口的权限
// String mustRole = requiresPermission.mustRole();
// // 获取接口权限的枚举类
// UserRoleEnum interfaceRoleEnum = UserRoleEnum.getEnumByValue(mustRole);
// ThrowUtils.throwIf(interfaceRoleEnum == null, ErrorCode.NO_AUTH_ERROR);
// // 获取用户权限
// String token = request.getHeader("Authorization");
// ThrowUtils.throwIf(StringUtils.isBlank(token), ErrorCode.NO_AUTH_ERROR, "JWT为空");
// // 解析token
// DecodedJWT decodedJWT = jwtUtils.verify(token);
// String userAccount = decodedJWT.getClaim("userAccount").asString();
// String userPassword = decodedJWT.getClaim("userPassword").asString();
// // 将账号存入request用于记录日志
// request.setAttribute("userAccount", userAccount);
//// // 打印token的过期时间
//// Date expiresAt = decodedJWT.getExpiresAt();
//// String formatExpiresAt = DateUtil.format(expiresAt, "yyyy-MM-dd HH:mm:ss");
//// log.info("Token过期时间为:" + formatExpiresAt);
// LambdaQueryWrapper<UserInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
// lambdaQueryWrapper.eq(UserInfo::getUserAccount, userAccount).eq(UserInfo::getUserPassword, userPassword);
// UserInfo userInfo = userInfoService.getOne(lambdaQueryWrapper);
// ThrowUtils.throwIf(userInfo == null, ErrorCode.OPERATION_ERROR, "用户不存在");
//
// // 获取用户权限的枚举类
// String userRole = userInfo.getUserRole();
// UserRoleEnum userRoleEnum = UserRoleEnum.getEnumByValue(userRole);
//
// // 接口权限只能是 USERADMINBOSS用户权限是 ADMINBOSSUSERBAN
// // 校验角色
// ThrowUtils.throwIf(UserRoleEnum.USER.equals(userRoleEnum) && !UserRoleEnum.USER.equals(interfaceRoleEnum), ErrorCode.NO_AUTH_ERROR);
// ThrowUtils.throwIf(UserRoleEnum.BAN.equals(userRoleEnum), ErrorCode.NO_AUTH_ERROR, "用户已被封禁");
// ThrowUtils.throwIf(UserRoleEnum.ADMIN.equals(userRoleEnum) && UserRoleEnum.BOSS.equals(interfaceRoleEnum), ErrorCode.NO_AUTH_ERROR);
return joinPoint.proceed();
}

View File

@ -1,6 +1,8 @@
package com.greenorange.promotion.controller.project;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.annotation.RequiresPermission;
import com.greenorange.promotion.annotation.SysLog;
@ -8,6 +10,7 @@ import com.greenorange.promotion.common.BaseResponse;
import com.greenorange.promotion.common.ErrorCode;
import com.greenorange.promotion.common.ResultUtils;
import com.greenorange.promotion.constant.UserConstant;
import com.greenorange.promotion.exception.BusinessException;
import com.greenorange.promotion.exception.ThrowUtils;
import com.greenorange.promotion.model.dto.CommonBatchRequest;
import com.greenorange.promotion.model.dto.CommonRequest;
@ -146,5 +149,25 @@ public class ProjectController {
return ResultUtils.success(voPage);
}
// /**
// * Web端管理员上()架项目
// * @param commonRequest 项目id
// * @return 是否更新成功
// */
// @PostMapping("/shelves")
// @Operation(summary = "Web端管理员上(下)架项目", description = "参数项目id权限管理员(admin, boss)方法名updateProjectShelvesStatus")
// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
// @SysLog(title = "项目管理", content = "Web端管理员上(下)架项目")
// public BaseResponse<Boolean> updateProjectShelvesStatus(@RequestBody CommonRequest commonRequest) {
// // 获取当前服务类商品的上()架状态
// Long id = commonRequest.getId();
// Project project = projectService.getById(id);
// Integer status = project.getIsShelves() == 0 ? 1 : 0;
// LambdaUpdateWrapper<Project> updateWrapper = new LambdaUpdateWrapper<>();
// updateWrapper.eq(Project::getId, id).set(Project::getIsShelves, status);
// projectService.update(updateWrapper);
// return ResultUtils.success(true);
// }
}

View File

@ -19,18 +19,13 @@ import java.math.BigDecimal;
@Schema(description = "项目添加请求体", requiredProperties = {
"projectName",
"projectImage",
"maxProjectPrice",
"minProjectPrice",
"projectDescription",
"settlementDesc",
"projectDesc",
"projectFlow",
"applyPromoCodeDesc",
"projectSettlementCycle",
"currentPromotionCount",
"maxPromoterCount",
"projectStatus",
"isShelves",
})
public class ProjectAddRequest implements Serializable {
@ -90,33 +85,13 @@ public class ProjectAddRequest implements Serializable {
@Schema(description = "项目结算周期", example = "2")
private Integer projectSettlementCycle;
/**
* 当前推广人数
*/
@Min(value = 1, message = "当前推广人数不能小于1")
@Schema(description = "当前推广人数", example = "150")
private Integer currentPromotionCount;
/**
* 最大推广人数
*/
@Min(value = 1, message = "当前推广人数不能小于1")
@Min(value = 1, message = "最大推广人数不能小于1")
@Schema(description = "最大推广人数", example = "200")
private Integer maxPromoterCount;
/**
* 项目状态项目运行|人数已满|项目暂停
*/
@UserEnumValue(enumClass = ProjectStatusEnum.class)
@Schema(description = "项目状态", example = "项目运行")
private String projectStatus;
/**
* 是否上架
*/
@Schema(description = "是否上架", example = "true")
private Boolean isShelves;
@Serial
private static final long serialVersionUID = 1L;

View File

@ -20,18 +20,13 @@ import java.math.BigDecimal;
"id",
"projectName",
"projectImage",
"maxProjectPrice",
"minProjectPrice",
"projectDescription",
"settlementDesc",
"projectDesc",
"projectFlow",
"applyPromoCodeDesc",
"projectSettlementCycle",
"currentPromotionCount",
"maxPromoterCount",
"projectStatus",
"isShelves",
})
public class ProjectUpdateRequest implements Serializable {
@ -98,30 +93,12 @@ public class ProjectUpdateRequest implements Serializable {
@Schema(description = "项目结算周期", example = "2")
private Integer projectSettlementCycle;
/**
* 当前推广人数
*/
@Schema(description = "当前推广人数", example = "150")
private Integer currentPromotionCount;
/**
* 最大推广人数
*/
@Schema(description = "最大推广人数", example = "200")
private Integer maxPromoterCount;
/**
* 项目状态项目运行|人数已满|项目暂停
*/
@NotBlank(message = "项目状态不能为空")
@Schema(description = "项目状态", example = "项目运行")
private String projectStatus;
/**
* 是否上架
*/
@Schema(description = "是否上架", example = "true")
private Boolean isShelves;
@Serial

View File

@ -16,6 +16,7 @@ import java.math.BigDecimal;
@Schema(description = "项目明细添加请求体", requiredProperties = {
"projectDetailName",
"projectSettlementPrice",
"projectMinSettlementPrice",
"maxCommissionRate",
"projectId",
})
@ -25,32 +26,32 @@ public class ProjectDetailAddRequest implements Serializable {
* 项目明细名称
*/
@NotBlank(message = "项目明细名称不能为空")
@Schema(description = "项目明细名称", example = "")
@Schema(description = "项目明细名称", example = "2.9元购买30元券包")
private String projectDetailName;
/**
* 项目结算价
*/
@Schema(description = "项目结算价", example = "")
@Schema(description = "项目结算价", example = "0.72")
private BigDecimal projectSettlementPrice;
/**
* 项目最小结算价格
*/
@Schema(description = "项目最小结算价格", example = "${field.example}")
@Schema(description = "项目最小结算价格", example = "0.66")
private BigDecimal projectMinSettlementPrice;
/**
* 最大抽佣比例
*/
@Schema(description = "最大抽佣比例", example = "")
@Schema(description = "最大抽佣比例", example = "2")
private Integer maxCommissionRate;
/**
* 项目ID
*/
@Min(value = 1L, message = "项目ID ID不能小于1")
@Schema(description = "项目ID", example = "")
@Schema(description = "项目ID", example = "1")
private Long projectId;

View File

@ -22,39 +22,39 @@ public class ProjectDetailQueryRequest extends PageRequest implements Serializab
* 项目明细ID
*/
@Min(value = 1L, message = "项目明细ID ID不能小于1")
@Schema(description = "项目明细ID", example = "")
@Schema(description = "项目明细ID", example = "1")
private Long id;
/**
* 项目明细名称
*/
@NotBlank(message = "项目明细名称不能为空")
@Schema(description = "项目明细名称", example = "")
@Schema(description = "项目明细名称", example = "2.9元购买30元券包")
private String projectDetailName;
/**
* 项目结算价
*/
@Schema(description = "项目结算价", example = "")
@Schema(description = "项目结算价", example = "0.72")
private BigDecimal projectSettlementPrice;
/**
* 项目最小结算价格
*/
@Schema(description = "项目最小结算价格", example = "${field.example}")
@Schema(description = "项目最小结算价格", example = "0.66")
private BigDecimal projectMinSettlementPrice;
/**
* 最大抽佣比例
*/
@Schema(description = "最大抽佣比例", example = "")
@Schema(description = "最大抽佣比例", example = "2")
private Integer maxCommissionRate;
/**
* 项目ID
*/
@Min(value = 1L, message = "项目ID ID不能小于1")
@Schema(description = "项目ID", example = "")
@Schema(description = "项目ID", example = "1")
private Long projectId;

View File

@ -17,6 +17,7 @@ import java.math.BigDecimal;
"id",
"projectDetailName",
"projectSettlementPrice",
"projectMinSettlementPrice",
"maxCommissionRate",
"projectId",
})
@ -26,39 +27,39 @@ public class ProjectDetailUpdateRequest implements Serializable {
* 项目明细ID
*/
@Min(value = 1L, message = "项目明细ID ID不能小于1")
@Schema(description = "项目明细ID", example = "")
@Schema(description = "项目明细ID", example = "1")
private Long id;
/**
* 项目明细名称
*/
@NotBlank(message = "项目明细名称不能为空")
@Schema(description = "项目明细名称", example = "")
@Schema(description = "项目明细名称", example = "2.9元购买30元券包")
private String projectDetailName;
/**
* 项目结算价
*/
@Schema(description = "项目结算价", example = "")
@Schema(description = "项目结算价", example = "0.72")
private BigDecimal projectSettlementPrice;
/**
* 项目最小结算价格
*/
@Schema(description = "项目最小结算价格", example = "${field.example}")
@Schema(description = "项目最小结算价格", example = "0.66")
private BigDecimal projectMinSettlementPrice;
/**
* 最大抽佣比例
*/
@Schema(description = "最大抽佣比例", example = "")
@Schema(description = "最大抽佣比例", example = "2")
private Integer maxCommissionRate;
/**
* 项目ID
*/
@Min(value = 1L, message = "项目ID ID不能小于1")
@Schema(description = "项目ID", example = "")
@Schema(description = "项目ID", example = "1")
private Long projectId;

View File

@ -80,7 +80,7 @@ public class Project implements Serializable {
/**
* 是否上架
*/
private Integer isShelves;
private Boolean isShelves;
/**
* 是否删除

View File

@ -2,6 +2,7 @@ package com.greenorange.promotion.model.vo.project;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.ibatis.ognl.BooleanExpression;
import java.io.Serial;
import java.io.Serializable;
@ -89,7 +90,7 @@ public class ProjectVO implements Serializable {
/**
* 是否上架
*/
@Schema(description = "是否上架", example = "true")
@Schema(description = "是否上架", example = "1")
private Boolean isShelves;

View File

@ -23,33 +23,33 @@ public class ProjectDetailVO implements Serializable {
/**
* 项目明细名称
*/
@Schema(description = "项目明细名称", example = "${field.example}")
@Schema(description = "项目明细名称", example = "2.9元购买30元券包")
private String projectDetailName;
/**
* 项目结算价
*/
@Schema(description = "项目结算价", example = "${field.example}")
@Schema(description = "项目结算价", example = "0.72")
private BigDecimal projectSettlementPrice;
/**
* 项目最小结算价格
*/
@Schema(description = "项目最小结算价格", example = "${field.example}")
@Schema(description = "项目最小结算价格", example = "0.66")
private BigDecimal projectMinSettlementPrice;
/**
* 最大抽佣比例
*/
@Schema(description = "最大抽佣比例", example = "${field.example}")
@Schema(description = "最大抽佣比例", example = "2")
private Integer maxCommissionRate;
/**
* 项目ID
*/
@Schema(description = "项目ID", example = "${field.example}")
@Schema(description = "项目ID", example = "1")
private Long projectId;

View File

@ -8,6 +8,7 @@
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="projectDetailName" column="projectDetailName" jdbcType="VARCHAR"/>
<result property="projectSettlementPrice" column="projectSettlementPrice" jdbcType="DECIMAL"/>
<result property="projectMinSettlementPrice" column="projectSettlementPrice" jdbcType="DECIMAL"/>
<result property="maxCommissionRate" column="maxCommissionRate" jdbcType="INTEGER"/>
<result property="projectId" column="projectId" jdbcType="BIGINT"/>
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>

View File

@ -8,8 +8,6 @@
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="projectName" column="projectName" jdbcType="VARCHAR"/>
<result property="projectImage" column="projectImage" jdbcType="VARCHAR"/>
<result property="maxProjectPrice" column="maxProjectPrice" jdbcType="DECIMAL"/>
<result property="minProjectPrice" column="minProjectPrice" jdbcType="DECIMAL"/>
<result property="projectDescription" column="projectDescription" jdbcType="VARCHAR"/>
<result property="settlementDesc" column="settlementDesc" jdbcType="VARCHAR"/>
<result property="projectDesc" column="projectDesc" jdbcType="VARCHAR"/>