This commit is contained in:
zrh050423 2024-11-24 18:46:36 +08:00
parent d19e678060
commit ef8b88ce90
7 changed files with 31 additions and 28 deletions

View File

@ -2,7 +2,6 @@ package edu.zrh.healthsystem.controller;
import edu.zrh.healthsystem.model.Elderly; import edu.zrh.healthsystem.model.Elderly;
import edu.zrh.healthsystem.model.elderly.RegularCheckupInfoResponse; import edu.zrh.healthsystem.model.elderly.RegularCheckupInfoResponse;
import edu.zrh.healthsystem.repository.RegularCheckupInfoRespository;
import edu.zrh.healthsystem.service.RegularCheckupService; import edu.zrh.healthsystem.service.RegularCheckupService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;

View File

@ -11,6 +11,9 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.Map;
/**
* @author han
*/
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@RestController @RestController
public class ElderlyConnectController { public class ElderlyConnectController {

View File

@ -19,7 +19,7 @@ public class RegularCheckupInfo {
@ManyToOne(fetch = FetchType.LAZY, optional = false) @ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "ProfileID", nullable = false) @JoinColumn(name = "ProfileID", nullable = false)
private MainProfileInfo profileID; private MainProfileInfo profileId;
@Column(name = "WeightStatus", nullable = false) @Column(name = "WeightStatus", nullable = false)
private String weightStatus; private String weightStatus;

View File

@ -1,12 +0,0 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.RegularCheckupInfo;
import edu.zrh.healthsystem.model.Elderly;
import org.springframework.data.jpa.repository.JpaRepository;
import java.lang.classfile.Opcode;
import java.util.Optional;
public interface RegularCheckupInfoRespository extends JpaRepository<RegularCheckupInfo, Integer> {
Optional<RegularCheckupInfo> findByElderlyId(int elderlyId);
}

View File

@ -0,0 +1,13 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.RegularCheckupInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
/**
* @author han
*/
public interface RegularCheckupRepository extends JpaRepository<RegularCheckupInfo, Integer> {
Optional<RegularCheckupInfo> findById(int id);
}

View File

@ -1,29 +1,26 @@
package edu.zrh.healthsystem.service; package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.eneity.RegularCheckupInfo; import edu.zrh.healthsystem.eneity.RegularCheckupInfo;
import edu.zrh.healthsystem.eneity.UserInfo;
import edu.zrh.healthsystem.model.Elderly; import edu.zrh.healthsystem.model.Elderly;
import edu.zrh.healthsystem.model.elderly.RegularCheckupInfoResponse; import edu.zrh.healthsystem.model.elderly.RegularCheckupInfoResponse;
import edu.zrh.healthsystem.repository.RegularCheckupInfoRespository; import edu.zrh.healthsystem.repository.RegularCheckupRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
@Service @Service
public class RegularCheckupService { public class RegularCheckupService {
private final RegularCheckupInfoRespository regularCheckupInfoRespository; private final RegularCheckupRepository regularCheckupRespository;
@Autowired @Autowired
public RegularCheckupService(RegularCheckupInfoRespository regularCheckupInfoRespository) { public RegularCheckupService(RegularCheckupRepository regularCheckupRespository) {
this.regularCheckupInfoRespository = regularCheckupInfoRespository; this.regularCheckupRespository = regularCheckupRespository;
} }
RegularCheckupInfoResponse regularCheckupInfoResponse = new RegularCheckupInfoResponse(); RegularCheckupInfoResponse regularCheckupInfoResponse = new RegularCheckupInfoResponse();
public RegularCheckupInfoResponse add(Elderly elderly) { public RegularCheckupInfoResponse add(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId()); Optional<RegularCheckupInfo> optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId());
if (optionalElderly.isPresent()) { if (optionalElderly.isPresent()) {
regularCheckupInfoResponse.setMessage("已经有表"); regularCheckupInfoResponse.setMessage("已经有表");
} else { } else {
@ -43,13 +40,13 @@ public class RegularCheckupService {
regularCheckupInfo.setTongueImage(elderly.getTongueImage()); regularCheckupInfo.setTongueImage(elderly.getTongueImage());
regularCheckupInfo.setWeightStatus(elderly.getWeightStatus()); regularCheckupInfo.setWeightStatus(elderly.getWeightStatus());
regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation()); regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation());
regularCheckupInfoRespository.save(regularCheckupInfo); regularCheckupRespository.save(regularCheckupInfo);
regularCheckupInfoResponse.setMessage("添加成功"); regularCheckupInfoResponse.setMessage("添加成功");
} }
return regularCheckupInfoResponse; return regularCheckupInfoResponse;
} }
public RegularCheckupInfoResponse delete(Elderly elderly) { public RegularCheckupInfoResponse delete(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId()); Optional<RegularCheckupInfo> optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId());
if (optionalElderly.isPresent()) { if (optionalElderly.isPresent()) {
RegularCheckupInfo regularCheckupInfo = optionalElderly.get(); RegularCheckupInfo regularCheckupInfo = optionalElderly.get();
regularCheckupInfo.setBloodType(elderly.getBloodType()); regularCheckupInfo.setBloodType(elderly.getBloodType());
@ -67,7 +64,7 @@ public class RegularCheckupService {
regularCheckupInfo.setTongueImage(elderly.getTongueImage()); regularCheckupInfo.setTongueImage(elderly.getTongueImage());
regularCheckupInfo.setWeightStatus(elderly.getWeightStatus()); regularCheckupInfo.setWeightStatus(elderly.getWeightStatus());
regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation()); regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation());
regularCheckupInfoRespository.save(regularCheckupInfo); regularCheckupRespository.save(regularCheckupInfo);
regularCheckupInfoResponse.setMessage("删除成功"); regularCheckupInfoResponse.setMessage("删除成功");
} else { } else {
regularCheckupInfoResponse.setMessage("没有该表"); regularCheckupInfoResponse.setMessage("没有该表");
@ -76,7 +73,7 @@ public class RegularCheckupService {
} }
public RegularCheckupInfoResponse update(Elderly elderly) { public RegularCheckupInfoResponse update(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId()); Optional<RegularCheckupInfo> optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId());
if (optionalElderly.isPresent()) { if (optionalElderly.isPresent()) {
RegularCheckupInfo regularCheckupInfo = optionalElderly.get(); RegularCheckupInfo regularCheckupInfo = optionalElderly.get();
regularCheckupInfo.setBloodType(elderly.getBloodType()); regularCheckupInfo.setBloodType(elderly.getBloodType());
@ -94,7 +91,7 @@ public class RegularCheckupService {
regularCheckupInfo.setTongueImage(elderly.getTongueImage()); regularCheckupInfo.setTongueImage(elderly.getTongueImage());
regularCheckupInfo.setWeightStatus(elderly.getWeightStatus()); regularCheckupInfo.setWeightStatus(elderly.getWeightStatus());
regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation()); regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation());
regularCheckupInfoRespository.save(regularCheckupInfo); regularCheckupRespository.save(regularCheckupInfo);
regularCheckupInfoResponse.setMessage("更新成功"); regularCheckupInfoResponse.setMessage("更新成功");
} else { } else {
regularCheckupInfoResponse.setMessage("没有该表"); regularCheckupInfoResponse.setMessage("没有该表");
@ -102,7 +99,7 @@ public class RegularCheckupService {
return regularCheckupInfoResponse; return regularCheckupInfoResponse;
} }
public RegularCheckupInfoResponse get(Elderly elderly) { public RegularCheckupInfoResponse get(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId()); Optional<RegularCheckupInfo> optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId());
if (optionalElderly.isPresent()) { if (optionalElderly.isPresent()) {
regularCheckupInfoResponse.setBloodType(elderly.getBloodType()); regularCheckupInfoResponse.setBloodType(elderly.getBloodType());
regularCheckupInfoResponse.setId(elderly.getElderlyId()); regularCheckupInfoResponse.setId(elderly.getElderlyId());

View File

@ -9,6 +9,9 @@ import org.springframework.stereotype.Service;
import java.util.Optional; import java.util.Optional;
/**
* @author han
*/
@Service @Service
public class ElderlyConnectService { public class ElderlyConnectService {
private final ElderlyConnectRepository elderlyConnectRepository; private final ElderlyConnectRepository elderlyConnectRepository;