|
@@ -19,13 +19,13 @@
|
|
|
where id = #{id,jdbcType=INTEGER}
|
|
where id = #{id,jdbcType=INTEGER}
|
|
|
</delete>
|
|
</delete>
|
|
|
<insert id="insert" parameterType="cn.seecoder.courselearning.po.Course" useGeneratedKeys="true" keyProperty="id">
|
|
<insert id="insert" parameterType="cn.seecoder.courselearning.po.Course" useGeneratedKeys="true" keyProperty="id">
|
|
|
- insert into course (id, name, type,
|
|
|
|
|
- intro, picture, school,
|
|
|
|
|
- create_time, delete_time, cost,
|
|
|
|
|
|
|
+ insert into course (id, name, type,
|
|
|
|
|
+ intro, picture, school,
|
|
|
|
|
+ create_time, delete_time, cost,
|
|
|
teacher_id, teacher_name)
|
|
teacher_id, teacher_name)
|
|
|
- values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
|
|
|
|
|
- #{intro,jdbcType=VARCHAR}, #{picture,jdbcType=VARCHAR}, #{school,jdbcType=VARCHAR},
|
|
|
|
|
- #{createTime,jdbcType=TIMESTAMP}, #{deleteTime,jdbcType=TIMESTAMP}, #{cost,jdbcType=INTEGER},
|
|
|
|
|
|
|
+ values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
|
|
|
|
|
+ #{intro,jdbcType=VARCHAR}, #{picture,jdbcType=VARCHAR}, #{school,jdbcType=VARCHAR},
|
|
|
|
|
+ #{createTime,jdbcType=TIMESTAMP}, #{deleteTime,jdbcType=TIMESTAMP}, #{cost,jdbcType=INTEGER},
|
|
|
#{teacherId,jdbcType=INTEGER}, #{teacherName,jdbcType=VARCHAR})
|
|
#{teacherId,jdbcType=INTEGER}, #{teacherName,jdbcType=VARCHAR})
|
|
|
</insert>
|
|
</insert>
|
|
|
<update id="updateByPrimaryKey" parameterType="cn.seecoder.courselearning.po.Course">
|
|
<update id="updateByPrimaryKey" parameterType="cn.seecoder.courselearning.po.Course">
|
|
@@ -43,14 +43,17 @@
|
|
|
where id = #{id,jdbcType=INTEGER}
|
|
where id = #{id,jdbcType=INTEGER}
|
|
|
</update>
|
|
</update>
|
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
|
|
- select id, name, type, intro, picture, school, create_time, delete_time, cost, teacher_id,
|
|
|
|
|
- teacher_name
|
|
|
|
|
- from course
|
|
|
|
|
- where id = #{id,jdbcType=INTEGER}
|
|
|
|
|
|
|
+ select c.id, c.name, c.type, c.intro, c.picture, c.school, c.create_time, c.delete_time, c.cost, c.teacher_id, c.teacher_name, t.count as likes
|
|
|
|
|
+ from course c
|
|
|
|
|
+ inner join (select count(*) as count, course_id as id from course_likes group by course_id) as t
|
|
|
|
|
+ on c.id = t.id
|
|
|
|
|
+ where c.id = #{id,jdbcType=INTEGER}
|
|
|
</select>
|
|
</select>
|
|
|
<select id="selectAll" resultMap="BaseResultMap">
|
|
<select id="selectAll" resultMap="BaseResultMap">
|
|
|
- select id, name, type, intro, picture, school, create_time, delete_time, cost, teacher_id, teacher_name
|
|
|
|
|
- from course
|
|
|
|
|
|
|
+ select c.id, c.name, c.type, c.intro, c.picture, c.school, c.create_time, c.delete_time, c.cost, c.teacher_id, c.teacher_name, t.count as likes
|
|
|
|
|
+ from course c
|
|
|
|
|
+ inner join (select count(*) as count, course_id as id from course_likes group by course_id) as t
|
|
|
|
|
+ on c.id = t.id
|
|
|
</select>
|
|
</select>
|
|
|
<select id="selectByType" parameterType="java.lang.String" resultMap="BaseResultMap">
|
|
<select id="selectByType" parameterType="java.lang.String" resultMap="BaseResultMap">
|
|
|
select id, name, type, intro, picture, school, create_time, delete_time, cost, teacher_id, teacher_name
|
|
select id, name, type, intro, picture, school, create_time, delete_time, cost, teacher_id, teacher_name
|
|
@@ -85,4 +88,11 @@
|
|
|
select o.id from course_order o where o.course_id = c.id and o.user_id = #{userId}
|
|
select o.id from course_order o where o.course_id = c.id and o.user_id = #{userId}
|
|
|
)
|
|
)
|
|
|
</select>
|
|
</select>
|
|
|
|
|
+ <select id="selectHotCourses" resultType="cn.seecoder.courselearning.po.Course">
|
|
|
|
|
+ select c.id, c.name, c.type, c.intro, c.picture, c.school, c.create_time, c.delete_time, c.cost, c.teacher_id, c.teacher_name, t.count as likes
|
|
|
|
|
+ from course c
|
|
|
|
|
+ inner join (select count(*) as count, course_id as id from course_likes group by course_id) as t
|
|
|
|
|
+ on c.id = t.id
|
|
|
|
|
+ order by likes desc
|
|
|
|
|
+ </select>
|
|
|
</mapper>
|
|
</mapper>
|