310 lines
13 KiB
XML
310 lines
13 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="UnivStudent">
|
||
|
|
|
||
|
|
<insert id="insertUnivStudent" parameterType="UnivStudent">
|
||
|
|
INSERT INTO UnivStudent ( studentId, password, truename, nickname,
|
||
|
|
gender, address, areaId, recognizeCode, cellphone, telephone,
|
||
|
|
email, avatar, status, source , schoolid , department , qq ,signature)
|
||
|
|
Values ( #{studentId}, #{password}, #{truename}, #{nickname},
|
||
|
|
#{gender}, #{address}, #{areaId}, #{recognizeCode}, #{cellphone},
|
||
|
|
#{telephone}, #{email}, #{avatar}, #{status}, #{source} ,
|
||
|
|
#{schoolId} , #{department} , #{qq},#{signature} )
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateUnivStudent" parameterType="UnivStudent">
|
||
|
|
UPDATE UnivStudent
|
||
|
|
SET studentId = #{studentId}, truename = #{truename},
|
||
|
|
nickname = #{nickname}, gender = #{gender}, address = #{address},
|
||
|
|
areaId = #{areaId}, recognizeCode = #{recognizeCode},
|
||
|
|
cellphone = #{cellphone}, telephone = #{telephone},
|
||
|
|
email = #{email}, status = #{status}, source = #{source} ,
|
||
|
|
lastSignIn = #{lastSignIn} ,
|
||
|
|
schoolid = #{schoolId} , department = #{department} , qq = #{qq},signature=#{signature}
|
||
|
|
where studentId=#{studentId}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="getUnivStudentByKey" parameterType="java.lang.Long" resultType="UnivStudent">
|
||
|
|
SELECT studentId , password , truename , nickname , gender , address ,
|
||
|
|
areaId , recognizeCode , cellphone , telephone , email , avatar ,
|
||
|
|
status , source , schoolId , lastSignIn , department , qq,signature
|
||
|
|
FROM UnivStudent
|
||
|
|
WHERE studentId=#{studentId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivStudentByCode" parameterType="java.lang.String" resultType="UnivStudent">
|
||
|
|
SELECT studentId , password , truename , nickname , gender , address ,
|
||
|
|
areaId , recognizeCode , cellphone , telephone , email , avatar ,
|
||
|
|
status , source , schoolId , lastSignIn , department , qq,signature
|
||
|
|
FROM UnivStudent
|
||
|
|
WHERE recognizeCode = #{_parameter}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getSeqUnivStudent" resultType="Integer" useCache="false" flushCache="true">
|
||
|
|
SELECT nextval('seq_univstudentId') ;
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getAllUnivStudent" resultType="UnivStudent">
|
||
|
|
SELECT studentId , password , truename , nickname , gender , address ,
|
||
|
|
areaId , recognizeCode , cellphone , telephone , email , avatar ,
|
||
|
|
status , source , schoolId , lastSignIn , department , qq,signature
|
||
|
|
FROM UnivStudent
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insertUnivStudentBatch" parameterType="java.util.List">
|
||
|
|
INSERT INTO UnivStudent ( studentId , password , truename , nickname ,
|
||
|
|
gender , address , areaId , recognizeCode , cellphone , telephone ,
|
||
|
|
email , avatar , status , source , schoolId ,
|
||
|
|
department , qq ) Values
|
||
|
|
<foreach collection="list" index="index" item="item" separator=",">
|
||
|
|
( #{item.studentId} , #{item.password} ,
|
||
|
|
#{item.truename} , #{item.nickname} ,
|
||
|
|
#{item.gender} , #{item.address} ,
|
||
|
|
#{item.areaId} , #{item.recognizeCode} ,
|
||
|
|
#{item.cellphone} , #{item.telephone} ,
|
||
|
|
#{item.email} , #{item.avatar} ,
|
||
|
|
1 , 1 ,
|
||
|
|
#{item.schoolId} ,
|
||
|
|
#{item.department} , #{item.qq} )
|
||
|
|
</foreach>
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateUnivStudentPassword" parameterType="java.util.Map">
|
||
|
|
UPDATE UnivStudent
|
||
|
|
SET password = #{password}
|
||
|
|
where studentId=#{studentId}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<update id="updateUnivStudentAvatar" parameterType="java.util.Map">
|
||
|
|
UPDATE UnivStudent
|
||
|
|
SET avatar = #{avatar}
|
||
|
|
where studentId=#{studentId}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="getUnivStudentCountBySchoolId" parameterType="java.lang.Long" resultType="Integer">
|
||
|
|
SELECT count(*)
|
||
|
|
FROM UnivStudent
|
||
|
|
where schoolid = #{schoolId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivStudentBySchoolId" parameterType="java.util.Map" resultType="UnivStudent">
|
||
|
|
SELECT studentId , password , truename , nickname , gender , address ,
|
||
|
|
areaId , recognizeCode , cellphone , telephone , email , avatar ,
|
||
|
|
status , source , schoolId , lastSignIn , department , qq,signature
|
||
|
|
FROM UnivStudent
|
||
|
|
where schoolid = #{schoolId}
|
||
|
|
order by truename
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivStudentCountByClassesId" parameterType="java.lang.Long" resultType="Integer">
|
||
|
|
SELECT count(*)
|
||
|
|
FROM UnivStudent s
|
||
|
|
INNER JOIN UnivStudentOwnClass c
|
||
|
|
ON s.studentId = c.studentId
|
||
|
|
WHERE c.classesId = #{classesId} and c.status= 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivStudentByClassesId" parameterType="java.util.Map" resultType="UnivStudent">
|
||
|
|
SELECT s.studentId, s.password, s.truename, s.nickname, s.gender,
|
||
|
|
s.address, s.areaId, s.recognizeCode, s.cellphone, s.telephone,
|
||
|
|
s.email, s.avatar, s.status, s.source , s.schoolId ,
|
||
|
|
s.department , s.qq,s.signature
|
||
|
|
FROM UnivStudent s
|
||
|
|
INNER JOIN UnivStudentOwnClass c
|
||
|
|
ON s.studentid = c.studentId
|
||
|
|
WHERE classesId = #{classesId} and c.status= 1
|
||
|
|
AND s.status = 1
|
||
|
|
ORDER BY s.recognizeCode
|
||
|
|
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivStudentMapByTrueName" parameterType="java.util.HashMap" resultType="java.util.HashMap">
|
||
|
|
SELECT m.studentid , m.truename , m.recognizecode , n.classesid , n.classname ,
|
||
|
|
u.schoolid , u.schoolname
|
||
|
|
FROM ( select studentId , truename , recognizeCode , schoolid
|
||
|
|
from Univstudent
|
||
|
|
where truename like '%${trueName}%'
|
||
|
|
order by recognizecode
|
||
|
|
limit #{pageSize} offset #{offset} ) as m
|
||
|
|
INNER JOIN University u
|
||
|
|
ON m.schoolid = u.schoolid
|
||
|
|
LEFT JOIN ( select so.studentId , c.classesid , c.classname
|
||
|
|
from Univstudentownclass so
|
||
|
|
inner join Univclasses c
|
||
|
|
on c.classesid = so.classesid and c.classtype = 1
|
||
|
|
and c.status = 1 and so.status = 1
|
||
|
|
) as n
|
||
|
|
ON m.studentId = n.studentId
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivStudentMapByTrueNameCount" parameterType="String" resultType="Integer">
|
||
|
|
SELECT count(*)
|
||
|
|
FROM ( select studentId , truename , recognizeCode , schoolid
|
||
|
|
from Univstudent
|
||
|
|
where truename like '%${_parameter}%'
|
||
|
|
) as m
|
||
|
|
INNER JOIN University u
|
||
|
|
ON m.schoolid = u.schoolid
|
||
|
|
LEFT JOIN ( select so.studentId , c.classesid , c.classname
|
||
|
|
from Univstudentownclass so
|
||
|
|
inner join Univclasses c
|
||
|
|
on c.classesid = so.classesid and c.classtype = 1
|
||
|
|
and c.status = 1 and so.status = 1
|
||
|
|
) as n
|
||
|
|
ON m.studentId = n.studentId
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivStudentMapByRecognizeCode" parameterType="java.util.HashMap" resultType="java.util.HashMap">
|
||
|
|
SELECT m.studentid , m.truename , m.recognizecode , n.classesid , n.classname ,
|
||
|
|
u.schoolid , u.schoolname
|
||
|
|
FROM ( select studentId , truename , recognizeCode , schoolid
|
||
|
|
from Univstudent
|
||
|
|
where upper(recognizeCode) = upper(#{recognizecode})
|
||
|
|
and status = 1
|
||
|
|
order by recognizecode
|
||
|
|
limit #{pageSize} offset #{offset} ) as m
|
||
|
|
INNER JOIN University u
|
||
|
|
ON m.schoolid = u.schoolid
|
||
|
|
LEFT JOIN ( select so.studentId , c.classesid , c.classname
|
||
|
|
from Univstudentownclass so
|
||
|
|
inner join Univclasses c
|
||
|
|
on c.classesid = so.classesid and c.classtype = 1
|
||
|
|
and c.status = 1 and so.status = 1
|
||
|
|
) as n
|
||
|
|
ON m.studentId = n.studentId
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivStudentMapByRecognizeCodeCount" parameterType="String" resultType="Integer">
|
||
|
|
SELECT count(*)
|
||
|
|
FROM ( select studentId , truename , recognizeCode , schoolid
|
||
|
|
from Univstudent
|
||
|
|
where upper(recognizeCode) = upper(#{_parameter})
|
||
|
|
and status = 1
|
||
|
|
order by recognizecode ) as m
|
||
|
|
INNER JOIN University u
|
||
|
|
ON m.schoolid = u.schoolid
|
||
|
|
LEFT JOIN ( select so.studentId , c.classesid , c.classname
|
||
|
|
from Univstudentownclass so
|
||
|
|
inner join Univclasses c
|
||
|
|
on c.classesid = so.classesid and c.classtype = 1
|
||
|
|
and c.status = 1 and so.status = 1
|
||
|
|
) as n
|
||
|
|
ON m.studentId = n.studentId
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivStudentMapByEmail" parameterType="java.util.HashMap" resultType="java.util.HashMap">
|
||
|
|
SELECT m.studentid , m.truename , m.recognizecode , n.classesid , n.classname ,
|
||
|
|
u.schoolid , u.schoolname
|
||
|
|
FROM ( select studentId , truename , recognizeCode , schoolid
|
||
|
|
from Univstudent
|
||
|
|
where upper(email) = upper(#{email} )
|
||
|
|
and status = 1
|
||
|
|
order by recognizecode
|
||
|
|
limit #{pageSize} offset #{offset} ) as m
|
||
|
|
LEFT JOIN University u
|
||
|
|
ON m.schoolid = u.schoolid
|
||
|
|
LEFT JOIN ( select so.studentId , c.classesid , c.classname
|
||
|
|
from Univstudentownclass so
|
||
|
|
inner join Univclasses c
|
||
|
|
on c.classesid = so.classesid and c.classtype = 1
|
||
|
|
and c.status = 1 and so.status = 1
|
||
|
|
) as n
|
||
|
|
ON m.studentId = n.studentId
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivStudentMapCountByEmail" parameterType="String" resultType="Integer">
|
||
|
|
SELECT count(*)
|
||
|
|
FROM ( select studentId , truename , recognizeCode , schoolid
|
||
|
|
from Univstudent
|
||
|
|
where upper(email) = upper(#{_parameter} )
|
||
|
|
and status = 1
|
||
|
|
order by recognizecode ) as m
|
||
|
|
LEFT JOIN University u
|
||
|
|
ON m.schoolid = u.schoolid
|
||
|
|
LEFT JOIN ( select so.studentId , c.classesid , c.classname
|
||
|
|
from Univstudentownclass so
|
||
|
|
inner join Univclasses c
|
||
|
|
on c.classesid = so.classesid and c.classtype = 1
|
||
|
|
and c.status = 1 and so.status = 1
|
||
|
|
) as n
|
||
|
|
ON m.studentId = n.studentId
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUniverStudentByRecognizeCode" parameterType="String" resultType="UnivStudent">
|
||
|
|
select studentId , password , truename , nickname , areaId ,
|
||
|
|
recognizeCode , cellphone , telephone , email ,
|
||
|
|
avatar ,status ,source ,lastSignIn,department,qq,signature
|
||
|
|
from UnivStudent where upper(recognizeCode) = upper(#{recognizecode})
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getAllRecoginizeCode" resultType="String">
|
||
|
|
select recognizeCode from UnivStudent
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getUnivStudentStudyState" parameterType="java.util.Map" resultType="UnivStudentStudyState">
|
||
|
|
<if test="classesId != null ">
|
||
|
|
with temp as ( select a.studentId,a.recognizeCode,a.trueName from univstudent as a inner join univstudentownclass as b on a.studentid = b.studentid
|
||
|
|
where b.classesid = #{classesId}),
|
||
|
|
</if>
|
||
|
|
<if test="classesId == null ">
|
||
|
|
with temp as ( select studentId,recognizeCode,trueName from univstudent where schoolid = #{schoolId}) ,
|
||
|
|
</if>
|
||
|
|
|
||
|
|
|
||
|
|
<!--学习次数-->
|
||
|
|
temp1 as (select a.uid, count(a.uid) as studyCount from univachivement as a inner join temp as a1 on a.uid = a1.studentId where pointcasetype <> 1 and pointcasetype <> 2 and created > #{startTime} and created <#{endTime} group by a.uid),
|
||
|
|
|
||
|
|
<!--考试训练次数-->
|
||
|
|
temp2 as (select a.uid, count(a.uid) as examCount from univracescore as a inner join temp as a1 on a.uid = a1.studentId where created > #{startTime} and created <#{endTime} GROUP BY a.uid),
|
||
|
|
|
||
|
|
<!--竞赛场学习次数-->
|
||
|
|
temp3 as (select a.uid, count(a.uid) as raceCount from univracescore as a inner join temp as a1 on a.uid = a1.studentId where created > #{startTime} and created <#{endTime} GROUP BY a.uid )
|
||
|
|
select temp.studentId,temp.recognizeCode,temp.trueName ,case when temp1.studyCount is null then 0 else temp1.studyCount end as studyCount ,
|
||
|
|
case when temp2.examCount is null then 0 else temp2.examCount end as examCount,
|
||
|
|
case when temp3.raceCount is null then 0 else temp3.raceCount end as raceCount
|
||
|
|
from temp left join temp1 on temp.studentId = temp1.uid left join temp2 on temp1.uid = temp2.uid left join temp3 on temp2.uid = temp3.uid
|
||
|
|
<if test = "type ==1">
|
||
|
|
order by studyCount desc
|
||
|
|
</if>
|
||
|
|
<if test = "type ==2">
|
||
|
|
order by examCount desc
|
||
|
|
</if>
|
||
|
|
<if test = "type ==3">
|
||
|
|
order by raceCount desc
|
||
|
|
</if>
|
||
|
|
<if test="pageSize != null and offSet != null">
|
||
|
|
limit #{pageSize} offset #{offSet};
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getUnivStudentStudyStateCount" parameterType="java.util.Map" resultType="java.lang.Integer">
|
||
|
|
<if test="classesId != null ">
|
||
|
|
select count(a.studentId) as count from univstudent as a inner join univstudentownclass as b on a.studentid = b.studentid
|
||
|
|
where b.classesid = #{classesId}
|
||
|
|
</if>
|
||
|
|
<if test="classesId == null ">
|
||
|
|
select count(studentId) as count from univstudent where schoolid = #{schoolId}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
</mapper>
|