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