【新增】教程
This commit is contained in:
45
src/main/resources/mapper/CourseMapper.xml
Normal file
45
src/main/resources/mapper/CourseMapper.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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.corewing.app.mapper.CourseMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="VOResultMap" type="com.corewing.app.vo.CourseVO">
|
||||
<id column="id" property="id"/>
|
||||
<result column="course_title" property="courseTitle"/>
|
||||
<result column="description" property="description"/>
|
||||
<result column="content" property="content"/>
|
||||
<result column="view_count" property="viewCount"/>
|
||||
<result column="recommend_status" property="recommendStatus"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="category_title" property="categoryTitle"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础查询SQL片段 -->
|
||||
<sql id="selectVOSql">
|
||||
select c.*, cc.category_title
|
||||
from app_course c
|
||||
left join app_course_category_relation ccr on c.id = ccr.course_id
|
||||
left join app_course_category cc on cc.id = ccr.category_id
|
||||
</sql>
|
||||
|
||||
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="pageList" resultMap="VOResultMap">
|
||||
<include refid="selectVOSql"/>
|
||||
<where>
|
||||
c.status = 1
|
||||
<if test="categoryId != null and categoryId != 0">
|
||||
AND cc.id = #{categoryId}
|
||||
</if>
|
||||
<if test="courseTitle != null and courseTitle != ''">
|
||||
AND c.course_title like CONCAT('%', #{courseTitle}, '%')
|
||||
</if>
|
||||
|
||||
</where>
|
||||
ORDER BY c.recommend_status,c.create_time asc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user