2.0
This commit is contained in:
parent
d19e678060
commit
ef8b88ce90
|
@ -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.*;
|
||||
|
|
|
@ -11,6 +11,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author han
|
||||
*/
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
public class ElderlyConnectController {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId());
|
||||
Optional<RegularCheckupInfo> 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<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId());
|
||||
Optional<RegularCheckupInfo> 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<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId());
|
||||
Optional<RegularCheckupInfo> 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<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId());
|
||||
Optional<RegularCheckupInfo> optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId());
|
||||
if (optionalElderly.isPresent()) {
|
||||
regularCheckupInfoResponse.setBloodType(elderly.getBloodType());
|
||||
regularCheckupInfoResponse.setId(elderly.getElderlyId());
|
||||
|
|
|
@ -9,6 +9,9 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author han
|
||||
*/
|
||||
@Service
|
||||
public class ElderlyConnectService {
|
||||
private final ElderlyConnectRepository elderlyConnectRepository;
|
||||
|
|
Loading…
Reference in New Issue