104 lines
4.1 KiB
XML
104 lines
4.1 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!DOCTYPE mapper
|
|
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.cxyxiaomo.epp.user.dao.UserDao">
|
|
<insert id="addUser" parameterType="com.cxyxiaomo.epp.common.pojo.User" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
|
INSERT INTO user (username, `password`, realname, id_number, phone_number, role_id, building_id, doorplate,
|
|
permission, permission_time, wx_code)
|
|
VALUES (#{username}, #{password}, #{realname}, #{idNumber}, #{phoneNumber}, #{roleId}, #{buildingId},
|
|
#{doorplate}, #{permission}, #{permissionTime}, #{wxcode})
|
|
</insert>
|
|
<update id="updateUser" parameterType="com.cxyxiaomo.epp.common.pojo.User">
|
|
UPDATE user
|
|
<set>
|
|
<if test="username != null and username != ''">
|
|
username = #{username},
|
|
</if>
|
|
<if test="password != null and password != ''">
|
|
`password` = #{password},
|
|
</if>
|
|
<if test="realname != null and realname != ''">
|
|
realname = #{realname},
|
|
</if>
|
|
<if test="idNumber != null and idNumber != ''">
|
|
id_number = #{idNumber},
|
|
</if>
|
|
<if test="phoneNumber != null and phoneNumber != ''">
|
|
phone_number = #{phoneNumber},
|
|
</if>
|
|
<if test="roleId != null">
|
|
role_id = #{roleId},
|
|
</if>
|
|
<if test="buildingId != null and buildingId != ''">
|
|
building_id = #{buildingId},
|
|
</if>
|
|
<if test="doorplate != null and doorplate != ''">
|
|
doorplate = #{doorplate},
|
|
</if>
|
|
<if test="permission != null">
|
|
permission = #{permission},
|
|
</if>
|
|
<if test="permissionTime != null">
|
|
permission_time = #{permissionTime},
|
|
</if>
|
|
<if test="wxcode != null and wxcode != ''">
|
|
wx_code = #{doorplate},
|
|
</if>
|
|
</set>
|
|
WHERE id = #{id}
|
|
</update>
|
|
<update id="updatePwd" parameterType="com.cxyxiaomo.epp.common.pojo.User">
|
|
UPDATE user
|
|
SET `password` = #{password}
|
|
WHERE id = #{id}
|
|
</update>
|
|
<select id="getUserById" parameterType="java.lang.Integer" resultType="com.cxyxiaomo.epp.common.pojo.User">
|
|
SELECT *
|
|
FROM user
|
|
WHERE id = #{id}
|
|
</select>
|
|
<select id="getUserByUsername" resultType="com.cxyxiaomo.epp.common.pojo.User">
|
|
select *
|
|
from user
|
|
where username = #{username}
|
|
</select>
|
|
<select id="getUserByWxcode" resultType="com.cxyxiaomo.epp.common.pojo.User">
|
|
select *
|
|
from user
|
|
where wx_code = #{wxcode}
|
|
</select>
|
|
<select id="getUserList" resultType="com.cxyxiaomo.epp.common.pojo.User">
|
|
select *
|
|
from user
|
|
where 1 = 1
|
|
<if test="roleId != null">
|
|
AND role_id = #{roleId}
|
|
</if>
|
|
<if test="username != null && username != ''">
|
|
AND username LIKE concat('%',#{username,jdbcType=VARCHAR},'%')
|
|
</if>
|
|
<if test="realname != null && realname != ''">
|
|
AND realname LIKE concat('%',#{realname,jdbcType=VARCHAR},'%')
|
|
</if>
|
|
<if test="idNumber != null && idNumber != ''">
|
|
AND id_number LIKE concat('%',#{idNumber,jdbcType=VARCHAR},'%')
|
|
</if>
|
|
<if test="phoneNumber != null && phoneNumber != ''">
|
|
AND phone_number LIKE concat('%',#{phoneNumber,jdbcType=VARCHAR},'%')
|
|
</if>
|
|
<if test="buildingId != null && buildingId != ''">
|
|
AND building_id LIKE concat('%',#{buildingId,jdbcType=VARCHAR},'%')
|
|
</if>
|
|
<if test="doorplate != null && doorplate != ''">
|
|
AND doorplate LIKE concat('%',#{doorplate,jdbcType=VARCHAR},'%')
|
|
</if>
|
|
</select>
|
|
|
|
<delete id="deleteUserById">
|
|
DELETE
|
|
FROM user
|
|
WHERE id = #{userId}
|
|
</delete>
|
|
</mapper>
|