肖海南最新收藏

master
wenyu441069198 4 months ago
parent 0d1a331144
commit 2cc709e009
  1. 1
      src/main/java/com/teaching/backend/controller/courses/CoursesController.java
  2. 23
      src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java
  3. 5
      src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java
  4. 1
      src/main/java/com/teaching/backend/mapper/umsAdmin/UmsUserMapper.java
  5. 8
      src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java
  6. 30
      src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java
  7. 27
      src/main/resources/mapper/SeCourseFavourMapper.xml
  8. 8
      src/main/resources/mapper/UmsUserMapper.xml

@ -141,7 +141,6 @@ public class CoursesController {
}
@ApiOperation("查询学生列表")
// @ValidateParams({"username"})
@PostMapping("/studentList")
public CommonResult<HashSet<UmsStudent>> getStudentList(CourseQuery courseQuery){
HashSet<UmsStudent> umsStudentList = coursesService.queryStudentList(courseQuery);

@ -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<CoursesVO> newCollect(@RequestParam String userId) {
CoursesVO newCoursesVO = seCourseFavourService.queryNewCollect(userId);
if (newCoursesVO == null){
CommonResult.failed();
}
return CommonResult.success(newCoursesVO);
}
}

@ -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<SeCourseFavour> {
String queryAllNewCollectCourse();
String queryStudentNewCollectCourse(String userId);
}

@ -19,4 +19,5 @@ public interface UmsUserMapper extends BaseMapper<UmsUser> {
UmsStudentVO getByIdStudent(String id);
String getbyIdRoleId(String userId);
}

@ -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<SeCourseFavour> {
*/
public Page<CourseFavourDetailVO> listCourseFavourByPage(Page<Courses> page, Wrapper<Courses> queryWrapper);
/**
* 获取最新收藏的课程
*
* @param userId
* @return
*/
CoursesVO queryNewCollect(String userId);
}

@ -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<SeCourseFavourMapper,
@Autowired
ICoursesService coursesService;
@Autowired
SeCourseFavourMapper seCourseFavourMapper;
@Autowired
UmsUserMapper umsUserMapper;
@Override
@ -145,5 +155,25 @@ public class SeCourseFavourServiceImpl extends ServiceImpl<SeCourseFavourMapper,
return courseFavourVOPage;
}
@Override
public CoursesVO queryNewCollect(String userId) {
String roleId = umsUserMapper.getbyIdRoleId(userId);
CoursesVO coursesVO = new CoursesVO();
if (roleId.equals("1")){
//老师
String courseId = seCourseFavourMapper.queryAllNewCollectCourse();
Courses courses = coursesMapper.selectById(courseId);
BeanUtil.copyProperties(courses,coursesVO);
return coursesVO;
}else if (roleId.equals("2")){
//学生
String courseId = seCourseFavourMapper.queryStudentNewCollectCourse(userId);
Courses courses = coursesMapper.selectById(courseId);
BeanUtil.copyProperties(courses,coursesVO);
return coursesVO;
}else {
return null;
}
}
}

@ -0,0 +1,27 @@
<?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.teaching.backend.mapper.favour.SeCourseFavourMapper">
<select id="queryAllNewCollectCourse" resultType="java.lang.String"
parameterType="java.lang.String">
SELECT
scf.course_id courseId
FROM
se_course_favour scf
ORDER BY
createtime
DESC LIMIT 1;
</select>
<select id="queryStudentNewCollectCourse" resultType="java.lang.String">
SELECT
scf.course_id courseId
FROM
se_course_favour scf
WHERE
scf.user_id = #{userId}
ORDER BY
createtime
DESC LIMIT 1;
</select>
</mapper>

@ -76,5 +76,13 @@
WHERE
s.user_id = #{id}
</select>
<select id="getbyIdRoleId" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
us.role_id roleId
FROM
ums_user us
WHERE
us.id = #{userId}
</select>
</mapper>

Loading…
Cancel
Save