1
0

ApiUserMapper.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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.api.dao.ApiUserMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap id="BaseResultMap" type="com.kmall.api.entity.UserVo" >
  6. <result property="id" column="id"/>
  7. <result property="username" column="username"/>
  8. <result property="password" column="password"/>
  9. <result property="gender" column="gender"/>
  10. <result property="birthday" column="birthday"/>
  11. <result property="register_time" column="register_time"/>
  12. <result property="last_login_time" column="last_login_time"/>
  13. <result property="last_login_ip" column="last_login_ip"/>
  14. <result property="user_level_id" column="user_level_id"/>
  15. <result property="nickname" column="nickname"/>
  16. <result property="mobile" column="mobile"/>
  17. <result property="register_ip" column="register_ip"/>
  18. <result property="avatar" column="avatar"/>
  19. <result property="weixin_openid" column="weixin_openid"/>
  20. <result column="id_no" property="idNo" jdbcType="VARCHAR" />
  21. <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
  22. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  23. <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
  24. <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
  25. <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
  26. </resultMap>
  27. <sql id="Base_Column_List" >
  28. id, username, password, gender, birthday, register_time, last_login_time, last_login_ip,
  29. user_level_id, nickname, mobile, register_ip, avatar, weixin_openid, id_no, creater_sn,
  30. create_time, moder_sn, mod_time, tstm
  31. </sql>
  32. <select id="queryObject" resultMap="BaseResultMap" >
  33. select
  34. <include refid="Base_Column_List" />
  35. from mall_user
  36. where id = #{id}
  37. </select>
  38. <select id="queryByMobile" resultMap="BaseResultMap" >
  39. select
  40. <include refid="Base_Column_List" />
  41. from mall_user
  42. where mobile = #{mobile}
  43. </select>
  44. <select id="queryObjectByIdNoAndName" resultMap="BaseResultMap" >
  45. select
  46. <include refid="Base_Column_List" />
  47. from mall_user
  48. where id_no = #{idNo} and username = #{userName}
  49. </select>
  50. <select id="queryByOpenId" resultMap="BaseResultMap">
  51. select
  52. <include refid="Base_Column_List" />
  53. from mall_user
  54. where 1 = 1
  55. <if test="openId != null">
  56. and `weixin_openid` = #{openId}
  57. </if>
  58. </select>
  59. <select id="queryList" resultMap="BaseResultMap">
  60. select
  61. <include refid="Base_Column_List" />
  62. from mall_user
  63. <choose>
  64. <when test="sidx != null and sidx.trim() != ''">
  65. order by ${sidx} ${order}
  66. </when>
  67. <otherwise>
  68. order by id desc
  69. </otherwise>
  70. </choose>
  71. <if test="offset != null and limit != null">
  72. limit #{offset}, #{limit}
  73. </if>
  74. </select>
  75. <select id="queryTotal" resultType="int">
  76. select count(*) from mall_user
  77. </select>
  78. <insert id="save" parameterType="com.kmall.api.entity.UserVo" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
  79. insert into mall_user
  80. <trim prefix="(" suffix=")" suffixOverrides="," >
  81. `username`,
  82. `password`,
  83. `gender`,
  84. `birthday`,
  85. `register_time`,
  86. `last_login_time`,
  87. `last_login_ip`,
  88. `user_level_id`,
  89. `nickname`,
  90. `mobile`,
  91. `register_ip`,
  92. `avatar`,
  93. `weixin_openid`,
  94. <if test="idNo != null" >
  95. id_no,
  96. </if>
  97. <if test="createrSn != null" >
  98. creater_sn,
  99. </if>
  100. <if test="createTime != null" >
  101. create_time,
  102. </if>
  103. <if test="moderSn != null" >
  104. moder_sn,
  105. </if>
  106. <if test="modTime != null" >
  107. mod_time,
  108. </if>
  109. <if test="tstm != null" >
  110. tstm,
  111. </if>
  112. </trim>
  113. <trim prefix="values (" suffix=")" suffixOverrides="," >
  114. #{username},
  115. #{password},
  116. #{gender},
  117. #{birthday},
  118. #{register_time},
  119. #{last_login_time},
  120. #{last_login_ip},
  121. #{user_level_id},
  122. #{nickname},
  123. #{mobile},
  124. #{register_ip},
  125. #{avatar},
  126. #{weixin_openid},
  127. <if test="idNo != null" >
  128. #{idNo,jdbcType=VARCHAR},
  129. </if>
  130. <if test="createrSn != null" >
  131. #{createrSn,jdbcType=VARCHAR},
  132. </if>
  133. <if test="createTime != null" >
  134. #{createTime,jdbcType=TIMESTAMP},
  135. </if>
  136. <if test="moderSn != null" >
  137. #{moderSn,jdbcType=VARCHAR},
  138. </if>
  139. <if test="modTime != null" >
  140. #{modTime,jdbcType=TIMESTAMP},
  141. </if>
  142. <if test="tstm != null" >
  143. #{tstm,jdbcType=TIMESTAMP},
  144. </if>
  145. </trim>
  146. </insert>
  147. <update id="update" parameterType="com.kmall.api.entity.UserVo">
  148. update mall_user
  149. <set >
  150. <if test="username != null">`username` = #{username},</if>
  151. <if test="password != null">`password` = #{password},</if>
  152. <if test="gender != null">`gender` = #{gender},</if>
  153. <if test="birthday != null">`birthday` = #{birthday},</if>
  154. <if test="register_time != null">`register_time` = #{register_time},</if>
  155. <if test="last_login_time != null">`last_login_time` = #{last_login_time},</if>
  156. <if test="last_login_ip != null">`last_login_ip` = #{last_login_ip},</if>
  157. <if test="user_level_id != null">`user_level_id` = #{user_level_id},</if>
  158. <if test="nickname != null">`nickname` = #{nickname},</if>
  159. <if test="mobile != null">`mobile` = #{mobile},</if>
  160. <if test="register_ip != null">`register_ip` = #{register_ip},</if>
  161. <if test="avatar != null">`avatar` = #{avatar},</if>
  162. <if test="weixin_openid != null">`weixin_openid` = #{weixin_openid},</if>
  163. <if test="idNo != null" >
  164. id_no = #{idNo,jdbcType=VARCHAR},
  165. </if>
  166. <if test="createrSn != null" >
  167. creater_sn = #{createrSn,jdbcType=VARCHAR},
  168. </if>
  169. <if test="createTime != null" >
  170. create_time = #{createTime,jdbcType=TIMESTAMP},
  171. </if>
  172. <if test="moderSn != null" >
  173. moder_sn = #{moderSn,jdbcType=VARCHAR},
  174. </if>
  175. <if test="modTime != null" >
  176. mod_time = #{modTime,jdbcType=TIMESTAMP},
  177. </if>
  178. <if test="tstm != null" >
  179. tstm = #{tstm,jdbcType=TIMESTAMP},
  180. </if>
  181. </set>
  182. where id = #{id,jdbcType=INTEGER}
  183. </update>
  184. <!-- 可根据自己的需求,是否要使用 -->
  185. <resultMap type="com.kmall.api.entity.SmsLogVo" id="smslogMap">
  186. <result property="id" column="id"/>
  187. <result property="user_id" column="user_id"/>
  188. <result property="mobile" column="mobile"/>
  189. <result property="stime" column="stime"/>
  190. <result property="sms_code" column="sms_code"/>
  191. <result property="send_status" column="send_status"/>
  192. <result property="content" column="content"/>
  193. <result property="smsode" column="sms_code"/>
  194. </resultMap>
  195. <select id="querySmsCodeByUserId" resultMap="smslogMap">
  196. a.id,
  197. a.user_id,
  198. a.mobile,
  199. a.stime,
  200. a.sms_code,
  201. a.send_status,
  202. a.content
  203. from sys_sms_log a
  204. left join sys_user b on a.user_id = b.user_id
  205. where a.user_id = #{id} ORDER BY stime desc limit 1
  206. </select>
  207. <insert id="saveSmsCodeLog" parameterType="com.kmall.api.entity.SmsLogVo">
  208. insert into mall_sms_log(
  209. `id`,
  210. `user_id`,
  211. `phone`,
  212. `log_date`,
  213. `sms_code`,
  214. `send_status`,
  215. `sms_text`)
  216. values(
  217. #{id},
  218. #{user_id},
  219. #{phone},
  220. #{log_date},
  221. #{sms_code},
  222. #{send_status},
  223. #{sms_text}
  224. )
  225. </insert>
  226. </mapper>