Compare commits

...

No commits in common. "master" and "backed-end" have entirely different histories.

100 changed files with 1990 additions and 1632 deletions

2
mvnw.cmd vendored
View File

@ -23,7 +23,7 @@
@REM
@REM Optional ENV vars
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
@REM MVNW_USERNAME/MVNW_PASSWORD - userLoginInfo and password for downloading maven
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
@REM ----------------------------------------------------------------------------

133
pom.xml
View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Maven项目的配置文件 -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@ -6,7 +7,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.5</version>
<relativePath/> <!-- lookup parent from repository -->
<relativePath/>
</parent>
<groupId>edu.zrh</groupId>
<artifactId>healthSystem</artifactId>
@ -27,47 +28,119 @@
<url/>
</scm>
<properties>
<java.version>23</java.version>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- Spring Boot Starter Web: 包含了Spring MVC、Tomcat等 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.3.5</version> <!-- 指定版本 -->
<version>3.3.5</version>
</dependency>
<!-- Spring Security依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.4</version>
</dependency>
<!-- Spring Boot Starter Data JPA: 用于简化JPA的开发 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.21</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>3.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.12</version> <!-- 使用适合你数据库版本的版本号 -->
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.14</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<!--Test-->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.10.7</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.10.7</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.10.7</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
<!-- 操作doc -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<!--<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
</dependency>-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
@ -76,24 +149,22 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>com.corundumstudio.socketio</groupId>
<artifactId>netty-socketio</artifactId>
<version>1.7.18</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- <plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<port>8080</port>
</configuration>
</plugin>-->
</plugins>
</build>
</project>

View File

@ -1,17 +1,20 @@
package edu.zrh.healthsystem;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
/**
* @author han
*/
@EnableJpaRepositories
@SpringBootApplication
public class HealthSystemApplication {
public static void main(String[] args) {
SpringApplication.run(HealthSystemApplication.class, args);
}
}

View File

@ -0,0 +1,71 @@
package edu.zrh.healthsystem.config;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import java.io.IOException;
// JwtAuthenticationFilter 类是用于处理 JWT 认证的过滤器
@Component
public class JwtAuthenticationFilter extends OncePerRequestFilter {
@Value("${jwt.secret-key}")
private String SECRET_KEY;
// doFilterInternal 方法实现了 JWT 认证逻辑
@Override
protected void doFilterInternal(HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
if ("OPTIONS".equals(request.getMethod())) {
filterChain.doFilter(request, response);
return;
}
// 仅对非登录和注册请求进行过滤
String uri = request.getRequestURI();
if (uri.contains("/medical")||uri.contains("/login") || uri.contains("/register")||uri.contains("/socket.io")||uri.contains("/ws")||uri.contains("/user")) {
filterChain.doFilter(request, response);
return; // 如果是登录或注册接口直接通过不做 token 验证
}
// 获取 Authorization
String authorizationHeader = request.getHeader("Authorization");
if (authorizationHeader == null || !authorizationHeader.startsWith("Bearer ")) {
response.setStatus(403);
response.getWriter().write("未登录");
return;
}
// 提取 Token
String token = authorizationHeader.replace("Bearer ", "");
try {
// 验证 Token
Claims claims = Jwts.parser()
.setSigningKey(SECRET_KEY)
.parseClaimsJws(token)
.getBody();
// 可以将解析出的用户信息存入 Request 对象供后续的 Controller 使用
request.setAttribute("user", claims.getSubject());
// 显示Request对象中的用户信息
System.out.println("Request中的用户信息" + request.getAttribute("user"));
} catch (Exception e) {
response.setStatus(403);
response.getWriter().write("Unauthorized: Invalid token");
return;
}
filterChain.doFilter(request, response);
// Token 验证通过继续后续请求处理
}
}

View File

@ -2,21 +2,21 @@ package edu.zrh.healthsystem.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* @author han
*/
@Configuration
public class WebConfig {
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}

View File

@ -0,0 +1,18 @@
package edu.zrh.healthsystem.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebLoginConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000")
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.allowCredentials(true);
}
}

View File

@ -1,18 +0,0 @@
package edu.zrh.healthsystem.controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author han
*/
@CrossOrigin(origins = "*")
@RestController
public class HelloController {
@GetMapping("/hello")
public String home() {
return "Hello, World!";
}
}

View File

@ -0,0 +1,72 @@
package edu.zrh.healthsystem.controller;
import edu.zrh.healthsystem.model.response.LoginResponse;
import edu.zrh.healthsystem.model.Login;
import edu.zrh.healthsystem.service.LoginService;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
@Tag(name = "用户登录")
@RestController
@RequestMapping(value = "/user")
public class LoginController {
@Resource
private LoginService userService;
@Value("${jwt.secret-key}")
private String SECRET_KEY;
/**
* 用户登录接口
*
* @param login 用户信息
* @return Result
*/
@PostMapping(value = "/login")
@ResponseBody
public LoginResponse login(@RequestBody Login login) {
return userService.login(login);
}
/**
* 生成 JWT Token
*
* @param id 用户名
* @return JWT Token
*/
private String generateToken(int id) {
return Jwts.builder()
.setSubject(String.valueOf(id))
// 将用户名存储到 token
.setIssuedAt(new Date())
// 设置 token 签发时间
.setExpiration(new Date(System.currentTimeMillis() + 3600000))
// 设置过期时间1小时
.signWith(SignatureAlgorithm.HS256, SECRET_KEY)
// 使用 HS256 签名算法并设置密钥
.compact();
}
/**
* 验证 JWT Token
*
* @param token JWT Token
* @return 是否有效
*/
private boolean validateToken(String token) {
try {
Jwts.parser()
.setSigningKey(SECRET_KEY)
.parseClaimsJws(token);
return true;
} catch (Exception e) {
return false;
}
}
}

View File

@ -0,0 +1,56 @@
package edu.zrh.healthsystem.controller;
import edu.zrh.healthsystem.entity.MedicalRecordInfo;
import edu.zrh.healthsystem.service.MedicalRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/medical-records")
public class MedicalRecordController {
@Autowired
private MedicalRecordService medicalRecordService;
@PostMapping
public ResponseEntity<MedicalRecordInfo> createMedicalRecord(@RequestBody MedicalRecordInfo medicalRecordInfo) {
MedicalRecordInfo savedRecord = medicalRecordService.createMedicalRecord(medicalRecordInfo);
return ResponseEntity.ok(savedRecord);
}
@GetMapping
public ResponseEntity<List<MedicalRecordInfo>> getMedicalRecords(
@RequestParam(required = false) String patientName) {
List<MedicalRecordInfo> records = patientName != null && !patientName.isEmpty()
? medicalRecordService.getMedicalRecordsByPatientName(patientName)
: medicalRecordService.getAllMedicalRecords();
return ResponseEntity.ok(records);
}
@GetMapping("/{id}")
public ResponseEntity<MedicalRecordInfo> getMedicalRecord(@PathVariable Long id) {
return medicalRecordService.getMedicalRecordById(id)
.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}
@PutMapping("/{id}")
public ResponseEntity<MedicalRecordInfo> updateMedicalRecord(
@PathVariable Long id,
@RequestBody MedicalRecordInfo medicalRecordInfo) {
MedicalRecordInfo updatedRecord = medicalRecordService.updateMedicalRecord(id, medicalRecordInfo);
return updatedRecord != null
? ResponseEntity.ok(updatedRecord)
: ResponseEntity.notFound().build();
}
@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteMedicalRecord(@PathVariable Long id) {
medicalRecordService.deleteMedicalRecord(id);
return ResponseEntity.ok().build();
}
}

View File

@ -0,0 +1,80 @@
package edu.zrh.healthsystem.controller;
import edu.zrh.healthsystem.model.OcrData;
import edu.zrh.healthsystem.service.OcrDataService;
import edu.zrh.healthsystem.entity.MedicalRecordInfo;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api")
public class PatientController {
@Autowired
private OcrDataService ocrDataService;
@PostMapping("/patientsocr")
public ResponseEntity<String> receivePatientData(@RequestBody PatientData patientData) {
try {
// 创建 OcrData 对象并保存到数据库
OcrData ocrData = new OcrData();
ocrData.setPatientName(patientData.getPatient_name());
ocrData.setAge(patientData.getAge());
ocrData.setGender(patientData.getGender());
ocrData.setDiagnosis(patientData.getDiagnosis());
ocrData.setTreatment(patientData.getTreatment());
ocrDataService.saveOcrData(ocrData);
// 创建 MedicalRecordInfo 对象并保存到 medical_records
MedicalRecordInfo medicalRecordInfo = getMedicalRecordInfo(patientData);
ocrDataService.saveMedicalRecordInfo(medicalRecordInfo);
// 调用新方法
return ResponseEntity.ok("数据接收成功");
} catch (Exception e) {
e.printStackTrace();
// 打印异常堆栈
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("数据处理失败: " + e.getMessage());
}
}
private static MedicalRecordInfo getMedicalRecordInfo(PatientData patientData) {
MedicalRecordInfo medicalRecordInfo = new MedicalRecordInfo();
medicalRecordInfo.setPatientName(patientData.getPatient_name());
medicalRecordInfo.setAge(Integer.parseInt(patientData.getAge()));
// 确保类型匹配
medicalRecordInfo.setGender(patientData.getGender());
medicalRecordInfo.setDiagnosis(patientData.getDiagnosis());
medicalRecordInfo.setTreatment(patientData.getTreatment());
return medicalRecordInfo;
}
// 定义一个内部类或单独的类来表示患者数据
@Data
public static class PatientData {
// 添加 getter setter 方法
private String patient_name;
private String age;
private String gender;
private String diagnosis;
private String treatment;
@Override
public String toString() {
return "PatientData{" +
"patient_name='" + patient_name + '\'' +
", age='" + age + '\'' +
", gender='" + gender + '\'' +
", diagnosis='" + diagnosis + '\'' +
", treatment='" + treatment + '\'' +
'}';
}
}
}

View File

