2025-04-20 20:26:58 +08:00
|
|
|
<?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.bonus.canteen.core.nutrition.mapper.HealthInfoMapper">
|
|
|
|
|
|
2025-06-03 09:18:31 +08:00
|
|
|
<select id="selectHealthInfoList" resultType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoSimpleVo">
|
|
|
|
|
SELECT a.user_id,
|
|
|
|
|
a.nick_name,
|
|
|
|
|
a.phonenumber as mobile,
|
|
|
|
|
a.photo_url as custPhotoUrl,
|
|
|
|
|
a.sex,
|
|
|
|
|
d.height,
|
|
|
|
|
d.weight,
|
|
|
|
|
d.bmi,
|
|
|
|
|
b.doctor_advice,
|
|
|
|
|
b.allergen,
|
|
|
|
|
b.labour_intensity,
|
|
|
|
|
b.pregnant_status,
|
|
|
|
|
GROUP_CONCAT(c.chronic_name ORDER BY c.chronic_id desc) AS chronic_names,
|
|
|
|
|
GROUP_CONCAT(c.chronic_id ORDER BY c.chronic_id desc) AS chronic_ids
|
|
|
|
|
from sys_user a
|
|
|
|
|
left join health_info b on a.user_id = b.user_id
|
|
|
|
|
left join health_info_chronic c on a.user_id = c.user_id
|
|
|
|
|
left join health_body_record d on a.user_id = d.user_id and d.if_latest = 1
|
|
|
|
|
where 1 = 1
|
|
|
|
|
group by a.user_id,
|
|
|
|
|
a.nick_name,
|
|
|
|
|
a.dept_id,
|
|
|
|
|
a.phonenumber,
|
|
|
|
|
a.photo_url,
|
|
|
|
|
a.sex,
|
|
|
|
|
d.height,
|
|
|
|
|
d.weight,
|
|
|
|
|
d.bmi,
|
|
|
|
|
b.doctor_advice,
|
|
|
|
|
b.allergen,
|
|
|
|
|
b.labour_intensity,
|
|
|
|
|
b.pregnant_status
|
|
|
|
|
</select>
|
2025-06-04 09:33:52 +08:00
|
|
|
|
|
|
|
|
<select id="selectHealthChronicList" resultType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoSimpleVo">
|
|
|
|
|
SELECT distinct chronic_id as chronic_ids,chronic_name as chronic_names from health_chronic where chronic_id in (${chronicIds})
|
|
|
|
|
</select>
|
|
|
|
|
|
2025-04-20 20:26:58 +08:00
|
|
|
<select id="getSimpleInfo" resultType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoSimpleVo">
|
|
|
|
|
SELECT a.user_id,
|
|
|
|
|
a.nick_name,
|
|
|
|
|
a.phonenumber as mobile,
|
|
|
|
|
a.photo_url as custPhotoUrl,
|
|
|
|
|
a.sex,
|
|
|
|
|
d.height,
|
|
|
|
|
d.weight,
|
|
|
|
|
d.bmi,
|
|
|
|
|
b.doctor_advice,
|
|
|
|
|
b.allergen,
|
|
|
|
|
b.labour_intensity,
|
|
|
|
|
b.pregnant_status,
|
|
|
|
|
GROUP_CONCAT(c.chronic_name ORDER BY c.chronic_id desc) AS chronic_names,
|
|
|
|
|
GROUP_CONCAT(c.chronic_id ORDER BY c.chronic_id desc) AS chronic_ids
|
|
|
|
|
from sys_user a
|
|
|
|
|
left join health_info b on a.user_id = b.user_id
|
|
|
|
|
left join health_info_chronic c on a.user_id = c.user_id
|
|
|
|
|
left join health_body_record d on a.user_id = d.user_id and d.if_latest = 1
|
|
|
|
|
where 1 = 1
|
|
|
|
|
and a.user_id = #{userId}
|
|
|
|
|
group by a.user_id,
|
|
|
|
|
a.nick_name,
|
|
|
|
|
a.dept_id,
|
|
|
|
|
a.phonenumber,
|
|
|
|
|
a.photo_url,
|
|
|
|
|
a.sex,
|
|
|
|
|
d.height,
|
|
|
|
|
d.weight,
|
|
|
|
|
d.bmi,
|
|
|
|
|
b.doctor_advice,
|
|
|
|
|
b.allergen,
|
|
|
|
|
b.labour_intensity,
|
|
|
|
|
b.pregnant_status
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="fullHealthInfo" resultType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo">
|
|
|
|
|
select a.user_id,
|
|
|
|
|
a.nick_name,
|
|
|
|
|
a.phonenumber as mobile,
|
|
|
|
|
a.sex,
|
|
|
|
|
a.dept_id as orgId,
|
|
|
|
|
a.user_type,
|
|
|
|
|
b.marital_status,
|
|
|
|
|
b.pregnant_status,
|
|
|
|
|
b.pregnancy_date,
|
|
|
|
|
b.doctor_advice,
|
|
|
|
|
b.if_hospitalized,
|
|
|
|
|
b.doctor_num,
|
|
|
|
|
b.hospital_num,
|
|
|
|
|
b.inpatient_date,
|
|
|
|
|
b.inpatient_result,
|
|
|
|
|
b.weight_control,
|
|
|
|
|
b.allergen,
|
|
|
|
|
b.labour_intensity,
|
|
|
|
|
b.health_state,
|
|
|
|
|
b.blood_type,
|
|
|
|
|
c.height,
|
|
|
|
|
c.weight,
|
|
|
|
|
c.bmi,
|
|
|
|
|
c.shape,
|
|
|
|
|
c.bust,
|
|
|
|
|
c.waistline,
|
|
|
|
|
c.blood_sugar,
|
|
|
|
|
c.blood_fat,
|
|
|
|
|
c.blood_pressure_high,
|
|
|
|
|
c.blood_pressure_low,
|
|
|
|
|
c.heart_rate,
|
|
|
|
|
c.blood_oxygen,
|
|
|
|
|
c.uric_acid,
|
|
|
|
|
c.blood_pressure,
|
|
|
|
|
GROUP_CONCAT(d.chronic_name ORDER BY d.chronic_id desc) AS chronic_names,
|
|
|
|
|
GROUP_CONCAT(d.chronic_id ORDER BY d.chronic_id desc) AS chronic_ids
|
|
|
|
|
from sys_user a
|
|
|
|
|
left join health_info b on a.user_id = b.user_id
|
|
|
|
|
left join health_body_record c on a.user_id = c.user_id and c.if_latest = 1
|
|
|
|
|
left join health_info_chronic d on a.user_id = d.user_id
|
|
|
|
|
where a.user_id = #{userId}
|
|
|
|
|
group by a.user_id,
|
|
|
|
|
a.user_name,
|
|
|
|
|
a.phonenumber,
|
|
|
|
|
a.sex,
|
|
|
|
|
a.dept_id,
|
|
|
|
|
a.user_type,
|
|
|
|
|
b.marital_status,
|
|
|
|
|
b.pregnant_status,
|
|
|
|
|
b.pregnancy_date,
|
|
|
|
|
b.doctor_advice,
|
|
|
|
|
b.if_hospitalized,
|
|
|
|
|
b.doctor_num,
|
|
|
|
|
b.hospital_num,
|
|
|
|
|
b.inpatient_date,
|
|
|
|
|
b.inpatient_result,
|
|
|
|
|
b.weight_control,
|
|
|
|
|
b.allergen,
|
|
|
|
|
b.labour_intensity,
|
|
|
|
|
b.health_state,
|
|
|
|
|
b.blood_type,
|
|
|
|
|
c.height,
|
|
|
|
|
c.weight,
|
|
|
|
|
c.bmi,
|
|
|
|
|
c.shape,
|
|
|
|
|
c.bust,
|
|
|
|
|
c.waistline,
|
|
|
|
|
c.blood_sugar,
|
|
|
|
|
c.blood_fat,
|
|
|
|
|
c.blood_pressure_high,
|
|
|
|
|
c.blood_pressure_low,
|
|
|
|
|
c.heart_rate,
|
|
|
|
|
c.blood_oxygen,
|
|
|
|
|
c.uric_acid,
|
|
|
|
|
c.blood_pressure
|
|
|
|
|
</select>
|
2025-06-04 09:33:52 +08:00
|
|
|
<update id="updateHealthInfo" parameterType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo">
|
|
|
|
|
update health_info
|
|
|
|
|
<set>
|
|
|
|
|
<if test="bloodType != null and bloodType != ''">
|
|
|
|
|
blood_type = #{bloodType},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="maritalStatus != null and maritalStatus != ''">
|
|
|
|
|
marital_status = #{maritalStatus},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pregnantStatus != null and pregnantStatus != ''">
|
|
|
|
|
pregnant_status = #{pregnantStatus},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="pregnancyDate != null and pregnancyDate != ''">
|
|
|
|
|
pregnancy_date = #{pregnancyDate},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="doctorAdvice != null and doctorAdvice != ''">
|
|
|
|
|
doctor_advice = #{doctorAdvice},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="ifHospitalized != null and ifHospitalized != ''">
|
|
|
|
|
if_hospitalized = #{ifHospitalized},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="doctorNum != null and doctorNum != ''">
|
|
|
|
|
doctor_num = #{doctorNum},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="hospitalNum != null and hospitalNum != ''">
|
|
|
|
|
hospital_num = #{hospitalNum},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="inpatientDate != null and inpatientDate != ''">
|
|
|
|
|
inpatient_date = #{inpatientDate},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="weightControl != null and weightControl != ''">
|
|
|
|
|
weight_control = #{weightControl},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="allergen != null and allergen != ''">
|
|
|
|
|
allergen = #{allergen},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="labourIntensity != null and labourIntensity != ''">
|
|
|
|
|
labour_intensity = #{labourIntensity},
|
|
|
|
|
</if>
|
|
|
|
|
</set>
|
|
|
|
|
where user_id = #{userId} and del_flag='0'
|
|
|
|
|
</update>
|
|
|
|
|
<update id="updateHealthBodyRecord" parameterType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo">
|
|
|
|
|
update health_body_record
|
|
|
|
|
<set>
|
|
|
|
|
<if test="height != null and height != ''">
|
|
|
|
|
height = #{height},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="weight != null and weight != ''">
|
|
|
|
|
weight = #{weight},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bmi != null and bmi != ''">
|
|
|
|
|
bmi = #{bmi},
|
|
|
|
|
</if>
|
|
|
|
|
</set>
|
|
|
|
|
where user_id = #{userId} and del_flag='0'
|
|
|
|
|
</update>
|
|
|
|
|
<update id="deleteHealthInfoChronic" parameterType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo">
|
|
|
|
|
delete from health_info_chronic
|
|
|
|
|
where user_id = #{userId}
|
|
|
|
|
</update>
|
|
|
|
|
<insert id="insertHealthInfoChronic" parameterType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo">
|
|
|
|
|
insert into health_info_chronic(user_id, chronic_id, chronic_name)
|
|
|
|
|
values
|
|
|
|
|
<foreach collection="entities" item="entity" separator=",">
|
|
|
|
|
(#{entity.userId}, #{entity.chronicIds}, #{entity.chronicNames})
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
2025-04-20 20:26:58 +08:00
|
|
|
</mapper>
|