ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZHealthHabitController.java
@@ -1,9 +1,16 @@ package com.ruoyi.web.controller.zhang; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.domain.ZHealthHabit; import com.ruoyi.domain.dto.ZHealthBaseDto; import com.ruoyi.domain.dto.ZHealthHabitDto; import com.ruoyi.service.ZHealthHabitService; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; /** * <p> @@ -17,5 +24,28 @@ @RequestMapping("/zHealthHabit") public class ZHealthHabitController { @Autowired ZHealthHabitService zHealthHabitService; /** * 查询数据 */ @GetMapping("/all") public AjaxResult listAll(){ return zHealthHabitService.selectData(); } /** * 新增或修改记录 */ // @PreAuthorize("@ss.hasPermi('system:property:edit')") @Log(title = "健康记录", businessType = BusinessType.UPDATE) @PostMapping public AjaxResult edit(@RequestBody ZHealthHabitDto zHealthHabitDto) { return zHealthHabitService.saveOrUpdateData(zHealthHabitDto); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZHealthInfoController.java
@@ -1,9 +1,13 @@ package com.ruoyi.web.controller.zhang; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.domain.dto.ZHealthInfoDto; import com.ruoyi.service.ZHealthInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; /** * <p> @@ -16,6 +20,27 @@ @RestController @RequestMapping("/zHealthInfo") public class ZHealthInfoController { @Autowired ZHealthInfoService zHealthInfoService; /** * 查询数据 */ @GetMapping("/all") public AjaxResult listAll(){ return zHealthInfoService.selectData(); } /** * 新增或修改记录 */ // @PreAuthorize("@ss.hasPermi('system:property:edit')") @Log(title = "健康记录", businessType = BusinessType.UPDATE) @PostMapping public AjaxResult edit(@RequestBody ZHealthInfoDto zHealthInfoDto) { return zHealthInfoService.saveOrUpdateData(zHealthInfoDto); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZHealthNoteController.java
@@ -1,10 +1,36 @@ package com.ruoyi.web.controller.zhang; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.domain.ZHealthNote; import com.ruoyi.domain.dto.ZHealthNowDto; import com.ruoyi.service.ZHealthNoteService; import com.ruoyi.service.ZHealthNowService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-17 13:30 * @Version 1.0.0 **/ @RestController @RequestMapping("/zHealthNote") public class ZHealthNoteController { @Autowired private ZHealthNoteService zHealthNoteService; @GetMapping() public AjaxResult listAll(){ return zHealthNoteService.listAll(); } @PostMapping public AjaxResult saveOrUpdate(@RequestBody ZHealthNote zHealthNote){ return zHealthNoteService.saveData(zHealthNote); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZHealthNowController.java
@@ -1,10 +1,41 @@ package com.ruoyi.web.controller.zhang; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.domain.dto.ZHealthNowDto; import com.ruoyi.service.ZHealthNowService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-17 13:30 * @Version 1.0.0 **/ @RestController @RequestMapping("/zHealthNow") public class ZHealthNowController { @Autowired ZHealthNowService zHealthNowService; /** * 查询数据 */ @GetMapping("/all") public AjaxResult listAll(){ return zHealthNowService.selectData(); } /** * 新增或修改记录 */ // @PreAuthorize("@ss.hasPermi('system:property:edit')") @Log(title = "健康记录", businessType = BusinessType.UPDATE) @PostMapping public AjaxResult edit(@RequestBody ZHealthNowDto zHealthNowDto) { return zHealthNowService.saveOrUpdateData(zHealthNowDto); } } zhang-content/src/main/java/com/ruoyi/domain/ZHealthHabit.java
@@ -36,13 +36,13 @@ private String sleep; // 睡眠状态(json) private String bigEgestionStatus; // 大便规律(json) private String stoolStatus; // 大便规律(json) private String smallEgestionStatus; // 小便规律(json) private String urineStatus; // 小便规律(json) private String bigEgestion; // 大便 private String stool; // 大便 private String smallEgestion; // 小便 private String urine; // 小便 private String eatType; // 饮食习惯(json) zhang-content/src/main/java/com/ruoyi/domain/ZHealthNow.java
@@ -28,9 +28,7 @@ private String blood; // 血管疾病 private String digestiveSystem; // 消化系统疾病 private String breathSystem; // 呼吸系统疾病 zhang-content/src/main/java/com/ruoyi/domain/dto/ZHealthHabitDto.java
New file @@ -0,0 +1,49 @@ package com.ruoyi.domain.dto; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.ruoyi.domain.health.*; import lombok.Data; import java.io.Serializable; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-19 20:52 * @Version 1.0.0 **/ @Data public class ZHealthHabitDto implements Serializable { private static final long serialVersionUID = 1L; @TableId(value = "id", type = IdType.AUTO) private Long id; private Long uid; // 所属用户id private String eatGood; // 饮食(喜) private String eatBad; // 饮食(忌) private String hobby; // 爱好 private String addition; // 嗜好 private String stool; // 大便 private String urine; // 小便 private Sleep sleepClass; //睡眠情况 private StoolStatus stoolStatusClass; //大便情况 private UrineStatus urineStatusClass; //小便情况 private EatingHabits eatingHabitsClass; //饮食习惯 private LifeEvent lifeEventClass; //生活事件 } zhang-content/src/main/java/com/ruoyi/domain/dto/ZHealthInfoDto.java
New file @@ -0,0 +1,43 @@ package com.ruoyi.domain.dto; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.ruoyi.domain.health.AttitudeType; import com.ruoyi.domain.health.NutritionType; import com.ruoyi.domain.health.PsychologyType; import com.ruoyi.domain.health.SkinType; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-20 11:20 * @Version 1.0.0 **/ @Data public class ZHealthInfoDto { @TableId(value = "id", type = IdType.AUTO) private Long id; private Long uid; // 健康表所属者id private String temperature; // 体温 private String pulse; // 脉搏 private String breathe; // 呼吸 private String bloodPressure; // 血压 private String weight; // 体重kg private String movement; // 四肢活动情况 private SkinType skinTypeClass; // 皮肤情况 private PsychologyType psychologyTypeClass; // 心理状态 private AttitudeType attitudeClass; // 面对疾病的态度 private NutritionType nutritionClass; // 全身营养状况 } zhang-content/src/main/java/com/ruoyi/domain/dto/ZHealthNowDto.java
New file @@ -0,0 +1,23 @@ package com.ruoyi.domain.dto; import com.ruoyi.domain.health.*; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-21 8:52 * @Version 1.0.0 **/ @Data public class ZHealthNowDto { private BrainDisease brainDiseaseClass; private HeartDisease heartDiseaseClass; private VascularDisease vascularDiseaseClass; private DigestiveSystemDisease digestiveSystemDiseaseClass; private RespiratorySystemDisease respiratorySystemDiseaseClass; private KidneyDisease kidneyDiseaseClass; private OtherDisease otherDiseaseClass; } zhang-content/src/main/java/com/ruoyi/domain/health/AttitudeType.java
New file @@ -0,0 +1,20 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-20 11:22 * @Version 1.0.0 **/ @Data //病理态度 public class AttitudeType { private Integer lucidity = 0; //明朗 private Integer unknown = 0; //不了解 private Integer normal = 0; //正常 private Integer abnormal = 0; //不正常 private Integer other = 0;//其他 private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/BrainDisease.java
New file @@ -0,0 +1,19 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-21 8:53 * @Version 1.0.0 **/ @Data public class BrainDisease { private Integer ischemicStroke = 0;//缺血性卒中 private Integer cerebralHemorrhage = 0;//脑出血 private Integer subarachnoidHemorrhage = 0;//蛛网膜下腔出血 private Integer TIA = 0;//短暂性脑缺血发作 private Integer other = 0; private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/DigestiveSystemDisease.java
New file @@ -0,0 +1,25 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-21 9:14 * @Version 1.0.0 **/ @Data public class DigestiveSystemDisease { private Integer gastroduodenalUlcer = 0;//胃十二指肠溃疡 private Integer esophagitis = 0;//返流性食管炎 private Integer gastritis = 0;//慢性胃炎 private Integer colitis = 0;//溃疡性结肠炎 private Integer hepatitis = 0;//肝炎 private Integer cholecystitis = 0;//胆囊炎 private Integer cholelithiasis = 0;//胆石症 private Integer fattyLiver = 0;//脂肪肝 private Integer hyperlipidemia = 0;//高脂血症 private Integer haemorrhoids = 0;//痔疮 private Integer other = 0; private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/EatingHabits.java
New file @@ -0,0 +1,21 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-19 21:20 * @Version 1.0.0 **/ @Data public class EatingHabits { private Integer uniformityOfMeatAndVegetables = 0; private Integer meat = 0; private Integer vegetable = 0; private Integer salt = 0; private Integer oil = 0; private Integer sugar = 0; private Integer other = 0; private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/HeartDisease.java
New file @@ -0,0 +1,20 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-21 8:56 * @Version 1.0.0 **/ @Data public class HeartDisease { private Integer myocardialInfarct = 0; //心肌梗塞 private Integer anginaPectoris = 0; //心绞痛 private Integer coronaryRevascularization = 0; //冠状动脉血运重建 private Integer congestiveHeartFailure = 0; //充血性心力衰竭充血性心力衰竭 private Integer precordialPain = 0; //心前区疼痛 private Integer other = 0; private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/KidneyDisease.java
New file @@ -0,0 +1,21 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-21 9:21 * @Version 1.0.0 **/ @Data public class KidneyDisease { private Integer diabetes = 0;//糖尿病 private Integer renalFailure = 0;//糖尿病 private Integer acuteNephritis = 0;//急性肾炎 private Integer chronicNephritis = 0;//慢性肾炎 private Integer urinaryCalculus = 0;//泌尿系统结石 private Integer urinaryTractInfection = 0;//泌尿系统感染 private Integer other = 0; private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/LifeEvent.java
New file @@ -0,0 +1,19 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-19 21:24 * @Version 1.0.0 **/ @Data public class LifeEvent { private Integer bereave = 0; private Integer liveAlone = 0; private Integer inHospital = 0; private Integer divide = 0; private Integer other = 0;//其它 private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/NutritionType.java
New file @@ -0,0 +1,21 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-20 11:22 * @Version 1.0.0 **/ @Data public class NutritionType { private Integer good = 0; //良好 private Integer medium = 0; //中等 private Integer poor = 0; //欠佳 private Integer obesity = 0; //肥胖 private Integer thin = 0; //消瘦 private Integer fluid = 0; //恶液质 private Integer other = 0;//其它 private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/OtherDisease.java
New file @@ -0,0 +1,22 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-21 9:24 * @Version 1.0.0 **/ @Data public class OtherDisease { private Integer pregnant = 0;//孕期三个月以内的孕妇 private Integer cold = 0;//病毒性重感冒 private Integer infectious = 0;//传染性疾病 private Integer pulmonaryBulla = 0;//肺大疱 private Integer hemoptysis = 0;//结核性空洞形成的咯血 private Integer pneumothorax = 0;//未经处理的气胸 private Integer activeBleeding = 0;//活动性出血 private Integer other = 0;//其它 private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/PsychologyType.java
New file @@ -0,0 +1,21 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-20 11:22 * @Version 1.0.0 **/ @Data public class PsychologyType { private Integer optimistic = 0; //开朗 private Integer worry = 0; //焦虑 private Integer fear = 0; //忧愁恐惧 private Integer suspicion = 0; //猜疑 private Integer constrain = 0; //压抑 private Integer miss = 0; //思念 private Integer other = 0;//其它 private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/RespiratorySystemDisease.java
New file @@ -0,0 +1,21 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-21 9:08 * @Version 1.0.0 **/ @Data public class RespiratorySystemDisease { private Integer COPD = 0; //COPD private Integer pneumonia = 0; //肺炎 private Integer bronchitis = 0; //支气管炎 private Integer bronchialAsthma = 0; //支气管哮喘 private Integer pulmonaryTuberculosis = 0; //肺结核 private Integer upperRespiratoryTractInfection = 0; //上呼吸道感染 private Integer other = 0;//其它 private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/SkinType.java
New file @@ -0,0 +1,24 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-20 11:22 * @Version 1.0.0 **/ @Data public class SkinType { private Integer acne = 0; //青春痘 private Integer psoriasis = 0; //牛皮藓 private Integer color = 0; //色素沉着 private Integer edema = 0; //水肿 private Integer rash = 0;//皮疹 private Integer bloodStasis = 0;//瘀点瘀斑 private Integer snom = 0;//皮下结节或肿块 private Integer nevus = 0;//蜘蛛痣 private Integer ulcer = 0;//溃疡或瘢痕 private Integer other = 0;//其它 private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/Sleep.java
New file @@ -0,0 +1,22 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-19 21:05 * @Version 1.0.0 **/ @Data public class Sleep { private Integer good = 0;//良好 private Integer general = 0;//良好 private Integer easyWake = 0;//易醒 private Integer dreaminess = 0;//多梦 private Integer sleepless = 0;//失眠 private Integer snore = 0;//打鼾 private Integer wakefulness = 0;//睡不熟 private Integer other = 0;//其它 private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/StoolStatus.java
New file @@ -0,0 +1,22 @@ package com.ruoyi.domain.health; import lombok.Data; import java.io.Serializable; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-19 21:12 * @Version 1.0.0 **/ @Data public class StoolStatus{ private Integer normal = 0;//正常 private Integer constipation = 0;//便秘 private Integer diarrhea = 0;//腹泻 private Integer incontinence = 0;//失禁 private Integer other = 0;//其它 private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/UrineStatus.java
New file @@ -0,0 +1,19 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-19 21:15 * @Version 1.0.0 **/ @Data public class UrineStatus { private Integer normal = 0;//正常 private Integer nightUrinaryRetention = 0;//夜尿潴留 private Integer incontinence = 0;//失禁 private Integer enuresis = 0;//遗尿 private Integer other = 0;//其它 private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/domain/health/VascularDisease.java
New file @@ -0,0 +1,17 @@ package com.ruoyi.domain.health; import lombok.Data; /** * @Author Jinquan_Ou * @Description * @Date 2023-07-21 9:11 * @Version 1.0.0 **/ @Data public class VascularDisease { private Integer dissectingAneurysm = 0; //夹层动脉瘤 private Integer arterialOcclusiveDiseases = 0; //动脉闭塞性疾病 private Integer other = 0;//其它 private String otherText = ""; } zhang-content/src/main/java/com/ruoyi/service/ZHealthHabitService.java
@@ -2,7 +2,9 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.ZHealthHabit; import com.ruoyi.domain.dto.ZHealthHabitDto; /** * <p> @@ -14,4 +16,7 @@ */ public interface ZHealthHabitService extends IService<ZHealthHabit> { AjaxResult selectData(); AjaxResult saveOrUpdateData(ZHealthHabitDto zHealthHabitDto); } zhang-content/src/main/java/com/ruoyi/service/ZHealthInfoService.java
@@ -2,7 +2,9 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.ZHealthInfo; import com.ruoyi.domain.dto.ZHealthInfoDto; /** * <p> @@ -14,4 +16,7 @@ */ public interface ZHealthInfoService extends IService<ZHealthInfo> { AjaxResult selectData(); AjaxResult saveOrUpdateData(ZHealthInfoDto zHealthInfoDto); } zhang-content/src/main/java/com/ruoyi/service/ZHealthNoteService.java
@@ -1,6 +1,7 @@ package com.ruoyi.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.ZHealthNote; /** @@ -10,4 +11,8 @@ * @Version 1.0.0 **/ public interface ZHealthNoteService extends IService<ZHealthNote> { AjaxResult listAll(); AjaxResult saveData(ZHealthNote zHealthNote); } zhang-content/src/main/java/com/ruoyi/service/ZHealthNowService.java
@@ -1,7 +1,9 @@ package com.ruoyi.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.domain.ZHealthNow; import com.ruoyi.domain.dto.ZHealthNowDto; /** * @Author Jinquan_Ou @@ -10,4 +12,8 @@ * @Version 1.0.0 **/ public interface ZHealthNowService extends IService<ZHealthNow> { AjaxResult selectData(); AjaxResult saveOrUpdateData(ZHealthNowDto zHealthNowDto); } zhang-content/src/main/java/com/ruoyi/service/impl/ZHealthHabitServiceImpl.java
@@ -1,8 +1,18 @@ package com.ruoyi.service.impl; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.domain.ZHealthHabit; import com.ruoyi.domain.ZHealthHabit; import com.ruoyi.domain.dto.ZHealthHabitDto; import com.ruoyi.domain.dto.ZHealthHabitDto; import com.ruoyi.domain.health.*; import com.ruoyi.mapper.ZHealthHabitMapper; import com.ruoyi.service.ZHealthHabitService; import org.springframework.stereotype.Service; @@ -18,4 +28,73 @@ @Service public class ZHealthHabitServiceImpl extends ServiceImpl<ZHealthHabitMapper, ZHealthHabit> implements ZHealthHabitService { @Override public AjaxResult selectData() { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); LambdaQueryWrapper<ZHealthHabit> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZHealthHabit::getUid,userId); ZHealthHabit zHealthHabit = getOne(lqw); //如果是第一次进来,之前没有这个用户的数据,抛异常让用户先插入数据 if(zHealthHabit == null){ throw new RuntimeException("第一次进来,请先填写好数据"); } //封装要返回的数据 ZHealthHabitDto returnData = new ZHealthHabitDto(); BeanUtils.copyProperties(zHealthHabit,returnData); // returnData.setName(zHealthHabit.getName()); // returnData.setSex(zHealthHabit.getSex()); // returnData.setEducationLevel(zHealthHabit.getEducationLevel()); // returnData.setWork(zHealthHabit.getWork()); // returnData.setPhone(zHealthHabit.getPhone()); // returnData.setEmail(zHealthHabit.getEmail()); // returnData.setMedicine(zHealthHabit.getMedicine()); // returnData.setBaseDisease(zHealthHabit.getBaseDisease()); //将json数组转换成对象 returnData.setSleepClass(JSON.parseObject(zHealthHabit.getSleep(), Sleep.class)); returnData.setStoolStatusClass(JSON.parseObject(zHealthHabit.getStoolStatus(), StoolStatus.class)); returnData.setUrineStatusClass(JSON.parseObject(zHealthHabit.getUrineStatus(), UrineStatus.class)); returnData.setEatingHabitsClass(JSON.parseObject(zHealthHabit.getEatType(), EatingHabits.class)); returnData.setLifeEventClass(JSON.parseObject(zHealthHabit.getLifeType(), LifeEvent.class)); return AjaxResult.success(returnData); } @Override public AjaxResult saveOrUpdateData(ZHealthHabitDto zHealthHabitDto) { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); LambdaQueryWrapper<ZHealthHabit> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZHealthHabit::getUid,userId); ZHealthHabit getResult = getOne(lqw); ZHealthHabit zHealthHabit = new ZHealthHabit(); BeanUtils.copyProperties(zHealthHabitDto,zHealthHabit); zHealthHabit.setUid(userId); zHealthHabit.setSleep(JSON.toJSONString(zHealthHabitDto.getSleepClass())); zHealthHabit.setStoolStatus(JSON.toJSONString(zHealthHabitDto.getStoolStatusClass())); zHealthHabit.setUrineStatus(JSON.toJSONString(zHealthHabitDto.getUrineStatusClass())); zHealthHabit.setEatType(JSON.toJSONString(zHealthHabitDto.getEatingHabitsClass())); zHealthHabit.setLifeType(JSON.toJSONString(zHealthHabitDto.getLifeEventClass())); if(getResult == null){ //如果是第一次进来,那么是新增数据 save(zHealthHabit); }else { //如果不是第一次,那就是修改数据了 zHealthHabit.setId(getResult.getId()); updateById(zHealthHabit); } return AjaxResult.success(); } } zhang-content/src/main/java/com/ruoyi/service/impl/ZHealthInfoServiceImpl.java
@@ -1,8 +1,19 @@ package com.ruoyi.service.impl; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.domain.ZHealthInfo; import com.ruoyi.domain.ZHealthInfo; import com.ruoyi.domain.ZHealthInfo; import com.ruoyi.domain.dto.ZHealthInfoDto; import com.ruoyi.domain.dto.ZHealthInfoDto; import com.ruoyi.domain.health.*; import com.ruoyi.mapper.ZHealthInfoMapper; import com.ruoyi.service.ZHealthInfoService; import org.springframework.stereotype.Service; @@ -18,4 +29,71 @@ @Service public class ZHealthInfoServiceImpl extends ServiceImpl<ZHealthInfoMapper, ZHealthInfo> implements ZHealthInfoService { @Override public AjaxResult selectData() { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); LambdaQueryWrapper<ZHealthInfo> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZHealthInfo::getUid,userId); ZHealthInfo zHealthInfo = getOne(lqw); //如果是第一次进来,之前没有这个用户的数据,抛异常让用户先插入数据 if(zHealthInfo == null){ throw new RuntimeException("第一次进来,请先填写好数据"); } //封装要返回的数据 ZHealthInfoDto returnData = new ZHealthInfoDto(); BeanUtils.copyProperties(zHealthInfo,returnData); // returnData.setName(zHealthInfo.getName()); // returnData.setSex(zHealthInfo.getSex()); // returnData.setEducationLevel(zHealthInfo.getEducationLevel()); // returnData.setWork(zHealthInfo.getWork()); // returnData.setPhone(zHealthInfo.getPhone()); // returnData.setEmail(zHealthInfo.getEmail()); // returnData.setMedicine(zHealthInfo.getMedicine()); // returnData.setBaseDisease(zHealthInfo.getBaseDisease()); //将json数组转换成对象 returnData.setSkinTypeClass(JSON.parseObject(zHealthInfo.getSkinType(), SkinType.class)); returnData.setPsychologyTypeClass(JSON.parseObject(zHealthInfo.getPsychologyType(), PsychologyType.class)); returnData.setAttitudeClass(JSON.parseObject(zHealthInfo.getAttitude(), AttitudeType.class)); returnData.setNutritionClass(JSON.parseObject(zHealthInfo.getNutrition(), NutritionType.class)); return AjaxResult.success(returnData); } @Override public AjaxResult saveOrUpdateData(ZHealthInfoDto zHealthInfoDto) { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); LambdaQueryWrapper<ZHealthInfo> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZHealthInfo::getUid,userId); ZHealthInfo getResult = getOne(lqw); ZHealthInfo zHealthInfo = new ZHealthInfo(); BeanUtils.copyProperties(zHealthInfoDto,zHealthInfo); zHealthInfo.setUid(userId); zHealthInfo.setSkinType(JSON.toJSONString(zHealthInfoDto.getSkinTypeClass())); zHealthInfo.setPsychologyType(JSON.toJSONString(zHealthInfoDto.getPsychologyTypeClass())); zHealthInfo.setAttitude(JSON.toJSONString(zHealthInfoDto.getAttitudeClass())); zHealthInfo.setNutrition(JSON.toJSONString(zHealthInfoDto.getNutritionClass())); if(getResult == null){ //如果是第一次进来,那么是新增数据 save(zHealthInfo); }else { //如果不是第一次,那就是修改数据了 zHealthInfo.setId(getResult.getId()); updateById(zHealthInfo); } return AjaxResult.success(); } } zhang-content/src/main/java/com/ruoyi/service/impl/ZHealthNoteServiceImpl.java
@@ -1,6 +1,10 @@ package com.ruoyi.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.domain.ZHealthNote; import com.ruoyi.mapper.ZHealthNoteMapper; import com.ruoyi.service.ZHealthNoteService; @@ -14,4 +18,40 @@ **/ @Service public class ZHealthNoteServiceImpl extends ServiceImpl<ZHealthNoteMapper, ZHealthNote> implements ZHealthNoteService { @Override public AjaxResult listAll() { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); LambdaQueryWrapper<ZHealthNote> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZHealthNote::getUid,userId); ZHealthNote result = getOne(lqw); if(result == null){ throw new RuntimeException("请先填写好数据"); } return AjaxResult.success(result); } @Override public AjaxResult saveData(ZHealthNote zHealthNote) { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); LambdaQueryWrapper<ZHealthNote> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZHealthNote::getUid,userId); ZHealthNote result = getOne(lqw); if(result == null){ zHealthNote.setUid(userId); save(zHealthNote); }else { zHealthNote.setId(result.getId()); zHealthNote.setUid(userId); updateById(zHealthNote); } return AjaxResult.success(); } } zhang-content/src/main/java/com/ruoyi/service/impl/ZHealthNowServiceImpl.java
@@ -1,10 +1,22 @@ package com.ruoyi.service.impl; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.domain.ZHealthNow; import com.ruoyi.domain.ZHealthNow; import com.ruoyi.domain.dto.ZHealthNowDto; import com.ruoyi.domain.dto.ZHealthNowDto; import com.ruoyi.domain.health.*; import com.ruoyi.mapper.ZHealthNowMapper; import com.ruoyi.service.ZHealthNowService; import org.springframework.stereotype.Service; import javax.sql.rowset.BaseRowSet; /** * @Author Jinquan_Ou @@ -14,4 +26,80 @@ **/ @Service public class ZHealthNowServiceImpl extends ServiceImpl<ZHealthNowMapper, ZHealthNow> implements ZHealthNowService { @Override public AjaxResult selectData() { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); LambdaQueryWrapper<ZHealthNow> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZHealthNow::getUid,userId); ZHealthNow zHealthNow = getOne(lqw); //如果是第一次进来,之前没有这个用户的数据,抛异常让用户先插入数据 if(zHealthNow == null){ throw new RuntimeException("第一次进来,请先填写好数据"); } //封装要返回的数据 ZHealthNowDto returnData = new ZHealthNowDto(); BeanUtils.copyProperties(zHealthNow,returnData); // returnData.setName(zHealthNow.getName()); // returnData.setSex(zHealthNow.getSex()); // returnData.setEducationLevel(zHealthNow.getEducationLevel()); // returnData.setWork(zHealthNow.getWork()); // returnData.setPhone(zHealthNow.getPhone()); // returnData.setEmail(zHealthNow.getEmail()); // returnData.setMedicine(zHealthNow.getMedicine()); // returnData.setBaseDisease(zHealthNow.getBaseDisease()); //将json数组转换成对象 returnData.setBrainDiseaseClass(JSON.parseObject(zHealthNow.getBrain(), BrainDisease.class)); returnData.setHeartDiseaseClass(JSON.parseObject(zHealthNow.getHeart(), HeartDisease.class)); returnData.setVascularDiseaseClass(JSON.parseObject(zHealthNow.getBlood(), VascularDisease.class)); returnData.setDigestiveSystemDiseaseClass(JSON.parseObject(zHealthNow.getDigestiveSystem(), DigestiveSystemDisease.class)); returnData.setRespiratorySystemDiseaseClass(JSON.parseObject(zHealthNow.getDigestiveSystem(), RespiratorySystemDisease.class)); returnData.setKidneyDiseaseClass(JSON.parseObject(zHealthNow.getKidney(), KidneyDisease.class)); returnData.setOtherDiseaseClass(JSON.parseObject(zHealthNow.getOther(), OtherDisease.class)); return AjaxResult.success(returnData); } @Override public AjaxResult saveOrUpdateData(ZHealthNowDto zHealthNowDto) { SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); LambdaQueryWrapper<ZHealthNow> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZHealthNow::getUid,userId); ZHealthNow getResult = getOne(lqw); ZHealthNow zHealthNow = new ZHealthNow(); BeanUtils.copyProperties(zHealthNowDto,zHealthNow); zHealthNow.setUid(userId); zHealthNow.setBrain(JSON.toJSONString(zHealthNowDto.getBrainDiseaseClass())); zHealthNow.setHeart(JSON.toJSONString(zHealthNowDto.getHeartDiseaseClass())); zHealthNow.setBlood(JSON.toJSONString(zHealthNowDto.getVascularDiseaseClass())); zHealthNow.setDigestiveSystem(JSON.toJSONString(zHealthNowDto.getDigestiveSystemDiseaseClass())); zHealthNow.setBreathSystem(JSON.toJSONString(zHealthNowDto.getRespiratorySystemDiseaseClass())); zHealthNow.setKidney(JSON.toJSONString(zHealthNowDto.getKidneyDiseaseClass())); zHealthNow.setOther(JSON.toJSONString(zHealthNowDto.getOtherDiseaseClass())); if(getResult == null){ //如果是第一次进来,那么是新增数据 save(zHealthNow); }else { //如果不是第一次,那就是修改数据了 zHealthNow.setId(getResult.getId()); updateById(zHealthNow); } return AjaxResult.success(); } }