2026-03-10 14:30:24 +08:00

144 lines
5.8 KiB
XML

<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Wed Jul 11 17:43:20 CST 2018-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="UnivOwnLesson">
<insert id="insertUnivOwnLesson" parameterType="UnivOwnLesson">
INSERT INTO UnivOwnLesson ( schoolId, goodsId, startTime,
endTime, status , areaid )
Values ( #{schoolId}, #{goodsId}, #{startTime},
#{endTime}, #{status} , #{areaId} )
</insert>
<update id="updateUnivOwnLesson" parameterType="UnivOwnLesson">
UPDATE UnivOwnLesson
SET schoolId = #{schoolId}, goodsId = #{goodsId},
startTime = #{startTime},
endTime = #{endTime}, status = #{status} , areaid = #{areaId}
WHERE schoolId=#{schoolId}
AND goodsId=#{goodsId}
AND areaid = #{areaId}
</update>
<select id="getUnivOwnLessonByKey" parameterType="java.util.Map" resultType="UnivOwnLesson">
SELECT schoolId , goodsId , startTime , endTime , status , areaid
FROM UnivOwnLesson
WHERE schoolId=#{schoolId}
AND goodsId=#{goodsId}
</select>
<insert id="insertUnivOwnLessonBatch" parameterType="java.util.List">
INSERT INTO UnivOwnLesson ( schoolId, goodsId, startTime,
endTime, status , areaid )
VALUES
<foreach collection="list" index="index" item="item" separator=",">
( #{item.schoolId}, #{item.goodsId},
#{item.startTime}, #{item.endTime},
#{item.status} , #{item.areaId} )
</foreach>
</insert>
<select id="getUnivOwnLessonBySchoolId" parameterType="java.util.Map" resultType="UserOwnLessonDto">
SELECT schoolId as uid , u.goodsId , g.goodsname ,g.price,
u.startTime , u.endTime , u.status , areaid
FROM UnivOwnLesson u
INNER JOIN goods g
ON g.goodsid = u.goodsid
WHERE u.schoolId=#{schoolId}
ORDER BY goodsId
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
</select>
<select id="getUnivGoodsCatesBySchoolIdByCateId" parameterType="java.util.HashMap" resultType="java.util.HashMap">
SELECT distinct(goodsid) , goodsname, goodspic , coursetype ,coursecode , packagepic,
packagename, packagetitle,lessonid, version , versionno
FROM v_univcategoodspack
WHERE schoolId=#{schoolId} and cateid = #{cateId} and language!='zh'
order by goodsid
</select>
<select id="getUnivHotGoodsBySchoolId" parameterType="java.lang.Long" resultType="java.util.HashMap">
SELECT distinct(goodsid) , goodsname, goodspic , coursetype ,coursecode , packagepic,
packagename, packagetitle,lessonid, version , versionno
FROM v_univcategoodspack
WHERE schoolId=#{schoolId} and ishot = 1
order by goodsid
</select>
<select id="getUnivOwnLessonCountByUid" parameterType="Long" resultType="Integer">
select count(*) from UnivOwnLesson where schoolId = #{schoolId}
</select>
<delete id="removeRepeatUnivOwnLesson" parameterType="java.util.Map">
DELETE FROM UnivOwnLesson
WHERE schoolId = #{schoolId}
AND GoodsId in
<foreach collection="goodsIds" item="item" separator="," close=")" open="(">
#{item}
</foreach>
</delete>
<select id="getUnivRequentlyGoodsBySchoolIdAndUserId" parameterType="java.util.HashMap" resultType="java.util.HashMap">
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&gt;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&gt;now()-interval '1 month' and achivetype='W'
group by l.parentid,achiveType )
SELECT distinct(v.goodsid) , v.goodsname, v.goodspic , v.coursetype as "coursetype" ,v.coursecode as "courseCode" , v.packagepic,
v.packagename, v.packagetitle as "lessonName",v.lessonid as "lessonId", v.version , v.versionno as "versionNo" , t.howmuch ,v.cateid as "cateId"
FROM v_univcategoodspack v
inner join temp t
on schoolId=#{schoolId} and v.lessonid=t.lessonid and v.courseType=t.achiveType and v.language!='zh'
order by t.howmuch,v.goodsid
<if test="pageSize!=null">
limit #{pageSize}
</if>
<if test="offset!=null">
offset #{offset}
</if>
</select>
<select id="getUnivRequentlyGoodsCountBySchoolIdAndUserId" parameterType="java.util.HashMap" resultType="java.lang.Integer">
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&gt;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&gt;now()-interval '1 month' and achivetype='W'
group by l.parentid,achiveType )
select count(*) from (SELECT distinct v.lessonid, courseType
FROM v_univcategoodspack v inner join temp t
on schoolId=#{schoolId} and v.lessonid=t.lessonid and v.courseType=t.achiveType and v.language!='zh'
) as a
</select>
</mapper>