Compare commits
12 Commits
7ca23bc987
...
dev
Author | SHA1 | Date | |
---|---|---|---|
e880431e07 | |||
1513ea51dc | |||
bbd063c4cd | |||
42aff09dae | |||
77c73355e2 | |||
3d8fd5591e | |||
ad6eb74170 | |||
1f7e1211cf | |||
502f079194 | |||
a0e60bece6 | |||
f871d61650 | |||
95d30cc5f6 |
7
pom.xml
7
pom.xml
@ -214,6 +214,13 @@
|
||||
<version>2.6.9</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-crypto</artifactId>
|
||||
<version>5.8.7</version> <!-- 换成你项目里使用的 Spring Security 版本 -->
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2,6 +2,8 @@ package com.greenorange.promotion.annotation;
|
||||
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@ -23,6 +25,6 @@ public class EnumValueValidator implements ConstraintValidator<EnumValue, String
|
||||
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext context) {
|
||||
return validValues.contains(value);
|
||||
return StringUtils.isBlank(value) || validValues.contains(value);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.greenorange.promotion.constant;
|
||||
|
||||
/**
|
||||
* 订单状态常量
|
||||
*/
|
||||
public interface OrderStatusConstant {
|
||||
|
||||
String CLOSED = "交易关闭";
|
||||
|
||||
String SUCCESS = "交易成功";
|
||||
|
||||
String PENDING = "待支付";
|
||||
|
||||
String REFUNDED = "已退款";
|
||||
|
||||
|
||||
}
|
@ -7,4 +7,10 @@ public interface SystemConstant {
|
||||
*/
|
||||
String VERIFICATION_CODE = "verificationCode";
|
||||
|
||||
|
||||
/**
|
||||
* 文件公共前缀
|
||||
*/
|
||||
String FILE_COMMON_PREFIX = "http://27.30.77.229:9091/file/download/";
|
||||
|
||||
}
|
||||
|
@ -121,15 +121,15 @@ public class CourseChapterController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Web端管理员分页查询课程章节
|
||||
* Web端管理员根据课程id分页查询课程章节
|
||||
* @param courseChapterQueryRequest 课程章节查询请求体
|
||||
* @return 课程章节列表
|
||||
*/
|
||||
@PostMapping("page")
|
||||
@Operation(summary = "Web端管理员分页查询课程章节", description = "参数:课程章节查询请求体,权限:管理员,方法名:listCourseChapterByPage")
|
||||
@Operation(summary = "Web端管理员根据课程id分页查询课程章节", description = "参数:课程章节查询请求体,权限:管理员,方法名:listCourseChapterByPageByCourseId")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "课程章节管理", content = "Web端管理员分页查询课程章节")
|
||||
public BaseResponse<Page<CourseChapterVO>> listCourseChapterByPage(@Valid @RequestBody CourseChapterQueryRequest courseChapterQueryRequest) {
|
||||
@SysLog(title = "课程章节管理", content = "Web端管理员根据课程id分页查询课程章节")
|
||||
public BaseResponse<Page<CourseChapterVO>> listCourseChapterByPageByCourseId(@Valid @RequestBody CourseChapterQueryRequest courseChapterQueryRequest) {
|
||||
long current = courseChapterQueryRequest.getCurrent();
|
||||
long pageSize = courseChapterQueryRequest.getPageSize();
|
||||
QueryWrapper<CourseChapter> queryWrapper = courseChapterService.getQueryWrapper(courseChapterQueryRequest);
|
||||
|
@ -1,29 +1,40 @@
|
||||
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.core.toolkit.support.SFunction;
|
||||
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.ErrorCode;
|
||||
import com.greenorange.promotion.common.ResultUtils;
|
||||
import com.greenorange.promotion.constant.UserConstant;
|
||||
import com.greenorange.promotion.exception.BusinessException;
|
||||
import com.greenorange.promotion.exception.ThrowUtils;
|
||||
import com.greenorange.promotion.model.dto.CommonBatchRequest;
|
||||
import com.greenorange.promotion.model.dto.CommonRequest;
|
||||
import com.greenorange.promotion.model.dto.CommonStringRequest;
|
||||
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.entity.CourseQrcodeApply;
|
||||
import com.greenorange.promotion.model.entity.ProjectCommission;
|
||||
import com.greenorange.promotion.model.vo.course.CourseCardVO;
|
||||
import com.greenorange.promotion.model.vo.course.CourseDetailVO;
|
||||
import com.greenorange.promotion.model.vo.course.CourseVO;
|
||||
import com.greenorange.promotion.model.vo.courseChapter.CourseChapterVO;
|
||||
import com.greenorange.promotion.service.common.CommonService;
|
||||
import com.greenorange.promotion.service.course.CourseChapterService;
|
||||
import com.greenorange.promotion.service.course.CourseQrcodeApplyService;
|
||||
import com.greenorange.promotion.service.course.CourseService;
|
||||
import com.greenorange.promotion.service.wechat.WechatGetQrcodeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -31,7 +42,10 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@ -52,6 +66,130 @@ public class CourseController {
|
||||
@Resource
|
||||
private CourseChapterService courseChapterService;
|
||||
|
||||
@Resource
|
||||
private WechatGetQrcodeService wechatGetQrcodeService;
|
||||
|
||||
@Resource
|
||||
private CourseQrcodeApplyService courseQrcodeApplyService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户查看热门课程列表
|
||||
* @return 课程信息列表
|
||||
*/
|
||||
@PostMapping("query/hot")
|
||||
@Operation(summary = "小程序端用户查看热门课程列表", description = "参数:无,权限:管理员,方法名:miniQueryHotCourseList")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@SysLog(title = "课程管理", content = "小程序端用户查看热门课程列表")
|
||||
public BaseResponse<List<CourseCardVO>> miniQueryHotCourseList() {
|
||||
List<Course> courseList = commonService.findByFieldEqTargetField(Course::getIsShelves, true, courseService);
|
||||
// 降序排序并取前四个元素
|
||||
courseList = courseList.stream()
|
||||
.sorted((course1, course2) -> Integer.compare(course2.getOrderCount(), course1.getOrderCount())) // 降序排序
|
||||
.limit(4) // 取前四个元素
|
||||
.collect(Collectors.toList());
|
||||
List<CourseCardVO> courseCardVOS = commonService.convertList(courseList, CourseCardVO.class);
|
||||
return ResultUtils.success(courseCardVOS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户根据类别查看课程列表
|
||||
* @param commonStringRequest 课程类别
|
||||
* @return 课程信息列表
|
||||
*/
|
||||
@PostMapping("query/type")
|
||||
@Operation(summary = "小程序端用户根据类别查看课程列表", description = "参数:课程添加请求体,权限:管理员,方法名:miniQueryCourseByType")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@SysLog(title = "课程管理", content = "小程序端用户根据类别查看课程列表")
|
||||
public BaseResponse<List<CourseCardVO>> miniQueryCourseByType(@Valid @RequestBody CommonStringRequest commonStringRequest) {
|
||||
String courseType = commonStringRequest.getTemplateString();
|
||||
Map<SFunction<Course, ?>, Object> fieldConditions = Map.of(Course::getType, courseType, Course::getIsShelves, true);
|
||||
List<Course> courseList = commonService.findByFieldEqTargetFields(fieldConditions, courseService);
|
||||
List<CourseCardVO> courseCardVOS = commonService.convertList(courseList, CourseCardVO.class);
|
||||
return ResultUtils.success(courseCardVOS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户根据id查询课程详情
|
||||
* @param commonRequest 课程id
|
||||
* @return 课程信息列表
|
||||
*/
|
||||
@PostMapping("query/id")
|
||||
@Operation(summary = "小程序端用户根据id查询课程详情", description = "参数:课程id,权限:管理员,方法名:miniQueryCourseById")
|
||||
@SysLog(title = "课程管理", content = "小程序端用户根据id查询课程详情")
|
||||
public BaseResponse<CourseDetailVO> miniQueryCourseById(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
Course course = courseService.getById(id);
|
||||
CourseDetailVO courseDetailVO = commonService.copyProperties(course, CourseDetailVO.class);
|
||||
LambdaQueryWrapper<CourseChapter> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(CourseChapter::getCourseId, id);
|
||||
List<CourseChapter> courseChapterList = courseChapterService.list(lambdaQueryWrapper);
|
||||
List<CourseChapterVO> courseChapterVOS = commonService.convertList(courseChapterList, CourseChapterVO.class);
|
||||
courseDetailVO.setCourseChapters(courseChapterVOS);
|
||||
return ResultUtils.success(courseDetailVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户生成课程推广码
|
||||
* @param commonRequest 课程id
|
||||
* @return 课程信息列表
|
||||
*/
|
||||
@PostMapping("generate/qrcode")
|
||||
@Operation(summary = "小程序端用户生成课程推广码", description = "参数:课程id,权限:管理员,方法名:miniGenerateQrcode")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@SysLog(title = "课程管理", content = "小程序端用户生成课程推广码")
|
||||
public BaseResponse<String> miniGenerateQrcode(@Valid @RequestBody CommonRequest commonRequest, HttpServletRequest request) throws Exception {
|
||||
String videoView = wechatGetQrcodeService.getWxCourseQrCode(commonRequest, request);
|
||||
return ResultUtils.success(videoView);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户根据id查看课程基本信息
|
||||
* @param commonRequest 课程id
|
||||
* @return 课程基本信息
|
||||
*/
|
||||
@PostMapping("detail/id")
|
||||
@Operation(summary = "小程序端用户根据id查看课程基本信息", description = "参数:课程id,权限:管理员,方法名:miniQueryCourseBaseInfo")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@SysLog(title = "课程管理", content = "小程序端用户根据id查看课程基本信息")
|
||||
public BaseResponse<CourseCardVO> miniQueryCourseBaseInfo(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
Course course = courseService.getById(id);
|
||||
CourseCardVO courseCardVO = commonService.copyProperties(course, CourseCardVO.class);
|
||||
return ResultUtils.success(courseCardVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户查看当前课程推广码
|
||||
* @param commonRequest 课程id
|
||||
* @return 课程推广码(view值)
|
||||
*/
|
||||
@PostMapping("verify")
|
||||
@Operation(summary = "小程序端用户查看当前课程推广码", description = "参数:课程id,权限:管理员,方法名:verifyIsApplyCourseQrcode")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@SysLog(title = "课程管理", content = "小程序端用户查看当前课程推广码")
|
||||
public BaseResponse<String> verifyIsApplyCourseQrcode(@Valid @RequestBody CommonRequest commonRequest, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
Long courseId = commonRequest.getId();
|
||||
LambdaQueryWrapper<CourseQrcodeApply> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(CourseQrcodeApply::getUserId, userId).eq(CourseQrcodeApply::getCourseId, courseId);
|
||||
CourseQrcodeApply courseQrcodeApply = courseQrcodeApplyService.getOne(lambdaQueryWrapper);
|
||||
ThrowUtils.throwIf(courseQrcodeApply == null, ErrorCode.OPERATION_ERROR, "当前用户尚未申请该课程的推广码");
|
||||
return ResultUtils.success(courseQrcodeApply.getCourseQrcode());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* web端管理员添加课程
|
||||
* @param courseAddRequest 课程添加请求体
|
||||
@ -62,6 +200,9 @@ public class CourseController {
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "课程管理", content = "web端管理员添加课程")
|
||||
public BaseResponse<Long> addCourse(@Valid @RequestBody CourseAddRequest courseAddRequest) {
|
||||
BigDecimal firstLevelRate = courseAddRequest.getFirstLevelRate();
|
||||
BigDecimal secondLevelRate = courseAddRequest.getSecondLevelRate();
|
||||
ThrowUtils.throwIf(firstLevelRate.compareTo(secondLevelRate) < 0, ErrorCode.PARAMS_ERROR, "一级佣金比例不能小于二级佣金比例");
|
||||
Course course = commonService.copyProperties(courseAddRequest, Course.class);
|
||||
courseService.save(course);
|
||||
return ResultUtils.success(course.getId());
|
||||
@ -73,7 +214,7 @@ public class CourseController {
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
@PostMapping("update")
|
||||
@Operation(summary = "web端管理员根据id修改课程", description = "参数:课程更新请求体,权限:管理员,方法名:updateCourse")
|
||||
@Operation(summary = "web端管理员根据id修改课程信息", description = "参数:课程更新请求体,权限:管理员,方法名:updateCourse")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "课程管理", content = "web端管理员根据id修改课程信息")
|
||||
public BaseResponse<Boolean> updateCourse(@Valid @RequestBody CourseUpdateRequest courseUpdateRequest) {
|
||||
@ -135,6 +276,25 @@ public class CourseController {
|
||||
return ResultUtils.success(courseVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* web端管理员上(下)架课程
|
||||
* @param commonRequest 课程id
|
||||
* @return 课程信息
|
||||
*/
|
||||
@PostMapping("isShelves")
|
||||
@Operation(summary = "web端管理员上(下)架课程", description = "参数:课程查询请求体,权限:管理员,方法名:updateCourseShelvesStatus")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "课程管理", content = "web端管理员上(下)架课程")
|
||||
public BaseResponse<Boolean> updateCourseShelvesStatus(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
Course course = courseService.getById(id);
|
||||
course.setIsShelves(!course.getIsShelves());
|
||||
courseService.updateById(course);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Web端管理员分页查询课程
|
||||
* @param courseQueryRequest 课程查询请求体
|
||||
|
@ -0,0 +1,218 @@
|
||||
package com.greenorange.promotion.controller.course;
|
||||
|
||||
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.ErrorCode;
|
||||
import com.greenorange.promotion.common.ResultUtils;
|
||||
import com.greenorange.promotion.constant.OrderStatusConstant;
|
||||
import com.greenorange.promotion.constant.UserConstant;
|
||||
import com.greenorange.promotion.exception.ThrowUtils;
|
||||
import com.greenorange.promotion.model.dto.CommonBatchRequest;
|
||||
import com.greenorange.promotion.model.dto.CommonRequest;
|
||||
import com.greenorange.promotion.model.dto.courseOrder.CourseOrderAddRequest;
|
||||
import com.greenorange.promotion.model.dto.courseOrder.CourseOrderQueryRequest;
|
||||
import com.greenorange.promotion.model.dto.courseOrder.CourseOrderUpdateRequest;
|
||||
import com.greenorange.promotion.model.entity.Course;
|
||||
import com.greenorange.promotion.model.entity.CourseOrder;
|
||||
import com.greenorange.promotion.model.vo.course.CourseCardVO;
|
||||
import com.greenorange.promotion.model.vo.courseOrder.CourseOrderCardVO;
|
||||
import com.greenorange.promotion.model.vo.courseOrder.CourseOrderVO;
|
||||
import com.greenorange.promotion.service.common.CommonService;
|
||||
import com.greenorange.promotion.service.course.CourseOrderService;
|
||||
import com.greenorange.promotion.service.course.CourseService;
|
||||
import com.greenorange.promotion.utils.OrderNumberUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
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.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 课程订单 控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("courseOrder")
|
||||
@Slf4j
|
||||
@Tag(name = "课程订单模块")
|
||||
public class CourseOrderController {
|
||||
|
||||
@Resource
|
||||
private CourseService courseService;
|
||||
|
||||
@Resource
|
||||
private CourseOrderService courseOrderService;
|
||||
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
|
||||
/**
|
||||
* 小程序端用户生成课程订单
|
||||
* @param courseOrderAddRequest 课程id
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
@PostMapping("add")
|
||||
@Operation(summary = "小程序端用户生成课程订单", description = "参数:课程id,权限:管理员,方法名:addCourseOrder")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@SysLog(title = "课程订单管理", content = "小程序端用户生成课程订单")
|
||||
public BaseResponse<Long> addCourseOrder(@Valid @RequestBody CourseOrderAddRequest courseOrderAddRequest, HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
Long courseId = courseOrderAddRequest.getCourseId();
|
||||
Course course = courseService.getById(courseId);
|
||||
ThrowUtils.throwIf(course == null, ErrorCode.OPERATION_ERROR, "该课程不存在");
|
||||
CourseOrder courseOrder = commonService.copyProperties(course, CourseOrder.class);
|
||||
courseOrder.setOrderNumber(OrderNumberUtils.generateOrderId());
|
||||
courseOrder.setTotalAmount(course.getDiscountPrice());
|
||||
courseOrder.setUserId(userId);
|
||||
courseOrderService.save(courseOrder);
|
||||
return ResultUtils.success(courseOrder.getId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户取消课程订单
|
||||
* @param courseOrderAddRequest 课程id
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
@PostMapping("cancel")
|
||||
@Operation(summary = "小程序端用户取消课程订单", description = "参数:订单id,权限:管理员,方法名:cancelCourseOrder")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@SysLog(title = "课程订单管理", content = "小程序端用户取消课程订单")
|
||||
public BaseResponse<Long> cancelCourseOrder(@Valid @RequestBody CourseOrderAddRequest courseOrderAddRequest) {
|
||||
Long courseId = courseOrderAddRequest.getCourseId();
|
||||
CourseOrder courseOrder = courseOrderService.getById(courseId);
|
||||
ThrowUtils.throwIf(courseOrder == null || !courseOrder.getOrderStatus().equals(OrderStatusConstant.PENDING),
|
||||
ErrorCode.OPERATION_ERROR, "该订单不存在或者订单状态错误");
|
||||
LambdaUpdateWrapper<CourseOrder> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(CourseOrder::getId, courseId).set(CourseOrder::getOrderStatus, OrderStatusConstant.CLOSED);
|
||||
courseOrderService.update(updateWrapper);
|
||||
return ResultUtils.success(courseOrder.getId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户查询课程订单列表
|
||||
* @return 课程订单列表
|
||||
*/
|
||||
@PostMapping("query/list")
|
||||
@Operation(summary = "小程序端用户查询课程订单列表", description = "参数:无,权限:管理员,方法名:queryCourseOrderList")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@SysLog(title = "课程订单管理", content = "小程序端用户查询课程订单列表")
|
||||
public BaseResponse<List<CourseOrderCardVO>> queryCourseOrderList(HttpServletRequest request) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
List<CourseOrder> courseOrderList = commonService.findByFieldEqTargetField(CourseOrder::getUserId, userId, courseOrderService);
|
||||
List<CourseOrderCardVO> courseOrderCardVOS = commonService.convertList(courseOrderList, CourseOrderCardVO.class);
|
||||
Collections.reverse(courseOrderCardVOS);
|
||||
return ResultUtils.success(courseOrderCardVOS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户根据id查询订单详情
|
||||
* @return 课程订单列表
|
||||
*/
|
||||
@PostMapping("query/detail")
|
||||
@Operation(summary = "小程序端用户根据id查询订单详情", description = "参数:订单id,权限:管理员,方法名:queryCourseOrderDetailById")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@SysLog(title = "课程订单管理", content = "小程序端用户根据id查询订单详情")
|
||||
public BaseResponse<CourseOrderVO> queryCourseOrderDetailById(@RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
CourseOrder courseOrder = courseOrderService.getById(id);
|
||||
CourseOrderVO courseOrderVO = commonService.copyProperties(courseOrder, CourseOrderVO.class);
|
||||
return ResultUtils.success(courseOrderVO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* web端管理员根据id删除课程订单
|
||||
* @param commonRequest 课程订单删除请求体
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
@Operation(summary = "web端管理员根据id删除课程订单", description = "参数:课程订单删除请求体,权限:管理员,方法名:delCourseOrder")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "课程订单管理", content = "web端管理员根据id删除课程订单")
|
||||
public BaseResponse<Boolean> delCourseOrder(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
CourseOrder courseOrder = courseOrderService.getById(id);
|
||||
ThrowUtils.throwIf(courseOrder == null || !courseOrder.getOrderStatus().equals(OrderStatusConstant.CLOSED),
|
||||
ErrorCode.OPERATION_ERROR, "该课程订单不存在或订单状态错误");
|
||||
courseOrderService.removeById(id);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员批量删除课程订单
|
||||
* @param commonBatchRequest 课程订单批量删除请求体
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@PostMapping("delBatch")
|
||||
@Operation(summary = "web端管理员批量删除课程订单", description = "参数:课程订单批量删除请求体,权限:管理员,方法名:delBatchCourseOrder")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "课程订单管理", content = "web端管理员批量删除课程订单")
|
||||
public BaseResponse<Boolean> delBatchCourseOrder(@Valid @RequestBody CommonBatchRequest commonBatchRequest) {
|
||||
List<Long> ids = commonBatchRequest.getIds();
|
||||
LambdaQueryWrapper<CourseOrder> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.ne(CourseOrder::getOrderStatus, OrderStatusConstant.CLOSED);
|
||||
long count = courseOrderService.count(queryWrapper);
|
||||
ThrowUtils.throwIf(count > 0, ErrorCode.OPERATION_ERROR, "存在未关闭的课程订单");
|
||||
courseOrderService.removeByIds(ids);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员根据id查询课程订单
|
||||
* @param commonRequest 课程订单查询请求体
|
||||
* @return 课程订单信息
|
||||
*/
|
||||
@PostMapping("queryById")
|
||||
@Operation(summary = "web端管理员根据id查询课程订单", description = "参数:课程订单查询请求体,权限:管理员,方法名:queryCourseOrderById")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "课程订单管理", content = "web端管理员根据id查询课程订单")
|
||||
public BaseResponse<CourseOrderVO> queryCourseOrderById(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
CourseOrder courseOrder = courseOrderService.getById(id);
|
||||
CourseOrderVO courseOrderVO = commonService.copyProperties(courseOrder, CourseOrderVO.class);
|
||||
return ResultUtils.success(courseOrderVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Web端管理员分页查询课程订单
|
||||
* @param courseOrderQueryRequest 课程订单查询请求体
|
||||
* @return 课程订单列表
|
||||
*/
|
||||
@PostMapping("page")
|
||||
@Operation(summary = "Web端管理员分页查询课程订单", description = "参数:课程订单查询请求体,权限:管理员,方法名:listCourseOrderByPage")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "课程订单管理", content = "Web端管理员分页查询课程订单")
|
||||
public BaseResponse<Page<CourseOrderVO>> listCourseOrderByPage(@Valid @RequestBody CourseOrderQueryRequest courseOrderQueryRequest) {
|
||||
long current = courseOrderQueryRequest.getCurrent();
|
||||
long pageSize = courseOrderQueryRequest.getPageSize();
|
||||
QueryWrapper<CourseOrder> queryWrapper = courseOrderService.getQueryWrapper(courseOrderQueryRequest);
|
||||
Page<CourseOrder> page = courseOrderService.page(new Page<>(current, pageSize), queryWrapper);
|
||||
List<CourseOrder> courseOrderList = page.getRecords();
|
||||
List<CourseOrderVO> courseOrderVOList = commonService.convertList(courseOrderList, CourseOrderVO.class);
|
||||
Page<CourseOrderVO> voPage = new Page<>(current, pageSize);
|
||||
voPage.setRecords(courseOrderVOList);
|
||||
voPage.setPages(page.getPages());
|
||||
voPage.setTotal(page.getTotal());
|
||||
return ResultUtils.success(voPage);
|
||||
}
|
||||
}
|
@ -33,8 +33,11 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.lang.reflect.GenericDeclaration;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
@ -138,6 +141,16 @@ public class ProjectCommissionController {
|
||||
return ResultUtils.success(projectCommissionVOList);
|
||||
}
|
||||
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
// String encode = passwordEncoder.encode("123456");
|
||||
// System.out.println(encode);
|
||||
// boolean matches = passwordEncoder.matches("123456", "$2a$10$/yBGQqsHK78vlEtuMGTVY.bU/TamHQbr4wQIzj1B1H1ud/ZKPGICC");
|
||||
// System.out.println(matches);
|
||||
// }
|
||||
|
||||
|
||||
//
|
||||
// /**
|
||||
// * 小程序用户修改项目的抽佣比例
|
||||
|
@ -1,19 +1,12 @@
|
||||
package com.greenorange.promotion.controller.wechat;
|
||||
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.freewayso.image.combiner.ImageCombiner;
|
||||
import com.freewayso.image.combiner.enums.OutputFormat;
|
||||
import com.greenorange.promotion.annotation.RequiresPermission;
|
||||
import com.greenorange.promotion.common.BaseResponse;
|
||||
import com.greenorange.promotion.common.ErrorCode;
|
||||
import com.greenorange.promotion.common.ResultUtils;
|
||||
import com.greenorange.promotion.config.WxAccessToken;
|
||||
import com.greenorange.promotion.constant.UserConstant;
|
||||
import com.greenorange.promotion.model.dto.CommonRequest;
|
||||
import com.greenorange.promotion.model.dto.CommonStringRequest;
|
||||
import com.greenorange.promotion.service.wechat.WechatGetQrcodeService;
|
||||
import com.greenorange.promotion.utils.QRCodeUtil;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -21,21 +14,10 @@ import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@ -72,7 +54,7 @@ public class WechatGetQrcodeController {
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
// @Hidden
|
||||
@Hidden
|
||||
@PostMapping("/get/qrcode")
|
||||
@Operation(summary = "微信小程序获取二维码", description = "参数:无, 权限:所有人, 方法名:getQrcode")
|
||||
// @RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@ -88,13 +70,12 @@ public class WechatGetQrcodeController {
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
// @Hidden
|
||||
@Hidden
|
||||
@PostMapping("/get/course/qrcode")
|
||||
@Operation(summary = "微信小程序获取课程码", description = "参数:无, 权限:所有人, 方法名:getCourseQrcode")
|
||||
// @RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
public BaseResponse<String> getCourseQrcode(@Valid @RequestBody CommonStringRequest commonStringRequest) throws Exception {
|
||||
String inviteCode = commonStringRequest.getTemplateString();
|
||||
String view = wechatGetQrcodeService.getWxCourseQrCode(inviteCode);
|
||||
public BaseResponse<String> getCourseQrcode(@Valid @RequestBody CommonRequest commonRequest, HttpServletRequest request) throws Exception {
|
||||
String view = wechatGetQrcodeService.getWxCourseQrCode(commonRequest, request);
|
||||
return ResultUtils.success(view);
|
||||
}
|
||||
|
||||
|
@ -61,18 +61,14 @@ public class GlobalExceptionHandler {
|
||||
// .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);
|
||||
// 按字段名排序,取第一个错误的 defaultMessage
|
||||
String msg = e.getBindingResult()
|
||||
.getFieldErrors().stream()
|
||||
.sorted(Comparator.comparing(FieldError::getField))
|
||||
.map(FieldError::getDefaultMessage)
|
||||
.findFirst()
|
||||
.orElse("参数校验失败");
|
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR, msg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 = "CourseChapter";
|
||||
private static final String ENTITY_NAME = "CourseOrder";
|
||||
// 表名
|
||||
private static final String TABLE_NAME = "course_chapter";
|
||||
private static final String TABLE_NAME = "course_order";
|
||||
// 实体类属性名
|
||||
private static final String ENTITY_NAME_LOWER = "courseChapter";
|
||||
private static final String ENTITY_NAME_LOWER = "courseOrder";
|
||||
|
||||
// 父包名
|
||||
private static final String PARENT_PATH = "com.greenorange.promotion";
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.greenorange.promotion.mapper;
|
||||
|
||||
import com.greenorange.promotion.model.entity.CourseQrcodeApply;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 35880
|
||||
* @description 针对表【course_qrcode_apply(课程推广码申请表)】的数据库操作Mapper
|
||||
* @createDate 2025-06-24 22:10:39
|
||||
* @Entity com.greenorange.promotion.model.entity.CourseQrcodeApply
|
||||
*/
|
||||
public interface CourseQrcodeApplyMapper extends BaseMapper<CourseQrcodeApply> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -5,6 +5,8 @@ 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 jakarta.validation.constraints.NotNull;
|
||||
import jdk.jfr.BooleanFlag;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ -22,19 +24,24 @@ 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;
|
||||
|
||||
|
||||
/**
|
||||
* 是否上架(true:上架,false:下架)
|
||||
*/
|
||||
@Schema(description = "是否上架(true:上架,false:下架)", example = "true")
|
||||
private Boolean isShelves;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
@ -39,11 +39,11 @@ public class CourseChapterAddRequest implements Serializable {
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
* 试看权限
|
||||
* 试看权限[全集试看,部分试看,关闭,开启]
|
||||
*/
|
||||
@NotBlank(message = "试看权限不能为空")
|
||||
@EnumValue(enumClass = PreviewPermissionEnum.class)
|
||||
@Schema(description = "试看权限", example = "全集试看")
|
||||
@Schema(description = "试看权限[全集试看,部分试看,关闭,开启]", example = "全集试看")
|
||||
private String permissions;
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@ 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 jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ -22,18 +23,24 @@ public class CourseChapterQueryRequest extends PageRequest implements Serializab
|
||||
/**
|
||||
* 章节名称
|
||||
*/
|
||||
@NotBlank(message = "章节名称不能为空")
|
||||
@Schema(description = "章节名称", example = "企业经营管理者为什么必须懂财务?")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 试看权限
|
||||
* 试看权限[全集试看,部分试看,关闭,开启]
|
||||
*/
|
||||
@NotBlank(message = "试看权限不能为空")
|
||||
@EnumValue(enumClass = PreviewPermissionEnum.class)
|
||||
@Schema(description = "试看权限", example = "全集试看")
|
||||
@Schema(description = "试看权限[全集试看,部分试看,关闭,开启]", example = "全集试看")
|
||||
private String permissions;
|
||||
|
||||
/**
|
||||
* 课程id
|
||||
*/
|
||||
@NotNull(message = "课程id不能为null")
|
||||
@Min(value = 1, message = "课程id不能小于1")
|
||||
@Schema(description = "课程id", example = "1")
|
||||
private Long courseId;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -47,11 +47,11 @@ public class CourseChapterUpdateRequest implements Serializable {
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
* 试看权限
|
||||
* 试看权限[全集试看,部分试看,关闭,开启]
|
||||
*/
|
||||
@NotBlank(message = "试看权限不能为空")
|
||||
@EnumValue(enumClass = PreviewPermissionEnum.class)
|
||||
@Schema(description = "试看权限", example = "全集试看")
|
||||
@Schema(description = "试看权限[全集试看,部分试看,关闭,开启]", example = "全集试看")
|
||||
private String permissions;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,92 @@
|
||||
package com.greenorange.promotion.model.dto.courseOrder;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 课程订单添加请求体
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "课程订单添加请求体", requiredProperties = {
|
||||
"courseId"
|
||||
})
|
||||
public class CourseOrderAddRequest implements Serializable {
|
||||
|
||||
// /**
|
||||
// * 订单号
|
||||
// */
|
||||
// @NotBlank(message = "订单号不能为空")
|
||||
// @Schema(description = "订单号", example = "202506241339232334d234234243")
|
||||
// private String orderNumber;
|
||||
|
||||
/**
|
||||
* 课程ID
|
||||
*/
|
||||
@Min(value = 1L, message = "课程ID ID不能小于1")
|
||||
@Schema(description = "课程ID", example = "1")
|
||||
private Long courseId;
|
||||
|
||||
// /**
|
||||
// * 课程名称
|
||||
// */
|
||||
// @NotBlank(message = "课程名称不能为空")
|
||||
// @Schema(description = "课程名称", example = "数据分析工程师训练营")
|
||||
// private String name;
|
||||
//
|
||||
// /**
|
||||
// * 课程类别
|
||||
// */
|
||||
// @NotBlank(message = "课程类别不能为空")
|
||||
// @Schema(description = "课程类别", example = "自媒体")
|
||||
// private String type;
|
||||
//
|
||||
// /**
|
||||
// * 课程封面图片URL
|
||||
// */
|
||||
// @NotBlank(message = "课程封面图片URL不能为空")
|
||||
// @Schema(description = "课程封面图片URL", example = "38EFJID33")
|
||||
// private String image;
|
||||
//
|
||||
// /**
|
||||
// * 课程原价
|
||||
// */
|
||||
// @Schema(description = "课程原价", example = "20.00")
|
||||
// private BigDecimal originPrice;
|
||||
//
|
||||
// /**
|
||||
// * 折扣价格
|
||||
// */
|
||||
// @Schema(description = "折扣价格", example = "80.00")
|
||||
// private BigDecimal discountPrice;
|
||||
//
|
||||
// /**
|
||||
// * 订单总金额
|
||||
// */
|
||||
// @Schema(description = "订单总金额", example = "80.00")
|
||||
// private BigDecimal totalAmount;
|
||||
//
|
||||
// /**
|
||||
// * 支付交易号
|
||||
// */
|
||||
// @NotBlank(message = "支付交易号不能为空")
|
||||
// @Schema(description = "支付交易号", example = "432332333324444444444444423")
|
||||
// private String transactionNumber;
|
||||
//
|
||||
// /**
|
||||
// * 订单状态
|
||||
// */
|
||||
// @NotBlank(message = "订单状态不能为空")
|
||||
//// @EnumValue(enumClass = CourseOrderStatusEnum.class)
|
||||
// @Schema(description = "订单状态", example = "order")
|
||||
// private String orderStatus;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.greenorange.promotion.model.dto.courseOrder;
|
||||
|
||||
import com.greenorange.promotion.annotation.EnumValue;
|
||||
import com.greenorange.promotion.model.enums.OrderStatusEnum;
|
||||
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;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 课程订单查询请求体,继承自分页请求 PageRequest
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "课程订单查询请求体", requiredProperties = {"current", "pageSize"})
|
||||
public class CourseOrderQueryRequest extends PageRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Schema(description = "订单号", example = "202506241339232334d234234243")
|
||||
private String orderNumber;
|
||||
|
||||
|
||||
/**
|
||||
* 订单状态[交易关闭,交易成功,待支付,已退款]
|
||||
*/
|
||||
@EnumValue(enumClass = OrderStatusEnum.class)
|
||||
@Schema(description = "订单状态[交易关闭,交易成功,待支付,已退款]", example = "交易成功")
|
||||
private String orderStatus;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
package com.greenorange.promotion.model.dto.courseOrder;
|
||||
|
||||
import com.greenorange.promotion.annotation.EnumValue;
|
||||
import com.greenorange.promotion.model.enums.OrderStatusEnum;
|
||||
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",
|
||||
"orderStatus"
|
||||
})
|
||||
public class CourseOrderUpdateRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* 订单ID
|
||||
*/
|
||||
@Min(value = 1L, message = "订单ID ID不能小于1")
|
||||
@Schema(description = "订单ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
|
||||
/**
|
||||
* 订单状态[交易关闭,交易成功,待支付,已退款]
|
||||
*/
|
||||
@NotBlank(message = "订单状态不能为空")
|
||||
@EnumValue(enumClass = OrderStatusEnum.class)
|
||||
@Schema(description = "订单状态[交易关闭,交易成功,待支付,已退款]", example = "交易成功")
|
||||
private String orderStatus;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -59,6 +59,7 @@ public class ProjectAddRequest implements Serializable {
|
||||
/**
|
||||
* 项目状态[项目运行(running)|人数已满(full)|项目暂停(paused)]
|
||||
*/
|
||||
@NotBlank(message = "项目状态不能为空")
|
||||
@EnumValue(enumClass = ProjectStatusEnum.class)
|
||||
@Schema(description = "项目状态[项目运行(running)|人数已满(full)|项目暂停(paused)]", example = "running")
|
||||
private String projectStatus;
|
||||
|
@ -42,6 +42,7 @@ public class UserInfoRegisterRequest implements Serializable {
|
||||
* 邀请码
|
||||
*/
|
||||
@Schema(description = "邀请码", example = "666999")
|
||||
@NotBlank(message = "邀请码不能为空")
|
||||
private String invitationCode;
|
||||
|
||||
/**
|
||||
|
@ -72,6 +72,11 @@ public class Course implements Serializable {
|
||||
*/
|
||||
private BigDecimal secondLevelRate;
|
||||
|
||||
/**
|
||||
* 是否上架(true:上架,false:下架)
|
||||
*/
|
||||
private Boolean isShelves;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
@ -29,12 +31,12 @@ public class CourseChapter implements Serializable {
|
||||
/**
|
||||
* 章节时长(格式可自定义,如"00:10:00")
|
||||
*/
|
||||
private String duration;
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
* 试看权限
|
||||
* 试看权限[全集试看,部分试看,关闭,开启]
|
||||
*/
|
||||
private Object permissions;
|
||||
private String permissions;
|
||||
|
||||
/**
|
||||
* 视频文件 view 值
|
||||
@ -61,6 +63,7 @@ public class CourseChapter implements Serializable {
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@Serial
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
@ -53,7 +55,7 @@ public class CourseOrder implements Serializable {
|
||||
private BigDecimal originPrice;
|
||||
|
||||
/**
|
||||
* 实际成交价格
|
||||
* 折扣价格
|
||||
*/
|
||||
private BigDecimal discountPrice;
|
||||
|
||||
@ -68,9 +70,14 @@ public class CourseOrder implements Serializable {
|
||||
private String transactionNumber;
|
||||
|
||||
/**
|
||||
* 订单状态
|
||||
* 订单状态[交易关闭,交易成功,待支付,已退款]
|
||||
*/
|
||||
private Object orderStatus;
|
||||
private String orderStatus;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
@ -87,6 +94,7 @@ public class CourseOrder implements Serializable {
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@Serial
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.greenorange.promotion.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 课程推广码申请表
|
||||
* @TableName course_qrcode_apply
|
||||
*/
|
||||
@TableName(value ="course_qrcode_apply")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class CourseQrcodeApply implements Serializable {
|
||||
/**
|
||||
* 课程推广码申请id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 课程id
|
||||
*/
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程推广码(view值)
|
||||
*/
|
||||
private String courseQrcode;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Integer isDelete;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -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 OrderStatusEnum implements BaseEnum {
|
||||
|
||||
CLOSED("交易关闭"),
|
||||
SUCCESS("交易成功"),
|
||||
PENDING("待支付"),
|
||||
REFUNDED("已退款");
|
||||
|
||||
private final String value;
|
||||
|
||||
OrderStatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* BaseEnum 要求的方法:返回枚举对应的校验值
|
||||
*/
|
||||
@Override
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有枚举值列表
|
||||
*/
|
||||
public static List<String> getValues() {
|
||||
return Arrays.stream(values())
|
||||
.map(OrderStatusEnum::getValue)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据值获取对应的枚举对象
|
||||
*/
|
||||
public static OrderStatusEnum getEnumByValue(String value) {
|
||||
if (StringUtils.isBlank(value)) {
|
||||
return null;
|
||||
}
|
||||
for (OrderStatusEnum status : OrderStatusEnum.values()) {
|
||||
if (status.value.equals(value)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
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 CourseCardVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 课程ID
|
||||
*/
|
||||
@Schema(description = "课程ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 课程名称
|
||||
*/
|
||||
@Schema(description = "课程名称", example = "数据分析工程师训练营")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 课程类别[考公考研,自媒体,财经]
|
||||
*/
|
||||
@Schema(description = "课程类别[考公考研,自媒体,财经]", example = "自媒体")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 课程图片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;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.greenorange.promotion.model.vo.course;
|
||||
|
||||
import com.greenorange.promotion.model.vo.courseChapter.CourseChapterVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@Schema(description = "课程详情 视图对象")
|
||||
public class CourseDetailVO 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 = "课程章节")
|
||||
private List<CourseChapterVO> courseChapters;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
@ -80,6 +80,12 @@ public class CourseVO implements Serializable {
|
||||
@Schema(description = "二级佣金比例(%)", example = "5")
|
||||
private BigDecimal secondLevelRate;
|
||||
|
||||
/**
|
||||
* 是否上架(true:上架,false:下架)
|
||||
*/
|
||||
@Schema(description = "是否上架(true:上架,false:下架)", example = "true")
|
||||
private Boolean isShelves;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -35,9 +35,9 @@ public class CourseChapterVO implements Serializable {
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
* 试看权限
|
||||
* 试看权限[全集试看,部分试看,关闭,开启]
|
||||
*/
|
||||
@Schema(description = "试看权限", example = "全集试看")
|
||||
@Schema(description = "试看权限[全集试看,部分试看,关闭,开启]", example = "全集试看")
|
||||
private String permissions;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,60 @@
|
||||
package com.greenorange.promotion.model.vo.courseOrder;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 课程订单卡片 视图对象
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "课程订单卡片 视图对象")
|
||||
public class CourseOrderCardVO implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 课程订单ID
|
||||
*/
|
||||
@Schema(description = "课程订单ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Schema(description = "订单号", example = "202506241339232334d234234243")
|
||||
private String orderNumber;
|
||||
|
||||
/**
|
||||
* 课程名称
|
||||
*/
|
||||
@Schema(description = "课程名称", example = "数据分析工程师训练营")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 课程类别
|
||||
*/
|
||||
@Schema(description = "课程类别", example = "自媒体")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 订单总金额
|
||||
*/
|
||||
@Schema(description = "订单总金额", example = "100.00")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 订单状态[交易关闭,交易成功,待支付,已退款]
|
||||
*/
|
||||
@Schema(description = "订单状态[交易关闭,交易成功,待支付,已退款]", example = "交易成功")
|
||||
private String orderStatus;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2025-06-24 13:39:23")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package com.greenorange.promotion.model.vo.courseOrder;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 课程订单 视图对象
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "课程订单 视图对象")
|
||||
public class CourseOrderVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 课程订单ID
|
||||
*/
|
||||
@Schema(description = "课程订单ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Schema(description = "订单号", example = "202506241339232334d234234243")
|
||||
private String orderNumber;
|
||||
|
||||
/**
|
||||
* 课程ID
|
||||
*/
|
||||
@Schema(description = "课程ID", example = "1")
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程名称
|
||||
*/
|
||||
@Schema(description = "课程名称", example = "数据分析工程师训练营")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 课程类别
|
||||
*/
|
||||
@Schema(description = "课程类别", example = "自媒体")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 课程封面图片URL
|
||||
*/
|
||||
@Schema(description = "课程封面图片URL", example = "32DHDF3KI")
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 课程原价
|
||||
*/
|
||||
@Schema(description = "课程原价", example = "100.00")
|
||||
private BigDecimal originPrice;
|
||||
|
||||
/**
|
||||
* 折扣价格
|
||||
*/
|
||||
@Schema(description = "折扣价格", example = "50.00")
|
||||
private BigDecimal discountPrice;
|
||||
|
||||
/**
|
||||
* 订单总金额
|
||||
*/
|
||||
@Schema(description = "订单总金额", example = "100.00")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 支付交易号
|
||||
*/
|
||||
@Schema(description = "支付交易号", example = "4342348232388888833333333333")
|
||||
private String transactionNumber;
|
||||
|
||||
/**
|
||||
* 订单状态[交易关闭,交易成功,待支付,已退款]
|
||||
*/
|
||||
@Schema(description = "订单状态[交易关闭,交易成功,待支付,已退款]", example = "交易成功")
|
||||
private String orderStatus;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@Schema(description = "用户id", example = "1")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间", example = "2025-06-24 13:39:23")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间", example = "2025-06-24 13:39:23")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.greenorange.promotion.service.course;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.greenorange.promotion.model.dto.courseOrder.CourseOrderQueryRequest;
|
||||
import com.greenorange.promotion.model.entity.CourseOrder;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@ -10,4 +12,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface CourseOrderService extends IService<CourseOrder> {
|
||||
|
||||
|
||||
/**
|
||||
* 获取查询条件
|
||||
*/
|
||||
QueryWrapper<CourseOrder> getQueryWrapper(CourseOrderQueryRequest courseOrderQueryRequest);
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.greenorange.promotion.service.course;
|
||||
|
||||
import com.greenorange.promotion.model.entity.CourseQrcodeApply;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author 35880
|
||||
* @description 针对表【course_qrcode_apply(课程推广码申请表)】的数据库操作Service
|
||||
* @createDate 2025-06-24 22:10:39
|
||||
*/
|
||||
public interface CourseQrcodeApplyService extends IService<CourseQrcodeApply> {
|
||||
|
||||
}
|
@ -25,11 +25,13 @@ public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, C
|
||||
*/
|
||||
@Override
|
||||
public QueryWrapper<CourseChapter> getQueryWrapper(CourseChapterQueryRequest courseChapterQueryRequest) {
|
||||
Long courseId = courseChapterQueryRequest.getCourseId();
|
||||
String name = courseChapterQueryRequest.getName();
|
||||
String permissions = courseChapterQueryRequest.getPermissions();
|
||||
String sortField = courseChapterQueryRequest.getSortField();
|
||||
String sortOrder = courseChapterQueryRequest.getSortOrder();
|
||||
QueryWrapper<CourseChapter> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("courseId", courseId);
|
||||
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);
|
||||
|
@ -1,9 +1,14 @@
|
||||
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.courseOrder.CourseOrderQueryRequest;
|
||||
import com.greenorange.promotion.model.entity.CourseOrder;
|
||||
import com.greenorange.promotion.service.course.CourseOrderService;
|
||||
import com.greenorange.promotion.mapper.CourseOrderMapper;
|
||||
import com.greenorange.promotion.utils.SqlUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@ -15,6 +20,22 @@ import org.springframework.stereotype.Service;
|
||||
public class CourseOrderServiceImpl extends ServiceImpl<CourseOrderMapper, CourseOrder>
|
||||
implements CourseOrderService{
|
||||
|
||||
|
||||
/**
|
||||
* 获取查询条件
|
||||
*/
|
||||
@Override
|
||||
public QueryWrapper<CourseOrder> getQueryWrapper(CourseOrderQueryRequest courseOrderQueryRequest) {
|
||||
String orderNumber = courseOrderQueryRequest.getOrderNumber();
|
||||
String orderStatus = courseOrderQueryRequest.getOrderStatus();
|
||||
String sortField = courseOrderQueryRequest.getSortField();
|
||||
String sortOrder = courseOrderQueryRequest.getSortOrder();
|
||||
QueryWrapper<CourseOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(StringUtils.isNotBlank(orderNumber), "orderNumber", orderNumber);
|
||||
queryWrapper.eq(StringUtils.isNotBlank(orderStatus), "orderStatus", orderStatus);
|
||||
queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), sortField);
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.greenorange.promotion.service.course.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.greenorange.promotion.model.entity.CourseQrcodeApply;
|
||||
import com.greenorange.promotion.service.course.CourseQrcodeApplyService;
|
||||
import com.greenorange.promotion.mapper.CourseQrcodeApplyMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author 35880
|
||||
* @description 针对表【course_qrcode_apply(课程推广码申请表)】的数据库操作Service实现
|
||||
* @createDate 2025-06-24 22:10:39
|
||||
*/
|
||||
@Service
|
||||
public class CourseQrcodeApplyServiceImpl extends ServiceImpl<CourseQrcodeApplyMapper, CourseQrcodeApply>
|
||||
implements CourseQrcodeApplyService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@ 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.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -28,11 +29,13 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course>
|
||||
public QueryWrapper<Course> getQueryWrapper(CourseQueryRequest courseQueryRequest) {
|
||||
String name = courseQueryRequest.getName();
|
||||
String type = courseQueryRequest.getType();
|
||||
Boolean isShelves = courseQueryRequest.getIsShelves();
|
||||
String sortField = courseQueryRequest.getSortField();
|
||||
String sortOrder = courseQueryRequest.getSortOrder();
|
||||
QueryWrapper<Course> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(StringUtils.isNotBlank(name), "name", name);
|
||||
queryWrapper.eq(StringUtils.isNotBlank(type), "type", type);
|
||||
queryWrapper.eq(ObjectUtils.isNotEmpty(isShelves), "isShelves", isShelves);
|
||||
queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), sortField);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class ProjectCommissionServiceImpl extends ServiceImpl<ProjectCommissionM
|
||||
public void updateProjectCommissionRate(ProjectCommissionUpdateRequest projectCommissionUpdateRequest) {
|
||||
Long id = projectCommissionUpdateRequest.getId();
|
||||
BigDecimal currentCommissionRate = projectCommissionUpdateRequest.getCurrentCommissionRate();
|
||||
// 获取当前项目明细信息
|
||||
// 获取当前项目明细抽佣信息
|
||||
ProjectCommission projectCommission = this.getById(id);
|
||||
ThrowUtils.throwIf(projectCommission == null, ErrorCode.OPERATION_ERROR, "项目明细抽佣信息不存在");
|
||||
Long projectDetailId = projectCommission.getProjectDetailId();
|
||||
@ -356,7 +356,7 @@ public class ProjectCommissionServiceImpl extends ServiceImpl<ProjectCommissionM
|
||||
|
||||
startTime = System.currentTimeMillis();
|
||||
|
||||
// 更新用户项目明细抽佣记录
|
||||
// 批量更新用户项目明细抽佣记录
|
||||
List<SubUserProjectCommission> proCommissions = subProjectCommissions.stream().filter(subProjectCommission -> subProjectCommission.getSubUserId() == -1L).toList();
|
||||
List<ProjectCommission> proCommissionList = commonService.convertList(proCommissions, ProjectCommission.class);
|
||||
// this.updateBatchById(proCommissionList);
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.greenorange.promotion.service.wechat;
|
||||
|
||||
import com.greenorange.promotion.config.WxAccessToken;
|
||||
import com.greenorange.promotion.model.dto.CommonRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@ -27,5 +29,5 @@ public interface WechatGetQrcodeService {
|
||||
/**
|
||||
* 微信小程序获取课程码
|
||||
*/
|
||||
String getWxCourseQrCode(String inviteCode) throws Exception;
|
||||
String getWxCourseQrCode(CommonRequest courseQrcodeAddRequest, HttpServletRequest request) throws Exception;
|
||||
}
|
||||
|
@ -12,13 +12,23 @@ import com.freewayso.image.combiner.enums.ZoomMode;
|
||||
import com.google.gson.Gson;
|
||||
import com.greenorange.promotion.common.ErrorCode;
|
||||
import com.greenorange.promotion.config.WxAccessToken;
|
||||
import com.greenorange.promotion.constant.SystemConstant;
|
||||
import com.greenorange.promotion.exception.BusinessException;
|
||||
import com.greenorange.promotion.mapper.UserInfoMapper;
|
||||
import com.greenorange.promotion.model.dto.CommonRequest;
|
||||
import com.greenorange.promotion.model.entity.Course;
|
||||
import com.greenorange.promotion.model.entity.CourseQrcodeApply;
|
||||
import com.greenorange.promotion.model.entity.FileInfo;
|
||||
import com.greenorange.promotion.model.entity.UserInfo;
|
||||
import com.greenorange.promotion.service.course.CourseQrcodeApplyService;
|
||||
import com.greenorange.promotion.service.course.CourseService;
|
||||
import com.greenorange.promotion.service.file.FileInfoService;
|
||||
import com.greenorange.promotion.service.userInfo.UserInfoService;
|
||||
import com.greenorange.promotion.service.wechat.WechatGetQrcodeService;
|
||||
import com.greenorange.promotion.utils.QRCodeUtil;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -31,7 +41,6 @@ import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -40,7 +49,6 @@ import java.util.concurrent.TimeUnit;
|
||||
public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
|
||||
|
||||
|
||||
|
||||
// 文件上传的存储目录
|
||||
@Value("${file.upload-dir}")
|
||||
private String uploadDir;
|
||||
@ -63,10 +71,18 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
|
||||
@Value("${wx.mini.appSecret}")
|
||||
private String appSecret;
|
||||
|
||||
|
||||
@Resource
|
||||
private FileInfoService fileInfoService;
|
||||
|
||||
@Resource
|
||||
private UserInfoMapper userInfoMapper;
|
||||
|
||||
@Resource
|
||||
private CourseService courseService;
|
||||
|
||||
@Resource
|
||||
private CourseQrcodeApplyService courseQrcodeApplyService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取接口调用凭据
|
||||
@ -197,14 +213,27 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String getWxCourseQrCode(String inviteCode) throws Exception {
|
||||
public String getWxCourseQrCode(CommonRequest commonRequest, HttpServletRequest request) throws Exception {
|
||||
String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY);
|
||||
if (accessToken == null) {
|
||||
accessToken = this.getAccessToken().getAccess_token();
|
||||
}
|
||||
// 获取用户邀请码
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
UserInfo userInfo = userInfoMapper.selectById(userId);
|
||||
String invitationCode = userInfo.getInvitationCode();
|
||||
// 获取课程信息
|
||||
Long courseId = commonRequest.getId();
|
||||
Course course = courseService.getById(courseId);
|
||||
String courseTitle = course.getName();
|
||||
String originalPrice = String.valueOf(course.getOriginPrice());
|
||||
String discountPrice = String.valueOf(course.getDiscountPrice());
|
||||
String discountText = "元券后价";
|
||||
|
||||
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("page", "pages/loginModule/register/register");
|
||||
param.put("scene", "invitationCode=" + inviteCode);
|
||||
param.put("scene", "invitationCode=" + invitationCode + "&courseId=" + courseId);
|
||||
param.put("width", 430);
|
||||
param.put("check_path", false);
|
||||
param.put("env_version", "develop");
|
||||
@ -216,10 +245,6 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
|
||||
.execute()
|
||||
.bodyBytes();
|
||||
|
||||
String courseTitle = "【早鸟42折】掌握CAD技能实战技能实战技能实战技能实战工作训练营";
|
||||
String originalPrice = "2680元";
|
||||
String discountPrice = "1680";
|
||||
String discountText = "元券后价";
|
||||
String FontType = "Microsoft YaHei UI";
|
||||
int FontStyle = Font.PLAIN;
|
||||
|
||||
@ -228,7 +253,7 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
|
||||
ImageCombiner combiner = new ImageCombiner(blankUrl, 341, 391, ZoomMode.WidthHeight, OutputFormat.PNG);
|
||||
|
||||
// 加载课程图片
|
||||
String courseUrl = "https://img.picui.cn/free/2025/06/22/6856ef5908d4b.jpg";
|
||||
String courseUrl = SystemConstant.FILE_COMMON_PREFIX + course.getImage();
|
||||
BufferedImage courseImage = ImageIO.read(new URL(courseUrl));
|
||||
|
||||
// Graphics2D graphics = courseImage.createGraphics();
|
||||
@ -311,21 +336,18 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
|
||||
.hashValue(hashValue)
|
||||
.build();
|
||||
fileInfoService.save(fileInfo);
|
||||
return biz + "-" + view;
|
||||
|
||||
String viewValue = biz + "-" + view;
|
||||
// 保存课程推广码申请记录
|
||||
CourseQrcodeApply courseQrcodeApply = CourseQrcodeApply.builder()
|
||||
.userId(userId)
|
||||
.courseId(courseId)
|
||||
.courseQrcode(viewValue)
|
||||
.build();
|
||||
courseQrcodeApplyService.save(courseQrcodeApply);
|
||||
return viewValue;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 获取本地图形环境
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
// 列出所有可用字体家族名
|
||||
String[] families = ge.getAvailableFontFamilyNames();
|
||||
|
||||
// 打印全部字体(可选)
|
||||
System.out.println("=== Available Font Families ===");
|
||||
Arrays.stream(families).forEach(System.out::println);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class OrderNumberUtils {
|
||||
// 获取时间戳(精确到秒)
|
||||
String timestamp = DATE_FORMAT.format(new Date());
|
||||
|
||||
// 获取4位随机数
|
||||
// 获取6位随机数
|
||||
String randomNumber = generateRandomNumber();
|
||||
|
||||
// 获取6位自增序列号,并确保不超过最大值
|
||||
@ -56,10 +56,10 @@ public class OrderNumberUtils {
|
||||
return new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
}
|
||||
|
||||
// 生成4位随机数(范围:0000到9999)
|
||||
// 生成6位随机数(范围:000000到999999)
|
||||
private static String generateRandomNumber() {
|
||||
int random = (int) (Math.random() * 10000); // 生成0到9999之间的随机数
|
||||
return String.format("%04d", random); // 格式化为4位
|
||||
int random = (int) (Math.random() * 1000000); // 生成0到999999之间的随机数
|
||||
return String.format("%06d", random); // 格式化为6位
|
||||
}
|
||||
|
||||
// 获取下一个自增序列号,使用ReentrantLock来确保线程安全
|
||||
|
@ -1,15 +1,21 @@
|
||||
spring:
|
||||
datasource:
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://27.30.77.229:3306/qingcheng_caozhe?serverTimezone=Asia/Shanghai
|
||||
# username: qingcheng
|
||||
# password: Qc@8ls2jf
|
||||
# hikari:
|
||||
# maximum-pool-size: 300
|
||||
# max-lifetime: 120000
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://27.30.77.229:3306/qingcheng_caozhe?serverTimezone=Asia/Shanghai
|
||||
username: qingcheng
|
||||
password: Qc@8ls2jf
|
||||
url: jdbc:mysql://43.143.28.121:3306/easybbs?serverTimezone=Asia/Shanghai
|
||||
username: easybbs
|
||||
password: root
|
||||
hikari:
|
||||
maximum-pool-size: 300
|
||||
max-lifetime: 120000
|
||||
|
||||
|
||||
|
||||
data:
|
||||
redis:
|
||||
port: 6379
|
||||
|
@ -1,4 +1,4 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
active: test
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
20
src/main/resources/mapper/CourseQrcodeApplyMapper.xml
Normal file
20
src/main/resources/mapper/CourseQrcodeApplyMapper.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.greenorange.promotion.mapper.CourseQrcodeApplyMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.greenorange.promotion.model.entity.CourseQrcodeApply">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="userId" column="userId" jdbcType="BIGINT"/>
|
||||
<result property="courseId" column="courseId" jdbcType="BIGINT"/>
|
||||
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>
|
||||
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="updateTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,userId,courseId,
|
||||
isDelete,createTime,updateTime
|
||||
</sql>
|
||||
</mapper>
|
@ -42,7 +42,7 @@ public class ${entityName}Controller {
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
@PostMapping("update")
|
||||
@Operation(summary = "web端管理员根据id修改${entityComment}", description = "参数:${entityComment}更新请求体,权限:管理员,方法名:update${entityName}")
|
||||
@Operation(summary = "web端管理员根据id修改${entityComment}信息", description = "参数:${entityComment}更新请求体,权限:管理员,方法名:update${entityName}")
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "${entityComment}管理", content = "web端管理员根据id修改${entityComment}信息")
|
||||
public BaseResponse<Boolean> update${entityName}(@Valid @RequestBody ${entityName}UpdateRequest ${entityNameLower}UpdateRequest) {
|
||||
|
@ -1,75 +1,74 @@
|
||||
package com.greenorange.promotion.junit;
|
||||
|
||||
import com.greenorange.promotion.model.dto.CommonRequest;
|
||||
import com.greenorange.promotion.model.entity.Project;
|
||||
import com.greenorange.promotion.model.vo.project.ProjectVO;
|
||||
import com.greenorange.promotion.service.common.CommonService;
|
||||
import com.greenorange.promotion.service.project.ProjectService;
|
||||
import com.greenorange.promotion.service.project.impl.ProjectServiceImpl;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class ProjectServiceImplTest {
|
||||
|
||||
@InjectMocks
|
||||
private ProjectServiceImpl service;
|
||||
// 把真正的业务实现类注入进来
|
||||
|
||||
@Mock
|
||||
private CommonService commonService;
|
||||
// 用于 copyProperties
|
||||
|
||||
@Mock
|
||||
private ProjectService projectService;
|
||||
// 用于 getById
|
||||
|
||||
@Test
|
||||
void queryProjectById_notFound_throwsException() {
|
||||
// Arrange
|
||||
CommonRequest req = new CommonRequest();
|
||||
req.setId(10L);
|
||||
when(projectService.getById(10L)).thenReturn(null);
|
||||
|
||||
// Act & Assert
|
||||
RuntimeException ex = assertThrows(RuntimeException.class, () ->
|
||||
service.queryProjectById(req)
|
||||
);
|
||||
assertTrue(ex.getMessage().contains("当前项目不存在"));
|
||||
|
||||
// commonService.copyProperties 不应被调用
|
||||
verify(commonService, never()).copyProperties(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryProjectById_found_returnsVO() {
|
||||
// Arrange
|
||||
Long projectId = 20L;
|
||||
CommonRequest req = new CommonRequest();
|
||||
req.setId(projectId);
|
||||
|
||||
Project project = new Project();
|
||||
project.setId(projectId);
|
||||
project.setProjectName("示例项目");
|
||||
when(projectService.getById(projectId)).thenReturn(project);
|
||||
|
||||
ProjectVO vo = new ProjectVO();
|
||||
vo.setId(projectId);
|
||||
vo.setProjectName("示例项目");
|
||||
when(commonService.copyProperties(project, ProjectVO.class))
|
||||
.thenReturn(vo);
|
||||
|
||||
// Act
|
||||
ProjectVO result = service.queryProjectById(req);
|
||||
|
||||
// Assert
|
||||
assertSame(vo, result, "应返回 commonService.copyProperties 的结果");
|
||||
verify(commonService, times(1)).copyProperties(project, ProjectVO.class);
|
||||
}
|
||||
}
|
||||
//package com.greenorange.promotion.junit;
|
||||
//
|
||||
//import com.greenorange.promotion.model.dto.CommonRequest;
|
||||
//import com.greenorange.promotion.model.entity.Project;
|
||||
//import com.greenorange.promotion.model.vo.project.ProjectVO;
|
||||
//import com.greenorange.promotion.service.common.CommonService;
|
||||
//import com.greenorange.promotion.service.project.ProjectService;
|
||||
//import com.greenorange.promotion.service.project.impl.ProjectServiceImpl;
|
||||
//import org.junit.jupiter.api.Test;
|
||||
//import org.junit.jupiter.api.extension.ExtendWith;
|
||||
//import org.mockito.InjectMocks;
|
||||
//import org.mockito.Mock;
|
||||
//import org.mockito.junit.jupiter.MockitoExtension;
|
||||
//
|
||||
//import static org.junit.jupiter.api.Assertions.*;
|
||||
//import static org.mockito.Mockito.*;
|
||||
//
|
||||
//@ExtendWith(MockitoExtension.class)
|
||||
//class ProjectServiceImplTest {
|
||||
//
|
||||
// @InjectMocks
|
||||
// private ProjectServiceImpl service;
|
||||
// // 把真正的业务实现类注入进来
|
||||
//
|
||||
// @Mock
|
||||
// private CommonService commonService;
|
||||
// // 用于 copyProperties
|
||||
//
|
||||
// @Mock
|
||||
// private ProjectService projectService;
|
||||
// // 用于 getById
|
||||
//
|
||||
// @Test
|
||||
// void queryProjectById_notFound_throwsException() {
|
||||
// // Arrange
|
||||
// CommonRequest req = new CommonRequest();
|
||||
// req.setId(10L);
|
||||
// when(projectService.getById(10L)).thenReturn(null);
|
||||
// // Act & Assert
|
||||
// RuntimeException ex = assertThrows(RuntimeException.class, () ->
|
||||
// service.queryProjectById(req)
|
||||
// );
|
||||
// assertTrue(ex.getMessage().equals("当前项目不存在"));
|
||||
//
|
||||
// // commonService.copyProperties 不应被调用
|
||||
// verify(commonService, never()).copyProperties(any(), any());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// void queryProjectById_found_returnsVO() {
|
||||
// // Arrange
|
||||
// Long projectId = 20L;
|
||||
// CommonRequest req = new CommonRequest();
|
||||
// req.setId(projectId);
|
||||
//
|
||||
// Project project = new Project();
|
||||
// project.setId(projectId);
|
||||
// project.setProjectName("示例项目");
|
||||
// when(projectService.getById(projectId)).thenReturn(project);
|
||||
//
|
||||
// ProjectVO vo = new ProjectVO();
|
||||
// vo.setId(projectId);
|
||||
// vo.setProjectName("示例项目");
|
||||
// when(commonService.copyProperties(project, ProjectVO.class))
|
||||
// .thenReturn(vo);
|
||||
//
|
||||
// // Act
|
||||
// ProjectVO result = service.queryProjectById(req);
|
||||
//
|
||||
// // Assert
|
||||
// assertSame(vo, result, "应返回 commonService.copyProperties 的结果");
|
||||
// verify(commonService, times(1)).copyProperties(project, ProjectVO.class);
|
||||
// }
|
||||
//}
|
||||
|
Reference in New Issue
Block a user