WatchUserMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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. <result property="xhsDeviceId" column="xhs_device_id" jdbcType="VARCHAR"/>
  23. <result property="newXhsDeviceId" column="new_xhs_device_id" jdbcType="VARCHAR"/>
  24. <result property="smartWatchDeviceId" column="smart_watch_device_id" jdbcType="VARCHAR"/>
  25. </resultMap>
  26. <!--查询单个-->
  27. <select id="selectWatchFsUserById" resultType="com.fs.watch.domain.WatchFsUser">
  28. select u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,
  29. wu.nick_name,
  30. wu.sex,wu.birthday,wu.w_company_id,wu.height,wu.weight,wu.target_step,wu.target_calorie,
  31. wu.target_activity,wu.target_sport,wu.device_id,wu.other_device,wu.monitor_data_type_order,
  32. wu.xhs_device_id,wu.new_xhs_device_id,wu.smart_watch_device_id
  33. from watch_user wu
  34. LEFT JOIN fs_user u ON wu.user_id = u.user_id
  35. where wu.user_id = #{userId}
  36. </select>
  37. <!--查询指定行数据-->
  38. <select id="queryAllByLimit" resultMap="WatchUserMap">
  39. select
  40. user_id,sex,birthday,w_company_id,height,weight,target_step,target_calorie,device_id,other_device,
  41. monitor_data_type_order,create_time,update_time,is_del,nick_name,xhs_device_id,new_xhs_device_id,smart_watch_device_id
  42. from watch_user
  43. <where>
  44. <if test="userId != null">
  45. and user_id = #{userId}
  46. </if>
  47. <if test="sex != null">
  48. and sex = #{sex}
  49. </if>
  50. <if test="birthday != null">
  51. and birthday = #{birthday}
  52. </if>
  53. <if test="wCompanyId != null">
  54. and w_company_id = #{wCompanyId}
  55. </if>
  56. <if test="height != null">
  57. and height = #{height}
  58. </if>
  59. <if test="weight != null">
  60. and weight = #{weight}
  61. </if>
  62. <if test="targetStep != null and targetStep != ''">
  63. and target_step = #{targetStep}
  64. </if>
  65. <if test="targetCalorie != null and targetCalorie != ''">
  66. and target_calorie = #{targetCalorie}
  67. </if>
  68. <if test="deviceId != null and deviceId != ''">
  69. and device_id = #{deviceId}
  70. </if>
  71. <if test="otherDevice != null and otherDevice != ''">
  72. and other_device = #{otherDevice}
  73. </if>
  74. <if test="monitorDataTypeOrder != null and monitorDataTypeOrder != ''">
  75. and monitor_data_type_order = #{monitorDataTypeOrder}
  76. </if>
  77. <if test="createTime != null">
  78. and create_time = #{createTime}
  79. </if>
  80. <if test="updateTime != null">
  81. and update_time = #{updateTime}
  82. </if>
  83. <if test="isDel != null">
  84. and is_del = #{isDel}
  85. </if>
  86. <if test="nickName != null and nickName != ''">
  87. and nick_name = #{nickName}
  88. </if>
  89. </where>
  90. limit #{pageable.offset}, #{pageable.pageSize}
  91. </select>
  92. <!--统计总行数-->
  93. <select id="count" resultType="java.lang.Long">
  94. select count(1)
  95. from watch_user
  96. <where>
  97. <if test="userId != null">
  98. and user_id = #{userId}
  99. </if>
  100. <if test="sex != null">
  101. and sex = #{sex}
  102. </if>
  103. <if test="birthday != null">
  104. and birthday = #{birthday}
  105. </if>
  106. <if test="wCompanyId != null">
  107. and w_company_id = #{wCompanyId}
  108. </if>
  109. <if test="height != null">
  110. and height = #{height}
  111. </if>
  112. <if test="weight != null">
  113. and weight = #{weight}
  114. </if>
  115. <if test="targetStep != null and targetStep != ''">
  116. and target_step = #{targetStep}
  117. </if>
  118. <if test="targetCalorie != null and targetCalorie != ''">
  119. and target_calorie = #{targetCalorie}
  120. </if>
  121. <if test="deviceId != null and deviceId != ''">
  122. and device_id = #{deviceId}
  123. </if>
  124. <if test="otherDevice != null and otherDevice != ''">
  125. and other_device = #{otherDevice}
  126. </if>
  127. <if test="monitorDataTypeOrder != null and monitorDataTypeOrder != ''">
  128. and monitor_data_type_order = #{monitorDataTypeOrder}
  129. </if>
  130. <if test="createTime != null">
  131. and create_time = #{createTime}
  132. </if>
  133. <if test="updateTime != null">
  134. and update_time = #{updateTime}
  135. </if>
  136. <if test="isDel != null">
  137. and is_del = #{isDel}
  138. </if>
  139. <if test="nickName != null and nickName != ''">
  140. and nick_name = #{nickName}
  141. </if>
  142. <if test="xhsDeviceId != null and xhsDeviceId != ''">
  143. and xhs_device_id = #{xhsDeviceId}
  144. </if>
  145. </where>
  146. </select>
  147. <select id="selectWatchFsUserByDeviceIdAndUserId" resultType="com.fs.watch.domain.WatchFsUser">
  148. <if test="type==0">
  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.w_company_id,wu.height,wu.weight,wu.target_step,
  152. wu.target_calorie,wu.target_activity,wu.target_sport,wu.device_id,wu.other_device,
  153. wu.monitor_data_type_order,wu.xhs_device_id
  154. FROM watch_user wu
  155. left join fs_user u on wu.user_id = u.user_id
  156. WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  157. AND wu.user_id = #{userId}
  158. </if>
  159. <if test="type==1">
  160. SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,u.phone,
  161. wu.nick_name,
  162. wu.sex,wu.birthday,wu.height,wu.weight,wu.target_step,wu.target_calorie,wu.target_activity,
  163. wu.target_sport,wu.device_id,wu.monitor_data_type_order
  164. FROM watch_family_user wu
  165. left join fs_user u on u.user_id = #{userId}
  166. WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  167. </if>
  168. <if test="type==2">
  169. SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,u.phone,
  170. wu.nick_name,
  171. wu.sex,wu.birthday,wu.w_company_id,wu.height,wu.weight,wu.target_step,wu.target_calorie,
  172. wu.target_activity,wu.target_sport,wu.device_id,wu.other_device,wu.monitor_data_type_order,
  173. wu.xhs_device_id
  174. FROM watch_user wu
  175. left join fs_user u on wu.user_id = u.user_id
  176. WHERE wu.xhs_device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  177. AND wu.user_id = #{userId}
  178. </if>
  179. <if test="type==3">
  180. SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,u.phone,
  181. wu.nick_name,
  182. wu.sex,wu.birthday,wu.height,wu.weight,wu.target_step,wu.target_calorie,
  183. wu.target_activity,wu.target_sport,wu.device_id as xhs_device_id,wu.monitor_data_type_order
  184. FROM watch_family_user wu
  185. left join fs_user u on u.user_id = #{userId}
  186. WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  187. </if>
  188. <if test="type==4">
  189. SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,u.phone,
  190. wu.nick_name,
  191. wu.sex,wu.birthday,wu.w_company_id,wu.height,wu.weight,wu.target_step,wu.target_calorie,
  192. wu.target_activity,wu.target_sport,wu.device_id,wu.other_device,wu.monitor_data_type_order,wu.new_xhs_device_id
  193. FROM watch_user wu
  194. left join fs_user u on wu.user_id = u.user_id
  195. WHERE wu.new_xhs_device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  196. AND wu.user_id = #{userId}
  197. </if>
  198. <if test="type==5">
  199. SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,u.phone,
  200. wu.nick_name,
  201. wu.sex,wu.birthday,wu.height,wu.weight,wu.target_step,wu.target_calorie,
  202. wu.target_activity,wu.target_sport,wu.device_id as new_xhs_device_id,wu.monitor_data_type_order
  203. FROM watch_family_user wu
  204. left join fs_user u on u.user_id = #{userId}
  205. WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  206. </if>
  207. <if test="type==6">
  208. SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,u.phone,
  209. wu.nick_name,
  210. wu.sex,wu.birthday,wu.w_company_id,wu.height,wu.weight,wu.target_step,wu.target_calorie,
  211. wu.target_activity,wu.target_sport,wu.device_id,wu.other_device,wu.monitor_data_type_order,wu.smart_watch_device_id
  212. FROM watch_user wu
  213. left join fs_user u on wu.user_id = u.user_id
  214. WHERE wu.smart_watch_device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  215. AND wu.user_id = #{userId}
  216. </if>
  217. <if test="type==7">
  218. SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,u.phone,
  219. wu.nick_name,
  220. wu.sex,wu.birthday,wu.height,wu.weight,wu.target_step,wu.target_calorie,
  221. wu.target_activity,wu.target_sport,wu.device_id as smart_watch_device_id,wu.monitor_data_type_order
  222. FROM watch_family_user wu
  223. left join fs_user u on u.user_id = #{userId}
  224. WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  225. </if>
  226. </select>
  227. <select id="selectWatchUserById" resultMap="WatchUserMap">
  228. select * from watch_user where user_id = #{userId}
  229. </select>
  230. <select id="listByDeviceIdNotNull" resultType="com.fs.watch.domain.vo.WatchUserAndHealthVo">
  231. SELECT wu.user_id,wu.device_id,hr.id AS health_record_id,hr.health_history FROM `watch_user` wu
  232. LEFT JOIN fs_health_record hr ON wu.user_id = hr.user_id
  233. WHERE wu.is_del = 0 AND wu.device_id is NOT NULL AND wu.device_id != ''
  234. </select>
  235. <select id="getLastTongueByDeviceId" resultType="com.fs.his.domain.FsHealthTongue">
  236. SELECT fht.* FROM `watch_user` wu
  237. LEFT JOIN fs_health_tongue fht ON wu.user_id = fht.user_id
  238. WHERE wu.device_id LIKE #{deviceId}
  239. </select>
  240. <select id="selectWatchFsUserByDeviceId" resultType="com.fs.watch.domain.WatchFsUser">
  241. SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,
  242. wu.nick_name,
  243. 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
  244. FROM watch_user wu
  245. left join fs_user u on wu.user_id = u.user_id
  246. WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
  247. </select>
  248. <!--新增所有列-->
  249. <insert id="insert" parameterType="WatchUser">
  250. insert into watch_user
  251. <trim prefix="(" suffix=")" suffixOverrides=",">
  252. <if test="userId != null">user_id,</if>
  253. <if test="sex != null">sex,</if>
  254. <if test="birthday != null and birthday !=''">birthday,</if>
  255. <if test="wCompanyId != null">w_company_id,</if>
  256. <if test="height != null">height,</if>
  257. <if test="weight != null">weight,</if>
  258. <if test="targetStep != null and targetStep !=''">target_step,</if>
  259. <if test="targetCalorie != null and targetCalorie !=''">target_calorie,</if>
  260. <if test="targetActivity != null and targetActivity !=''">target_activity,</if>
  261. <if test="targetSport != null and targetSport !=''">target_sport,</if>
  262. <if test="deviceId != null and deviceId !=''">device_id,</if>
  263. <if test="otherDevice != null">other_device,</if>
  264. <if test="monitorDataTypeOrder != null and monitorDataTypeOrder !=''">monitor_data_type_order,</if>
  265. <if test="createTime != null">create_time,</if>
  266. <if test="updateTime != null">update_time,</if>
  267. <if test="isDel != null">is_del,</if>
  268. <if test="xhsDeviceId != null">xhs_device_id,</if>
  269. <if test="newXhsDeviceId != null">new_xhs_device_id,</if>
  270. <if test="smartWatchDeviceId != null">smart_watch_device_id,</if>
  271. </trim>
  272. <trim prefix="values (" suffix=")" suffixOverrides=",">
  273. <if test="userId != null">#{userId},</if>
  274. <if test="sex != null">#{sex},</if>
  275. <if test="birthday != null and birthday !=''">#{birthday},</if>
  276. <if test="wCompanyId != null">#{wCompanyId},</if>
  277. <if test="height != null">#{height},</if>
  278. <if test="weight != null">#{weight},</if>
  279. <if test="targetStep != null and targetStep !=''">#{targetStep},</if>
  280. <if test="targetCalorie != null and targetCalorie !=''">#{targetCalorie},</if>
  281. <if test="targetActivity != null and targetActivity !=''">#{targetActivity},</if>
  282. <if test="targetSport != null and targetSport !=''">#{targetSport},</if>
  283. <if test="deviceId != null and deviceId !=''">#{deviceId},</if>
  284. <if test="otherDevice != null">#{otherDevice},</if>
  285. <if test="monitorDataTypeOrder != null and monitorDataTypeOrder !=''">#{monitorDataTypeOrder},</if>
  286. <if test="createTime != null">#{createTime},</if>
  287. <if test="updateTime != null">#{updateTime},</if>
  288. <if test="isDel != null">#{isDel},</if>
  289. <if test="xhsDeviceId != null">#{xhsDeviceId},</if>
  290. <if test="newXhsDeviceId != null">#{newXhsDeviceId},</if>
  291. <if test="smartWatchDeviceId != null">#{smartWatchDeviceId},</if>
  292. </trim>
  293. </insert>
  294. <!--通过主键修改数据-->
  295. <update id="updateWatchUser" parameterType="WatchUser">
  296. update watch_user
  297. <set>
  298. <if test="sex != null">
  299. sex = #{sex},
  300. </if>
  301. <if test="birthday != null">
  302. birthday = #{birthday},
  303. </if>
  304. <if test="wCompanyId != null">
  305. w_company_id = #{wCompanyId},
  306. </if>
  307. <if test="height != null">
  308. height = #{height},
  309. </if>
  310. <if test="weight != null">
  311. weight = #{weight},
  312. </if>
  313. <if test="targetStep != null and targetStep != ''">
  314. target_step = #{targetStep},
  315. </if>
  316. <if test="targetCalorie != null and targetCalorie != ''">
  317. target_calorie = #{targetCalorie},
  318. </if>
  319. <if test="targetActivity != null and targetActivity != ''">
  320. target_activity = #{targetActivity},
  321. </if>
  322. <if test="targetSport != null and targetSport != ''">
  323. target_sport = #{targetSport},
  324. </if>
  325. <if test="deviceId != null">
  326. device_id = #{deviceId},
  327. </if>
  328. <if test="otherDevice != null and otherDevice != ''">
  329. other_device = #{otherDevice},
  330. </if>
  331. <if test="monitorDataTypeOrder != null and monitorDataTypeOrder != ''">
  332. monitor_data_type_order = #{monitorDataTypeOrder},
  333. </if>
  334. <if test="createTime != null">
  335. create_time = #{createTime},
  336. </if>
  337. <if test="updateTime != null">
  338. update_time = #{updateTime},
  339. </if>
  340. <if test="isDel != null">
  341. is_del = #{isDel},
  342. </if>
  343. <if test="nickName != null and nickName != ''">
  344. nick_name = #{nickName},
  345. </if>
  346. <if test="xhsDeviceId != null">
  347. xhs_device_id = #{xhsDeviceId},
  348. </if>
  349. <if test="newXhsDeviceId != null">
  350. new_xhs_device_id = #{newXhsDeviceId},
  351. </if>
  352. <if test="smartWatchDeviceId != null">
  353. smart_watch_device_id = #{smartWatchDeviceId},
  354. </if>
  355. </set>
  356. where user_id = #{userId}
  357. </update>
  358. <update id="updateFsUserByDeviceId" parameterType="com.fs.watch.domain.WatchFsUser">
  359. update watch_user
  360. <trim prefix="SET" suffixOverrides=",">
  361. <if test="sex != null">sex = #{sex},</if>
  362. <if test="birthday != null">birthday = #{birthday},</if>
  363. <if test="updateTime != null">update_time = #{updateTime},</if>
  364. <if test="wCompanyId != null">w_company_id = #{wCompanyId},</if>
  365. <if test="height != null">height = #{height},</if>
  366. <if test="weight != null">weight = #{weight},</if>
  367. <if test="targetStep != null">target_step = #{targetStep},</if>
  368. <if test="targetCalorie != null">target_calorie = #{targetCalorie},</if>
  369. <if test="targetActivity != null">target_activity = #{targetActivity},</if>
  370. <if test="targetSport != null">target_sport = #{targetSport},</if>
  371. <!-- <if test="deviceId != null">device_id = #{deviceId},</if>-->
  372. <if test="otherDevice != null">other_device = #{otherDevice},</if>
  373. <if test="monitorDataTypeOrder != null">monitor_data_type_order = #{monitorDataTypeOrder},</if>
  374. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  375. </trim>
  376. where device_id like concat('%',#{deviceId},'%') and user_id = #{userId}
  377. </update>
  378. <!--通过主键删除-->
  379. <delete id="deleteById">
  380. delete from watch_user where user_id = #{userId}
  381. </delete>
  382. </mapper>