@ -1,76 +0,0 @@
package edu.zrh.healthsystem.controller;
import edu.zrh.healthsystem.model.Elderly;
import edu.zrh.healthsystem.model.elderly.RegularCheckupInfoResponse;
import edu.zrh.healthsystem.service.RegularCheckupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/regularcheckup")
public class RegularCheckupController {
private final RegularCheckupService regularCheckupService;
@Autowired
public RegularCheckupController(RegularCheckupService regularCheckupService) {
this.regularCheckupService = regularCheckupService;
}
@PostMapping("/add")
public Map<String, Object> add(@RequestBody Elderly elderly) {
RegularCheckupInfoResponse result = regularCheckupService.add(elderly);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
@PostMapping("/delete")
public Map<String, Object> delete(@RequestBody Elderly elderly) {
RegularCheckupInfoResponse result = regularCheckupService.delete(elderly);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
@PostMapping("/update")
public Map<String, Object> update(@RequestBody Elderly elderly) {
RegularCheckupInfoResponse result = regularCheckupService.update(elderly);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
@PostMapping("/get")
public Map<String, Object> get(@RequestBody Elderly elderly) {
RegularCheckupInfoResponse result = regularCheckupService.get(elderly);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
@GetMapping("/getall")
public Map<String, Object> getAll() {
RegularCheckupInfoResponse result = regularCheckupService.getAll();
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
}

View File

@ -0,0 +1,27 @@
package edu.zrh.healthsystem.controller;
import edu.zrh.healthsystem.service.ReportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
@RestController
@RequestMapping("/user")
@Tag(name = "导入、导出报表")
public class ReportController {
@Resource
private ReportService reportService;
@GetMapping("/export")
@Operation(summary = "导出用户数据报表")
public void export(HttpServletResponse response) throws IOException {
reportService.exportBusinessData(response);
}
}

View File

@ -1,17 +1,21 @@
package edu.zrh.healthsystem.controller;
import edu.zrh.healthsystem.entity.TalkInfo;
import edu.zrh.healthsystem.model.Talk;
import edu.zrh.healthsystem.model.TalkResponse;
import edu.zrh.healthsystem.model.response.TalkResponse;
import edu.zrh.healthsystem.service.TalkService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @author han
*
* TalkController类用于处理与对话相关的HTTP请求
*/
@CrossOrigin(origins = "*")
@RestController
public class TalkController {
private final TalkService talkService;
@ -21,14 +25,26 @@ public class TalkController {
this.talkService = talkService;
}
/**
* 测试API调用的GET请求
*
* @return 调用外部API的返回结果
*/
@GetMapping("/talk/test")
public String callApi() {
return talkService.callApi("http://10.10.10.44:11434/");
}
/**
* 处理聊天的POST请求
*
* @param talk 包含对话信息的Talk对象
* @param httpServletRequest HTTP请求对象
* @return 携带处理结果的Map对象
*/
@PostMapping("/talk/main")
public Map<String, Object> callApiChat(@RequestBody Talk talk) {
TalkResponse result = talkService.callApiChat(talk);
public Map<String, Object> callApiChat(@RequestBody Talk talk, HttpServletRequest httpServletRequest) {
TalkResponse result = talkService.callApiChat(talk,httpServletRequest);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
@ -36,4 +52,25 @@ public class TalkController {
return Map.of("status", "fail", "message", "登录失败");
}
}
/**
* 获取所有对话记录的GET请求
*
* @return 所有对话信息的List
*/
@GetMapping("/talk/record/all")
public List<TalkInfo> getHistory() {
return talkService.getAllRecord();
}
/**
* 获取单个用户对话记录的GET请求
*
* @param httpServletRequest HTTP请求对象
* @return 单个用户的对话信息的List
*/
@GetMapping("/talk/record/one")
public List<TalkInfo> getOneRecord(HttpServletRequest httpServletRequest) {
return talkService.getRecordByUsername(httpServletRequest);
}
}

View File

@ -0,0 +1,48 @@
package edu.zrh.healthsystem.controller;
import edu.zrh.healthsystem.entity.Template; // 假设你有一个Template实体类
import edu.zrh.healthsystem.service.TemplateService; // 假设你有一个TemplateService类
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
// 控制器类用于处理与Template相关的HTTP请求
@RestController
@RequestMapping("/api/templates")
public class TemplateController {
@Autowired
private TemplateService templateService;
// 创建新的Template
@PostMapping
public ResponseEntity<Template> createTemplate(@RequestBody Template template) {
Template savedTemplate = templateService.createTemplate(template);
return ResponseEntity.ok(savedTemplate);
}
// 获取所有Template支持根据模板名称和部门进行过滤
@GetMapping
public ResponseEntity<List<Template>> getAllTemplates(@RequestParam(required = false) String templateName,
@RequestParam(required = false) String department) {
List<Template> templates = templateService.getAllTemplates(templateName, department);
return ResponseEntity.ok(templates);
}
// 更新指定ID的Template
@PutMapping("/{id}")
public ResponseEntity<Template> updateTemplate(@PathVariable Long id, @RequestBody Template template) {
Template updatedTemplate = templateService.updateTemplate(id, template);
return ResponseEntity.ok(updatedTemplate);
}
// 删除指定ID的Template
@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteTemplate(@PathVariable Long id) {
templateService.deleteTemplate(id);
return ResponseEntity.noContent().build();
}
}

View File

@ -0,0 +1,109 @@
package edu.zrh.healthsystem.controller;
import edu.zrh.healthsystem.entity.RegularCheckupInfo;
import edu.zrh.healthsystem.model.PageBean;
import edu.zrh.healthsystem.model.response.ResultResponse;
import edu.zrh.healthsystem.model.User;
import edu.zrh.healthsystem.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
@RestController
@RequestMapping("/user")
@Tag(name = "用户增删改查")
public class UserController {
@Resource
private UserService userService;
// 新增用户
@PostMapping("/add")
@Operation(summary = "新增用户")
public ResultResponse add(@RequestBody User user) {
userService.add(user);
return ResultResponse.success();
}
// 修改用户
@PutMapping("/update")
@Operation(summary = "修改用户")
public ResultResponse update(@RequestBody User user) {
userService.update(user);
return ResultResponse.success();
}
// 根据id删除用户
@DeleteMapping("deleteById/{id}")
@Operation(summary = "根据id删除用户")
public ResultResponse deleteById(@PathVariable("id") Long id) {
userService.delete(id);
return ResultResponse.success();
}
// 批量删除
@DeleteMapping("deleteByIds/{ids}")
@Operation(summary = "批量删除")
public ResultResponse deleteByIds(@PathVariable List<Integer> ids) {
userService.delete(ids);
return ResultResponse.success();
}
// 根据id查询用户
@GetMapping("/{id}")
@Operation(summary = "根据id查询用户")
public ResultResponse<User> findById(@PathVariable Long id) {
return ResultResponse.success(userService.findById(id));
}
//
@GetMapping("/{id}/treatment")
@Operation(summary = "根据用户ID查询病历中的治疗详情")
public ResultResponse<User> findtreatById(@PathVariable Long id) {
return ResultResponse.success(userService.findtreatById(id));
}
@GetMapping("/{id}/record")
@Operation(summary = "根据用户ID查询病历中的记录详情")
public ResultResponse<RegularCheckupInfo> findrecordById(@PathVariable Long id) {
return ResultResponse.success(userService.findRegularCheckupById(id));
}
// 查询所有用户
@GetMapping("/getAll")
@Operation(summary = "查询所有用户")
public ResultResponse<List<User>> findAll() {
return ResultResponse.success(userService.findAll());
}
// 原生的分页查询
@GetMapping("/page01")
@Operation(summary = "分页查询")
public ResultResponse page01(@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "5") Integer pageSize) {
//调用业务层分页查询功能
PageBean pageBean = userService.page01(page, pageSize);
//响应
ResultResponse<PageBean> resultResponse = ResultResponse.success(pageBean);
return resultResponse;
}
// 使用pagehelper进行条件分页查询
@GetMapping("/page02")
@Operation(summary = "条件分页查询")
public ResultResponse page02(@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "5") Integer pageSize,
Long id, String name, Integer age, String status, String sex, String address, String phone,
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime createTime,
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime updateTime) {
//调用业务层分页查询功能
PageBean pageBean = userService.page02(page, pageSize, id, name, age, status, sex, address, phone, createTime, updateTime);
//响应
ResultResponse<PageBean> resultResponse = ResultResponse.success(pageBean);
return resultResponse;
}
}

View File

@ -1,35 +0,0 @@
package edu.zrh.healthsystem.controller.elderly;
import edu.zrh.healthsystem.service.elderly.ElderMainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* @author han
*/
@CrossOrigin(origins = "*")
@RestController
public class ElderMainController {
private ElderMainService elderMainService;
@Autowired
public ElderMainController(ElderMainService elderMainService) {
this.elderMainService = elderMainService;
}
@GetMapping("/elderly/main")
public Map elderMain() {
List result = elderMainService.elderMain();
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "登录失败");
}
}
}

View File

@ -1,36 +0,0 @@
package edu.zrh.healthsystem.controller.elderly;
import edu.zrh.healthsystem.model.elderly.ElderlyConnect;
import edu.zrh.healthsystem.model.elderly.ElderlyConnectResponse;
import edu.zrh.healthsystem.service.elderly.ElderlyConnectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @author han
*/
@CrossOrigin(origins = "*")
@RestController
public class ElderlyConnectController {
private final ElderlyConnectService elderlyConnectService;
@Autowired
public ElderlyConnectController(ElderlyConnectService elderlyConnectService) {
this.elderlyConnectService = elderlyConnectService;
}
@PostMapping("/elderly/Connect")
public Map<String,Object> elderlyConnect(@RequestBody ElderlyConnect elderlyConnect){
ElderlyConnectResponse result= elderlyConnectService.getElderlyConnectResponse(elderlyConnect);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "创建失败");
}
}
}

View File

@ -1,33 +0,0 @@
package edu.zrh.healthsystem.controller.elderly;
import edu.zrh.healthsystem.model.elderly.ElderlyNew;
import edu.zrh.healthsystem.model.elderly.ElderlyNewResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import edu.zrh.healthsystem.service.elderly.ElderlyNewService;
import java.util.Map;
@CrossOrigin(origins = "*")
@RestController
public class ElderlyNewController {
private final ElderlyNewService elderlyNewService;
@Autowired
public ElderlyNewController(ElderlyNewService elderlyNewService) {
this.elderlyNewService = elderlyNewService;
}
@PostMapping("/elderly/new")
public Map<String,Object> elderlyNew(@RequestBody ElderlyNew elderlyNew){
ElderlyNewResponse result= elderlyNewService.elderly(elderlyNew);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "创建失败");
}
}
}

View File

