WatchUserMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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.fs.watch.mapper.WatchUserMapper">
  4. <resultMap type="com.fs.watch.domain.WatchUser" id="WatchUserMap">
  5. <result property="userId" column="user_id" jdbcType="INTEGER"/>
  6. <result property="sex" column="sex" jdbcType="INTEGER"/>
  7. <result property="birthday" column="birthday"/>
  8. <result property="wCompanyId" column="w_company_id" jdbcType="INTEGER"/>
  9. <result property="height" column="height" jdbcType="INTEGER"/>
  10. <result property="weight" column="weight" jdbcType="INTEGER"/>
  11. <result property="targetStep" column="target_step" jdbcType="VARCHAR"/>
  12. <result property="targetCalorie" column="target_calorie" jdbcType="VARCHAR"/>
  13. <result property="targetActivity" column="target_activity" jdbcType="VARCHAR"/>
  14. <result property="targetSport" column="target_sport" jdbcType="VARCHAR"/>
  15. <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>
  16. <result property="otherDevice" column="other_device" jdbcType="VARCHAR"/>
  17. <result property="monitorDataTypeOrder" column="monitor_data_type_order" jdbcType="VARCHAR"/>
  18. <result property="createTime" column="create_time"/>
  19. <result property="updateTime" column="update_time"/>
  20. <result property="isDel" column="is_del" jdbcType="INTEGER"/>
  21. <result property="nickName" column="nick_name" jdbcType="VARCHAR"/>
  22. </resultMap>
  23. <!--查询单个-->
  24. <select id="selectWatchFsUserById" resultType="com.fs.watch.domain.WatchFsUser">
  25. select u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,
  26. wu.nick_name,
  27. wu.sex,wu.birthday,wu.w_company_id,wu.height,wu.weight,wu.target_step,wu.target_calorie,wu.target_activity,wu.target_sport,wu.device_id,wu.other_device,wu.monitor_data_type_order
  28. from watch_user wu
  29. LEFT JOIN fs_user u ON wu.user_id = u.user_id
  30. where wu.user_id = #{userId}
  31. </select>
  32. <!--查询指定行数据-->
  33. <select id="queryAllByLimit" resultMap="WatchUserMap">
  34. select
  35. user_id,sex,birthday,w_company_id,height,weight,target_step,target_calorie,device_id,other_device,monitor_data_type_order,create_time,update_time,is_del,nick_name
  36. from watch_user
  37. <where>
  38. <if test="userId != null">
  39. and user_id = #{userId}
  40. </if>
  41. <if test="sex != null">
  42. and sex = #{sex}
  43. </if>
  44. <if test="birthday != null">
  45. and birthday = #{birthday}
  46. </if>
  47. <if test="wCompanyId != null">
  48. and w_company_id = #{wCompanyId}
  49. </if>
  50. <if test="height != null">
  51. and height = #{height}
  52. </if>
  53. <if test="weight != null">
  54. and weight = #{weight}
  55. </if>
  56. <if test="targetStep != null and targetStep != ''">
  57. and target_step = #{targetStep}
  58. </if>
  59. <if test="targetCalorie != null and targetCalorie != ''">
  60. and target_calorie = #{targetCalorie}
  61. </if>
  62. <if test="deviceId != null and deviceId != ''">
  63. and device_id = #{deviceId}
  64. </if>
  65. <if test="otherDevice != null and otherDevice != ''">
  66. and other_device = #{otherDevice}
  67. </if>
  68. <if test="monitorDataTypeOrder != null and monitorDataTypeOrder != ''">
  69. and monitor_data_type_order = #{monitorDataTypeOrder}
  70. </if>
  71. <if test="createTime != null">
  72. and create_time = #{createTime}
  73. </if>
  74. <if test="updateTime != null">
  75. and update_time = #{updateTime}
  76. </if>
  77. <if test="isDel != null">
  78. and is_del = #{isDel}
  79. </if>
  80. <if test="nickName != null and nickName != ''">
  81. and nick_name = #{nickName}
  82. </if>
  83. </where>
  84. limit #{pageable.offset}, #{pageable.pageSize}
  85. </select>
  86. <!--统计总行数-->
  87. <select id="count" resultType="java.lang.Long">
  88. select count(1)
  89. from watch_user
  90. <where>
  91. <if test="userId != null">
  92. and user_id = #{userId}
  93. </if>
  94. <if test="sex != null">
  95. and sex = #{sex}
  96. </if>
  97. <if test="birthday != null">
  98. and birthday = #{birthday}
  99. </if>
  100. <if test="wCompanyId != null">
  101. and w_company_id = #{wCompanyId}
  102. </if>
  103. <if test="height != null">
  104. and height = #{height}
  105. </if>
  106. <if test="weight != null">
  107. and weight = #{weight}
  108. </if>
  109. <if test="targetStep != null and targetStep != ''">
  110. and target_step = #{targetStep}
  111. </if>
  112. <if test="targetCalorie != null and targetCalorie != ''">
  113. and target_calorie = #{targetCalorie}
  114. </if>
  115. <if test="deviceId != null and deviceId != ''">
  116. and device_id = #{deviceId}
  117. </if>
  118. <if test="otherDevice != null and otherDevice != ''">
  119. and other_device = #{otherDevice}
  120. </if>
  121. <if test="monitorDataTypeOrder != null and monitorDataTypeOrder != ''">
  122. and monitor_data_type_order = #{monitorDataTypeOrder}
  123. </if>
  124. <if test="createTime != null">
  125. and create_time = #{createTime}
  126. </if>
  127. <if test="updateTime != null">
  128. and update_time = #{updateTime}
  129. </if>
  130. <if test="isDel != null">
  131. and is_del = #{isDel}
  132. </if>
  133. <if test="nickName != null and nickName != ''">
  134. and nick_name = #{nickName}
  135. </if>
  136. </where>
  137. </select>
  138. <select id="selectWatchFsUserByDeviceIdAndUserId" resultType="com.fs.watch.domain.WatchFsUser">
  139. <if test="type==0">
  140. SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,u.phone,
  141. wu.nick_name,
  142. wu.sex,wu.birthday,wu.w_company_id,wu.height,wu.weight,wu.target_step,wu.target_calorie,wu.target_activity,wu.target_sport,wu.device_id,wu.other_device,wu.monitor_data_type_order
  143. FROM watch_user wu
  144. left join fs_user u on wu.user_id = u.user_id
  145. WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  146. AND wu.user_id = #{userId}
  147. </if>
  148. <if test="type==1">
  149. SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,u.phone,
  150. wu.nick_name,
  151. wu.sex,wu.birthday,wu.height,wu.weight,wu.target_step,wu.target_calorie,wu.target_activity,wu.target_sport,wu.device_id,wu.monitor_data_type_order
  152. FROM watch_family_user wu
  153. left join fs_user u on u.user_id = #{userId}
  154. WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  155. </if>
  156. </select>
  157. <select id="selectWatchUserById" resultMap="WatchUserMap">
  158. select * from watch_user where user_id = #{userId}
  159. </select>
  160. <select id="listByDeviceIdNotNull" resultType="com.fs.watch.domain.vo.WatchUserAndHealthVo">
  161. SELECT wu.user_id,wu.device_id,hr.id AS health_record_id,hr.health_history FROM `watch_user` wu
  162. LEFT JOIN fs_health_record hr ON wu.user_id = hr.user_id
  163. WHERE wu.is_del = 0 AND wu.device_id is NOT NULL AND wu.device_id != ''
  164. </select>
  165. <select id="getLastTongueByDeviceId" resultType="com.fs.his.domain.FsHealthTongue">
  166. SELECT fht.* FROM `watch_user` wu
  167. LEFT JOIN fs_health_tongue fht ON wu.user_id = fht.user_id
  168. WHERE wu.device_id LIKE #{deviceId}
  169. </select>
  170. <select id="selectWatchFsUserByDeviceId" resultType="com.fs.watch.domain.WatchFsUser">
  171. SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,
  172. wu.nick_name,
  173. wu.sex,wu.birthday,wu.w_company_id,wu.height,wu.weight,wu.target_step,wu.target_calorie,wu.target_activity,wu.target_sport,wu.device_id,wu.other_device,wu.monitor_data_type_order
  174. FROM watch_user wu
  175. left join fs_user u on wu.user_id = u.user_id
  176. WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  177. </select>
  178. <!--新增所有列-->
  179. <insert id="insert" parameterType="WatchUser">
  180. insert into watch_user
  181. <trim prefix="(" suffix=")" suffixOverrides=",">
  182. <if test="userId != null">user_id,</if>
  183. <if test="sex != null">sex,</if>
  184. <if test="birthday != null and birthday !=''">birthday,</if>
  185. <if test="wCompanyId != null">w_company_id,</if>
  186. <if test="height != null">height,</if>
  187. <if test="weight != null">weight,</if>
  188. <if test="targetStep != null and targetStep !=''">target_step,</if>
  189. <if test="targetCalorie != null and targetCalorie !=''">target_calorie,</if>
  190. <if test="targetActivity != null and targetActivity !=''">target_activity,</if>
  191. <if test="targetSport != null and targetSport !=''">target_sport,</if>
  192. <if test="deviceId != null and deviceId !=''">device_id,</if>
  193. <if test="otherDevice != null">other_device,</if>
  194. <if test="monitorDataTypeOrder != null and monitorDataTypeOrder !=''">monitor_data_type_order,</if>
  195. <if test="createTime != null">create_time,</if>
  196. <if test="updateTime != null">update_time,</if>
  197. <if test="isDel != null">is_del,</if>
  198. </trim>
  199. <trim prefix="values (" suffix=")" suffixOverrides=",">
  200. <if test="userId != null">#{userId},</if>
  201. <if test="sex != null">#{sex},</if>
  202. <if test="birthday != null and birthday !=''">#{birthday},</if>
  203. <if test="wCompanyId != null">#{wCompanyId},</if>
  204. <if test="height != null">#{height},</if>
  205. <if test="weight != null">#{weight},</if>
  206. <if test="targetStep != null and targetStep !=''">#{targetStep},</if>
  207. <if test="targetCalorie != null and targetCalorie !=''">#{targetCalorie},</if>
  208. <if test="targetActivity != null and targetActivity !=''">#{targetActivity},</if>
  209. <if test="targetSport != null and targetSport !=''">#{targetSport},</if>
  210. <if test="deviceId != null and deviceId !=''">#{deviceId},</if>
  211. <if test="otherDevice != null">#{otherDevice},</if>
  212. <if test="monitorDataTypeOrder != null and monitorDataTypeOrder !=''">#{monitorDataTypeOrder},</if>
  213. <if test="createTime != null">#{createTime},</if>
  214. <if test="updateTime != null">#{updateTime},</if>
  215. <if test="isDel != null">#{isDel},</if>
  216. </trim>
  217. </insert>
  218. <!--通过主键修改数据-->
  219. <update id="updateWatchUser" parameterType="WatchUser">
  220. update watch_user
  221. <set>
  222. <if test="sex != null">
  223. sex = #{sex},
  224. </if>
  225. <if test="birthday != null">
  226. birthday = #{birthday},
  227. </if>
  228. <if test="wCompanyId != null">
  229. w_company_id = #{wCompanyId},
  230. </if>
  231. <if test="height != null">
  232. height = #{height},
  233. </if>
  234. <if test="weight != null">
  235. weight = #{weight},
  236. </if>
  237. <if test="targetStep != null and targetStep != ''">
  238. target_step = #{targetStep},
  239. </if>
  240. <if test="targetCalorie != null and targetCalorie != ''">
  241. target_calorie = #{targetCalorie},
  242. </if>
  243. <if test="targetActivity != null and targetActivity != ''">
  244. target_activity = #{targetActivity},
  245. </if>
  246. <if test="targetSport != null and targetSport != ''">
  247. target_sport = #{targetSport},
  248. </if>
  249. <if test="deviceId != null">
  250. device_id = #{deviceId},
  251. </if>
  252. <if test="otherDevice != null and otherDevice != ''">
  253. other_device = #{otherDevice},
  254. </if>
  255. <if test="monitorDataTypeOrder != null and monitorDataTypeOrder != ''">
  256. monitor_data_type_order = #{monitorDataTypeOrder},
  257. </if>
  258. <if test="createTime != null">
  259. create_time = #{createTime},
  260. </if>
  261. <if test="updateTime != null">
  262. update_time = #{updateTime},
  263. </if>
  264. <if test="isDel != null">
  265. is_del = #{isDel},
  266. </if>
  267. <if test="nickName != null and nickName != ''">
  268. nick_name = #{nickName},
  269. </if>
  270. </set>
  271. where user_id = #{userId}
  272. </update>
  273. <update id="updateFsUserByDeviceId" parameterType="com.fs.watch.domain.WatchFsUser">
  274. update watch_user
  275. <trim prefix="SET" suffixOverrides=",">
  276. <if test="sex != null">sex = #{sex},</if>
  277. <if test="birthday != null">birthday = #{birthday},</if>
  278. <if test="updateTime != null">update_time = #{updateTime},</if>
  279. <if test="wCompanyId != null">w_company_id = #{wCompanyId},</if>
  280. <if test="height != null">height = #{height},</if>
  281. <if test="weight != null">weight = #{weight},</if>
  282. <if test="targetStep != null">target_step = #{targetStep},</if>
  283. <if test="targetCalorie != null">target_calorie = #{targetCalorie},</if>
  284. <if test="targetActivity != null">target_activity = #{targetActivity},</if>
  285. <if test="targetSport != null">target_sport = #{targetSport},</if>
  286. <!-- <if test="deviceId != null">device_id = #{deviceId},</if>-->
  287. <if test="otherDevice != null">other_device = #{otherDevice},</if>
  288. <if test="monitorDataTypeOrder != null">monitor_data_type_order = #{monitorDataTypeOrder},</if>
  289. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  290. </trim>
  291. where device_id like concat('%',#{deviceId},'%') and user_id = #{userId}
  292. </update>
  293. <!--通过主键删除-->
  294. <delete id="deleteById">
  295. delete from watch_user where user_id = #{userId}
  296. </delete>
  297. </mapper>