255 lines
12 KiB
XML
255 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.UserHonorDao">
|
||
|
|
<update id= "doUpdateHonor" parameterType="map">
|
||
|
|
update userhonor
|
||
|
|
set totalmoney = totalmoney + #{totalmoney},totalscore = totalscore + #{totalscore},
|
||
|
|
howmuch = howmuch + #{howmuch},totalpoint=totalpoint + #{totalpoint},
|
||
|
|
goldmedalcount=goldmedalcount+#{goldmedalcount},silvermedalcount=silvermedalcount+#{silvermedalcount},
|
||
|
|
bronzemedalcount=bronzemedalcount+#{bronzemedalcount},userlevel=#{userlevel},levelname=#{levelname}
|
||
|
|
where uid=#{uid} and areaid = #{areaid}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<update id= "doUpdateSouthHonor" parameterType="map">
|
||
|
|
update userhonor
|
||
|
|
set jmark=#{jMark,typeHandler=com._3e.http.wrongbook.typehandler.JSONTypeHandlerPg}
|
||
|
|
where uid=#{uid} and areaid = #{areaId}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<update id="doMinusBefollowcount" parameterType="long" >
|
||
|
|
update userhonor set befollowcount = befollowcount -1 where uid=#{uid}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<update id= "doPlusBefollowcount" parameterType="long">
|
||
|
|
update userhonor set befollowcount = befollowcount + 1 where uid= #{uid}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id= "getUserHonorByUid" parameterType="long" resultType="com._3e.entity.UserHonor" >
|
||
|
|
SELECT * FROM UserHonor
|
||
|
|
WHERE uid = #{uid}
|
||
|
|
</select>
|
||
|
|
<select id= "findClassBD" parameterType="map" resultType="com._3e.http.myspace.dto._3EResClassRand" >
|
||
|
|
<!-- A 学霸榜 -->
|
||
|
|
<if test="bdType == 'A'.toString()">
|
||
|
|
SELECT A.*,X.rankvalue,X.userLevel,X.levelName FROM v_studentclass A,
|
||
|
|
(select q.uid , q.totalScore / q.howmuch ::numeric as rankvalue , userLevel , levelName from StudentOwnClass p
|
||
|
|
inner join UserHonor q
|
||
|
|
on p.classesId in
|
||
|
|
<foreach item="item" index="index" collection="classids"
|
||
|
|
open="(" separator="," close=")">
|
||
|
|
#{item}
|
||
|
|
</foreach>
|
||
|
|
and p.studentId = q.uid and p.areaid = #{areaid} and q.areaid = #{areaid}
|
||
|
|
where q.howmuch > 1 and p.status =1
|
||
|
|
order by rankvalue desc , q.howmuch desc ) X
|
||
|
|
WHERE A.STUDENTID = X.UID and X.rankvalue > 0
|
||
|
|
and A.classesid in
|
||
|
|
<foreach item="item" index="index" collection="classids"
|
||
|
|
open="(" separator="," close=")">
|
||
|
|
#{item}
|
||
|
|
</foreach>
|
||
|
|
ORDER BY X.rankvalue desc,A.studentid
|
||
|
|
</if>
|
||
|
|
<!-- B 金牌榜 -->
|
||
|
|
<if test="bdType == 'B'.toString()">
|
||
|
|
SELECT A.*,X.goldmedalcount as rankvalue FROM v_studentclass A,userhonor X
|
||
|
|
where A.STUDENTID = X.UID
|
||
|
|
and X.areaid = #{areaid}
|
||
|
|
and A.classesid in
|
||
|
|
<foreach item="item" index="index" collection="classids"
|
||
|
|
open="(" separator="," close=")">
|
||
|
|
#{item}
|
||
|
|
</foreach>
|
||
|
|
and X.goldmedalcount > 0
|
||
|
|
ORDER BY X.goldmedalcount desc,A.studentid
|
||
|
|
</if>
|
||
|
|
<!-- C 人气榜 -->
|
||
|
|
<if test="bdType == 'C'.toString()">
|
||
|
|
select a.uid , b.truename , b.avatar,b.studentid, m.avgScore as rankvalue,
|
||
|
|
a.userLevel , a.levelName
|
||
|
|
From ( select p.studentId , count(*) as avgScore
|
||
|
|
from StudentOwnClass p inner join FollowShip q
|
||
|
|
on p.classesId in
|
||
|
|
<foreach item="item" index="index" collection="classids"
|
||
|
|
open="(" separator="," close=")">
|
||
|
|
#{item}
|
||
|
|
</foreach>
|
||
|
|
and p.studentId = q.beFollower and p.areaid=#{areaid} and q.areaid = #{areaid}
|
||
|
|
where p.status =1 group by p.studentId order by avgScore desc , p.studentId asc) m
|
||
|
|
inner join UserHonor a on m.studentId = a.uid and a.areaid=#{areaid}
|
||
|
|
inner join Student b on a.uid = b.studentId and b.areaid=#{areaid}
|
||
|
|
ORDER BY m.avgScore desc, b.studentid
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="page != null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
<!-- 班级榜单 -->
|
||
|
|
<select id= "findClassBD_1" parameterType="map" resultType="com._3e.http.myspace.dto._3EResClassRand" >
|
||
|
|
<!-- A 学霸榜 -->
|
||
|
|
<if test="bdType == 'A'.toString()">
|
||
|
|
SELECT A.*,X.rankvalue,X.rankvalue as score,X.userLevel,X.levelName FROM v_studentclass A,
|
||
|
|
(select q.uid , q.totalScore / q.howmuch ::numeric as rankvalue , userLevel , levelName from StudentOwnClass p
|
||
|
|
inner join UserHonor q
|
||
|
|
on p.classesId =#{classids} and p.areaid = #{areaid} and q.areaid = #{areaid}
|
||
|
|
<!--<foreach item="item" index="index" collection="classids"-->
|
||
|
|
<!--open="(" separator="," close=")">-->
|
||
|
|
<!--#{item}-->
|
||
|
|
<!--</foreach>-->
|
||
|
|
where q.howmuch > 1 and p.status =1
|
||
|
|
and p.studentId = q.uid
|
||
|
|
order by rankvalue desc , q.howmuch desc ) X
|
||
|
|
WHERE A.STUDENTID = X.UID and X.rankvalue > 0
|
||
|
|
and A.classesid =#{classids}
|
||
|
|
<!--<foreach item="item" index="index" collection="classids"-->
|
||
|
|
<!--open="(" separator="," close=")">-->
|
||
|
|
<!--#{item}-->
|
||
|
|
<!--</foreach>-->
|
||
|
|
ORDER BY X.rankvalue desc,A.studentid
|
||
|
|
</if>
|
||
|
|
<!-- B 金牌榜 -->
|
||
|
|
<if test="bdType == 'B'.toString()">
|
||
|
|
<if test="time=='month'">
|
||
|
|
select m.howmuch as rankvalue,m.uid,s.truename,sl.schoolName
|
||
|
|
from mv_monthgoldmedal m inner join student s on m.uid=s.studentid
|
||
|
|
and s.areaid = #{areaid}
|
||
|
|
and s.status=1
|
||
|
|
inner join classes c on m.classesid=c.classesid inner join school sl
|
||
|
|
on sl.schoolid=c.schoolid
|
||
|
|
where c.classesId =#{classids}
|
||
|
|
and howmuch > 0
|
||
|
|
ORDER BY howmuch desc,s.studentid desc
|
||
|
|
</if>
|
||
|
|
<if test="time=='week'">
|
||
|
|
select m.howmuch as rankvalue,m.uid,s.truename,sl.schoolName
|
||
|
|
from mv_weekgoldmedal m inner join student s on m.uid=s.studentid
|
||
|
|
and s.areaid = #{areaid}
|
||
|
|
and s.status=1
|
||
|
|
inner join classes c on m.classesid=c.classesid inner join school sl
|
||
|
|
on sl.schoolid=c.schoolid
|
||
|
|
where c.classesId =#{classids}
|
||
|
|
and howmuch > 0
|
||
|
|
ORDER BY howmuch desc,s.studentid desc
|
||
|
|
</if>
|
||
|
|
</if>
|
||
|
|
<!-- C 人气榜 -->
|
||
|
|
<if test="bdType == 'C'.toString()">
|
||
|
|
select a.uid , b.truename , b.avatar,b.studentid, m.avgScore as rankvalue,
|
||
|
|
a.userLevel , a.levelName
|
||
|
|
From ( select p.studentId , count(*) as avgScore
|
||
|
|
from StudentOwnClass p inner join FollowShip q
|
||
|
|
on p.classesId =#{#{classids}}
|
||
|
|
and p.areaid = #{areaid} and q.areaid = #{areaid}
|
||
|
|
and p.studentId = q.beFollower
|
||
|
|
where p.status =1 group by p.studentId order by avgScore desc , p.studentId asc) m
|
||
|
|
inner join UserHonor a on m.studentId = a.uid and a.areaid = #{areaid}
|
||
|
|
inner join Student b on a.uid = b.studentId and b.areaid =#{areaid}
|
||
|
|
ORDER BY m.avgScore desc, b.studentid
|
||
|
|
</if>
|
||
|
|
<!-- D 勤学榜 -->
|
||
|
|
<if test="bdType == 'D'.toString()">
|
||
|
|
<if test="time=='month'">
|
||
|
|
<!--
|
||
|
|
SELECT a.uid,
|
||
|
|
count(a.objectid) AS numCount,st.truename
|
||
|
|
FROM achivement a
|
||
|
|
inner join studentownclass s on a.uid=s.studentId and s.status=1 and s.classesId=#{classids}
|
||
|
|
and (a.pointcasetype = ANY (ARRAY[3, 5, 6, 7, 8]))
|
||
|
|
AND a.created> ( current_date + interval '-1 month') and a.created<current_date
|
||
|
|
inner join student st on a.uid=st.studentid
|
||
|
|
GROUP BY a.uid ,st.truename
|
||
|
|
order by numCount desc ,a.uid
|
||
|
|
limit 10
|
||
|
|
-->
|
||
|
|
select mms.uid,mms.numcount,st.truename from mv_Month_studycount mms
|
||
|
|
inner join studentownclass s on mms.uid=s.studentId
|
||
|
|
and s.areaid = #{areaid}
|
||
|
|
and s.status=1 and s.classesId=#{classids}
|
||
|
|
inner join student st on mms.uid=st.studentid
|
||
|
|
and st.areaid = #{areaid}
|
||
|
|
order by mms.numCount desc ,mms.uid
|
||
|
|
limit 10
|
||
|
|
</if>
|
||
|
|
<if test="time=='week'">
|
||
|
|
<!--
|
||
|
|
SELECT a.uid,
|
||
|
|
count(a.objectid) AS numCount,st.truename
|
||
|
|
FROM achivement a
|
||
|
|
inner join studentownclass s on a.uid=s.studentId and s.status=1 and s.classesId=#{classids}
|
||
|
|
and (a.pointcasetype = ANY (ARRAY[3, 5, 6, 7, 8]))
|
||
|
|
AND a.created> ( current_date + interval '-1 week') and a.created<current_date
|
||
|
|
inner join student st on a.uid=st.studentid
|
||
|
|
GROUP BY a.uid ,st.truename
|
||
|
|
order by numCount desc ,a.uid
|
||
|
|
limit 10
|
||
|
|
-->
|
||
|
|
select mws.uid,mws.numcount,st.truename from mv_Week_studycount mws
|
||
|
|
inner join studentownclass s on mws.uid=s.studentId
|
||
|
|
and s.areaid = #{areaid}
|
||
|
|
and s.status=1 and s.classesId=#{classids}
|
||
|
|
inner join student st on mws.uid=st.studentid
|
||
|
|
and st.areaid = #{areaid}
|
||
|
|
order by mws.numCount desc ,mws.uid
|
||
|
|
limit 10
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<!-- with temp0 as ( select a.uid , a.objectid
|
||
|
|
from achivement a
|
||
|
|
where
|
||
|
|
<if test="time=='week'">
|
||
|
|
a.created> ( current_date + interval '-1 week') and a.created<current_date
|
||
|
|
</if>
|
||
|
|
<if test="time=='month'">
|
||
|
|
a.created> ( current_date + interval '-1 month') and a.created<current_date
|
||
|
|
</if>
|
||
|
|
|
||
|
|
and (a.pointcasetype = ANY (ARRAY[3, 5, 6, 7, 8])) ) ,
|
||
|
|
temp1 as ( select a.uid , a.objectid
|
||
|
|
from studentownclass s
|
||
|
|
inner join temp0 a
|
||
|
|
on s.classesId = #{classids} and s.status=1 and s.studentId = a.uid )
|
||
|
|
select a.uid , count(a.objectid) AS numCount,st.truename
|
||
|
|
from temp1 a inner join student st on a.uid=st.studentid
|
||
|
|
GROUP BY a.uid,st.truename
|
||
|
|
order by numCount desc ,a.uid
|
||
|
|
limit 10 -->
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id= "getLastMonthUserHonorByUid" parameterType="map" resultType="map" >
|
||
|
|
SELECT SUM(a.gold) AS gold, SUM(a.cup) AS cup, SUM(a.emoney) AS emoney
|
||
|
|
FROM (
|
||
|
|
SELECT COUNT(CASE WHEN badgecaseid=4 AND badgetype=1 THEN 1 END )AS gold,
|
||
|
|
COUNT(CASE WHEN badgecaseid=8 AND badgetype=2 THEN 1 END )AS cup,
|
||
|
|
0 AS emoney
|
||
|
|
FROM badgelog
|
||
|
|
WHERE userid = #{uid} AND badgecaseid IN (4,8)
|
||
|
|
AND created >= #{startTime} AND created <= #{endTime}
|
||
|
|
|
||
|
|
UNION
|
||
|
|
|
||
|
|
SELECT 0 AS gold, 0 AS cup, SUM(howmuch) AS emoney
|
||
|
|
FROM emoneylog
|
||
|
|
WHERE uid = #{uid}
|
||
|
|
AND created >= #{startTime} AND created <= #{endTime}
|
||
|
|
) a
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insertUserHonor" parameterType="com._3e.entity.UserHonor">
|
||
|
|
INSERT INTO UserHonor ( uid, totalPoint, userLevel, levelName, totalMoney,
|
||
|
|
goldMedalCount, silverMedalCount, bronzeMedalCount, cupCount, flowerCount,
|
||
|
|
totalScore, howmuch , studyDuration, studyNum, beFollowCount , areaid ) Values
|
||
|
|
( #{uid}, #{totalpoint}, #{userlevel}, #{levelname}, #{totalmoney},
|
||
|
|
#{goldmedalcount}, #{silvermedalcount}, #{bronzemedalcount}, #{cupcount}, #{flowercount},
|
||
|
|
#{totalscore}, #{howmuch} , #{studyduration}, #{studynum}, #{befollowcount} , #{areaid})
|
||
|
|
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<delete id="deleteuserHonorById" parameterType="long">
|
||
|
|
delete from UserHonor where uid = #{studentId}
|
||
|
|
</delete>
|
||
|
|
</mapper>
|