@ -1,34 +0,0 @@
package edu.zrh.healthsystem.controller.elderly;
import edu.zrh.healthsystem.model.Elderly;
import edu.zrh.healthsystem.model.elderly.ElderlyShowResponse;
import edu.zrh.healthsystem.service.elderly.ElderlyShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@CrossOrigin(origins = "*")
@RestController
public class ElderlyShowController {
private final ElderlyShowService elderlyShowService;
@Autowired
public ElderlyShowController(ElderlyShowService elderlyShowService) {
this.elderlyShowService = elderlyShowService;
}
@PostMapping("/elderly/show")
public Map<String,Object> elderlyShow(@RequestBody Elderly elderly){
ElderlyShowResponse result= elderlyShowService.getElderlyShow(elderly);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
}

View File

@ -1,38 +0,0 @@
package edu.zrh.healthsystem.controller.user;
import edu.zrh.healthsystem.model.user.UserLogin;
import edu.zrh.healthsystem.model.user.UserLoginResponse;
import edu.zrh.healthsystem.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* @author han
*/
@CrossOrigin(origins = "*")
@RestController
public class LoginController {
private final LoginService loginService;
@Autowired
public LoginController(LoginService loginService) {
this.loginService = loginService;
}
@PostMapping("/login")
public Map<String, Object> login(@RequestBody UserLogin userLogin) {
// 调用登录服务
UserLoginResponse result = loginService.login(userLogin);
// 如果登录成功返回成功信息和用户信息
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "登录失败");
}
}
}

View File

@ -1,35 +0,0 @@
package edu.zrh.healthsystem.controller.user;
import edu.zrh.healthsystem.model.user.UserRegister;
import edu.zrh.healthsystem.model.user.UserRegisterResponse;
import edu.zrh.healthsystem.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @author han
*/
@RestController
public class RegisterController {
private final RegisterService registerService;
@Autowired
public RegisterController(RegisterService registerService) {
this.registerService = registerService;
}
@PostMapping("/register")
public Map<String,Object> register(@RequestBody UserRegister userRegister) {
UserRegisterResponse result = registerService.register(userRegister);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "登录失败");
}
}
}

View File

@ -1,75 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Data;
import java.util.Date;
/**
* @author han
*/
@Data
@Entity
@Table(name = "basic_info")
public class BasicInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "elderly_id")
private int elderlyId;
@Column(name = "full_name")
private String fullName;
@Column(name = "gender")
private String gender;
@Column(name = "date_of_birth")
private Date dateOfBirth;
@Column(name = "ethnicity")
private String ethnicity;
@Column(name = "native_place")
private String nativePlace;
@Column(name = "id_number")
private String idNumber;
@Column(name = "permanent_address")
private String permanentAddress;
@Column(name = "occupation")
private String occupation;
@Column(name = "education_level")
private String educationLevel;
@Column(name = "living_alone")
private String livingAlone;
@Column(name = "marital_status")
private String maritalStatus;
@Column(name = "phone_number")
private String phoneNumber;
@Column(name = "contact_name")
private String contactName;
@Column(name = "contact_relation")
private String contactRelation;
@Column(name = "contact_phone")
private String contactPhone;
@Column(name = "eating_habits")
private String eatingHabits;
@Column(name = "exercise_frequency")
private String exerciseFrequency;
}

View File

@ -1,31 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Data;
import java.sql.Timestamp;
@Entity
@Table(name = "daily_schedule_info")
@Data
public class DailyScheduleInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int checkInId;
@Column(name = "Elderly_id")
private Integer elderlyId;
@Column(name = "Schedule_id")
private Integer scheduleId;
@Column(name = "Check_in_time")
private Timestamp checkInTime;
@Column(name = "Check_out_time")
private Timestamp checkOutTime;
@Column(name = "notes")
private String notes;
}

View File

@ -1,65 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "diseaserecord_info")
public class DiseaseRecordInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "DiseaseID", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "ProfileID", nullable = false)
private MainProfileInfo profileID;
@Lob
@Column(name = "PastMedicalHistory")
private String pastMedicalHistory;
@Lob
@Column(name = "CurrentMedicalHistory")
private String currentMedicalHistory;
@Lob
@Column(name = "FamilyMedicalHistory")
private String familyMedicalHistory;
@Lob
@Column(name = "Allergies")
private String allergies;
@Lob
@Column(name = "Disability")
private String disability;
@Lob
@Column(name = "VaccinationHistory")
private String vaccinationHistory;
@Lob
@Column(name = "ExposureHistory")
private String exposureHistory;
@Lob
@Column(name = "GeneticDiseaseHistory")
private String geneticDiseaseHistory;
@Lob
@Column(name = "TreatmentHistory")
private String treatmentHistory;
@Lob
@Column(name = "NursingHistory")
private String nursingHistory;
@Lob
@Column(name = "FollowUpManagement")
private String followUpManagement;
}

View File

@ -1,27 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "healthbehavior_info")
public class HealthBehaviorInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "BehaviorID", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "ProfileID", nullable = false)
private MainProfileInfo profileID;
@Column(name = "SmokingStatus", nullable = false)
private String smokingStatus;
@Column(name = "DrinkingStatus", nullable = false)
private String drinkingStatus;
}

View File

@ -1,17 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Data;
@Data
@Entity
@Table(name = "mainprofile_info")
public class MainProfileInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int profileId;
@OneToOne
@JoinColumn(name = "elderly_id")
private BasicInfo elderlyId;
}

View File

@ -1,29 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "mentalhealth_info")
public class MentalHealthInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "MentalHealthID", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "Elderly_id", nullable = false)
private MainProfileInfo elderly;
@Lob
@Column(name = "PsychologicalIssues")
private String psychologicalIssues;
@Lob
@Column(name = "FollowUpRecord")
private String followUpRecord;
}

View File

@ -1,37 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "pastmedicalhistoryrecord_info")
public class PastMedicalHistoryrecordInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "PastMedicalHistoryID", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "ProfileID", nullable = false)
private MainProfileInfo profileID;
@Lob
@Column(name = "CurrentMedicalHistory")
private String currentMedicalHistory;
@Lob
@Column(name = "ExposureHistory")
private String exposureHistory;
@Lob
@Column(name = "TreatmentHistory")
private String treatmentHistory;
@Lob
@Column(name = "NursingHistory")
private String nursingHistory;
}

View File

@ -1,67 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.time.LocalDate;
@Getter
@Setter
@Entity
@Table(name = "regularcheckup_info")
public class RegularCheckupInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CheckupID", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "ProfileID", nullable = false)
private MainProfileInfo profileId;
@Column(name = "WeightStatus", nullable = false)
private String weightStatus;
@Column(name = "BloodType", nullable = false)
private String bloodType;
@Lob
@Column(name = "ChronicDiseases")
private String chronicDiseases;
@Column(name = "Height", precision = 5, scale = 2)
private BigDecimal height;
@Column(name = "Weight", precision = 5, scale = 2)
private BigDecimal weight;
@Column(name = "HeartRate")
private Integer heartRate;
@Column(name = "Temperature", precision = 3, scale = 1)
private BigDecimal temperature;
@Column(name = "OxygenSaturation")
private Integer oxygenSaturation;
@Column(name = "BloodPressure", length = 10)
private String bloodPressure;
@Column(name = "GlucoseLevel", precision = 5, scale = 2)
private BigDecimal glucoseLevel;
@Column(name = "Pulse")
private Integer pulse;
@Column(name = "face_image")
private byte[] faceImage;
@Column(name = "tongue_image")
private byte[] tongueImage;
@Column(name = "CheckupDate")
private LocalDate checkupDate;
}

View File

@ -1,29 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import java.time.Instant;
@Getter
@Setter
@Entity
@Table(name = "schedule_info")
public class ScheduleInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "schedule_id", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "elderly_id", nullable = false)
private BasicInfo elderly;
@Column(name = "event_description")
private String eventDescription;
@Column(name = "event_time")
private Instant eventTime;
}

View File

@ -1,31 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.Instant;
@Getter
@Setter
@Entity
@Table(name = "tcm_diagnosis_info")
public class TcmDiagnosisInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "diagnosis_id", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "elderly_id", nullable = false)
private BasicInfo elderly;
@Column(name = "diagnosis", nullable = false)
private String diagnosis;
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "diagnosis_time")
private Instant diagnosisTime;
}

View File

@ -1,36 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.Instant;
@Getter
@Setter
@Entity
@Table(name = "tcm_qa_info")
public class TcmQaInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "qa_id", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "elderly_id", nullable = false)
private BasicInfo elderly;
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "asked_time")
private Instant askedTime;
@Lob
@Column(name = "question", nullable = false)
private String question;
@Lob
@Column(name = "answer", nullable = false)
private String answer;
}

View File

@ -1,29 +0,0 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Data;
/**
* @author han
*/
@Data
@Entity
@Table(name = "user_info")
public class UserInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int userId;
@Column(name = "User_name")
private String userName;
@Column(name = "User_password")
private String userPassword;
@Column(name = "User_elderly")
private Integer userElderly;
@Column(name = "User_email")
private String userEmail;
}

View File

@ -0,0 +1,46 @@
package edu.zrh.healthsystem.entity;
import jakarta.persistence.*;
import lombok.Data;
import java.time.LocalDateTime;
@Entity
@Table(name = "medical_records")
@Data
public class MedicalRecordInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String patientName;
@Column(nullable = false)
private Integer age;
@Column(nullable = false)
private String gender;
@Column(columnDefinition = "TEXT")
private String diagnosis;
@Column(columnDefinition = "TEXT")
private String treatment;
@Column(nullable = false)
private LocalDateTime createTime;
@Column(nullable = false)
private LocalDateTime updateTime;
@PrePersist
protected void onCreate() {
createTime = LocalDateTime.now();
updateTime = LocalDateTime.now();
}
@PreUpdate
protected void onUpdate() {
updateTime = LocalDateTime.now();
}
}

View File

@ -0,0 +1,71 @@
package edu.zrh.healthsystem.entity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
@Entity
@Table(name = "regularcheckup_info")
@Data
public class RegularCheckupInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "checkup_id")
private Long checkupId;
@Size(max = 255)
@NotNull
@Column(name = "weight_status", nullable = false)
private String weightStatus;
@Size(max = 255)
@NotNull
@Column(name = "blood_type", nullable = false)
private String bloodType;
@Lob
@Column(name = "chronic_diseases")
private String chronicDiseases;
@Column(name = "height", precision = 5, scale = 2)
private BigDecimal height;
@Column(name = "weight", precision = 5, scale = 2)
private BigDecimal weight;
@Column(name = "heart_rate")
private Integer heartRate;
@Column(name = "temperature", precision = 3, scale = 1)
private BigDecimal temperature;
@Column(name = "oxygen_saturation")
private Integer oxygenSaturation;
@Size(max = 10)
@Column(name = "blood_pressure", length = 10)
private String bloodPressure;
@Column(name = "glucose_level", precision = 5, scale = 2)
private BigDecimal glucoseLevel;
@Column(name = "pulse")
private Integer pulse;
@Column(name = "face_image")
private byte[] faceImage;
@Column(name = "tongue_image")
private byte[] tongueImage;
@Column(name = "checkup_date")
private LocalDate checkupDate;
}

View File

