| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.fs.watch.mapper.WatchUserMapper">
- <resultMap type="com.fs.watch.domain.WatchUser" id="WatchUserMap">
- <result property="userId" column="user_id" jdbcType="INTEGER"/>
- <result property="sex" column="sex" jdbcType="INTEGER"/>
- <result property="birthday" column="birthday"/>
- <result property="wCompanyId" column="w_company_id" jdbcType="INTEGER"/>
- <result property="height" column="height" jdbcType="INTEGER"/>
- <result property="weight" column="weight" jdbcType="INTEGER"/>
- <result property="targetStep" column="target_step" jdbcType="VARCHAR"/>
- <result property="targetCalorie" column="target_calorie" jdbcType="VARCHAR"/>
- <result property="targetActivity" column="target_activity" jdbcType="VARCHAR"/>
- <result property="targetSport" column="target_sport" jdbcType="VARCHAR"/>
- <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>
- <result property="otherDevice" column="other_device" jdbcType="VARCHAR"/>
- <result property="monitorDataTypeOrder" column="monitor_data_type_order" jdbcType="VARCHAR"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="isDel" column="is_del" jdbcType="INTEGER"/>
- <result property="nickName" column="nick_name" jdbcType="VARCHAR"/>
- </resultMap>
- <!--查询单个-->
- <select id="selectWatchFsUserById" resultType="com.fs.watch.domain.WatchFsUser">
- select u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,
- wu.nick_name,
- 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
- from watch_user wu
- LEFT JOIN fs_user u ON wu.user_id = u.user_id
- where wu.user_id = #{userId}
- </select>
- <!--查询指定行数据-->
- <select id="queryAllByLimit" resultMap="WatchUserMap">
- select
- 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
- from watch_user
- <where>
- <if test="userId != null">
- and user_id = #{userId}
- </if>
- <if test="sex != null">
- and sex = #{sex}
- </if>
- <if test="birthday != null">
- and birthday = #{birthday}
- </if>
- <if test="wCompanyId != null">
- and w_company_id = #{wCompanyId}
- </if>
- <if test="height != null">
- and height = #{height}
- </if>
- <if test="weight != null">
- and weight = #{weight}
- </if>
- <if test="targetStep != null and targetStep != ''">
- and target_step = #{targetStep}
- </if>
- <if test="targetCalorie != null and targetCalorie != ''">
- and target_calorie = #{targetCalorie}
- </if>
- <if test="deviceId != null and deviceId != ''">
- and device_id = #{deviceId}
- </if>
- <if test="otherDevice != null and otherDevice != ''">
- and other_device = #{otherDevice}
- </if>
- <if test="monitorDataTypeOrder != null and monitorDataTypeOrder != ''">
- and monitor_data_type_order = #{monitorDataTypeOrder}
- </if>
- <if test="createTime != null">
- and create_time = #{createTime}
- </if>
- <if test="updateTime != null">
- and update_time = #{updateTime}
- </if>
- <if test="isDel != null">
- and is_del = #{isDel}
- </if>
- <if test="nickName != null and nickName != ''">
- and nick_name = #{nickName}
- </if>
- </where>
- limit #{pageable.offset}, #{pageable.pageSize}
- </select>
- <!--统计总行数-->
- <select id="count" resultType="java.lang.Long">
- select count(1)
- from watch_user
- <where>
- <if test="userId != null">
- and user_id = #{userId}
- </if>
- <if test="sex != null">
- and sex = #{sex}
- </if>
- <if test="birthday != null">
- and birthday = #{birthday}
- </if>
- <if test="wCompanyId != null">
- and w_company_id = #{wCompanyId}
- </if>
- <if test="height != null">
- and height = #{height}
- </if>
- <if test="weight != null">
- and weight = #{weight}
- </if>
- <if test="targetStep != null and targetStep != ''">
- and target_step = #{targetStep}
- </if>
- <if test="targetCalorie != null and targetCalorie != ''">
- and target_calorie = #{targetCalorie}
- </if>
- <if test="deviceId != null and deviceId != ''">
- and device_id = #{deviceId}
- </if>
- <if test="otherDevice != null and otherDevice != ''">
- and other_device = #{otherDevice}
- </if>
- <if test="monitorDataTypeOrder != null and monitorDataTypeOrder != ''">
- and monitor_data_type_order = #{monitorDataTypeOrder}
- </if>
- <if test="createTime != null">
- and create_time = #{createTime}
- </if>
- <if test="updateTime != null">
- and update_time = #{updateTime}
- </if>
- <if test="isDel != null">
- and is_del = #{isDel}
- </if>
- <if test="nickName != null and nickName != ''">
- and nick_name = #{nickName}
- </if>
- </where>
- </select>
- <select id="selectWatchFsUserByDeviceIdAndUserId" resultType="com.fs.watch.domain.WatchFsUser">
- <if test="type==0">
- SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,u.phone,
- wu.nick_name,
- 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
- FROM watch_user wu
- left join fs_user u on wu.user_id = u.user_id
- WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
- AND wu.user_id = #{userId}
- </if>
- <if test="type==1">
- SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,u.phone,
- wu.nick_name,
- 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
- FROM watch_family_user wu
- left join fs_user u on u.user_id = #{userId}
- WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
- </if>
- </select>
- <select id="selectWatchUserById" resultMap="WatchUserMap">
- select * from watch_user where user_id = #{userId}
- </select>
- <select id="listByDeviceIdNotNull" resultType="com.fs.watch.domain.vo.WatchUserAndHealthVo">
- SELECT wu.user_id,wu.device_id,hr.id AS health_record_id,hr.health_history FROM `watch_user` wu
- LEFT JOIN fs_health_record hr ON wu.user_id = hr.user_id
- WHERE wu.is_del = 0 AND wu.device_id is NOT NULL AND wu.device_id != ''
- </select>
- <select id="getLastTongueByDeviceId" resultType="com.fs.his.domain.FsHealthTongue">
- SELECT fht.* FROM `watch_user` wu
- LEFT JOIN fs_health_tongue fht ON wu.user_id = fht.user_id
- WHERE wu.device_id LIKE #{deviceId}
- </select>
- <select id="selectWatchFsUserByDeviceId" resultType="com.fs.watch.domain.WatchFsUser">
- SELECT u.user_id, u.avatar, u.password, u.sex, u.status, u.remark,
- wu.nick_name,
- 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
- FROM watch_user wu
- left join fs_user u on wu.user_id = u.user_id
- WHERE wu.device_id LIKE concat('%',#{deviceId},'%') AND wu.is_del = 0
- </select>
- <!--新增所有列-->
- <insert id="insert" parameterType="WatchUser">
- insert into watch_user
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="userId != null">user_id,</if>
- <if test="sex != null">sex,</if>
- <if test="birthday != null and birthday !=''">birthday,</if>
- <if test="wCompanyId != null">w_company_id,</if>
- <if test="height != null">height,</if>
- <if test="weight != null">weight,</if>
- <if test="targetStep != null and targetStep !=''">target_step,</if>
- <if test="targetCalorie != null and targetCalorie !=''">target_calorie,</if>
- <if test="targetActivity != null and targetActivity !=''">target_activity,</if>
- <if test="targetSport != null and targetSport !=''">target_sport,</if>
- <if test="deviceId != null and deviceId !=''">device_id,</if>
- <if test="otherDevice != null">other_device,</if>
- <if test="monitorDataTypeOrder != null and monitorDataTypeOrder !=''">monitor_data_type_order,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="isDel != null">is_del,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="userId != null">#{userId},</if>
- <if test="sex != null">#{sex},</if>
- <if test="birthday != null and birthday !=''">#{birthday},</if>
- <if test="wCompanyId != null">#{wCompanyId},</if>
- <if test="height != null">#{height},</if>
- <if test="weight != null">#{weight},</if>
- <if test="targetStep != null and targetStep !=''">#{targetStep},</if>
- <if test="targetCalorie != null and targetCalorie !=''">#{targetCalorie},</if>
- <if test="targetActivity != null and targetActivity !=''">#{targetActivity},</if>
- <if test="targetSport != null and targetSport !=''">#{targetSport},</if>
- <if test="deviceId != null and deviceId !=''">#{deviceId},</if>
- <if test="otherDevice != null">#{otherDevice},</if>
- <if test="monitorDataTypeOrder != null and monitorDataTypeOrder !=''">#{monitorDataTypeOrder},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="isDel != null">#{isDel},</if>
- </trim>
- </insert>
- <!--通过主键修改数据-->
- <update id="updateWatchUser" parameterType="WatchUser">
- update watch_user
- <set>
- <if test="sex != null">
- sex = #{sex},
- </if>
- <if test="birthday != null">
- birthday = #{birthday},
- </if>
- <if test="wCompanyId != null">
- w_company_id = #{wCompanyId},
- </if>
- <if test="height != null">
- height = #{height},
- </if>
- <if test="weight != null">
- weight = #{weight},
- </if>
- <if test="targetStep != null and targetStep != ''">
- target_step = #{targetStep},
- </if>
- <if test="targetCalorie != null and targetCalorie != ''">
- target_calorie = #{targetCalorie},
- </if>
- <if test="targetActivity != null and targetActivity != ''">
- target_activity = #{targetActivity},
- </if>
- <if test="targetSport != null and targetSport != ''">
- target_sport = #{targetSport},
- </if>
- <if test="deviceId != null">
- device_id = #{deviceId},
- </if>
- <if test="otherDevice != null and otherDevice != ''">
- other_device = #{otherDevice},
- </if>
- <if test="monitorDataTypeOrder != null and monitorDataTypeOrder != ''">
- monitor_data_type_order = #{monitorDataTypeOrder},
- </if>
- <if test="createTime != null">
- create_time = #{createTime},
- </if>
- <if test="updateTime != null">
- update_time = #{updateTime},
- </if>
- <if test="isDel != null">
- is_del = #{isDel},
- </if>
- <if test="nickName != null and nickName != ''">
- nick_name = #{nickName},
- </if>
- </set>
- where user_id = #{userId}
- </update>
- <update id="updateFsUserByDeviceId" parameterType="com.fs.watch.domain.WatchFsUser">
- update watch_user
- <trim prefix="SET" suffixOverrides=",">
- <if test="sex != null">sex = #{sex},</if>
- <if test="birthday != null">birthday = #{birthday},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="wCompanyId != null">w_company_id = #{wCompanyId},</if>
- <if test="height != null">height = #{height},</if>
- <if test="weight != null">weight = #{weight},</if>
- <if test="targetStep != null">target_step = #{targetStep},</if>
- <if test="targetCalorie != null">target_calorie = #{targetCalorie},</if>
- <if test="targetActivity != null">target_activity = #{targetActivity},</if>
- <if test="targetSport != null">target_sport = #{targetSport},</if>
- <!-- <if test="deviceId != null">device_id = #{deviceId},</if>-->
- <if test="otherDevice != null">other_device = #{otherDevice},</if>
- <if test="monitorDataTypeOrder != null">monitor_data_type_order = #{monitorDataTypeOrder},</if>
- <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
- </trim>
- where device_id like concat('%',#{deviceId},'%') and user_id = #{userId}
- </update>
- <!--通过主键删除-->
- <delete id="deleteById">
- delete from watch_user where user_id = #{userId}
- </delete>
- </mapper>
|