205 lines
6.4 KiB
XML
205 lines
6.4 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="UnivRace">
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<insert id="insertUnivRace" parameterType="UnivRace">
|
||
|
|
INSERT INTO UnivRace ( raceId, raceName, holder, raceType, description,
|
||
|
|
startTime, endTime, joinRace, credential, badge, reward, timeLength,
|
||
|
|
content, status, created, raceAreaId, origiVoice, banner , title ,groupLevel,signupUrl,isPlay)
|
||
|
|
Values ( #{raceId}, #{raceName}, #{holder}, #{raceType},
|
||
|
|
#{description}, #{startTime}, #{endTime}, #{joinRace}, #{credential},
|
||
|
|
#{badge}, #{reward}, #{timeLength}, #{content},
|
||
|
|
#{status},current_timestamp, #{raceAreaId}, #{origiVoice}, #{banner} ,
|
||
|
|
#{title},#{groupLevel},#{signupUrl},#{isPlay} )
|
||
|
|
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateUnivRace" parameterType="UnivRace">
|
||
|
|
|
||
|
|
|
||
|
|
UPDATE UnivRace SET
|
||
|
|
|
||
|
|
raceId = #{raceId}, raceName = #{raceName}, holder = #{holder}, raceType =
|
||
|
|
#{raceType}, description = #{description}, startTime = #{startTime},
|
||
|
|
endTime = #{endTime}, joinRace = #{joinRace}, credential =
|
||
|
|
#{credential}, badge = #{badge}, reward = #{reward}, timeLength =
|
||
|
|
#{timeLength}, content = #{content}, status = #{status}, created =
|
||
|
|
#{created}, raceAreaId = #{raceAreaId}, origiVoice = #{origiVoice},
|
||
|
|
banner = #{banner} , title = #{title}, groupLevel = #{groupLevel} ,signupUrl=#{signupUrl},isPlay=#{isPlay}
|
||
|
|
where raceId=#{raceId}
|
||
|
|
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="getUnivRaceByKey" parameterType="java.lang.Integer"
|
||
|
|
resultType="UnivRace">
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
SELECT raceId , raceName , holder , raceType , description , startTime ,
|
||
|
|
endTime , joinRace , credential , badge , reward , timeLength ,
|
||
|
|
content , status , created , raceAreaId , origiVoice , banner , title , groupLevel,signupUrl,isPlay
|
||
|
|
FROM UnivRace WHERE raceId=#{raceId}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getSeqUnivRace" resultType="Integer" useCache="false"
|
||
|
|
flushCache="true">
|
||
|
|
|
||
|
|
SELECT nextval('seq_univRaceId') ;
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getUnivRacesCount" parameterType="java.lang.Integer"
|
||
|
|
resultType="Integer">
|
||
|
|
SELECT COUNT(*)
|
||
|
|
FROM UnivRace
|
||
|
|
WHERE status = 1
|
||
|
|
<if test="value==null">
|
||
|
|
<![CDATA[
|
||
|
|
and current_timestamp < endTime
|
||
|
|
]]>
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivRaces" parameterType="java.util.Map"
|
||
|
|
resultType="UnivRace">
|
||
|
|
SELECT raceId , raceName , holder , raceType , description , startTime
|
||
|
|
, endTime , joinRace , credential , badge ,
|
||
|
|
reward , timeLength , content , status , created , raceAreaId , origiVoice ,
|
||
|
|
banner , title ,groupLevel,signupUrl
|
||
|
|
FROM UnivRace
|
||
|
|
WHERE status = 1
|
||
|
|
<if test="status==null">
|
||
|
|
<![CDATA[
|
||
|
|
and current_timestamp < endTime
|
||
|
|
]]>
|
||
|
|
</if>
|
||
|
|
ORDER BY raceId DESC
|
||
|
|
<if test="pageSize!=null"> LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="joinedUnivRacesCount" parameterType="Long"
|
||
|
|
resultType="Integer">
|
||
|
|
SELECT count(distinct(b.raceId))
|
||
|
|
FROM ( SELECT distinct a.raceId
|
||
|
|
FROM UnivRaceScore a
|
||
|
|
WHERE a.uid = #{uid} )a
|
||
|
|
INNER JOIN UnivRace b
|
||
|
|
ON a.raceId = b.raceId
|
||
|
|
and b.endTime > current_timestamp
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="joinedUnivRaces" parameterType="java.util.Map"
|
||
|
|
resultType="UnivRace">
|
||
|
|
SELECT b.raceId , b.raceName , b.holder , b.raceType , b.description ,
|
||
|
|
b.startTime , b.endTime , b.joinRace , b.credential , b.badge ,
|
||
|
|
b.reward , b.timeLength , b.content , b.status , b.created ,
|
||
|
|
b.raceAreaId , b.origiVoice , b.banner , b.title ,b.groupLevel ,b.signupUrl
|
||
|
|
FROM ( SELECT distinct a.raceId
|
||
|
|
FROM UnivRaceScore a
|
||
|
|
WHERE a.uid = #{uid} )a
|
||
|
|
INNER JOIN UnivRace b
|
||
|
|
ON a.raceId = b.raceId
|
||
|
|
and b.endTime > current_timestamp
|
||
|
|
ORDER BY raceId DESC
|
||
|
|
<if test="pageSize!=null"> LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="checkSchoolUnivRaceValidByStudentId" parameterType="java.util.Map"
|
||
|
|
resultType="Integer">
|
||
|
|
|
||
|
|
select count(*) from univownrace c inner join univrace d
|
||
|
|
on c.raceid=d.raceid where d.raceid= #{raceId} and c.schoolid =
|
||
|
|
(select
|
||
|
|
schoolid from univstudent
|
||
|
|
where studentid = #{studentid} )
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="checkSchoolUnivRaceValidByTeacherId" parameterType="java.util.Map"
|
||
|
|
resultType="Integer">
|
||
|
|
|
||
|
|
select count(*) from univownrace c inner join univrace d
|
||
|
|
on c.raceid=d.raceid where d.raceid= #{raceId} and c.schoolid =
|
||
|
|
(select
|
||
|
|
schoolid from univteacher
|
||
|
|
where teacherid = #{teacherId} )
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getFinishUnivRace" resultType="Integer">
|
||
|
|
|
||
|
|
select raceId from UnivRace where endTime < current_timestamp and endTime
|
||
|
|
> current_timestamp - interval '1 day'
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivQTRaces" resultType="UnivRace" parameterType="Integer">
|
||
|
|
select raceId ,raceName,holder,raceType,description,startTime,endTime,joinRace,credential,badge,reward,timeLength
|
||
|
|
,content,status,created,raceAreaId,origiVoice,banner,title,groupLevel from UnivRace where raceType = #{raceType} and now()>= startTime and endTime>=now() order by raceId desc
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="addRaceUsers" parameterType="java.util.List">
|
||
|
|
INSERT INTO Parameter (paraId,valueStr,paraInt,paraLong,created,status,description,paraType) values
|
||
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
||
|
|
(nextval('seq_parameterid'),#{item.valueStr},#{item.paraInt},#{item.paraLong},#{item.created},#{item.status},#{item.educationStatus},#{item.paramType})
|
||
|
|
</foreach>
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getUnivRaceQTUser" resultType="QTRaceUsersVO" parameterType="java.util.Map">
|
||
|
|
SELECT
|
||
|
|
u.studentId,
|
||
|
|
truename,
|
||
|
|
nickname,
|
||
|
|
gender,
|
||
|
|
-- a.valuestr,
|
||
|
|
u.recognizeCode,
|
||
|
|
a.description,
|
||
|
|
a.created,
|
||
|
|
ucls.classname,
|
||
|
|
uvs.schoolname
|
||
|
|
FROM
|
||
|
|
Parameter AS a
|
||
|
|
INNER JOIN univstudent AS u ON a.paraLong = u.studentid
|
||
|
|
left JOIN univstudentownclass usoc ON usoc.studentid = u.studentid
|
||
|
|
left JOIN univclasses ucls ON ucls.classesid = usoc.classesid
|
||
|
|
left JOIN university AS uvs ON uvs.schoolid = ucls.schoolid
|
||
|
|
WHERE
|
||
|
|
a.paraInt = #{raceId}
|
||
|
|
|
||
|
|
ORDER BY created DESC
|
||
|
|
lIMIT #{pageSize} OFFSET #{pageNum}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getUnivRaceQTUserCount" resultType="Integer" parameterType="Integer">
|
||
|
|
SELECT
|
||
|
|
count(u.studentId)
|
||
|
|
FROM
|
||
|
|
Parameter AS a
|
||
|
|
INNER JOIN univstudent AS u ON a.paraLong = u.studentid
|
||
|
|
INNER JOIN univstudentownclass usoc ON usoc.studentid = u.studentid
|
||
|
|
INNER JOIN univclasses ucls ON ucls.classesid = usoc.classesid
|
||
|
|
INNER JOIN university AS uvs ON uvs.schoolid = ucls.schoolid
|
||
|
|
WHERE
|
||
|
|
a.paraInt = #{raceId}
|
||
|
|
</select>
|
||
|
|
</mapper>
|