ApiUserMapper.xml 8.9 KB

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