feat(training): 课程管理新增核验状态流转与权限细化(000157)
deploy-hxtesting / build-and-deploy (push) Failing after 0s
deploy-hxtesting / build-and-deploy (push) Failing after 0s
核验状态(verify_status,迁移 000157): - 新字段 pending 待核验(初始)/confirmed 已确认,附核验人/核验时间审计列,存量数据回填待核验 - 新增/导入/编辑(含重新上传课件)一律重置为待核验,原核验结论作废 - 发布前置校验:课程发布、月培训计划「发布/保存并发布」关联课程必须已确认,否则友好提示核验入口 核验/删除权限(仅本部门课长/经理): - 新端点 POST /training/course-library/verify 单个/批量共用,越权/已确认行跳过不阻断 - 核验与删除严格按课长身份所在部门收窄,人事/讲师/学员/空间管理员均无跨部门操作权 - 删除仅限待核验状态(已确认课程不可删,须走核验流程) 列表数据范围与页签: - 课程管理列表按角色注入过滤:人事/空间管理员全部,课长/经理本部门,讲师/学员仅「与我相关」(本人创建或本人授课) - 课程管理页签对学员开放;无维护角色用户仅可编辑本人创建/授课课程(不可新增) 前端: - 发布状态「草稿」文案改为「待发布」;新增「状态」列固定右侧置于操作列前 - 列表勾选 + 批量核验/批量删除(仅本部门待核验行提交);发布按钮前置核验校验未核验友好提示;按钮按角色/部门/状态动态显隐
This commit is contained in:
1 parent
168057db78
commit
80deef9c53
13 files changed
+418
-21
No files matched your search
@@ -458,10 +458,18 @@ export interface TrainingLibraryCourse {
|
||||
knowledge_id?: string
|
||||
/** 发布状态(000154):draft 草稿/published 已发布/offline 已下线 */
|
||||
publish_status?: string
|
||||
/** 核验状态(000157):pending 待核验/confirmed 已确认;发布前必须已确认 */
|
||||
verify_status?: string
|
||||
/** 核验人(课长/经理用户 id,联查展示用;仅审计) */
|
||||
confirmed_by?: string
|
||||
/** 核验时间 */
|
||||
confirmed_at?: string
|
||||
/** 移除课件文件标记(保存时置 true 强制清空文件) */
|
||||
clear_file?: boolean
|
||||
/** 讲师姓名(联查 users 只读) */
|
||||
lecturer_name?: string
|
||||
/** 创建人用户 id(学员「与我相关」列表的编辑权限判断用) */
|
||||
creator_id?: string
|
||||
/** 创建人姓名(联查 users 只读;导入/新增时落 creator_id 后带出) */
|
||||
creator_name?: string
|
||||
created_at?: string
|
||||
@@ -485,6 +493,10 @@ export const publishCourseLibraryItem = (id: string) =>
|
||||
export const offlineCourseLibraryItem = (id: string) =>
|
||||
post<{ success: boolean; data: TrainingLibraryCourse }>(`${base}/course-library/${enc(id)}/offline`)
|
||||
|
||||
/** 课程条目核验(000157,单个/批量共用):仅课长/经理限本部门;返回核验/跳过条数。 */
|
||||
export const verifyCourseLibraryItems = (ids: string[]) =>
|
||||
post<{ success: boolean; data: { verified: number; skipped: number } }>(`${base}/course-library/verify`, { ids })
|
||||
|
||||
/** 批量导入(前端解析 Excel 后逐行提交,与需求导入同口径;返回导入条数)。 */
|
||||
export const importCourseLibrary = (items: Partial<TrainingLibraryCourse>[]) =>
|
||||
post<{ success: boolean; data: { imported: number } }>(`${base}/course-library/import`, { items })
|
||||
|
||||
@@ -51,8 +51,9 @@
|
||||
<t-empty v-else class="training-empty" description="月培训计划仅课长/经理/人事/讲师可见,学员请前往培训中心课程目录" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'library'">
|
||||
<LibraryPanel v-if="canManageTabs" :roles="myRoles" :admin="isAdmin" />
|
||||
<t-empty v-else class="training-empty" description="课程管理仅课长/经理/人事/讲师可见" />
|
||||
<!-- 课程管理全员可见(000157):数据范围与按钮权限按角色细分(人事全部/
|
||||
课长经理本部门/讲师学员仅「与我相关」),细控在 LibraryPanel 与后端 -->
|
||||
<LibraryPanel :roles="myRoles" :admin="isAdmin" />
|
||||
</template>
|
||||
<template v-else-if="activeTab === 'sign'">
|
||||
<SignPanel v-if="canManageTabs" :roles="myRoles" :admin="isAdmin" />
|
||||
|
||||
@@ -29,9 +29,22 @@
|
||||
</t-select>
|
||||
<t-button variant="text" theme="primary" size="small" @click="resetFilters">重置</t-button>
|
||||
<span class="library-filter-count">共 {{ filteredItems.length }} 门</span>
|
||||
<!-- 批量操作(000157):核验/删除均仅课长/经理限本部门,且仅待核验行可删 -->
|
||||
<t-button
|
||||
v-if="canVerify" variant="outline" theme="primary" size="small"
|
||||
:disabled="!selectedKeys.length" :loading="batchSaving" @click="onBatchVerify"
|
||||
>批量核验</t-button>
|
||||
<t-button
|
||||
v-if="canDelete" variant="outline" theme="danger" size="small"
|
||||
:disabled="!selectedKeys.length" :loading="batchSaving" @click="onBatchDelete"
|
||||
>批量删除</t-button>
|
||||
<span v-if="selectedKeys.length" class="library-filter-count">已选 {{ selectedKeys.length }} 项</span>
|
||||
</div>
|
||||
|
||||
<t-table :data="filteredItems" :columns="columns" row-key="id" size="small" :loading="loading">
|
||||
<t-table
|
||||
v-model:selected-row-keys="selectedKeys"
|
||||
:data="filteredItems" :columns="columns" row-key="id" size="small" :loading="loading"
|
||||
>
|
||||
<template #code="{ row }">{{ row.code || '-' }}</template>
|
||||
<template #name="{ row }"><span class="clamp-2">{{ row.name }}</span></template>
|
||||
<template #description="{ row }">
|
||||
@@ -78,9 +91,22 @@
|
||||
variant="light" size="small"
|
||||
>{{ publishStatusText(row.publish_status) }}</t-tag>
|
||||
</template>
|
||||
<!-- 核验状态(000157):新增/编辑后待核验,课长/经理核验确认后方可发布 -->
|
||||
<template #verify_status="{ row }">
|
||||
<t-tag :theme="row.verify_status === 'confirmed' ? 'success' : 'warning'" variant="light" size="small">
|
||||
{{ row.verify_status === 'confirmed' ? '已确认' : '待核验' }}
|
||||
</t-tag>
|
||||
</template>
|
||||
<template #op="{ row }">
|
||||
<t-button v-if="canManage" variant="text" theme="primary" size="small" @click="openForm(row)">编辑</t-button>
|
||||
<t-button v-if="canEditCourse(row)" variant="text" theme="primary" size="small" @click="openForm(row)">编辑</t-button>
|
||||
<t-button variant="text" size="small" @click="openQuestions(row)">试题</t-button>
|
||||
<t-popconfirm
|
||||
v-if="canVerifyCourse(row)"
|
||||
content="核验确认后该课程方可发布,确认核验通过?" theme="primary"
|
||||
@confirm="onVerify(row)"
|
||||
>
|
||||
<t-button variant="text" theme="primary" size="small">核验</t-button>
|
||||
</t-popconfirm>
|
||||
<t-popconfirm
|
||||
v-if="canManage && row.publish_status !== 'published'"
|
||||
content="发布后该课程进入培训中心「和信课程」目录(本部门可见)。" theme="primary"
|
||||
@@ -95,7 +121,10 @@
|
||||
>
|
||||
<t-button variant="text" theme="danger" size="small">下线</t-button>
|
||||
</t-popconfirm>
|
||||
<t-popconfirm v-if="canManage" content="确定删除该课程?已创建的月培训计划不受影响。" theme="danger" @confirm="onDelete(row)">
|
||||
<t-popconfirm
|
||||
v-if="canDeleteCourse(row)"
|
||||
content="仅待核验状态的课程可删除,确定删除该课程?已创建的月培训计划不受影响。" theme="danger" @confirm="onDelete(row)"
|
||||
>
|
||||
<t-button variant="text" theme="danger" size="small">删除</t-button>
|
||||
</t-popconfirm>
|
||||
<t-button v-if="row.file_name" variant="text" size="small" @click="onDownloadMaterial(row)">下载课件</t-button>
|
||||
@@ -470,6 +499,7 @@ import {
|
||||
saveCourseLibraryItem,
|
||||
saveQuestion,
|
||||
uploadCourseLibraryMaterial,
|
||||
verifyCourseLibraryItems,
|
||||
type TrainingDept,
|
||||
type TrainingLibraryCourse,
|
||||
type TrainingMember,
|
||||
@@ -479,7 +509,8 @@ import {
|
||||
} from '@/api/training'
|
||||
|
||||
const props = defineProps<{ roles: string[]; admin?: boolean }>()
|
||||
// 课程维护:人事/课长/讲师(roles 已按权限组展开,经理经课长继承自动命中)
|
||||
// 课程维护(新增/编辑/发布/导入/导出):人事/课长/讲师(roles 已按权限组展开,
|
||||
// 经理经课长继承自动命中)。人事无核验/删除权限(000157)。
|
||||
const canManage = computed(() => props.admin || props.roles.some((r) => r === 'hr' || r === 'supervisor' || r === 'lecturer'))
|
||||
|
||||
const loading = ref(false)
|
||||
@@ -492,6 +523,28 @@ const depts = ref<TrainingDept[]>([])
|
||||
const configCategories = ref<string[]>([])
|
||||
// 本人所在部门 id:新增课程「所属部门」默认当前登录用户所在部门(getMyProfile)
|
||||
const myDeptId = ref('')
|
||||
// 本人用户 id:学员「与我相关」课程的编辑权限判断(创建人/讲师为本人)
|
||||
const myUserId = ref('')
|
||||
|
||||
// 核验/删除权限(000157):严格限「本部门课长/经理」——人事/空间管理员一律无
|
||||
// 跨部门核验/删除权(roles 已按权限组展开,经理经课长继承自动命中 supervisor)。
|
||||
const canVerify = computed(() => props.roles.includes('supervisor'))
|
||||
const canDelete = canVerify
|
||||
// 仅本部门「待核验」课程可核验/删除;与后端 callerVerifyDeptScope 同口径:
|
||||
// 无部门身份或课程所属部门与本人不一致时一律不可操作。
|
||||
const canVerifyCourse = (row: TrainingLibraryCourse) =>
|
||||
canVerify.value &&
|
||||
row.verify_status === 'pending' &&
|
||||
Boolean(myDeptId.value) &&
|
||||
Boolean(row.owner_dept_id) &&
|
||||
row.owner_dept_id === myDeptId.value
|
||||
const canDeleteCourse = canVerifyCourse
|
||||
|
||||
// 编辑权限:维护角色可编辑可见课程;无维护角色的学员仅可编辑「与我相关」课程
|
||||
// (本人创建或本人授课,后端兜底校验同口径)
|
||||
const canEditCourse = (row: TrainingLibraryCourse) =>
|
||||
canManage.value ||
|
||||
(Boolean(myUserId.value) && (row.creator_id === myUserId.value || row.lecturer_id === myUserId.value))
|
||||
|
||||
// ---- 查询条件(编号/名称/分类/类型/形式;列表全量加载,本地过滤) ----
|
||||
const filters = ref({ keyword: '', category: '', type: '', mode: '' })
|
||||
@@ -520,6 +573,8 @@ const filteredItems = computed(() => {
|
||||
})
|
||||
|
||||
const columns = [
|
||||
// 批量勾选列(000157):配合批量核验/批量删除
|
||||
{ colKey: 'row-select', type: 'multiple', width: 44 },
|
||||
// 左侧列不固定(000154):课程编号/课程名称随横向滚动,操作仍固定右侧
|
||||
{ colKey: 'code', title: '课程编号', width: 105 },
|
||||
{ colKey: 'name', title: '课程名称', width: 170 },
|
||||
@@ -537,7 +592,9 @@ const columns = [
|
||||
{ colKey: 'created_at', title: '创建时间', width: 140 },
|
||||
// 创建人(联查 users):记录课程录入人员
|
||||
{ colKey: 'creator_name', title: '创建人', width: 96 },
|
||||
{ colKey: 'op', title: '操作', width: 280, fixed: 'right' },
|
||||
// 核验状态(000157):固定右侧置于操作列前
|
||||
{ colKey: 'verify_status', title: '状态', width: 90, fixed: 'right' },
|
||||
{ colKey: 'op', title: '操作', width: 340, fixed: 'right' },
|
||||
]
|
||||
|
||||
const lecturerText = (row: TrainingLibraryCourse) =>
|
||||
@@ -558,7 +615,9 @@ const loadAll = async () => {
|
||||
members.value = (m && unwrap(m)?.items) || []
|
||||
depts.value = (d && unwrap(d)) || []
|
||||
configCategories.value = cats
|
||||
myDeptId.value = (me && unwrap(me)?.dept_id) || ''
|
||||
const meBody = me && unwrap(me)
|
||||
myDeptId.value = meBody?.dept_id || ''
|
||||
myUserId.value = meBody?.user_id || ''
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -769,12 +828,80 @@ const onDelete = async (row: TrainingLibraryCourse) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 发布状态展示文案(000154)
|
||||
// ---- 核验(000157):待核验 → 已确认,单个/批量共用核验端点(仅课长/经理限本部门) ----
|
||||
const selectedKeys = ref<string[]>([])
|
||||
const batchSaving = ref(false)
|
||||
|
||||
const onVerify = async (row: TrainingLibraryCourse) => {
|
||||
try {
|
||||
await verifyCourseLibraryItems([row.id])
|
||||
row.verify_status = 'confirmed'
|
||||
MessagePlugin.success(`课程「${row.name}」已核验确认,可发布`)
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '核验失败'))
|
||||
}
|
||||
}
|
||||
|
||||
const onBatchVerify = async () => {
|
||||
// 与后端口径一致:仅本部门待核验行提交,已确认/越权行直接跳过
|
||||
const rows = filteredItems.value.filter(
|
||||
(r) => selectedKeys.value.includes(r.id) && r.verify_status !== 'confirmed' && canVerifyCourse(r),
|
||||
)
|
||||
if (!rows.length) {
|
||||
MessagePlugin.warning('请先勾选本部门待核验状态的课程')
|
||||
return
|
||||
}
|
||||
batchSaving.value = true
|
||||
try {
|
||||
const { verified, skipped } = unwrap(await verifyCourseLibraryItems(rows.map((r) => r.id)))
|
||||
MessagePlugin.success(`批量核验完成:成功 ${verified} 条${skipped ? `,跳过 ${skipped} 条` : ''}`)
|
||||
selectedKeys.value = []
|
||||
loadAll()
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(apiErrorMessage(e, '批量核验失败'))
|
||||
} finally {
|
||||
batchSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const onBatchDelete = async () => {
|
||||
// 与后端口径一致:仅本部门待核验行提交(已确认/越权行跳过)
|
||||
const rows = filteredItems.value.filter((r) => selectedKeys.value.includes(r.id) && canDeleteCourse(r))
|
||||
if (!rows.length) {
|
||||
MessagePlugin.warning('请先勾选本部门待核验状态的课程')
|
||||
return
|
||||
}
|
||||
batchSaving.value = true
|
||||
let ok = 0
|
||||
let fail = 0
|
||||
try {
|
||||
for (const row of rows) {
|
||||
try {
|
||||
await deleteCourseLibraryItem(row.id)
|
||||
ok += 1
|
||||
} catch {
|
||||
fail += 1
|
||||
}
|
||||
}
|
||||
MessagePlugin.success(`批量删除完成:成功 ${ok} 条${fail ? `,失败 ${fail} 条` : ''}`)
|
||||
selectedKeys.value = []
|
||||
loadAll()
|
||||
} finally {
|
||||
batchSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 发布状态展示文案(000154;000157 起草稿文案调整为「待发布」)
|
||||
const publishStatusText = (status?: string) =>
|
||||
({ published: '已发布', offline: '已下线', draft: '草稿' }[status || 'draft'] || '草稿')
|
||||
({ published: '已发布', offline: '已下线', draft: '待发布' }[status || 'draft'] || '待发布')
|
||||
|
||||
// 发布/下线(000154):发布后进入培训中心「和信课程」目录,下线即从目录撤回
|
||||
const onSetPublishStatus = async (row: TrainingLibraryCourse, status: 'published' | 'offline') => {
|
||||
// 发布前置校验(000157):仅「已确认」课程可发布(后端兜底同样拦截)
|
||||
if (status === 'published' && row.verify_status !== 'confirmed') {
|
||||
MessagePlugin.warning('该课程尚未核验,请先由本部门课长/经理核验确认后再发布')
|
||||
return
|
||||
}
|
||||
try {
|
||||
const updated = unwrap(
|
||||
status === 'published' ? await publishCourseLibraryItem(row.id) : await offlineCourseLibraryItem(row.id),
|
||||
|
||||
@@ -23,6 +23,14 @@ func (r *trainingRepository) ListCourseLibrary(ctx context.Context, tenantID uin
|
||||
if q.Keyword != "" {
|
||||
tx = tx.Where("tr_course_library.name ILIKE ?", "%"+q.Keyword+"%")
|
||||
}
|
||||
// 数据范围过滤(handler 按调用方角色强制注入,000157):dept_id=课长/经理
|
||||
// 本部门;related_user_id=无维护角色的用户仅见自己创建或授课的课程。
|
||||
if q.DeptID != "" {
|
||||
tx = tx.Where("tr_course_library.owner_dept_id = ?", q.DeptID)
|
||||
}
|
||||
if q.RelatedUserID != "" {
|
||||
tx = tx.Where("tr_course_library.creator_id = ? OR tr_course_library.lecturer_id = ?", q.RelatedUserID, q.RelatedUserID)
|
||||
}
|
||||
}
|
||||
var total int64
|
||||
if err := tx.Count(&total).Error; err != nil {
|
||||
@@ -92,9 +100,30 @@ func (r *trainingRepository) UpdateCourseLibraryItem(ctx context.Context, item *
|
||||
"file_size": item.FileSize,
|
||||
// 课件知识库文档 id(上传同步后回填;code 编号列只读不在更新列)。
|
||||
"knowledge_id": item.KnowledgeID,
|
||||
// 核验状态(000157):编辑/换课件后由服务层重置为待核验并清空核验痕迹。
|
||||
"verify_status": item.VerifyStatus,
|
||||
"confirmed_by": item.ConfirmedBy,
|
||||
"confirmed_at": item.ConfirmedAt,
|
||||
}).Error
|
||||
}
|
||||
|
||||
// ConfirmCourseLibraryItems 批量核验课程条目(000157):仅待核验行置为已确认并
|
||||
// 回填核验人/时间(幂等:已确认行不重复更新),返回实际核验行数。
|
||||
func (r *trainingRepository) ConfirmCourseLibraryItems(ctx context.Context, tenantID uint64, ids []string, verifierID string) (int64, error) {
|
||||
if len(ids) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
tx := r.db.WithContext(ctx).Model(&types.TrainingCourseLibrary{}).
|
||||
Where("tenant_id = ? AND id IN ? AND verify_status = ?", tenantID, ids, types.CourseLibraryVerifyPending).
|
||||
Updates(map[string]interface{}{
|
||||
"verify_status": types.CourseLibraryVerifyConfirmed,
|
||||
"confirmed_by": verifierID,
|
||||
"confirmed_at": time.Now(),
|
||||
"updated_at": time.Now(),
|
||||
})
|
||||
return tx.RowsAffected, tx.Error
|
||||
}
|
||||
|
||||
// UpdateCourseLibraryPublishStatus 更新课程管理条目发布状态(000154):
|
||||
// published 已发布 / offline 已下线,供培训中心「和信课程」目录过滤。
|
||||
func (r *trainingRepository) UpdateCourseLibraryPublishStatus(ctx context.Context, tenantID uint64, id, status string) error {
|
||||
|
||||
@@ -358,6 +358,17 @@ func (s *trainingService) PublishCourse(ctx context.Context, tenantID uint64, id
|
||||
if course.Status == types.TrainingCoursePublished {
|
||||
return course, nil
|
||||
}
|
||||
// 关联课程管理条目须已核验确认(000157):月培训计划发布/保存并发布共用本端点,
|
||||
// 未核验的课程拦截并友好提示,核验入口在「课程管理」。
|
||||
if course.LibraryCourseID != "" {
|
||||
lib, libErr := s.repo.GetCourseLibraryItem(ctx, tenantID, course.LibraryCourseID)
|
||||
if libErr != nil || lib == nil {
|
||||
return nil, errors.NewBadRequestError("关联的课程管理条目不存在,请先在「课程管理」中确认该课程")
|
||||
}
|
||||
if lib.VerifyStatus != types.CourseLibraryVerifyConfirmed {
|
||||
return nil, errors.NewBadRequestError(fmt.Sprintf("关联课程《%s》尚未核验确认,请先在「课程管理」中由所属部门课长/经理核验后再发布", lib.Name))
|
||||
}
|
||||
}
|
||||
course.Status = types.TrainingCoursePublished
|
||||
if err := s.repo.UpdateCourse(ctx, course); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -103,6 +103,8 @@ func (s *trainingService) SaveCourseLibraryItem(ctx context.Context, tenantID ui
|
||||
item.ID = trainingNewID()
|
||||
item.TenantID = tenantID
|
||||
item.CreatorID = updaterID
|
||||
// 新增即待核验(000157):由所属部门课长/经理核验后方可发布。
|
||||
item.VerifyStatus = types.CourseLibraryVerifyPending
|
||||
// 仅传部门名时按组织架构解析为 id(不阻断保存)。
|
||||
s.resolveCourseLibraryDept(ctx, tenantID, item)
|
||||
// 课程编号(CRS-####,创建时由服务端生成;编号列只读,不收前端值)。
|
||||
@@ -129,6 +131,10 @@ func (s *trainingService) SaveCourseLibraryItem(ctx context.Context, tenantID ui
|
||||
if item.KnowledgeID == "" {
|
||||
item.KnowledgeID = old.KnowledgeID
|
||||
}
|
||||
// 编辑即回待核验(000157):内容变更后原核验结论作废,需重新核验。
|
||||
item.VerifyStatus = types.CourseLibraryVerifyPending
|
||||
item.ConfirmedBy = ""
|
||||
item.ConfirmedAt = nil
|
||||
item.TenantID = tenantID
|
||||
if err := s.repo.UpdateCourseLibraryItem(ctx, item); err != nil {
|
||||
return nil, err
|
||||
@@ -137,10 +143,19 @@ func (s *trainingService) SaveCourseLibraryItem(ctx context.Context, tenantID ui
|
||||
}
|
||||
|
||||
// DeleteCourseLibraryItem 软删课程管理条目(月培训计划已创建的历史计划不受影响)。
|
||||
func (s *trainingService) DeleteCourseLibraryItem(ctx context.Context, tenantID uint64, id string) error {
|
||||
if _, err := s.repo.GetCourseLibraryItem(ctx, tenantID, id); err != nil {
|
||||
// 000157 收紧:仅「待核验」状态可删(已确认课程须走核验流程,不可绕过);
|
||||
// deptScope 非空(课长/经理)时仅可删除本部门课程。
|
||||
func (s *trainingService) DeleteCourseLibraryItem(ctx context.Context, tenantID uint64, id, deptScope string) error {
|
||||
item, err := s.repo.GetCourseLibraryItem(ctx, tenantID, id)
|
||||
if err != nil || item == nil {
|
||||
return werrors.NewNotFoundError("课程不存在")
|
||||
}
|
||||
if item.VerifyStatus != types.CourseLibraryVerifyPending {
|
||||
return werrors.NewBadRequestError("仅待核验状态的课程可删除,已确认课程不可删除")
|
||||
}
|
||||
if deptScope != "" && item.OwnerDeptID != deptScope {
|
||||
return werrors.NewForbiddenError("仅可删除本部门的课程")
|
||||
}
|
||||
return s.repo.DeleteCourseLibraryItem(ctx, tenantID, id)
|
||||
}
|
||||
|
||||
@@ -155,6 +170,7 @@ func (s *trainingService) GetCourseLibraryItem(ctx context.Context, tenantID uin
|
||||
|
||||
// SetCourseLibraryPublishStatus 课程条目发布/下线(000154):published 已发布 /
|
||||
// offline 已下线;培训中心「和信课程」目录仅展示已发布课程。
|
||||
// 发布前置校验核验状态(000157):仅「已确认」课程可发布。
|
||||
func (s *trainingService) SetCourseLibraryPublishStatus(ctx context.Context, tenantID uint64, id, status string) error {
|
||||
if status != "published" && status != "offline" {
|
||||
return werrors.NewBadRequestError("发布状态不合法(仅支持发布/下线)")
|
||||
@@ -163,9 +179,42 @@ func (s *trainingService) SetCourseLibraryPublishStatus(ctx context.Context, ten
|
||||
if err != nil || item == nil {
|
||||
return werrors.NewNotFoundError("课程不存在")
|
||||
}
|
||||
if status == "published" && item.VerifyStatus != types.CourseLibraryVerifyConfirmed {
|
||||
return werrors.NewBadRequestError(fmt.Sprintf("课程《%s》尚未核验,请先由所属部门课长/经理核验确认后再发布", item.Name))
|
||||
}
|
||||
return s.repo.UpdateCourseLibraryPublishStatus(ctx, tenantID, id, status)
|
||||
}
|
||||
|
||||
// VerifyCourseLibraryItems 批量核验课程条目(000157,单个/批量共用):核验人所在
|
||||
// 部门(deptScope,handler 保证恒非空)必须与课程所属部门一致;已确认行与部门
|
||||
// 不匹配行跳过,返回实际核验数与跳过数,全无效时报错提示。
|
||||
func (s *trainingService) VerifyCourseLibraryItems(ctx context.Context, tenantID uint64, ids []string, verifierID, deptScope string) (int64, int64, error) {
|
||||
allowed := make([]string, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
item, err := s.repo.GetCourseLibraryItem(ctx, tenantID, id)
|
||||
if err != nil || item == nil {
|
||||
continue // 不存在的条目跳过,不阻断其余行
|
||||
}
|
||||
if item.VerifyStatus != types.CourseLibraryVerifyPending {
|
||||
continue // 已确认行幂等跳过
|
||||
}
|
||||
if deptScope != "" && item.OwnerDeptID != deptScope {
|
||||
continue // 课长/经理仅可核验本部门课程
|
||||
}
|
||||
allowed = append(allowed, id)
|
||||
}
|
||||
skipped := int64(len(ids) - len(allowed))
|
||||
if len(allowed) == 0 {
|
||||
return 0, skipped, werrors.NewBadRequestError("没有可核验的课程(仅本部门待核验状态的课程可核验)")
|
||||
}
|
||||
verified, err := s.repo.ConfirmCourseLibraryItems(ctx, tenantID, allowed, verifierID)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
logger.Infof(ctx, "[Training] course library verified, tenant=%d verified=%d skipped=%d verifier=%s", tenantID, verified, skipped, verifierID)
|
||||
return verified, skipped, nil
|
||||
}
|
||||
|
||||
// ImportCourseLibraryItems 批量导入(前端解析 Excel 后逐行提交,讲师已在
|
||||
// 前端按员工名册解析为 id / 外部姓名,与需求导入同口径)。
|
||||
func (s *trainingService) ImportCourseLibraryItems(ctx context.Context, tenantID uint64, items []*types.TrainingCourseLibrary, updaterID string) (int, error) {
|
||||
@@ -182,6 +231,8 @@ func (s *trainingService) ImportCourseLibraryItems(ctx context.Context, tenantID
|
||||
item.ID = trainingNewID()
|
||||
item.TenantID = tenantID
|
||||
item.CreatorID = updaterID
|
||||
// 导入即待核验(000157):与新增同口径,核验后方可发布。
|
||||
item.VerifyStatus = types.CourseLibraryVerifyPending
|
||||
// 课程编号逐行生成(CRS-####)。
|
||||
item.Code = s.nextCourseLibraryCode(ctx, tenantID)
|
||||
rows = append(rows, item)
|
||||
@@ -290,6 +341,10 @@ func (s *trainingService) UploadCourseLibraryMaterial(ctx context.Context, tenan
|
||||
if strings.TrimSpace(item.MaterialName) == "" {
|
||||
item.MaterialName = fh.Filename
|
||||
}
|
||||
// 换课件即回待核验(000157):课件内容变更后需重新核验。
|
||||
item.VerifyStatus = types.CourseLibraryVerifyPending
|
||||
item.ConfirmedBy = ""
|
||||
item.ConfirmedAt = nil
|
||||
if err := s.repo.UpdateCourseLibraryItem(ctx, item); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -353,6 +408,10 @@ func (s *trainingService) AttachCourseLibraryMaterialFromKnowledge(ctx context.C
|
||||
}
|
||||
item.FileKey, item.FileSize = "", 0
|
||||
item.KnowledgeID = knowledgeID
|
||||
// 换课件即回待核验(000157):课件内容变更后需重新核验。
|
||||
item.VerifyStatus = types.CourseLibraryVerifyPending
|
||||
item.ConfirmedBy = ""
|
||||
item.ConfirmedAt = nil
|
||||
if err := s.repo.UpdateCourseLibraryItem(ctx, item); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -180,6 +180,32 @@ func (h *Handler) callerDeptScope(c *gin.Context) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// callerCourseLibraryScope 课程管理列表的数据范围(000157):人事/空间管理员全局
|
||||
// (两个返回值均空);课长/经理限本部门(owner_dept_id);讲师/学员(无维护角色)
|
||||
// 收窄为「与我相关」——自己创建或自己授课的课程。relatedUserID 非空时 repo 按
|
||||
// creator_id/lecturer_id 过滤。
|
||||
func (h *Handler) callerCourseLibraryScope(c *gin.Context) (deptID, relatedUserID string) {
|
||||
if callerRole := types.TenantRoleFromContext(c.Request.Context()); callerRole.IsValid() &&
|
||||
(callerRole == types.TenantRoleAdmin || callerRole == types.TenantRoleOwner) {
|
||||
return "", ""
|
||||
}
|
||||
userID := callerUserID(c)
|
||||
member, err := h.svc.CurrentMember(c.Request.Context(), callerTenantID(c), userID)
|
||||
if err != nil || member == nil {
|
||||
return "", userID
|
||||
}
|
||||
roles := h.svc.ExpandTrainingRoles(c.Request.Context(), callerTenantID(c), member.TrainingRoleList())
|
||||
switch {
|
||||
case types.HasTrainingRole(roles, types.TrainingRoleHR):
|
||||
return "", ""
|
||||
case types.HasTrainingRole(roles, types.TrainingRoleSupervisor):
|
||||
// 经理继承课长权限组,与课长一致收窄本部门
|
||||
return member.DeptID, ""
|
||||
default:
|
||||
return "", userID
|
||||
}
|
||||
}
|
||||
|
||||
// checkCourseVisibility 课程详情可见性:全局视角与已发布课程对所有人开放;
|
||||
// 纯讲师另可见自己相关的未发布课程(供维护);纯学员不可见未发布课程。
|
||||
func (h *Handler) checkCourseVisibility(c *gin.Context, course *types.TrainingCourse) error {
|
||||
|
||||
@@ -17,7 +17,9 @@ import (
|
||||
// 字段:课程名称/所属部门(org_depts)/说明/适合人员/分类(配置中心
|
||||
// course_category_dict 可配,可自定义)/类型(必修课/选修课)/线上或线下/
|
||||
// 讲师/时长/课件。月培训计划的「计划名称」从本表选择。
|
||||
// 列表 Viewer 可读(月培训计划下拉同源);维护动作限人事/课长/讲师。
|
||||
// 列表 Viewer 可读(月培训计划下拉同源),数据范围按角色收窄(000157):
|
||||
// 人事全部/课长经理本部门/讲师学员仅「与我相关」;维护(新增/编辑/发布/导入/
|
||||
// 导出)限人事/课长/讲师;核验/删除仅课长/经理且限本部门、删除仅限待核验行。
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// saveCourseLibraryRequest is the body of POST /training/course-library.
|
||||
@@ -62,8 +64,12 @@ func toCourseLibrary(req saveCourseLibraryRequest) *types.TrainingCourseLibrary
|
||||
}
|
||||
|
||||
// ListCourseLibrary GET /training/course-library — 课程管理列表(关键字分页)。
|
||||
// 数据范围按调用方角色强制注入(000157):人事全部/课长经理本部门/讲师学员仅
|
||||
// 「与我相关」;月培训计划「计划名称」下拉同源,口径一致。
|
||||
func (h *Handler) ListCourseLibrary(c *gin.Context) {
|
||||
items, total, err := h.svc.ListCourseLibraryItems(c.Request.Context(), callerTenantID(c), listQueryFromRequest(c))
|
||||
q := listQueryFromRequest(c)
|
||||
q.DeptID, q.RelatedUserID = h.callerCourseLibraryScope(c)
|
||||
items, total, err := h.svc.ListCourseLibraryItems(c.Request.Context(), callerTenantID(c), q)
|
||||
if err != nil {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
@@ -72,15 +78,19 @@ func (h *Handler) ListCourseLibrary(c *gin.Context) {
|
||||
}
|
||||
|
||||
// SaveCourseLibraryItem POST /training/course-library — 新增/编辑(id 空 = 新增)。
|
||||
// 维护角色限人事/课长/讲师;无维护角色的用户兜底仅可编辑「与我相关」课程
|
||||
// (本人创建或本人授课,不可新增,000157)。
|
||||
func (h *Handler) SaveCourseLibraryItem(c *gin.Context) {
|
||||
if !h.requireRoles(c, types.TrainingRoleHR, types.TrainingRoleSupervisor, types.TrainingRoleLecturer) {
|
||||
return
|
||||
}
|
||||
var req saveCourseLibraryRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
_ = c.Error(errors.NewBadRequestError("请求参数不合法").WithDetails(err.Error()))
|
||||
return
|
||||
}
|
||||
if !h.requireRoles(c, types.TrainingRoleHR, types.TrainingRoleSupervisor, types.TrainingRoleLecturer) {
|
||||
if req.ID == "" || !h.canEditRelatedLibraryCourse(c, req.ID) {
|
||||
return // requireRoles/兜底校验已写 403/404
|
||||
}
|
||||
}
|
||||
item, err := h.svc.SaveCourseLibraryItem(c.Request.Context(), callerTenantID(c), toCourseLibrary(req), callerUserID(c))
|
||||
if err != nil {
|
||||
_ = c.Error(err)
|
||||
@@ -89,12 +99,34 @@ func (h *Handler) SaveCourseLibraryItem(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": item})
|
||||
}
|
||||
|
||||
// DeleteCourseLibraryItem DELETE /training/course-library/:id — 删除(人事/课长)。
|
||||
// canEditRelatedLibraryCourse 无维护角色用户的编辑兜底(000157):目标课程须存在
|
||||
// 且创建人或讲师为本人;学员编辑同样触发服务层「编辑即回待核验」重核验流程。
|
||||
func (h *Handler) canEditRelatedLibraryCourse(c *gin.Context, id string) bool {
|
||||
item, err := h.svc.GetCourseLibraryItem(c.Request.Context(), callerTenantID(c), id)
|
||||
if err != nil || item == nil {
|
||||
_ = c.Error(errors.NewNotFoundError("课程不存在"))
|
||||
return false
|
||||
}
|
||||
userID := callerUserID(c)
|
||||
if item.CreatorID != userID && item.LecturerID != userID {
|
||||
_ = c.Error(errors.NewForbiddenError("仅可编辑本人创建或本人授课的课程"))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// DeleteCourseLibraryItem DELETE /training/course-library/:id — 删除
|
||||
// (000157:仅本部门课长/经理,仅待核验状态;人事/学员/空间管理员无删除权限)。
|
||||
func (h *Handler) DeleteCourseLibraryItem(c *gin.Context) {
|
||||
if !h.requireRoles(c, types.TrainingRoleHR, types.TrainingRoleSupervisor) {
|
||||
if !h.requireRoles(c, types.TrainingRoleSupervisor, types.TrainingRoleManager) {
|
||||
return
|
||||
}
|
||||
if err := h.svc.DeleteCourseLibraryItem(c.Request.Context(), callerTenantID(c), c.Param("id")); err != nil {
|
||||
deptID, ok := h.callerVerifyDeptScope(c)
|
||||
if !ok {
|
||||
_ = c.Error(errors.NewForbiddenError("仅本部门课长/经理可删除课程"))
|
||||
return
|
||||
}
|
||||
if err := h.svc.DeleteCourseLibraryItem(c.Request.Context(), callerTenantID(c), c.Param("id"), deptID); err != nil {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
}
|
||||
@@ -136,6 +168,53 @@ func (h *Handler) SetCourseLibraryPublishStatus(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": item})
|
||||
}
|
||||
|
||||
// callerVerifyDeptScope 核验/删除的部门口径(000157):一律按课长身份收窄本部门,
|
||||
// 不设全局旁路(人事/空间管理员均不例外)——核验权只属于「该部门课长/经理」。
|
||||
// 返回所在部门 id 与是否具备身份;无课长身份(或课长未分配部门)一律拒绝。
|
||||
func (h *Handler) callerVerifyDeptScope(c *gin.Context) (deptID string, ok bool) {
|
||||
member, err := h.svc.CurrentMember(c.Request.Context(), callerTenantID(c), callerUserID(c))
|
||||
if err != nil || member == nil {
|
||||
return "", false
|
||||
}
|
||||
roles := h.svc.ExpandTrainingRoles(c.Request.Context(), callerTenantID(c), member.TrainingRoleList())
|
||||
// 经理继承课长权限组,与课长同口径;人事角色不构成核验身份。
|
||||
if types.HasTrainingRole(roles, types.TrainingRoleSupervisor) && member.DeptID != "" {
|
||||
return member.DeptID, true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// verifyCourseLibraryRequest is the body of POST /training/course-library/verify
|
||||
// (单个/批量核验共用,ids 长度 1 即单条)。
|
||||
type verifyCourseLibraryRequest struct {
|
||||
IDs []string `json:"ids" binding:"required,min=1"`
|
||||
}
|
||||
|
||||
// VerifyCourseLibraryItems POST /training/course-library/verify — 课程条目核验
|
||||
// (000157):仅本部门课长/经理可核验(人事/讲师/学员/空间管理员均无跨部门核验权),
|
||||
// 待核验 → 已确认;越权/已确认/不存在行跳过不阻断其余行。
|
||||
func (h *Handler) VerifyCourseLibraryItems(c *gin.Context) {
|
||||
if !h.requireRoles(c, types.TrainingRoleSupervisor, types.TrainingRoleManager) {
|
||||
return
|
||||
}
|
||||
var req verifyCourseLibraryRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
_ = c.Error(errors.NewBadRequestError("请求参数不合法").WithDetails(err.Error()))
|
||||
return
|
||||
}
|
||||
deptID, ok := h.callerVerifyDeptScope(c)
|
||||
if !ok {
|
||||
_ = c.Error(errors.NewForbiddenError("仅本部门课长/经理可核验课程"))
|
||||
return
|
||||
}
|
||||
verified, skipped, err := h.svc.VerifyCourseLibraryItems(c.Request.Context(), callerTenantID(c), req.IDs, callerUserID(c), deptID)
|
||||
if err != nil {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"verified": verified, "skipped": skipped}})
|
||||
}
|
||||
|
||||
// ImportCourseLibraryRequest is the body of POST /training/course-library/import
|
||||
// (前端解析 Excel 后逐行提交,与需求导入同口径)。
|
||||
type ImportCourseLibraryRequest struct {
|
||||
|
||||
@@ -93,6 +93,8 @@ func RegisterTrainingRoutes(r *gin.RouterGroup, h *training.Handler, g *rbacGuar
|
||||
// 发布/下线(000154):静态段 :action 须先于 :id 参数段注册区分
|
||||
trainingGroup.POST("/course-library/:id/publish", g.Contributor(), h.SetCourseLibraryPublishStatus)
|
||||
trainingGroup.POST("/course-library/:id/offline", g.Contributor(), h.SetCourseLibraryPublishStatus)
|
||||
// 核验(000157):单个/批量共用(ids 数组),仅课长/经理限本部门。
|
||||
trainingGroup.POST("/course-library/verify", g.Contributor(), h.VerifyCourseLibraryItems)
|
||||
// 导入/导出:与需求域同口径(前端解析 Excel 后按行提交;导出 xlsx 下载)。
|
||||
trainingGroup.POST("/course-library/import", g.Contributor(), h.ImportCourseLibrary)
|
||||
trainingGroup.POST("/course-library/export", g.Contributor(), h.ExportCourseLibrary)
|
||||
|
||||
@@ -18,6 +18,9 @@ type TrainingListQuery struct {
|
||||
// LecturerID 讲师数据范围过滤(handler 按调用方角色强制注入:
|
||||
// 纯讲师只能看到自己讲师相关的课程/场次)。
|
||||
LecturerID string
|
||||
// RelatedUserID 课程管理「与我相关」范围过滤(handler 对无维护角色的用户
|
||||
// 强制注入:仅可见自己创建或自己授课的课程)。
|
||||
RelatedUserID string
|
||||
// Scope 视图口径:"student"=学员目录视图(已发布课程/全场次),用于区分
|
||||
// 讲师的学习视角与其课程维护视角(handler 按此决定是否注入讲师过滤)。
|
||||
Scope string
|
||||
@@ -84,6 +87,9 @@ type TrainingRepository interface {
|
||||
UpdateCourseLibraryItem(ctx context.Context, item *types.TrainingCourseLibrary) error
|
||||
// UpdateCourseLibraryPublishStatus 更新课程条目发布状态(000154:发布/下线)。
|
||||
UpdateCourseLibraryPublishStatus(ctx context.Context, tenantID uint64, id, status string) error
|
||||
// ConfirmCourseLibraryItems 批量核验课程条目(000157):仅 pending 行置为
|
||||
// confirmed 并回填核验人/时间,返回实际核验行数。
|
||||
ConfirmCourseLibraryItems(ctx context.Context, tenantID uint64, ids []string, verifierID string) (int64, error)
|
||||
BatchCreateCourseLibrary(ctx context.Context, items []*types.TrainingCourseLibrary) error
|
||||
DeleteCourseLibraryItem(ctx context.Context, tenantID uint64, id string) error
|
||||
|
||||
@@ -300,9 +306,14 @@ type TrainingService interface {
|
||||
SaveCourseLibraryItem(ctx context.Context, tenantID uint64, item *types.TrainingCourseLibrary, updaterID string) (*types.TrainingCourseLibrary, error)
|
||||
// SetCourseLibraryPublishStatus 课程条目发布/下线(000154)。
|
||||
SetCourseLibraryPublishStatus(ctx context.Context, tenantID uint64, id, status string) error
|
||||
// VerifyCourseLibraryItems 批量核验课程条目(000157,仅本部门课长/经理):
|
||||
// deptScope 为调用方所在部门(恒非空),仅核验所属部门匹配的条目。
|
||||
VerifyCourseLibraryItems(ctx context.Context, tenantID uint64, ids []string, verifierID, deptScope string) (verified int64, skipped int64, err error)
|
||||
// GetCourseLibraryItem 取单条课程条目(发布/下线后回显)。
|
||||
GetCourseLibraryItem(ctx context.Context, tenantID uint64, id string) (*types.TrainingCourseLibrary, error)
|
||||
DeleteCourseLibraryItem(ctx context.Context, tenantID uint64, id string) error
|
||||
// DeleteCourseLibraryItem 软删课程条目(仅待核验状态可删;deptScope 非空时
|
||||
// 校验所属部门匹配,000157 仅课长/经理限本部门)。
|
||||
DeleteCourseLibraryItem(ctx context.Context, tenantID uint64, id, deptScope string) error
|
||||
// ImportCourseLibraryItems 批量导入(前端解析 Excel 后按行提交)。
|
||||
ImportCourseLibraryItems(ctx context.Context, tenantID uint64, items []*types.TrainingCourseLibrary, updaterID string) (int, error)
|
||||
// ExportCourseLibrary 导出 Excel(excelize;ids 空 = 全量)。
|
||||
|
||||
@@ -567,6 +567,15 @@ type TrainingCourseChangeLog struct {
|
||||
// TableName pins the physical table name.
|
||||
func (TrainingCourseChangeLog) TableName() string { return "tr_course_change_logs" }
|
||||
|
||||
// 课程管理条目核验状态(000157):新增/编辑后一律待核验,由所属部门课长/经理
|
||||
// 核验确认;发布课程、发布月培训计划(关联课程)前必须已确认。
|
||||
const (
|
||||
// CourseLibraryVerifyPending 待核验(初始状态)。
|
||||
CourseLibraryVerifyPending = "pending"
|
||||
// CourseLibraryVerifyConfirmed 已确认(课长/经理核验通过)。
|
||||
CourseLibraryVerifyConfirmed = "confirmed"
|
||||
)
|
||||
|
||||
// TrainingCourseLibrary 课程管理条目(课程资产主数据,000151)。
|
||||
// 月培训计划的「计划名称」从本表选择,选中计划创建时带 library_course_id 关联。
|
||||
type TrainingCourseLibrary struct {
|
||||
@@ -608,6 +617,13 @@ type TrainingCourseLibrary struct {
|
||||
// PublishStatus 发布状态(000154):draft 草稿/published 已发布/offline 已下线;
|
||||
// 培训中心「和信课程」目录仅展示已发布且部门范围覆盖查看人的课程。
|
||||
PublishStatus string `json:"publish_status" gorm:"type:varchar(16);default:'draft'"`
|
||||
// VerifyStatus 核验状态(000157):pending 待核验/confirmed 已确认;新增/编辑
|
||||
// 后回待核验,由所属部门课长/经理核验;发布前必须已确认。
|
||||
VerifyStatus string `json:"verify_status" gorm:"type:varchar(16);default:'pending'"`
|
||||
// ConfirmedBy 核验人(课长/经理用户 id;核验时回填,编辑重置时清空)。
|
||||
ConfirmedBy string `json:"confirmed_by" gorm:"type:varchar(36);default:''"`
|
||||
// ConfirmedAt 核验时间。
|
||||
ConfirmedAt *time.Time `json:"confirmed_at"`
|
||||
// ClearFile 课件文件移除标记(请求侧瞬态,不落库:置 true 时强制清空 file_* 三列)。
|
||||
ClearFile bool `json:"clear_file" gorm:"-"`
|
||||
// CreatorID 创建人(平台用户 id)。
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
-- 000157 回滚:移除课程管理条目核验状态三列。
|
||||
ALTER TABLE tr_course_library DROP COLUMN IF EXISTS verify_status;
|
||||
ALTER TABLE tr_course_library DROP COLUMN IF EXISTS confirmed_by;
|
||||
ALTER TABLE tr_course_library DROP COLUMN IF EXISTS confirmed_at;
|
||||
@@ -0,0 +1,20 @@
|
||||
-- Migration: 000157_course_library_verify_status
|
||||
-- 课程管理条目增加核验状态:pending 待核验(初始状态)/ confirmed 已确认。
|
||||
-- 新增/导入/编辑(含重新上传课件)后一律回到待核验,由所属部门课长/经理核验;
|
||||
-- 发布课程、发布月培训计划(关联课程)前必须已确认。存量课程回填为待核验
|
||||
-- (NOT NULL DEFAULT 随加列自动填充),核验人/核验时间留审计痕迹。
|
||||
|
||||
DO $$ BEGIN RAISE NOTICE '[Migration 000157] Adding tr_course_library verify_status / confirmed_by / confirmed_at columns...'; END $$;
|
||||
|
||||
ALTER TABLE tr_course_library
|
||||
ADD COLUMN IF NOT EXISTS verify_status VARCHAR(16) NOT NULL DEFAULT 'pending';
|
||||
|
||||
ALTER TABLE tr_course_library
|
||||
ADD COLUMN IF NOT EXISTS confirmed_by VARCHAR(36) NOT NULL DEFAULT '';
|
||||
|
||||
ALTER TABLE tr_course_library
|
||||
ADD COLUMN IF NOT EXISTS confirmed_at TIMESTAMP WITH TIME ZONE;
|
||||
|
||||
COMMENT ON COLUMN tr_course_library.verify_status IS 'Verify status: pending 待核验(initial, set on create/import/edit) / confirmed 已确认(by dept supervisor/manager); publishing requires confirmed';
|
||||
COMMENT ON COLUMN tr_course_library.confirmed_by IS 'User id of the verifier (dept supervisor/manager) who confirmed the course';
|
||||
COMMENT ON COLUMN tr_course_library.confirmed_at IS 'Time the course was confirmed';
|
||||
Reference in new issue
Block a user