“djh”
9 天以前 f84f28a824fde14acd2bd91cff054de44beafbb7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?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.gkhy.exam.system.mapper.ExStudentMapper">
    <resultMap type="com.gkhy.exam.system.domain.ExStudent" id="ExStudentResult">
        <result property="id"       column="id"       />
        <result property="name"    column="name"    />
        <result property="companyId"     column="company_id"     />
        <result property="empno"  column="empno"  />
        <result property="phone"         column="phone"          />
        <result property="password"         column="password"          />
        <result property="status"         column="status"          />
        <result property="sex"         column="sex"          />
        <result property="idNo"         column="id_no"          />
        <result property="post"         column="post"          />
        <result property="duty"         column="duty"          />
        <result property="createId"         column="create_id"          />
 
        <result property="delFlag"         column="del_flag"          />
        <result property="loginIp"         column="login_ip"          />
        <result property="loginDate"         column="login_date"          />
        <result property="pwdUpdateDate"         column="pwd_update_date"          />
        <result property="version"         column="version"          />
        <result property="createBy"       column="create_by"       />
        <result property="createTime"     column="create_time"     />
        <result property="updateBy"       column="update_by"       />
        <result property="updateTime"     column="update_time"     />
        <result property="remark"         column="remark"          />
 
        <association property="company" javaType="com.gkhy.exam.system.domain.SysCompany" resultMap="companyResult" />
        <association property="createUser" javaType="com.gkhy.exam.common.domain.entity.SysUser" resultMap="userResult" />
    </resultMap>
    <resultMap id="companyResult" type="com.gkhy.exam.system.domain.SysCompany">
        <id     property="id"       column="company_id"        />
        <result property="name"     column="company_name"      />
    </resultMap>
 
    <resultMap id="userResult" type="com.gkhy.exam.common.domain.entity.SysUser">
        <id     property="id"       column="create_id"        />
        <result property="name"     column="create_name"      />
    </resultMap>
 
    <sql id="selectStudentVo">
        select s.id, s.name, s.company_id, s.empno, s.phone,s.status,s.sex,s.id_no,s.post,s.duty,
               s.create_id,s.del_flag,s.version, s.create_by, s.create_time, s.update_by, s.update_time, s.remark,
                c.id as company_id,c.name as company_name,d.name as create_name
        from ex_student s
        left join sys_company c on c.id=s.company_id
        left join sys_user d on d.id=s.create_id
    </sql>
 
    <update id="deleteByStudentId">
        update ex_student set del_flag=1 where id=#{studentId}
    </update>
 
 
    <select id="selectStudentList" resultMap="ExStudentResult">
        <include refid="selectStudentVo"/>
        <where>
            and s.del_flag=0
            <if test="name != null and name != ''">
                AND s.name like concat('%', #{name}, '%')
            </if>
            <if test="phone != null and phone != ''">
                AND s.phone like concat('%', #{phone}, '%')
            </if>
            <if test="companyId != null">
                AND s.company_id =#{companyId}
            </if>
            <if test="idNo != null and idNo != ''">
                AND s.id_no like concat('%', #{idNo}, '%')
            </if>
            <if test="createId != null">
                AND s.create_id =#{createId}
            </if>
            <if test="duty != null">
                AND s.duty =#{duty}
            </if>
            <if test="params.createIds != null and params.createIds != ''">
                AND s.create_id in
                <foreach collection="params.createIds" item="createId" open="(" separator="," close=")">
                    #{createId}
                </foreach>
            </if>
        </where>
        order by s.id desc
    </select>
 
    <select id="selectStudentById" resultMap="ExStudentResult">
        <include refid="selectStudentVo"/>
        where s.id=#{studentId}
    </select>
    <select id="checkPhoneUnique" resultType="com.gkhy.exam.system.domain.ExStudent">
        select id,phone from ex_student where phone=#{phone} and del_flag=0 limit 1
    </select>
 
    <select id="checkIdNoUnique" resultType="com.gkhy.exam.system.domain.ExStudent">
        select id,id_no,company_id from ex_student where id_no=#{idNo} and del_flag=0 limit 1
    </select>
 
    <select id="selectStudentByPhone" resultType="com.gkhy.exam.system.domain.ExStudent">
        select * from ex_student where phone=#{phone} and del_flag=0  limit 1
    </select>
 
</mapper>