38 lines
1.1 KiB
XML
38 lines
1.1 KiB
XML
<?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="cn.unizk.mapper.CourseMapper">
|
|
|
|
<!-- 通用查询映射结果 -->
|
|
<resultMap id="BaseResultMap" type="cn.unizk.entity.po.Course">
|
|
<id column="course_id" property="courseId" />
|
|
<result column="title" property="title" />
|
|
<result column="obj_name" property="objName" />
|
|
<result column="purchases" property="purchases" />
|
|
<result column="create_time" property="createTime" />
|
|
</resultMap>
|
|
|
|
<resultMap id="VOResultMap" type="cn.unizk.entity.vo.CourseVO">
|
|
<result column="chapterTotal" property="chapterTotal" />
|
|
</resultMap>
|
|
|
|
<select id="voPage" resultMap="VOResultMap">
|
|
SELECT
|
|
c.course_id,
|
|
c.title,
|
|
c.price,
|
|
COUNT(ch.chapter_id) AS chapterTotal
|
|
FROM
|
|
course c
|
|
LEFT JOIN
|
|
chapter ch ON c.course_id = ch.course_id
|
|
<where>
|
|
<if test="title != null and title != ''">
|
|
and c.title = #{title}
|
|
</if>
|
|
</where>
|
|
GROUP BY
|
|
c.course_id, c.title, c.price
|
|
</select>
|
|
|
|
</mapper>
|