UserDao.xml 5.6 KB

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