From 7ca23bc987bfe9a69f23cd93ca4932a9dcc46f3e Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Tue, 24 Jun 2025 09:18:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86Web=E7=AB=AF?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../promotion/annotation/BaseEnum.java | 10 ++ .../promotion/annotation/EnumValue.java | 18 ++ .../annotation/EnumValueValidator.java | 28 +++ .../annotation/FileEnumValidator.java | 20 --- .../promotion/annotation/FileEnumValue.java | 20 --- .../ProjectStatusEnumValidator.java | 18 -- .../annotation/ProjectStatusEnumValue.java | 22 --- .../annotation/UserEnumValidator.java | 22 --- .../promotion/annotation/UserEnumValue.java | 20 --- .../WithdrawStatusEnumValidator.java | 18 -- .../annotation/WithdrawStatusEnumValue.java | 21 --- .../promotion/constant/RegexConstant.java | 2 - .../course/CourseChapterController.java | 145 ++++++++++++++++ .../controller/course/CourseController.java | 160 ++++++++++++++++++ .../exception/GlobalExceptionHandler.java | 33 ++-- .../promotion/generator/Generator.java | 12 +- .../promotion/mapper/CourseChapterMapper.java | 4 +- .../promotion/mapper/CourseMapper.java | 4 +- .../promotion/mapper/CourseOrderMapper.java | 4 +- .../promotion/mapper/PromoRecordMapper.java | 4 +- .../promotion/mapper/RakeRewardMapper.java | 4 +- .../model/dto/course/CourseAddRequest.java | 99 +++++++++++ .../model/dto/course/CourseQueryRequest.java | 41 +++++ .../model/dto/course/CourseUpdateRequest.java | 115 +++++++++++++ .../CourseChapterAddRequest.java | 67 ++++++++ .../CourseChapterQueryRequest.java | 41 +++++ .../CourseChapterUpdateRequest.java | 74 ++++++++ .../dto/fileInfo/FileInfoAddRequest.java | 7 +- .../dto/fileInfo/FileInfoQueryRequest.java | 36 ---- .../dto/fileInfo/FileInfoUpdateRequest.java | 79 --------- .../model/dto/fileInfo/UploadFileRequest.java | 4 +- .../model/dto/project/ProjectAddRequest.java | 11 +- .../project/ProjectStatusUpdateRequest.java | 4 +- .../dto/project/ProjectUpdateRequest.java | 3 + .../dto/userInfo/UserInfoAddRequest.java | 5 +- .../dto/userInfo/UserInfoUpdateRequest.java | 32 +--- .../WithdrawalApplyAddRequest.java | 8 +- .../WithdrawalApplyQueryRequest.java | 6 +- .../WithdrawalApplyUpdateRequest.java | 22 +-- .../promotion/model/entity/Course.java | 26 +-- .../promotion/model/entity/CourseChapter.java | 16 +- .../promotion/model/entity/CourseOrder.java | 26 +-- .../promotion/model/entity/PromoRecord.java | 22 +-- .../promotion/model/entity/RakeReward.java | 34 ++-- .../promotion/model/enums/CourseTypeEnum.java | 58 +++++++ .../model/enums/FileUploadBizEnum.java | 11 +- .../model/enums/PreviewPermissionEnum.java | 59 +++++++ .../model/enums/ProjectStatusEnum.java | 11 +- .../promotion/model/enums/UserRoleEnum.java | 11 +- .../model/enums/WithdrawStatusEnum.java | 11 +- .../promotion/model/vo/course/CourseVO.java | 86 ++++++++++ .../vo/courseChapter/CourseChapterVO.java | 58 +++++++ .../service/course/CourseChapterService.java | 11 +- .../service/course/CourseOrderService.java | 4 +- .../service/course/CourseService.java | 11 +- .../service/course/PromoRecordService.java | 4 +- .../service/course/RakeRewardService.java | 4 +- .../course/impl/CourseChapterServiceImpl.java | 24 ++- .../course/impl/CourseOrderServiceImpl.java | 4 +- .../course/impl/CourseServiceImpl.java | 25 ++- .../course/impl/PromoRecordServiceImpl.java | 4 +- .../course/impl/RakeRewardServiceImpl.java | 4 +- .../project/impl/ProjectServiceImpl.java | 8 +- 63 files changed, 1297 insertions(+), 478 deletions(-) create mode 100644 src/main/java/com/greenorange/promotion/annotation/BaseEnum.java create mode 100644 src/main/java/com/greenorange/promotion/annotation/EnumValue.java create mode 100644 src/main/java/com/greenorange/promotion/annotation/EnumValueValidator.java delete mode 100644 src/main/java/com/greenorange/promotion/annotation/FileEnumValidator.java delete mode 100644 src/main/java/com/greenorange/promotion/annotation/FileEnumValue.java delete mode 100644 src/main/java/com/greenorange/promotion/annotation/ProjectStatusEnumValidator.java delete mode 100644 src/main/java/com/greenorange/promotion/annotation/ProjectStatusEnumValue.java delete mode 100644 src/main/java/com/greenorange/promotion/annotation/UserEnumValidator.java delete mode 100644 src/main/java/com/greenorange/promotion/annotation/UserEnumValue.java delete mode 100644 src/main/java/com/greenorange/promotion/annotation/WithdrawStatusEnumValidator.java delete mode 100644 src/main/java/com/greenorange/promotion/annotation/WithdrawStatusEnumValue.java create mode 100644 src/main/java/com/greenorange/promotion/controller/course/CourseChapterController.java create mode 100644 src/main/java/com/greenorange/promotion/controller/course/CourseController.java create mode 100644 src/main/java/com/greenorange/promotion/model/dto/course/CourseAddRequest.java create mode 100644 src/main/java/com/greenorange/promotion/model/dto/course/CourseQueryRequest.java create mode 100644 src/main/java/com/greenorange/promotion/model/dto/course/CourseUpdateRequest.java create mode 100644 src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterAddRequest.java create mode 100644 src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterQueryRequest.java create mode 100644 src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterUpdateRequest.java delete mode 100644 src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoQueryRequest.java delete mode 100644 src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoUpdateRequest.java create mode 100644 src/main/java/com/greenorange/promotion/model/enums/CourseTypeEnum.java create mode 100644 src/main/java/com/greenorange/promotion/model/enums/PreviewPermissionEnum.java create mode 100644 src/main/java/com/greenorange/promotion/model/vo/course/CourseVO.java create mode 100644 src/main/java/com/greenorange/promotion/model/vo/courseChapter/CourseChapterVO.java diff --git a/src/main/java/com/greenorange/promotion/annotation/BaseEnum.java b/src/main/java/com/greenorange/promotion/annotation/BaseEnum.java new file mode 100644 index 0000000..d0e346a --- /dev/null +++ b/src/main/java/com/greenorange/promotion/annotation/BaseEnum.java @@ -0,0 +1,10 @@ +package com.greenorange.promotion.annotation; + +/** + * 所有待校验的枚举都应实现此接口, + * 并通过 getValue() 返回其对应的校验字符串。 + */ +public interface BaseEnum { + /** 返回该枚举常量对应的校验值 */ + String getValue(); +} diff --git a/src/main/java/com/greenorange/promotion/annotation/EnumValue.java b/src/main/java/com/greenorange/promotion/annotation/EnumValue.java new file mode 100644 index 0000000..ba9a19a --- /dev/null +++ b/src/main/java/com/greenorange/promotion/annotation/EnumValue.java @@ -0,0 +1,18 @@ +package com.greenorange.promotion.annotation; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; +import java.lang.annotation.*; + +@Documented +@Constraint(validatedBy = EnumValueValidator.class) +@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +public @interface EnumValue { + String message() default "无效的枚举值"; + Class[] groups() default {}; + Class[] payload() default {}; + + /** 要校验的枚举类,必须实现 BaseEnum */ + Class enumClass(); +} diff --git a/src/main/java/com/greenorange/promotion/annotation/EnumValueValidator.java b/src/main/java/com/greenorange/promotion/annotation/EnumValueValidator.java new file mode 100644 index 0000000..2c74b47 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/annotation/EnumValueValidator.java @@ -0,0 +1,28 @@ +package com.greenorange.promotion.annotation; + +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * 初始化时从 enumClass 拿到所有常量的 getValue(), + * 然后在 isValid 中判断传入值是否包含于其中。 + */ +public class EnumValueValidator implements ConstraintValidator { + private Set validValues; + + @Override + public void initialize(EnumValue annotation) { + Class enumClass = annotation.enumClass(); + validValues = Stream.of(enumClass.getEnumConstants()) + .map(BaseEnum::getValue) + .collect(Collectors.toSet()); + } + + @Override + public boolean isValid(String value, ConstraintValidatorContext context) { + return validValues.contains(value); + } +} diff --git a/src/main/java/com/greenorange/promotion/annotation/FileEnumValidator.java b/src/main/java/com/greenorange/promotion/annotation/FileEnumValidator.java deleted file mode 100644 index eeebb52..0000000 --- a/src/main/java/com/greenorange/promotion/annotation/FileEnumValidator.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.greenorange.promotion.annotation; - -import com.greenorange.promotion.model.enums.FileUploadBizEnum; -import jakarta.validation.ConstraintValidator; -import jakarta.validation.ConstraintValidatorContext; - -// 枚举校验器 -public class FileEnumValidator implements ConstraintValidator { - - - @Override - public void initialize(FileEnumValue constraintAnnotation) { - - } - - @Override - public boolean isValid(String value, ConstraintValidatorContext context) { - return FileUploadBizEnum.getEnumByValue(value) != null; - } -} diff --git a/src/main/java/com/greenorange/promotion/annotation/FileEnumValue.java b/src/main/java/com/greenorange/promotion/annotation/FileEnumValue.java deleted file mode 100644 index d116762..0000000 --- a/src/main/java/com/greenorange/promotion/annotation/FileEnumValue.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.greenorange.promotion.annotation; - -import jakarta.validation.Constraint; -import jakarta.validation.Payload; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -// 自定义校验注解 -@Constraint(validatedBy = FileEnumValidator.class) -@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -public @interface FileEnumValue { - String message() default "文件业务类型错误"; // 错误信息 - Class[] groups() default {}; // 组别 - Class[] payload() default {}; // 负载 - Class> enumClass(); // 枚举类类型 -} diff --git a/src/main/java/com/greenorange/promotion/annotation/ProjectStatusEnumValidator.java b/src/main/java/com/greenorange/promotion/annotation/ProjectStatusEnumValidator.java deleted file mode 100644 index 286a186..0000000 --- a/src/main/java/com/greenorange/promotion/annotation/ProjectStatusEnumValidator.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.greenorange.promotion.annotation; - -import com.greenorange.promotion.model.enums.ProjectStatusEnum; -import jakarta.validation.ConstraintValidator; -import jakarta.validation.ConstraintValidatorContext; - -public class ProjectStatusEnumValidator implements ConstraintValidator { - - @Override - public void initialize(ProjectStatusEnumValue constraintAnnotation) { - - } - - @Override - public boolean isValid(String value, ConstraintValidatorContext context) { - return ProjectStatusEnum.getEnumByValue(value) != null; - } -} diff --git a/src/main/java/com/greenorange/promotion/annotation/ProjectStatusEnumValue.java b/src/main/java/com/greenorange/promotion/annotation/ProjectStatusEnumValue.java deleted file mode 100644 index 226e4d5..0000000 --- a/src/main/java/com/greenorange/promotion/annotation/ProjectStatusEnumValue.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.greenorange.promotion.annotation; - -import jakarta.validation.Constraint; -import jakarta.validation.Payload; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -// 自定义校验注解 -@Constraint(validatedBy = ProjectStatusEnumValidator.class) -@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -public @interface ProjectStatusEnumValue { - - String message() default "项目状态错误"; // 错误信息 - Class[] groups() default {}; // 组别 - Class[] payload() default {}; // 负载 - Class> enumClass(); // 枚举类类型 - -} diff --git a/src/main/java/com/greenorange/promotion/annotation/UserEnumValidator.java b/src/main/java/com/greenorange/promotion/annotation/UserEnumValidator.java deleted file mode 100644 index a5d2975..0000000 --- a/src/main/java/com/greenorange/promotion/annotation/UserEnumValidator.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.greenorange.promotion.annotation; - - -import com.greenorange.promotion.model.enums.UserRoleEnum; -import jakarta.validation.ConstraintValidator; -import jakarta.validation.ConstraintValidatorContext; - - -// 枚举校验器 -public class UserEnumValidator implements ConstraintValidator { - - - @Override - public void initialize(UserEnumValue constraintAnnotation) { - - } - - @Override - public boolean isValid(String value, ConstraintValidatorContext context) { - return UserRoleEnum.getEnumByValue(value) != null; - } -} diff --git a/src/main/java/com/greenorange/promotion/annotation/UserEnumValue.java b/src/main/java/com/greenorange/promotion/annotation/UserEnumValue.java deleted file mode 100644 index a0d83b2..0000000 --- a/src/main/java/com/greenorange/promotion/annotation/UserEnumValue.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.greenorange.promotion.annotation; - -import jakarta.validation.Constraint; -import jakarta.validation.Payload; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -// 自定义校验注解 -@Constraint(validatedBy = UserEnumValidator.class) -@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -public @interface UserEnumValue { - String message() default "无效的用户角色"; // 错误信息 - Class[] groups() default {}; // 组别 - Class[] payload() default {}; // 负载 - Class> enumClass(); // 枚举类类型 -} diff --git a/src/main/java/com/greenorange/promotion/annotation/WithdrawStatusEnumValidator.java b/src/main/java/com/greenorange/promotion/annotation/WithdrawStatusEnumValidator.java deleted file mode 100644 index 95cd934..0000000 --- a/src/main/java/com/greenorange/promotion/annotation/WithdrawStatusEnumValidator.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.greenorange.promotion.annotation; - -import com.greenorange.promotion.model.enums.WithdrawStatusEnum; -import jakarta.validation.ConstraintValidator; -import jakarta.validation.ConstraintValidatorContext; - -public class WithdrawStatusEnumValidator implements ConstraintValidator { - - @Override - public void initialize(WithdrawStatusEnumValue constraintAnnotation) { - - } - - @Override - public boolean isValid(String value, ConstraintValidatorContext context) { - return WithdrawStatusEnum.getEnumByValue(value) != null; - } -} diff --git a/src/main/java/com/greenorange/promotion/annotation/WithdrawStatusEnumValue.java b/src/main/java/com/greenorange/promotion/annotation/WithdrawStatusEnumValue.java deleted file mode 100644 index 8c2ba7b..0000000 --- a/src/main/java/com/greenorange/promotion/annotation/WithdrawStatusEnumValue.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.greenorange.promotion.annotation; - -import jakarta.validation.Constraint; -import jakarta.validation.Payload; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -// 自定义校验注解 -@Constraint(validatedBy = WithdrawStatusEnumValidator.class) -@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -public @interface WithdrawStatusEnumValue { - String message() default "提现状态错误"; // 错误信息 - Class[] groups() default {}; // 组别 - Class[] payload() default {}; // 负载 - Class> enumClass(); // 枚举类类型 -} diff --git a/src/main/java/com/greenorange/promotion/constant/RegexConstant.java b/src/main/java/com/greenorange/promotion/constant/RegexConstant.java index b5bd4f0..0c18a01 100644 --- a/src/main/java/com/greenorange/promotion/constant/RegexConstant.java +++ b/src/main/java/com/greenorange/promotion/constant/RegexConstant.java @@ -2,8 +2,6 @@ package com.greenorange.promotion.constant; /** * 正则表达式常量 - * - * @author 玄德 */ @SuppressWarnings("all") public interface RegexConstant { diff --git a/src/main/java/com/greenorange/promotion/controller/course/CourseChapterController.java b/src/main/java/com/greenorange/promotion/controller/course/CourseChapterController.java new file mode 100644 index 0000000..9cf88d9 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/controller/course/CourseChapterController.java @@ -0,0 +1,145 @@ +package com.greenorange.promotion.controller.course; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.greenorange.promotion.annotation.RequiresPermission; +import com.greenorange.promotion.annotation.SysLog; +import com.greenorange.promotion.common.BaseResponse; +import com.greenorange.promotion.common.ResultUtils; +import com.greenorange.promotion.constant.UserConstant; +import com.greenorange.promotion.model.dto.CommonBatchRequest; +import com.greenorange.promotion.model.dto.CommonRequest; +import com.greenorange.promotion.model.dto.courseChapter.CourseChapterAddRequest; +import com.greenorange.promotion.model.dto.courseChapter.CourseChapterQueryRequest; +import com.greenorange.promotion.model.dto.courseChapter.CourseChapterUpdateRequest; +import com.greenorange.promotion.model.entity.CourseChapter; +import com.greenorange.promotion.model.vo.courseChapter.CourseChapterVO; +import com.greenorange.promotion.service.common.CommonService; +import com.greenorange.promotion.service.course.CourseChapterService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + + +/** + * 课程章节 控制器 + */ +@RestController +@RequestMapping("courseChapter") +@Slf4j +@Tag(name = "课程章节模块") +public class CourseChapterController { + + @Resource + private CourseChapterService courseChapterService; + + @Resource + private CommonService commonService; + + /** + * web端管理员添加课程章节 + * @param courseChapterAddRequest 课程章节添加请求体 + * @return 是否添加成功 + */ + @PostMapping("add") + @Operation(summary = "web端管理员添加课程章节", description = "参数:课程章节添加请求体,权限:管理员,方法名:addCourseChapter") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程章节管理", content = "web端管理员添加课程章节") + public BaseResponse addCourseChapter(@Valid @RequestBody CourseChapterAddRequest courseChapterAddRequest) { + CourseChapter courseChapter = commonService.copyProperties(courseChapterAddRequest, CourseChapter.class); + courseChapterService.save(courseChapter); + return ResultUtils.success(courseChapter.getId()); + } + + /** + * web端管理员根据id修改课程章节信息 + * @param courseChapterUpdateRequest 课程章节更新请求体 + * @return 是否更新成功 + */ + @PostMapping("update") + @Operation(summary = "web端管理员根据id修改课程章节", description = "参数:课程章节更新请求体,权限:管理员,方法名:updateCourseChapter") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程章节管理", content = "web端管理员根据id修改课程章节信息") + public BaseResponse updateCourseChapter(@Valid @RequestBody CourseChapterUpdateRequest courseChapterUpdateRequest) { + CourseChapter courseChapter = commonService.copyProperties(courseChapterUpdateRequest, CourseChapter.class); + courseChapterService.updateById(courseChapter); + return ResultUtils.success(true); + } + + /** + * web端管理员根据id删除课程章节 + * @param commonRequest 课程章节删除请求体 + * @return 是否删除成功 + */ + @PostMapping("delete") + @Operation(summary = "web端管理员根据id删除课程章节", description = "参数:课程章节删除请求体,权限:管理员,方法名:delCourseChapter") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程章节管理", content = "web端管理员根据id删除课程章节") + public BaseResponse delCourseChapter(@Valid @RequestBody CommonRequest commonRequest) { + Long id = commonRequest.getId(); + courseChapterService.removeById(id); + return ResultUtils.success(true); + } + + /** + * web端管理员批量删除课程章节 + * @param commonBatchRequest 课程章节批量删除请求体 + * @return 是否删除成功 + */ + @PostMapping("delBatch") + @Operation(summary = "web端管理员批量删除课程章节", description = "参数:课程章节批量删除请求体,权限:管理员,方法名:delBatchCourseChapter") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程章节管理", content = "web端管理员批量删除课程章节") + public BaseResponse delBatchCourseChapter(@Valid @RequestBody CommonBatchRequest commonBatchRequest) { + List ids = commonBatchRequest.getIds(); + courseChapterService.removeByIds(ids); + return ResultUtils.success(true); + } + + /** + * web端管理员根据id查询课程章节 + * @param commonRequest 课程章节查询请求体 + * @return 课程章节信息 + */ + @PostMapping("queryById") + @Operation(summary = "web端管理员根据id查询课程章节", description = "参数:课程章节查询请求体,权限:管理员,方法名:queryCourseChapterById") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程章节管理", content = "web端管理员根据id查询课程章节") + public BaseResponse queryCourseChapterById(@Valid @RequestBody CommonRequest commonRequest) { + Long id = commonRequest.getId(); + CourseChapter courseChapter = courseChapterService.getById(id); + CourseChapterVO courseChapterVO = commonService.copyProperties(courseChapter, CourseChapterVO.class); + return ResultUtils.success(courseChapterVO); + } + + /** + * Web端管理员分页查询课程章节 + * @param courseChapterQueryRequest 课程章节查询请求体 + * @return 课程章节列表 + */ + @PostMapping("page") + @Operation(summary = "Web端管理员分页查询课程章节", description = "参数:课程章节查询请求体,权限:管理员,方法名:listCourseChapterByPage") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程章节管理", content = "Web端管理员分页查询课程章节") + public BaseResponse> listCourseChapterByPage(@Valid @RequestBody CourseChapterQueryRequest courseChapterQueryRequest) { + long current = courseChapterQueryRequest.getCurrent(); + long pageSize = courseChapterQueryRequest.getPageSize(); + QueryWrapper queryWrapper = courseChapterService.getQueryWrapper(courseChapterQueryRequest); + Page page = courseChapterService.page(new Page<>(current, pageSize), queryWrapper); + List courseChapterList = page.getRecords(); + List courseChapterVOList = commonService.convertList(courseChapterList, CourseChapterVO.class); + Page voPage = new Page<>(current, pageSize); + voPage.setRecords(courseChapterVOList); + voPage.setPages(page.getPages()); + voPage.setTotal(page.getTotal()); + return ResultUtils.success(voPage); + } +} \ No newline at end of file diff --git a/src/main/java/com/greenorange/promotion/controller/course/CourseController.java b/src/main/java/com/greenorange/promotion/controller/course/CourseController.java new file mode 100644 index 0000000..c4d0cc9 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/controller/course/CourseController.java @@ -0,0 +1,160 @@ +package com.greenorange.promotion.controller.course; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.greenorange.promotion.annotation.RequiresPermission; +import com.greenorange.promotion.annotation.SysLog; +import com.greenorange.promotion.common.BaseResponse; +import com.greenorange.promotion.common.ResultUtils; +import com.greenorange.promotion.constant.UserConstant; +import com.greenorange.promotion.model.dto.CommonBatchRequest; +import com.greenorange.promotion.model.dto.CommonRequest; +import com.greenorange.promotion.model.dto.course.CourseAddRequest; +import com.greenorange.promotion.model.dto.course.CourseQueryRequest; +import com.greenorange.promotion.model.dto.course.CourseUpdateRequest; +import com.greenorange.promotion.model.entity.Course; +import com.greenorange.promotion.model.entity.CourseChapter; +import com.greenorange.promotion.model.vo.course.CourseVO; +import com.greenorange.promotion.service.common.CommonService; +import com.greenorange.promotion.service.course.CourseChapterService; +import com.greenorange.promotion.service.course.CourseService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + + +/** + * 课程 控制器 + */ +@RestController +@RequestMapping("course") +@Slf4j +@Tag(name = "课程模块") +public class CourseController { + + @Resource + private CourseService courseService; + + @Resource + private CommonService commonService; + + @Resource + private CourseChapterService courseChapterService; + + /** + * web端管理员添加课程 + * @param courseAddRequest 课程添加请求体 + * @return 是否添加成功 + */ + @PostMapping("add") + @Operation(summary = "web端管理员添加课程", description = "参数:课程添加请求体,权限:管理员,方法名:addCourse") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程管理", content = "web端管理员添加课程") + public BaseResponse addCourse(@Valid @RequestBody CourseAddRequest courseAddRequest) { + Course course = commonService.copyProperties(courseAddRequest, Course.class); + courseService.save(course); + return ResultUtils.success(course.getId()); + } + + /** + * web端管理员根据id修改课程信息 + * @param courseUpdateRequest 课程更新请求体 + * @return 是否更新成功 + */ + @PostMapping("update") + @Operation(summary = "web端管理员根据id修改课程", description = "参数:课程更新请求体,权限:管理员,方法名:updateCourse") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程管理", content = "web端管理员根据id修改课程信息") + public BaseResponse updateCourse(@Valid @RequestBody CourseUpdateRequest courseUpdateRequest) { + Course course = commonService.copyProperties(courseUpdateRequest, Course.class); + courseService.updateById(course); + return ResultUtils.success(true); + } + + /** + * web端管理员根据id删除课程 + * @param commonRequest 课程删除请求体 + * @return 是否删除成功 + */ + @PostMapping("delete") + @Operation(summary = "web端管理员根据id删除课程", description = "参数:课程删除请求体,权限:管理员,方法名:delCourse") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程管理", content = "web端管理员根据id删除课程") + public BaseResponse delCourse(@Valid @RequestBody CommonRequest commonRequest) { + Long id = commonRequest.getId(); + courseService.removeById(id); + // 删除课程下的所有章节 + LambdaQueryWrapper lambdaQueryWrapper = commonService.buildQueryWrapperByField(CourseChapter::getCourseId, id, courseChapterService); + courseChapterService.remove(lambdaQueryWrapper); + return ResultUtils.success(true); + } + + /** + * web端管理员批量删除课程 + * @param commonBatchRequest 课程批量删除请求体 + * @return 是否删除成功 + */ + @PostMapping("delBatch") + @Operation(summary = "web端管理员批量删除课程", description = "参数:课程批量删除请求体,权限:管理员,方法名:delBatchCourse") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程管理", content = "web端管理员批量删除课程") + public BaseResponse delBatchCourse(@Valid @RequestBody CommonBatchRequest commonBatchRequest) { + List ids = commonBatchRequest.getIds(); + courseService.removeByIds(ids); + // 批量删除课程下的所有章节 + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.in(CourseChapter::getCourseId, ids); + courseChapterService.remove(lambdaQueryWrapper); + return ResultUtils.success(true); + } + + /** + * web端管理员根据id查询课程 + * @param commonRequest 课程查询请求体 + * @return 课程信息 + */ + @PostMapping("queryById") + @Operation(summary = "web端管理员根据id查询课程", description = "参数:课程查询请求体,权限:管理员,方法名:queryCourseById") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程管理", content = "web端管理员根据id查询课程") + public BaseResponse queryCourseById(@Valid @RequestBody CommonRequest commonRequest) { + Long id = commonRequest.getId(); + Course course = courseService.getById(id); + CourseVO courseVO = commonService.copyProperties(course, CourseVO.class); + return ResultUtils.success(courseVO); + } + + /** + * Web端管理员分页查询课程 + * @param courseQueryRequest 课程查询请求体 + * @return 课程列表 + */ + @PostMapping("page") + @Operation(summary = "Web端管理员分页查询课程", description = "参数:课程查询请求体,权限:管理员,方法名:listCourseByPage") + @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) + @SysLog(title = "课程管理", content = "Web端管理员分页查询课程") + public BaseResponse> listCourseByPage(@Valid @RequestBody CourseQueryRequest courseQueryRequest) { + long current = courseQueryRequest.getCurrent(); + long pageSize = courseQueryRequest.getPageSize(); + QueryWrapper queryWrapper = courseService.getQueryWrapper(courseQueryRequest); + Page page = courseService.page(new Page<>(current, pageSize), queryWrapper); + List courseList = page.getRecords(); + List courseVOList = commonService.convertList(courseList, CourseVO.class); + Page voPage = new Page<>(current, pageSize); + voPage.setRecords(courseVOList); + voPage.setPages(page.getPages()); + voPage.setTotal(page.getTotal()); + return ResultUtils.success(voPage); + } +} \ No newline at end of file diff --git a/src/main/java/com/greenorange/promotion/exception/GlobalExceptionHandler.java b/src/main/java/com/greenorange/promotion/exception/GlobalExceptionHandler.java index a5c1491..8a38384 100644 --- a/src/main/java/com/greenorange/promotion/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/greenorange/promotion/exception/GlobalExceptionHandler.java @@ -50,16 +50,29 @@ public class GlobalExceptionHandler { // 处理参数绑定失败的异常 @ExceptionHandler(MethodArgumentNotValidException.class) public BaseResponse handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { - StringBuilder errors = new StringBuilder(); - // 按字段名排序,确保每次返回的顺序一致 - e.getBindingResult().getFieldErrors().stream() - .sorted(Comparator.comparing(FieldError::getField)) // 按字段名排序 - .forEach(fieldError -> errors.append("参数: ") - .append(fieldError.getField()) - .append(" | 错误: ") - .append(fieldError.getDefaultMessage()) - .append("; ")); - return ResultUtils.error(ErrorCode.PARAMS_ERROR, errors.toString()); +// StringBuilder errors = new StringBuilder(); +// // 按字段名排序,确保每次返回的顺序一致 +// e.getBindingResult().getFieldErrors().stream() +// .sorted(Comparator.comparing(FieldError::getField)) // 按字段名排序 +// .forEach(fieldError -> errors.append("参数: ") +// .append(fieldError.getField()) +// .append(" | 错误: ") +// .append(fieldError.getDefaultMessage()) +// .append("; ")); +// return ResultUtils.error(ErrorCode.PARAMS_ERROR, errors.toString()); + + // 从所有 FieldError 里,排序后取第一个 + FieldError firstError = e.getBindingResult() + .getFieldErrors().stream().min(Comparator.comparing(FieldError::getField)) + .orElse(null); + + // 直接取它的 defaultMessage,即注解里配置的 message + String msg = (firstError != null) + ? firstError.getDefaultMessage() + : "参数校验失败"; + + // 返回时只带 msg,不再拼前缀或字段名 + return ResultUtils.error(ErrorCode.PARAMS_ERROR, msg); } diff --git a/src/main/java/com/greenorange/promotion/generator/Generator.java b/src/main/java/com/greenorange/promotion/generator/Generator.java index 7a7d90c..0bccb73 100644 --- a/src/main/java/com/greenorange/promotion/generator/Generator.java +++ b/src/main/java/com/greenorange/promotion/generator/Generator.java @@ -15,9 +15,9 @@ import java.util.*; public class Generator { // 数据源配置 - private static final String DATASOURCE_URL = "jdbc:mysql://1.94.237.210:3306/qingcheng?serverTimezone=Asia/Shanghai"; + private static final String DATASOURCE_URL = "jdbc:mysql://27.30.77.229:3306/qingcheng_dev?serverTimezone=Asia/Shanghai"; private static final String USERNAME = "qingcheng"; - private static final String PASSWORD = "Qc@123456"; + private static final String PASSWORD = "Qc@8ls2jf"; // 输出路径 private static final String OUTPUT_PATH = System.getProperty("user.dir"); @@ -27,13 +27,13 @@ public class Generator { // 作者 private static final String AUTHOR = "chenxinzhi"; // 表注释 - private static final String TABLE_COMMENT = "用户账户"; + private static final String TABLE_COMMENT = "课程章节"; // 实体类名 - private static final String ENTITY_NAME = "UserAccount"; + private static final String ENTITY_NAME = "CourseChapter"; // 表名 - private static final String TABLE_NAME = "user_account"; + private static final String TABLE_NAME = "course_chapter"; // 实体类属性名 - private static final String ENTITY_NAME_LOWER = "userAccount"; + private static final String ENTITY_NAME_LOWER = "courseChapter"; // 父包名 private static final String PARENT_PATH = "com.greenorange.promotion"; diff --git a/src/main/java/com/greenorange/promotion/mapper/CourseChapterMapper.java b/src/main/java/com/greenorange/promotion/mapper/CourseChapterMapper.java index c135056..049454a 100644 --- a/src/main/java/com/greenorange/promotion/mapper/CourseChapterMapper.java +++ b/src/main/java/com/greenorange/promotion/mapper/CourseChapterMapper.java @@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * @author 35880 -* @description 针对表【course_chapter】的数据库操作Mapper -* @createDate 2025-06-23 18:07:34 +* @description 针对表【course_chapter(课程章节表)】的数据库操作Mapper +* @createDate 2025-06-23 18:30:28 * @Entity com.greenorange.promotion.model.entity.CourseChapter */ public interface CourseChapterMapper extends BaseMapper { diff --git a/src/main/java/com/greenorange/promotion/mapper/CourseMapper.java b/src/main/java/com/greenorange/promotion/mapper/CourseMapper.java index 75f0672..d72dcf8 100644 --- a/src/main/java/com/greenorange/promotion/mapper/CourseMapper.java +++ b/src/main/java/com/greenorange/promotion/mapper/CourseMapper.java @@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * @author 35880 -* @description 针对表【course】的数据库操作Mapper -* @createDate 2025-06-23 17:06:12 +* @description 针对表【course(课程表)】的数据库操作Mapper +* @createDate 2025-06-23 18:29:49 * @Entity com.greenorange.promotion.model.entity.Course */ public interface CourseMapper extends BaseMapper { diff --git a/src/main/java/com/greenorange/promotion/mapper/CourseOrderMapper.java b/src/main/java/com/greenorange/promotion/mapper/CourseOrderMapper.java index aa5c398..1c36fe7 100644 --- a/src/main/java/com/greenorange/promotion/mapper/CourseOrderMapper.java +++ b/src/main/java/com/greenorange/promotion/mapper/CourseOrderMapper.java @@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * @author 35880 -* @description 针对表【course_order】的数据库操作Mapper -* @createDate 2025-06-23 18:08:14 +* @description 针对表【course_order(课程订单表)】的数据库操作Mapper +* @createDate 2025-06-23 18:31:13 * @Entity com.greenorange.promotion.model.entity.CourseOrder */ public interface CourseOrderMapper extends BaseMapper { diff --git a/src/main/java/com/greenorange/promotion/mapper/PromoRecordMapper.java b/src/main/java/com/greenorange/promotion/mapper/PromoRecordMapper.java index 1ecd197..39071cc 100644 --- a/src/main/java/com/greenorange/promotion/mapper/PromoRecordMapper.java +++ b/src/main/java/com/greenorange/promotion/mapper/PromoRecordMapper.java @@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * @author 35880 -* @description 针对表【promo_record】的数据库操作Mapper -* @createDate 2025-06-23 18:09:37 +* @description 针对表【promo_record(推广记录表)】的数据库操作Mapper +* @createDate 2025-06-23 18:31:45 * @Entity com.greenorange.promotion.model.entity.PromoRecord */ public interface PromoRecordMapper extends BaseMapper { diff --git a/src/main/java/com/greenorange/promotion/mapper/RakeRewardMapper.java b/src/main/java/com/greenorange/promotion/mapper/RakeRewardMapper.java index ff2dcdb..1de050f 100644 --- a/src/main/java/com/greenorange/promotion/mapper/RakeRewardMapper.java +++ b/src/main/java/com/greenorange/promotion/mapper/RakeRewardMapper.java @@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * @author 35880 -* @description 针对表【rake_reward】的数据库操作Mapper -* @createDate 2025-06-23 18:09:57 +* @description 针对表【rake_reward(课程抽成记录表)】的数据库操作Mapper +* @createDate 2025-06-23 18:32:46 * @Entity com.greenorange.promotion.model.entity.RakeReward */ public interface RakeRewardMapper extends BaseMapper { diff --git a/src/main/java/com/greenorange/promotion/model/dto/course/CourseAddRequest.java b/src/main/java/com/greenorange/promotion/model/dto/course/CourseAddRequest.java new file mode 100644 index 0000000..74546fc --- /dev/null +++ b/src/main/java/com/greenorange/promotion/model/dto/course/CourseAddRequest.java @@ -0,0 +1,99 @@ +package com.greenorange.promotion.model.dto.course; + +import com.greenorange.promotion.annotation.EnumValue; +import com.greenorange.promotion.model.enums.CourseTypeEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.DecimalMin; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; +import java.math.BigDecimal; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 课程添加请求体 + */ +@Data +@Schema(description = "课程添加请求体", requiredProperties = { + "name", + "type", + "detail", + "promoCodeDesc", + "image", + "originPrice", + "discountPrice", + "firstLevelRate", + "secondLevelRate", +}) +public class CourseAddRequest implements Serializable { + + /** + * 课程名称 + */ + @NotBlank(message = "课程名称不能为空") + @Schema(description = "课程名称", example = "数据分析工程师训练营") + private String name; + + /** + * 课程类别[考公考研,自媒体,财经] + */ + @NotBlank(message = "课程类别不能为空") + @EnumValue(enumClass = CourseTypeEnum.class) + @Schema(description = "课程类别[考公考研,自媒体,财经]", example = "自媒体") + private String type; + + /** + * 课程概述(富文本) + */ + @NotBlank(message = "课程概述(富文本)不能为空") + @Schema(description = "课程概述(富文本)", example = "富文本") + private String detail; + + /** + * 推广码说明(富文本) + */ + @NotBlank(message = "推广码说明(富文本)不能为空") + @Schema(description = "推广码说明(富文本)", example = "富文本") + private String promoCodeDesc; + + /** + * 课程图片URL + */ + @NotBlank(message = "课程图片URL不能为空") + @Schema(description = "课程图片URL", example = "324IEHJDE") + private String image; + + /** + * 课程原价 + */ + @DecimalMin(value = "0", message = "课程原价不能小于0") + @Schema(description = "课程原价", example = "3499") + private BigDecimal originPrice; + + /** + * 折扣价格 + */ + @DecimalMin(value = "0", message = "折扣价格不能小于0") + @Schema(description = "折扣价格", example = "2499") + private BigDecimal discountPrice; + + /** + * 一级佣金比例(%) + */ + @DecimalMin(value = "0", message = "一级佣金比例不能小于0") + @Schema(description = "一级佣金比例(%)", example = "10") + private BigDecimal firstLevelRate; + + /** + * 二级佣金比例(%) + */ + @DecimalMin(value = "0", message = "二级佣金比例不能小于0") + @Schema(description = "二级佣金比例(%)", example = "5") + private BigDecimal secondLevelRate; + + + @Serial + private static final long serialVersionUID = 1L; +} + diff --git a/src/main/java/com/greenorange/promotion/model/dto/course/CourseQueryRequest.java b/src/main/java/com/greenorange/promotion/model/dto/course/CourseQueryRequest.java new file mode 100644 index 0000000..cc48881 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/model/dto/course/CourseQueryRequest.java @@ -0,0 +1,41 @@ +package com.greenorange.promotion.model.dto.course; + +import com.greenorange.promotion.annotation.EnumValue; +import com.greenorange.promotion.model.enums.CourseTypeEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Min; +import lombok.Data; +import java.math.BigDecimal; + +import java.io.Serial; +import java.io.Serializable; +import com.greenorange.promotion.common.PageRequest; + +/** + * 课程查询请求体,继承自分页请求 PageRequest + */ +@Data +@Schema(description = "课程查询请求体", requiredProperties = {"current", "pageSize"}) +public class CourseQueryRequest extends PageRequest implements Serializable { + + /** + * 课程名称 + */ + @NotBlank(message = "课程名称不能为空") + @Schema(description = "课程名称", example = "数据分析工程师训练营") + private String name; + + /** + * 课程类别[考公考研,自媒体,财经] + */ + @NotBlank(message = "课程类别不能为空") + @EnumValue(enumClass = CourseTypeEnum.class) + @Schema(description = "课程类别[考公考研,自媒体,财经]", example = "自媒体") + private String type; + + + @Serial + private static final long serialVersionUID = 1L; +} + diff --git a/src/main/java/com/greenorange/promotion/model/dto/course/CourseUpdateRequest.java b/src/main/java/com/greenorange/promotion/model/dto/course/CourseUpdateRequest.java new file mode 100644 index 0000000..cea8cfe --- /dev/null +++ b/src/main/java/com/greenorange/promotion/model/dto/course/CourseUpdateRequest.java @@ -0,0 +1,115 @@ +package com.greenorange.promotion.model.dto.course; + +import com.greenorange.promotion.annotation.EnumValue; +import com.greenorange.promotion.model.enums.CourseTypeEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.DecimalMin; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Min; +import lombok.Data; + +import java.math.BigDecimal; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 课程更新请求体 + */ +@Data +@Schema(description = "课程更新请求体", requiredProperties = { + "id", + "name", + "type", + "detail", + "promoCodeDesc", + "image", + "originPrice", + "discountPrice", + "orderCount", + "firstLevelRate", + "secondLevelRate", +}) +public class CourseUpdateRequest implements Serializable { + + /** + * 课程ID + */ + @Min(value = 1L, message = "课程ID ID不能小于1") + @Schema(description = "课程ID", example = "1") + private Long id; + + /** + * 课程名称 + */ + @NotBlank(message = "课程名称不能为空") + @Schema(description = "课程名称", example = "数据分析工程师训练营") + private String name; + + /** + * 课程类别[考公考研,自媒体,财经] + */ + @NotBlank(message = "课程类别不能为空") + @EnumValue(enumClass = CourseTypeEnum.class) + @Schema(description = "课程类别[考公考研,自媒体,财经]", example = "自媒体") + private String type; + + /** + * 课程概述(富文本) + */ + @NotBlank(message = "课程概述(富文本)不能为空") + @Schema(description = "课程概述(富文本)", example = "富文本") + private String detail; + + /** + * 推广码说明(富文本) + */ + @NotBlank(message = "推广码说明(富文本)不能为空") + @Schema(description = "推广码说明(富文本)", example = "富文本") + private String promoCodeDesc; + + /** + * 课程图片URL + */ + @NotBlank(message = "课程图片URL不能为空") + @Schema(description = "课程图片URL", example = "324IEHJDE") + private String image; + + /** + * 课程原价 + */ + @DecimalMin(value = "0.0", message = "课程原价不能小于0") + @Schema(description = "课程原价", example = "3499") + private BigDecimal originPrice; + + /** + * 折扣价格 + */ + @DecimalMin(value = "0.0", message = "折扣价格不能小于0") + @Schema(description = "折扣价格", example = "2499") + private BigDecimal discountPrice; + + /** + * 已下单人数 + */ + @Schema(description = "已下单人数", example = "100") + private Integer orderCount; + + /** + * 一级佣金比例(%) + */ + @DecimalMin(value = "0.0", message = "一级佣金比例不能小于0") + @Schema(description = "一级佣金比例(%)", example = "10") + private BigDecimal firstLevelRate; + + /** + * 二级佣金比例(%) + */ + @DecimalMin(value = "0.0", message = "二级佣金比例不能小于0") + @Schema(description = "二级佣金比例(%)", example = "5") + private BigDecimal secondLevelRate; + + + @Serial + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterAddRequest.java b/src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterAddRequest.java new file mode 100644 index 0000000..adaa2a4 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterAddRequest.java @@ -0,0 +1,67 @@ +package com.greenorange.promotion.model.dto.courseChapter; + +import com.greenorange.promotion.annotation.EnumValue; +import com.greenorange.promotion.model.enums.PreviewPermissionEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Min; +import lombok.Data; +import java.math.BigDecimal; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 课程章节添加请求体 + */ +@Data +@Schema(description = "课程章节添加请求体", requiredProperties = { + "name", + "duration", + "permissions", + "videoView", + "courseId", +}) +public class CourseChapterAddRequest implements Serializable { + + /** + * 章节名称 + */ + @NotBlank(message = "章节名称不能为空") + @Schema(description = "章节名称", example = "企业经营管理者为什么必须懂财务?") + private String name; + + /** + * 章节时长(单位:秒) + */ + @Min(value = 0L, message = "章节时长不能小于0") + @Schema(description = "章节时长", example = "600") + private Long duration; + + /** + * 试看权限 + */ + @NotBlank(message = "试看权限不能为空") + @EnumValue(enumClass = PreviewPermissionEnum.class) + @Schema(description = "试看权限", example = "全集试看") + private String permissions; + + /** + * 视频文件 view 值 + */ + @NotBlank(message = "视频文件 view 值不能为空") + @Schema(description = "视频文件 view 值", example = "3E29KDS9") + private String videoView; + + /** + * 所属课程ID + */ + @Min(value = 1L, message = "所属课程ID ID不能小于1") + @Schema(description = "所属课程ID", example = "1") + private Long courseId; + + + @Serial + private static final long serialVersionUID = 1L; +} + diff --git a/src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterQueryRequest.java b/src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterQueryRequest.java new file mode 100644 index 0000000..444abb2 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterQueryRequest.java @@ -0,0 +1,41 @@ +package com.greenorange.promotion.model.dto.courseChapter; + +import com.greenorange.promotion.annotation.EnumValue; +import com.greenorange.promotion.model.enums.PreviewPermissionEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Min; +import lombok.Data; +import java.math.BigDecimal; + +import java.io.Serial; +import java.io.Serializable; +import com.greenorange.promotion.common.PageRequest; + +/** + * 课程章节查询请求体,继承自分页请求 PageRequest + */ +@Data +@Schema(description = "课程章节查询请求体", requiredProperties = {"current", "pageSize"}) +public class CourseChapterQueryRequest extends PageRequest implements Serializable { + + /** + * 章节名称 + */ + @NotBlank(message = "章节名称不能为空") + @Schema(description = "章节名称", example = "企业经营管理者为什么必须懂财务?") + private String name; + + /** + * 试看权限 + */ + @NotBlank(message = "试看权限不能为空") + @EnumValue(enumClass = PreviewPermissionEnum.class) + @Schema(description = "试看权限", example = "全集试看") + private String permissions; + + + @Serial + private static final long serialVersionUID = 1L; +} + diff --git a/src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterUpdateRequest.java b/src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterUpdateRequest.java new file mode 100644 index 0000000..381da16 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/model/dto/courseChapter/CourseChapterUpdateRequest.java @@ -0,0 +1,74 @@ +package com.greenorange.promotion.model.dto.courseChapter; + +import com.greenorange.promotion.annotation.EnumValue; +import com.greenorange.promotion.model.enums.PreviewPermissionEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Min; +import lombok.Data; +import java.math.BigDecimal; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 课程章节更新请求体 + */ +@Data +@Schema(description = "课程章节更新请求体", requiredProperties = { + "id", + "name", + "duration", + "permissions", + "videoView", + "courseId", +}) +public class CourseChapterUpdateRequest implements Serializable { + + /** + * 章节ID + */ + @Min(value = 1L, message = "章节ID ID不能小于1") + @Schema(description = "章节ID", example = "1") + private Long id; + + /** + * 章节名称 + */ + @NotBlank(message = "章节名称不能为空") + @Schema(description = "章节名称", example = "企业经营管理者为什么必须懂财务?") + private String name; + + /** + * 章节时长(单位:秒) + */ + @Min(value = 0L, message = "章节时长不能小于0") + @Schema(description = "章节时长", example = "600") + private Long duration; + + /** + * 试看权限 + */ + @NotBlank(message = "试看权限不能为空") + @EnumValue(enumClass = PreviewPermissionEnum.class) + @Schema(description = "试看权限", example = "全集试看") + private String permissions; + + /** + * 视频文件 view 值 + */ + @NotBlank(message = "视频文件 view 值不能为空") + @Schema(description = "视频文件 view 值", example = "3E29KDS9") + private String videoView; + + /** + * 所属课程ID + */ + @Min(value = 1L, message = "所属课程ID ID不能小于1") + @Schema(description = "所属课程ID", example = "1") + private Long courseId; + + + @Serial + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoAddRequest.java b/src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoAddRequest.java index 686cf07..5e62d63 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoAddRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoAddRequest.java @@ -1,13 +1,10 @@ package com.greenorange.promotion.model.dto.fileInfo; -import com.greenorange.promotion.annotation.FileEnumValue; +import com.greenorange.promotion.annotation.EnumValue; import com.greenorange.promotion.model.enums.FileUploadBizEnum; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; -import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Data; -import lombok.NoArgsConstructor; import java.io.Serial; import java.io.Serializable; @@ -55,7 +52,7 @@ public class FileInfoAddRequest implements Serializable { /** * 文件业务类型[头像(avatar)|项目(project)|富文本(richText)|默认(default))] */ - @FileEnumValue(enumClass = FileUploadBizEnum.class) + @EnumValue(enumClass = FileUploadBizEnum.class) @Schema(description = "文件业务类型[头像(avatar)|项目(project)|富文本(richText)|默认(default))]", example = "avatar") private String biz; diff --git a/src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoQueryRequest.java b/src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoQueryRequest.java deleted file mode 100644 index 2ce421f..0000000 --- a/src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoQueryRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.greenorange.promotion.model.dto.fileInfo; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.Min; -import lombok.Data; - -import java.io.Serial; -import java.io.Serializable; -import com.greenorange.promotion.common.PageRequest; - -/** - * 文件查询请求体,继承自分页请求 PageRequest - */ -@Data -@Schema(description = "文件查询请求体", requiredProperties = {"current", "pageSize"}) -public class FileInfoQueryRequest extends PageRequest implements Serializable { - - /** - * 文件ID - */ - @Min(value = 1L, message = "文件ID ID不能小于1") - @Schema(description = "文件ID", example = "1") - private Long id; - - - /** - * 文件view值 - */ - @Schema(description = "文件view值", example = "3E8U2AM8") - private String fileView; - - - @Serial - private static final long serialVersionUID = 1L; -} - diff --git a/src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoUpdateRequest.java b/src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoUpdateRequest.java deleted file mode 100644 index dbc0ef8..0000000 --- a/src/main/java/com/greenorange/promotion/model/dto/fileInfo/FileInfoUpdateRequest.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.greenorange.promotion.model.dto.fileInfo; - -import com.greenorange.promotion.annotation.FileEnumValue; -import com.greenorange.promotion.model.enums.FileUploadBizEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Min; -import lombok.Data; - -import java.io.Serial; -import java.io.Serializable; - -/** - * 文件更新请求体 - */ -@Data -@Schema(description = "文件更新请求体", requiredProperties = { - "id", - "name", - "type", - "size", - "fileView", - "biz", -}) -public class FileInfoUpdateRequest implements Serializable { - - /** - * 文件ID - */ - @Min(value = 1L, message = "文件ID ID不能小于1") - @Schema(description = "文件ID", example = "1") - private Long id; - - /** - * 文件名 - */ - @NotBlank(message = "文件名不能为空") - @Schema(description = "文件名", example = "file.png") - private String name; - - /** - * 文件类型 - */ - @NotBlank(message = "文件类型不能为空") - @Schema(description = "文件类型", example = "png") - private String type; - - /** - * 文件大小(KB) - */ - @Min(value = 1L, message = "文件大小 ID不能小于1") - @Schema(description = "文件大小", example = "3000") - private Double size; - - /** - * 文件view值 - */ - @NotBlank(message = "文件view值不能为空") - @Schema(description = "文件view值", example = "3E8U2AM8") - private String fileView; - - /** - * 文件业务类型[头像(avatar)|项目(project)|富文本(richText)|默认(default))] - */ - @FileEnumValue(enumClass = FileUploadBizEnum.class) - @Schema(description = "文件业务类型[头像(avatar)|项目(project)|富文本(richText)|默认(default))]", example = "default") - private String biz; - - /** - * 文件hash值 - */ - @NotBlank(message = "文件hash值不能为空") - @Schema(description = "文件hash值", example = "3E8U2AM8") - private String hashValue; - - - @Serial - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/src/main/java/com/greenorange/promotion/model/dto/fileInfo/UploadFileRequest.java b/src/main/java/com/greenorange/promotion/model/dto/fileInfo/UploadFileRequest.java index 7cd7dea..3f4305f 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/fileInfo/UploadFileRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/fileInfo/UploadFileRequest.java @@ -1,6 +1,6 @@ package com.greenorange.promotion.model.dto.fileInfo; -import com.greenorange.promotion.annotation.FileEnumValue; +import com.greenorange.promotion.annotation.EnumValue; import com.greenorange.promotion.model.enums.FileUploadBizEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -15,7 +15,7 @@ public class UploadFileRequest implements Serializable { /** * 文件业务类型[头像(avatar)|项目(project)|富文本(richText)|默认(default))] */ - @FileEnumValue(enumClass = FileUploadBizEnum.class) + @EnumValue(enumClass = FileUploadBizEnum.class) @Schema(description = "文件业务类型[头像(avatar)|项目(project)|富文本(richText)|默认(default))]", example = "default") private String biz; diff --git a/src/main/java/com/greenorange/promotion/model/dto/project/ProjectAddRequest.java b/src/main/java/com/greenorange/promotion/model/dto/project/ProjectAddRequest.java index 9ac93d0..419fcc8 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/project/ProjectAddRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/project/ProjectAddRequest.java @@ -1,21 +1,14 @@ package com.greenorange.promotion.model.dto.project; -import com.greenorange.promotion.annotation.ProjectStatusEnumValue; -import com.greenorange.promotion.model.dto.projectDetail.ProjectDetailAddRequest; -import com.greenorange.promotion.model.dto.projectDetail.ProjectDetailUpdateRequest; -import com.greenorange.promotion.model.dto.projectNotification.ProjectNotificationAddRequest; -import com.greenorange.promotion.model.entity.ProjectNotification; +import com.greenorange.promotion.annotation.EnumValue; import com.greenorange.promotion.model.enums.ProjectStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotEmpty; import lombok.Data; import java.io.Serial; import java.io.Serializable; -import java.math.BigDecimal; -import java.util.List; /** * 项目添加请求体 @@ -66,7 +59,7 @@ public class ProjectAddRequest implements Serializable { /** * 项目状态[项目运行(running)|人数已满(full)|项目暂停(paused)] */ - @ProjectStatusEnumValue(enumClass = ProjectStatusEnum.class) + @EnumValue(enumClass = ProjectStatusEnum.class) @Schema(description = "项目状态[项目运行(running)|人数已满(full)|项目暂停(paused)]", example = "running") private String projectStatus; diff --git a/src/main/java/com/greenorange/promotion/model/dto/project/ProjectStatusUpdateRequest.java b/src/main/java/com/greenorange/promotion/model/dto/project/ProjectStatusUpdateRequest.java index 346c679..e6a2d20 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/project/ProjectStatusUpdateRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/project/ProjectStatusUpdateRequest.java @@ -1,6 +1,6 @@ package com.greenorange.promotion.model.dto.project; -import com.greenorange.promotion.annotation.ProjectStatusEnumValue; +import com.greenorange.promotion.annotation.EnumValue; import com.greenorange.promotion.model.enums.ProjectStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Min; @@ -27,7 +27,7 @@ public class ProjectStatusUpdateRequest implements Serializable { /** * 项目状态[项目运行(running)|人数已满(full)|项目暂停(paused)] */ - @ProjectStatusEnumValue(enumClass = ProjectStatusEnum.class) + @EnumValue(enumClass = ProjectStatusEnum.class) @Schema(description = "项目状态[项目运行(running)|人数已满(full)|项目暂停(paused)]", example = "running") private String projectStatus; diff --git a/src/main/java/com/greenorange/promotion/model/dto/project/ProjectUpdateRequest.java b/src/main/java/com/greenorange/promotion/model/dto/project/ProjectUpdateRequest.java index 1bc31dc..63663ed 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/project/ProjectUpdateRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/project/ProjectUpdateRequest.java @@ -2,6 +2,8 @@ package com.greenorange.promotion.model.dto.project; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; +import com.greenorange.promotion.annotation.EnumValue; +import com.greenorange.promotion.model.enums.ProjectStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.DecimalMin; import jakarta.validation.constraints.NotBlank; @@ -103,6 +105,7 @@ public class ProjectUpdateRequest implements Serializable { /** * 项目状态[项目运行(running)|人数已满(full)|项目暂停(paused)] */ + @EnumValue(enumClass = ProjectStatusEnum.class) @Schema(description = "项目状态[项目运行(running)|人数已满(full)|项目暂停(paused)]", example = "running") private String projectStatus; diff --git a/src/main/java/com/greenorange/promotion/model/dto/userInfo/UserInfoAddRequest.java b/src/main/java/com/greenorange/promotion/model/dto/userInfo/UserInfoAddRequest.java index 9cccc9a..20976ae 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/userInfo/UserInfoAddRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/userInfo/UserInfoAddRequest.java @@ -1,10 +1,7 @@ package com.greenorange.promotion.model.dto.userInfo; -import com.greenorange.promotion.annotation.UserEnumValue; -import com.greenorange.promotion.model.enums.UserRoleEnum; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; import lombok.Data; @@ -16,7 +13,7 @@ import java.io.Serializable; */ @Data @Schema(description = "用户添加请求体", requiredProperties = {"nickName", "userAvatar", "phoneNumber", - "userAccount", "userPassword", "userRole"}) + "userAccount", "userPassword"}) public class UserInfoAddRequest implements Serializable { /** diff --git a/src/main/java/com/greenorange/promotion/model/dto/userInfo/UserInfoUpdateRequest.java b/src/main/java/com/greenorange/promotion/model/dto/userInfo/UserInfoUpdateRequest.java index aa2f35f..00a1784 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/userInfo/UserInfoUpdateRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/userInfo/UserInfoUpdateRequest.java @@ -1,7 +1,5 @@ package com.greenorange.promotion.model.dto.userInfo; -import com.greenorange.promotion.annotation.UserEnumValue; -import com.greenorange.promotion.model.enums.UserRoleEnum; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; @@ -16,8 +14,8 @@ import java.io.Serializable; * 用户更新请求体 */ @Data -@Schema(description = "用户更新请求体", requiredProperties = {"id", "nickName", "userAvatar", "phoneNumber", - "userAccount", "userPassword", "userRole"}) +@Schema(description = "用户更新请求体", requiredProperties = {"id", "nickName", "userAvatar", + "userAccount", "userPassword"}) public class UserInfoUpdateRequest implements Serializable { /** @@ -42,13 +40,6 @@ public class UserInfoUpdateRequest implements Serializable { @Schema(description = "用户头像URL", example = "3E8U2AM8") private String userAvatar; - /** - * 手机号 - */ - @NotBlank(message = "手机号不能为空") - @Schema(description = "手机号", example = "15888610253") - private String phoneNumber; - /** * 账号 */ @@ -65,25 +56,6 @@ public class UserInfoUpdateRequest implements Serializable { @Schema(description = "密码(建议加密存储)", example = "qingcheng") private String userPassword; - /** - * 邀请码 - */ - @Schema(description = "邀请码", example = "666999") - private String invitationCode; - - /** - * 用户角色 - */ - @UserEnumValue(enumClass = UserRoleEnum.class) - @Schema(description = "用户角色", example = "user") - private String userRole; - - /** - * 上级用户id - */ - @Schema(description = "上级用户id", example = "1") - private Long parentUserId; - @Serial private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyAddRequest.java b/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyAddRequest.java index 7a69750..5ba9358 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyAddRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyAddRequest.java @@ -1,10 +1,6 @@ package com.greenorange.promotion.model.dto.withdrawalApply; -import com.greenorange.promotion.annotation.WithdrawStatusEnumValue; -import com.greenorange.promotion.model.enums.WithdrawStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Min; import lombok.Data; import java.math.BigDecimal; @@ -16,9 +12,7 @@ import java.io.Serializable; */ @Data @Schema(description = "提现申请记录添加请求体", requiredProperties = { - "withdrawnAmount", - "withdrawalStatus", - "userId", + "withdrawnAmount" }) public class WithdrawalApplyAddRequest implements Serializable { diff --git a/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyQueryRequest.java b/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyQueryRequest.java index d0287c0..3bc5c72 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyQueryRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyQueryRequest.java @@ -1,12 +1,9 @@ package com.greenorange.promotion.model.dto.withdrawalApply; -import com.greenorange.promotion.annotation.WithdrawStatusEnumValue; +import com.greenorange.promotion.annotation.EnumValue; import com.greenorange.promotion.model.enums.WithdrawStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Min; import lombok.Data; -import java.math.BigDecimal; import java.io.Serial; import java.io.Serializable; @@ -22,6 +19,7 @@ public class WithdrawalApplyQueryRequest extends PageRequest implements Serializ /** * 提现状态[提现中(processing)|提现成功(success)|提现失败(failed)] */ + @EnumValue(enumClass = WithdrawStatusEnum.class) @Schema(description = "提现状态[提现中(processing)|提现成功(success)|提现失败(failed)]", example = "processing") private String withdrawalStatus; diff --git a/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyUpdateRequest.java b/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyUpdateRequest.java index a1971d4..0c00663 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyUpdateRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/withdrawalApply/WithdrawalApplyUpdateRequest.java @@ -1,9 +1,8 @@ package com.greenorange.promotion.model.dto.withdrawalApply; -import com.greenorange.promotion.annotation.WithdrawStatusEnumValue; +import com.greenorange.promotion.annotation.EnumValue; import com.greenorange.promotion.model.enums.WithdrawStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Min; import lombok.Data; import java.math.BigDecimal; @@ -17,9 +16,7 @@ import java.io.Serializable; @Data @Schema(description = "提现申请记录更新请求体", requiredProperties = { "id", - "withdrawnAmount", - "withdrawalStatus", - "userId", + "withdrawalStatus" }) public class WithdrawalApplyUpdateRequest implements Serializable { @@ -30,26 +27,13 @@ public class WithdrawalApplyUpdateRequest implements Serializable { @Schema(description = "提现申请ID", example = "1") private Long id; - /** - * 提现金额 - */ - @Schema(description = "提现金额", example = "1.00") - private BigDecimal withdrawnAmount; - /** * 提现状态[提现中(processing)|提现成功(success)|提现失败(failed)] */ - @WithdrawStatusEnumValue(enumClass = WithdrawStatusEnum.class) + @EnumValue(enumClass = WithdrawStatusEnum.class) @Schema(description = "提现状态[提现中(processing)|提现成功(success)|提现失败(failed)]", example = "processing") private String withdrawalStatus; - /** - * 用户ID - */ - @Min(value = 1L, message = "用户ID ID不能小于1") - @Schema(description = "用户ID", example = "1") - private Long userId; - @Serial private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/greenorange/promotion/model/entity/Course.java b/src/main/java/com/greenorange/promotion/model/entity/Course.java index f7cea2a..60754a0 100644 --- a/src/main/java/com/greenorange/promotion/model/entity/Course.java +++ b/src/main/java/com/greenorange/promotion/model/entity/Course.java @@ -10,65 +10,65 @@ import java.util.Date; import lombok.Data; /** - * + * 课程表 * @TableName course */ @TableName(value ="course") @Data public class Course implements Serializable { /** - * + * 课程ID */ - @TableId + @TableId(type = IdType.AUTO) private Long id; /** - * + * 课程名称 */ private String name; /** - * + * 课程类别[考公考研,自媒体,财经] */ private String type; /** - * + * 课程概述(富文本) */ private String detail; /** - * + * 推广码说明(富文本) */ private String promoCodeDesc; /** - * + * 课程图片URL */ private String image; /** - * + * 课程原价 */ private BigDecimal originPrice; /** - * + * 折扣价格 */ private BigDecimal discountPrice; /** - * + * 已下单人数 */ private Integer orderCount; /** - * + * 一级佣金比例(%) */ private BigDecimal firstLevelRate; /** - * + * 二级佣金比例(%) */ private BigDecimal secondLevelRate; diff --git a/src/main/java/com/greenorange/promotion/model/entity/CourseChapter.java b/src/main/java/com/greenorange/promotion/model/entity/CourseChapter.java index 1ab633c..b7235c7 100644 --- a/src/main/java/com/greenorange/promotion/model/entity/CourseChapter.java +++ b/src/main/java/com/greenorange/promotion/model/entity/CourseChapter.java @@ -9,40 +9,40 @@ import java.util.Date; import lombok.Data; /** - * + * 课程章节表 * @TableName course_chapter */ @TableName(value ="course_chapter") @Data public class CourseChapter implements Serializable { /** - * + * 章节ID */ - @TableId + @TableId(type = IdType.AUTO) private Long id; /** - * + * 章节名称 */ private String name; /** - * + * 章节时长(格式可自定义,如"00:10:00") */ private String duration; /** - * + * 试看权限 */ private Object permissions; /** - * + * 视频文件 view 值 */ private String videoView; /** - * + * 所属课程ID */ private Long courseId; diff --git a/src/main/java/com/greenorange/promotion/model/entity/CourseOrder.java b/src/main/java/com/greenorange/promotion/model/entity/CourseOrder.java index 89c089d..b619e61 100644 --- a/src/main/java/com/greenorange/promotion/model/entity/CourseOrder.java +++ b/src/main/java/com/greenorange/promotion/model/entity/CourseOrder.java @@ -10,65 +10,65 @@ import java.util.Date; import lombok.Data; /** - * + * 课程订单表 * @TableName course_order */ @TableName(value ="course_order") @Data public class CourseOrder implements Serializable { /** - * + * 订单ID */ - @TableId + @TableId(type = IdType.AUTO) private Long id; /** - * + * 订单号 */ private String orderNumber; /** - * + * 课程ID */ private Long courseId; /** - * + * 课程名称 */ private String name; /** - * + * 课程类别 */ private String type; /** - * + * 课程封面图片URL */ private String image; /** - * + * 课程原价 */ private BigDecimal originPrice; /** - * + * 实际成交价格 */ private BigDecimal discountPrice; /** - * + * 订单总金额 */ private BigDecimal totalAmount; /** - * + * 支付交易号 */ private String transactionNumber; /** - * + * 订单状态 */ private Object orderStatus; diff --git a/src/main/java/com/greenorange/promotion/model/entity/PromoRecord.java b/src/main/java/com/greenorange/promotion/model/entity/PromoRecord.java index 148c2ac..340cacb 100644 --- a/src/main/java/com/greenorange/promotion/model/entity/PromoRecord.java +++ b/src/main/java/com/greenorange/promotion/model/entity/PromoRecord.java @@ -10,55 +10,55 @@ import java.util.Date; import lombok.Data; /** - * + * 推广记录表 * @TableName promo_record */ @TableName(value ="promo_record") @Data public class PromoRecord implements Serializable { /** - * + * 推广记录ID */ - @TableId + @TableId(type = IdType.AUTO) private Long id; /** - * + * 被推广课程ID */ private Long courseId; /** - * + * 下级用户ID */ private Long subUserId; /** - * + * 下级用户昵称 */ private String nickName; /** - * + * 下级用户手机号 */ private String phone; /** - * + * 下级带给上级的收益 */ private BigDecimal benefits; /** - * + * 绑定时间(字符串格式) */ private String bindTime; /** - * + * 推广类型 */ private Object promoType; /** - * + * 推广人(上级用户)ID */ private Long userId; diff --git a/src/main/java/com/greenorange/promotion/model/entity/RakeReward.java b/src/main/java/com/greenorange/promotion/model/entity/RakeReward.java index 62e89c9..54b957d 100644 --- a/src/main/java/com/greenorange/promotion/model/entity/RakeReward.java +++ b/src/main/java/com/greenorange/promotion/model/entity/RakeReward.java @@ -10,85 +10,85 @@ import java.util.Date; import lombok.Data; /** - * + * 课程抽成记录表 * @TableName rake_reward */ @TableName(value ="rake_reward") @Data public class RakeReward implements Serializable { /** - * + * 抽成记录ID */ - @TableId + @TableId(type = IdType.AUTO) private Long id; /** - * + * 课程ID */ private Long courseId; /** - * + * 课程名称 */ private String name; /** - * + * 课程类别 */ private String type; /** - * + * 课程图片URL */ private String image; /** - * + * 一级佣金比例(%) */ private BigDecimal firstLevelRate; /** - * + * 二级佣金比例(%) */ private BigDecimal secondLevelRate; /** - * + * 订单ID */ private Long orderId; /** - * + * 下单用户ID */ private Long userId; /** - * + * 下单用户昵称 */ private String nickName; /** - * + * 订单金额 */ private BigDecimal totalAmount; /** - * + * 订单创建日期 */ private Date orderCreateTime; /** - * + * 对应推广记录ID */ private Long promoId; /** - * + * 推广类型 */ private Object promoType; /** - * + * 抽成补贴金额 */ private BigDecimal reward; diff --git a/src/main/java/com/greenorange/promotion/model/enums/CourseTypeEnum.java b/src/main/java/com/greenorange/promotion/model/enums/CourseTypeEnum.java new file mode 100644 index 0000000..cd59af9 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/model/enums/CourseTypeEnum.java @@ -0,0 +1,58 @@ +package com.greenorange.promotion.model.enums; + +import com.greenorange.promotion.annotation.BaseEnum; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 课程类型枚举 + */ +@Getter +public enum CourseTypeEnum implements BaseEnum { + + KAOGONGKAOYAN("考公考研"), + ZIMEITI("自媒体"), + CAIJING("财经"); + + private final String value; + + CourseTypeEnum(String value) { + this.value = value; + } + + /** + * BaseEnum 要求的方法:返回枚举对应的校验值 + */ + @Override + public String getValue() { + return this.value; + } + + /** + * 获取所有枚举值列表 + */ + public static List getValues() { + return Arrays.stream(values()) + .map(CourseTypeEnum::getValue) + .collect(Collectors.toList()); + } + + /** + * 根据值获取对应的枚举对象 + */ + public static CourseTypeEnum getEnumByValue(String value) { + if (StringUtils.isBlank(value)) { + return null; + } + for (CourseTypeEnum type : CourseTypeEnum.values()) { + if (type.value.equals(value)) { + return type; + } + } + return null; + } +} diff --git a/src/main/java/com/greenorange/promotion/model/enums/FileUploadBizEnum.java b/src/main/java/com/greenorange/promotion/model/enums/FileUploadBizEnum.java index 027ba0f..fb17652 100644 --- a/src/main/java/com/greenorange/promotion/model/enums/FileUploadBizEnum.java +++ b/src/main/java/com/greenorange/promotion/model/enums/FileUploadBizEnum.java @@ -1,5 +1,6 @@ package com.greenorange.promotion.model.enums; +import com.greenorange.promotion.annotation.BaseEnum; import lombok.Getter; import org.apache.commons.lang3.StringUtils; @@ -11,7 +12,7 @@ import java.util.stream.Collectors; * 文件上传业务类型枚举 */ @Getter -public enum FileUploadBizEnum { +public enum FileUploadBizEnum implements BaseEnum { AVATAR("用户头像", "avatar"), PROJECT("项目", "project"), @@ -26,6 +27,14 @@ public enum FileUploadBizEnum { this.value = value; } + /** + * BaseEnum 要求的方法:返回这个枚举的“校验值” + */ + @Override + public String getValue() { + return this.value; + } + /** * 获取值列表 */ diff --git a/src/main/java/com/greenorange/promotion/model/enums/PreviewPermissionEnum.java b/src/main/java/com/greenorange/promotion/model/enums/PreviewPermissionEnum.java new file mode 100644 index 0000000..03a7933 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/model/enums/PreviewPermissionEnum.java @@ -0,0 +1,59 @@ +package com.greenorange.promotion.model.enums; + +import com.greenorange.promotion.annotation.BaseEnum; +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 试看权限枚举 + */ +@Getter +public enum PreviewPermissionEnum implements BaseEnum { + + FULL_VIEW("全集试看"), + PART_VIEW("部分试看"), + CLOSED("关闭"), + OPEN("开启"); + + private final String value; + + PreviewPermissionEnum(String value) { + this.value = value; + } + + /** + * BaseEnum 要求的方法:返回枚举对应的校验值 + */ + @Override + public String getValue() { + return this.value; + } + + /** + * 获取所有枚举值列表 + */ + public static List getValues() { + return Arrays.stream(values()) + .map(PreviewPermissionEnum::getValue) + .collect(Collectors.toList()); + } + + /** + * 根据值获取对应的枚举对象 + */ + public static PreviewPermissionEnum getEnumByValue(String value) { + if (StringUtils.isBlank(value)) { + return null; + } + for (PreviewPermissionEnum permission : PreviewPermissionEnum.values()) { + if (permission.value.equals(value)) { + return permission; + } + } + return null; + } +} diff --git a/src/main/java/com/greenorange/promotion/model/enums/ProjectStatusEnum.java b/src/main/java/com/greenorange/promotion/model/enums/ProjectStatusEnum.java index e74b991..5f127c3 100644 --- a/src/main/java/com/greenorange/promotion/model/enums/ProjectStatusEnum.java +++ b/src/main/java/com/greenorange/promotion/model/enums/ProjectStatusEnum.java @@ -1,5 +1,6 @@ package com.greenorange.promotion.model.enums; +import com.greenorange.promotion.annotation.BaseEnum; import lombok.Getter; import org.apache.commons.lang3.StringUtils; @@ -11,7 +12,7 @@ import java.util.stream.Collectors; * 项目状态枚举 */ @Getter -public enum ProjectStatusEnum { +public enum ProjectStatusEnum implements BaseEnum { RUNNING("项目运行", "running"), FULL("人数已满", "full"), @@ -25,6 +26,14 @@ public enum ProjectStatusEnum { this.value = value; } + /** + * BaseEnum 要求的方法:返回这个枚举的“校验值” + */ + @Override + public String getValue() { + return this.value; + } + /** * 获取值列表 */ diff --git a/src/main/java/com/greenorange/promotion/model/enums/UserRoleEnum.java b/src/main/java/com/greenorange/promotion/model/enums/UserRoleEnum.java index 2253036..9b58481 100644 --- a/src/main/java/com/greenorange/promotion/model/enums/UserRoleEnum.java +++ b/src/main/java/com/greenorange/promotion/model/enums/UserRoleEnum.java @@ -1,5 +1,6 @@ package com.greenorange.promotion.model.enums; +import com.greenorange.promotion.annotation.BaseEnum; import lombok.Getter; import org.apache.commons.lang3.StringUtils; @@ -12,7 +13,7 @@ import java.util.stream.Collectors; * 用户角色枚举 */ @Getter -public enum UserRoleEnum { +public enum UserRoleEnum implements BaseEnum { USER("用户", "user"), ADMIN("管理员", "admin"), @@ -29,6 +30,14 @@ public enum UserRoleEnum { this.value = value; } + /** + * BaseEnum 要求的方法:返回这个枚举的“校验值” + */ + @Override + public String getValue() { + return this.value; + } + /** * 获取值列表 */ diff --git a/src/main/java/com/greenorange/promotion/model/enums/WithdrawStatusEnum.java b/src/main/java/com/greenorange/promotion/model/enums/WithdrawStatusEnum.java index 13b34da..7fd1a09 100644 --- a/src/main/java/com/greenorange/promotion/model/enums/WithdrawStatusEnum.java +++ b/src/main/java/com/greenorange/promotion/model/enums/WithdrawStatusEnum.java @@ -1,5 +1,6 @@ package com.greenorange.promotion.model.enums; +import com.greenorange.promotion.annotation.BaseEnum; import lombok.Getter; import org.apache.commons.lang3.StringUtils; @@ -11,7 +12,7 @@ import java.util.stream.Collectors; * 提现状态枚举 */ @Getter -public enum WithdrawStatusEnum { +public enum WithdrawStatusEnum implements BaseEnum { PROCESSING("提现中", "processing"), SUCCESS("提现成功", "success"), @@ -26,6 +27,14 @@ public enum WithdrawStatusEnum { this.value = value; } + /** + * BaseEnum 要求的方法:返回这个枚举的“校验值” + */ + @Override + public String getValue() { + return this.value; + } + /** * 获取所有状态的值列表 */ diff --git a/src/main/java/com/greenorange/promotion/model/vo/course/CourseVO.java b/src/main/java/com/greenorange/promotion/model/vo/course/CourseVO.java new file mode 100644 index 0000000..31de0b2 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/model/vo/course/CourseVO.java @@ -0,0 +1,86 @@ +package com.greenorange.promotion.model.vo.course; + +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 = "课程 视图对象") +public class CourseVO implements Serializable { + + /** + * 课程ID + */ + @Schema(description = "课程ID", example = "1") + private Long id; + + /** + * 课程名称 + */ + @Schema(description = "课程名称", example = "数据分析工程师训练营") + private String name; + + /** + * 课程类别[考公考研,自媒体,财经] + */ + @Schema(description = "课程类别[考公考研,自媒体,财经]", example = "自媒体") + private String type; + + /** + * 课程概述(富文本) + */ + @Schema(description = "课程概述(富文本)", example = "富文本") + private String detail; + + /** + * 推广码说明(富文本) + */ + @Schema(description = "推广码说明(富文本)", example = "富文本") + private String promoCodeDesc; + + /** + * 课程图片URL + */ + @Schema(description = "课程图片URL", example = "324IEHJDE") + private String image; + + /** + * 课程原价 + */ + @Schema(description = "课程原价", example = "3499") + private BigDecimal originPrice; + + /** + * 折扣价格 + */ + @Schema(description = "折扣价格", example = "2499") + private BigDecimal discountPrice; + + /** + * 已下单人数 + */ + @Schema(description = "已下单人数", example = "100") + private Integer orderCount; + + /** + * 一级佣金比例(%) + */ + @Schema(description = "一级佣金比例(%)", example = "10") + private BigDecimal firstLevelRate; + + /** + * 二级佣金比例(%) + */ + @Schema(description = "二级佣金比例(%)", example = "5") + private BigDecimal secondLevelRate; + + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/greenorange/promotion/model/vo/courseChapter/CourseChapterVO.java b/src/main/java/com/greenorange/promotion/model/vo/courseChapter/CourseChapterVO.java new file mode 100644 index 0000000..6de0688 --- /dev/null +++ b/src/main/java/com/greenorange/promotion/model/vo/courseChapter/CourseChapterVO.java @@ -0,0 +1,58 @@ +package com.greenorange.promotion.model.vo.courseChapter; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 课程章节 视图对象 + */ +@Data +@Schema(description = "课程章节 视图对象") +public class CourseChapterVO implements Serializable { + + /** + * 课程章节ID + */ + @Schema(description = "课程章节ID", example = "1") + private Long id; + + /** + * 章节名称 + */ + @Schema(description = "章节名称", example = "企业经营管理者为什么必须懂财务?") + private String name; + + /** + * 章节时长(单位:秒) + */ + @Schema(description = "章节时长", example = "600") + private Long duration; + + /** + * 试看权限 + */ + @Schema(description = "试看权限", example = "全集试看") + private String permissions; + + /** + * 视频文件 view 值 + */ + @Schema(description = "视频文件 view 值", example = "3E29KDS9") + private String videoView; + + /** + * 所属课程ID + */ + @Schema(description = "所属课程ID", example = "所属课程ID ID不能小于1") + private Long courseId; + + + @Serial + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/greenorange/promotion/service/course/CourseChapterService.java b/src/main/java/com/greenorange/promotion/service/course/CourseChapterService.java index d4b52f0..502b7c4 100644 --- a/src/main/java/com/greenorange/promotion/service/course/CourseChapterService.java +++ b/src/main/java/com/greenorange/promotion/service/course/CourseChapterService.java @@ -1,13 +1,20 @@ package com.greenorange.promotion.service.course; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.greenorange.promotion.model.dto.courseChapter.CourseChapterQueryRequest; import com.greenorange.promotion.model.entity.CourseChapter; import com.baomidou.mybatisplus.extension.service.IService; /** * @author 35880 -* @description 针对表【course_chapter】的数据库操作Service -* @createDate 2025-06-23 18:07:34 +* @description 针对表【course_chapter(课程章节表)】的数据库操作Service +* @createDate 2025-06-23 18:30:28 */ public interface CourseChapterService extends IService { + + /** + * 获取查询条件 + */ + QueryWrapper getQueryWrapper(CourseChapterQueryRequest courseChapterQueryRequest); } diff --git a/src/main/java/com/greenorange/promotion/service/course/CourseOrderService.java b/src/main/java/com/greenorange/promotion/service/course/CourseOrderService.java index 2d89757..069ecc3 100644 --- a/src/main/java/com/greenorange/promotion/service/course/CourseOrderService.java +++ b/src/main/java/com/greenorange/promotion/service/course/CourseOrderService.java @@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService; /** * @author 35880 -* @description 针对表【course_order】的数据库操作Service -* @createDate 2025-06-23 18:08:14 +* @description 针对表【course_order(课程订单表)】的数据库操作Service +* @createDate 2025-06-23 18:31:13 */ public interface CourseOrderService extends IService { diff --git a/src/main/java/com/greenorange/promotion/service/course/CourseService.java b/src/main/java/com/greenorange/promotion/service/course/CourseService.java index 1aa39ec..9f15001 100644 --- a/src/main/java/com/greenorange/promotion/service/course/CourseService.java +++ b/src/main/java/com/greenorange/promotion/service/course/CourseService.java @@ -1,13 +1,20 @@ package com.greenorange.promotion.service.course; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.greenorange.promotion.model.dto.course.CourseQueryRequest; import com.greenorange.promotion.model.entity.Course; import com.baomidou.mybatisplus.extension.service.IService; /** * @author 35880 -* @description 针对表【course】的数据库操作Service -* @createDate 2025-06-23 17:06:12 +* @description 针对表【course(课程表)】的数据库操作Service +* @createDate 2025-06-23 18:29:49 */ public interface CourseService extends IService { + + /** + * 获取查询条件 + */ + QueryWrapper getQueryWrapper(CourseQueryRequest courseQueryRequest); } diff --git a/src/main/java/com/greenorange/promotion/service/course/PromoRecordService.java b/src/main/java/com/greenorange/promotion/service/course/PromoRecordService.java index 3c492c4..f41b0a4 100644 --- a/src/main/java/com/greenorange/promotion/service/course/PromoRecordService.java +++ b/src/main/java/com/greenorange/promotion/service/course/PromoRecordService.java @@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService; /** * @author 35880 -* @description 针对表【promo_record】的数据库操作Service -* @createDate 2025-06-23 18:09:37 +* @description 针对表【promo_record(推广记录表)】的数据库操作Service +* @createDate 2025-06-23 18:31:45 */ public interface PromoRecordService extends IService { diff --git a/src/main/java/com/greenorange/promotion/service/course/RakeRewardService.java b/src/main/java/com/greenorange/promotion/service/course/RakeRewardService.java index 3e1415b..ffa7e24 100644 --- a/src/main/java/com/greenorange/promotion/service/course/RakeRewardService.java +++ b/src/main/java/com/greenorange/promotion/service/course/RakeRewardService.java @@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService; /** * @author 35880 -* @description 针对表【rake_reward】的数据库操作Service -* @createDate 2025-06-23 18:09:57 +* @description 针对表【rake_reward(课程抽成记录表)】的数据库操作Service +* @createDate 2025-06-23 18:32:46 */ public interface RakeRewardService extends IService { diff --git a/src/main/java/com/greenorange/promotion/service/course/impl/CourseChapterServiceImpl.java b/src/main/java/com/greenorange/promotion/service/course/impl/CourseChapterServiceImpl.java index fec5bba..0906500 100644 --- a/src/main/java/com/greenorange/promotion/service/course/impl/CourseChapterServiceImpl.java +++ b/src/main/java/com/greenorange/promotion/service/course/impl/CourseChapterServiceImpl.java @@ -1,20 +1,40 @@ package com.greenorange.promotion.service.course.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.greenorange.promotion.constant.CommonConstant; +import com.greenorange.promotion.model.dto.courseChapter.CourseChapterQueryRequest; import com.greenorange.promotion.model.entity.CourseChapter; import com.greenorange.promotion.service.course.CourseChapterService; import com.greenorange.promotion.mapper.CourseChapterMapper; +import com.greenorange.promotion.utils.SqlUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; /** * @author 35880 -* @description 针对表【course_chapter】的数据库操作Service实现 -* @createDate 2025-06-23 18:07:34 +* @description 针对表【course_chapter(课程章节表)】的数据库操作Service实现 +* @createDate 2025-06-23 18:30:28 */ @Service public class CourseChapterServiceImpl extends ServiceImpl implements CourseChapterService{ + /** + * 获取查询条件 + */ + @Override + public QueryWrapper getQueryWrapper(CourseChapterQueryRequest courseChapterQueryRequest) { + String name = courseChapterQueryRequest.getName(); + String permissions = courseChapterQueryRequest.getPermissions(); + String sortField = courseChapterQueryRequest.getSortField(); + String sortOrder = courseChapterQueryRequest.getSortOrder(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(StringUtils.isNotBlank(name), "name", name); + queryWrapper.eq(StringUtils.isNotBlank(permissions), "permissions", permissions); + queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), sortField); + return queryWrapper; + } } diff --git a/src/main/java/com/greenorange/promotion/service/course/impl/CourseOrderServiceImpl.java b/src/main/java/com/greenorange/promotion/service/course/impl/CourseOrderServiceImpl.java index bcc7756..539070d 100644 --- a/src/main/java/com/greenorange/promotion/service/course/impl/CourseOrderServiceImpl.java +++ b/src/main/java/com/greenorange/promotion/service/course/impl/CourseOrderServiceImpl.java @@ -8,8 +8,8 @@ import org.springframework.stereotype.Service; /** * @author 35880 -* @description 针对表【course_order】的数据库操作Service实现 -* @createDate 2025-06-23 18:08:14 +* @description 针对表【course_order(课程订单表)】的数据库操作Service实现 +* @createDate 2025-06-23 18:31:13 */ @Service public class CourseOrderServiceImpl extends ServiceImpl diff --git a/src/main/java/com/greenorange/promotion/service/course/impl/CourseServiceImpl.java b/src/main/java/com/greenorange/promotion/service/course/impl/CourseServiceImpl.java index 2d2196c..d01bcbb 100644 --- a/src/main/java/com/greenorange/promotion/service/course/impl/CourseServiceImpl.java +++ b/src/main/java/com/greenorange/promotion/service/course/impl/CourseServiceImpl.java @@ -1,20 +1,41 @@ package com.greenorange.promotion.service.course.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.greenorange.promotion.constant.CommonConstant; +import com.greenorange.promotion.model.dto.course.CourseQueryRequest; import com.greenorange.promotion.model.entity.Course; import com.greenorange.promotion.service.course.CourseService; import com.greenorange.promotion.mapper.CourseMapper; +import com.greenorange.promotion.utils.SqlUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; /** * @author 35880 -* @description 针对表【course】的数据库操作Service实现 -* @createDate 2025-06-23 17:06:12 +* @description 针对表【course(课程表)】的数据库操作Service实现 +* @createDate 2025-06-23 18:29:49 */ @Service public class CourseServiceImpl extends ServiceImpl implements CourseService{ + + /** + * 获取查询条件 + */ + @Override + public QueryWrapper getQueryWrapper(CourseQueryRequest courseQueryRequest) { + String name = courseQueryRequest.getName(); + String type = courseQueryRequest.getType(); + String sortField = courseQueryRequest.getSortField(); + String sortOrder = courseQueryRequest.getSortOrder(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(StringUtils.isNotBlank(name), "name", name); + queryWrapper.eq(StringUtils.isNotBlank(type), "type", type); + queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), sortField); + return queryWrapper; + } } diff --git a/src/main/java/com/greenorange/promotion/service/course/impl/PromoRecordServiceImpl.java b/src/main/java/com/greenorange/promotion/service/course/impl/PromoRecordServiceImpl.java index f7a5c51..7687b40 100644 --- a/src/main/java/com/greenorange/promotion/service/course/impl/PromoRecordServiceImpl.java +++ b/src/main/java/com/greenorange/promotion/service/course/impl/PromoRecordServiceImpl.java @@ -8,8 +8,8 @@ import org.springframework.stereotype.Service; /** * @author 35880 -* @description 针对表【promo_record】的数据库操作Service实现 -* @createDate 2025-06-23 18:09:37 +* @description 针对表【promo_record(推广记录表)】的数据库操作Service实现 +* @createDate 2025-06-23 18:31:45 */ @Service public class PromoRecordServiceImpl extends ServiceImpl diff --git a/src/main/java/com/greenorange/promotion/service/course/impl/RakeRewardServiceImpl.java b/src/main/java/com/greenorange/promotion/service/course/impl/RakeRewardServiceImpl.java index 0146980..1dd9c64 100644 --- a/src/main/java/com/greenorange/promotion/service/course/impl/RakeRewardServiceImpl.java +++ b/src/main/java/com/greenorange/promotion/service/course/impl/RakeRewardServiceImpl.java @@ -8,8 +8,8 @@ import org.springframework.stereotype.Service; /** * @author 35880 -* @description 针对表【rake_reward】的数据库操作Service实现 -* @createDate 2025-06-23 18:09:57 +* @description 针对表【rake_reward(课程抽成记录表)】的数据库操作Service实现 +* @createDate 2025-06-23 18:32:46 */ @Service public class RakeRewardServiceImpl extends ServiceImpl diff --git a/src/main/java/com/greenorange/promotion/service/project/impl/ProjectServiceImpl.java b/src/main/java/com/greenorange/promotion/service/project/impl/ProjectServiceImpl.java index b6797d2..01d57a4 100644 --- a/src/main/java/com/greenorange/promotion/service/project/impl/ProjectServiceImpl.java +++ b/src/main/java/com/greenorange/promotion/service/project/impl/ProjectServiceImpl.java @@ -42,10 +42,6 @@ public class ProjectServiceImpl extends ServiceImpl private CommonService commonService; - @Resource - private ProjectService projectService; - - @Resource private ProjectCommissionService projectCommissionService; @@ -89,7 +85,7 @@ public class ProjectServiceImpl extends ServiceImpl } projectPriceMap.put(projectId, projectPrice); } - List projectList = commonService.findByFieldEqTargetField(Project::getIsShelves, 1, projectService); + List projectList = commonService.findByFieldEqTargetField(Project::getIsShelves, 1, this); for (Project project : projectList) { BigDecimal projectPrice = projectPriceMap.get(project.getId()); project.setProjectPrice(projectPrice == null ? BigDecimal.ZERO : projectPrice); @@ -104,7 +100,7 @@ public class ProjectServiceImpl extends ServiceImpl @Override public ProjectVO queryProjectById(CommonRequest commonRequest) { Long id = commonRequest.getId(); - Project project = projectService.getById(id); + Project project = this.getById(id); ThrowUtils.throwIf(project == null, ErrorCode.OPERATION_ERROR, "当前项目不存在"); return commonService.copyProperties(project, ProjectVO.class); }