恢复点(restore point)。别人改崩后可 git reset --hard 回到此提交。 == 此快照内容 == - 后端 oa-backend: 734 控制器 / 711 实体 (Spring Boot 3.2.5 + SQLite, 端口8091) - 前端 modern-ui/app: Vue3+Vite, 约700页 (构建产物已在 oa-backend/src/main/resources/static) - 数据库 oa-backend/data/oa.db: 含全部演示数据 (强制入库, 6.6MB) - 交接文档 go.md + go-code-reference/endpoints/entities/database.md - 多代理建设脚本 .claude/wf-*.js == 状态 == - 对 凯迪科技ERP_20260507.xlsx 合规 MET ~73.3% (PARTIAL 75: 34可建+6种子/bug+35外部硬天花板) - 安全: 5轮红队+5轮复检, default-deny分级鉴权, 连续零可利用 - W3~W7 累计补完436缺口; W8末轮(40缺口)为半成品(源码树可编译但未集成) - 运行: cd oa-backend; java -jar build/libs/oa-backend-0.1.0.jar --server.port=8091; admin/123456 == 排除(gitignore, 可再生) == node_modules / oa-backend/build / .jdks / *.log / Backup-ERP-* / 弃用的OFBiz核心(只保留modern-ui) 完整文件夹备份见同目录 Backup-ERP-20260615-191517/ (含上述全部, 仅缺 node_modules) 时间戳: 20260615-191517 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
205 lines
8.8 KiB
Java
205 lines
8.8 KiB
Java
package com.kaidi.oa.web;
|
|
|
|
import com.kaidi.oa.common.ApiException;
|
|
import com.kaidi.oa.common.ApiResp;
|
|
import com.kaidi.oa.common.NotFoundException;
|
|
import com.kaidi.oa.domain.BrandEvent;
|
|
import com.kaidi.oa.domain.EventGuest;
|
|
import com.kaidi.oa.repository.BrandEventRepository;
|
|
import com.kaidi.oa.repository.EventGuestRepository;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PatchMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.time.Instant;
|
|
import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 品牌推广部·活动嘉宾管理(活动策划与执行·模块4深化)。
|
|
*
|
|
* <p>为 {@link BrandEvent} 下达嘉宾邀请({@link EventGuest}),跟踪邀请状态
|
|
* (待邀请→已邀请→已确认/已拒绝→已签到/未出席),支持到场统计。
|
|
* /checkin 端点模拟现场扫码签到,更新 checkinTime 并推进 inviteStatus=已签到。
|
|
* /stats 端点聚合邀请/确认/签到人数,支持实时大屏显示。
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/api/oa/event-guests")
|
|
public class EventGuestController {
|
|
|
|
private final EventGuestRepository guestRepo;
|
|
private final BrandEventRepository eventRepo;
|
|
|
|
public EventGuestController(EventGuestRepository guestRepo, BrandEventRepository eventRepo) {
|
|
this.guestRepo = guestRepo;
|
|
this.eventRepo = eventRepo;
|
|
}
|
|
|
|
// ==================== CRUD ====================
|
|
|
|
@GetMapping("/by-event/{eventId}")
|
|
public ApiResp<List<EventGuest>> listByEvent(@PathVariable Long eventId) {
|
|
findEvent(eventId);
|
|
return ApiResp.ok(guestRepo.findByEventIdOrderByIdAsc(eventId));
|
|
}
|
|
|
|
@GetMapping("/{id}")
|
|
public ApiResp<EventGuest> get(@PathVariable Long id) {
|
|
return ApiResp.ok(findGuest(id));
|
|
}
|
|
|
|
public record GuestRequest(
|
|
Long eventId, String guestName, String organization, String title,
|
|
String phone, String email, String guestType, String specialRequirements, String remark) {
|
|
}
|
|
|
|
@PostMapping
|
|
public ApiResp<EventGuest> create(@RequestBody GuestRequest req) {
|
|
if (req.eventId() == null) {
|
|
throw new ApiException(400, "eventId 不能为空");
|
|
}
|
|
if (req.guestName() == null || req.guestName().isBlank()) {
|
|
throw new ApiException(400, "嘉宾姓名(guestName) 不能为空");
|
|
}
|
|
BrandEvent e = findEvent(req.eventId());
|
|
if ("已总结".equals(e.getStatus()) || "已取消".equals(e.getStatus())) {
|
|
throw new ApiException(409, "「" + e.getStatus() + "」活动不能再添加嘉宾");
|
|
}
|
|
EventGuest g = new EventGuest();
|
|
g.setEventId(e.getId());
|
|
g.setEventName(e.getName());
|
|
g.setGuestName(req.guestName());
|
|
g.setOrganization(req.organization());
|
|
g.setTitle(req.title());
|
|
g.setPhone(req.phone());
|
|
g.setEmail(req.email());
|
|
g.setGuestType(req.guestType() == null || req.guestType().isBlank() ? "合作伙伴" : req.guestType());
|
|
g.setSpecialRequirements(req.specialRequirements());
|
|
g.setRemark(req.remark());
|
|
g.setInviteStatus("待邀请");
|
|
g.setCreatedAt(Instant.now());
|
|
return ApiResp.ok(guestRepo.save(g));
|
|
}
|
|
|
|
@PatchMapping("/{id}")
|
|
public ApiResp<EventGuest> update(@PathVariable Long id, @RequestBody GuestRequest req) {
|
|
EventGuest g = findGuest(id);
|
|
if (req.guestName() != null && !req.guestName().isBlank()) g.setGuestName(req.guestName());
|
|
if (req.organization() != null) g.setOrganization(req.organization());
|
|
if (req.title() != null) g.setTitle(req.title());
|
|
if (req.phone() != null) g.setPhone(req.phone());
|
|
if (req.email() != null) g.setEmail(req.email());
|
|
if (req.guestType() != null) g.setGuestType(req.guestType());
|
|
if (req.specialRequirements() != null) g.setSpecialRequirements(req.specialRequirements());
|
|
if (req.remark() != null) g.setRemark(req.remark());
|
|
return ApiResp.ok(guestRepo.save(g));
|
|
}
|
|
|
|
@DeleteMapping("/{id}")
|
|
public ApiResp<Void> delete(@PathVariable Long id) {
|
|
if (!guestRepo.existsById(id)) {
|
|
throw new NotFoundException("event guest not found: " + id);
|
|
}
|
|
guestRepo.deleteById(id);
|
|
return ApiResp.ok(null);
|
|
}
|
|
|
|
// ==================== 邀请状态流转 ====================
|
|
|
|
public record InviteStatusRequest(String inviteStatus, String date) {
|
|
}
|
|
|
|
/** 更新邀请状态(已邀请/已确认/已拒绝)。 */
|
|
@PostMapping("/{id}/update-status")
|
|
public ApiResp<EventGuest> updateStatus(@PathVariable Long id, @RequestBody InviteStatusRequest req) {
|
|
EventGuest g = findGuest(id);
|
|
String allowed = "已邀请,已确认,已拒绝";
|
|
if (req.inviteStatus() == null || !allowed.contains(req.inviteStatus())) {
|
|
throw new ApiException(400, "状态只能为:" + allowed);
|
|
}
|
|
g.setInviteStatus(req.inviteStatus());
|
|
String today = java.time.LocalDate.now().toString();
|
|
if ("已邀请".equals(req.inviteStatus())) {
|
|
g.setInvitedDate(req.date() == null ? today : req.date());
|
|
} else if ("已确认".equals(req.inviteStatus())) {
|
|
g.setConfirmedDate(req.date() == null ? today : req.date());
|
|
}
|
|
return ApiResp.ok(guestRepo.save(g));
|
|
}
|
|
|
|
/** 现场签到(已确认/已邀请 → 已签到),记录签到时间。 */
|
|
@PostMapping("/{id}/checkin")
|
|
public ApiResp<EventGuest> checkin(@PathVariable Long id) {
|
|
EventGuest g = findGuest(id);
|
|
if ("已签到".equals(g.getInviteStatus())) {
|
|
throw new ApiException(409, "嘉宾已签到,不可重复操作");
|
|
}
|
|
if ("已拒绝".equals(g.getInviteStatus()) || "未出席".equals(g.getInviteStatus())) {
|
|
throw new ApiException(409, "嘉宾状态「" + g.getInviteStatus() + "」,不可签到");
|
|
}
|
|
g.setInviteStatus("已签到");
|
|
g.setCheckinTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
return ApiResp.ok(guestRepo.save(g));
|
|
}
|
|
|
|
/** 标记未出席(活动结束后,已确认/已邀请但未签到的嘉宾)。 */
|
|
@PostMapping("/{id}/absent")
|
|
public ApiResp<EventGuest> markAbsent(@PathVariable Long id) {
|
|
EventGuest g = findGuest(id);
|
|
if ("已签到".equals(g.getInviteStatus())) {
|
|
throw new ApiException(409, "已签到嘉宾不能标记为未出席");
|
|
}
|
|
g.setInviteStatus("未出席");
|
|
return ApiResp.ok(guestRepo.save(g));
|
|
}
|
|
|
|
// ==================== 签到统计(大屏聚合)====================
|
|
|
|
public record GuestStats(Long eventId, String eventName, int total, int invited, int confirmed,
|
|
int checkedIn, int absent, int refused, int pending,
|
|
double checkinRate) {
|
|
}
|
|
|
|
/** 嘉宾签到统计:邀请/确认/签到/缺席人数,支持活动大屏实时显示。 */
|
|
@GetMapping("/stats/{eventId}")
|
|
public ApiResp<GuestStats> stats(@PathVariable Long eventId) {
|
|
BrandEvent e = findEvent(eventId);
|
|
List<EventGuest> guests = guestRepo.findByEventIdOrderByIdAsc(eventId);
|
|
int total = guests.size();
|
|
int invited = 0, confirmed = 0, checkedIn = 0, absent = 0, refused = 0, pending = 0;
|
|
for (EventGuest g : guests) {
|
|
switch (g.getInviteStatus() == null ? "待邀请" : g.getInviteStatus()) {
|
|
case "待邀请" -> pending++;
|
|
case "已邀请" -> invited++;
|
|
case "已确认" -> confirmed++;
|
|
case "已签到" -> checkedIn++;
|
|
case "未出席" -> absent++;
|
|
case "已拒绝" -> refused++;
|
|
default -> pending++;
|
|
}
|
|
}
|
|
double rate = total == 0 ? 0 : Math.round(checkedIn * 1000.0 / total) / 10.0;
|
|
return ApiResp.ok(new GuestStats(eventId, e.getName(), total, invited, confirmed,
|
|
checkedIn, absent, refused, pending, rate));
|
|
}
|
|
|
|
// ==================== 私有工具 ====================
|
|
|
|
private BrandEvent findEvent(Long id) {
|
|
return eventRepo.findById(id)
|
|
.orElseThrow(() -> new NotFoundException("brand event not found: " + id));
|
|
}
|
|
|
|
private EventGuest findGuest(Long id) {
|
|
return guestRepo.findById(id)
|
|
.orElseThrow(() -> new NotFoundException("event guest not found: " + id));
|
|
}
|
|
}
|