feat(training): 企业培训迭代:推送深链接与签名下载、课程管理修复与收集模板调整

推送域(000155):
- 广播通知支持 link_url:demand_collect 场景自动签发教育训练需求表模板
  匿名下载直链(HMAC token,20 天有效,免登录路由),企微消息尾部拼
  「下载模板 + 查看更多详情」链接;站内文本保持纯文本不受影响
- 配置中心新增「推送链接基址」(notify_link_base_url,多入口/内外网部署固定
  权威地址,留空跟随推送人访问地址)与「年培训计划收集推送文案」
  (demand_collect_*,{year} 渲染收集年度);空标题/内容按模板回落渲染
- 迁移 000155:tr_training_notifications 增 link_url/link_token 列

课程管理:
- 修复点【发布/下线】报「不支持的操作」:动作取值兼容字面量路由(FullPath
  末段)与 :action 通配两种注册形态
- 列表新增「创建人」列:creator_id 联查 users 带出姓名,导出 Excel 同步;
  新增课程「所属部门」默认当前登录用户所在部门
- 导入加固:表头归一化 + 别名模糊匹配(兼容内置模板/旧口径/自定义模板变体);
  导入与新增行支持按部门名兜底解析为 id(前端名册未命中时传 owner_dept_name)

年培训计划:
- 需求列表新增「创建人/创建时间」列(submitter_id 联查 users 带出姓名)
- 收集模板调整:下载时动态删除「培训费用(RMB)」列(旧版自定义模板同步归一,
  右侧列/合并/下拉随删列平移);备注右侧追加「调研维度/培训策划要求」说明列
  (合并至数据区末行,自动换行带边框,已带说明的自定义模板不覆盖)

开发工具:
- air 热重载适配 Windows:构建收敛到 scripts/air_build.sh(规避 air 经
  PowerShell 执行不支持 bash 命令替换),产物改 .exe 后缀;CGO_CFLAGS 取
  持久化值并集追加,不覆盖 go env -w 的头文件包含路径
This commit is contained in:
runny committed 2026-11-19 17:10:12 +08:00
1 parent 242dd7e1a6
commit 4e25fce9aa
30 files changed
+1150 -143

No files matched your search

