1
0

ApiUserMapper.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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="queryByOpenId" resultMap="BaseResultMap">
  39. select
  40. <include refid="Base_Column_List" />
  41. from mall_user
  42. where 1 = 1
  43. <if test="openId != null">
  44. and `weixin_openid` = #{openId}
  45. </if>
  46. </select>
  47. <select id="queryList" resultMap="BaseResultMap">
  48. select
  49. <include refid="Base_Column_List" />
  50. from mall_user
  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(*) from mall_user
  65. </select>
  66. <insert id="save" parameterType="com.kmall.api.entity.UserVo" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
  67. insert into mall_user
  68. <trim prefix="(" suffix=")" suffixOverrides="," >
  69. `username`,
  70. `password`,
  71. `gender`,
  72. `birthday`,
  73. `register_time`,
  74. `last_login_time`,
  75. `last_login_ip`,
  76. `user_level_id`,
  77. `nickname`,
  78. `mobile`,
  79. `register_ip`,
  80. `avatar`,
  81. `weixin_openid`,
  82. <if test="idNo != null" >
  83. id_no,
  84. </if>
  85. <if test="createrSn != null" >
  86. creater_sn,
  87. </if>
  88. <if test="createTime != null" >
  89. create_time,
  90. </if>
  91. <if test="moderSn != null" >
  92. moder_sn,
  93. </if>
  94. <if test="modTime != null" >
  95. mod_time,
  96. </if>
  97. <if test="tstm != null" >
  98. tstm,
  99. </if>
  100. </trim>
  101. <trim prefix="values (" suffix=")" suffixOverrides="," >
  102. #{username},
  103. #{password},
  104. #{gender},
  105. #{birthday},
  106. #{register_time},
  107. #{last_login_time},
  108. #{last_login_ip},
  109. #{user_level_id},
  110. #{nickname},
  111. #{mobile},
  112. #{register_ip},
  113. #{avatar},
  114. #{weixin_openid},
  115. <if test="idNo != null" >
  116. #{idNo,jdbcType=VARCHAR},
  117. </if>
  118. <if test="createrSn != null" >
  119. #{createrSn,jdbcType=VARCHAR},
  120. </if>
  121. <if test="createTime != null" >
  122. #{createTime,jdbcType=TIMESTAMP},
  123. </if>
  124. <if test="moderSn != null" >
  125. #{moderSn,jdbcType=VARCHAR},
  126. </if>
  127. <if test="modTime != null" >
  128. #{modTime,jdbcType=TIMESTAMP},
  129. </if>
  130. <if test="tstm != null" >
  131. #{tstm,jdbcType=TIMESTAMP},
  132. </if>
  133. </trim>
  134. </insert>
  135. <update id="update" parameterType="com.kmall.api.entity.UserVo">
  136. update mall_user
  137. <set >
  138. <if test="username != null">`username` = #{username},</if>
  139. <if test="password != null">`password` = #{password},</if>
  140. <if test="gender != null">`gender` = #{gender},</if>
  141. <if test="birthday != null">`birthday` = #{birthday},</if>
  142. <if test="register_time != null">`register_time` = #{register_time},</if>
  143. <if test="last_login_time != null">`last_login_time` = #{last_login_time},</if>
  144. <if test="last_login_ip != null">`last_login_ip` = #{last_login_ip},</if>
  145. <if test="user_level_id != null">`user_level_id` = #{user_level_id},</if>
  146. <if test="nickname != null">`nickname` = #{nickname},</if>
  147. <if test="mobile != null">`mobile` = #{mobile},</if>
  148. <if test="register_ip != null">`register_ip` = #{register_ip},</if>
  149. <if test="avatar != null">`avatar` = #{avatar},</if>
  150. <if test="weixin_openid != null">`weixin_openid` = #{weixin_openid},</if>
  151. <if test="idNo != null" >
  152. id_no = #{idNo,jdbcType=VARCHAR},
  153. </if>
  154. <if test="createrSn != null" >
  155. creater_sn = #{createrSn,jdbcType=VARCHAR},
  156. </if>
  157. <if test="createTime != null" >
  158. create_time = #{createTime,jdbcType=TIMESTAMP},
  159. </if>
  160. <if test="moderSn != null" >
  161. moder_sn = #{moderSn,jdbcType=VARCHAR},
  162. </if>
  163. <if test="modTime != null" >
  164. mod_time = #{modTime,jdbcType=TIMESTAMP},
  165. </if>
  166. <if test="tstm != null" >
  167. tstm = #{tstm,jdbcType=TIMESTAMP},
  168. </if>
  169. </set>
  170. where id = #{id,jdbcType=INTEGER}
  171. </update>
  172. <!-- 可根据自己的需求,是否要使用 -->
  173. <resultMap type="com.kmall.api.entity.SmsLogVo" id="smslogMap">
  174. <result property="id" column="id"/>
  175. <result property="user_id" column="user_id"/>
  176. <result property="mobile" column="mobile"/>
  177. <result property="stime" column="stime"/>
  178. <result property="sms_code" column="sms_code"/>
  179. <result property="send_status" column="send_status"/>
  180. <result property="content" column="content"/>
  181. <result property="smsode" column="sms_code"/>
  182. </resultMap>
  183. <select id="querySmsCodeByUserId" resultMap="smslogMap">
  184. a.id,
  185. a.user_id,
  186. a.mobile,
  187. a.stime,
  188. a.sms_code,
  189. a.send_status,
  190. a.content
  191. from sys_sms_log a
  192. left join sys_user b on a.user_id = b.user_id
  193. where a.user_id = #{id} ORDER BY stime desc limit 1
  194. </select>
  195. <insert id="saveSmsCodeLog" parameterType="com.kmall.api.entity.SmsLogVo">
  196. insert into mall_sms_log(
  197. `id`,
  198. `user_id`,
  199. `phone`,
  200. `log_date`,
  201. `sms_code`,
  202. `send_status`,
  203. `sms_text`)
  204. values(
  205. #{id},
  206. #{user_id},
  207. #{phone},
  208. #{log_date},
  209. #{sms_code},
  210. #{send_status},
  211. #{sms_text}
  212. )
  213. </insert>
  214. </mapper>