SysUserMapper.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.yonge.cooleshow.biz.dal.mapper.SysUserMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.SysUser">
  6. <id column="id_" property="id" />
  7. <result column="username_" property="username" />
  8. <result column="password_" property="password" />
  9. <result column="salt_" property="salt" />
  10. <result column="phone_" property="phone" />
  11. <result column="avatar_" property="avatar" />
  12. <result column="create_time_" property="createTime" />
  13. <result column="update_time_" property="updateTime" />
  14. <result column="lock_flag_" property="lockFlag" />
  15. <result column="wx_openid_" property="wxOpenid" />
  16. <result column="qq_openid_" property="qqOpenid" />
  17. <result column="user_type_" property="userType" />
  18. <result column="gender_" property="gender" />
  19. <result column="nation_" property="nation" />
  20. <result column="birthdate_" property="birthdate" />
  21. <result column="email_" property="email" />
  22. <result column="im_token_" property="imToken" />
  23. <result column="real_name_" property="realName" />
  24. <result column="id_card_no_" property="idCardNo" />
  25. <result column="certificate_type_" property="certificateType" />
  26. <result column="is_super_admin_" property="superAdmin" />
  27. <result column="wechat_id_" property="wechatId" />
  28. <result column="del_flag_" property="delFlag" />
  29. <result column="last_username_time_" property="lastUsernameTime" />
  30. </resultMap>
  31. <!-- 通用查询结果列 -->
  32. <sql id="Base_Column_List">
  33. id_, username_, password_, salt_, phone_, avatar_, create_time_, update_time_, lock_flag_, wx_openid_, qq_openid_, user_type_, gender_, nation_, birthdate_, email_, im_token_, real_name_, id_card_no_, certificate_type_, is_super_admin_, wechat_id_, del_flag_, last_username_time_
  34. </sql>
  35. <select id="queryCouponIssueUser" resultType="com.yonge.cooleshow.biz.dal.vo.CouponIssueUserVo">
  36. select
  37. su.id_ as userId,
  38. su.username_ as username,
  39. su.real_name_ as realName,
  40. #{client} as clientType,
  41. su.phone_ as phone
  42. from
  43. <choose>
  44. <when test="client.code == 'TEACHER'">
  45. teacher t
  46. </when>
  47. <when test="client.code == 'STUDENT'">
  48. student t
  49. </when>
  50. </choose>
  51. left join sys_user su on su.id_ = t.user_id_
  52. <where>
  53. t.lock_flag_ = 0 and su.del_flag_ = 0
  54. <if test="keyword != null and keyword != ''">
  55. and (
  56. su.real_name_ like concat('%',#{keyword},'%')
  57. or su.username_ like concat('%',#{keyword},'%')
  58. or su.phone_ like concat('%',#{keyword},'%')
  59. or su.id_ like concat('%',#{keyword},'%')
  60. )
  61. </if>
  62. <if test="client.code == 'STUDENT'">
  63. AND t.tenant_id_ = -1
  64. </if>
  65. </where>
  66. </select>
  67. <update id="updateUserCard">
  68. UPDATE sys_user
  69. set
  70. <if test="param.realName != null and param.realName != ''">
  71. real_name_ = #{param.realName},
  72. </if>
  73. <if test="param.idCardNo != null and param.idCardNo != ''">
  74. id_card_no_ = #{param.idCardNo},
  75. </if>
  76. <if test="param.gender != null">
  77. gender_ = #{param.gender},
  78. </if>
  79. <if test="param.birthday != null">
  80. birthdate_ = #{param.birthday},
  81. </if>
  82. update_time_ = now()
  83. WHERE del_flag_ = 0 and id_ = #{param.userId}
  84. </update>
  85. <!--客服消息接收者-->
  86. <select id="selectMessageReceives"
  87. resultType="com.yonge.cooleshow.biz.dal.wrapper.im.CustomerService$MessageReceives">
  88. SELECT t1.id_ AS userId, t1.username_ FROM sys_user t1
  89. <if test="param.clientType != null">
  90. <if test="param.clientType.code == 'TEACHER'"> LEFT JOIN teacher t2 ON (t1.id_ = t2.user_id_)</if>
  91. <if test="param.clientType.code == 'STUDENT'"> LEFT JOIN student t2 ON (t1.id_ = t2.user_id_)</if>
  92. </if>
  93. <where>
  94. <if test="param.receives != null">
  95. AND t1.phone_ IN (<foreach collection="param.receives" separator="," item="item">#{item}</foreach>)
  96. </if>
  97. <if test="param.subjectId != null">
  98. AND FIND_IN_SET(#{param.subjectId}, t2.subject_id_)
  99. </if>
  100. </where>
  101. LIMIT 1500
  102. </select>
  103. <select id="findUserByPhone" resultType="com.yonge.cooleshow.auth.api.entity.SysUser">
  104. SELECT * FROM sys_user WHERE phone_ = #{phone} AND del_flag_ = 0
  105. </select>
  106. <select id="getByUserId" resultType="com.yonge.cooleshow.auth.api.entity.SysUser">
  107. select id_ as id,
  108. username_ as username,
  109. password_ as password,
  110. salt_ as salt,
  111. del_flag_ as delFlag,
  112. phone_ as phone,
  113. avatar_ as avatar,
  114. lock_flag_ as lockFlag,
  115. user_type_ as userType,
  116. gender_ as gender,
  117. nation_ as nation,
  118. birthdate_ as birthdate,
  119. email_ as email,
  120. im_token_ as imToken,
  121. real_name_ as realName,
  122. id_card_no_ as idCardNo,
  123. certificate_type_ as certificateType
  124. from sys_user
  125. where id_ = #{userId}
  126. </select>
  127. <!--客服消息接收者-->
  128. </mapper>