| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package com.train.service;
- import com.train.common.Result;
- import java.util.List;
- import java.util.Map;
- /**
- * 培训现场签到服务(动态签到码 + 反扫 + 台账入账)
- *
- * 幂等设计:
- * - issueCode 幂等返回:同 session 已有 active 码且未过期 → 直接返回,不重复发码
- * - scan ★:train_attendance uk(user_id, session_id) 防重复扫码;台账侧 ledgerPending 再按 uk(user_id,source_type,source_id) 幂等
- * - 有效期默认 5 分钟,可配 app.attendance.code-valid-minutes
- * - 权限:issueCode/rotateCode(讲师发码)与 pendingAttendance 仅 admin;scan/mySessions/myAttendance 本人
- */
- public interface AttendanceService {
- /**
- * 发码(仅 admin;幂等返回):同 session 复用未过期 active 码;无则新建并轮换旧码。
- */
- Result<Map<String, Object>> issueCode(Boolean isAdmin, Long operatorId, String sessionId,
- Integer sessionHours, String category, String note);
- /**
- * 轮换码(仅 admin):同 session 旧 active 码置 rotated,新建 active 码。
- */
- Result<Map<String, Object>> rotateCode(Boolean isAdmin, Long operatorId, String sessionId,
- Integer sessionHours, String category, String note);
- /**
- * 反扫(本人):验码 → 写 attendance → 台账 pending 入账(同事务)。
- */
- Result<Map<String, Object>> scan(Long userId, String code);
- /**
- * 我的场次列表(按 attended_at 倒序)。
- */
- Result<List<Map<String, Object>>> mySessions(Long userId);
- /**
- * 我的签到记录(按批次可选过滤)。
- */
- Result<List<Map<String, Object>>> myAttendance(Long userId, Long cohortId);
- /**
- * 管理后台:待生效签到记录列表(真分页;仅 admin,方法内 RoleGuard 校验)。
- */
- Result<Map<String, Object>> pendingAttendance(Boolean isAdmin, Long cohortId, Integer page, Integer size);
- }
|