@ -0,0 +1,32 @@
package edu.zrh.healthsystem.entity;
import jakarta.persistence.*;
import lombok.Data;
@Data
@Entity
@Table(name = "talk_info")
public class TalkInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "talk_id")
private int talkId;
@Column(name = "talk_prompt")
private String talkPrompt;
@Column(name = "talk_response")
private String talkResponse;
@Column(name = "talk_time")
private String talkTime;
@Column(name="talk_user")
private String talkUser;
@ManyToOne
@JoinColumn(name = "talk_user", referencedColumnName = "user_name", insertable = false, updatable = false)
private UserMainInfo userMainInfo;
// 关联到 UserMainInfo
}

View File

@ -0,0 +1,28 @@
package edu.zrh.healthsystem.entity;
import jakarta.persistence.*;
import lombok.Data;
@Entity
@Table(name = "templates")
@Data
public class Template {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String templateName;
@Column(nullable = false)
private String department;
@Column(nullable = false)
private String type;
@Column(columnDefinition = "TEXT")
private String content;
@Column(columnDefinition = "TEXT")
private String remarks;
}

View File

@ -0,0 +1,40 @@
package edu.zrh.healthsystem.entity;
import jakarta.persistence.*;
import lombok.Data;
@Entity
@Data
@Table(name = "user_login")
public class UserLoginInfo {
/**
* ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 账号
*/
@Column(name = "username")
private String username;
/**
* 密码
*/
@Column(name = "pwd")
private String pwd;
/**
* 权限
* 0: 超级管理员
* 1: 医生
*/
@Column(name = "permission")
private String permission;
@ManyToOne
@JoinColumn(name = "id", referencedColumnName = "user_id", insertable = false, updatable = false)
private UserMainInfo userMainInfo;
// 关联到 UserMainInfo
}

View File

@ -0,0 +1,46 @@
package edu.zrh.healthsystem.entity;
import jakarta.persistence.*;
import lombok.Data;
@Entity
@Data
@Table(name = "user_main")
public class UserMainInfo {
/**
* ID
*/
@Id
@Column(name = "user_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 名字
*/
@Column(name = "user_name")
private String username;
/**
* 年龄
*/
@Column(name = "user_age")
private Integer age;
/**
* 性别
*/
@Column(name = "user_gender")
private String gender;
/**
* 邮箱
*/
@Column(name = "user_email")
private String email;
/**
* 权限
*/
@Column(name = "user_permission")
private String permission;
}

View File

@ -0,0 +1,56 @@
package edu.zrh.healthsystem.mapper;
import edu.zrh.healthsystem.entity.RegularCheckupInfo;
import edu.zrh.healthsystem.model.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime;
import java.util.List;
@Mapper
public interface UserMapper {
// 新增
@Insert("insert into user (id,name,age,status,sex,address,phone,create_time,update_Time) values " +
"(#{id},#{name},#{age},#{status},#{sex},#{address},#{phone},#{createTime},#{updateTime})")
void add(User user);
// 修改
void update(User user);
// 删除
@Delete("delete from user where id = #{id} ")
void deleteById(Long id);
void deleteByIds(List<Integer> ids);
@Select("select * from user where id = #{id}")
User findById(Long id);
@Select("select medical_records.treatment FROM user JOIN medical_records ON user.id = medical_records.id WHERE user.id = #{id}")
User findtreatById(Long id);
@Select("select * from user")
List<User> findAll();
//获取总记录数
@Select("select count(*) from user")
Long count();
//原生的分页查询
@Select("select * from user limit #{start}, #{pageSize}")
List<User> page(Integer start, Integer pageSize);
// 使用pagehelper进行条件分页查询
List<User> list(Long id, String name, Integer age, String status, String sex, String address, String phone,
LocalDateTime createTime, LocalDateTime updateTime);
@Select("select regularcheckup_info.* from user JOIN regularcheckup_info ON user.id = regularcheckup_info.id WHERE user.id = #{id}")
RegularCheckupInfo findRegularCheckupById(Long id);
}

View File

@ -1,20 +0,0 @@
package edu.zrh.healthsystem.model;
/**
* @author han
*/
public class Basic {
private int elderlyId;
private String fullName;
private char gender;
private String dateOfBirth;
private String ethnicity;
private String nativePlace;
private String idNumber;
private String permanentAddress;
private String occupation;
private String educationLevel;
private boolean livingAlone;
private String maritalStatus;
private String phoneNumber;
}

View File

@ -1,43 +0,0 @@
package edu.zrh.healthsystem.model;
import edu.zrh.healthsystem.eneity.MainProfileInfo;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
public @Data class Elderly {
private int elderlyId;
private MainProfileInfo profileId;
private String weightStatus;
private String bloodType;
private String chronicDiseases;
private BigDecimal height;
private BigDecimal weight;
private Integer heartRate;
private BigDecimal temperature;
private Integer oxygenSaturation;
private String bloodPressure;
private BigDecimal glucoseLevel;
private Integer pulse;
private byte[] faceImage;
private byte[] tongueImage;
private LocalDate checkupDate;
private String message;
}

View File

@ -0,0 +1,11 @@
package edu.zrh.healthsystem.model;
import lombok.Data;
@Data
public class Login {
private String username;
private String pwd;
}

View File

@ -2,7 +2,8 @@ package edu.zrh.healthsystem.model;
import lombok.Data;
public @Data class Message {
private String role="user";
private String content;
}
private String from;
private String text;
}

View File

@ -0,0 +1,21 @@
package edu.zrh.healthsystem.model;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.Data;
@Data
@Entity
public class OcrData {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String patientName;
private String age;
private String gender;
private String diagnosis;
private String treatment;
}

View File

@ -0,0 +1,32 @@
package edu.zrh.healthsystem.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
/**
* 操作日志实体类
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OperateLog {
private Integer id;
//主键ID
private Integer operateUser;
//操作人ID
private LocalDateTime operateTime;
//操作时间
private String className;
//操作类名
private String methodName;
//操作方法名
private String methodParams;
//操作方法参数
private String returnValue;
//操作方法返回值
private Long costTime;
//操作耗时
}

View File

@ -0,0 +1,18 @@
package edu.zrh.healthsystem.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageBean {
private Long total;
//总记录数
private List rows;
//当前页数据列表
}

View File

@ -6,10 +6,14 @@ import java.util.List;
/**
* @author han
*
* 模型输入参数
*/
public @Data class Talk {
private String model="qwen2";
private List<Message> messages;
//模型名称
private String model="glm4:latest";
//模型输入
private String prompt;
//是否流式输出
private Boolean stream=false;
}

View File

@ -1,21 +0,0 @@
package edu.zrh.healthsystem.model;
import lombok.Data;
import java.util.List;
/**
* @author han
*/
public @Data class TalkResponse {
private String model;
private String created_at;
private String done;
private String total_duration;
private String load_duration;
private String prompt_eval_count;
private String prompt_eval_duration;
private String eval_count;
private String eval_duration;
private List<Message> messages;
}

View File

