383 lines
15 KiB
XML
383 lines
15 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="Student">
|
|
|
|
|
|
<insert id="insertStudent" parameterType="Student">
|
|
INSERT INTO Student ( studentId, password, truename, nickname, gender,
|
|
address, areaId, recognizeCode, cellphone, telephone, email,
|
|
avatar, status, source , code )
|
|
Values ( #{studentId}, #{password}, #{truename}, #{nickname}, #{gender},
|
|
#{address}, #{areaId}, upper(#{recognizeCode}), #{cellphone}, #{telephone}, #{email},
|
|
#{avatar}, #{status}, #{source} , #{code} )
|
|
</insert>
|
|
|
|
<update id="updateStudent" parameterType="Student">
|
|
|
|
UPDATE Student
|
|
SET studentId = #{studentId}, truename = #{truename},
|
|
nickname = #{nickname}, gender = #{gender}, address = #{address},
|
|
areaId = #{areaId}, recognizeCode = upper(#{recognizeCode}),
|
|
cellphone = #{cellphone}, telephone = #{telephone}, email = #{email},
|
|
status = #{status}, source = #{source} , lastSignIn = #{lastSignIn} ,
|
|
jdToken = #{jdToken} , code = #{code},signature = #{signature}
|
|
where studentId=#{studentId}
|
|
|
|
</update>
|
|
|
|
<select id="getStudentByKey" parameterType="java.lang.Long" resultType="Student">
|
|
|
|
SELECT studentId , password , truename , nickname , gender , address , areaId ,
|
|
recognizeCode , cellphone , telephone , email , avatar , status , source , code , signature,lastSignIn
|
|
FROM Student
|
|
WHERE studentId=#{studentId}
|
|
|
|
</select>
|
|
|
|
<select id="getStudentByCode" parameterType="java.lang.String" resultType="Student">
|
|
|
|
SELECT studentId , password , truename , nickname , gender , address , areaId ,
|
|
recognizeCode , cellphone , telephone , email , avatar , status , source , code ,signature,lastSignIn
|
|
FROM Student
|
|
WHERE upper(recognizeCode) = upper(#{_parameter})
|
|
|
|
</select>
|
|
|
|
<select id="getSeqStudent" resultType="Integer" useCache="false" flushCache="true">
|
|
|
|
SELECT nextval('seq_studentId') ;
|
|
|
|
</select>
|
|
|
|
<select id="getAllStudent" resultType="Student">
|
|
|
|
SELECT studentId , password , truename , nickname , gender , address ,
|
|
areaId , recognizeCode , cellphone , telephone , email , avatar ,
|
|
status , source
|
|
FROM Student
|
|
|
|
</select>
|
|
|
|
<insert id="insertStudentBatch" parameterType="java.util.List">
|
|
|
|
INSERT INTO Student ( studentId, password, truename, nickname, gender,
|
|
address, areaId, recognizeCode, cellphone, telephone, email,
|
|
avatar, status, source , code ) Values
|
|
|
|
<foreach collection="list" item="item" index="index" separator=",">
|
|
|
|
( #{item.studentId}, #{item.password}, #{item.truename},
|
|
#{item.nickname}, #{item.gender}, #{item.address},
|
|
#{item.areaId}, upper(#{item.recognizeCode}), #{item.cellphone},
|
|
#{item.telephone}, #{item.email}, #{item.avatar},
|
|
#{item.status}, #{item.source} , #{item.code} )
|
|
|
|
</foreach>
|
|
</insert>
|
|
|
|
<update id="updateStudentPassword" parameterType="java.util.Map">
|
|
|
|
UPDATE Student
|
|
SET password = #{password}
|
|
where studentId=#{studentId}
|
|
|
|
</update>
|
|
|
|
<update id="updateStudentAvatar" parameterType="java.util.Map">
|
|
|
|
UPDATE Student
|
|
SET avatar = #{avatar}
|
|
where studentId=#{studentId}
|
|
|
|
</update>
|
|
|
|
<select id="getStudentCountByClassesId" parameterType="java.util.Map" resultType="Integer">
|
|
|
|
SELECT count(*) FROM Student s inner join
|
|
StudentOwnClass c on s.studentId = c.studentId
|
|
where c.classesId = #{classesId} and c.areaId=#{areaId}
|
|
<if test="status!=null">
|
|
and c.status= #{status} and s.status=#{status}
|
|
</if>
|
|
<if test="status==null">
|
|
and c.status= 1 and s.status=1
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<select id="getStudentByClassesId" parameterType="java.util.Map" resultType="Student">
|
|
|
|
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.code, s.created
|
|
FROM Student s inner join StudentOwnClass c on
|
|
s.studentid = c.studentId where classesId = #{classesId} and c.areaId=#{areaId}
|
|
<if test="status!=null">
|
|
and c.status= #{status} and s.status=#{status}
|
|
</if>
|
|
<if test="status==null">
|
|
and c.status= 1 and s.status=1
|
|
</if>
|
|
<if test="order==null">
|
|
order by s.recognizeCode
|
|
</if>
|
|
<if test="order==2">
|
|
order by s.created desc,s.studentId
|
|
</if>
|
|
|
|
<if test="pageSize!=null">
|
|
LIMIT #{pageSize}
|
|
</if>
|
|
|
|
<if test="offset!=null">
|
|
OFFSET #{offset}
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<select id="getServerFeeByStudentId" parameterType="long" resultType="integer">
|
|
|
|
select distinct s.serviceFee
|
|
from studentownclass so
|
|
inner join classes c
|
|
on so.studentid = #{uid} and so.classesId = c.classesId and c.classtype = 1 and c.status = 1
|
|
inner join school s
|
|
on c.schoolId = s.schoolId
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getRetailByAreaId" parameterType="map" resultType="Student">
|
|
|
|
SELECT studentId , password , truename , nickname , gender , address ,
|
|
areaId , recognizeCode , cellphone , telephone , email , avatar ,
|
|
status , source , code
|
|
FROM Student where source = 2 and areaId = #{areaId}
|
|
<if test="pageSize!=null">
|
|
LIMIT #{pageSize}
|
|
</if>
|
|
|
|
<if test="offset!=null">
|
|
OFFSET #{offset}
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<select id="getRetailCountByAreaId" parameterType="Integer" resultType="Integer">
|
|
|
|
SELECT count(*)
|
|
FROM Student where source = 2 and areaId = #{areaId}
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getUserInfoByStudentId" parameterType="Long" resultType="java.util.HashMap">
|
|
|
|
SELECT b.classesId , b.schoolYear , b.classOrder , b.schoolId , t.teacherid , t.truename
|
|
|
|
FROM StudentOwnClass a
|
|
INNER JOIN Classes b
|
|
ON a.classesId = b.classesId and b.classType = 1 and b.status = 1
|
|
inner join teacher t on t.teacherid = b.teacherid
|
|
WHERE a.studentId= #{studentid}
|
|
AND a.status = 1
|
|
LIMIT 1
|
|
|
|
</select>
|
|
|
|
<select id="getSchoolIdByStudentId" parameterType="Long" resultType="Long">
|
|
|
|
select c.schoolId
|
|
from studentownclass so
|
|
inner join classes c
|
|
on so.studentid = #{uid} and so.classesId = c.classesId and c.classtype = 1 and c.status = 1
|
|
Limit 1
|
|
|
|
</select>
|
|
|
|
<select id="getClassesIdByStudentId" parameterType="java.util.Map" resultType="Long">
|
|
select c.classesid from classes c INNER JOIN studentownclass st on c.classesid = st.classesid and st.status = 1 and c.status =1
|
|
and st.areaid = #{areaId} and c.classtype = 1
|
|
INNER JOIN student s on st.studentid = s.studentid and s.status = 1 and s.studentid = #{studentId} and s.areaid =#{areaId}
|
|
</select>
|
|
|
|
|
|
<select id="findAllClassByStudentid" parameterType="java.util.Map" resultType="Classes">
|
|
SELECT * FROM Classes
|
|
WHERE classesid in (
|
|
select classesid from studentownclass where studentid = #{studentId} and status =1 and areaid=#{areaId}
|
|
)
|
|
and status = 1
|
|
</select>
|
|
|
|
|
|
<select id="getStudentMapByTrueName" parameterType="java.util.HashMap" resultType="java.util.HashMap">
|
|
|
|
SELECT s.studentid , s.truename , s.recognizecode , c.classesid ,
|
|
c.classname , sc.schoolid , sc.schoolname,s.source,s.cellphone
|
|
FROM student s
|
|
INNER JOIN studentownclass so
|
|
ON s.studentid = so.studentid and so.status =1 and s.status=1
|
|
INNER JOIN classes c
|
|
ON c.classesid = so.classesid and c.classtype = 1 and c.status >= 1
|
|
INNER JOIN school sc
|
|
ON sc.schoolid = c.schoolid and sc.status = 1
|
|
WHERE trim( s.truename )= #{trueName}
|
|
ORDER BY s.recognizecode
|
|
LIMIT #{pageSize} OFFSET #{offset}
|
|
|
|
</select>
|
|
|
|
<select id="getStudentMapByTrueNameCount" parameterType="String" resultType="Integer">
|
|
SELECT count(*)
|
|
FROM student s
|
|
INNER JOIN studentownclass so
|
|
ON s.studentid = so.studentid and so.status =1 and s.status=1
|
|
INNER JOIN classes c
|
|
ON c.classesid = so.classesid and c.classtype = 1 and c.status >= 1
|
|
INNER JOIN school sc
|
|
ON sc.schoolid = c.schoolid and sc.status = 1
|
|
WHERE s.truename = #{_parameter}
|
|
</select>
|
|
|
|
<select id="getStudentMapByRecognizeCode" parameterType="java.util.HashMap" resultType="java.util.HashMap">
|
|
|
|
select m.studentid , m.truename , m.recognizecode , n.classesid , n.classname ,
|
|
n.schoolid , n.schoolname,m.source,cellphone
|
|
from ( select studentId , truename , recognizeCode ,source,cellphone
|
|
from student
|
|
where upper(recognizeCode) = upper(#{recognizecode}) and status=1
|
|
order by recognizecode
|
|
limit #{pageSize} offset #{offset} ) as m
|
|
left join ( select so.studentId , c.classesid , c.classname ,
|
|
sc.schoolid , sc.schoolname
|
|
from studentownclass so
|
|
inner join classes c
|
|
on c.classesid = so.classesid and c.classtype = 1 and c.status >= 1
|
|
inner join school sc
|
|
on sc.schoolid = c.schoolid and sc.status = 1 ) as n
|
|
on m.studentId = n.studentId
|
|
|
|
</select>
|
|
|
|
<select id="getStudentMapCellPhone" parameterType="java.util.HashMap" resultType="java.util.HashMap">
|
|
|
|
select m.studentid , m.truename , m.recognizecode , n.classesid , n.classname ,
|
|
n.schoolid , n.schoolname,m.source,m.cellphone
|
|
from ( select studentId , truename , recognizeCode ,source,cellphone
|
|
from student
|
|
where cellphone = #{cellphone} and status=1
|
|
order by recognizecode
|
|
limit #{pageSize} offset #{offset} ) as m
|
|
left join ( select so.studentId , c.classesid , c.classname ,
|
|
sc.schoolid , sc.schoolname
|
|
from studentownclass so
|
|
inner join classes c
|
|
on c.classesid = so.classesid and c.classtype = 1 and c.status >= 1
|
|
inner join school sc
|
|
on sc.schoolid = c.schoolid and sc.status = 1 ) as n
|
|
on m.studentId = n.studentId
|
|
|
|
</select>
|
|
|
|
<select id="getStudentMapByRecognizeCodeCount" parameterType="String" resultType="Integer">
|
|
|
|
select count(*) from student s left join studentownclass so
|
|
on s.studentid = so.studentid and so.status =1
|
|
left join classes c on c.classesid = so.classesid and c.classtype = 1 and c.status >= 1
|
|
left join school sc on sc.schoolid = c.schoolid and sc.status = 1
|
|
where upper(s.recognizeCode) = upper(#{_parameter}) and s.status=1
|
|
|
|
</select>
|
|
|
|
<select id="getStudentCountByCellPhone" parameterType="String" resultType="Integer">
|
|
select count(studentId) from student where status=1 and cellphone=#{_parameter}
|
|
</select>
|
|
|
|
|
|
<select id="getStudentCountByCellPhoneAndSource" parameterType="java.util.Map" resultType="java.lang.Integer">
|
|
select count(studentId) from student
|
|
<where>
|
|
status = 1
|
|
<if test="cellphone != null">
|
|
and cellphone = #{cellphone}
|
|
</if>
|
|
<if test="source != null">
|
|
and source = #{source}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectStudentCountByMonth" parameterType="java.util.Map" resultType="java.util.Map">
|
|
select count(studentId) userCount , extract(MONTH from created) as month from student where
|
|
created>=#{startTime} and created<#{endTime}
|
|
group by month
|
|
|
|
</select>
|
|
|
|
<select id="selectSchoolUserPayCountByMonth" parameterType="java.util.Map" resultType="java.util.Map">
|
|
select count(distinct uid) schoolUserCount, extract(MONTH from created) as month from goodsauthlog where
|
|
created>=#{startTime} and created<#{endTime} and authtype in (1,4) and objecttype=4
|
|
group by month
|
|
</select>
|
|
|
|
|
|
<select id="selectStudentPayCountByMonth" parameterType="java.util.Map" resultType="java.util.Map">
|
|
select count(distinct (case when ispayed = 1 then uid else null end) ) userPayNetCount,
|
|
count(distinct (case when ispayed=-1 then uid else null end) ) userPayCashCount,
|
|
extract(MONTH from created) as month from orderinfo where
|
|
created>=#{startTime} and created<#{endTime}
|
|
and (payway > 0 or payway=-100) and (ispayed = 1 or ispayed=-1) and amount>0
|
|
group by month
|
|
</select>
|
|
|
|
|
|
<select id="selectStudentRenewCountByTime" parameterType="java.util.Map" resultType="java.util.Map">
|
|
with temp as(select uid from orderinfo where created >=#{startTime} and created<#{endTime}
|
|
and (payway >0 or payway=-100) and (ispayed = 1 or ispayed=-1) and amount>0),
|
|
temp1 as(
|
|
select count(distinct o.uid) payCount from orderinfo o inner join userownlesson u on o.uid=u.uid and
|
|
u.endtime<#{endTime} and u.endtime>#{startTime} and (o.payway >0 or o.payway=-100) and (o.ispayed = 1 or o.ispayed=-1)
|
|
and o.amount>0
|
|
),
|
|
temp2 as( select count(distinct o.uid) renewCount from orderinfo o
|
|
inner join temp t on t.uid=o.uid and created <=#{startTime}
|
|
and (payway >0 or payway=-100) and (ispayed = 1 or ispayed=-1) and o.amount>0
|
|
)
|
|
select payCount,renewCount from temp1,temp2 where 1=1
|
|
</select>
|
|
|
|
|
|
<select id="selectStudentPayCountByTime" parameterType="java.util.Map" resultType="java.lang.Integer">
|
|
select count(distinct uid) from orderinfo where
|
|
created<#{endTime}
|
|
and (payway > 0 or payway=-100) and (ispayed = 1 or ispayed=-1) and amount>0
|
|
|
|
</select>
|
|
|
|
<select id="selectStudentCountByTime" parameterType="java.util.Map" resultType="java.lang.Integer">
|
|
select count(studentid ) from student where
|
|
created<#{endTime}
|
|
</select>
|
|
|
|
|
|
<select id="findStudentsByStudentIds" parameterType="java.util.Map" resultType="java.util.Map">
|
|
select truename,studentid from student where studentid in
|
|
<foreach collection="uids" item="item" index="index" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</select>
|
|
|
|
|
|
<select id="findStudentCountbyClasses" parameterType="java.util.Map" resultType="java.lang.Integer">
|
|
WITH temp as ( select soc.studentId
|
|
from StudentOwnClass soc inner join student s on soc.studentid=s.studentid and soc.classesId = #{classesId}
|
|
and soc.areaid = #{areaId} and s.areaid = #{areaId}
|
|
and s.status=1
|
|
),
|
|
temp1 as (SELECT b.uid from temp as a INNER JOIN racescore b ON a.studentid = b.uid and b.areaid = #{areaId}
|
|
and b.created between #{startTime} and #{endTime} )
|
|
SELECT count(uid) from temp1
|
|
</select>
|
|
</mapper> |