fix(培训优化):1.签到码文案改「二维码有效期至 HH:mm」、代扫码按钮改「补录」;2.课程管理「适合人员」升级「课程权限」(默认所属部门,部门+人员混合选择互斥,按权限过滤目录/选课/学员视图);3.筛选增加按状态查询,核验改审核;4.审核通过即自动发布(去发布按钮),审核时课程权限必填;5.下线课程全面拦截(和信课程撤回/计划不可选/学习提示已下线,存量计划保留);6.课件管理支持多课件追加不替换(迁移000163/000164);7.AI对话问候语改「小和」;8.登录页品牌标识提升对比度
deploy-hxtesting / build-and-deploy (push) Successful in 1m15s
deploy-hxtesting / build-and-deploy (push) Successful in 1m15s
This commit is contained in:
1 parent
9e00af1905
commit
6defb1f2c6
22 files changed
+1169
-307
No files matched your search
@@ -13,6 +13,36 @@ import (
|
||||
// 月培训计划的「计划名称」从本表选择,选中后经 tr_courses.library_course_id 关联。
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// courseLibraryPermissionMatchSQL 课程权限覆盖判定(000163):
|
||||
// - perm_dept_ids 含调用方部门 id,或 perm_user_ids 含调用方用户 id → 可见;
|
||||
// - perm 两列为空的存量课程沿用 suitable_members 老口径:'全部' 全员可见 /
|
||||
// 部门名成员匹配(逗号/分号归一为「、」)/ 所属部门兜底(空=全员)。
|
||||
//
|
||||
// 参数顺序:PermDeptID×2, PermUserID×2, '全部', 调用方部门名×2, 调用方部门 id×2。
|
||||
const courseLibraryPermissionMatchSQL = "tr_course_library.perm_dept_ids <> '' AND ? <> '' AND ? = ANY(string_to_array(tr_course_library.perm_dept_ids, ',')) " +
|
||||
"OR tr_course_library.perm_user_ids <> '' AND ? <> '' AND ? = ANY(string_to_array(tr_course_library.perm_user_ids, ',')) " +
|
||||
"OR (tr_course_library.perm_dept_ids = '' AND tr_course_library.perm_user_ids = '' AND (" +
|
||||
"tr_course_library.suitable_members = ? " +
|
||||
"OR (? <> '' AND ? = ANY(string_to_array(replace(replace(replace(replace(tr_course_library.suitable_members, ',', '、'), ',', '、'), ';', '、'), ';', '、'), '、'))) " +
|
||||
"OR (tr_course_library.suitable_members = '' AND (tr_course_library.owner_dept_id = '' " +
|
||||
"OR (? <> '' AND tr_course_library.owner_dept_id = ?))))"
|
||||
|
||||
// courseLibraryPermissionCond 组装课程权限匹配条件与参数(000163;handler 注入
|
||||
// 调用方部门 id/部门名/用户 id,PermIncludeCreator 时创建人/讲师放行)。
|
||||
func courseLibraryPermissionCond(q *interfaces.TrainingListQuery) (string, []interface{}) {
|
||||
cond := courseLibraryPermissionMatchSQL
|
||||
args := []interface{}{
|
||||
q.PermDeptID, q.PermDeptID,
|
||||
q.PermUserID, q.PermUserID,
|
||||
"全部", q.CatalogDeptName, q.CatalogDeptName, q.CatalogDeptID, q.CatalogDeptID,
|
||||
}
|
||||
if q.PermIncludeCreator {
|
||||
cond += " OR (tr_course_library.creator_id = ? OR tr_course_library.lecturer_id = ?)"
|
||||
args = append(args, q.PermUserID, q.PermUserID)
|
||||
}
|
||||
return "(" + cond + ")", args
|
||||
}
|
||||
|
||||
// ListCourseLibrary returns a page of course-library items with keyword filter
|
||||
// (分类/类型等前端本地过滤,数据量小全量加载)。
|
||||
func (r *trainingRepository) ListCourseLibrary(ctx context.Context, tenantID uint64, q *interfaces.TrainingListQuery) ([]*types.TrainingCourseLibrary, int64, error) {
|
||||
@@ -31,20 +61,23 @@ func (r *trainingRepository) ListCourseLibrary(ctx context.Context, tenantID uin
|
||||
if q.RelatedUserID != "" {
|
||||
tx = tx.Where("tr_course_library.creator_id = ? OR tr_course_library.lecturer_id = ?", q.RelatedUserID, q.RelatedUserID)
|
||||
}
|
||||
// 学员目录口径(000160,scope=catalog):仅已发布 + 适合人员覆盖调用方。
|
||||
// suitable='全部' 全员可见;000159 多部门口径:值按「、」拆分(逗号/分号
|
||||
// 兼容归一)后与调用方部门名做成员匹配;未设置适合人员的存量课程沿用
|
||||
// 原部门范围口径(所属部门为空=全员,否则须与调用方部门一致)。调用方
|
||||
// 无部门档案时只见「全部」与未设置的课程。
|
||||
// 学员目录口径(000160,scope=catalog):仅已发布 + 课程权限覆盖调用方
|
||||
// (000163:perm 两列精确命中;存量课程沿用 suitable_members 老口径)。
|
||||
if q.CatalogOnly {
|
||||
tx = tx.Where("tr_course_library.publish_status = ?", "published")
|
||||
tx = tx.Where(
|
||||
"tr_course_library.suitable_members = ? "+
|
||||
"OR (? <> '' AND ? = ANY(string_to_array(replace(replace(replace(replace(tr_course_library.suitable_members, ',', '、'), ',', '、'), ';', '、'), ';', '、'), '、'))) "+
|
||||
"OR (tr_course_library.suitable_members = '' AND (tr_course_library.owner_dept_id = '' "+
|
||||
"OR (? <> '' AND tr_course_library.owner_dept_id = ?)))",
|
||||
"全部", q.CatalogDeptName, q.CatalogDeptName, q.CatalogDeptID, q.CatalogDeptID,
|
||||
)
|
||||
cond, args := courseLibraryPermissionCond(q)
|
||||
tx = tx.Where(cond, args...)
|
||||
}
|
||||
// 课程权限过滤(000163):计划选课/无维护角色视图按调用方部门+人员收窄
|
||||
// (与 catalog 同一匹配口径,handler 按视图注入调用方身份与放行项)。
|
||||
if q.PermFilter {
|
||||
cond, args := courseLibraryPermissionCond(q)
|
||||
tx = tx.Where(cond, args...)
|
||||
}
|
||||
// 计划选课口径(000163,scope=plan):已下线课程不再可选(存量计划行
|
||||
// tr_courses 不受影响,历史计划照常展示)。
|
||||
if q.ExcludeOffline {
|
||||
tx = tx.Where("tr_course_library.publish_status <> ?", "offline")
|
||||
}
|
||||
}
|
||||
var total int64
|
||||
@@ -103,6 +136,26 @@ func (r *trainingRepository) GetCourseLibraryItem(ctx context.Context, tenantID
|
||||
return &item, nil
|
||||
}
|
||||
|
||||
// ListCourseLibraryStatuses 批量取课程管理条目的发布状态(000163:月培训计划
|
||||
// 列表/学习页据此拦截「该课程已下线」;ids 为 tr_courses.library_course_id 集合)。
|
||||
func (r *trainingRepository) ListCourseLibraryStatuses(ctx context.Context, tenantID uint64, ids []string) (map[string]string, error) {
|
||||
out := make(map[string]string, len(ids))
|
||||
if len(ids) == 0 {
|
||||
return out, nil
|
||||
}
|
||||
var rows []*types.TrainingCourseLibrary
|
||||
if err := r.db.WithContext(ctx).
|
||||
Select("id, publish_status").
|
||||
Where("tenant_id = ? AND id IN ?", tenantID, ids).
|
||||
Find(&rows).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, row := range rows {
|
||||
out[row.ID] = row.PublishStatus
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// CreateCourseLibraryItem inserts one course-library item.
|
||||
func (r *trainingRepository) CreateCourseLibraryItem(ctx context.Context, item *types.TrainingCourseLibrary) error {
|
||||
return r.db.WithContext(ctx).Create(item).Error
|
||||
@@ -118,6 +171,9 @@ func (r *trainingRepository) UpdateCourseLibraryItem(ctx context.Context, item *
|
||||
"owner_dept_id": item.OwnerDeptID,
|
||||
"description": item.Description,
|
||||
"suitable_members": item.SuitableMembers,
|
||||
// 课程权限(000163):部门/人员 id 列表随保存更新。
|
||||
"perm_dept_ids": item.PermDeptIDs,
|
||||
"perm_user_ids": item.PermUserIDs,
|
||||
"category": item.Category,
|
||||
"type": item.Type,
|
||||
"mode": item.Mode,
|
||||
@@ -130,6 +186,8 @@ func (r *trainingRepository) UpdateCourseLibraryItem(ctx context.Context, item *
|
||||
"file_size": item.FileSize,
|
||||
// 课件知识库文档 id(上传同步后回填;code 编号列只读不在更新列)。
|
||||
"knowledge_id": item.KnowledgeID,
|
||||
// 课件列表(000164 多课件,JSON 数组;主字段镜像最新条)。
|
||||
"materials": item.Materials,
|
||||
// 核验状态(000157):编辑/换课件后由服务层重置为待核验并清空核验痕迹。
|
||||
"verify_status": item.VerifyStatus,
|
||||
"confirmed_by": item.ConfirmedBy,
|
||||
|
||||
Reference in new issue
Block a user