SysUserMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.auth.dal.dao.SysUserDao">
  8. <resultMap type="com.ym.mec.auth.api.entity.SysUser" id="SysUser">
  9. <result column="id_" property="id"/>
  10. <result column="username_" property="username"/>
  11. <result column="password_" property="password"/>
  12. <result column="salt_" property="salt"/>
  13. <result column="phone_" property="phone"/>
  14. <result column="avatar_" property="avatar"/>
  15. <result column="organ_id_" property="organId"/>
  16. <result column="create_time_" property="createTime"/>
  17. <result column="update_time_" property="updateTime"/>
  18. <result column="lock_flag_" property="lockFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  19. <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  20. <result column="wx_openid_" property="wxOpenid"/>
  21. <result column="qq_openid_" property="qqOpenid"/>
  22. <result column="user_type_" property="userType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  23. <result column="gender_" property="gender"/>
  24. <result column="nation_" property="nation"/>
  25. <result column="birthdate_" property="birthdate"/>
  26. <result column="email_" property="email"/>
  27. <result column="im_token_" property="imToken"/>
  28. <result column="id_card_no_" property="idCardNo"/>
  29. <result column="wechat_id_" property="wechatId"/>
  30. </resultMap>
  31. <!-- 查询条件 -->
  32. <sql id="queryCondition">
  33. <if test="userStartDate != null">
  34. and create_time_ &gt;= #{createStartDate}
  35. </if>
  36. <if test="userEndDate != null">
  37. and create_time_ &lt;= #{createEndDate}
  38. </if>
  39. <if test="userType != null">
  40. and user_type_ = #{userType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  41. </if>
  42. <if test="organId != null">
  43. and organ_id_ = #{organId}
  44. </if>
  45. </sql>
  46. <!-- 根据主键查询一条记录 -->
  47. <select id="get" resultMap="SysUser">
  48. SELECT * FROM sys_user WHERE id_ = #{id}
  49. </select>
  50. <!-- 全查询 -->
  51. <select id="findAll" resultMap="SysUser">
  52. SELECT * FROM sys_user ORDER BY id_
  53. </select>
  54. <!-- 向数据库增加一条记录 -->
  55. <insert id="insert" parameterType="com.ym.mec.auth.api.entity.SysUser" useGeneratedKeys="true" keyColumn="id"
  56. keyProperty="id">
  57. <!--
  58. <selectKey resultClass="int" keyProperty="id" >
  59. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  60. </selectKey>
  61. -->
  62. INSERT INTO sys_user
  63. (im_token_,id_,username_,salt_,phone_,avatar_,organ_id_,create_time_,update_time_,wx_openid_,qq_openid_,user_type_,gender_,nation_,birthdate_,email_,id_card_no_,wechat_id_,real_name_)
  64. VALUES(#{imToken},#{id},#{username},#{salt},#{phone},#{avatar},#{organId},now(),now(),#{wxOpenid},#{qqOpenid},#{userType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  65. #{gender},#{nation},#{birthdate},#{email},#{idCardNo},#{wechatId},#{realName})
  66. </insert>
  67. <!-- 根据主键查询一条记录 -->
  68. <update id="update" parameterType="com.ym.mec.auth.api.entity.SysUser">
  69. UPDATE sys_user
  70. <set>
  71. <if test="delFlag != null">
  72. del_flag_ = #{delFlag, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  73. </if>
  74. <if test="wxOpenid != null">
  75. wx_openid_ = #{wxOpenid},
  76. </if>
  77. <if test="avatar != null">
  78. avatar_ = #{avatar},
  79. </if>
  80. <if test="email != null">
  81. email_ = #{email},
  82. </if>
  83. <if test="gender != null">
  84. gender_ = #{gender},
  85. </if>
  86. <if test="salt != null">
  87. salt_ = #{salt},
  88. </if>
  89. <if test="username != null">
  90. username_ = #{username},
  91. </if>
  92. <if test="userType != null">
  93. user_type_ = #{userType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  94. </if>
  95. <if test="updateTime != null">
  96. update_time_ = #{updateTime},
  97. </if>
  98. <if test="lockFlag != null">
  99. lock_flag_ = #{lockFlag, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  100. </if>
  101. <if test="birthdate != null">
  102. birthdate_ = #{birthdate},
  103. </if>
  104. <if test="phone != null">
  105. phone_ = #{phone},
  106. </if>
  107. <if test="qqOpenid != null">
  108. qq_openid_ = #{qqOpenid},
  109. </if>
  110. <if test="nation != null">
  111. nation_ = #{nation},
  112. </if>
  113. <if test="organId != null">
  114. organ_id_ = #{organId},
  115. </if>
  116. <if test="imToken != null">
  117. im_token_ = #{imToken},
  118. </if>
  119. <if test="idCardNo != null">
  120. id_card_no_ = #{idCardNo},
  121. </if>
  122. <if test="password != null">
  123. password_ = #{password},
  124. </if>
  125. <if test="wechatId != null">
  126. wechat_id_ = #{wechatId},
  127. </if>
  128. <if test="realName != null">
  129. real_name = #{realName},
  130. </if>
  131. </set>
  132. WHERE id_ = #{id}
  133. </update>
  134. <update id="updatePassword">
  135. UPDATE sys_user SET password_ = #{password} WHERE phone_ = #{mobile}
  136. </update>
  137. <!-- 根据主键删除一条记录 -->
  138. <delete id="delete">
  139. UPDATE sys_user SET del_flag_ = 1 WHERE id_ = #{id}
  140. </delete>
  141. <!-- 分页查询 -->
  142. <select id="queryPage" resultMap="SysUser" parameterType="map">
  143. SELECT * FROM sys_user ORDER BY id_
  144. <include refid="queryCondition"/>
  145. <include refid="global.orderby"/>
  146. <include refid="global.limit"/>
  147. </select>
  148. <!-- 查询当前表的总记录数 -->
  149. <select id="queryCount" resultType="int">
  150. SELECT COUNT(*) FROM sys_user
  151. <include refid="queryCondition"/>
  152. </select>
  153. <select id="queryByUsername" resultMap="SysUser">
  154. select * from sys_user where username_ = #{username} OR phone_ = #{username}
  155. </select>
  156. <select id="queryByPhone" resultMap="SysUser">
  157. select * from sys_user where phone_ = #{phone} OR username_ = #{phone}
  158. </select>
  159. <resultMap id="ImUserModel" type="com.ym.mec.common.entity.ImUserModel">
  160. <result column="id_" property="id"/>
  161. <result property="name" column="username_"/>
  162. <result property="portrait" column="avatar_"/>
  163. </resultMap>
  164. <select id="getBasic" resultMap="ImUserModel">
  165. select * from sys_user where id_ = #{userId}
  166. </select>
  167. </mapper>