deploy: rebuild jar

This commit is contained in:
MaDaLei 2026-04-19 14:26:25 +08:00
parent 7ac2b27a83
commit 979c2a99e0
8 changed files with 109 additions and 33 deletions

View File

@ -1,7 +1,7 @@
# petstore-backend # petstore-backend
#### Description #### Description
伴生活馆 小它
#### Software Architecture #### Software Architecture
Software architecture description Software architecture description

View File

@ -1,7 +1,7 @@
# petstore-backend # petstore-backend
#### 介绍 #### 介绍
伴生活馆 小它
#### 软件架构 #### 软件架构
软件架构说明 软件架构说明

View File

@ -16,7 +16,7 @@
<version>1.0.0</version> <version>1.0.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>petstore-backend</name> <name>petstore-backend</name>
<description>伴生活馆 后端服务</description> <description>小它 后端服务|智慧宠物门店服务系统</description>
<properties> <properties>
<java.version>17</java.version> <java.version>17</java.version>

View File

@ -117,21 +117,13 @@ public class AppointmentController {
public Map<String, Object> start(@RequestBody Map<String, Object> params) { public Map<String, Object> start(@RequestBody Map<String, Object> params) {
Long appointmentId = Long.valueOf(params.get("appointmentId").toString()); Long appointmentId = Long.valueOf(params.get("appointmentId").toString());
Long staffUserId = Long.valueOf(params.get("staffUserId").toString()); Long staffUserId = Long.valueOf(params.get("staffUserId").toString());
Appointment updated = appointmentService.startService(appointmentId, staffUserId); return appointmentService.startService(appointmentId, staffUserId);
if (updated != null) {
return Map.of("code", 200, "message", "已开始服务", "data", updated);
}
return Map.of("code", 404, "message", "预约不存在");
} }
/** 更新预约状态 */ /** 更新预约状态(合法迁移见 AppointmentService.transitionStatus */
@PutMapping("/status") @PutMapping("/status")
public Map<String, Object> updateStatus(@RequestParam Long id, @RequestParam String status) { public Map<String, Object> updateStatus(@RequestParam Long id, @RequestParam String status) {
Appointment updated = appointmentService.updateStatus(id, status); return appointmentService.transitionStatus(id, status);
if (updated != null) {
return Map.of("code", 200, "message", "更新成功", "data", updated);
}
return Map.of("code", 404, "message", "预约不存在");
} }
@DeleteMapping("/delete") @DeleteMapping("/delete")

View File

@ -5,6 +5,8 @@ import com.petstore.entity.Report;
import com.petstore.entity.ReportImage; import com.petstore.entity.ReportImage;
import com.petstore.entity.Store; import com.petstore.entity.Store;
import com.petstore.entity.User; import com.petstore.entity.User;
import com.petstore.entity.Appointment;
import com.petstore.service.AppointmentService;
import com.petstore.service.ReportHighlightVideoService; import com.petstore.service.ReportHighlightVideoService;
import com.petstore.service.ReportService; import com.petstore.service.ReportService;
import com.petstore.service.ReportTestimonialService; import com.petstore.service.ReportTestimonialService;
@ -13,6 +15,8 @@ import com.petstore.service.UserService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@ -24,7 +28,9 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
@CrossOrigin @CrossOrigin
public class ReportController { public class ReportController {
private static final Logger log = LoggerFactory.getLogger(ReportController.class);
private final ReportService reportService; private final ReportService reportService;
private final AppointmentService appointmentService;
private final StoreService storeService; private final StoreService storeService;
private final ReportHighlightVideoService reportHighlightVideoService; private final ReportHighlightVideoService reportHighlightVideoService;
private final ReportTestimonialService reportTestimonialService; private final ReportTestimonialService reportTestimonialService;
@ -92,9 +98,39 @@ public class ReportController {
return reportHighlightVideoService.requestGenerate(reportId, operatorUserId, role, composeMode); return reportHighlightVideoService.requestGenerate(reportId, operatorUserId, role, composeMode);
} }
/**
* P0 埋点报告打开首访/再次当前写入应用日志便于日志平台统计不落库
*/
@PostMapping("/open-track")
public Map<String, Object> trackReportOpen(@RequestBody Map<String, Object> body) {
Object rawTok = body == null ? null : body.get("token");
String token = rawTok == null ? "" : rawTok.toString().trim();
if (token.isEmpty()) {
return Map.of("code", 400, "message", "token 必填");
}
String visitType = body.get("visitType") == null ? "" : body.get("visitType").toString();
String prefix = token.length() > 16 ? token.substring(0, 16) + "" : token;
log.info("report_open tokenPrefix={} visitType={}", prefix, visitType);
return Map.of("code", 200);
}
@PostMapping("/create") @PostMapping("/create")
public Map<String, Object> create(@RequestBody Report report) { public Map<String, Object> create(@RequestBody Report report) {
System.out.println(">>> Report create received: appointmentId=" + report.getAppointmentId() + ", userId=" + report.getUserId() + ", images count=" + (report.getImages() == null ? 0 : report.getImages().size())); System.out.println(">>> Report create received: appointmentId=" + report.getAppointmentId() + ", userId=" + report.getUserId() + ", images count=" + (report.getImages() == null ? 0 : report.getImages().size()));
if (report.getAppointmentId() != null) {
Appointment appt = appointmentService.getById(report.getAppointmentId());
if (appt == null) {
return Map.of("code", 404, "message", "关联预约不存在", "bizCode", "NOT_FOUND");
}
String st = appt.getStatus() == null ? "" : appt.getStatus().trim().toLowerCase();
if (!"doing".equals(st)) {
return Map.of(
"code", 400,
"message", "请先开始服务后再提交报告",
"bizCode", "INVALID_STATUS"
);
}
}
Report created = reportService.create(report); Report created = reportService.create(report);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();

View File

@ -35,7 +35,7 @@ public class SmsController {
// 阿里云示例 dysmsapi.aliyuncs.com // 阿里云示例 dysmsapi.aliyuncs.com
// 腾讯云示例 sms.tencentcloudapi.com // 腾讯云示例 sms.tencentcloudapi.com
System.out.println("【宠伴生活馆】验证码:" + code + "您正在登录5分钟内有效。"); System.out.println("【宠小它】验证码:" + code + "您正在登录5分钟内有效。");
result.put("code", 200); result.put("code", 200);
result.put("message", "发送成功"); result.put("message", "发送成功");

View File

@ -177,26 +177,72 @@ public class AppointmentService {
return ok; return ok;
} }
public Appointment updateStatus(Long id, String status) { /**
* 预约状态迁移PUT /appointment/status
* 允许newcanceldoingdonenewdoing 请走 {@link #startService}
*/
public Map<String, Object> transitionStatus(Long id, String nextStatus) {
Appointment appointment = appointmentMapper.findByIdAndDeletedFalse(id).orElse(null); Appointment appointment = appointmentMapper.findByIdAndDeletedFalse(id).orElse(null);
if (appointment != null) { if (appointment == null) {
appointment.setStatus(status); return Map.of("code", 404, "message", "预约不存在", "bizCode", "NOT_FOUND");
appointment.setUpdateTime(LocalDateTime.now());
return appointmentMapper.save(appointment);
} }
return null; if (nextStatus == null || nextStatus.isBlank()) {
return Map.of("code", 400, "message", "状态不能为空", "bizCode", "INVALID_STATUS");
}
String to = nextStatus.trim().toLowerCase();
String from = appointment.getStatus() == null ? "" : appointment.getStatus().trim().toLowerCase();
if ("cancel".equals(to)) {
if (!"new".equals(from)) {
return Map.of(
"code", 400,
"message", "仅待开始的预约可取消",
"bizCode", "CANCEL_NOT_ALLOWED"
);
}
} else if ("done".equals(to)) {
if (!"doing".equals(from)) {
return Map.of(
"code", 400,
"message", "仅进行中的预约可标记为已完成",
"bizCode", "INVALID_STATUS"
);
}
} else if ("doing".equals(to)) {
return Map.of(
"code", 400,
"message", "请使用「开始服务」接口将预约置为进行中",
"bizCode", "USE_START_ENDPOINT"
);
} else {
return Map.of("code", 400, "message", "不支持的状态变更", "bizCode", "INVALID_STATUS");
} }
/** 开始服务:状态变为进行中,同时指定技师为当前用户 */ appointment.setStatus(to);
public Appointment startService(Long appointmentId, Long staffUserId) { appointment.setUpdateTime(LocalDateTime.now());
Appointment saved = appointmentMapper.save(appointment);
return Map.of("code", 200, "message", "更新成功", "data", saved);
}
/** 开始服务:仅 new → doing并指定技师 */
public Map<String, Object> startService(Long appointmentId, Long staffUserId) {
Appointment appointment = appointmentMapper.findByIdAndDeletedFalse(appointmentId).orElse(null); Appointment appointment = appointmentMapper.findByIdAndDeletedFalse(appointmentId).orElse(null);
if (appointment != null) { if (appointment == null) {
return Map.of("code", 404, "message", "预约不存在", "bizCode", "NOT_FOUND");
}
String from = appointment.getStatus() == null ? "" : appointment.getStatus().trim().toLowerCase();
if (!"new".equals(from)) {
return Map.of(
"code", 400,
"message", "仅待开始的预约可开始服务",
"bizCode", "INVALID_STATUS"
);
}
appointment.setStatus("doing"); appointment.setStatus("doing");
appointment.setAssignedUserId(staffUserId); appointment.setAssignedUserId(staffUserId);
appointment.setUpdateTime(LocalDateTime.now()); appointment.setUpdateTime(LocalDateTime.now());
return appointmentMapper.save(appointment); Appointment saved = appointmentMapper.save(appointment);
} return Map.of("code", 200, "message", "已开始服务", "data", saved);
return null;
} }
public boolean softDelete(Long id) { public boolean softDelete(Long id) {

View File

@ -41,12 +41,14 @@ public class ReportService {
report.setStaffName(staff.getName()); report.setStaffName(staff.getName());
} }
} }
// 填写完报告自动标记预约为已完成 // 填写完报告仅进行中 已完成与预约状态机一致
if ("doing".equalsIgnoreCase(appt.getStatus())) {
appt.setStatus("done"); appt.setStatus("done");
appt.setUpdateTime(LocalDateTime.now()); appt.setUpdateTime(LocalDateTime.now());
appointmentMapper.save(appt); appointmentMapper.save(appt);
} }
} }
}
// 如果预约没分配技师则用当前操作人 // 如果预约没分配技师则用当前操作人
if (report.getUserId() != null && report.getStaffName() == null) { if (report.getUserId() != null && report.getStaffName() == null) {
User staff = userMapper.findByIdAndDeletedFalse(report.getUserId()).orElse(null); User staff = userMapper.findByIdAndDeletedFalse(report.getUserId()).orElse(null);