SysUserMapper.xml 7.8 KB

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