UserDao.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. </resultMap>
  22. <select id="queryObject" resultType="com.kmall.admin.entity.UserEntity">
  23. select *
  24. from mall_user
  25. where id = #{id}
  26. </select>
  27. <select id="queryList" resultType="com.kmall.admin.entity.UserEntity">
  28. SELECT DISTINCT
  29. mall_user.*
  30. ,mall_user_level.NAME levelName
  31. FROM
  32. mall_user
  33. LEFT JOIN mall_user_level ON mall_user.user_level_id = mall_user_level.id
  34. LEFT JOIN mall_merch_user mu ON mall_user.id = mu.user_id
  35. LEFT JOIN mall_store s on mu.store_id = s.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 mall_user.username like concat('%',#{username},'%')
  48. </if>
  49. <if test="mobile != null and mobile.trim() != ''">
  50. and mall_user.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. values(
  106. #{username},
  107. #{password},
  108. #{idNo},
  109. #{gender},
  110. #{birthday},
  111. #{registerTime},
  112. #{lastLoginTime},
  113. #{lastLoginIp},
  114. #{userLevelId},
  115. #{nickname},
  116. #{mobile},
  117. #{registerIp},
  118. #{avatar},
  119. #{weixinOpenid},
  120. #{lastFaceTime})
  121. </insert>
  122. <update id="update" parameterType="com.kmall.admin.entity.UserEntity">
  123. update mall_user
  124. <set>
  125. <if test="username != null">`username` = #{username},</if>
  126. <if test="password != null">`password` = #{password},</if>
  127. <if test="gender != null">`gender` = #{gender},</if>
  128. <if test="birthday != null">`birthday` = #{birthday},</if>
  129. <if test="registerTime != null">`register_time` = #{registerTime},</if>
  130. <if test="lastLoginTime != null">`last_login_time` = #{lastLoginTime},</if>
  131. <if test="lastLoginIp != null">`last_login_ip` = #{lastLoginIp},</if>
  132. <if test="userLevelId != null">`user_level_id` = #{userLevelId},</if>
  133. <if test="nickname != null">`nickname` = #{nickname},</if>
  134. <if test="mobile != null">`mobile` = #{mobile},</if>
  135. <if test="registerIp != null">`register_ip` = #{registerIp},</if>
  136. <if test="avatar != null">`avatar` = #{avatar},</if>
  137. <if test="weixinOpenid != null">`weixin_openid` = #{weixinOpenid}</if>
  138. <if test="lastFaceTime != null">`last_face_time` = #{lastFaceTime}</if>
  139. </set>
  140. where id = #{id}
  141. </update>
  142. <delete id="delete">
  143. delete from mall_user where id = #{value}
  144. </delete>
  145. <delete id="deleteBatch">
  146. delete from mall_user where id in
  147. <foreach item="id" collection="array" open="(" separator="," close=")">
  148. #{id}
  149. </foreach>
  150. </delete>
  151. <select id="queryByMobile" resultType="com.kmall.admin.entity.UserEntity">
  152. select *
  153. from mall_user
  154. where mobile = #{mobile}
  155. </select>
  156. </mapper>