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