SysUserDao.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.pine.admin.modules.system.dao.SysUserDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.pine.admin.modules.system.entity.SysUser" id="sysUserMap">
  6. <result property="id" column="id"/>
  7. <result property="usercode" column="usercode"/>
  8. <result property="username" column="username"/>
  9. <result property="password" column="password"/>
  10. <result property="salt" column="salt"/>
  11. <result property="locked" column="locked"/>
  12. <result property="createTime" column="create_time"/>
  13. <result property="updateTime" column="update_time"/>
  14. </resultMap>
  15. <sql id="Base_Column_List">
  16. id,
  17. usercode,
  18. username,
  19. password,
  20. salt,
  21. locked,
  22. create_time,
  23. update_time </sql>
  24. <!-- 根据Id查询-->
  25. <select id="selectByPrimaryKey" resultMap="sysUserMap" parameterType="java.lang.Integer">
  26. select
  27. <include refid="Base_Column_List"/>
  28. from sys_user
  29. where id = #{id,jdbcType=INTEGER}
  30. </select>
  31. <!-- 根据用户CODE查询查询-->
  32. <select id="selectByUserCode" resultMap="sysUserMap" parameterType="java.lang.String">
  33. select
  34. <include refid="Base_Column_List"/>
  35. from sys_user
  36. where usercode = #{userCode,jdbcType=INTEGER} and del_flag = 'N'
  37. </select>
  38. <!-- 根据Id删除-->
  39. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  40. delete from sys_user
  41. where id = #{id,jdbcType=INTEGER}
  42. </delete>
  43. <!-- 插入数据-->
  44. <insert id="insertSelective" parameterType="com.pine.admin.modules.system.entity.SysUser"
  45. useGeneratedKeys="true" keyProperty="id">
  46. insert into sys_user
  47. <trim prefix="(" suffix=")" suffixOverrides=",">
  48. <if test="id !=null">id,</if>
  49. <if test="usercode !=null">usercode,</if>
  50. <if test="username !=null">username,</if>
  51. <if test="password !=null">password,</if>
  52. <if test="salt !=null">salt,</if>
  53. <if test="locked !=null">locked,</if>
  54. <if test="delFlag !=null">del_flag,</if>
  55. <if test="createTime !=null">create_time,</if>
  56. <if test="updateTime !=null">update_time,</if>
  57. </trim>
  58. <trim prefix="values (" suffix=")" suffixOverrides=",">
  59. <if test="id !=null">#{id},</if>
  60. <if test="usercode !=null">#{usercode},</if>
  61. <if test="username !=null">#{username},</if>
  62. <if test="password !=null">#{password},</if>
  63. <if test="salt !=null">#{salt},</if>
  64. <if test="locked !=null">#{locked},</if>
  65. <if test="delFlag !=null">#{delFlag},</if>
  66. <if test="createTime !=null">#{createTime},</if>
  67. <if test="updateTime !=null">#{updateTime},</if>
  68. </trim>
  69. </insert>
  70. <!-- 更新数据-->
  71. <update id="updateByPrimaryKeySelective" parameterType="com.pine.admin.modules.system.entity.SysUser">
  72. update sys_user
  73. <set>
  74. <if test="id != null">id = #{id},</if>
  75. <if test="usercode != null">usercode = #{usercode},</if>
  76. <if test="username != null">username = #{username},</if>
  77. <if test="password != null">password = #{password},</if>
  78. <if test="salt != null">salt = #{salt},</if>
  79. <if test="locked != null">locked = #{locked},</if>
  80. <if test="delFlag != null">del_flag = #{delFlag},</if>
  81. <if test="createTime != null">create_time = #{createTime},</if>
  82. <if test="updateTime != null">update_time = #{updateTime},</if>
  83. </set>
  84. where id = #{id}
  85. </update>
  86. <!-- 分页查询-->
  87. <select id="querySysUsersByPage" parameterType="java.util.Map"
  88. resultType="com.pine.admin.modules.system.entity.SysUser">
  89. select
  90. <include refid="Base_Column_List"/>
  91. from sys_user
  92. <where>
  93. and del_flag = 'N'
  94. <if test="record.id != null and !&quot;&quot;.equals(record.id)">and id = #{record.id}</if>
  95. <if test="record.usercode != null and !&quot;&quot;.equals(record.usercode)">and usercode =
  96. #{record.usercode}
  97. </if>
  98. <if test="record.username != null and !&quot;&quot;.equals(record.username)">and username =
  99. #{record.username}
  100. </if>
  101. <if test="record.password != null and !&quot;&quot;.equals(record.password)">and password =
  102. #{record.password}
  103. </if>
  104. <if test="record.salt != null and !&quot;&quot;.equals(record.salt)">and salt = #{record.salt}</if>
  105. <if test="record.locked != null and !&quot;&quot;.equals(record.locked)">and locked = #{record.locked}</if>
  106. <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">and del_flag =
  107. #{record.delFlag}
  108. </if>
  109. <if test="record.createTime != null and !&quot;&quot;.equals(record.createTime)">and create_time =
  110. #{record.createTime}
  111. </if>
  112. <if test="record.updateTime != null and !&quot;&quot;.equals(record.updateTime)">and update_time =
  113. #{record.updateTime}
  114. </if>
  115. </where>
  116. order by id desc
  117. </select>
  118. <!-- 全部查询 -->
  119. <select id="queryAllSysUser" parameterType="java.util.Map"
  120. resultType="com.pine.admin.modules.system.entity.SysUser">
  121. select
  122. <include refid="Base_Column_List"/>
  123. from sys_user
  124. <where>
  125. and del_flag = 'N'
  126. <if test="id != null and !&quot;&quot;.equals(id)">and id = #{id}</if>
  127. <if test="usercode != null and !&quot;&quot;.equals(usercode)">and usercode = #{usercode}</if>
  128. <if test="username != null and !&quot;&quot;.equals(username)">and username = #{username}</if>
  129. <if test="password != null and !&quot;&quot;.equals(password)">and password = #{password}</if>
  130. <if test="salt != null and !&quot;&quot;.equals(salt)">and salt = #{salt}</if>
  131. <if test="locked != null and !&quot;&quot;.equals(locked)">and locked = #{locked}</if>
  132. <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">and del_flag = #{delFlag}</if>
  133. <if test="createTime != null and !&quot;&quot;.equals(createTime)">and create_time = #{createTime}</if>
  134. <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">and update_time = #{updateTime}</if>
  135. </where>
  136. order by id desc
  137. </select>
  138. <!-- 根据条件查询一个 -->
  139. <select id="querySysUser" parameterType="java.util.Map"
  140. resultType="com.pine.admin.modules.system.entity.SysUser">
  141. select
  142. <include refid="Base_Column_List"/>
  143. from sys_user
  144. <where>
  145. and del_flag = 'N'
  146. <if test="id != null and !&quot;&quot;.equals(id)">and id = #{id}</if>
  147. <if test="usercode != null and !&quot;&quot;.equals(usercode)">and usercode = #{usercode}</if>
  148. <if test="username != null and !&quot;&quot;.equals(username)">and username = #{username}</if>
  149. <if test="password != null and !&quot;&quot;.equals(password)">and password = #{password}</if>
  150. <if test="salt != null and !&quot;&quot;.equals(salt)">and salt = #{salt}</if>
  151. <if test="locked != null and !&quot;&quot;.equals(locked)">and locked = #{locked}</if>
  152. <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">and del_flag = #{delFlag}</if>
  153. <if test="createTime != null and !&quot;&quot;.equals(createTime)">and create_time = #{createTime}</if>
  154. <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">and update_time = #{updateTime}</if>
  155. </where>
  156. LIMIT 1
  157. </select>
  158. <update id="delete">
  159. UPDATE sys_user SET del_flag = 'Y'
  160. <where>
  161. AND id = #{id}
  162. </where>
  163. </update>
  164. </mapper>