Examination_system/Examination_system-1/resources/mybatis/enroll/EnrollMapper.xml

103 lines
2.7 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.bonus.enroll.dao.EnrollDao" >
<select id="findByPage" parameterType="com.bonus.enroll.beans.EnrollBean" resultType="com.bonus.enroll.beans.EnrollBean">
SELECT
sz.id,
sz.`name`,
sz.idcard,
sz.times,
sz.specialty,
sz.del_flag AS delFlag,
enr.seat_num as seatNum
FROM
sz_registrations sz LEFT JOIN sz_enroll enr
on
sz.idcard =enr.idcard
WHERE
1 = 1
<if test="param.keyWord != null">
and (
sz.name LIKE CONCAT("%",#{param.keyWord},"%") or
sz.idcard LIKE CONCAT("%",#{param.keyWord},"%") or
sz.times LIKE CONCAT("%",#{param.keyWord},"%") or
sz.specialty LIKE CONCAT("%",#{param.keyWord},"%")
)
</if>
order by
enr.seat_num+"" ASC
</select>
<select id="findCountByLoginName" resultType="int">
SELECT COUNT(*)
FROM sz_registrations
WHERE idcard=#{loginName}
</select>
<insert id="add" parameterType="com.bonus.enroll.beans.EnrollBean" useGeneratedKeys="true" >
insert into
sz_registrations (
name
<if test="idcard != null and idcard != ''">
,idcard
</if>
<if test="times != null and times != ''">
,times
</if>
<if test="specialty != null and specialty != ''">
,specialty
</if>
)
values (
#{name}
<if test="idcard != null and idcard != ''">
,#{idcard}
</if>
<if test="times != null and times != ''">
,#{times}
</if>
<if test="specialty != null and specialty != ''">
,#{specialty}
</if>
)
</insert>
<select id="finds" parameterType="com.bonus.enroll.beans.EnrollBean" resultType="com.bonus.enroll.beans.EnrollBean">
SELECT
name AS name,
idcard as idcard
FROM
sz_registrations
WHERE
is_active = 0
AND times = #{times}
</select>
<insert id="insertInfo" parameterType="com.bonus.enroll.beans.EnrollBean" useGeneratedKeys="true" >
insert into
sz_enroll (
name
<if test="idcard != null and idcard != ''">
,idcard
</if>
<if test="seatNum != null and seatNum != ''">
,seat_num
</if>
)
values (
#{name}
<if test="idcard != null and idcard != ''">
,#{idcard}
</if>
<if test="seatNum != null and seatNum != ''">
,#{seatNum}
</if>
)
</insert>
<update id="updateInfo" parameterType="com.bonus.enroll.beans.EnrollBean">
update sz_registrations SET `is_active` = '1'
where times = #{times}
</update>
</mapper>