he2802 4 лет назад
Родитель
Сommit
0b4c430ce9

+ 8 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/course/CourseController.java

@@ -11,6 +11,8 @@ import com.zhongzheng.modules.course.bo.CourseEditBo;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
 import com.zhongzheng.modules.course.service.ICourseService;
 import com.zhongzheng.modules.course.vo.CourseVo;
+import com.zhongzheng.modules.exam.bo.ExamNoteQueryBo;
+import com.zhongzheng.modules.exam.vo.ExamNoteVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
@@ -60,5 +62,11 @@ public class CourseController extends BaseController {
         return AjaxResult.success(iCourseService.queryById(courseId));
     }
 
+    @ApiOperation("课程推荐列表")
+    @GetMapping("/recommendList")
+    public AjaxResult<List<CourseVo>> recommendList(CourseQueryBo bo) {
+        List<CourseVo> list = iCourseService.queryRecommendList(bo);
+        return AjaxResult.success(list);
+    }
 
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseQueryBo.java

@@ -24,6 +24,8 @@ import com.zhongzheng.common.core.domain.BaseEntity;
 @ApiModel("课程分页查询对象")
 public class CourseQueryBo extends BaseEntity {
 
+	private Long courseId;
+
 	/** 分页大小 */
 	@ApiModelProperty("分页大小")
 	private Integer pageSize;

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseMapper.java

@@ -20,4 +20,7 @@ public interface CourseMapper extends BaseMapper<Course> {
 
     List<CourseVo> selectCourseList(CourseQueryBo bo);
 
+    List<CourseVo> queryRecommendList(CourseQueryBo bo);
+
+
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseService.java

@@ -7,6 +7,8 @@ import com.zhongzheng.modules.course.bo.CourseEditBo;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
 import com.zhongzheng.modules.course.domain.Course;
 import com.zhongzheng.modules.course.vo.CourseVo;
+import com.zhongzheng.modules.exam.bo.ExamNoteQueryBo;
+import com.zhongzheng.modules.exam.vo.ExamNoteVo;
 import com.zhongzheng.modules.order.bo.CouponQueryBo;
 import com.zhongzheng.modules.order.vo.CouponVo;
 
@@ -33,6 +35,8 @@ public interface ICourseService extends IService<Course> {
 	 */
 	List<CourseVo> queryList(CourseQueryBo bo);
 
+	List<CourseVo> queryRecommendList(CourseQueryBo bo);
+
 	List<CourseVo> selectCourseList(CourseQueryBo bo);
 
 	/**

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java

@@ -59,6 +59,11 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
         return entity2Vo(this.list(lqw));
     }
 
+    @Override
+    public List<CourseVo> queryRecommendList(CourseQueryBo bo) {
+        return courseMapper.queryRecommendList(bo);
+    }
+
     @Override
     public List<CourseVo> selectCourseList(CourseQueryBo bo) {
         return courseMapper.selectCourseList(bo);

+ 15 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

@@ -50,4 +50,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         GROUP BY course_id
     </select>
 
+    <select id="queryRecommendList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo"  resultMap="CourseResult">
+        SELECT
+        course_id,course_name,cover_url,price
+        FROM
+        course
+        WHERE
+        STATUS = 1
+        <if test="courseId != null and courseId != ''">
+            AND course_id != #{courseId}
+        </if>
+        ORDER BY
+        RAND()
+        LIMIT 4
+    </select>
+
 </mapper>