+36 -36
View File
@@ -112,7 +112,7 @@ func (h *Handler) requireRoles(c *gin.Context, allowed ...string) (ok bool) {
labelParts = append(labelParts, want)
}
}
_ = c.Error(errors.NewForbiddenError("无权执行该操作,需要职称角色: "+strings.Join(labelParts, "/")))
_ = c.Error(errors.NewForbiddenError("无权执行该操作,需要职称角色: " + strings.Join(labelParts, "/")))
return false
}
@@ -423,10 +423,10 @@ type saveDemandRequest struct {
// LecturerExternal 外部讲师姓名(非系统员工;lecturer_id 为空时生效)。
LecturerExternal string `json:"lecturer_external"`
// TrainType 内/外培训(内部/外部,选填;来自需求表模板「內/外培訓」列)。
TrainType string `json:"train_type"`
TargetCount int `json:"target_count"`
Hours float64 `json:"hours"`
ExpectMonth int `json:"expect_month"`
TrainType string `json:"train_type"`
TargetCount int `json:"target_count"`
Hours float64 `json:"hours"`
ExpectMonth int `json:"expect_month"`
// PlannedTime 计划培训时间(YYYY-MM-DD HH:mm 或 YYYY-MM-DD,选填;确认后同步课程)。
PlannedTime string `json:"planned_time"`
Remark string `json:"remark"`
@@ -735,7 +735,7 @@ func (h *Handler) syncDemandParticipants(ctx context.Context, tenantID uint64, c
if startAt := parseFlexibleTime(demand.PlannedTime); startAt != nil {
session.StartAt = startAt
if demand.Hours > 0 {
end := startAt.Add(time.Duration(demand.Hours*float64(time.Hour)))
end := startAt.Add(time.Duration(demand.Hours * float64(time.Hour)))
session.EndAt = &end
}
}
@@ -834,7 +834,7 @@ func (h *Handler) notifyDemandVerify(ctx context.Context, tenantID uint64, deman
"%s 新导入 %d 条年度培训需求(课程:%s)。请登录 AIDO → 企业培训 → 年培训计划,逐条核验并【确认】,确认后将自动转入月培训计划。",
name, len(courses), strings.Join(courses, "、"),
)
n, err := h.svc.BroadcastNotification(ctx, tenantID, recipients, "demand_verify", title, content, "plan", strconv.Itoa(year))
n, err := h.svc.BroadcastNotification(ctx, tenantID, recipients, "demand_verify", title, content, "plan", strconv.Itoa(year), "")
if err != nil {
logger.Error(ctx, "Failed to notify dept managers for demand verify", err)
continue
@@ -870,7 +870,7 @@ func (h *Handler) notifyDemandConfirmed(ctx context.Context, tenantID uint64, op
"%d年度需求「%s」已核验确认并自动转入月培训计划:请讲师维护课程信息(课件/试题),课长安排授课时间/地点与学员名单。入口:AIDO → 企业培训 → 月培训计划。",
demand.Year, demand.CourseName,
)
if _, err := h.svc.BroadcastNotification(ctx, tenantID, final, "demand_confirmed", title, content, "course", demand.ID); err != nil {
if _, err := h.svc.BroadcastNotification(ctx, tenantID, final, "demand_confirmed", title, content, "course", demand.ID, ""); err != nil {
logger.Error(ctx, "Failed to notify lecturer and supervisors after demand confirm", err)
}
}
@@ -1000,13 +1000,13 @@ func (h *Handler) ListMonthPlans(c *gin.Context) {
// saveMonthPlanRequest is the body of POST /training/month-plans.
type saveMonthPlanRequest struct {
ID string `json:"id"`
Year int `json:"year"`
Month int `json:"month"`
DeptID string `json:"dept_id"`
Title string `json:"title" binding:"required"`
StartAt string `json:"start_at"` // RFC3339 / "2006-01-02 15:04"
Location string `json:"location"`
ID string `json:"id"`
Year int `json:"year"`
Month int `json:"month"`
DeptID string `json:"dept_id"`
Title string `json:"title" binding:"required"`
StartAt string `json:"start_at"` // RFC3339 / "2006-01-02 15:04"
Location string `json:"location"`
LecturerID string `json:"lecturer_id"`
}
@@ -1123,23 +1123,23 @@ func (h *Handler) GetCourse(c *gin.Context) {
// saveCourseRequest is the body of POST /training/courses.
type saveCourseRequest struct {
ID string `json:"id"`
Code string `json:"code"`
Name string `json:"name" binding:"required"`
Mode string `json:"mode"`
Type string `json:"type"`
LecturerID string `json:"lecturer_id"`
Hours float64 `json:"hours"`
Credits float64 `json:"credits"`
ExamEnabled bool `json:"exam_enabled"`
DeptIDs []string `json:"dept_ids"`
PostScope string `json:"post_scope"`
Description string `json:"description"`
MaterialIDs []string `json:"material_ids"`
TeachTime string `json:"teach_time"`
ID string `json:"id"`
Code string `json:"code"`
Name string `json:"name" binding:"required"`
Mode string `json:"mode"`
Type string `json:"type"`
LecturerID string `json:"lecturer_id"`
Hours float64 `json:"hours"`
Credits float64 `json:"credits"`
ExamEnabled bool `json:"exam_enabled"`
DeptIDs []string `json:"dept_ids"`
PostScope string `json:"post_scope"`
Description string `json:"description"`
MaterialIDs []string `json:"material_ids"`
TeachTime string `json:"teach_time"`
// PlannedTime 计划培训时间(需求确认同步的课程携带;前端编辑时原样回传保留)。
PlannedTime string `json:"planned_time"`
QuestionBankID string `json:"question_bank_id"`
PlannedTime string `json:"planned_time"`
QuestionBankID string `json:"question_bank_id"`
// 以下为需求确认同步字段(前端编辑时原样回传保留,防止被零值覆盖)。
TrainType string `json:"train_type"`
Plant string `json:"plant"`
@@ -1632,12 +1632,12 @@ func (h *Handler) GetSignCode(c *gin.Context) {
// CheckinRequest is the body of POST /training/sign-records/checkin.
type CheckinRequest struct {
Token string `json:"token" binding:"required"`
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
Channel string `json:"channel"`
Token string `json:"token" binding:"required"`
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
Channel string `json:"channel"`
// MemberID 可选:讲师/课长/人事现场代扫码/补录。
MemberID string `json:"member_id"`
MemberID string `json:"member_id"`
}
// Checkin POST /training/sign-records/checkin — 学员扫码签到(带定位校验);