deploy: rebuild jar
This commit is contained in:
parent
7ac2b27a83
commit
979c2a99e0
@ -1,7 +1,7 @@
|
||||
# petstore-backend
|
||||
|
||||
#### Description
|
||||
宠伴生活馆
|
||||
宠小它
|
||||
|
||||
#### Software Architecture
|
||||
Software architecture description
|
||||
|
||||
2
pom.xml
2
pom.xml
@ -16,7 +16,7 @@
|
||||
<version>1.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>petstore-backend</name>
|
||||
<description>宠伴生活馆 后端服务</description>
|
||||
<description>宠小它 后端服务|智慧宠物门店服务系统</description>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
|
||||
@ -117,21 +117,13 @@ public class AppointmentController {
|
||||
public Map<String, Object> start(@RequestBody Map<String, Object> params) {
|
||||
Long appointmentId = Long.valueOf(params.get("appointmentId").toString());
|
||||
Long staffUserId = Long.valueOf(params.get("staffUserId").toString());
|
||||
Appointment updated = appointmentService.startService(appointmentId, staffUserId);
|
||||
if (updated != null) {
|
||||
return Map.of("code", 200, "message", "已开始服务", "data", updated);
|
||||
}
|
||||
return Map.of("code", 404, "message", "预约不存在");
|
||||
return appointmentService.startService(appointmentId, staffUserId);
|
||||
}
|
||||
|
||||
/** 更新预约状态 */
|
||||
/** 更新预约状态(合法迁移见 AppointmentService.transitionStatus) */
|
||||
@PutMapping("/status")
|
||||
public Map<String, Object> updateStatus(@RequestParam Long id, @RequestParam String status) {
|
||||
Appointment updated = appointmentService.updateStatus(id, status);
|
||||
if (updated != null) {
|
||||
return Map.of("code", 200, "message", "更新成功", "data", updated);
|
||||
}
|
||||
return Map.of("code", 404, "message", "预约不存在");
|
||||
return appointmentService.transitionStatus(id, status);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
|
||||
@ -5,6 +5,8 @@ import com.petstore.entity.Report;
|
||||
import com.petstore.entity.ReportImage;
|
||||
import com.petstore.entity.Store;
|
||||
import com.petstore.entity.User;
|
||||
import com.petstore.entity.Appointment;
|
||||
import com.petstore.service.AppointmentService;
|
||||
import com.petstore.service.ReportHighlightVideoService;
|
||||
import com.petstore.service.ReportService;
|
||||
import com.petstore.service.ReportTestimonialService;
|
||||
@ -13,6 +15,8 @@ import com.petstore.service.UserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
@ -24,7 +28,9 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
@CrossOrigin
|
||||
public class ReportController {
|
||||
private static final Logger log = LoggerFactory.getLogger(ReportController.class);
|
||||
private final ReportService reportService;
|
||||
private final AppointmentService appointmentService;
|
||||
private final StoreService storeService;
|
||||
private final ReportHighlightVideoService reportHighlightVideoService;
|
||||
private final ReportTestimonialService reportTestimonialService;
|
||||
@ -92,9 +98,39 @@ public class ReportController {
|
||||
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")
|
||||
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()));
|
||||
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);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
@ -35,7 +35,7 @@ public class SmsController {
|
||||
// 阿里云示例: dysmsapi.aliyuncs.com
|
||||
// 腾讯云示例: sms.tencentcloudapi.com
|
||||
|
||||
System.out.println("【宠伴生活馆】验证码:" + code + ",您正在登录,5分钟内有效。");
|
||||
System.out.println("【宠小它】验证码:" + code + ",您正在登录,5分钟内有效。");
|
||||
|
||||
result.put("code", 200);
|
||||
result.put("message", "发送成功");
|
||||
|
||||
@ -177,26 +177,72 @@ public class AppointmentService {
|
||||
return ok;
|
||||
}
|
||||
|
||||
public Appointment updateStatus(Long id, String status) {
|
||||
/**
|
||||
* 预约状态迁移(PUT /appointment/status 等)。
|
||||
* 允许:new→cancel、doing→done;new→doing 请走 {@link #startService}。
|
||||
*/
|
||||
public Map<String, Object> transitionStatus(Long id, String nextStatus) {
|
||||
Appointment appointment = appointmentMapper.findByIdAndDeletedFalse(id).orElse(null);
|
||||
if (appointment != null) {
|
||||
appointment.setStatus(status);
|
||||
appointment.setUpdateTime(LocalDateTime.now());
|
||||
return appointmentMapper.save(appointment);
|
||||
if (appointment == null) {
|
||||
return Map.of("code", 404, "message", "预约不存在", "bizCode", "NOT_FOUND");
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
/** 开始服务:状态变为进行中,同时指定技师为当前用户 */
|
||||
public Appointment startService(Long appointmentId, Long staffUserId) {
|
||||
appointment.setStatus(to);
|
||||
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);
|
||||
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.setAssignedUserId(staffUserId);
|
||||
appointment.setUpdateTime(LocalDateTime.now());
|
||||
return appointmentMapper.save(appointment);
|
||||
}
|
||||
return null;
|
||||
Appointment saved = appointmentMapper.save(appointment);
|
||||
return Map.of("code", 200, "message", "已开始服务", "data", saved);
|
||||
}
|
||||
|
||||
public boolean softDelete(Long id) {
|
||||
|
||||
@ -41,12 +41,14 @@ public class ReportService {
|
||||
report.setStaffName(staff.getName());
|
||||
}
|
||||
}
|
||||
// 填写完报告,自动标记预约为已完成
|
||||
// 填写完报告:仅进行中 → 已完成(与预约状态机一致)
|
||||
if ("doing".equalsIgnoreCase(appt.getStatus())) {
|
||||
appt.setStatus("done");
|
||||
appt.setUpdateTime(LocalDateTime.now());
|
||||
appointmentMapper.save(appt);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果预约没分配技师,则用当前操作人
|
||||
if (report.getUserId() != null && report.getStaffName() == null) {
|
||||
User staff = userMapper.findByIdAndDeletedFalse(report.getUserId()).orElse(null);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user