<?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.tina.mapper.CourseMapper">
<!--根据id值查询CourseInfoReq的信息-->
<select id="getCourseInfo" parameterType="String" resultType="com.tina.req.CourseInfoReq">
SELECT
tc.id,tc.teacher_id,tc.subject_id,tc.title,tc.price,
tc.lesson_num,tc.cover,tc.buy_count,tc.view_count,
tcd.description
from t_course as tc left join t_course_description as tcd
on tc.id = tcd.id where tc.del_flag = 0 and tcd.del_flag =0 and tc.id =#{id}
</select>
<select id="getCourseInfoCondition" resultType="com.tina.req.CourseInfoReq">
SELECT
tc.id,tc.teacher_id,tc.subject_id,tc.title,tc.price,
tc.lesson_num,tc.cover,tc.buy_count,tc.view_count,
tcd.description
from t_course as tc left join t_course_description as tcd
on tc.id = tcd.id where tc.del_flag = 0 and tcd.del_flag =0
order by tc.gmt_modified desc
</select>
<select id="getCourseInfoConditionByWaper2" parameterType="com.tina.req.CourseInfoConditionrReq" resultType="com.tina.req.CourseInfoReq" >
SELECT
tc.id,
tc.teacher_id,
tc.subject_id,
tc.title,
tc.price,
tc.lesson_num,
tc.cover,
tc.buy_count,
tc.view_count,
tcd.description
FROM
t_course AS tc
LEFT JOIN t_course_description AS tcd ON tc.id = tcd.id
WHERE
tc.del_flag = 0
AND tcd.del_flag = 0
<if test="id != null and id != ''">
and tc.id = #{id}
</if>
<if test="teacherId != null and teacherId != ''">
and tc.teacher_id = #{teacherId}
</if>
<if test="subjectId != null and subjectId != ''">
and tc.subject_id = #{subjectId}
</if>
<if test="teacherId != null and teacherId != ''">
and tc.title like CONCAT(CONCAT('%', #{title}), '%')
</if>
order by tc.gmt_modified desc
</select>
<select id="getCourseInfoConditionByWaper" parameterType="com.tina.req.CourseInfoConditionrReq" resultType="com.tina.req.CourseInfoReq" >
SELECT
tc.id,
tc.teacher_id,
tc.subject_id,
tc.title,
tc.price,
tc.lesson_num,
tc.cover,
tc.buy_count,
tc.view_count,
tcd.description
FROM
t_course AS tc
LEFT JOIN t_course_description AS tcd ON tc.id = tcd.id
WHERE
tc.del_flag = 0
AND tcd.del_flag = 0
<if test="id != null and id != ''">
AND tc.id = #{id}
</if>
<if test="teacherId != null and teacherId != ''">
and tc.teacher_id = #{teacherId}
</if>
<if test="subjectId != null and subjectId != ''">
and tc.subject_id = #{subjectId}
</if>
<if test="teacherId != null and teacherId != ''">
and tc.title LIKE CONCAT(CONCAT('%', #{title}), '%')
</if>
order by tc.gmt_modified desc
limit #{pages} , #{row}
</select>
</mapper>
网友评论