add
This commit is contained in:
74
backend/pom.xml
Normal file
74
backend/pom.xml
Normal file
@@ -0,0 +1,74 @@
|
||||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.nursinghome</groupId>
|
||||
<artifactId>nursing-home-backend</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>nursing-home-backend</name>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<spring.boot.version>3.2.5</spring.boot.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot3-starter</artifactId>
|
||||
<version>1.37.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-crypto</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
143
backend/sql/schema.sql
Normal file
143
backend/sql/schema.sql
Normal file
@@ -0,0 +1,143 @@
|
||||
CREATE DATABASE IF NOT EXISTS nursing_home DEFAULT CHARACTER SET utf8mb4;
|
||||
USE nursing_home;
|
||||
|
||||
DROP TABLE IF EXISTS payment_record;
|
||||
DROP TABLE IF EXISTS bill;
|
||||
DROP TABLE IF EXISTS feedback;
|
||||
DROP TABLE IF EXISTS notice;
|
||||
DROP TABLE IF EXISTS handover;
|
||||
DROP TABLE IF EXISTS health_record;
|
||||
DROP TABLE IF EXISTS care_record;
|
||||
DROP TABLE IF EXISTS schedule;
|
||||
DROP TABLE IF EXISTS family_elder;
|
||||
DROP TABLE IF EXISTS elder;
|
||||
DROP TABLE IF EXISTS sys_user;
|
||||
|
||||
CREATE TABLE sys_user (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
username VARCHAR(50) NOT NULL UNIQUE,
|
||||
password VARCHAR(100) NOT NULL,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
phone VARCHAR(30),
|
||||
role VARCHAR(20) NOT NULL,
|
||||
status TINYINT NOT NULL DEFAULT 1,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE elder (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
gender VARCHAR(10),
|
||||
id_card VARCHAR(30) NOT NULL UNIQUE,
|
||||
birthday DATE,
|
||||
room_no VARCHAR(20),
|
||||
check_in_date DATE,
|
||||
care_level VARCHAR(20),
|
||||
status VARCHAR(20),
|
||||
remark VARCHAR(200)
|
||||
);
|
||||
|
||||
CREATE TABLE family_elder (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
family_id BIGINT NOT NULL,
|
||||
elder_id BIGINT NOT NULL,
|
||||
relationship VARCHAR(20),
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_family (family_id),
|
||||
INDEX idx_elder (elder_id)
|
||||
);
|
||||
|
||||
CREATE TABLE schedule (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
nurse_id BIGINT NOT NULL,
|
||||
date DATE NOT NULL,
|
||||
shift VARCHAR(20),
|
||||
task VARCHAR(200),
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
INDEX idx_nurse_date (nurse_id, date)
|
||||
);
|
||||
|
||||
CREATE TABLE care_record (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
elder_id BIGINT NOT NULL,
|
||||
nurse_id BIGINT NOT NULL,
|
||||
content VARCHAR(500),
|
||||
attachment_url VARCHAR(200),
|
||||
record_time DATETIME,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_elder (elder_id)
|
||||
);
|
||||
|
||||
CREATE TABLE health_record (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
elder_id BIGINT NOT NULL,
|
||||
nurse_id BIGINT NOT NULL,
|
||||
temperature DECIMAL(4,1),
|
||||
bp_systolic INT,
|
||||
bp_diastolic INT,
|
||||
heart_rate INT,
|
||||
note VARCHAR(200),
|
||||
record_time DATETIME,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_elder (elder_id)
|
||||
);
|
||||
|
||||
CREATE TABLE handover (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
nurse_id BIGINT NOT NULL,
|
||||
date DATE NOT NULL,
|
||||
content VARCHAR(500),
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_nurse (nurse_id)
|
||||
);
|
||||
|
||||
CREATE TABLE notice (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(100) NOT NULL,
|
||||
content VARCHAR(1000),
|
||||
target_role VARCHAR(20),
|
||||
target_user_id BIGINT,
|
||||
created_by BIGINT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE feedback (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
family_id BIGINT NOT NULL,
|
||||
elder_id BIGINT NOT NULL,
|
||||
type VARCHAR(20),
|
||||
content VARCHAR(500),
|
||||
rating INT,
|
||||
status VARCHAR(20),
|
||||
reply VARCHAR(500),
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE bill (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
elder_id BIGINT NOT NULL,
|
||||
month VARCHAR(7) NOT NULL,
|
||||
bed_fee DECIMAL(10,2),
|
||||
care_fee DECIMAL(10,2),
|
||||
meal_fee DECIMAL(10,2),
|
||||
other_fee DECIMAL(10,2),
|
||||
total DECIMAL(10,2),
|
||||
status VARCHAR(20),
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
paid_at DATETIME
|
||||
);
|
||||
|
||||
CREATE TABLE payment_record (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
bill_id BIGINT NOT NULL,
|
||||
family_id BIGINT NOT NULL,
|
||||
amount DECIMAL(10,2) NOT NULL,
|
||||
method VARCHAR(20),
|
||||
paid_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
INSERT INTO sys_user(username, password, name, phone, role, status)
|
||||
VALUES ('admin', 'admin123', 'Administrator', '13800000000', 'ADMIN', 1);
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.nursinghome;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.nursinghome.mapper")
|
||||
public class NursingHomeApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(NursingHomeApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.nursinghome.common;
|
||||
|
||||
public class ApiException extends RuntimeException {
|
||||
public ApiException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.nursinghome.common;
|
||||
|
||||
public class ApiResponse<T> {
|
||||
private int code;
|
||||
private String message;
|
||||
private T data;
|
||||
|
||||
public ApiResponse() {}
|
||||
|
||||
public ApiResponse(int code, String message, T data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> success(T data) {
|
||||
return new ApiResponse<>(0, "ok", data);
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> success() {
|
||||
return new ApiResponse<>(0, "ok", null);
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> error(String message) {
|
||||
return new ApiResponse<>(1, message, null);
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.nursinghome.common;
|
||||
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(ApiException.class)
|
||||
public ApiResponse<Void> handleApi(ApiException ex) {
|
||||
return ApiResponse.error(ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ApiResponse<Void> handleValid(MethodArgumentNotValidException ex) {
|
||||
String msg = ex.getBindingResult().getAllErrors().isEmpty()
|
||||
? "validation error" : ex.getBindingResult().getAllErrors().get(0).getDefaultMessage();
|
||||
return ApiResponse.error(msg);
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ApiResponse<Void> handle(Exception ex) {
|
||||
return ApiResponse.error(ex.getMessage());
|
||||
}
|
||||
}
|
||||
17
backend/src/main/java/com/nursinghome/config/CorsConfig.java
Normal file
17
backend/src/main/java/com/nursinghome/config/CorsConfig.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.nursinghome.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 CorsConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOriginPatterns("*")
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
.allowedHeaders("*")
|
||||
.allowCredentials(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.nursinghome.config;
|
||||
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import com.nursinghome.entity.User;
|
||||
import com.nursinghome.mapper.UserMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class SaTokenStpInterfaceImpl implements StpInterface {
|
||||
private final UserMapper userMapper;
|
||||
|
||||
public SaTokenStpInterfaceImpl(UserMapper userMapper) {
|
||||
this.userMapper = userMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRoleList(Object loginId, String loginType) {
|
||||
User user = userMapper.findById(Long.valueOf(loginId.toString()));
|
||||
if (user == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.singletonList(user.getRole());
|
||||
}
|
||||
}
|
||||
23
backend/src/main/java/com/nursinghome/config/WebConfig.java
Normal file
23
backend/src/main/java/com/nursinghome/config/WebConfig.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.nursinghome.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
@Value("${app.upload-dir}")
|
||||
private String uploadDir;
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
Path uploadPath = Paths.get(uploadDir).toAbsolutePath().normalize();
|
||||
String location = uploadPath.toUri().toString();
|
||||
registry.addResourceHandler("/files/**")
|
||||
.addResourceLocations(location);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
package com.nursinghome.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.nursinghome.common.ApiException;
|
||||
import com.nursinghome.common.ApiResponse;
|
||||
import com.nursinghome.dto.*;
|
||||
import com.nursinghome.entity.*;
|
||||
import com.nursinghome.mapper.*;
|
||||
import com.nursinghome.service.BillService;
|
||||
import com.nursinghome.service.ElderService;
|
||||
import com.nursinghome.service.UserService;
|
||||
import com.nursinghome.util.PasswordUtil;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/admin")
|
||||
@SaCheckRole("ADMIN")
|
||||
public class AdminController {
|
||||
private final UserService userService;
|
||||
private final ElderService elderService;
|
||||
private final ScheduleMapper scheduleMapper;
|
||||
private final FeedbackMapper feedbackMapper;
|
||||
private final NoticeMapper noticeMapper;
|
||||
private final BillService billService;
|
||||
private final BillMapper billMapper;
|
||||
private final UserMapper userMapper;
|
||||
|
||||
public AdminController(UserService userService,
|
||||
ElderService elderService,
|
||||
ScheduleMapper scheduleMapper,
|
||||
FeedbackMapper feedbackMapper,
|
||||
NoticeMapper noticeMapper,
|
||||
BillService billService,
|
||||
BillMapper billMapper,
|
||||
UserMapper userMapper) {
|
||||
this.userService = userService;
|
||||
this.elderService = elderService;
|
||||
this.scheduleMapper = scheduleMapper;
|
||||
this.feedbackMapper = feedbackMapper;
|
||||
this.noticeMapper = noticeMapper;
|
||||
this.billService = billService;
|
||||
this.billMapper = billMapper;
|
||||
this.userMapper = userMapper;
|
||||
}
|
||||
|
||||
@GetMapping("/stats")
|
||||
public ApiResponse<Map<String, Object>> stats() {
|
||||
int elders = elderService.listAll().size();
|
||||
int nurses = userService.listByRole("NURSE").size();
|
||||
int families = userService.listByRole("FAMILY").size();
|
||||
BigDecimal income = BigDecimal.ZERO;
|
||||
for (Bill bill : billMapper.listAll()) {
|
||||
if ("PAID".equals(bill.getStatus()) && bill.getTotal() != null) {
|
||||
income = income.add(bill.getTotal());
|
||||
}
|
||||
}
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("elders", elders);
|
||||
data.put("nurses", nurses);
|
||||
data.put("families", families);
|
||||
data.put("income", income);
|
||||
return ApiResponse.success(data);
|
||||
}
|
||||
|
||||
@GetMapping("/users")
|
||||
public ApiResponse<List<User>> listUsers(@RequestParam(required = false) String role) {
|
||||
List<User> users = userService.listByRole(role);
|
||||
for (User user : users) {
|
||||
user.setPassword(null);
|
||||
}
|
||||
return ApiResponse.success(users);
|
||||
}
|
||||
|
||||
@PostMapping("/users")
|
||||
public ApiResponse<User> createUser(@RequestBody UserRequest request) {
|
||||
User user = new User();
|
||||
user.setUsername(request.getUsername());
|
||||
user.setPassword(request.getPassword());
|
||||
user.setName(request.getName());
|
||||
user.setPhone(request.getPhone());
|
||||
user.setRole(request.getRole());
|
||||
user.setStatus(request.getStatus() == null ? 1 : request.getStatus());
|
||||
userService.createUser(user, true);
|
||||
user.setPassword(null);
|
||||
return ApiResponse.success(user);
|
||||
}
|
||||
|
||||
@PutMapping("/users")
|
||||
public ApiResponse<Void> updateUser(@RequestBody UserUpdateRequest request) {
|
||||
User user = new User();
|
||||
user.setId(request.getId());
|
||||
user.setName(request.getName());
|
||||
user.setPhone(request.getPhone());
|
||||
user.setStatus(request.getStatus());
|
||||
userService.updateUser(user);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@PutMapping("/users/{id}/status")
|
||||
public ApiResponse<Void> updateUserStatus(@PathVariable Long id, @RequestParam Integer status) {
|
||||
userService.updateStatus(id, status);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@PostMapping("/users/{id}/reset-password")
|
||||
public ApiResponse<Void> resetPassword(@PathVariable Long id, @RequestParam String password) {
|
||||
userService.updatePassword(id, PasswordUtil.hash(password));
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@GetMapping("/elders")
|
||||
public ApiResponse<List<Elder>> listElders() {
|
||||
return ApiResponse.success(elderService.listAll());
|
||||
}
|
||||
|
||||
@PostMapping("/elders")
|
||||
public ApiResponse<Elder> createElder(@RequestBody ElderRequest request) {
|
||||
Elder elder = new Elder();
|
||||
elder.setName(request.getName());
|
||||
elder.setGender(request.getGender());
|
||||
elder.setIdCard(request.getIdCard());
|
||||
elder.setBirthday(request.getBirthday());
|
||||
elder.setRoomNo(request.getRoomNo());
|
||||
elder.setCheckInDate(request.getCheckInDate());
|
||||
elder.setCareLevel(request.getCareLevel());
|
||||
elder.setStatus(request.getStatus());
|
||||
elder.setRemark(request.getRemark());
|
||||
return ApiResponse.success(elderService.create(elder));
|
||||
}
|
||||
|
||||
@PutMapping("/elders")
|
||||
public ApiResponse<Void> updateElder(@RequestBody ElderRequest request) {
|
||||
Elder elder = new Elder();
|
||||
elder.setId(request.getId());
|
||||
elder.setName(request.getName());
|
||||
elder.setGender(request.getGender());
|
||||
elder.setIdCard(request.getIdCard());
|
||||
elder.setBirthday(request.getBirthday());
|
||||
elder.setRoomNo(request.getRoomNo());
|
||||
elder.setCheckInDate(request.getCheckInDate());
|
||||
elder.setCareLevel(request.getCareLevel());
|
||||
elder.setStatus(request.getStatus());
|
||||
elder.setRemark(request.getRemark());
|
||||
elderService.update(elder);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@DeleteMapping("/elders/{id}")
|
||||
public ApiResponse<Void> deleteElder(@PathVariable Long id) {
|
||||
elderService.delete(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@GetMapping("/schedules")
|
||||
public ApiResponse<List<Schedule>> listSchedules(@RequestParam String date) {
|
||||
return ApiResponse.success(scheduleMapper.listByDate(java.time.LocalDate.parse(date)));
|
||||
}
|
||||
|
||||
@PostMapping("/schedules")
|
||||
public ApiResponse<Schedule> createSchedule(@RequestBody ScheduleRequest request) {
|
||||
Schedule schedule = new Schedule();
|
||||
schedule.setNurseId(request.getNurseId());
|
||||
schedule.setDate(request.getDate());
|
||||
schedule.setShift(request.getShift());
|
||||
schedule.setTask(request.getTask());
|
||||
scheduleMapper.insert(schedule);
|
||||
return ApiResponse.success(schedule);
|
||||
}
|
||||
|
||||
@PutMapping("/schedules")
|
||||
public ApiResponse<Void> updateSchedule(@RequestBody ScheduleRequest request) {
|
||||
Schedule schedule = new Schedule();
|
||||
schedule.setId(request.getId());
|
||||
schedule.setNurseId(request.getNurseId());
|
||||
schedule.setDate(request.getDate());
|
||||
schedule.setShift(request.getShift());
|
||||
schedule.setTask(request.getTask());
|
||||
scheduleMapper.update(schedule);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@DeleteMapping("/schedules/{id}")
|
||||
public ApiResponse<Void> deleteSchedule(@PathVariable Long id) {
|
||||
scheduleMapper.delete(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@PostMapping("/bills")
|
||||
public ApiResponse<Bill> createBill(@RequestBody BillRequest request) {
|
||||
Bill bill = new Bill();
|
||||
bill.setElderId(request.getElderId());
|
||||
bill.setMonth(request.getMonth());
|
||||
bill.setBedFee(request.getBedFee());
|
||||
bill.setCareFee(request.getCareFee());
|
||||
bill.setMealFee(request.getMealFee());
|
||||
bill.setOtherFee(request.getOtherFee());
|
||||
return ApiResponse.success(billService.createBill(bill));
|
||||
}
|
||||
|
||||
@GetMapping("/bills")
|
||||
public ApiResponse<List<Bill>> listBills(@RequestParam(required = false) Long elderId) {
|
||||
if (elderId == null) {
|
||||
return ApiResponse.success(billMapper.listAll());
|
||||
}
|
||||
return ApiResponse.success(billService.listByElderId(elderId));
|
||||
}
|
||||
|
||||
@GetMapping("/feedback")
|
||||
public ApiResponse<List<Feedback>> listFeedback() {
|
||||
return ApiResponse.success(feedbackMapper.listAll());
|
||||
}
|
||||
|
||||
@PutMapping("/feedback")
|
||||
public ApiResponse<Void> updateFeedback(@RequestBody FeedbackUpdateRequest request) {
|
||||
Feedback feedback = new Feedback();
|
||||
feedback.setId(request.getId());
|
||||
feedback.setStatus(request.getStatus());
|
||||
feedback.setReply(request.getReply());
|
||||
feedbackMapper.updateStatus(feedback);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@PostMapping("/notices")
|
||||
public ApiResponse<Notice> createNotice(@RequestBody NoticeRequest request) {
|
||||
Notice notice = new Notice();
|
||||
notice.setTitle(request.getTitle());
|
||||
notice.setContent(request.getContent());
|
||||
notice.setTargetRole(request.getTargetRole());
|
||||
notice.setTargetUserId(request.getTargetUserId());
|
||||
notice.setCreatedBy(Long.valueOf(StpUtil.getLoginId().toString()));
|
||||
noticeMapper.insert(notice);
|
||||
return ApiResponse.success(notice);
|
||||
}
|
||||
|
||||
@GetMapping("/notices")
|
||||
public ApiResponse<List<Notice>> listNotices(@RequestParam(required = false) String role,
|
||||
@RequestParam(required = false) Long userId) {
|
||||
return ApiResponse.success(noticeMapper.listByTarget(role, userId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.nursinghome.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.nursinghome.common.ApiException;
|
||||
import com.nursinghome.common.ApiResponse;
|
||||
import com.nursinghome.dto.LoginRequest;
|
||||
import com.nursinghome.dto.RegisterRequest;
|
||||
import com.nursinghome.entity.User;
|
||||
import com.nursinghome.service.FamilyService;
|
||||
import com.nursinghome.service.UserService;
|
||||
import com.nursinghome.util.PasswordUtil;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/auth")
|
||||
public class AuthController {
|
||||
private final UserService userService;
|
||||
private final FamilyService familyService;
|
||||
|
||||
public AuthController(UserService userService, FamilyService familyService) {
|
||||
this.userService = userService;
|
||||
this.familyService = familyService;
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public ApiResponse<Map<String, Object>> login(@Valid @RequestBody LoginRequest request) {
|
||||
User user = userService.findByUsername(request.getUsername());
|
||||
if (user == null) {
|
||||
throw new ApiException("user not found");
|
||||
}
|
||||
if (user.getStatus() != null && user.getStatus() == 0) {
|
||||
throw new ApiException("user disabled");
|
||||
}
|
||||
if (!PasswordUtil.matches(request.getPassword(), user.getPassword())) {
|
||||
throw new ApiException("invalid password");
|
||||
}
|
||||
if (!PasswordUtil.isBcrypt(user.getPassword())) {
|
||||
userService.updatePassword(user.getId(), PasswordUtil.hash(request.getPassword()));
|
||||
}
|
||||
StpUtil.login(user.getId());
|
||||
|
||||
user.setPassword(null);
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("token", StpUtil.getTokenValue());
|
||||
data.put("role", user.getRole());
|
||||
data.put("user", user);
|
||||
return ApiResponse.success(data);
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
public ApiResponse<User> register(@Valid @RequestBody RegisterRequest request) {
|
||||
User user = familyService.registerFamily(
|
||||
request.getUsername(),
|
||||
request.getPassword(),
|
||||
request.getName(),
|
||||
request.getPhone(),
|
||||
request.getElderIdCard(),
|
||||
request.getRelationship()
|
||||
);
|
||||
return ApiResponse.success(user);
|
||||
}
|
||||
|
||||
@PostMapping("/logout")
|
||||
public ApiResponse<Void> logout() {
|
||||
StpUtil.logout();
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@GetMapping("/me")
|
||||
@SaCheckLogin
|
||||
public ApiResponse<User> me() {
|
||||
Long userId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
User user = userService.findById(userId);
|
||||
if (user != null) {
|
||||
user.setPassword(null);
|
||||
}
|
||||
return ApiResponse.success(user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.nursinghome.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.nursinghome.common.ApiException;
|
||||
import com.nursinghome.common.ApiResponse;
|
||||
import com.nursinghome.dto.FeedbackRequest;
|
||||
import com.nursinghome.dto.PayRequest;
|
||||
import com.nursinghome.entity.*;
|
||||
import com.nursinghome.mapper.*;
|
||||
import com.nursinghome.service.BillService;
|
||||
import com.nursinghome.service.FamilyService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/family")
|
||||
@SaCheckRole("FAMILY")
|
||||
public class FamilyController {
|
||||
private final FamilyService familyService;
|
||||
private final ElderMapper elderMapper;
|
||||
private final CareRecordMapper careRecordMapper;
|
||||
private final HealthRecordMapper healthRecordMapper;
|
||||
private final BillService billService;
|
||||
private final BillMapper billMapper;
|
||||
private final NoticeMapper noticeMapper;
|
||||
private final FeedbackMapper feedbackMapper;
|
||||
|
||||
public FamilyController(FamilyService familyService,
|
||||
ElderMapper elderMapper,
|
||||
CareRecordMapper careRecordMapper,
|
||||
HealthRecordMapper healthRecordMapper,
|
||||
BillService billService,
|
||||
BillMapper billMapper,
|
||||
NoticeMapper noticeMapper,
|
||||
FeedbackMapper feedbackMapper) {
|
||||
this.familyService = familyService;
|
||||
this.elderMapper = elderMapper;
|
||||
this.careRecordMapper = careRecordMapper;
|
||||
this.healthRecordMapper = healthRecordMapper;
|
||||
this.billService = billService;
|
||||
this.billMapper = billMapper;
|
||||
this.noticeMapper = noticeMapper;
|
||||
this.feedbackMapper = feedbackMapper;
|
||||
}
|
||||
|
||||
@GetMapping("/elders")
|
||||
public ApiResponse<List<Elder>> listElders() {
|
||||
Long familyId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
List<FamilyElder> relations = familyService.listRelations(familyId);
|
||||
List<Elder> elders = new ArrayList<>();
|
||||
for (FamilyElder relation : relations) {
|
||||
Elder elder = elderMapper.findById(relation.getElderId());
|
||||
if (elder != null) {
|
||||
elders.add(elder);
|
||||
}
|
||||
}
|
||||
return ApiResponse.success(elders);
|
||||
}
|
||||
|
||||
@GetMapping("/care-records")
|
||||
public ApiResponse<List<CareRecord>> listCare(@RequestParam Long elderId) {
|
||||
Long familyId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
boolean allowed = false;
|
||||
for (FamilyElder relation : familyService.listRelations(familyId)) {
|
||||
if (relation.getElderId().equals(elderId)) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!allowed) {
|
||||
throw new ApiException("no access to this elder");
|
||||
}
|
||||
return ApiResponse.success(careRecordMapper.listByElderId(elderId));
|
||||
}
|
||||
|
||||
@GetMapping("/health-records")
|
||||
public ApiResponse<List<HealthRecord>> listHealth(@RequestParam Long elderId) {
|
||||
Long familyId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
boolean allowed = false;
|
||||
for (FamilyElder relation : familyService.listRelations(familyId)) {
|
||||
if (relation.getElderId().equals(elderId)) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!allowed) {
|
||||
throw new ApiException("no access to this elder");
|
||||
}
|
||||
return ApiResponse.success(healthRecordMapper.listByElderId(elderId));
|
||||
}
|
||||
|
||||
@GetMapping("/bills")
|
||||
public ApiResponse<List<Bill>> listBills(@RequestParam Long elderId) {
|
||||
Long familyId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
boolean allowed = false;
|
||||
for (FamilyElder relation : familyService.listRelations(familyId)) {
|
||||
if (relation.getElderId().equals(elderId)) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!allowed) {
|
||||
throw new ApiException("no access to this elder");
|
||||
}
|
||||
return ApiResponse.success(billService.listByElderId(elderId));
|
||||
}
|
||||
|
||||
@PostMapping("/bills/{id}/pay")
|
||||
public ApiResponse<Void> pay(@PathVariable Long id, @RequestBody PayRequest request) {
|
||||
Long familyId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
Bill bill = billMapper.findById(id);
|
||||
if (bill == null) {
|
||||
throw new ApiException("bill not found");
|
||||
}
|
||||
boolean allowed = false;
|
||||
for (FamilyElder relation : familyService.listRelations(familyId)) {
|
||||
if (relation.getElderId().equals(bill.getElderId())) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!allowed) {
|
||||
throw new ApiException("no access to this bill");
|
||||
}
|
||||
if ("PAID".equals(bill.getStatus())) {
|
||||
throw new ApiException("bill already paid");
|
||||
}
|
||||
BigDecimal amount = bill.getTotal() == null ? BigDecimal.ZERO : bill.getTotal();
|
||||
billService.payBill(id, familyId, request.getMethod(), amount);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@PostMapping("/feedback")
|
||||
public ApiResponse<Feedback> createFeedback(@RequestBody FeedbackRequest request) {
|
||||
Feedback feedback = new Feedback();
|
||||
feedback.setFamilyId(Long.valueOf(StpUtil.getLoginId().toString()));
|
||||
feedback.setElderId(request.getElderId());
|
||||
feedback.setType(request.getType());
|
||||
feedback.setContent(request.getContent());
|
||||
feedback.setRating(request.getRating());
|
||||
feedback.setStatus("NEW");
|
||||
feedback.setCreatedAt(LocalDateTime.now());
|
||||
feedbackMapper.insert(feedback);
|
||||
return ApiResponse.success(feedback);
|
||||
}
|
||||
|
||||
@GetMapping("/notices")
|
||||
public ApiResponse<List<Notice>> listNotices() {
|
||||
Long familyId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
return ApiResponse.success(noticeMapper.listByTarget("FAMILY", familyId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.nursinghome.controller;
|
||||
|
||||
import com.nursinghome.common.ApiResponse;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/files")
|
||||
public class FileController {
|
||||
@Value("${app.upload-dir}")
|
||||
private String uploadDir;
|
||||
|
||||
@PostMapping("/upload")
|
||||
public ApiResponse<Map<String, Object>> upload(@RequestParam("file") MultipartFile file) throws IOException {
|
||||
if (file.isEmpty()) {
|
||||
return ApiResponse.error("empty file");
|
||||
}
|
||||
String original = file.getOriginalFilename();
|
||||
String ext = StringUtils.getFilenameExtension(original);
|
||||
String name = UUID.randomUUID().toString().replace("-", "");
|
||||
if (ext != null && !ext.isEmpty()) {
|
||||
name = name + "." + ext;
|
||||
}
|
||||
File dir = new File(uploadDir);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
File dest = new File(dir, name);
|
||||
file.transferTo(dest);
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("url", "/files/" + name);
|
||||
return ApiResponse.success(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.nursinghome.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.nursinghome.common.ApiResponse;
|
||||
import com.nursinghome.dto.CareRecordRequest;
|
||||
import com.nursinghome.dto.HandoverRequest;
|
||||
import com.nursinghome.dto.HealthRecordRequest;
|
||||
import com.nursinghome.entity.*;
|
||||
import com.nursinghome.mapper.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/nurse")
|
||||
@SaCheckRole("NURSE")
|
||||
public class NurseController {
|
||||
private final ScheduleMapper scheduleMapper;
|
||||
private final CareRecordMapper careRecordMapper;
|
||||
private final HealthRecordMapper healthRecordMapper;
|
||||
private final HandoverMapper handoverMapper;
|
||||
private final NoticeMapper noticeMapper;
|
||||
|
||||
public NurseController(ScheduleMapper scheduleMapper,
|
||||
CareRecordMapper careRecordMapper,
|
||||
HealthRecordMapper healthRecordMapper,
|
||||
HandoverMapper handoverMapper,
|
||||
NoticeMapper noticeMapper) {
|
||||
this.scheduleMapper = scheduleMapper;
|
||||
this.careRecordMapper = careRecordMapper;
|
||||
this.healthRecordMapper = healthRecordMapper;
|
||||
this.handoverMapper = handoverMapper;
|
||||
this.noticeMapper = noticeMapper;
|
||||
}
|
||||
|
||||
@GetMapping("/schedules")
|
||||
public ApiResponse<List<Schedule>> listSchedules(@RequestParam String date) {
|
||||
Long nurseId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
return ApiResponse.success(scheduleMapper.listByNurseAndDate(nurseId, java.time.LocalDate.parse(date)));
|
||||
}
|
||||
|
||||
@PostMapping("/care-records")
|
||||
public ApiResponse<CareRecord> createCare(@RequestBody CareRecordRequest request) {
|
||||
CareRecord record = new CareRecord();
|
||||
record.setElderId(request.getElderId());
|
||||
record.setNurseId(Long.valueOf(StpUtil.getLoginId().toString()));
|
||||
record.setContent(request.getContent());
|
||||
record.setAttachmentUrl(request.getAttachmentUrl());
|
||||
record.setRecordTime(request.getRecordTime() == null ? java.time.LocalDateTime.now() : request.getRecordTime());
|
||||
careRecordMapper.insert(record);
|
||||
return ApiResponse.success(record);
|
||||
}
|
||||
|
||||
@GetMapping("/care-records")
|
||||
public ApiResponse<List<CareRecord>> listCare(@RequestParam Long elderId) {
|
||||
return ApiResponse.success(careRecordMapper.listByElderId(elderId));
|
||||
}
|
||||
|
||||
@PostMapping("/health-records")
|
||||
public ApiResponse<HealthRecord> createHealth(@RequestBody HealthRecordRequest request) {
|
||||
HealthRecord record = new HealthRecord();
|
||||
record.setElderId(request.getElderId());
|
||||
record.setNurseId(Long.valueOf(StpUtil.getLoginId().toString()));
|
||||
record.setTemperature(request.getTemperature());
|
||||
record.setBpSystolic(request.getBpSystolic());
|
||||
record.setBpDiastolic(request.getBpDiastolic());
|
||||
record.setHeartRate(request.getHeartRate());
|
||||
record.setNote(request.getNote());
|
||||
record.setRecordTime(request.getRecordTime() == null ? java.time.LocalDateTime.now() : request.getRecordTime());
|
||||
healthRecordMapper.insert(record);
|
||||
return ApiResponse.success(record);
|
||||
}
|
||||
|
||||
@GetMapping("/health-records")
|
||||
public ApiResponse<List<HealthRecord>> listHealth(@RequestParam Long elderId) {
|
||||
return ApiResponse.success(healthRecordMapper.listByElderId(elderId));
|
||||
}
|
||||
|
||||
@PostMapping("/handovers")
|
||||
public ApiResponse<Handover> createHandover(@RequestBody HandoverRequest request) {
|
||||
Handover handover = new Handover();
|
||||
handover.setNurseId(Long.valueOf(StpUtil.getLoginId().toString()));
|
||||
handover.setDate(request.getDate());
|
||||
handover.setContent(request.getContent());
|
||||
handoverMapper.insert(handover);
|
||||
return ApiResponse.success(handover);
|
||||
}
|
||||
|
||||
@GetMapping("/handovers")
|
||||
public ApiResponse<List<Handover>> listHandovers() {
|
||||
Long nurseId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
return ApiResponse.success(handoverMapper.listByNurseId(nurseId));
|
||||
}
|
||||
|
||||
@GetMapping("/notices")
|
||||
public ApiResponse<List<Notice>> listNotices() {
|
||||
Long nurseId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
return ApiResponse.success(noticeMapper.listByTarget("NURSE", nurseId));
|
||||
}
|
||||
}
|
||||
60
backend/src/main/java/com/nursinghome/dto/BillRequest.java
Normal file
60
backend/src/main/java/com/nursinghome/dto/BillRequest.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class BillRequest {
|
||||
private Long elderId;
|
||||
private String month;
|
||||
private BigDecimal bedFee;
|
||||
private BigDecimal careFee;
|
||||
private BigDecimal mealFee;
|
||||
private BigDecimal otherFee;
|
||||
|
||||
public Long getElderId() {
|
||||
return elderId;
|
||||
}
|
||||
|
||||
public void setElderId(Long elderId) {
|
||||
this.elderId = elderId;
|
||||
}
|
||||
|
||||
public String getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth(String month) {
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public BigDecimal getBedFee() {
|
||||
return bedFee;
|
||||
}
|
||||
|
||||
public void setBedFee(BigDecimal bedFee) {
|
||||
this.bedFee = bedFee;
|
||||
}
|
||||
|
||||
public BigDecimal getCareFee() {
|
||||
return careFee;
|
||||
}
|
||||
|
||||
public void setCareFee(BigDecimal careFee) {
|
||||
this.careFee = careFee;
|
||||
}
|
||||
|
||||
public BigDecimal getMealFee() {
|
||||
return mealFee;
|
||||
}
|
||||
|
||||
public void setMealFee(BigDecimal mealFee) {
|
||||
this.mealFee = mealFee;
|
||||
}
|
||||
|
||||
public BigDecimal getOtherFee() {
|
||||
return otherFee;
|
||||
}
|
||||
|
||||
public void setOtherFee(BigDecimal otherFee) {
|
||||
this.otherFee = otherFee;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class CareRecordRequest {
|
||||
private Long elderId;
|
||||
private String content;
|
||||
private String attachmentUrl;
|
||||
private LocalDateTime recordTime;
|
||||
|
||||
public Long getElderId() {
|
||||
return elderId;
|
||||
}
|
||||
|
||||
public void setElderId(Long elderId) {
|
||||
this.elderId = elderId;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getAttachmentUrl() {
|
||||
return attachmentUrl;
|
||||
}
|
||||
|
||||
public void setAttachmentUrl(String attachmentUrl) {
|
||||
this.attachmentUrl = attachmentUrl;
|
||||
}
|
||||
|
||||
public LocalDateTime getRecordTime() {
|
||||
return recordTime;
|
||||
}
|
||||
|
||||
public void setRecordTime(LocalDateTime recordTime) {
|
||||
this.recordTime = recordTime;
|
||||
}
|
||||
}
|
||||
96
backend/src/main/java/com/nursinghome/dto/ElderRequest.java
Normal file
96
backend/src/main/java/com/nursinghome/dto/ElderRequest.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class ElderRequest {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String gender;
|
||||
private String idCard;
|
||||
private LocalDate birthday;
|
||||
private String roomNo;
|
||||
private LocalDate checkInDate;
|
||||
private String careLevel;
|
||||
private String status;
|
||||
private String remark;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getIdCard() {
|
||||
return idCard;
|
||||
}
|
||||
|
||||
public void setIdCard(String idCard) {
|
||||
this.idCard = idCard;
|
||||
}
|
||||
|
||||
public java.time.LocalDate getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(java.time.LocalDate birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getRoomNo() {
|
||||
return roomNo;
|
||||
}
|
||||
|
||||
public void setRoomNo(String roomNo) {
|
||||
this.roomNo = roomNo;
|
||||
}
|
||||
|
||||
public java.time.LocalDate getCheckInDate() {
|
||||
return checkInDate;
|
||||
}
|
||||
|
||||
public void setCheckInDate(java.time.LocalDate checkInDate) {
|
||||
this.checkInDate = checkInDate;
|
||||
}
|
||||
|
||||
public String getCareLevel() {
|
||||
return careLevel;
|
||||
}
|
||||
|
||||
public void setCareLevel(String careLevel) {
|
||||
this.careLevel = careLevel;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
public class FeedbackRequest {
|
||||
private Long elderId;
|
||||
private String type;
|
||||
private String content;
|
||||
private Integer rating;
|
||||
|
||||
public Long getElderId() {
|
||||
return elderId;
|
||||
}
|
||||
|
||||
public void setElderId(Long elderId) {
|
||||
this.elderId = elderId;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Integer getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
||||
public void setRating(Integer rating) {
|
||||
this.rating = rating;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
public class FeedbackUpdateRequest {
|
||||
private Long id;
|
||||
private String status;
|
||||
private String reply;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getReply() {
|
||||
return reply;
|
||||
}
|
||||
|
||||
public void setReply(String reply) {
|
||||
this.reply = reply;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class HandoverRequest {
|
||||
private LocalDate date;
|
||||
private String content;
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class HealthRecordRequest {
|
||||
private Long elderId;
|
||||
private BigDecimal temperature;
|
||||
private Integer bpSystolic;
|
||||
private Integer bpDiastolic;
|
||||
private Integer heartRate;
|
||||
private String note;
|
||||
private LocalDateTime recordTime;
|
||||
|
||||
public Long getElderId() {
|
||||
return elderId;
|
||||
}
|
||||
|
||||
public void setElderId(Long elderId) {
|
||||
this.elderId = elderId;
|
||||
}
|
||||
|
||||
public BigDecimal getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
public void setTemperature(BigDecimal temperature) {
|
||||
this.temperature = temperature;
|
||||
}
|
||||
|
||||
public Integer getBpSystolic() {
|
||||
return bpSystolic;
|
||||
}
|
||||
|
||||
public void setBpSystolic(Integer bpSystolic) {
|
||||
this.bpSystolic = bpSystolic;
|
||||
}
|
||||
|
||||
public Integer getBpDiastolic() {
|
||||
return bpDiastolic;
|
||||
}
|
||||
|
||||
public void setBpDiastolic(Integer bpDiastolic) {
|
||||
this.bpDiastolic = bpDiastolic;
|
||||
}
|
||||
|
||||
public Integer getHeartRate() {
|
||||
return heartRate;
|
||||
}
|
||||
|
||||
public void setHeartRate(Integer heartRate) {
|
||||
this.heartRate = heartRate;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public LocalDateTime getRecordTime() {
|
||||
return recordTime;
|
||||
}
|
||||
|
||||
public void setRecordTime(LocalDateTime recordTime) {
|
||||
this.recordTime = recordTime;
|
||||
}
|
||||
}
|
||||
26
backend/src/main/java/com/nursinghome/dto/LoginRequest.java
Normal file
26
backend/src/main/java/com/nursinghome/dto/LoginRequest.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public class LoginRequest {
|
||||
@NotBlank(message = "username required")
|
||||
private String username;
|
||||
@NotBlank(message = "password required")
|
||||
private String password;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
40
backend/src/main/java/com/nursinghome/dto/NoticeRequest.java
Normal file
40
backend/src/main/java/com/nursinghome/dto/NoticeRequest.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
public class NoticeRequest {
|
||||
private String title;
|
||||
private String content;
|
||||
private String targetRole;
|
||||
private Long targetUserId;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getTargetRole() {
|
||||
return targetRole;
|
||||
}
|
||||
|
||||
public void setTargetRole(String targetRole) {
|
||||
this.targetRole = targetRole;
|
||||
}
|
||||
|
||||
public Long getTargetUserId() {
|
||||
return targetUserId;
|
||||
}
|
||||
|
||||
public void setTargetUserId(Long targetUserId) {
|
||||
this.targetUserId = targetUserId;
|
||||
}
|
||||
}
|
||||
13
backend/src/main/java/com/nursinghome/dto/PayRequest.java
Normal file
13
backend/src/main/java/com/nursinghome/dto/PayRequest.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
public class PayRequest {
|
||||
private String method;
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public class RegisterRequest {
|
||||
@NotBlank(message = "username required")
|
||||
private String username;
|
||||
@NotBlank(message = "password required")
|
||||
private String password;
|
||||
@NotBlank(message = "name required")
|
||||
private String name;
|
||||
private String phone;
|
||||
@NotBlank(message = "elderIdCard required")
|
||||
private String elderIdCard;
|
||||
private String relationship;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getElderIdCard() {
|
||||
return elderIdCard;
|
||||
}
|
||||
|
||||
public void setElderIdCard(String elderIdCard) {
|
||||
this.elderIdCard = elderIdCard;
|
||||
}
|
||||
|
||||
public String getRelationship() {
|
||||
return relationship;
|
||||
}
|
||||
|
||||
public void setRelationship(String relationship) {
|
||||
this.relationship = relationship;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class ScheduleRequest {
|
||||
private Long id;
|
||||
private Long nurseId;
|
||||
private LocalDate date;
|
||||
private String shift;
|
||||
private String task;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getNurseId() {
|
||||
return nurseId;
|
||||
}
|
||||
|
||||
public void setNurseId(Long nurseId) {
|
||||
this.nurseId = nurseId;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getShift() {
|
||||
return shift;
|
||||
}
|
||||
|
||||
public void setShift(String shift) {
|
||||
this.shift = shift;
|
||||
}
|
||||
|
||||
public String getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
public void setTask(String task) {
|
||||
this.task = task;
|
||||
}
|
||||
}
|
||||
58
backend/src/main/java/com/nursinghome/dto/UserRequest.java
Normal file
58
backend/src/main/java/com/nursinghome/dto/UserRequest.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
public class UserRequest {
|
||||
private String username;
|
||||
private String password;
|
||||
private String name;
|
||||
private String phone;
|
||||
private String role;
|
||||
private Integer status;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.nursinghome.dto;
|
||||
|
||||
public class UserUpdateRequest {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String phone;
|
||||
private Integer status;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
106
backend/src/main/java/com/nursinghome/entity/Bill.java
Normal file
106
backend/src/main/java/com/nursinghome/entity/Bill.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package com.nursinghome.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Bill {
|
||||
private Long id;
|
||||
private Long elderId;
|
||||
private String month;
|
||||
private BigDecimal bedFee;
|
||||
private BigDecimal careFee;
|
||||
private BigDecimal mealFee;
|
||||
private BigDecimal otherFee;
|
||||
private BigDecimal total;
|
||||
private String status;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime paidAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getElderId() {
|
||||
return elderId;
|
||||
}
|
||||
|
||||
public void setElderId(Long elderId) {
|
||||
this.elderId = elderId;
|
||||
}
|
||||
|
||||
public String getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth(String month) {
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public BigDecimal getBedFee() {
|
||||
return bedFee;
|
||||
}
|
||||
|
||||
public void setBedFee(BigDecimal bedFee) {
|
||||
this.bedFee = bedFee;
|
||||
}
|
||||
|
||||
public BigDecimal getCareFee() {
|
||||
return careFee;
|
||||
}
|
||||
|
||||
public void setCareFee(BigDecimal careFee) {
|
||||
this.careFee = careFee;
|
||||
}
|
||||
|
||||
public BigDecimal getMealFee() {
|
||||
return mealFee;
|
||||
}
|
||||
|
||||
public void setMealFee(BigDecimal mealFee) {
|
||||
this.mealFee = mealFee;
|
||||
}
|
||||
|
||||
public BigDecimal getOtherFee() {
|
||||
return otherFee;
|
||||
}
|
||||
|
||||
public void setOtherFee(BigDecimal otherFee) {
|
||||
this.otherFee = otherFee;
|
||||
}
|
||||
|
||||
public BigDecimal getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(BigDecimal total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getPaidAt() {
|
||||
return paidAt;
|
||||
}
|
||||
|
||||
public void setPaidAt(LocalDateTime paidAt) {
|
||||
this.paidAt = paidAt;
|
||||
}
|
||||
}
|
||||
69
backend/src/main/java/com/nursinghome/entity/CareRecord.java
Normal file
69
backend/src/main/java/com/nursinghome/entity/CareRecord.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package com.nursinghome.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class CareRecord {
|
||||
private Long id;
|
||||
private Long elderId;
|
||||
private Long nurseId;
|
||||
private String content;
|
||||
private String attachmentUrl;
|
||||
private LocalDateTime recordTime;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getElderId() {
|
||||
return elderId;
|
||||
}
|
||||
|
||||
public void setElderId(Long elderId) {
|
||||
this.elderId = elderId;
|
||||
}
|
||||
|
||||
public Long getNurseId() {
|
||||
return nurseId;
|
||||
}
|
||||
|
||||
public void setNurseId(Long nurseId) {
|
||||
this.nurseId = nurseId;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getAttachmentUrl() {
|
||||
return attachmentUrl;
|
||||
}
|
||||
|
||||
public void setAttachmentUrl(String attachmentUrl) {
|
||||
this.attachmentUrl = attachmentUrl;
|
||||
}
|
||||
|
||||
public LocalDateTime getRecordTime() {
|
||||
return recordTime;
|
||||
}
|
||||
|
||||
public void setRecordTime(LocalDateTime recordTime) {
|
||||
this.recordTime = recordTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
||||
96
backend/src/main/java/com/nursinghome/entity/Elder.java
Normal file
96
backend/src/main/java/com/nursinghome/entity/Elder.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package com.nursinghome.entity;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class Elder {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String gender;
|
||||
private String idCard;
|
||||
private LocalDate birthday;
|
||||
private String roomNo;
|
||||
private LocalDate checkInDate;
|
||||
private String careLevel;
|
||||
private String status;
|
||||
private String remark;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getIdCard() {
|
||||
return idCard;
|
||||
}
|
||||
|
||||
public void setIdCard(String idCard) {
|
||||
this.idCard = idCard;
|
||||
}
|
||||
|
||||
public LocalDate getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(LocalDate birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public String getRoomNo() {
|
||||
return roomNo;
|
||||
}
|
||||
|
||||
public void setRoomNo(String roomNo) {
|
||||
this.roomNo = roomNo;
|
||||
}
|
||||
|
||||
public LocalDate getCheckInDate() {
|
||||
return checkInDate;
|
||||
}
|
||||
|
||||
public void setCheckInDate(LocalDate checkInDate) {
|
||||
this.checkInDate = checkInDate;
|
||||
}
|
||||
|
||||
public String getCareLevel() {
|
||||
return careLevel;
|
||||
}
|
||||
|
||||
public void setCareLevel(String careLevel) {
|
||||
this.careLevel = careLevel;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.nursinghome.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class FamilyElder {
|
||||
private Long id;
|
||||
private Long familyId;
|
||||
private Long elderId;
|
||||
private String relationship;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getFamilyId() {
|
||||
return familyId;
|
||||
}
|
||||
|
||||
public void setFamilyId(Long familyId) {
|
||||
this.familyId = familyId;
|
||||
}
|
||||
|
||||
public Long getElderId() {
|
||||
return elderId;
|
||||
}
|
||||
|
||||
public void setElderId(Long elderId) {
|
||||
this.elderId = elderId;
|
||||
}
|
||||
|
||||
public String getRelationship() {
|
||||
return relationship;
|
||||
}
|
||||
|
||||
public void setRelationship(String relationship) {
|
||||
this.relationship = relationship;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
||||
96
backend/src/main/java/com/nursinghome/entity/Feedback.java
Normal file
96
backend/src/main/java/com/nursinghome/entity/Feedback.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package com.nursinghome.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Feedback {
|
||||
private Long id;
|
||||
private Long familyId;
|
||||
private Long elderId;
|
||||
private String type;
|
||||
private String content;
|
||||
private Integer rating;
|
||||
private String status;
|
||||
private String reply;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getFamilyId() {
|
||||
return familyId;
|
||||
}
|
||||
|
||||
public void setFamilyId(Long familyId) {
|
||||
this.familyId = familyId;
|
||||
}
|
||||
|
||||
public Long getElderId() {
|
||||
return elderId;
|
||||
}
|
||||
|
||||
public void setElderId(Long elderId) {
|
||||
this.elderId = elderId;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Integer getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
||||
public void setRating(Integer rating) {
|
||||
this.rating = rating;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getReply() {
|
||||
return reply;
|
||||
}
|
||||
|
||||
public void setReply(String reply) {
|
||||
this.reply = reply;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
}
|
||||
52
backend/src/main/java/com/nursinghome/entity/Handover.java
Normal file
52
backend/src/main/java/com/nursinghome/entity/Handover.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package com.nursinghome.entity;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Handover {
|
||||
private Long id;
|
||||
private Long nurseId;
|
||||
private LocalDate date;
|
||||
private String content;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getNurseId() {
|
||||
return nurseId;
|
||||
}
|
||||
|
||||
public void setNurseId(Long nurseId) {
|
||||
this.nurseId = nurseId;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.nursinghome.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class HealthRecord {
|
||||
private Long id;
|
||||
private Long elderId;
|
||||
private Long nurseId;
|
||||
private BigDecimal temperature;
|
||||
private Integer bpSystolic;
|
||||
private Integer bpDiastolic;
|
||||
private Integer heartRate;
|
||||
private String note;
|
||||
private LocalDateTime recordTime;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getElderId() {
|
||||
return elderId;
|
||||
}
|
||||
|
||||
public void setElderId(Long elderId) {
|
||||
this.elderId = elderId;
|
||||
}
|
||||
|
||||
public Long getNurseId() {
|
||||
return nurseId;
|
||||
}
|
||||
|
||||
public void setNurseId(Long nurseId) {
|
||||
this.nurseId = nurseId;
|
||||
}
|
||||
|
||||
public BigDecimal getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
public void setTemperature(BigDecimal temperature) {
|
||||
this.temperature = temperature;
|
||||
}
|
||||
|
||||
public Integer getBpSystolic() {
|
||||
return bpSystolic;
|
||||
}
|
||||
|
||||
public void setBpSystolic(Integer bpSystolic) {
|
||||
this.bpSystolic = bpSystolic;
|
||||
}
|
||||
|
||||
public Integer getBpDiastolic() {
|
||||
return bpDiastolic;
|
||||
}
|
||||
|
||||
public void setBpDiastolic(Integer bpDiastolic) {
|
||||
this.bpDiastolic = bpDiastolic;
|
||||
}
|
||||
|
||||
public Integer getHeartRate() {
|
||||
return heartRate;
|
||||
}
|
||||
|
||||
public void setHeartRate(Integer heartRate) {
|
||||
this.heartRate = heartRate;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public LocalDateTime getRecordTime() {
|
||||
return recordTime;
|
||||
}
|
||||
|
||||
public void setRecordTime(LocalDateTime recordTime) {
|
||||
this.recordTime = recordTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
||||
69
backend/src/main/java/com/nursinghome/entity/Notice.java
Normal file
69
backend/src/main/java/com/nursinghome/entity/Notice.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package com.nursinghome.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Notice {
|
||||
private Long id;
|
||||
private String title;
|
||||
private String content;
|
||||
private String targetRole;
|
||||
private Long targetUserId;
|
||||
private Long createdBy;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getTargetRole() {
|
||||
return targetRole;
|
||||
}
|
||||
|
||||
public void setTargetRole(String targetRole) {
|
||||
this.targetRole = targetRole;
|
||||
}
|
||||
|
||||
public Long getTargetUserId() {
|
||||
return targetUserId;
|
||||
}
|
||||
|
||||
public void setTargetUserId(Long targetUserId) {
|
||||
this.targetUserId = targetUserId;
|
||||
}
|
||||
|
||||
public Long getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(Long createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.nursinghome.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class PaymentRecord {
|
||||
private Long id;
|
||||
private Long billId;
|
||||
private Long familyId;
|
||||
private BigDecimal amount;
|
||||
private String method;
|
||||
private LocalDateTime paidAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getBillId() {
|
||||
return billId;
|
||||
}
|
||||
|
||||
public void setBillId(Long billId) {
|
||||
this.billId = billId;
|
||||
}
|
||||
|
||||
public Long getFamilyId() {
|
||||
return familyId;
|
||||
}
|
||||
|
||||
public void setFamilyId(Long familyId) {
|
||||
this.familyId = familyId;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(BigDecimal amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public LocalDateTime getPaidAt() {
|
||||
return paidAt;
|
||||
}
|
||||
|
||||
public void setPaidAt(LocalDateTime paidAt) {
|
||||
this.paidAt = paidAt;
|
||||
}
|
||||
}
|
||||
70
backend/src/main/java/com/nursinghome/entity/Schedule.java
Normal file
70
backend/src/main/java/com/nursinghome/entity/Schedule.java
Normal file
@@ -0,0 +1,70 @@
|
||||
package com.nursinghome.entity;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Schedule {
|
||||
private Long id;
|
||||
private Long nurseId;
|
||||
private LocalDate date;
|
||||
private String shift;
|
||||
private String task;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getNurseId() {
|
||||
return nurseId;
|
||||
}
|
||||
|
||||
public void setNurseId(Long nurseId) {
|
||||
this.nurseId = nurseId;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getShift() {
|
||||
return shift;
|
||||
}
|
||||
|
||||
public void setShift(String shift) {
|
||||
this.shift = shift;
|
||||
}
|
||||
|
||||
public String getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
public void setTask(String task) {
|
||||
this.task = task;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
}
|
||||
87
backend/src/main/java/com/nursinghome/entity/User.java
Normal file
87
backend/src/main/java/com/nursinghome/entity/User.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.nursinghome.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class User {
|
||||
private Long id;
|
||||
private String username;
|
||||
private String password;
|
||||
private String name;
|
||||
private String phone;
|
||||
private String role;
|
||||
private Integer status;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
}
|
||||
28
backend/src/main/java/com/nursinghome/mapper/BillMapper.java
Normal file
28
backend/src/main/java/com/nursinghome/mapper/BillMapper.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.nursinghome.mapper;
|
||||
|
||||
import com.nursinghome.entity.Bill;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BillMapper {
|
||||
@Insert("INSERT INTO bill(elder_id, month, bed_fee, care_fee, meal_fee, other_fee, total, status, created_at) VALUES(#{elderId}, #{month}, #{bedFee}, #{careFee}, #{mealFee}, #{otherFee}, #{total}, #{status}, NOW())")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(Bill bill);
|
||||
|
||||
@Select("SELECT * FROM bill ORDER BY month DESC")
|
||||
List<Bill> listAll();
|
||||
|
||||
@Select("SELECT * FROM bill WHERE id = #{id}")
|
||||
Bill findById(Long id);
|
||||
|
||||
@Select("SELECT * FROM bill WHERE elder_id = #{elderId} ORDER BY month DESC")
|
||||
List<Bill> listByElderId(Long elderId);
|
||||
|
||||
@Select("<script>SELECT * FROM bill WHERE elder_id IN <foreach collection='elderIds' item='id' open='(' separator=',' close=')'>#{id}</foreach> ORDER BY month DESC</script>")
|
||||
List<Bill> listByElderIds(@Param("elderIds") List<Long> elderIds);
|
||||
|
||||
@Update("UPDATE bill SET status=#{status}, paid_at=#{paidAt} WHERE id=#{id}")
|
||||
int updateStatus(Bill bill);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.nursinghome.mapper;
|
||||
|
||||
import com.nursinghome.entity.CareRecord;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CareRecordMapper {
|
||||
@Insert("INSERT INTO care_record(elder_id, nurse_id, content, attachment_url, record_time, created_at) VALUES(#{elderId}, #{nurseId}, #{content}, #{attachmentUrl}, #{recordTime}, NOW())")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(CareRecord record);
|
||||
|
||||
@Select("SELECT * FROM care_record WHERE elder_id = #{elderId} ORDER BY record_time DESC")
|
||||
List<CareRecord> listByElderId(Long elderId);
|
||||
|
||||
@Select("<script>SELECT * FROM care_record WHERE elder_id IN <foreach collection='elderIds' item='id' open='(' separator=',' close=')'>#{id}</foreach> ORDER BY record_time DESC</script>")
|
||||
List<CareRecord> listByElderIds(@Param("elderIds") List<Long> elderIds);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.nursinghome.mapper;
|
||||
|
||||
import com.nursinghome.entity.Elder;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ElderMapper {
|
||||
@Select("SELECT * FROM elder ORDER BY id DESC")
|
||||
List<Elder> listAll();
|
||||
|
||||
@Select("SELECT * FROM elder WHERE id = #{id}")
|
||||
Elder findById(Long id);
|
||||
|
||||
@Select("SELECT * FROM elder WHERE id_card = #{idCard} LIMIT 1")
|
||||
Elder findByIdCard(String idCard);
|
||||
|
||||
@Insert("INSERT INTO elder(name, gender, id_card, birthday, room_no, check_in_date, care_level, status, remark) VALUES(#{name}, #{gender}, #{idCard}, #{birthday}, #{roomNo}, #{checkInDate}, #{careLevel}, #{status}, #{remark})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(Elder elder);
|
||||
|
||||
@Update("UPDATE elder SET name=#{name}, gender=#{gender}, id_card=#{idCard}, birthday=#{birthday}, room_no=#{roomNo}, check_in_date=#{checkInDate}, care_level=#{careLevel}, status=#{status}, remark=#{remark} WHERE id=#{id}")
|
||||
int update(Elder elder);
|
||||
|
||||
@Delete("DELETE FROM elder WHERE id=#{id}")
|
||||
int delete(Long id);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.nursinghome.mapper;
|
||||
|
||||
import com.nursinghome.entity.FamilyElder;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface FamilyElderMapper {
|
||||
@Insert("INSERT INTO family_elder(family_id, elder_id, relationship, created_at) VALUES(#{familyId}, #{elderId}, #{relationship}, NOW())")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(FamilyElder relation);
|
||||
|
||||
@Select("SELECT * FROM family_elder WHERE family_id = #{familyId}")
|
||||
List<FamilyElder> listByFamilyId(Long familyId);
|
||||
|
||||
@Select("SELECT * FROM family_elder WHERE family_id = #{familyId} AND elder_id = #{elderId} LIMIT 1")
|
||||
FamilyElder findByFamilyAndElder(@Param("familyId") Long familyId, @Param("elderId") Long elderId);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.nursinghome.mapper;
|
||||
|
||||
import com.nursinghome.entity.Feedback;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface FeedbackMapper {
|
||||
@Insert("INSERT INTO feedback(family_id, elder_id, type, content, rating, status, created_at, updated_at) VALUES(#{familyId}, #{elderId}, #{type}, #{content}, #{rating}, #{status}, NOW(), NOW())")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(Feedback feedback);
|
||||
|
||||
@Select("SELECT * FROM feedback ORDER BY created_at DESC")
|
||||
List<Feedback> listAll();
|
||||
|
||||
@Update("UPDATE feedback SET status=#{status}, reply=#{reply}, updated_at=NOW() WHERE id=#{id}")
|
||||
int updateStatus(Feedback feedback);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.nursinghome.mapper;
|
||||
|
||||
import com.nursinghome.entity.Handover;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface HandoverMapper {
|
||||
@Insert("INSERT INTO handover(nurse_id, date, content, created_at) VALUES(#{nurseId}, #{date}, #{content}, NOW())")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(Handover handover);
|
||||
|
||||
@Select("SELECT * FROM handover WHERE nurse_id = #{nurseId} ORDER BY date DESC")
|
||||
List<Handover> listByNurseId(Long nurseId);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.nursinghome.mapper;
|
||||
|
||||
import com.nursinghome.entity.HealthRecord;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface HealthRecordMapper {
|
||||
@Insert("INSERT INTO health_record(elder_id, nurse_id, temperature, bp_systolic, bp_diastolic, heart_rate, note, record_time, created_at) VALUES(#{elderId}, #{nurseId}, #{temperature}, #{bpSystolic}, #{bpDiastolic}, #{heartRate}, #{note}, #{recordTime}, NOW())")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(HealthRecord record);
|
||||
|
||||
@Select("SELECT * FROM health_record WHERE elder_id = #{elderId} ORDER BY record_time DESC")
|
||||
List<HealthRecord> listByElderId(Long elderId);
|
||||
|
||||
@Select("<script>SELECT * FROM health_record WHERE elder_id IN <foreach collection='elderIds' item='id' open='(' separator=',' close=')'>#{id}</foreach> ORDER BY record_time DESC</script>")
|
||||
List<HealthRecord> listByElderIds(@Param("elderIds") List<Long> elderIds);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.nursinghome.mapper;
|
||||
|
||||
import com.nursinghome.entity.Notice;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface NoticeMapper {
|
||||
@Insert("INSERT INTO notice(title, content, target_role, target_user_id, created_by, created_at) VALUES(#{title}, #{content}, #{targetRole}, #{targetUserId}, #{createdBy}, NOW())")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(Notice notice);
|
||||
|
||||
@Select("<script>SELECT * FROM notice WHERE 1=1 <if test='targetUserId != null'> AND target_user_id = #{targetUserId}</if> <if test='targetRole != null'> AND (target_role = #{targetRole} OR target_role = 'ALL')</if> ORDER BY created_at DESC</script>")
|
||||
List<Notice> listByTarget(@Param("targetRole") String targetRole, @Param("targetUserId") Long targetUserId);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.nursinghome.mapper;
|
||||
|
||||
import com.nursinghome.entity.PaymentRecord;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PaymentRecordMapper {
|
||||
@Insert("INSERT INTO payment_record(bill_id, family_id, amount, method, paid_at) VALUES(#{billId}, #{familyId}, #{amount}, #{method}, #{paidAt})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(PaymentRecord record);
|
||||
|
||||
@Select("SELECT * FROM payment_record WHERE bill_id = #{billId} ORDER BY paid_at DESC")
|
||||
List<PaymentRecord> listByBillId(Long billId);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.nursinghome.mapper;
|
||||
|
||||
import com.nursinghome.entity.Schedule;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ScheduleMapper {
|
||||
@Select("SELECT * FROM schedule WHERE nurse_id = #{nurseId} AND date = #{date} ORDER BY id DESC")
|
||||
List<Schedule> listByNurseAndDate(@Param("nurseId") Long nurseId, @Param("date") LocalDate date);
|
||||
|
||||
@Select("SELECT * FROM schedule WHERE date = #{date} ORDER BY id DESC")
|
||||
List<Schedule> listByDate(LocalDate date);
|
||||
|
||||
@Insert("INSERT INTO schedule(nurse_id, date, shift, task, created_at, updated_at) VALUES(#{nurseId}, #{date}, #{shift}, #{task}, NOW(), NOW())")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(Schedule schedule);
|
||||
|
||||
@Update("UPDATE schedule SET nurse_id=#{nurseId}, date=#{date}, shift=#{shift}, task=#{task}, updated_at=NOW() WHERE id=#{id}")
|
||||
int update(Schedule schedule);
|
||||
|
||||
@Delete("DELETE FROM schedule WHERE id=#{id}")
|
||||
int delete(Long id);
|
||||
}
|
||||
31
backend/src/main/java/com/nursinghome/mapper/UserMapper.java
Normal file
31
backend/src/main/java/com/nursinghome/mapper/UserMapper.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.nursinghome.mapper;
|
||||
|
||||
import com.nursinghome.entity.User;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper {
|
||||
@Select("SELECT * FROM sys_user WHERE username = #{username} LIMIT 1")
|
||||
User findByUsername(String username);
|
||||
|
||||
@Select("SELECT * FROM sys_user WHERE id = #{id}")
|
||||
User findById(Long id);
|
||||
|
||||
@Select("<script>SELECT * FROM sys_user <where><if test='role != null'>role = #{role}</if></where> ORDER BY id DESC</script>")
|
||||
List<User> listByRole(@Param("role") String role);
|
||||
|
||||
@Insert("INSERT INTO sys_user(username, password, name, phone, role, status, created_at, updated_at) VALUES(#{username}, #{password}, #{name}, #{phone}, #{role}, #{status}, NOW(), NOW())")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(User user);
|
||||
|
||||
@Update("UPDATE sys_user SET name=#{name}, phone=#{phone}, status=#{status}, updated_at=NOW() WHERE id=#{id}")
|
||||
int update(User user);
|
||||
|
||||
@Update("UPDATE sys_user SET password=#{password}, updated_at=NOW() WHERE id=#{id}")
|
||||
int updatePassword(@Param("id") Long id, @Param("password") String password);
|
||||
|
||||
@Update("UPDATE sys_user SET status=#{status}, updated_at=NOW() WHERE id=#{id}")
|
||||
int updateStatus(@Param("id") Long id, @Param("status") Integer status);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.nursinghome.service;
|
||||
|
||||
import com.nursinghome.entity.Bill;
|
||||
import com.nursinghome.entity.PaymentRecord;
|
||||
import com.nursinghome.mapper.BillMapper;
|
||||
import com.nursinghome.mapper.PaymentRecordMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class BillService {
|
||||
private final BillMapper billMapper;
|
||||
private final PaymentRecordMapper paymentRecordMapper;
|
||||
|
||||
public BillService(BillMapper billMapper, PaymentRecordMapper paymentRecordMapper) {
|
||||
this.billMapper = billMapper;
|
||||
this.paymentRecordMapper = paymentRecordMapper;
|
||||
}
|
||||
|
||||
public Bill createBill(Bill bill) {
|
||||
if (bill.getTotal() == null) {
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
if (bill.getBedFee() != null) total = total.add(bill.getBedFee());
|
||||
if (bill.getCareFee() != null) total = total.add(bill.getCareFee());
|
||||
if (bill.getMealFee() != null) total = total.add(bill.getMealFee());
|
||||
if (bill.getOtherFee() != null) total = total.add(bill.getOtherFee());
|
||||
bill.setTotal(total);
|
||||
}
|
||||
if (bill.getStatus() == null) {
|
||||
bill.setStatus("UNPAID");
|
||||
}
|
||||
billMapper.insert(bill);
|
||||
return bill;
|
||||
}
|
||||
|
||||
public List<Bill> listByElderId(Long elderId) {
|
||||
return billMapper.listByElderId(elderId);
|
||||
}
|
||||
|
||||
public List<Bill> listByElderIds(List<Long> elderIds) {
|
||||
return billMapper.listByElderIds(elderIds);
|
||||
}
|
||||
|
||||
public void payBill(Long billId, Long familyId, String method, BigDecimal amount) {
|
||||
Bill bill = new Bill();
|
||||
bill.setId(billId);
|
||||
bill.setStatus("PAID");
|
||||
bill.setPaidAt(LocalDateTime.now());
|
||||
billMapper.updateStatus(bill);
|
||||
|
||||
PaymentRecord record = new PaymentRecord();
|
||||
record.setBillId(billId);
|
||||
record.setFamilyId(familyId);
|
||||
record.setAmount(amount);
|
||||
record.setMethod(method);
|
||||
record.setPaidAt(LocalDateTime.now());
|
||||
paymentRecordMapper.insert(record);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.nursinghome.service;
|
||||
|
||||
import com.nursinghome.common.ApiException;
|
||||
import com.nursinghome.entity.Elder;
|
||||
import com.nursinghome.mapper.ElderMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ElderService {
|
||||
private final ElderMapper elderMapper;
|
||||
|
||||
public ElderService(ElderMapper elderMapper) {
|
||||
this.elderMapper = elderMapper;
|
||||
}
|
||||
|
||||
public List<Elder> listAll() {
|
||||
return elderMapper.listAll();
|
||||
}
|
||||
|
||||
public Elder findById(Long id) {
|
||||
return elderMapper.findById(id);
|
||||
}
|
||||
|
||||
public Elder findByIdCard(String idCard) {
|
||||
return elderMapper.findByIdCard(idCard);
|
||||
}
|
||||
|
||||
public Elder create(Elder elder) {
|
||||
if (elderMapper.findByIdCard(elder.getIdCard()) != null) {
|
||||
throw new ApiException("id card already exists");
|
||||
}
|
||||
elderMapper.insert(elder);
|
||||
return elder;
|
||||
}
|
||||
|
||||
public void update(Elder elder) {
|
||||
elderMapper.update(elder);
|
||||
}
|
||||
|
||||
public void delete(Long id) {
|
||||
elderMapper.delete(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.nursinghome.service;
|
||||
|
||||
import com.nursinghome.common.ApiException;
|
||||
import com.nursinghome.entity.Elder;
|
||||
import com.nursinghome.entity.FamilyElder;
|
||||
import com.nursinghome.entity.User;
|
||||
import com.nursinghome.mapper.FamilyElderMapper;
|
||||
import com.nursinghome.util.PasswordUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FamilyService {
|
||||
private final UserService userService;
|
||||
private final ElderService elderService;
|
||||
private final FamilyElderMapper familyElderMapper;
|
||||
|
||||
public FamilyService(UserService userService, ElderService elderService, FamilyElderMapper familyElderMapper) {
|
||||
this.userService = userService;
|
||||
this.elderService = elderService;
|
||||
this.familyElderMapper = familyElderMapper;
|
||||
}
|
||||
|
||||
public User registerFamily(String username, String password, String name, String phone, String elderIdCard, String relationship) {
|
||||
Elder elder = elderService.findByIdCard(elderIdCard);
|
||||
if (elder == null) {
|
||||
throw new ApiException("elder not found");
|
||||
}
|
||||
User user = new User();
|
||||
user.setUsername(username);
|
||||
user.setPassword(password);
|
||||
user.setName(name);
|
||||
user.setPhone(phone);
|
||||
user.setRole("FAMILY");
|
||||
user.setStatus(1);
|
||||
userService.createUser(user, true);
|
||||
|
||||
FamilyElder relation = new FamilyElder();
|
||||
relation.setFamilyId(user.getId());
|
||||
relation.setElderId(elder.getId());
|
||||
relation.setRelationship(relationship);
|
||||
familyElderMapper.insert(relation);
|
||||
return user;
|
||||
}
|
||||
|
||||
public List<FamilyElder> listRelations(Long familyId) {
|
||||
return familyElderMapper.listByFamilyId(familyId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.nursinghome.service;
|
||||
|
||||
import com.nursinghome.common.ApiException;
|
||||
import com.nursinghome.entity.User;
|
||||
import com.nursinghome.mapper.UserMapper;
|
||||
import com.nursinghome.util.PasswordUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
private final UserMapper userMapper;
|
||||
|
||||
public UserService(UserMapper userMapper) {
|
||||
this.userMapper = userMapper;
|
||||
}
|
||||
|
||||
public User findByUsername(String username) {
|
||||
return userMapper.findByUsername(username);
|
||||
}
|
||||
|
||||
public User findById(Long id) {
|
||||
return userMapper.findById(id);
|
||||
}
|
||||
|
||||
public List<User> listByRole(String role) {
|
||||
return userMapper.listByRole(role);
|
||||
}
|
||||
|
||||
public User createUser(User user, boolean hashPassword) {
|
||||
if (userMapper.findByUsername(user.getUsername()) != null) {
|
||||
throw new ApiException("username already exists");
|
||||
}
|
||||
if (hashPassword) {
|
||||
user.setPassword(PasswordUtil.hash(user.getPassword()));
|
||||
}
|
||||
if (user.getStatus() == null) {
|
||||
user.setStatus(1);
|
||||
}
|
||||
userMapper.insert(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
public void updateUser(User user) {
|
||||
userMapper.update(user);
|
||||
}
|
||||
|
||||
public void updateStatus(Long id, Integer status) {
|
||||
userMapper.updateStatus(id, status);
|
||||
}
|
||||
|
||||
public void updatePassword(Long id, String password) {
|
||||
userMapper.updatePassword(id, password);
|
||||
}
|
||||
}
|
||||
25
backend/src/main/java/com/nursinghome/util/PasswordUtil.java
Normal file
25
backend/src/main/java/com/nursinghome/util/PasswordUtil.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.nursinghome.util;
|
||||
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
public class PasswordUtil {
|
||||
private static final BCryptPasswordEncoder ENCODER = new BCryptPasswordEncoder();
|
||||
|
||||
public static String hash(String raw) {
|
||||
return ENCODER.encode(raw);
|
||||
}
|
||||
|
||||
public static boolean matches(String raw, String stored) {
|
||||
if (stored == null) {
|
||||
return false;
|
||||
}
|
||||
if (isBcrypt(stored)) {
|
||||
return ENCODER.matches(raw, stored);
|
||||
}
|
||||
return stored.equals(raw);
|
||||
}
|
||||
|
||||
public static boolean isBcrypt(String stored) {
|
||||
return stored != null && stored.startsWith("$2");
|
||||
}
|
||||
}
|
||||
28
backend/src/main/resources/application.yml
Normal file
28
backend/src/main/resources/application.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/nursing_home?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: root
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 10MB
|
||||
max-request-size: 20MB
|
||||
|
||||
mybatis:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
sa-token:
|
||||
token-name: satoken
|
||||
timeout: 86400
|
||||
activity-timeout: -1
|
||||
is-concurrent: true
|
||||
is-share: true
|
||||
token-style: uuid
|
||||
|
||||
app:
|
||||
upload-dir: uploads
|
||||
Reference in New Issue
Block a user