@ -0,0 +1,25 @@
package edu.zrh.healthsystem.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class User {
private Long id;
private String name;
private Integer age;
private Integer status;
private String sex;
private String address;
private String phone;
private String treatment;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

View File

@ -1,8 +0,0 @@
package edu.zrh.healthsystem.model.elderly;
import lombok.Data;
public @Data class ElderlyConnect {
private int userId;
private int userElderly;
}

View File

@ -1,8 +0,0 @@
package edu.zrh.healthsystem.model.elderly;
import lombok.Data;
public @Data class ElderlyConnectResponse {
private int userId;
private String message;
}

View File

@ -1,32 +0,0 @@
package edu.zrh.healthsystem.model.elderly;
import lombok.Data;
import java.util.Date;
/**
* @author han
*/
public @Data class ElderlyNew {
private String fullName;
private String gender;
private Date dateOfBirth;
private String ethnicity;
private String nativePlace;
private String idNumber;
private String permanentAddress;
private String occupation;
private String educationLevel;
private String livingAlone;
private String maritalStatus;
private String phoneNumber;
private String contactName;
private String contactRelation;
private String contactPhone;
private String eatingHabits;
private String exerciseFrequency;
}

View File

@ -1,8 +0,0 @@
package edu.zrh.healthsystem.model.elderly;
import lombok.Data;
public @Data class ElderlyNewResponse {
private int elderlyId;
private String message;
}

View File

@ -1,27 +0,0 @@
package edu.zrh.healthsystem.model.elderly;
import lombok.Data;
import java.util.Date;
public @Data class ElderlyShowResponse {
private int ElderlyId;
private String fullName;
private String gender;
private Date dateOfBirth;
private String ethnicity;
private String nativePlace;
private String idNumber;
private String permanentAddress;
private String occupation;
private String educationLevel;
private String livingAlone;
private String maritalStatus;
private String phoneNumber;
private String contactName;
private String contactRelation;
private String contactPhone;
private String eatingHabits;
private String exerciseFrequency;
private String message;
}

View File

@ -1,47 +0,0 @@
package edu.zrh.healthsystem.model.elderly;
import edu.zrh.healthsystem.eneity.MainProfileInfo;
import jakarta.persistence.*;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
* @author han
*/
public @Data class RegularCheckupInfoResponse {
private Integer id;
private MainProfileInfo profileId;
private String weightStatus;
private String bloodType;
private String chronicDiseases;
private BigDecimal height;
private BigDecimal weight;
private Integer heartRate;
private BigDecimal temperature;
private Integer oxygenSaturation;
private String bloodPressure;
private BigDecimal glucoseLevel;
private Integer pulse;
private byte[] faceImage;
private byte[] tongueImage;
private LocalDate checkupDate;
private String message;
}

View File

@ -0,0 +1,21 @@
package edu.zrh.healthsystem.model.response;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class LoginResponse {
private String data;
private Integer code;
private String message;
private String username;
private String permission;
private String email;
private Integer age;
private String gender;
public LoginResponse() {
}
}

View File

@ -0,0 +1,34 @@
package edu.zrh.healthsystem.model.response;
import lombok.Data;
import java.io.Serializable;
/**
* 后端统一返回结果
* @param <T>
*/
@Data
public class ResultResponse<T> implements Serializable {
private Integer code;
//编码1成功0和其它数字为失败
private String msg;
//错误信息
private T data;
//数据
public static <T> ResultResponse<T> success() {
ResultResponse<T> resultResponse = new ResultResponse<T>();
resultResponse.code = 1;
return resultResponse;
}
public static <T> ResultResponse<T> success(T object) {
ResultResponse<T> resultResponse = new ResultResponse<T>();
resultResponse.data = object;
resultResponse.code = 1;
return resultResponse;
}
}

View File

@ -0,0 +1,21 @@
package edu.zrh.healthsystem.model.response;
import lombok.Data;
import java.util.Date;
import java.util.List;
public @Data class TalkResponse {
private String model;
private Date createdAt;
private String response;
private boolean done;
private List<Integer> context;
private long totalDuration;
private long loadDuration;
private int promptEvalCount;
private long promptEvalDuration;
private int evalCount;
private long evalDuration;
}

View File

@ -1,10 +0,0 @@
package edu.zrh.healthsystem.model.user;
import lombok.Data;
/**
* @author han
*/
public @Data class UserLogin {
private String userName;
private String userPassword;
}

View File

@ -1,14 +0,0 @@
package edu.zrh.healthsystem.model.user;
import lombok.Data;
/**
* @author han
*/
public @Data class UserLoginResponse {
private boolean userRe;
private int userId;
private String message;
}

View File

@ -1,13 +0,0 @@
package edu.zrh.healthsystem.model.user;
import lombok.Data;
/**
* @author han
*/
public @Data class UserRegister {
private String userName;
private String userPassword;
private String userEmail;
}

View File

@ -1,10 +0,0 @@
package edu.zrh.healthsystem.model.user;
import lombok.Data;
public @Data class UserRegisterResponse {
private boolean userRe;
private int userId;
private String message;
}

View File

@ -1,7 +0,0 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.DailyScheduleInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface DailyScheduleRepository extends JpaRepository<DailyScheduleInfo, Integer> {
}

View File

@ -1,7 +0,0 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.DiseaseRecordInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface DiseaseRecordRepository extends JpaRepository<DiseaseRecordInfo, Integer> {
}

View File

@ -1,7 +0,0 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.HealthBehaviorInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface HealthBehaviorInfoRespository extends JpaRepository<HealthBehaviorInfo, Integer> {
}

View File

@ -0,0 +1,17 @@
package edu.zrh.healthsystem.repository;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 自定义Log注解
* @author han
*/
@Target(ElementType.METHOD)
// 标识方法
@Retention(RetentionPolicy.RUNTIME)
// 运行时有效
public @interface LogRepository {
}

View File

@ -1,16 +1,11 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.UserInfo;
import edu.zrh.healthsystem.entity.UserLoginInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
/**
* @author han
*/
@Repository
public interface LoginRepository extends JpaRepository<UserInfo, Integer> {
Optional<UserInfo> findByUserName(String username);
public interface LoginRepository extends JpaRepository<UserLoginInfo, Long> {
UserLoginInfo findByUsername(String username);
}

View File

@ -1,8 +0,0 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.MainProfileInfo;
import edu.zrh.healthsystem.eneity.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface MainProfileInfoRepository extends JpaRepository<MainProfileInfo, Integer> {
}

View File

@ -0,0 +1,11 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.entity.MedicalRecordInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface MedicalRecordRepository extends JpaRepository<MedicalRecordInfo, Long> {
List<MedicalRecordInfo> findByPatientNameContaining(String patientName);
}

View File

@ -0,0 +1,7 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.model.OcrData;
import org.springframework.data.jpa.repository.JpaRepository;
public interface OcrDataRepository extends JpaRepository<OcrData, Long> {
}

View File

@ -0,0 +1,7 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.entity.MedicalRecordInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface OcrMedicalRecordInfoRepository extends JpaRepository<MedicalRecordInfo, Long> {
}

View File

@ -1,18 +0,0 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
/**
* @author han
*/
@Repository
public interface RegisterRepository extends JpaRepository<UserInfo, Integer> {
Optional<UserInfo> findByUserName(String username);
Optional<UserInfo> findByUserEmail(String userEmail);
}

View File

@ -1,13 +0,0 @@
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

@ -0,0 +1,12 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.entity.TalkInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface TalkInfoRepository extends JpaRepository<TalkInfo, Integer> {
List<TalkInfo> findAllByTalkUser(String talkUser);
}

View File

@ -0,0 +1,11 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.entity.Template;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface TemplateRepository extends JpaRepository<Template, Long> {
List<Template> findByTemplateNameContaining(String templateName);
List<Template> findByDepartment(String department);
}

View File

@ -0,0 +1,7 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.entity.UserMainInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserMainInfoRepository extends JpaRepository<UserMainInfo, Integer> {
}

View File

@ -1,7 +0,0 @@
package edu.zrh.healthsystem.repository.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ElderMainRepository extends JpaRepository<BasicInfo, Integer> {
}

View File

@ -1,13 +0,0 @@
package edu.zrh.healthsystem.repository.elderly;
import edu.zrh.healthsystem.eneity.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface ElderlyConnectRepository extends JpaRepository<UserInfo, Integer> {
Optional<UserInfo> findByUserId(int userId);
Optional<UserInfo> findByUserElderly(int userElderly);
}

View File

@ -1,11 +0,0 @@
package edu.zrh.healthsystem.repository.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface ElderlyNewRepository extends JpaRepository<BasicInfo, Integer> {
Optional<BasicInfo> findByFullName(String fullName);
}

View File

@ -1,10 +0,0 @@
package edu.zrh.healthsystem.repository.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
public interface ElderlyShowRepository extends JpaRepository<BasicInfo, Integer> {
Optional<BasicInfo> findByElderlyId(int elderlyId);
}

View File

@ -1,57 +1,76 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.eneity.UserInfo;
import edu.zrh.healthsystem.model.user.UserLogin;
import edu.zrh.healthsystem.model.user.UserLoginResponse;
import edu.zrh.healthsystem.entity.UserLoginInfo;
import edu.zrh.healthsystem.entity.UserMainInfo;
import edu.zrh.healthsystem.model.response.LoginResponse;
import edu.zrh.healthsystem.model.Login;
import edu.zrh.healthsystem.repository.LoginRepository;
import jakarta.annotation.Resource;
import edu.zrh.healthsystem.repository.UserMainInfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* @author han
*/
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
@Service
public class LoginService {
private final LoginRepository loginRepository;
@Resource
private BCryptPasswordEncoder passwordEncoder;
@Autowired
public LoginService( LoginRepository loginRepository){
private LoginRepository loginRepository;
private final UserMainInfoRepository userMainInfoRepository;
public LoginService(LoginRepository loginRepository, UserMainInfoRepository userMainInfoRepository) {
this.loginRepository = loginRepository;
this.userMainInfoRepository = userMainInfoRepository;
}
private Login login;
/**
* 用户登录逻辑
* @param login 用户登录信息
* @return LoginResult 登录结果
*/
public LoginResponse login(Login login) {
LoginResponse result = new LoginResponse();
UserLoginInfo storedUser = loginRepository.findByUsername(login.getUsername());
String userId = String.valueOf(storedUser.getId());
UserMainInfo userMainInfo = userMainInfoRepository.findById(Integer.parseInt(userId)).orElse(null);
if (storedUser.getPwd().equals(login.getPwd())) {
public UserLoginResponse login(UserLogin userLogin) {
Optional<UserInfo> optionalUserInfo = loginRepository.findByUserName(userLogin.getUserName());
UserLoginResponse userLoginResponse = new UserLoginResponse();
if (optionalUserInfo.isPresent()) {
UserInfo userInfo = optionalUserInfo.get();
// 检查提供的密码是否与数据库中存储的密码匹配
if (passwordEncoder.matches(userLogin.getUserPassword(), userInfo.getUserPassword())) {
// 如果密码正确返回userLogin对象
userLoginResponse.setUserId(userInfo.getUserId());
userLoginResponse.setUserRe(true);
userLoginResponse.setMessage("登录成功");
} else {
// 如果密码不正确抛出异常或返回null
userLoginResponse.setUserId(-1);
userLoginResponse.setUserRe(true);
userLoginResponse.setMessage("密码错误");
// 密码正确生成 JWT Token
String token = generateToken(storedUser.getId());
// 假设 ID UserLogin 的字段
if (userMainInfo != null) {
result.setUsername(userMainInfo.getUsername());
result.setPermission(userMainInfo.getPermission());
result.setAge(userMainInfo.getAge());
result.setGender(userMainInfo.getGender());
result.setEmail(userMainInfo.getEmail());
}
result.setCode(200);
result.setMessage("登录成功");
result.setData(token);
// 返回生成的 JWT Token
} else {
// 如果找不到用户抛出异常或返回null
userLoginResponse.setUserId(-2);
userLoginResponse.setUserRe(true);
userLoginResponse.setMessage("未注册用户");
result.setCode(400);
result.setMessage("用户名或密码错误");
}
return userLoginResponse;
return result;
}
/**
* 生成 JWT Token
*/
@Value("${jwt.secret-key}")
private String SECRET_KEY;
private String generateToken(int id) {
return Jwts.builder()
.setSubject(String.valueOf(id))
.setIssuedAt(new java.util.Date())
// 设置签发时间
.setExpiration(new java.util.Date(System.currentTimeMillis() + 3600000))
// 设置过期时间1小时
.signWith(SignatureAlgorithm.HS256, SECRET_KEY)
// 使用 HS256 算法并设置密钥
.compact();
}
}

View File

@ -0,0 +1,43 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.entity.MedicalRecordInfo;
import edu.zrh.healthsystem.repository.MedicalRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class MedicalRecordService {
@Autowired
private MedicalRecordRepository medicalRecordRepository;
public MedicalRecordInfo createMedicalRecord(MedicalRecordInfo medicalRecordInfo) {
return medicalRecordRepository.save(medicalRecordInfo);
}
public List<MedicalRecordInfo> getAllMedicalRecords() {
return medicalRecordRepository.findAll();
}
public Optional<MedicalRecordInfo> getMedicalRecordById(Long id) {
return medicalRecordRepository.findById(id);
}
public List<MedicalRecordInfo> getMedicalRecordsByPatientName(String patientName) {
return medicalRecordRepository.findByPatientNameContaining(patientName);
}
public MedicalRecordInfo updateMedicalRecord(Long id, MedicalRecordInfo medicalRecordInfo) {
if (medicalRecordRepository.existsById(id)) {
medicalRecordInfo.setId(id);
return medicalRecordRepository.save(medicalRecordInfo);
}
return null;
}
public void deleteMedicalRecord(Long id) {
medicalRecordRepository.deleteById(id);
}
}

View File

@ -0,0 +1,25 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.model.OcrData;
import edu.zrh.healthsystem.entity.MedicalRecordInfo;
import edu.zrh.healthsystem.repository.OcrDataRepository;
import edu.zrh.healthsystem.repository.OcrMedicalRecordInfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class OcrDataService {
@Autowired
private OcrDataRepository ocrDataRepository;
@Autowired
private OcrMedicalRecordInfoRepository medicalRecordInfoRepository;
public OcrData saveOcrData(OcrData ocrData) {
return ocrDataRepository.save(ocrData);
}
public MedicalRecordInfo saveMedicalRecordInfo(MedicalRecordInfo medicalRecordInfo) {
return medicalRecordInfoRepository.save(medicalRecordInfo);
}
}

View File

@ -1,55 +0,0 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.eneity.UserInfo;
import edu.zrh.healthsystem.model.user.UserRegister;
import edu.zrh.healthsystem.model.user.UserRegisterResponse;
import edu.zrh.healthsystem.repository.RegisterRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* @author han
*/
@Service
public class RegisterService {
private final RegisterRepository registerRepository;
// 密码加密
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
@Autowired
public RegisterService(RegisterRepository registerRepository) {
this.registerRepository = registerRepository;
}
public UserRegisterResponse register(UserRegister userRegister) {
// 检查用户名和电子邮件是否已存在
Optional<UserInfo> optionalName = registerRepository.findByUserName(userRegister.getUserName());
Optional<UserInfo> optionalEmail = registerRepository.findByUserEmail(userRegister.getUserEmail());
UserRegisterResponse userRegisterResponse = new UserRegisterResponse();
if (optionalName.isPresent()) {
userRegisterResponse.setMessage("已经存在账户名");
}
else
{
if (optionalEmail.isPresent()) {
userRegisterResponse.setMessage("已经存在电子邮件");
}
else
{
UserInfo user = new UserInfo();
user.setUserName(userRegister.getUserName());
user.setUserEmail(userRegister.getUserEmail());
user.setUserPassword(passwordEncoder.encode(userRegister.getUserPassword()));
registerRepository.save(user);
userRegisterResponse.setUserId(user.getUserId());
userRegisterResponse.setMessage("注册成功");
}
}
return userRegisterResponse;
}
}

View File

@ -1,134 +0,0 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.eneity.RegularCheckupInfo;
import edu.zrh.healthsystem.model.Elderly;
import edu.zrh.healthsystem.model.elderly.RegularCheckupInfoResponse;
import edu.zrh.healthsystem.repository.RegularCheckupRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
public class RegularCheckupService {
private final RegularCheckupRepository regularCheckupRespository;
@Autowired
public RegularCheckupService(RegularCheckupRepository regularCheckupRespository) {
this.regularCheckupRespository = regularCheckupRespository;
}
RegularCheckupInfoResponse regularCheckupInfoResponse = new RegularCheckupInfoResponse();
public RegularCheckupInfoResponse add(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId());
if (optionalElderly.isPresent()) {
regularCheckupInfoResponse.setMessage("已经有表");
} else {
RegularCheckupInfo regularCheckupInfo = new RegularCheckupInfo();
regularCheckupInfo.setBloodType(elderly.getBloodType());
regularCheckupInfo.setId(elderly.getElderlyId());
regularCheckupInfo.setCheckupDate(elderly.getCheckupDate());
regularCheckupInfo.setBloodPressure(elderly.getBloodPressure());
regularCheckupInfo.setFaceImage(elderly.getFaceImage());
regularCheckupInfo.setHeight(elderly.getHeight());
regularCheckupInfo.setGlucoseLevel(elderly.getGlucoseLevel());
regularCheckupInfo.setPulse(elderly.getPulse());
regularCheckupInfo.setHeartRate(elderly.getHeartRate());
regularCheckupInfo.setChronicDiseases(elderly.getChronicDiseases());
regularCheckupInfo.setTemperature(elderly.getTemperature());
regularCheckupInfo.setWeight(elderly.getWeight());
regularCheckupInfo.setTongueImage(elderly.getTongueImage());
regularCheckupInfo.setWeightStatus(elderly.getWeightStatus());
regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation());
regularCheckupRespository.save(regularCheckupInfo);
regularCheckupInfoResponse.setMessage("添加成功");
}
return regularCheckupInfoResponse;
}
public RegularCheckupInfoResponse delete(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId());
if (optionalElderly.isPresent()) {
RegularCheckupInfo regularCheckupInfo = optionalElderly.get();
regularCheckupInfo.setBloodType(elderly.getBloodType());
regularCheckupInfo.setId(elderly.getElderlyId());
regularCheckupInfo.setCheckupDate(elderly.getCheckupDate());
regularCheckupInfo.setBloodPressure(elderly.getBloodPressure());
regularCheckupInfo.setFaceImage(elderly.getFaceImage());
regularCheckupInfo.setHeight(elderly.getHeight());
regularCheckupInfo.setGlucoseLevel(elderly.getGlucoseLevel());
regularCheckupInfo.setPulse(elderly.getPulse());
regularCheckupInfo.setHeartRate(elderly.getHeartRate());
regularCheckupInfo.setChronicDiseases(elderly.getChronicDiseases());
regularCheckupInfo.setTemperature(elderly.getTemperature());
regularCheckupInfo.setWeight(elderly.getWeight());
regularCheckupInfo.setTongueImage(elderly.getTongueImage());
regularCheckupInfo.setWeightStatus(elderly.getWeightStatus());
regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation());
regularCheckupRespository.save(regularCheckupInfo);
regularCheckupInfoResponse.setMessage("删除成功");
} else {
regularCheckupInfoResponse.setMessage("没有该表");
}
return regularCheckupInfoResponse;
}
public RegularCheckupInfoResponse update(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId());
if (optionalElderly.isPresent()) {
RegularCheckupInfo regularCheckupInfo = optionalElderly.get();
regularCheckupInfo.setBloodType(elderly.getBloodType());
regularCheckupInfo.setId(elderly.getElderlyId());
regularCheckupInfo.setCheckupDate(elderly.getCheckupDate());
regularCheckupInfo.setBloodPressure(elderly.getBloodPressure());
regularCheckupInfo.setFaceImage(elderly.getFaceImage());
regularCheckupInfo.setHeight(elderly.getHeight());
regularCheckupInfo.setGlucoseLevel(elderly.getGlucoseLevel());
regularCheckupInfo.setPulse(elderly.getPulse());
regularCheckupInfo.setHeartRate(elderly.getHeartRate());
regularCheckupInfo.setChronicDiseases(elderly.getChronicDiseases());
regularCheckupInfo.setTemperature(elderly.getTemperature());
regularCheckupInfo.setWeight(elderly.getWeight());
regularCheckupInfo.setTongueImage(elderly.getTongueImage());
regularCheckupInfo.setWeightStatus(elderly.getWeightStatus());
regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation());
regularCheckupRespository.save(regularCheckupInfo);
regularCheckupInfoResponse.setMessage("更新成功");
} else {
regularCheckupInfoResponse.setMessage("没有该表");
}
return regularCheckupInfoResponse;
}
public RegularCheckupInfoResponse get(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupRespository.findById(elderly.getElderlyId());
if (optionalElderly.isPresent()) {
regularCheckupInfoResponse.setBloodType(elderly.getBloodType());
regularCheckupInfoResponse.setId(elderly.getElderlyId());
regularCheckupInfoResponse.setCheckupDate(elderly.getCheckupDate());
regularCheckupInfoResponse.setBloodPressure(elderly.getBloodPressure());
regularCheckupInfoResponse.setFaceImage(elderly.getFaceImage());
regularCheckupInfoResponse.setHeight(elderly.getHeight());
regularCheckupInfoResponse.setGlucoseLevel(elderly.getGlucoseLevel());
regularCheckupInfoResponse.setPulse(elderly.getPulse());
regularCheckupInfoResponse.setHeartRate(elderly.getHeartRate());
regularCheckupInfoResponse.setChronicDiseases(elderly.getChronicDiseases());
regularCheckupInfoResponse.setTemperature(elderly.getTemperature());
regularCheckupInfoResponse.setWeight(elderly.getWeight());
regularCheckupInfoResponse.setProfileId(elderly.getProfileId());
regularCheckupInfoResponse.setTongueImage(elderly.getTongueImage());
regularCheckupInfoResponse.setWeightStatus(elderly.getWeightStatus());
regularCheckupInfoResponse.setOxygenSaturation(elderly.getOxygenSaturation());
regularCheckupInfoResponse.setMessage("查找成功");
} else {
regularCheckupInfoResponse.setMessage("没有该表");
}
return regularCheckupInfoResponse;
}
public RegularCheckupInfoResponse getAll() {
//待实现
regularCheckupInfoResponse.setMessage("查找全部成功");
return regularCheckupInfoResponse;
}
}

