代码修正

master
Alan 5 months ago
parent 51bcfa9cc7
commit 423afadb38
  1. 2
      src/main/java/com/teaching/backend/controller/courses/CoursesController.java
  2. 7
      src/main/java/com/teaching/backend/model/query/CourseQuery.java
  3. 27
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java

@ -66,7 +66,7 @@ public class CoursesController {
@ApiOperation("查询课程列表")
@ValidateParams({"username","roleId"})
@ValidateParams({"username"})
@GetMapping("/page")
public BaseResponse<PageDTO<CoursesVO>> getCourses(CourseQuery courseQuery){
PageDTO<CoursesVO> coursesList = coursesService.queryCourses(courseQuery);

@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Data
@ -15,8 +18,8 @@ public class CourseQuery extends PageQuery {
@ApiModelProperty(value = "用户的username",required = true)
private String username;
@ApiModelProperty(value = "用户的角色id",required = true)
private Long roleId;
// @ApiModelProperty(value = "用户的角色id",required = true)
// private List<String> roleId;
@ApiModelProperty("课程任课教师")
private String teacher;

@ -43,6 +43,7 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* <p>
@ -148,13 +149,26 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
// throw new BusinessException(ErrorCode.USERNAME_NOT_EXIT);
// }
// UmsUser umsUser = umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
// .eq(UmsUser::getUsername, username));
// UmsAdminRoleRelation umsAdminRoleRelation = umsAdminRoleRelationMapper.selectOne(new LambdaQueryWrapper<UmsAdminRoleRelation>()
// .eq(UmsAdminRoleRelation::getAdminId, umsUser.getId()));
int roleId = Integer.parseInt(umsUserMapper.selectOne(new LambdaQueryWrapper<UmsUser>()
.eq(UmsUser::getUsername, username)).getRoleId());
// int roleId = Math.toIntExact(umsAdminRoleRelation.getRoleId());
int roleId = Math.toIntExact(courseQuery.getRoleId());
// int roleId = 0;
// List<String> roleIdList = courseQuery.getRoleId();
// System.out.println(roleIdList);
// if (roleIdList != null && !roleIdList.isEmpty()) {
// Object firstElement = roleIdList.get(0);
//
// if (firstElement instanceof List) {
// List<?> innerList = (List<?>) firstElement;
// if (!innerList.isEmpty()) {
// roleId = Integer.parseInt((String) innerList.get(0));
// }
// } else if (firstElement instanceof String) {
// roleId = Integer.parseInt((String) firstElement);
// }
// }
System.out.println(roleId);
PageDTO<CoursesVO> coursesVOPageDTO;
switch (roleId) {
@ -183,6 +197,9 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
Page<Courses> p = lambdaQuery()
.like(courseQuery.getName() != null, Courses::getName, courseQuery.getName())
.apply("FIND_IN_SET({0}, teacher)", username)
.eq(courseQuery.getCategory() != null && !courseQuery.getCategory().isEmpty(), Courses::getCategory, courseQuery.getCategory())
.eq(courseQuery.getNature() != null && !courseQuery.getNature().isEmpty(), Courses::getNature, courseQuery.getNature())
.eq(courseQuery.getAssessmenttype() != null &&!courseQuery.getAssessmenttype().isEmpty(), Courses::getAssessmenttype, courseQuery.getAssessmenttype())
.page(page);
return PageDTO.of(p, CoursesVO.class);
}

Loading…
Cancel
Save