This commit is contained in:
王子琦
2026-02-09 21:14:30 +08:00
parent 09028d97f7
commit f9bfb8556b
54 changed files with 6963 additions and 461 deletions

View File

@@ -26,6 +26,8 @@ public class AppointmentController {
AuthUser user = SecurityUtils.currentUser();
if (user != null && "CUSTOMER".equals(user.getRole())) {
appointment.setCustomerId(user.getId());
} else if (appointment.getCustomerId() == null) {
return ApiResponse.error(400, "customerId required");
}
if (appointment.getStatus() == null) {
appointment.setStatus("PENDING");

View File

@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gpf.pethospital.common.ApiResponse;
import com.gpf.pethospital.entity.Notice;
import com.gpf.pethospital.security.AuthUser;
import com.gpf.pethospital.service.NoticeService;
import com.gpf.pethospital.util.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -42,6 +44,15 @@ public class NoticeController {
@PreAuthorize("hasRole('ADMIN')")
@PostMapping("/notices")
public ApiResponse<?> create(@RequestBody Notice notice) {
if (notice.getPublisherId() == null) {
AuthUser user = SecurityUtils.currentUser();
if (user != null) {
notice.setPublisherId(user.getId());
}
}
if (notice.getPublisherId() == null) {
return ApiResponse.error(400, "publisherId required");
}
if (notice.getStatus() == null) {
notice.setStatus(1);
}

View File

@@ -38,6 +38,8 @@ public class PetController {
AuthUser user = SecurityUtils.currentUser();
if (user != null && "CUSTOMER".equals(user.getRole())) {
pet.setOwnerId(user.getId());
} else if (pet.getOwnerId() == null) {
return ApiResponse.error(400, "ownerId required");
}
petService.save(pet);
return ApiResponse.success("created", null);

View File

@@ -55,8 +55,11 @@ public class StatsController {
wrapper.select("SUM(amount) AS total");
List<Map<String, Object>> result = orderService.listMaps(wrapper);
BigDecimal total = BigDecimal.ZERO;
if (!result.isEmpty() && result.get(0).get("total") != null) {
total = new BigDecimal(result.get(0).get("total").toString());
if (!result.isEmpty()) {
Map<String, Object> row = result.get(0);
if (row != null && row.get("total") != null) {
total = new BigDecimal(row.get("total").toString());
}
}
data.put("orderAmountTotal", total);
return ApiResponse.success(data);

View File

@@ -46,7 +46,8 @@ public class PrescriptionItem {
/**
* 用法用量
*/
private String usage;
@TableField("usage_desc")
private String usageDesc;
/**
* 用药天数

View File

@@ -9,9 +9,9 @@ spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/pet_hospital_dev?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
url: jdbc:mysql://localhost:3307/pet_hospital_dev?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
username: root
password: password
password: qq5211314
hikari:
maximum-pool-size: 20
minimum-idle: 10
@@ -30,7 +30,7 @@ spring:
sql:
init:
mode: always
mode: never
schema-locations: classpath*:schema.sql
data-locations: classpath*:data.sql

View File

@@ -58,7 +58,13 @@ CREATE TABLE IF NOT EXISTS prescription_item (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
prescription_id BIGINT NOT NULL,
drug_id BIGINT NOT NULL,
drug_name VARCHAR(100),
specification VARCHAR(100),
quantity INT NOT NULL,
usage_desc VARCHAR(200),
days INT,
unit_price DECIMAL(10,2),
subtotal DECIMAL(10,2),
dosage VARCHAR(100),
frequency VARCHAR(50),
duration VARCHAR(50),
@@ -92,6 +98,12 @@ CREATE TABLE IF NOT EXISTS drug (
specification VARCHAR(100),
unit_price DECIMAL(10,2),
stock_quantity INT DEFAULT 0,
stock INT DEFAULT 0,
alert_threshold INT,
purchase_price DECIMAL(10,2),
sale_price DECIMAL(10,2),
approval_number VARCHAR(100),
expiry_date TIMESTAMP NULL,
unit VARCHAR(20),
status INT DEFAULT 1,
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
@@ -150,6 +162,14 @@ CREATE TABLE IF NOT EXISTS `user` (
CREATE TABLE IF NOT EXISTS medical_record (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
visit_id BIGINT NOT NULL,
chief_complaint TEXT,
present_illness TEXT,
physical_examination TEXT,
examination_results TEXT,
diagnosis TEXT,
treatment_plan TEXT,
advice TEXT,
status VARCHAR(20),
record_type VARCHAR(50), -- CHECKUP体检, DIAGNOSIS诊断, TREATMENT治疗
content TEXT,
attachment_urls TEXT,
@@ -162,11 +182,18 @@ CREATE TABLE IF NOT EXISTS medical_record (
-- 检查并创建message表
CREATE TABLE IF NOT EXISTS message (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT,
user_name VARCHAR(100),
contact VARCHAR(100),
title VARCHAR(200),
sender_id BIGINT,
receiver_id BIGINT NOT NULL,
content TEXT NOT NULL,
type VARCHAR(20) DEFAULT 'NOTICE', -- NOTICE通知, CHAT聊天
status VARCHAR(20) DEFAULT 'UNREAD', -- UNREAD未读, READ已读
reply TEXT,
reply_time TIMESTAMP NULL,
reply_user_id BIGINT,
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
deleted INT DEFAULT 0
@@ -177,6 +204,7 @@ CREATE TABLE IF NOT EXISTS notice (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(200) NOT NULL,
content TEXT NOT NULL,
is_top INT DEFAULT 0,
publisher_id BIGINT NOT NULL,
publish_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
status INT DEFAULT 1,
@@ -188,6 +216,13 @@ CREATE TABLE IF NOT EXISTS notice (
-- 检查并创建report表
CREATE TABLE IF NOT EXISTS report (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
visit_id BIGINT,
pet_id BIGINT,
type VARCHAR(50),
title VARCHAR(200),
summary TEXT,
attachment_url VARCHAR(255),
doctor_id BIGINT,
report_type VARCHAR(50) NOT NULL, -- REVENUE收入, CUSTOMER客户, PET宠物, DRUG药品
report_data JSON,
period_start DATE,
@@ -206,6 +241,7 @@ CREATE TABLE IF NOT EXISTS stock_in (
unit_price DECIMAL(10,2),
supplier VARCHAR(100),
operator_id BIGINT,
stock_in_time TIMESTAMP NULL,
remark TEXT,
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
@@ -216,10 +252,12 @@ CREATE TABLE IF NOT EXISTS stock_in (
CREATE TABLE IF NOT EXISTS stock_out (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
drug_id BIGINT NOT NULL,
prescription_id BIGINT,
quantity INT NOT NULL,
unit_price DECIMAL(10,2),
purpose VARCHAR(100), -- 用途:销售、损耗等
operator_id BIGINT,
stock_out_time TIMESTAMP NULL,
remark TEXT,
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
@@ -230,6 +268,10 @@ CREATE TABLE IF NOT EXISTS stock_out (
CREATE TABLE IF NOT EXISTS vaccine_record (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
pet_id BIGINT NOT NULL,
type VARCHAR(20), -- VACCINE疫苗, DEWORMING驱虫
item_name VARCHAR(100),
execute_date DATE,
next_reminder_date DATE,
vaccine_name VARCHAR(100) NOT NULL,
dose_number INT,
injection_date DATE,
@@ -239,4 +281,4 @@ CREATE TABLE IF NOT EXISTS vaccine_record (
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
deleted INT DEFAULT 0
);
);