From 2cc709e0092906c461801eb645bd23f64c6dd09c Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Mon, 29 Jul 2024 17:07:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=82=96=E6=B5=B7=E5=8D=97=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/courses/CoursesController.java | 1 - .../favour/SeCourseFavourController.java | 23 +++++++++++--- .../mapper/favour/SeCourseFavourMapper.java | 5 ++++ .../mapper/umsAdmin/UmsUserMapper.java | 1 + .../service/favour/SeCourseFavourService.java | 8 +++++ .../favour/SeCourseFavourServiceImpl.java | 30 +++++++++++++++++++ .../resources/mapper/SeCourseFavourMapper.xml | 27 +++++++++++++++++ src/main/resources/mapper/UmsUserMapper.xml | 8 +++++ 8 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/mapper/SeCourseFavourMapper.xml 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 b193a11..419691c 100644 --- a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java +++ b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java @@ -141,7 +141,6 @@ public class CoursesController { } @ApiOperation("查询学生列表") -// @ValidateParams({"username"}) @PostMapping("/studentList") public CommonResult> getStudentList(CourseQuery courseQuery){ HashSet umsStudentList = coursesService.queryStudentList(courseQuery); diff --git a/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java b/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java index f09fc43..05dde6a 100644 --- a/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java +++ b/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java @@ -3,6 +3,7 @@ package com.teaching.backend.controller.favour; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.teaching.backend.common.BaseResponse; +import com.teaching.backend.common.CommonResult; import com.teaching.backend.common.ErrorCode; import com.teaching.backend.common.ResultUtils; import com.teaching.backend.exception.BusinessException; @@ -10,14 +11,13 @@ import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourAddRequest import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourAllRequest; import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourQueryRequest; import com.teaching.backend.model.entity.courses.Courses; +import com.teaching.backend.model.vo.courses.CoursesVO; import com.teaching.backend.model.vo.favour.CourseFavourDetailVO; import com.teaching.backend.service.favour.SeCourseFavourService; +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -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 org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @@ -92,5 +92,20 @@ public class SeCourseFavourController { return ResultUtils.success(courseFavourDetailVOPage); } + /** + * 获取最新收藏的课程 + * + * @return + */ + @ApiOperation("查询最新收藏") + @PostMapping("/newCollect") + public CommonResult newCollect(@RequestParam String userId) { + CoursesVO newCoursesVO = seCourseFavourService.queryNewCollect(userId); + if (newCoursesVO == null){ + CommonResult.failed(); + } + return CommonResult.success(newCoursesVO); + } } + diff --git a/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java b/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java index 47ed89a..3c9c766 100644 --- a/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java +++ b/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java @@ -1,6 +1,7 @@ package com.teaching.backend.mapper.favour; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.favour.SeCourseFavour; /** @@ -8,6 +9,10 @@ import com.teaching.backend.model.entity.favour.SeCourseFavour; */ public interface SeCourseFavourMapper extends BaseMapper { + + String queryAllNewCollectCourse(); + + String queryStudentNewCollectCourse(String userId); } diff --git a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsUserMapper.java b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsUserMapper.java index ca18264..7f422de 100644 --- a/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsUserMapper.java +++ b/src/main/java/com/teaching/backend/mapper/umsAdmin/UmsUserMapper.java @@ -19,4 +19,5 @@ public interface UmsUserMapper extends BaseMapper { UmsStudentVO getByIdStudent(String id); + String getbyIdRoleId(String userId); } diff --git a/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java b/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java index 9cb0d40..9723cbf 100644 --- a/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java +++ b/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.teaching.backend.common.BaseResponse; import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.favour.SeCourseFavour; +import com.teaching.backend.model.vo.courses.CoursesVO; import com.teaching.backend.model.vo.favour.CourseFavourDetailVO; import java.util.List; @@ -54,4 +55,11 @@ public interface SeCourseFavourService extends IService { */ public Page listCourseFavourByPage(Page page, Wrapper queryWrapper); + /** + * 获取最新收藏的课程 + * + * @param userId + * @return + */ + CoursesVO queryNewCollect(String userId); } diff --git a/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java index a442c5a..bebe162 100644 --- a/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java @@ -1,5 +1,6 @@ package com.teaching.backend.service.impl.favour; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateTime; import com.baomidou.mybatisplus.core.conditions.Wrapper; @@ -12,10 +13,13 @@ import com.teaching.backend.common.ResultUtils; import com.teaching.backend.exception.BusinessException; import com.teaching.backend.mapper.courses.CoursesMapper; import com.teaching.backend.mapper.favour.SeCourseFavourMapper; +import com.teaching.backend.mapper.umsAdmin.UmsUserMapper; import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.entity.favour.SeCourseFavour; import com.teaching.backend.model.entity.favour.SeKnowFavour; import com.teaching.backend.model.entity.favour.SeResourceFavour; +import com.teaching.backend.model.entity.umsAdmin.UmsUser; +import com.teaching.backend.model.vo.courses.CoursesVO; import com.teaching.backend.model.vo.favour.CourseFavourDetailVO; import com.teaching.backend.service.courses.ICoursesService; import com.teaching.backend.service.favour.SeCourseFavourService; @@ -52,6 +56,12 @@ public class SeCourseFavourServiceImpl extends ServiceImpl + + + + + + + diff --git a/src/main/resources/mapper/UmsUserMapper.xml b/src/main/resources/mapper/UmsUserMapper.xml index 7c422c1..d09d5a0 100644 --- a/src/main/resources/mapper/UmsUserMapper.xml +++ b/src/main/resources/mapper/UmsUserMapper.xml @@ -76,5 +76,13 @@ WHERE s.user_id = #{id} +