UserDao.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.kmall.admin.dao.UserDao">
  4. <resultMap type="com.kmall.admin.entity.UserEntity" id="userMap">
  5. <result property="id" column="id"/>
  6. <result property="username" column="username"/>
  7. <result property="password" column="password"/>
  8. <result property="gender" column="gender"/>
  9. <result property="birthday" column="birthday"/>
  10. <result property="registerTime" column="register_time"/>
  11. <result property="lastLoginTime" column="last_login_time"/>
  12. <result property="lastLoginIp" column="last_login_ip"/>
  13. <result property="userLevelId" column="user_level_id"/>
  14. <result property="nickname" column="nickname"/>
  15. <result property="mobile" column="mobile"/>
  16. <result property="registerIp" column="register_ip"/>
  17. <result property="avatar" column="avatar"/>
  18. <result property="weixinOpenid" column="weixin_openid"/>
  19. <result property="idNo" column="id_no"/>
  20. <result property="lastFaceTime" column="last_face_time"/>
  21. <result property="openId" column="open_id"/>
  22. <result property="memberCode" column="member_code"/>
  23. </resultMap>
  24. <select id="queryObject" resultType="com.kmall.admin.entity.UserEntity">
  25. select *
  26. from mall_user
  27. where id = #{id}
  28. </select>
  29. <select id="queryList" resultType="com.kmall.admin.entity.UserEntity">
  30. SELECT DISTINCT
  31. mu1.*
  32. FROM
  33. mall_store s
  34. LEFT JOIN mall_merch_user mu ON s.id = mu.store_id
  35. LEFT JOIN mall_user mu1 on mu1.id = mu.user_id
  36. WHERE 1=1
  37. <if test="storeId != null and storeId != ''">
  38. and mu.store_id = #{storeId}
  39. </if>
  40. <if test="merchSn != null and merchSn.trim() != ''">
  41. and mu.merch_sn = #{merchSn}
  42. </if>
  43. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  44. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  45. </if>
  46. <if test="username != null and username.trim() != ''">
  47. and mu1.username like concat('%',#{username},'%')
  48. </if>
  49. <if test="mobile != null and mobile.trim() != ''">
  50. and mu1.mobile like concat('%',#{mobile},'%')
  51. </if>
  52. <choose>
  53. <when test="sidx != null and sidx.trim() != ''">
  54. order by ${sidx} ${order}
  55. </when>
  56. <otherwise>
  57. order by id desc
  58. </otherwise>
  59. </choose>
  60. <if test="offset != null and limit != null">
  61. limit #{offset}, #{limit}
  62. </if>
  63. </select>
  64. <select id="queryTotal" resultType="int">
  65. select count(distinct mall_user.id)
  66. FROM
  67. mall_store s
  68. LEFT JOIN mall_merch_user mu ON mu.store_id = s.id
  69. left join mall_user on mall_user.id = mu.user_id
  70. LEFT JOIN mall_user_level ON mall_user.user_level_id = mall_user_level.id
  71. WHERE 1=1
  72. <if test="storeId != null and storeId != ''">
  73. and mu.store_id = #{storeId}
  74. </if>
  75. <if test="merchSn != null and merchSn.trim() != ''">
  76. and mu.merch_sn = #{merchSn}
  77. </if>
  78. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  79. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  80. </if>
  81. <if test="username != null and username.trim() != ''">
  82. and username like concat('%',#{username},'%')
  83. </if>
  84. <if test="mobile != null and mobile.trim() != ''">
  85. and mobile like concat('%',#{mobile},'%')
  86. </if>
  87. </select>
  88. <insert id="save" parameterType="com.kmall.admin.entity.UserEntity" useGeneratedKeys="true" keyProperty="id">
  89. insert into mall_user(
  90. `username`,
  91. `password`,
  92. `id_no`,
  93. `gender`,
  94. `birthday`,
  95. `register_time`,
  96. `last_login_time`,
  97. `last_login_ip`,
  98. `user_level_id`,
  99. `nickname`,
  100. `mobile`,
  101. `register_ip`,
  102. `avatar`,
  103. `weixin_openid`,
  104. last_face_time,
  105. `open_id`,
  106. `member_code`)
  107. values(
  108. #{username},
  109. #{password},
  110. #{idNo},
  111. #{gender},
  112. #{birthday},
  113. #{registerTime},
  114. #{lastLoginTime},
  115. #{lastLoginIp},
  116. #{userLevelId},
  117. #{nickname},
  118. #{mobile},
  119. #{registerIp},
  120. #{avatar},
  121. #{weixinOpenid},
  122. #{lastFaceTime},
  123. #{openId},
  124. #{memberCode})
  125. </insert>
  126. <update id="update" parameterType="com.kmall.admin.entity.UserEntity">
  127. update mall_user
  128. <set>
  129. <if test="username != null">`username` = #{username},</if>
  130. <if test="password != null">`password` = #{password},</if>
  131. <if test="idNo != null">`id_no` = #{idNo},</if>
  132. <if test="gender != null">`gender` = #{gender},</if>
  133. <if test="birthday != null">`birthday` = #{birthday},</if>
  134. <if test="registerTime != null">`register_time` = #{registerTime},</if>
  135. <if test="lastLoginTime != null">`last_login_time` = #{lastLoginTime},</if>
  136. <if test="lastLoginIp != null">`last_login_ip` = #{lastLoginIp},</if>
  137. <if test="userLevelId != null">`user_level_id` = #{userLevelId},</if>
  138. <if test="nickname != null">`nickname` = #{nickname},</if>
  139. <if test="mobile != null">`mobile` = #{mobile},</if>
  140. <if test="registerIp != null">`register_ip` = #{registerIp},</if>
  141. <if test="avatar != null">`avatar` = #{avatar},</if>
  142. <if test="weixinOpenid != null">`weixin_openid` = #{weixinOpenid},</if>
  143. <if test="lastFaceTime != null">`last_face_time` = #{lastFaceTime},</if>
  144. <if test="openId != null">`open_id` = #{openId},</if>
  145. <if test="memberCode != null">`member_code` = #{memberCode}</if>
  146. </set>
  147. where id = #{id}
  148. </update>
  149. <delete id="delete">
  150. delete from mall_user where id = #{value}
  151. </delete>
  152. <delete id="deleteBatch">
  153. delete from mall_user where id in
  154. <foreach item="id" collection="array" open="(" separator="," close=")">
  155. #{id}
  156. </foreach>
  157. </delete>
  158. <select id="queryByMobile" resultType="com.kmall.admin.entity.UserEntity">
  159. select *
  160. from mall_user
  161. where mobile = #{mobile}
  162. </select>
  163. <select id="queryByOpenId" resultType="com.kmall.admin.entity.UserEntity">
  164. select *
  165. from mall_user
  166. where open_id = #{openId}
  167. </select>
  168. </mapper>