305 lines
12 KiB
XML
305 lines
12 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="com._3e.dao.ResPackageDao">
|
||
|
|
<select id= "findResPackageByUID" parameterType="map" resultType="com._3e.entity.ResPackage" >
|
||
|
|
SELECT R.*
|
||
|
|
FROM ResPackage R,(
|
||
|
|
SELECT * from goodsownpackage g,userownlesson u
|
||
|
|
where g.goodsid = u.goodsid and u.uid = #{uid}
|
||
|
|
) T,lesson L
|
||
|
|
WHERE R.lessonid = T.lessonid AND R.lessonid = L.lessonid AND R.COURSETYPE = T.COURSETYPE
|
||
|
|
<if test="title != null">
|
||
|
|
AND R.packagetitle like '%'||#{title}||'%'
|
||
|
|
</if>
|
||
|
|
group by R.lessonid,R.COURSETYPE,L.orderid
|
||
|
|
ORDER BY L.orderid
|
||
|
|
<if test="page != null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
<select id= "findMyBooks" parameterType="map" resultType="com._3e.entity.VUserBook" >
|
||
|
|
|
||
|
|
<!-- select distinct * from v_userownbook2 where uid = #{uid}
|
||
|
|
<if test="title != null">
|
||
|
|
AND lessonname like '%'||#{title}||'%'
|
||
|
|
</if>
|
||
|
|
<if test="courseType != null">
|
||
|
|
AND coursetype = #{courseType}
|
||
|
|
</if>
|
||
|
|
order by coursecode,orderid,coursetype
|
||
|
|
<if test="page != null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if> -->
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
with temp as(select b.unitid,a.assigntype from assignment a inner join assigndetail b on
|
||
|
|
a.assignmentid=b.assignmentid and a.teacherid=#{uid}
|
||
|
|
|
||
|
|
<if test="courseType != null">
|
||
|
|
AND a.assigntype = #{courseType}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
order by created desc
|
||
|
|
limit 1),
|
||
|
|
temp2 as (select parentid,assigntype from lesson a inner join temp b on a.lessonid =b.unitid )
|
||
|
|
|
||
|
|
select distinct a.*,b.parentid,lsn.lessonname as category from v_userownbook2 a
|
||
|
|
left join temp2 b on a.lessonid=b.parentid and a.coursetype = b.assigntype
|
||
|
|
INNER JOIN lesson ls on a.lessonid = ls.lessonid
|
||
|
|
INNER JOIN lesson lsn on ls.parentid = lsn.lessonid
|
||
|
|
where a.uid =#{uid}
|
||
|
|
<if test="title != null">
|
||
|
|
AND lessonname like '%'||#{title}||'%'
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="courseType != null">
|
||
|
|
AND a.coursetype = #{courseType}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
order by b.parentid desc nulls last,coursecode,orderid,coursetype
|
||
|
|
<if test="page != null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
<select id= "findMyBooks_1" parameterType="map" resultType="com._3e.entity.VUserBook" >
|
||
|
|
select distinct lessonid,lessonname,coursetype,coursecode,orderid,packagepic,version,versionno,url,isrecommend,bookname,mobilpic,isout,ispicture,iscn
|
||
|
|
from v_userownbook2 where uid = #{uid}
|
||
|
|
-- and endtime>now()
|
||
|
|
<if test="title != null">
|
||
|
|
AND lessonname like '%'||#{title}||'%'
|
||
|
|
</if>
|
||
|
|
<if test="courseType != null">
|
||
|
|
AND coursetype = #{courseType}
|
||
|
|
</if>
|
||
|
|
<if test="isout == 0 or isout== 1">
|
||
|
|
AND isout = #{isout}
|
||
|
|
</if>
|
||
|
|
order by coursecode,orderid,coursetype,lessonname desc
|
||
|
|
<if test="page != null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id= "findMyBookByBookID" parameterType="map" resultType="com._3e.entity.VUserBook" >
|
||
|
|
select distinct uid,lessonid,lessonname,coursetype,coursecode,orderid,packagepic,version,versionno,url,isrecommend,bookname,mobilpic,ispicture,iscn from v_userownbook2
|
||
|
|
where uid = #{uid} and coursetype = #{courseType} and lessonid = #{bookId}
|
||
|
|
order by coursecode,orderid,coursetype limit 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id= "findResPackageByBookID" parameterType="map" resultType="com._3e.entity.ResPackage" >
|
||
|
|
SELECT * FROM ResPackage
|
||
|
|
WHERE lessonid = #{bookId} and coursetype = #{courseType}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="findGoodsRes" parameterType="int" resultType="com._3e.entity.ResPackage" >
|
||
|
|
SELECT b.* FROM GoodsOwnPackage a
|
||
|
|
INNER JOIN ResPackage b ON a.lessonId = b.lessonId and a.courseType = b.courseType
|
||
|
|
WHERE a.goodsId=#{goodsid}
|
||
|
|
ORDER BY a.lessonId , a.courseType
|
||
|
|
</select>
|
||
|
|
<!-- 常用课程-->
|
||
|
|
<!--List<VUserBook> getCommonCourse(Map<String,Object> map)-->
|
||
|
|
<select id="getCommonCourse" parameterType="map" resultType="com._3e.entity.VUserBook">
|
||
|
|
with temp as (
|
||
|
|
select count(a.objectid) howmuch,l1.parentid lessonid,achiveType from achivement a
|
||
|
|
inner join lesson l on a.objectid=l.lessonid and
|
||
|
|
a.uid=#{uid} and a.created>now()-interval '1 month' and achivetype='L'
|
||
|
|
inner join lesson l1 on l.parentid=l1.lessonid
|
||
|
|
group by l1.parentid,achiveType
|
||
|
|
union all
|
||
|
|
select count(a.objectid) howmuch,l.parentid lessonid,achiveType from achivement a
|
||
|
|
inner join lesson l on a.objectid=l.lessonid
|
||
|
|
and a.uid=#{uid} and a.created>now()-interval '1 month' and achivetype='W'
|
||
|
|
group by l.parentid,achiveType )
|
||
|
|
SELECT distinct uid,mobilpic, v.lessonid, lessonname, courseType,
|
||
|
|
coursecode, orderid, packagePic , version,
|
||
|
|
versionNo, url, isrecommend,isOut,howmuch
|
||
|
|
FROM v_userownBook2 v
|
||
|
|
<if test="isAll==null">
|
||
|
|
inner join
|
||
|
|
</if>
|
||
|
|
<if test="isAll!=null">
|
||
|
|
left join
|
||
|
|
</if>
|
||
|
|
|
||
|
|
temp t on v.lessonid=t.lessonid and v.courseType=t.achiveType
|
||
|
|
|
||
|
|
WHERE uid = #{uid}
|
||
|
|
<!--<if test="title != null">
|
||
|
|
and v.lessonname like '%'||#{title}||'%'
|
||
|
|
</if>-->
|
||
|
|
order by howmuch desc nulls last,coursecode , orderid , courseType,lessonname desc
|
||
|
|
<if test="page != null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<select id= "findUniversityBookByBookID" parameterType="map" resultType="com._3e.entity.VUserBook" >
|
||
|
|
|
||
|
|
SELECT distinct a.schoolid uid,
|
||
|
|
b.lessonid,
|
||
|
|
c.packagetitle AS lessonname,
|
||
|
|
c.coursetype,
|
||
|
|
c.coursecode,
|
||
|
|
b.orderid,
|
||
|
|
c.packagepic,
|
||
|
|
c.version,
|
||
|
|
c.versionno,
|
||
|
|
c.packagename AS url,
|
||
|
|
b.isrecommend,
|
||
|
|
b.lessonname AS bookname,
|
||
|
|
c.mobilpic,
|
||
|
|
m.isout ,
|
||
|
|
c.language,
|
||
|
|
e.cateid
|
||
|
|
FROM univownlesson a
|
||
|
|
JOIN goods m ON a.goodsid = m.goodsid and a.schoolid = #{uid}
|
||
|
|
JOIN goodsownpackage n ON a.goodsid = n.goodsid
|
||
|
|
JOIN respackage c ON n.lessonid = c.lessonid AND n.coursetype::text = c.coursetype::text
|
||
|
|
and c.coursetype = #{courseType}
|
||
|
|
JOIN lesson b ON c.lessonid = b.lessonid AND b.status = 1 and b.lessonid = #{bookId}
|
||
|
|
JOIN univcateowngoods e ON a.goodsid = e.goodsid
|
||
|
|
WHERE a.starttime <= now()
|
||
|
|
order by e.cateid desc limit 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getUnivCommonCourse" parameterType="map" resultType="com._3e.entity.VUserBook">
|
||
|
|
|
||
|
|
with temp as (
|
||
|
|
select count(a.objectid) howmuch,l1.parentid lessonid,achiveType from univachivement a
|
||
|
|
inner join lesson l on a.objectid=l.lessonid and
|
||
|
|
a.uid=#{uid} and a.created>now()-interval '1 month' and achivetype='L'
|
||
|
|
inner join lesson l1 on l.parentid=l1.lessonid
|
||
|
|
group by l1.parentid,achiveType
|
||
|
|
union all
|
||
|
|
select count(a.objectid) howmuch,l.parentid lessonid,achiveType from univachivement a
|
||
|
|
inner join lesson l on a.objectid=l.lessonid
|
||
|
|
and a.uid=#{uid} and a.created>now()-interval '1 month' and achivetype='W'
|
||
|
|
group by l.parentid,achiveType )
|
||
|
|
SELECT distinct(v.goodsid) ,v.mobilpic,v.lessonid, packagetitle as lessonname, v.coursetype ,v.coursecode
|
||
|
|
,packagePic,v.version , v.versionno , t.howmuch ,v.packagename as url , v.language ,v.cateid
|
||
|
|
FROM v_univcategoodspack v
|
||
|
|
inner join temp t
|
||
|
|
on schoolId=#{schoolId} and v.lessonid=t.lessonid and v.courseType=t.achiveType
|
||
|
|
order by t.howmuch,v.goodsid
|
||
|
|
<if test="page != null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getLlessonid" parameterType="map" resultType="com._3e.http.achivement.dto.MyLessionDto">
|
||
|
|
select s.lessonid,s.achivetype,s.created from
|
||
|
|
(select l1.parentid lessonid,a.created,a.achivetype,ROW_NUMBER() over(partition by l1.parentid order by a.created desc) new_index from achivement a
|
||
|
|
inner join lesson l on a.objectid=l.lessonid and
|
||
|
|
a.uid=#{uid}
|
||
|
|
and a.areaid=#{areaid}
|
||
|
|
and a.created>#{created} and a.created < #{createdEnd} and achivetype='L' and pointcasetype !=2
|
||
|
|
inner join lesson l1 on l.parentid=l1.lessonid) s where s.new_index=1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getWlessonid" parameterType="map" resultType="com._3e.http.achivement.dto.MyLessionDto">
|
||
|
|
select s.lessonid,s.achivetype,s.created from
|
||
|
|
(select l.parentid lessonid,a.created,a.achivetype,ROW_NUMBER() over(partition by l.parentid order by a.created desc) new_index from achivement a
|
||
|
|
inner join lesson l on a.objectid=l.lessonid
|
||
|
|
and a.uid=#{uid}
|
||
|
|
and a.areaid = #{areaid}
|
||
|
|
and a.created>#{created} and a.created < #{createdEnd} and achivetype='W') s where s.new_index=1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getCommonCourse_1" parameterType="map" resultType="com._3e.entity.VUserBook">
|
||
|
|
SELECT uid,mobilpic, v.lessonid, lessonname, courseType,
|
||
|
|
coursecode, orderid, packagePic , version,
|
||
|
|
versionNo, url, isrecommend,isOut,ispicture,iscn
|
||
|
|
FROM v_userownBook2 v
|
||
|
|
where v.lessonid=#{lessonid} and v.courseType=#{achivetype}
|
||
|
|
and uid = #{uid}
|
||
|
|
limit 1
|
||
|
|
</select>
|
||
|
|
<resultMap id="gradeBookListMap" type="com._3e.http.practice.dto.ResXKWGradeBook">
|
||
|
|
<result column="grade" property="grade" />
|
||
|
|
<result column="id" property="id" />
|
||
|
|
<collection property="bookList" ofType="com._3e.http.practice.dto.XKWBook">
|
||
|
|
<result column="bookName" property="bookName"/>
|
||
|
|
<result column="bookId" property="bookId"/>
|
||
|
|
<result column="category" property="category"/>
|
||
|
|
<result column="versionId" property="versionId"/>
|
||
|
|
</collection>
|
||
|
|
</resultMap>
|
||
|
|
<select id="getGradeAndBooksV1" resultMap="gradeBookListMap">
|
||
|
|
select CASE
|
||
|
|
WHEN ls.term = 'LAST' THEN -(ls.gradeId * 10 + 1)
|
||
|
|
WHEN ls.term = 'NEXT' THEN -(ls.gradeId * 10 + 2)
|
||
|
|
WHEN ls.term = 'ALL' THEN -(ls.gradeId * 10 + 3)
|
||
|
|
WHEN ls.term = '' THEN -(ls.gradeId * 10 + 3)
|
||
|
|
ELSE g.lessonId
|
||
|
|
END AS id,
|
||
|
|
CASE
|
||
|
|
WHEN ls.gradeid = 0 THEN '其它'
|
||
|
|
ELSE CONCAT(
|
||
|
|
CASE ls.gradeid
|
||
|
|
WHEN 1 THEN '一年级'
|
||
|
|
WHEN 2 THEN '二年级'
|
||
|
|
WHEN 3 THEN '三年级'
|
||
|
|
WHEN 4 THEN '四年级'
|
||
|
|
WHEN 5 THEN '五年级'
|
||
|
|
WHEN 6 THEN '六年级'
|
||
|
|
WHEN 7 THEN '七年级'
|
||
|
|
WHEN 8 THEN '八年级'
|
||
|
|
WHEN 9 THEN '九年级'
|
||
|
|
WHEN 10 THEN '高一年级'
|
||
|
|
WHEN 11 THEN '高二年级'
|
||
|
|
WHEN 12 THEN '高三年级'
|
||
|
|
ELSE '未知年级'
|
||
|
|
END,
|
||
|
|
CASE ls.term
|
||
|
|
WHEN 'LAST' THEN '上册'
|
||
|
|
WHEN 'NEXT' THEN '下册'
|
||
|
|
ELSE '全册'
|
||
|
|
END
|
||
|
|
)
|
||
|
|
END AS grade,ls.lessonName bookName,ls.lessonId AS bookId,lsn.lessonid AS versionId,lsn.lessonname as category from v_userownbook2 g
|
||
|
|
INNER JOIN lesson ls on g.lessonid = ls.lessonid
|
||
|
|
INNER JOIN lesson lsn on ls.parentid = lsn.lessonid
|
||
|
|
where g.uid=#{uid} and coursetype = 'L' ORDER BY (CASE
|
||
|
|
WHEN (CASE
|
||
|
|
WHEN ls.term = 'LAST' THEN -(ls.gradeId * 10 + 1)
|
||
|
|
WHEN ls.term = 'NEXT' THEN -(ls.gradeId * 10 + 2)
|
||
|
|
WHEN ls.term = 'ALL' THEN -(ls.gradeId * 10 + 3)
|
||
|
|
WHEN ls.term = '' THEN -(ls.gradeId * 10 + 3)
|
||
|
|
ELSE g.lessonId
|
||
|
|
END) BETWEEN -10 AND 0 THEN 1
|
||
|
|
ELSE 0 END),id DESC
|
||
|
|
</select>
|
||
|
|
<select id="findLastAssignBookByTeacherId" resultType="com._3e.entity.VUserBook">
|
||
|
|
with temp as(select b.unitid,a.assigntype from assignment a inner join assigndetail b on
|
||
|
|
a.assignmentid=b.assignmentid and a.teacherid=#{uid}
|
||
|
|
<if test="courseType != null">
|
||
|
|
AND a.assigntype = #{courseType}
|
||
|
|
</if>
|
||
|
|
order by created desc limit 1)
|
||
|
|
select parentid lessonid,assigntype from lesson a inner join temp b on a.lessonid =b.unitid
|
||
|
|
</select>
|
||
|
|
<select id="findLastAssignBookByTeacherIdAndClasses" resultType="com._3e.entity.VUserBook">
|
||
|
|
with temp as(select b.unitid,a.assigntype from assigntoclass ac INNER JOIN
|
||
|
|
assignment a on ac.assignmentid = a.assignmentid inner join assigndetail b on
|
||
|
|
a.assignmentid=b.assignmentid and a.teacherid=#{uid}
|
||
|
|
and ac.classesid in
|
||
|
|
<foreach item="classesId" collection="classesList" separator="," open="(" close=")">
|
||
|
|
#{classesId}
|
||
|
|
</foreach>
|
||
|
|
<if test="courseType != null">
|
||
|
|
AND a.assigntype = #{courseType}
|
||
|
|
</if>
|
||
|
|
order by created desc limit 1)
|
||
|
|
select parentid lessonid,assigntype from lesson a inner join temp b on a.lessonid =b.unitid
|
||
|
|
</select>
|
||
|
|
</mapper>
|
||
|
|
|