From 423afadb38b20684dbbb288157beae41edad7730 Mon Sep 17 00:00:00 2001 From: Alan <3052806735@qq.com> Date: Sun, 23 Jun 2024 00:10:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/courses/CoursesController.java | 2 +- .../backend/model/query/CourseQuery.java | 7 +++-- .../impl/courses/CoursesServiceImpl.java | 27 +++++++++++++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java index c05c549..243ead4 100644 --- a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java +++ b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java @@ -66,7 +66,7 @@ public class CoursesController { @ApiOperation("查询课程列表") - @ValidateParams({"username","roleId"}) + @ValidateParams({"username"}) @GetMapping("/page") public BaseResponse> getCourses(CourseQuery courseQuery){ PageDTO coursesList = coursesService.queryCourses(courseQuery); diff --git a/src/main/java/com/teaching/backend/model/query/CourseQuery.java b/src/main/java/com/teaching/backend/model/query/CourseQuery.java index b5d0393..a8901a3 100644 --- a/src/main/java/com/teaching/backend/model/query/CourseQuery.java +++ b/src/main/java/com/teaching/backend/model/query/CourseQuery.java @@ -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 roleId; @ApiModelProperty("课程任课教师") private String teacher; diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java index 4486a40..1efe8c2 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java @@ -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; /** *

@@ -148,13 +149,26 @@ public class CoursesServiceImpl extends ServiceImpl impl // throw new BusinessException(ErrorCode.USERNAME_NOT_EXIT); // } -// UmsUser umsUser = umsUserMapper.selectOne(new LambdaQueryWrapper() -// .eq(UmsUser::getUsername, username)); -// UmsAdminRoleRelation umsAdminRoleRelation = umsAdminRoleRelationMapper.selectOne(new LambdaQueryWrapper() -// .eq(UmsAdminRoleRelation::getAdminId, umsUser.getId())); + int roleId = Integer.parseInt(umsUserMapper.selectOne(new LambdaQueryWrapper() + .eq(UmsUser::getUsername, username)).getRoleId()); // int roleId = Math.toIntExact(umsAdminRoleRelation.getRoleId()); - int roleId = Math.toIntExact(courseQuery.getRoleId()); +// int roleId = 0; +// List 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 coursesVOPageDTO; switch (roleId) { @@ -183,6 +197,9 @@ public class CoursesServiceImpl extends ServiceImpl impl Page 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); }