liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?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.jeeplus.modules.userregister.dao.UserRegisterDao">
    
    <sql id="userRegisterColumns">
        a.id AS "id",
        a.create_by AS "createBy.id",
        a.create_date AS "createDate",
        a.update_by AS "updateBy.id",
        a.update_date AS "updateDate",
        a.remarks AS "remarks",
        a.del_flag AS "delFlag",
        a.user_id AS "userId",
        a.card_id AS "cardId",
        a.user_name AS "userName",
        a.dep_id AS "depId",
        a.user_sex AS "usersex",
        a.user_type AS "userType",
        a.user_status AS "userStatus",
        a.user_duty AS "userDuty",
        a.user_other AS "userOther",
        a.user_class AS "userClass",
        a.user_birthday AS "userBirthday"
    </sql>
    
    <sql id="userRegisterJoins">
    </sql>
    
    <select id="get" resultType="UserRegister">
        SELECT 
            <include refid="userRegisterColumns"/>
        FROM user_register a
        <include refid="userRegisterJoins"/>
        WHERE a.id = #{id}
    </select>
    
    <select id="findList" resultType="UserRegister">
        SELECT 
            <include refid="userRegisterColumns"/>
        FROM user_register a
        <include refid="userRegisterJoins"/>
        <where>
            a.del_flag = #{DEL_FLAG_NORMAL}
            <if test="userId != null and userId != ''">
                AND a.user_id = #{userId}
            </if>
            <if test="cardId != null and cardId != ''">
                AND a.card_id = #{cardId}
            </if>
            <if test="userName != null and userName != ''">
                AND a.user_name = #{userName}
            </if>
            <if test="depId != null and depId != ''">
                AND a.dep_id = #{depId}
            </if>
            <if test="usersex != null and usersex != ''">
                AND a.user_sex = #{usersex}
            </if>
            <if test="userType != null and userType != ''">
                AND a.user_type = #{userType}
            </if>
            <if test="userStatus != null and userStatus != ''">
                AND a.user_status = #{userStatus}
            </if>
            <if test="userDuty != null and userDuty != ''">
                AND a.user_duty = #{userDuty}
            </if>
            <if test="userClass != null and userClass != ''">
                AND a.user_class = #{userClass}
            </if>
            <if test="userBirthday != null and userBirthday != ''">
                AND a.user_birthday = #{userBirthday}
            </if>
        </where>
        <choose>
            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
                ORDER BY ${page.orderBy}
            </when>
            <otherwise>
                ORDER BY a.update_date DESC
            </otherwise>
        </choose>
    </select>
    
    <select id="findAllList" resultType="UserRegister">
        SELECT 
            <include refid="userRegisterColumns"/>
        FROM user_register a
        <include refid="userRegisterJoins"/>
        <where>
            a.del_flag = #{DEL_FLAG_NORMAL}
        </where>        
        <choose>
            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
                ORDER BY ${page.orderBy}
            </when>
            <otherwise>
                ORDER BY a.update_date DESC
            </otherwise>
        </choose>
    </select>
    
    <insert id="insert">
        INSERT INTO user_register(
            id,
            create_by,
            create_date,
            update_by,
            update_date,
            remarks,
            del_flag,
            user_id,
            card_id,
            user_name,
            dep_id,
            user_sex,
            user_type,
            user_status,
            user_duty,
            user_other,
            user_class,
            user_birthday
        ) VALUES (
            #{id},
            #{createBy.id},
            #{createDate},
            #{updateBy.id},
            #{updateDate},
            #{remarks},
            #{delFlag},
            #{userId},
            #{cardId},
            #{userName},
            #{depId},
            #{usersex},
            #{userType},
            #{userStatus},
            #{userDuty},
            #{userOther},
            #{userClass},
            #{userBirthday}
        )
    </insert>
    
    <update id="update">
        UPDATE user_register SET     
            update_by = #{updateBy.id},
            update_date = #{updateDate},
            remarks = #{remarks},
            user_id = #{userId},
            card_id = #{cardId},
            user_name = #{userName},
            dep_id = #{depId},
            user_sex = #{usersex},
            user_type = #{userType},
            user_status = #{userStatus},
            user_duty = #{userDuty},
            user_other = #{userOther},
            user_birthday = #{userBirthday},
            user_class = #{userClass}
        WHERE id = #{id}
    </update>
    
    
    <!--物理删除-->
    <update id="delete">
        DELETE FROM user_register
        WHERE id = #{id}
    </update>
    
    <!--逻辑删除-->
    <update id="deleteByLogic">
        UPDATE user_register SET 
            del_flag = #{DEL_FLAG_DELETE}
        WHERE id = #{id}
    </update>
    
    
    <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
    <select id="findUniqueByProperty" resultType="UserRegister" statementType="STATEMENT">
        select * FROM user_register  where ${propertyName} = '${value}'
    </select>
</mapper>