fix(bug):1.帮我检查一下平台中有多少处显示部门地方这种“e10-、、、、”字样拿掉不要显示
deploy-hxtesting / build-and-deploy (push) Successful in 1m28s
deploy-hxtesting / build-and-deploy (push) Successful in 1m28s
2.月培训计划发布时授课时间默认空着点击【发布】时提示先维护授课时间,(不要默认年培训计划) 3.授课地点默认“年度计划”所设置的授课地点,如果年培训计划没有维护发布时也要必填 4.点击【发布】时要校验参加人员不能为空!默认为所属部门下的人员~ 认真阅读相关代码~
This commit is contained in:
1 parent
6cdcc4f221
commit
858c352991
16 files changed
+421
-89
No files matched your search
@@ -13,6 +13,7 @@ import (
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/types/interfaces"
|
||||
"academy/internal/utils"
|
||||
"github.com/xuri/excelize/v2"
|
||||
)
|
||||
|
||||
@@ -474,15 +475,17 @@ func (s *trainingService) PublishCourse(ctx context.Context, tenantID uint64, id
|
||||
return nil, errors.NewBadRequestError("线上课程发布前需先登记课件资料(上传课件/从课件库选择/仅登记名称)")
|
||||
}
|
||||
}
|
||||
// 参加人员:适用人员非空或场次学员名单有人(跨场次)任一满足即可。
|
||||
if strings.TrimSpace(course.PostScope) == "" {
|
||||
enrolled, enrolledErr := s.repo.CountEnrolledMembersByCourseID(ctx, tenantID, course.ID)
|
||||
if enrolledErr != nil {
|
||||
return nil, enrolledErr
|
||||
}
|
||||
if enrolled == 0 {
|
||||
return nil, errors.NewBadRequestError("发布前需先设置参加人员")
|
||||
}
|
||||
// 参加人员(2026-11 需求收紧:发布时校验参加人员不能为空):场次学员名单
|
||||
// 有人(跨场次)即已设置;否则 post_scope 姓名须至少一人匹配到员工名册 ——
|
||||
// 需求确认同步的 post_scope 是「适合人员」部门名串(匹配不到任何员工),
|
||||
// 不能视为已设置,防止名单为空的计划带空应培名单发布。
|
||||
enrolled, enrolledErr := s.repo.CountEnrolledMembersByCourseID(ctx, tenantID, course.ID)
|
||||
if enrolledErr != nil {
|
||||
return nil, enrolledErr
|
||||
}
|
||||
if enrolled == 0 && !s.postScopeHasMember(ctx, tenantID, course.PostScope) {
|
||||
return nil, errors.NewBadRequestError("发布前需先设置参加人员").
|
||||
WithDetails("参加人员不能为空;可在月培训计划「调整」中确认(默认为所属部门下的人员)后保存再发布")
|
||||
}
|
||||
if course.Mode != types.TrainingCourseModeOnline {
|
||||
// 授课时间/地点与列表展示同口径(场次排期优先,2026-11-26 复测修复):
|
||||
@@ -530,6 +533,46 @@ func (s *trainingService) PublishCourse(ctx context.Context, tenantID uint64, id
|
||||
return course, nil
|
||||
}
|
||||
|
||||
// postScopeHasMember post_scope 姓名串(、/,/,/;/;/空格分隔)至少一人匹配到员工
|
||||
// 名册(姓名或工号)即认为已设置参加人员(2026-11 需求:需求确认同步的 post_scope
|
||||
// 是「适合人员」部门名串,匹配不到任何员工,不算已设置)。名册查询失败时返回
|
||||
// false,交由上层按「未设置参加人员」统一拦截,不放行空名单。
|
||||
func (s *trainingService) postScopeHasMember(ctx context.Context, tenantID uint64, postScope string) bool {
|
||||
names := map[string]struct{}{}
|
||||
for _, part := range strings.FieldsFunc(postScope, func(r rune) bool {
|
||||
return r == '、' || r == ',' || r == ',' || r == ';' || r == ';' || r == ' ' || r == '\t'
|
||||
}) {
|
||||
if part = strings.TrimSpace(part); part != "" {
|
||||
names[part] = struct{}{}
|
||||
}
|
||||
}
|
||||
if len(names) == 0 {
|
||||
return false
|
||||
}
|
||||
if s.org == nil {
|
||||
return false
|
||||
}
|
||||
members, _, err := s.org.ListEmployees(ctx, tenantID, types.OrgModuleTraining, &types.OrgListQuery{Page: 1, PageSize: 2000})
|
||||
if err != nil {
|
||||
logger.Error(ctx, "Failed to list members for publish participant check", err)
|
||||
return false
|
||||
}
|
||||
for _, m := range members {
|
||||
if m == nil {
|
||||
continue
|
||||
}
|
||||
if _, ok := names[m.UserName]; ok {
|
||||
return true
|
||||
}
|
||||
if m.EmployeeNo != "" {
|
||||
if _, ok := names[m.EmployeeNo]; ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ListSessions returns sessions.
|
||||
func (s *trainingService) ListSessions(ctx context.Context, tenantID uint64, q *interfaces.TrainingListQuery) ([]*types.TrainingCourseSession, error) {
|
||||
return s.repo.ListSessions(ctx, tenantID, q)
|
||||
@@ -1091,7 +1134,8 @@ func (s *trainingService) ExportEvidence(ctx context.Context, tenantID uint64, s
|
||||
if row.InRoster {
|
||||
rosterLabel = "要求培训人员"
|
||||
}
|
||||
values := []string{row.DeptName, row.EmployeeNo, row.MemberName, row.SignedAt,
|
||||
// 2026-11 需求:部门列剥离企微同步残留的「e10-<ID>」字样
|
||||
values := []string{utils.CleanDeptName(row.DeptName), row.EmployeeNo, row.MemberName, row.SignedAt,
|
||||
row.LecturerName, row.CourseName, row.SessionTime, row.ExamScore, rosterLabel}
|
||||
for i, v := range values {
|
||||
cell, _ := excelize.CoordinatesToCellName(i+1, r+2)
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"academy/internal/errors"
|
||||
"academy/internal/logger"
|
||||
"academy/internal/types"
|
||||
"academy/internal/utils"
|
||||
)
|
||||
|
||||
// 手动推送默认文案(前端弹窗预填同款,后端对空值兜底)。
|
||||
@@ -245,10 +246,14 @@ func (s *trainingService) deptNames(ctx context.Context, tenantID uint64, ids []
|
||||
}
|
||||
out := make([]string, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
if name := byID[id]; name != "" {
|
||||
out = append(out, name)
|
||||
} else {
|
||||
out = append(out, id)
|
||||
name := byID[id]
|
||||
if name == "" {
|
||||
out = append(out, id) // 组织中心不可用或部门已删,回落 id 原文,不阻断列表
|
||||
continue
|
||||
}
|
||||
// 2026-11 需求:推送文案剥离企微同步残留的「e10-<ID>」部门名字样
|
||||
if cleaned := utils.CleanDeptName(name); cleaned != "" {
|
||||
out = append(out, cleaned)
|
||||
}
|
||||
}
|
||||
return out
|
||||
|
||||
Reference in new issue
Block a user