View File

@ -0,0 +1,10 @@
package edu.zrh.healthsystem.service;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
public interface ReportService {
void exportBusinessData(HttpServletResponse response) throws IOException;
}

View File

@ -1,28 +1,66 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.entity.TalkInfo;
import edu.zrh.healthsystem.entity.UserMainInfo;
import edu.zrh.healthsystem.model.Talk;
import edu.zrh.healthsystem.model.TalkResponse;
import edu.zrh.healthsystem.model.response.TalkResponse;
import edu.zrh.healthsystem.repository.TalkInfoRepository;
import edu.zrh.healthsystem.repository.UserMainInfoRepository;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.Map;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
* @author han
*/
@Service
public class TalkService {
private final RestTemplate restTemplate;
public TalkService(RestTemplate restTemplate) {
private final TalkInfoRepository talkInfoRepository;
private final UserMainInfoRepository userMainInfoRepository;
public TalkService(RestTemplate restTemplate, TalkInfoRepository talkInfoRepository, UserMainInfoRepository userMainInfoRepository) {
this.restTemplate = restTemplate;
this.talkInfoRepository = talkInfoRepository;
this.userMainInfoRepository = userMainInfoRepository;
}
public String callApi(String url) {
return restTemplate.getForObject(url, String.class);
}
public TalkResponse callApiChat(Talk request) {
return restTemplate.postForObject("http://10.10.10.44:11434/api/chat", request, TalkResponse.class);
public TalkResponse callApiChat(Talk request, HttpServletRequest httpServletRequest) {
TalkResponse response = restTemplate.postForObject("http://10.10.10.44:11434/api/generate", request, TalkResponse.class);
String userId = (String) httpServletRequest.getAttribute("user");
UserMainInfo userMainInfo = userMainInfoRepository.findById(Integer.parseInt(userId)).orElse(null);
if (userMainInfo != null) {
TalkInfo talkInfo = new TalkInfo();
talkInfo.setTalkPrompt(request.getPrompt());
if (response != null) {
talkInfo.setTalkResponse(response.getResponse());
}
talkInfo.setTalkTime(LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
talkInfo.setTalkUser(userMainInfo.getUsername());
// 保存聊天记录
talkInfoRepository.save(talkInfo);
}
return response;
}
public List<TalkInfo> getAllRecord() {
return talkInfoRepository.findAll();
}
public List<TalkInfo> getRecordByUsername(HttpServletRequest httpServletRequest) {
String userId = (String) httpServletRequest.getAttribute("user");
TalkInfo talkInfo = talkInfoRepository.findById(Integer.parseInt(userId)).orElse(null);
if (talkInfo != null) {
return talkInfoRepository.findAllByTalkUser(talkInfo.getTalkUser());
}else {
return null;
}
}
}

View File

@ -0,0 +1,41 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.entity.Template; // 假设你有一个Template实体类
import edu.zrh.healthsystem.repository.TemplateRepository; // 假设你有一个TemplateRepository接口
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class TemplateService {
@Autowired
private TemplateRepository templateRepository;
public Template createTemplate(Template template) {
return templateRepository.save(template);
}
public Template updateTemplate(Long id, Template template) {
template.setId(id);
// 确保 ID 被设置
return templateRepository.save(template);
}
public void deleteTemplate(Long id) {
templateRepository.deleteById(id);
}
public List<Template> getAllTemplates(String templateName, String department) {
if (templateName != null && !templateName.isEmpty()) {
return templateRepository.findByTemplateNameContaining(templateName);
}
if (department != null && !department.isEmpty()) {
return templateRepository.findByDepartment(department);
}
return templateRepository.findAll();
}
// 其他服务方法...
}

View File

@ -0,0 +1,32 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.entity.RegularCheckupInfo;
import edu.zrh.healthsystem.model.PageBean;
import edu.zrh.healthsystem.model.User;
import java.time.LocalDateTime;
import java.util.List;
public interface UserService {
void add(User user);
void update(User user);
void delete(Long id);
void delete(List<Integer> ids);
User findById(Long id);
User findtreatById(Long id);
RegularCheckupInfo findRegularCheckupById(Long id);
List<User> findAll();
PageBean page01(Integer page, Integer pageSize);
PageBean page02(Integer page, Integer pageSize, Long id, String name, Integer age, String status, String sex,
String address, String phone, LocalDateTime createTime, LocalDateTime updateTime);
}

View File

@ -1,25 +0,0 @@
package edu.zrh.healthsystem.service.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import edu.zrh.healthsystem.repository.elderly.ElderMainRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author han
*/
@Service
public class ElderMainService {
private final ElderMainRepository elderMainRepository;
@Autowired
public ElderMainService(ElderMainRepository elderMainRepository) {this.elderMainRepository = elderMainRepository;}
public List elderMain(){
List<BasicInfo> basicInfoList = elderMainRepository.findAll();
return basicInfoList;
}
}

View File

@ -1,47 +0,0 @@
package edu.zrh.healthsystem.service.elderly;
import edu.zrh.healthsystem.eneity.UserInfo;
import edu.zrh.healthsystem.model.elderly.ElderlyConnect;
import edu.zrh.healthsystem.model.elderly.ElderlyConnectResponse;
import edu.zrh.healthsystem.repository.elderly.ElderlyConnectRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* @author han
*/
@Service
public class ElderlyConnectService {
private final ElderlyConnectRepository elderlyConnectRepository;
@Autowired
public ElderlyConnectService(ElderlyConnectRepository elderlyConnectRepository) {
this.elderlyConnectRepository = elderlyConnectRepository;
}
public ElderlyConnectResponse getElderlyConnectResponse(ElderlyConnect elderlyConnect) {
Optional<UserInfo> optionalUserId = elderlyConnectRepository.findByUserId(elderlyConnect.getUserId());
Optional<UserInfo> optionalUserElderly = elderlyConnectRepository.findByUserElderly(elderlyConnect.getUserElderly());
ElderlyConnectResponse elderlyConnectResponse = new ElderlyConnectResponse();
if (optionalUserId.isPresent()) {
if(optionalUserElderly.isPresent())
{
UserInfo userInfo = optionalUserId.get();
userInfo.setUserElderly(elderlyConnect.getUserElderly());
elderlyConnectResponse.setUserId(elderlyConnect.getUserId());
elderlyConnectResponse.setMessage("添加成功");
}
else {
elderlyConnectResponse.setUserId(-2);
elderlyConnectResponse.setMessage("该老人不存在");
}
}
else {
elderlyConnectResponse.setUserId(-1);
elderlyConnectResponse.setMessage("该用户不存在");
}
return elderlyConnectResponse;
}
}

View File

@ -1,66 +0,0 @@
package edu.zrh.healthsystem.service.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import edu.zrh.healthsystem.eneity.MainProfileInfo;
import edu.zrh.healthsystem.model.elderly.ElderlyNew;
import edu.zrh.healthsystem.model.elderly.ElderlyNewResponse;
import edu.zrh.healthsystem.repository.elderly.ElderlyNewRepository;
import edu.zrh.healthsystem.repository.MainProfileInfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* @author han
*/
@Service
public class ElderlyNewService {
private final ElderlyNewRepository elderlyNewRepository;
private final MainProfileInfoRepository mainProfileInfoRepository;
@Autowired
public ElderlyNewService(ElderlyNewRepository elderlyNewRepository, MainProfileInfoRepository mainProfileInfoRepository) {
this.elderlyNewRepository = elderlyNewRepository;
this.mainProfileInfoRepository = mainProfileInfoRepository;
}
public ElderlyNewResponse elderly(ElderlyNew elderlyNew) {
Optional<BasicInfo> optionalBasicInfo = elderlyNewRepository.findByFullName(elderlyNew.getFullName());
ElderlyNewResponse elderlyNewResponse = new ElderlyNewResponse();
if (optionalBasicInfo.isPresent()) {
elderlyNewResponse.setElderlyId(-1);
elderlyNewResponse.setMessage("该用户已存在");
}
else {
BasicInfo basic = new BasicInfo();
basic.setContactRelation(elderlyNew.getContactRelation());
basic.setContactPhone(elderlyNew.getContactPhone());
basic.setContactName(elderlyNew.getContactName());
basic.setFullName(elderlyNew.getFullName());
basic.setGender(elderlyNew.getGender());
basic.setDateOfBirth(elderlyNew.getDateOfBirth());
basic.setEthnicity(elderlyNew.getEthnicity());
basic.setNativePlace(elderlyNew.getNativePlace());
basic.setIdNumber(elderlyNew.getIdNumber());
basic.setPermanentAddress(elderlyNew.getPermanentAddress());
basic.setOccupation(elderlyNew.getOccupation());
basic.setEducationLevel(elderlyNew.getEducationLevel());
basic.setLivingAlone(elderlyNew.getLivingAlone());
basic.setMaritalStatus(elderlyNew.getMaritalStatus());
basic.setPhoneNumber(elderlyNew.getPhoneNumber());
basic.setEatingHabits(elderlyNew.getEatingHabits());
basic.setExerciseFrequency(elderlyNew.getExerciseFrequency());
elderlyNewRepository.save(basic);
// 创建MainProfile记录
MainProfileInfo mainProfile = new MainProfileInfo();
mainProfile.setElderlyId(basic);
// 保存MainProfile记录
mainProfileInfoRepository.save(mainProfile);
elderlyNewResponse.setElderlyId(basic.getElderlyId());
elderlyNewResponse.setMessage("提交成功");
}
return elderlyNewResponse;
}
}

View File

@ -1,51 +0,0 @@
package edu.zrh.healthsystem.service.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import edu.zrh.healthsystem.model.Elderly;
import edu.zrh.healthsystem.repository.elderly.ElderlyShowRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import edu.zrh.healthsystem.model.elderly.ElderlyShowResponse;
import java.util.Optional;
@Service
public class ElderlyShowService {
private final ElderlyShowRepository elderlyShowRepository;
@Autowired
public ElderlyShowService(ElderlyShowRepository elderlyShowRepository) {
this.elderlyShowRepository = elderlyShowRepository;
}
public ElderlyShowResponse getElderlyShow(Elderly elderly) {
Optional<BasicInfo> optionalelderlyId = elderlyShowRepository.findByElderlyId(elderly.getElderlyId());
ElderlyShowResponse elderlyShowResponse = new ElderlyShowResponse();
if (optionalelderlyId.isPresent()) {
BasicInfo basic=optionalelderlyId.get();
elderlyShowResponse.setElderlyId(basic.getElderlyId());
elderlyShowResponse.setContactName(basic.getContactName());
elderlyShowResponse.setContactPhone(basic.getContactPhone());
elderlyShowResponse.setEatingHabits(basic.getEatingHabits());
elderlyShowResponse.setContactRelation(basic.getContactRelation());
elderlyShowResponse.setEthnicity(basic.getEthnicity());
elderlyShowResponse.setEducationLevel(basic.getEducationLevel());
elderlyShowResponse.setExerciseFrequency(basic.getExerciseFrequency());
elderlyShowResponse.setGender(basic.getGender());
elderlyShowResponse.setMaritalStatus(basic.getMaritalStatus());
elderlyShowResponse.setDateOfBirth(basic.getDateOfBirth());
elderlyShowResponse.setOccupation(basic.getOccupation());
elderlyShowResponse.setLivingAlone(basic.getLivingAlone());
elderlyShowResponse.setNativePlace(basic.getNativePlace());
elderlyShowResponse.setFullName(basic.getFullName());
elderlyShowResponse.setMessage("获取成功");
elderlyShowResponse.setPermanentAddress(basic.getPermanentAddress());
elderlyShowResponse.setIdNumber(basic.getIdNumber());
elderlyShowResponse.setPhoneNumber(basic.getPhoneNumber());
}
else {
elderlyShowResponse.setMessage("该用户不存在");
}
return elderlyShowResponse;
}
}

View File

@ -0,0 +1,96 @@
package edu.zrh.healthsystem.service.impl;
import cn.hutool.core.date.DateUtil;
import edu.zrh.healthsystem.model.User;
import edu.zrh.healthsystem.service.ReportService;
import edu.zrh.healthsystem.service.UserService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
@Service
public class ReportServiceImpl implements ReportService {
@Resource
private UserService userService;
// 导出用户数据报表
@Override
public void exportBusinessData(HttpServletResponse response) throws IOException {
// 1.获取全部用户的数据
List<User> userList = userService.findAll();
// 2.提供Excel模板文件
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("template/用户数据报表模板.xlsx");
Workbook workbook;
if (inputStream != null) {
// 复制模板到新的工作簿
workbook = new XSSFWorkbook(inputStream);
} else {
// 如果没有模板创建一个新的工作簿
workbook = new XSSFWorkbook();
}
// 3.填充数据
Sheet sheet = workbook.createSheet("用户数据");
int rownum = 0;
Row row = sheet.createRow(rownum++);
// 创建标题行
String[] headers = {"ID", "姓名", "年龄", "状态", "性别", "地址", "电话", "创建时间", "更新时间"};
for (int i = 0; i < headers.length; i++) {
Cell cell = row.createCell(i);
cell.setCellValue(headers[i]);
}
// 填充用户数据
for (User user : userList) {
row = sheet.createRow(rownum++);
row.createCell(0).setCellValue(user.getId());
row.createCell(1).setCellValue(user.getName());
row.createCell(2).setCellValue(user.getAge());
row.createCell(3).setCellValue(user.getStatus().toString());
row.createCell(4).setCellValue(user.getSex());
row.createCell(5).setCellValue(user.getAddress());
row.createCell(6).setCellValue(user.getPhone());
row.createCell(7).setCellValue(user.getCreateTime() != null ? DateUtil.format(user.getCreateTime(), "yyyy-MM-dd HH:mm:ss") : "");
row.createCell(8).setCellValue(user.getUpdateTime() != null ? DateUtil.format(user.getUpdateTime(), "yyyy-MM-dd HH:mm:ss") : "");
}
// 4.写入响应
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("用户数据报表模板.xlsx", StandardCharsets.UTF_8.name()));
OutputStream outputStream = null;
try {
outputStream = response.getOutputStream();
workbook.write(outputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (outputStream != null) {
outputStream.close();
}
workbook.close();
if (inputStream != null) {
inputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,117 @@
package edu.zrh.healthsystem.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import edu.zrh.healthsystem.repository.LogRepository;
import edu.zrh.healthsystem.entity.RegularCheckupInfo;
import edu.zrh.healthsystem.model.PageBean;
import edu.zrh.healthsystem.mapper.UserMapper;
import edu.zrh.healthsystem.model.User;
import edu.zrh.healthsystem.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
@Resource
private UserMapper userMapper;
@Override
@LogRepository
public void add(User user) {
// 补充属性
user.setCreateTime(LocalDateTime.now());
user.setUpdateTime(LocalDateTime.now());
userMapper.add(user);
}
@Override
@LogRepository
public void update(User user) {
// 补充属性
user.setUpdateTime(LocalDateTime.now());
userMapper.update(user);
}
// 根据id删除员工
@Override
@LogRepository
public void delete(Long id) {
userMapper.deleteById(id);
}
// 批量删除
@Override
@LogRepository
public void delete(List<Integer> ids) {
userMapper.deleteByIds(ids);
}
@Override
@LogRepository
public User findById(Long id) {
return userMapper.findById(id);
}
@Override
@LogRepository
public User findtreatById(Long id) {
return userMapper.findtreatById(id);
}
@Override
@LogRepository
public RegularCheckupInfo findRegularCheckupById(Long id) {
return userMapper.findRegularCheckupById(id);
}
@Override
@LogRepository
public List<User> findAll() {
return userMapper.findAll();
}
/**
* 原生的分页查询
*
* @param page 页码
* @param pageSize 每页展示记录数
*/
@Override
@LogRepository
public PageBean page01(Integer page, Integer pageSize) {
// 1.获取总记录数
Long count = userMapper.count();
//2获取分页查询结果列表
Integer start = (page - 1) * pageSize;
//计算起始索引 , 公式: (页码-1)*页大小
List<User> userList = userMapper.page(start, pageSize);
//3封装PageBean对象
return new PageBean(count, userList);
}
@Override
@LogRepository
public PageBean page02(Integer page, Integer pageSize, Long id, String name, Integer age, String status, String sex,
String address, String phone, LocalDateTime createTime, LocalDateTime updateTime) {
// 设置分页参数
PageHelper.startPage(page, pageSize);
// 执行分页查询
List<User> empList = userMapper.list(id, name, age, status, sex, address, phone, createTime, updateTime);
// 获取分页结果
Page<User> p = (Page<User>) empList;
//封装PageBean
PageBean pageBean = new PageBean(p.getTotal(), p.getResult());
return pageBean;
}
}

View File

@ -1,7 +1,33 @@
server.port=8080
spring.application.name=healthSystem
# DataSource settings
spring.datasource.url= jdbc:mysql://localhost:3306/healthsystem?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.url= jdbc:mysql://10.33.66.120:3306/202201080137?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.username=202201080137
spring.datasource.password=KQGTTX732721
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.ai.ollama.chat.options.model=qwen:2b
spring.ai.ollama.base-url=http://10.10.10.44:11434
mybatis.configuration.map-underscore-to-camel-case=true
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
jwt.secret-key=hunanzhongyiyaodaxue2024kechengsheji109dishiwuzu
# knife4j??????
springdoc.swagger-ui.path=/swagger-ui.html
springdoc.swagger-ui.tags-sorter=alpha
springdoc.swagger-ui.operations-sorter=alpha
springdoc.api-docs.path=/v3/api-docs
springdoc.group-configs[0].group=zrh
springdoc.group-configs[0].paths-to-match=/**
springdoc.group-configs[0].packages-to-scan=edu.zrh.healthsystem.controller
knife4j.enable=true
knife4j.openapi.title="????"
knife4j.openapi.description="??????????"
knife4j.openapi.email=xiaoymin@foxmail.com
knife4j.openapi.concat=xzy
knife4j.openapi.url=https://xzynet.com.cn
knife4j.openapi.version=v1.0

184
src/main/resources/data.sql Normal file
View File

@ -0,0 +1,184 @@
/*
Navicat Premium Data Transfer
Source Server :
Source Server Type : MySQL
Source Server Version : 50744 (5.7.44-log)
Source Host : 10.33.66.120:3306
Source Schema : 202201080137
Target Server Type : MySQL
Target Server Version : 50744 (5.7.44-log)
File Encoding : 65001
Date: 23/12/2024 20:11:28
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for db_account
-- ----------------------------
DROP TABLE IF EXISTS `db_account`;
CREATE TABLE `db_account` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`role` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
`register_time` datetime NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `unique_email`(`email`) USING BTREE,
UNIQUE INDEX `unique_username`(`username`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for medical_records
-- ----------------------------
DROP TABLE IF EXISTS `medical_records`;
CREATE TABLE `medical_records` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`age` int(11) NOT NULL,
`create_time` datetime(6) NOT NULL,
`diagnosis` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`gender` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`patient_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`treatment` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`update_time` datetime(6) NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
CONSTRAINT `fk_patient` FOREIGN KEY (`id`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for ocr_data
-- ----------------------------
DROP TABLE IF EXISTS `ocr_data`;
CREATE TABLE `ocr_data` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`patient_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`age` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`gender` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`diagnosis` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`treatment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for operate_log
-- ----------------------------
DROP TABLE IF EXISTS `operate_log`;
CREATE TABLE `operate_log` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
`operate_user` int(10) UNSIGNED NULL DEFAULT NULL COMMENT '操作人',
`operate_time` datetime NULL DEFAULT NULL COMMENT '操作时间',
`class_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作的类名',
`method_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作的方法名',
`method_params` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法参数',
`return_value` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '返回值',
`cost_time` bigint(20) NULL DEFAULT NULL COMMENT '方法执行耗时, 单位:ms',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 37 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '操作日志表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for regularcheckup_info
-- ----------------------------
DROP TABLE IF EXISTS `regularcheckup_info`;
CREATE TABLE `regularcheckup_info` (
`checkup_id` int(20) NOT NULL AUTO_INCREMENT,
`id` bigint(20) NOT NULL,
`weight_status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`blood_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`chronic_diseases` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`height` decimal(5, 2) NULL DEFAULT NULL,
`weight` decimal(5, 2) NULL DEFAULT NULL,
`heart_rate` int(11) NULL DEFAULT NULL,
`temperature` decimal(3, 1) NULL DEFAULT NULL,
`oxygen_saturation` int(11) NULL DEFAULT NULL,
`blood_pressure` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`glucose_level` decimal(5, 2) NULL DEFAULT NULL,
`pulse` int(11) NULL DEFAULT NULL,
`face_image` blob NULL,
`tongue_image` blob NULL,
`checkup_date` date NULL DEFAULT NULL,
PRIMARY KEY (`checkup_id`) USING BTREE,
INDEX `id`(`id`) USING BTREE,
CONSTRAINT `regularcheckup_info_ibfk_1` FOREIGN KEY (`id`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 155 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Table structure for talk_info
-- ----------------------------
DROP TABLE IF EXISTS `talk_info`;
CREATE TABLE `talk_info` (
`talk_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`talk_prompt` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`talk_response` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`talk_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`talk_user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`talk_id`) USING BTREE,
INDEX `talk_user`(`talk_user`) USING BTREE,
CONSTRAINT `talk_info_ibfk_1` FOREIGN KEY (`talk_user`) REFERENCES `user_main` (`user_name`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 51 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for templates
-- ----------------------------
DROP TABLE IF EXISTS `templates`;
CREATE TABLE `templates` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`template_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`department` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`remarks` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '姓名',
`age` int(11) NULL DEFAULT NULL COMMENT '年龄',
`status` int(11) NULL DEFAULT NULL COMMENT '状态1有效0无效',
`sex` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '性别',
`address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '地址',
`phone` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电话',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`, `name`) USING BTREE,
INDEX `id`(`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 80 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for user_login
-- ----------------------------
DROP TABLE IF EXISTS `user_login`;
CREATE TABLE `user_login` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '账号',
`pwd` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '密码',
`permission` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '权限 0为管理员1为普通用户',
PRIMARY KEY (`id`) USING BTREE,
CONSTRAINT `user_login_ibfk_1` FOREIGN KEY (`id`) REFERENCES `user_main` (`user_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Table structure for user_main
-- ----------------------------
DROP TABLE IF EXISTS `user_main`;
CREATE TABLE `user_main` (
`user_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '医生姓名',
`user_age` int(11) NULL DEFAULT NULL COMMENT '医生年龄',
`user_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '医生邮件',
`user_permission` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '医生权限',
`user_gender` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`user_id`) USING BTREE,
INDEX `user_name`(`user_name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -0,0 +1,79 @@
<?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="edu.zrh.healthsystem.mapper.UserMapper">
<update id="update">
update user
<set>
<if test="name != null">
name = #{name},
</if>
<if test="age != null">
age = #{age},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="sex != null">
sex = #{sex},
</if>
<if test="address != null">
address = #{address},
</if>
<if test="updateTime != null">
update_Time = #{updateTime},
</if>
<if test="phone != null">
phone = #{phone}
</if>
</set>
where id = #{id}
</update>
<!-- 条件分页查询 -->
<select id="list" resultType="edu.zrh.healthsystem.model.User">
select * from user
<where>
<if test="id != null">
id = #{id}
</if>
<if test="name != null and name != ''">
name like concat('%',#{name},'%')
</if>
<if test="age != null">
age = #{age}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="sex != null and sex != ''">
and sex = #{sex}
</if>
<if test="address != null and name != ''">
address like concat('%',#{address},'%')
</if>
<if test="phone != null and phone != ''">
phone = #{phone}
</if>
<if test="createTime != null">
and create_Time = #{createTime}
</if>
<if test="updateTime != null">
and update_Time = #{updateTime}
</if>
</where>
</select>
<!--批量删除-->
<delete id="deleteByIds">
delete from user where id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
</mapper>