修复课程模块的bug
This commit is contained in:
@ -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);
|
||||
|
@ -2,12 +2,16 @@ 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.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;
|
||||
@ -16,6 +20,7 @@ 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.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;
|
||||
@ -35,7 +40,9 @@ 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;
|
||||
|
||||
|
||||
@ -71,7 +78,7 @@ public class CourseController {
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@SysLog(title = "课程管理", content = "小程序端用户查看热门课程列表")
|
||||
public BaseResponse<List<CourseCardVO>> miniQueryHotCourseList() {
|
||||
List<Course> courseList = courseService.list();
|
||||
List<Course> courseList = commonService.findByFieldEqTargetField(Course::getIsShelves, true, courseService);
|
||||
// 降序排序并取前四个元素
|
||||
courseList = courseList.stream()
|
||||
.sorted((course1, course2) -> Integer.compare(course2.getOrderCount(), course1.getOrderCount())) // 降序排序
|
||||
@ -93,8 +100,8 @@ public class CourseController {
|
||||
@SysLog(title = "课程管理", content = "小程序端用户根据类别查看课程列表")
|
||||
public BaseResponse<List<CourseCardVO>> miniQueryCourseByType(@Valid @RequestBody CommonStringRequest commonStringRequest) {
|
||||
String courseType = commonStringRequest.getTemplateString();
|
||||
LambdaQueryWrapper<Course> lambdaQueryWrapper = commonService.buildQueryWrapperByField(Course::getType, courseType, courseService);
|
||||
List<Course> courseList = courseService.list(lambdaQueryWrapper);
|
||||
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);
|
||||
}
|
||||
@ -167,6 +174,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());
|
||||
@ -240,6 +250,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 课程查询请求体
|
||||
|
@ -103,23 +103,6 @@ public class CourseOrderController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户在提交订单页中显示课程信息
|
||||
* @param commonRequest 课程id
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
@PostMapping("show/info")
|
||||
@Operation(summary = "小程序端用户在提交订单页中显示课程信息", description = "参数:订单id,权限:管理员,方法名:showCourseInfo")
|
||||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
@SysLog(title = "课程订单管理", content = "小程序端用户在提交订单页中显示课程信息")
|
||||
public BaseResponse<CourseCardVO> showCourseInfo(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
Course course = courseService.getById(id);
|
||||
CourseCardVO courseCardVO = commonService.copyProperties(course, CourseCardVO.class);
|
||||
return ResultUtils.success(courseCardVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序端用户查询课程订单列表
|
||||
* @return 课程订单列表
|
||||
|
@ -33,6 +33,13 @@ public class CourseQueryRequest extends PageRequest implements Serializable {
|
||||
private String type;
|
||||
|
||||
|
||||
/**
|
||||
* 是否上架(true:上架,false:下架)
|
||||
*/
|
||||
@Schema(description = "是否上架(true:上架,false:下架)", example = "true")
|
||||
private Boolean isShelves;
|
||||
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
@ -32,6 +33,14 @@ public class CourseChapterQueryRequest extends PageRequest implements Serializab
|
||||
@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;
|
||||
|
@ -72,6 +72,11 @@ public class Course implements Serializable {
|
||||
*/
|
||||
private BigDecimal secondLevelRate;
|
||||
|
||||
/**
|
||||
* 是否上架(true:上架,false:下架)
|
||||
*/
|
||||
private Boolean isShelves;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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.isEmpty(isShelves), "isShelves", isShelves);
|
||||
queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), sortField);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ 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.FileInfo;
|
||||
@ -72,7 +73,7 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
|
||||
private FileInfoService fileInfoService;
|
||||
|
||||
@Resource
|
||||
private UserInfoService userInfoService;
|
||||
private UserInfoMapper userInfoMapper;
|
||||
|
||||
@Resource
|
||||
private CourseService courseService;
|
||||
@ -214,7 +215,7 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
|
||||
}
|
||||
// 获取用户邀请码
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
UserInfo userInfo = userInfoService.getById(userId);
|
||||
UserInfo userInfo = userInfoMapper.selectById(userId);
|
||||
String invitationCode = userInfo.getInvitationCode();
|
||||
// 获取课程信息
|
||||
Long id = commonRequest.getId();
|
||||
|
Reference in New Issue
Block a user