218 lines
14 KiB
XML
218 lines
14 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="Lesson">
|
|
|
|
<insert id="insertLesson" parameterType="Lesson">
|
|
INSERT INTO Lesson ( lessonId, lessonType, lessonName, parentId, courseCode, description, orderId, status, bigIcon, version, versionNo, url, isRecommend
|
|
<if test="assigntime != null">
|
|
,assigntime
|
|
</if>
|
|
<if test="gradeid != null">
|
|
,gradeid
|
|
</if>
|
|
<if test="term != null">
|
|
,term
|
|
</if>
|
|
|
|
|
|
) Values ( #{lessonId}, #{lessonType}, #{lessonName}, #{parentId}, #{courseCode}, #{description}, #{orderId}, #{status}, #{bigIcon}, #{version}, #{versionNo}, #{url}, #{isRecommend}
|
|
<if test="assigntime != null">
|
|
,#{assigntime}
|
|
</if>
|
|
<if test="gradeid != null">
|
|
,#{gradeid}
|
|
</if>
|
|
<if test="term != null">
|
|
,#{term}
|
|
</if>
|
|
)
|
|
|
|
</insert>
|
|
|
|
<update id="updateLesson" parameterType="Lesson">
|
|
|
|
|
|
UPDATE Lesson SET
|
|
|
|
lessonId = #{lessonId}, lessonType = #{lessonType}, lessonName = #{lessonName}, parentId = #{parentId}, courseCode = #{courseCode}, description = #{description}, orderId = #{orderId}, status = #{status}, bigIcon = #{bigIcon}, version = #{version}, versionNo = #{versionNo}, url = #{url}, isRecommend = #{isRecommend}
|
|
<if test="assigntime != null">
|
|
,assigntime = #{assigntime}
|
|
</if>
|
|
<if test="gradeid != null">
|
|
,gradeid=#{gradeid}
|
|
</if>
|
|
<if test="term != null">
|
|
,term = #{term}
|
|
</if>
|
|
where lessonId=#{lessonId}
|
|
|
|
</update>
|
|
|
|
<select id="getLessonByKey" parameterType="java.lang.Integer" resultType="Lesson">
|
|
|
|
|
|
|
|
SELECT lessonId , lessonType , lessonName , parentId , courseCode , description , orderId , status , bigIcon , version , versionNo , url , isRecommend,assigntime,gradeid,term
|
|
FROM Lesson WHERE lessonId=#{lessonId}
|
|
|
|
</select>
|
|
|
|
<select id="getCsUserOwnLessonByTeacherId" parameterType="java.util.Map" resultType="Lesson">
|
|
|
|
SELECT l2.lessonId , l2.lessonType , l2.lessonName , l2.parentId , l2.courseCode , l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend,l3.lessonName as parentName,rpg.packagePic from cs_lesson as cl inner join lesson as l1 on cl.unitid = l1.lessonid and l1.lessontype = 'U' and l1.status = 1 inner join lesson as l2 on l1.parentid = l2.lessonid and l2.lessontype= 'B' and l2.status = 1 inner join lesson as l3 on l2.parentid = l3.lessonid and l3.lessontype='C' inner join goods as g on g.lessonid = l3.lessonid inner join userownlesson as ul on ul.goodsid= g.goodsid and ul.status =1 and ul.areaid= #{areaId} inner join teacher as tea on tea.teacherid = ul.uid and tea.teacherid= #{teacherId} left join respackage as rpg on rpg.lessonid = l2.lessonid where rpg.coursetype = 'L' and ul.endtime > CURRENT_TIMESTAMP group by l2.lessonId , l2.lessonType , l2.lessonName , l2.parentId , l2.courseCode , l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend, parentName,rpg.packagePic order by lessonId desc
|
|
</select>
|
|
|
|
|
|
<select id="getUserOwnLessonByTeacherIdAll" parameterType="java.util.Map" resultType="Lesson">
|
|
<if test="isAuth!= null">
|
|
with temp as ( SELECT l2.lessonId , l2.lessonType , l2.lessonName , l2.parentId , l2.courseCode ,l2.gradeid, l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend,l3.lessonName as parentName,rpg.packagePic from cs_lesson as cl inner join lesson as l1 on cl.unitid = l1.lessonid and cl.status = 1 and l1.lessontype = 'U' and l1.status = 1 inner join lesson as l2 on l1.parentid = l2.lessonid and l2.lessontype= 'B' and l2.status = 1 inner join lesson as l3 on l2.parentid = l3.lessonid and l3.lessontype='C' inner join goodsownpackage as g on g.lessonid = l2.lessonid inner join userownlesson as ul on ul.goodsid= g.goodsid and ul.status =1 and ul.areaid= #{areaId} inner join teacher as tea on tea.teacherid = ul.uid and tea.teacherid= #{teacherId} left join respackage as rpg on rpg.lessonid = l2.lessonid where rpg.coursetype = 'L' and ul.endtime > CURRENT_TIMESTAMP
|
|
<if test="exincluedBookIds!=null">
|
|
and l2.lessonid not in
|
|
<foreach collection="exincluedBookIds" index="index" item="item" separator="," close=")" open="(">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
group by l2.lessonId , l2.lessonType , l2.lessonName , l2.parentId , l2.courseCode , l2.gradeid,l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend, parentName,rpg.packagePic order by l2.lessonId desc),
|
|
</if>
|
|
|
|
<if test="isAuth == null">
|
|
with temp as (SELECT l2.lessonId , l2.lessonType , l2.lessonName , l2.parentId , l2.courseCode ,l2.gradeid, l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend,l3.lessonName as parentName,rpg.packagePic from cs_lesson as cl inner join lesson as l1 on cl.unitid = l1.lessonid and cl.status = 1 and l1.lessontype = 'U' and l1.status = 1 inner join lesson as l2 on l1.parentid = l2.lessonid and l2.lessontype= 'B' and l2.status = 1 inner join lesson as l3 on l2.parentid = l3.lessonid and l3.lessontype='C' inner join goodsownpackage as g on g.lessonid = l2.lessonid left join respackage as rpg on rpg.lessonid = l2.lessonid where rpg.coursetype = 'L'
|
|
<if test="exincluedBookIds!=null">
|
|
and l2.lessonid not in
|
|
<foreach collection="exincluedBookIds" index="index" item="item" separator="," close=")" open="(">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="goodsIds != null and goodsIds.size != 0">
|
|
and g.goodsid in
|
|
<foreach collection="goodsIds" item="item" open="(" close=")" separator=",">
|
|
#{item.goodsId}
|
|
</foreach>
|
|
</if>
|
|
|
|
group by l2.lessonId , l2.lessonType , l2.lessonName , l2.parentId , l2.courseCode ,l2.gradeid, l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend, parentName,rpg.packagePic order by l2.lessonId desc ),
|
|
</if>
|
|
|
|
|
|
temp1 as ( SELECT l2.lessonId , l2.lessonType , l2.lessonName , l2.parentId , l2.courseCode ,l2.gradeid, l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend,l3.lessonName as parentName,rpg.packagePic from cs_lesson as cl inner join lesson as l1 on cl.unitid = l1.lessonid and cl.status = 1 and l1.lessontype = 'U' and l1.status = 1 inner join lesson as l2 on l1.parentid = l2.lessonid and l2.lessontype= 'B' and l2.status = 1 inner join lesson as l3 on l2.parentid = l3.lessonid and l3.lessontype='C' inner join goodsownpackage as g on g.lessonid = l2.lessonid left join respackage as rpg on rpg.lessonid = l2.lessonid where rpg.coursetype = 'L' and l2.lessonid not in (select lessonid from temp)
|
|
<if test="exincluedBookIds!=null">
|
|
and l2.lessonid not in
|
|
<foreach collection="exincluedBookIds" index="index" item="item" separator="," close=")" open="(">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
group by l2.lessonId , l2.lessonType , l2.lessonName , l2.parentId , l2.courseCode , l2.gradeid,l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend, parentName,rpg.packagePic order by l2.lessonId desc)
|
|
|
|
select * from temp UNION All select * from temp1
|
|
<if test="pageSize != null ">
|
|
limit #{pageSize} offset #{offset}
|
|
</if>
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getUserOwnLessonByTeacherId" parameterType="java.util.Map" resultType="Lesson">
|
|
SELECT l2.lessonId , l2.lessonType , rpg.packagetitle as lessonName , l2.parentId , l2.courseCode , l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , gs.isout as isRecommend,l3.lessonName as parentName,rpg.packagePic,rpg.courseType from lesson as l2 inner join lesson as l3 on l2.parentid = l3.lessonid and l3.lessontype='C' and l2.lessontype= 'B' and l2.status = 1 inner join goodsownpackage as g on g.lessonid = l2.lessonid inner join userownlesson as ul on ul.goodsid= g.goodsid and ul.status =1 and ul.areaid= #{areaId} inner join goods as gs on gs.goodsid = g.goodsid inner join teacher as tea on tea.teacherid = ul.uid and tea.teacherid= #{teacherId} inner join respackage as rpg on rpg.lessonid = l2.lessonid and rpg.coursetype = g.coursetype group by l2.lessonId , l2.lessonType , rpg.packagetitle , l2.parentId , l2.courseCode , l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , gs.isout, parentName,rpg.packagePic,rpg.coursecode,rpg.courseType
|
|
order by rpg.coursecode , l2.orderid,rpg.courseType
|
|
<if test="pageSize != null ">
|
|
limit #{pageSize} offset #{offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getUserOwnLessonByTeacherIdCount" parameterType="java.util.Map" resultType="java.lang.Integer">
|
|
SELECT count(Distinct l2.lessonId) from lesson as l2 inner join lesson as l3 on l2.parentid = l3.lessonid and l3.lessontype='C' and l2.lessontype= 'B' and l2.status = 1 inner join goodsownpackage as g on g.lessonid = l2.lessonid inner join userownlesson as ul on ul.goodsid= g.goodsid and ul.status =1 and ul.areaid= #{areaId} inner join teacher as tea on tea.teacherid = ul.uid and tea.teacherid= #{teacherId} inner join respackage as rpg on rpg.lessonid = l2.lessonid
|
|
</select>
|
|
|
|
<select id="getUserOwnLessonWordByTeacherId" parameterType="java.util.Map" resultType="Lesson">
|
|
|
|
<!-- SELECT l2.lessonId , l2.lessonType , rpg.packagetitle as lessonName , l2.parentId , l2.courseCode , l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend,l3.lessonName as parentName,rpg.packagePic from lesson as l2 inner join lesson as l3 on l2.parentid = l3.lessonid and l3.lessontype='C' and l2.lessontype= 'B' and l2.status = 1 inner join goods as g on g.lessonid = l3.lessonid inner join userownlesson as ul on ul.goodsid= g.goodsid and ul.status =1 and ul.areaid= #{areaId} inner join teacher as tea on tea.teacherid = ul.uid and tea.teacherid= #{teacherId} inner join respackage as rpg on rpg.lessonid = l2.lessonid where rpg.coursetype = 'W' and ul.endtime > CURRENT_TIMESTAMP group by l2.lessonId , l2.lessonType , rpg.packagetitle , l2.parentId , l2.courseCode , l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend, parentName,rpg.packagePic order by lessonId desc -->
|
|
|
|
|
|
SELECT l2.lessonId , l2.lessonType , rpg.packagetitle as lessonName , l2.parentId , l2.courseCode , l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend,l3.lessonName as parentName,rpg.packagePic,rpg.packageName,l2.gradeid ,l2.term from lesson as l2 inner join lesson as l3 on l2.parentid = l3.lessonid and l3.lessontype='C' and l2.lessontype= 'B' and l2.status = 1 inner join goodsownpackage as g on g.lessonid = l2.lessonid inner join userownlesson as ul on ul.goodsid= g.goodsid and ul.status =1 and ul.areaid= #{areaId} inner join teacher as tea on tea.teacherid = ul.uid and tea.teacherid= #{teacherId} inner join respackage as rpg on rpg.lessonid = l2.lessonid where rpg.coursetype = 'W' group by l2.lessonId , l2.lessonType , rpg.packagetitle , l2.parentId , l2.courseCode , l2.description , l2.orderId , l2.status , l2.bigIcon , l2.version , l2.versionNo , l2.url , l2.isRecommend, parentName,rpg.packagePic,rpg.coursecode,rpg.packageName
|
|
order by rpg.coursecode , l2.orderid
|
|
<if test="pageSize != null ">
|
|
limit #{pageSize} offset #{offset}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getParentLessonByKey" parameterType="java.lang.Integer" resultType="java.util.Map">
|
|
|
|
|
|
|
|
with temp as ( SELECT parentId ,lessonId
|
|
FROM Lesson WHERE lessonId=#{lessonId})
|
|
select l.lessonId as unitId, temp.lessonId,lessonType , lessonName , l.parentId as bookId , courseCode , description , orderId , status , bigIcon , version , versionNo , url , isRecommend,l.gradeid,l.term
|
|
FROM Lesson as l inner join temp on l.lessonId=temp.parentId
|
|
</select>
|
|
|
|
<select id="getLessonByCourseCode" parameterType="String" resultType="Lesson">
|
|
|
|
|
|
|
|
SELECT lessonId , lessonType , lessonName , parentId , courseCode , description , orderId , status , bigIcon , version , versionNo , url , isRecommend,assigntime,gradeid,term
|
|
FROM Lesson WHERE courseCode=#{_parameter}
|
|
order by lessonId desc limit 1
|
|
|
|
|
|
</select>
|
|
|
|
<select id="getSeqLesson" resultType="Integer" useCache="false" flushCache="true">
|
|
|
|
|
|
SELECT nextval('seq_lessonId') ;
|
|
|
|
|
|
</select>
|
|
|
|
<select id="getAllLesson" resultType="Lesson">
|
|
|
|
|
|
SELECT lessonId , lessonType , lessonName , parentId , courseCode , description , orderId , status , bigIcon , version , versionNo , url , isRecommend,assigntime,gradeid,term
|
|
FROM Lesson
|
|
|
|
|
|
</select>
|
|
<select id="getLessonsByParentId" parameterType="java.util.Map" resultType="Lesson">
|
|
|
|
|
|
SELECT lessonId , lessonType , lessonName , parentId , courseCode , description , orderId , status , bigIcon , version , versionNo , url , isRecommend,assigntime,gradeid,term
|
|
FROM Lesson
|
|
|
|
WHERE parentId=#{parentId}
|
|
<if test="status!=null">
|
|
and status = #{status}
|
|
</if>
|
|
order by orderId
|
|
|
|
</select>
|
|
|
|
<insert id="insertLessonBatch" parameterType="java.util.List">
|
|
|
|
INSERT INTO Lesson ( lessonId, lessonType, lessonName, parentId, courseCode, description, orderId, status, bigIcon, version, versionNo, url, isRecommend ,assigntime
|
|
|
|
,gradeid
|
|
|
|
,term
|
|
|
|
) Values
|
|
|
|
<foreach collection="list" index="index" item="item" separator=",">
|
|
|
|
( #{item.lessonId}, #{item.lessonType}, #{item.lessonName}, #{item.parentId}, #{item.courseCode}, #{item.description}, #{item.orderId}, #{item.status}, #{item.bigIcon}, #{item.version}, #{item.versionNo}, #{item.url}, #{item.isRecommend} ,#{item.assigntime}
|
|
,#{item.gradeid}
|
|
,#{item.term}
|
|
)
|
|
|
|
</foreach>
|
|
</insert>
|
|
|
|
<delete id="deleteLessonByIds" parameterType="java.util.List">
|
|
|
|
delete from lesson where lessonId in
|
|
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
|
|
</delete>
|
|
</mapper> |