SysUserMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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"/>
  19. <result column="del_flag_" property="delFlag"/>
  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" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  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. </resultMap>
  29. <!-- 查询条件 -->
  30. <sql id="queryCondition">
  31. <if test="userStartDate != null">
  32. and create_time_ &gt;= #{createStartDate}
  33. </if>
  34. <if test="userEndDate != null">
  35. and create_time_ &lt;= #{createEndDate}
  36. </if>
  37. <if test="userType != null">
  38. and user_type_ = #{userType}
  39. </if>
  40. <if test="organId != null">
  41. and organ_id_ = #{organId}
  42. </if>
  43. </sql>
  44. <!-- 根据主键查询一条记录 -->
  45. <select id="get" resultMap="SysUser">
  46. SELECT * FROM sys_user WHERE id_ = #{id}
  47. </select>
  48. <!-- 全查询 -->
  49. <select id="findAll" resultMap="SysUser">
  50. SELECT * FROM sys_user ORDER BY id_
  51. </select>
  52. <!-- 向数据库增加一条记录 -->
  53. <insert id="insert" parameterType="com.ym.mec.auth.api.entity.SysUser" useGeneratedKeys="true" keyColumn="id"
  54. keyProperty="id">
  55. <!--
  56. <selectKey resultClass="int" keyProperty="id" >
  57. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  58. </selectKey>
  59. -->
  60. INSERT INTO sys_user
  61. (im_token_,id_,username_,password_,salt_,phone_,avatar_,organ_id_,create_time_,update_time_,lock_flag_,del_flag_,wx_openid_,qq_openid_,user_type_,gender_,nation_,birthdate_,email_)
  62. VALUES(#{imToken},#{id},#{username},#{password},#{salt},#{phone},#{avatar},#{organId},#{createTime},#{updateTime},#{lockFlag},#{delFlag},#{wxOpenid},#{qqOpenid},#{userType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{gender, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{nation},#{birthdate},#{email})
  63. </insert>
  64. <!-- 根据主键查询一条记录 -->
  65. <update id="update" parameterType="com.ym.mec.auth.api.entity.SysUser">
  66. UPDATE sys_user
  67. <set>
  68. <if test="delFlag != null">
  69. del_flag_ = #{delFlag},
  70. </if>
  71. <if test="wxOpenid != null">
  72. wx_openid_ = #{wxOpenid},
  73. </if>
  74. <if test="avatar != null">
  75. avatar_ = #{avatar},
  76. </if>
  77. <if test="email != null">
  78. email_ = #{email},
  79. </if>
  80. <if test="gender != null">
  81. gender_ = #{gender, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  82. </if>
  83. <if test="password != null">
  84. password_ = #{password},
  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},
  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. </set>
  120. WHERE id_ = #{id}
  121. </update>
  122. <!-- 根据主键删除一条记录 -->
  123. <delete id="delete">
  124. DELETE FROM sys_user WHERE id_ = #{id}
  125. </delete>
  126. <!-- 分页查询 -->
  127. <select id="queryPage" resultMap="SysUser" parameterType="map">
  128. SELECT * FROM sys_user ORDER BY id_
  129. <include refid="queryCondition"/>
  130. <include refid="global.orderby"/>
  131. <include refid="global.limit"/>
  132. </select>
  133. <!-- 查询当前表的总记录数 -->
  134. <select id="queryCount" resultType="int">
  135. SELECT COUNT(*) FROM sys_user
  136. <include refid="queryCondition"/>
  137. </select>
  138. <select id="queryByUsername" resultMap="SysUser">
  139. select * from sys_user where username_ = #{username} OR phone_ = #{username}
  140. </select>
  141. <select id="queryByPhone" resultMap="SysUser">
  142. select * from sys_user where phone_ = #{phone} OR username_ = #{phone}
  143. </select>
  144. </mapper>