1
0

ApiUserMapper.xml 8.3 KB

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