diff --git a/src/main/java/edu/zrh/healthsystem/controller/RegularCheckupController.java b/src/main/java/edu/zrh/healthsystem/controller/RegularCheckupController.java index b964ed9..c2d5229 100644 --- a/src/main/java/edu/zrh/healthsystem/controller/RegularCheckupController.java +++ b/src/main/java/edu/zrh/healthsystem/controller/RegularCheckupController.java @@ -2,7 +2,6 @@ package edu.zrh.healthsystem.controller; import edu.zrh.healthsystem.model.Elderly; import edu.zrh.healthsystem.model.elderly.RegularCheckupInfoResponse; -import edu.zrh.healthsystem.repository.RegularCheckupInfoRespository; import edu.zrh.healthsystem.service.RegularCheckupService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/edu/zrh/healthsystem/controller/elderly/ElderlyConnectController.java b/src/main/java/edu/zrh/healthsystem/controller/elderly/ElderlyConnectController.java index 79b9c7c..5f73f26 100644 --- a/src/main/java/edu/zrh/healthsystem/controller/elderly/ElderlyConnectController.java +++ b/src/main/java/edu/zrh/healthsystem/controller/elderly/ElderlyConnectController.java @@ -11,6 +11,9 @@ import org.springframework.web.bind.annotation.RestController; import java.util.Map; +/** + * @author han + */ @CrossOrigin(origins = "*") @RestController public class ElderlyConnectController { diff --git a/src/main/java/edu/zrh/healthsystem/eneity/RegularCheckupInfo.java b/src/main/java/edu/zrh/healthsystem/eneity/RegularCheckupInfo.java index a36cc2f..0749f20 100644 --- a/src/main/java/edu/zrh/healthsystem/eneity/RegularCheckupInfo.java +++ b/src/main/java/edu/zrh/healthsystem/eneity/RegularCheckupInfo.java @@ -19,7 +19,7 @@ public class RegularCheckupInfo { @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "ProfileID", nullable = false) - private MainProfileInfo profileID; + private MainProfileInfo profileId; @Column(name = "WeightStatus", nullable = false) private String weightStatus; diff --git a/src/main/java/edu/zrh/healthsystem/repository/RegularCheckupInfoRespository.java b/src/main/java/edu/zrh/healthsystem/repository/RegularCheckupInfoRespository.java deleted file mode 100644 index 3cb58bb..0000000 --- a/src/main/java/edu/zrh/healthsystem/repository/RegularCheckupInfoRespository.java +++ /dev/null @@ -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 { - Optional findByElderlyId(int elderlyId); -} diff --git a/src/main/java/edu/zrh/healthsystem/repository/RegularCheckupRepository.java b/src/main/java/edu/zrh/healthsystem/repository/RegularCheckupRepository.java new file mode 100644 index 0000000..4af7b93 --- /dev/null +++ b/src/main/java/edu/zrh/healthsystem/repository/RegularCheckupRepository.java @@ -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 { + Optional findById(int id); +} diff --git a/src/main/java/edu/zrh/healthsystem/service/RegularCheckupService.java b/src/main/java/edu/zrh/healthsystem/service/RegularCheckupService.java index 3840768..800751e 100644 --- a/src/main/java/edu/zrh/healthsystem/service/RegularCheckupService.java +++ b/src/main/java/edu/zrh/healthsystem/service/RegularCheckupService.java @@ -1,29 +1,26 @@ package edu.zrh.healthsystem.service; import edu.zrh.healthsystem.eneity.RegularCheckupInfo; -import edu.zrh.healthsystem.eneity.UserInfo; import edu.zrh.healthsystem.model.Elderly; 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.stereotype.Service; -import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; @Service public class RegularCheckupService { - private final RegularCheckupInfoRespository regularCheckupInfoRespository; + private final RegularCheckupRepository regularCheckupRespository; @Autowired - public RegularCheckupService(RegularCheckupInfoRespository regularCheckupInfoRespository) { - this.regularCheckupInfoRespository = regularCheckupInfoRespository; + public RegularCheckupService(RegularCheckupRepository regularCheckupRespository) { + this.regularCheckupRespository = regularCheckupRespository; } RegularCheckupInfoResponse regularCheckupInfoResponse = new RegularCheckupInfoResponse(); public RegularCheckupInfoResponse add(Elderly elderly) { - Optional optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId()); + Optional optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId()); if (optionalElderly.isPresent()) { regularCheckupInfoResponse.setMessage("已经有表"); } else { @@ -43,13 +40,13 @@ public class RegularCheckupService { regularCheckupInfo.setTongueImage(elderly.getTongueImage()); regularCheckupInfo.setWeightStatus(elderly.getWeightStatus()); regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation()); - regularCheckupInfoRespository.save(regularCheckupInfo); + regularCheckupRespository.save(regularCheckupInfo); regularCheckupInfoResponse.setMessage("添加成功"); } return regularCheckupInfoResponse; } public RegularCheckupInfoResponse delete(Elderly elderly) { - Optional optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId()); + Optional optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId()); if (optionalElderly.isPresent()) { RegularCheckupInfo regularCheckupInfo = optionalElderly.get(); regularCheckupInfo.setBloodType(elderly.getBloodType()); @@ -67,7 +64,7 @@ public class RegularCheckupService { regularCheckupInfo.setTongueImage(elderly.getTongueImage()); regularCheckupInfo.setWeightStatus(elderly.getWeightStatus()); regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation()); - regularCheckupInfoRespository.save(regularCheckupInfo); + regularCheckupRespository.save(regularCheckupInfo); regularCheckupInfoResponse.setMessage("删除成功"); } else { regularCheckupInfoResponse.setMessage("没有该表"); @@ -76,7 +73,7 @@ public class RegularCheckupService { } public RegularCheckupInfoResponse update(Elderly elderly) { - Optional optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId()); + Optional optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId()); if (optionalElderly.isPresent()) { RegularCheckupInfo regularCheckupInfo = optionalElderly.get(); regularCheckupInfo.setBloodType(elderly.getBloodType()); @@ -94,7 +91,7 @@ public class RegularCheckupService { regularCheckupInfo.setTongueImage(elderly.getTongueImage()); regularCheckupInfo.setWeightStatus(elderly.getWeightStatus()); regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation()); - regularCheckupInfoRespository.save(regularCheckupInfo); + regularCheckupRespository.save(regularCheckupInfo); regularCheckupInfoResponse.setMessage("更新成功"); } else { regularCheckupInfoResponse.setMessage("没有该表"); @@ -102,7 +99,7 @@ public class RegularCheckupService { return regularCheckupInfoResponse; } public RegularCheckupInfoResponse get(Elderly elderly) { - Optional optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId()); + Optional optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId()); if (optionalElderly.isPresent()) { regularCheckupInfoResponse.setBloodType(elderly.getBloodType()); regularCheckupInfoResponse.setId(elderly.getElderlyId()); diff --git a/src/main/java/edu/zrh/healthsystem/service/elderly/ElderlyConnectService.java b/src/main/java/edu/zrh/healthsystem/service/elderly/ElderlyConnectService.java index 6f16522..626fce3 100644 --- a/src/main/java/edu/zrh/healthsystem/service/elderly/ElderlyConnectService.java +++ b/src/main/java/edu/zrh/healthsystem/service/elderly/ElderlyConnectService.java @@ -9,6 +9,9 @@ import org.springframework.stereotype.Service; import java.util.Optional; +/** + * @author han + */ @Service public class ElderlyConnectService { private final ElderlyConnectRepository elderlyConnectRepository;