feat(training): 企业培训迭代:核验权限收窄、课程发布状态与培训中心改版
需求域: - 需求导入修复内/外培训与外部讲师落库;按模板标题年入库(年-月一致) - 核验确认收窄为「需求归属部门+经理职称角色」,越权提示联系部门经理 - 确认转月计划后自动推送讲师/课长维护;导入后自动推送部门经理核验(站内+企微) 课程域: - 课程管理发布状态字段(迁移000154)+发布/下线;培训中心「和信课程」目录 - 需求讲师改选后回写课程管理;确认同步带出适合人员/课件/试题 - 月计划详情课件/试题更换(上传/知识库选择/题库换绑)回写课程管理, 无关联条目的存量计划自动创建课程条目 模板与表单: - 教育训练需求表:适合人员/内-外培训口径;部门联动课程下拉; 适合人员/讲师按所选课程自动带出;在线提报课程下拉(本部门)自动带出分类/讲师/适合人员 页面与权限: - 培训中心页签重组(和信课程/我的培训/我的考试),移除线上/线下页签 - 数据驾驶舱迁侧栏(职称角色之下);职称角色迁至更多工具配置中心之后 - 配置中心/职称角色对经理开放;页签「职称角色」更名「角色权限」 - 修复年度下拉空白(TDesign options 需对象数组)、月计划列表地点兜底 其他: 培训预览端口修正与 dev:training 脚本;tmp-extract-duckdb 加入 gitignore
This commit is contained in:
1 parent
aae041a0b4
commit
242dd7e1a6
47 files changed
+5882
-1134
No files matched your search
@@ -157,8 +157,9 @@ func (h *Handler) callerDataScope(c *gin.Context) (dataScope, *types.TrainingMem
|
||||
}
|
||||
}
|
||||
|
||||
// callerDeptScope 计划类列表的部门范围限定:纯课长(有课长角色、无人事/经理
|
||||
// 全局视角)只能查询本部门数据,返回其所在部门 ID;其余角色返回空串(不限定)。
|
||||
// callerDeptScope 计划类列表的部门范围限定:人事/空间管理员为全局视角(返回
|
||||
// 空串不限定);经理/课长(含继承课长的自定义角色)只能查询本部门数据,返回其
|
||||
// 所在部门 ID;其余角色(讲师/学员)不限定(本就无管理入口)。
|
||||
func (h *Handler) callerDeptScope(c *gin.Context) string {
|
||||
if callerRole := types.TenantRoleFromContext(c.Request.Context()); callerRole.IsValid() &&
|
||||
(callerRole == types.TenantRoleAdmin || callerRole == types.TenantRoleOwner) {
|
||||
@@ -169,12 +170,14 @@ func (h *Handler) callerDeptScope(c *gin.Context) string {
|
||||
return ""
|
||||
}
|
||||
roles := h.svc.ExpandTrainingRoles(c.Request.Context(), callerTenantID(c), member.TrainingRoleList())
|
||||
if types.HasTrainingRole(roles, types.TrainingRoleHR) ||
|
||||
types.HasTrainingRole(roles, types.TrainingRoleManager) ||
|
||||
!types.HasTrainingRole(roles, types.TrainingRoleSupervisor) {
|
||||
// 人事全量;经理继承课长权限组,与课长一致收窄本部门
|
||||
if types.HasTrainingRole(roles, types.TrainingRoleHR) {
|
||||
return ""
|
||||
}
|
||||
return member.DeptID
|
||||
if types.HasTrainingRole(roles, types.TrainingRoleSupervisor) {
|
||||
return member.DeptID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// checkCourseVisibility 课程详情可见性:全局视角与已发布课程对所有人开放;
|
||||
@@ -314,7 +317,8 @@ func (h *Handler) ImportMembers(c *gin.Context) {
|
||||
// 企微 userid(培训提醒推送目标;空串=解绑)。
|
||||
func (h *Handler) UpdateMemberWecomUserid(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
if !h.requireRoles(c, types.TrainingRoleHR) {
|
||||
// 经理与人事同权(000159):职称角色页对经理开放。
|
||||
if !h.requireRoles(c, types.TrainingRoleHR, types.TrainingRoleManager) {
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
@@ -341,10 +345,10 @@ func rolesToJSON(roles []string) types.JSON {
|
||||
return types.JSON(data)
|
||||
}
|
||||
|
||||
// UpdateMemberRoles PUT /training/members/:id/roles
|
||||
// UpdateMemberRoles PUT /training/members/:id/roles — 经理与人事同权(000159)。
|
||||
func (h *Handler) UpdateMemberRoles(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
if !h.requireRoles(c, types.TrainingRoleHR) {
|
||||
if !h.requireRoles(c, types.TrainingRoleHR, types.TrainingRoleManager) {
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
@@ -391,6 +395,17 @@ func (h *Handler) ListDemands(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"items": items, "total": total}})
|
||||
}
|
||||
|
||||
// ListDemandYears GET /training/demands/years — 需求库实际年份去重列表(降序),
|
||||
// 年度需求收集页年份下拉数据源(前端默认选中最新一年);纯课长收窄本部门口径。
|
||||
func (h *Handler) ListDemandYears(c *gin.Context) {
|
||||
years, err := h.svc.ListDemandYears(c.Request.Context(), callerTenantID(c), h.callerDeptScope(c))
|
||||
if err != nil {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": years})
|
||||
}
|
||||
|
||||
// saveDemandRequest is the body of POST /training/demands.
|
||||
// 字段口径对齐「年度教育培训收集模板」(docs/moban):厂区/主办单位(→dept_id)/课程名称/
|
||||
// 次数/参加人员(→post_scope)/地点/分类/培训讲师/月份。
|
||||
@@ -485,6 +500,8 @@ func (h *Handler) SaveDemand(c *gin.Context) {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
}
|
||||
// 需求讲师回写课程管理(000156):在线改选讲师后课程管理同步追加(fail-open)。
|
||||
h.syncDemandLecturerToLibrary(ctx, callerTenantID(c), callerUserID(c), []*types.TrainingDemand{demand})
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": demand})
|
||||
}
|
||||
|
||||
@@ -550,6 +567,7 @@ func (h *Handler) ImportDemands(c *gin.Context) {
|
||||
Year: item.Year, DeptID: item.DeptID, CourseName: item.CourseName,
|
||||
Plant: item.Plant, Category: item.Category, SessionCount: item.SessionCount,
|
||||
Location: item.Location, PostScope: item.PostScope, LecturerID: item.LecturerID,
|
||||
LecturerExternal: trimSpace(item.LecturerExternal), TrainType: trimSpace(item.TrainType),
|
||||
TargetCount: item.TargetCount, Hours: item.Hours, ExpectMonth: item.ExpectMonth,
|
||||
PlannedTime: trimSpace(item.PlannedTime), Remark: item.Remark,
|
||||
})
|
||||
@@ -559,22 +577,57 @@ func (h *Handler) ImportDemands(c *gin.Context) {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"imported": len(result)}})
|
||||
// 需求讲师回写课程管理(000156):改选讲师后课程管理同步追加该讲师(fail-open)。
|
||||
h.syncDemandLecturerToLibrary(ctx, callerTenantID(c), callerUserID(c), demands)
|
||||
// 导入后自动推送部门经理核验(000157,站内+企微,fail-open)。
|
||||
notified := h.notifyDemandVerify(ctx, callerTenantID(c), demands)
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"imported": len(result), "notified": notified}})
|
||||
}
|
||||
|
||||
// ConfirmDemand POST /training/demands/:id/confirm — 人事复核确认。
|
||||
// demandConfirmDenied 年度需求核验确认的统一拒绝文案(000154 权限收窄):
|
||||
// 仅「需求归属部门」内、职称角色为经理的成员可确认,其余人员一律提示联系部门经理。
|
||||
const demandConfirmDenied = "暂无权限,请联系部门经理~"
|
||||
|
||||
// ConfirmDemand POST /training/demands/:id/confirm — 经理核验确认(部门+角色双校验)。
|
||||
// 仅「需求归属部门的成员且职称角色为经理」可核验(000154 收窄:人事/空间管理员/
|
||||
// 其他部门经理一律拒绝),统一提示「暂无权限,请联系部门经理~」;
|
||||
// 部门校验先于确认落库,避免越权时已改状态。
|
||||
func (h *Handler) ConfirmDemand(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
if !h.requireRoles(c, types.TrainingRoleHR) {
|
||||
tenantID, userID := callerTenantID(c), callerUserID(c)
|
||||
member, err := h.svc.CurrentMember(ctx, tenantID, userID)
|
||||
if err != nil {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
}
|
||||
demand, err := h.svc.ConfirmDemand(ctx, callerTenantID(c), c.Param("id"), callerUserID(c))
|
||||
if member == nil {
|
||||
_ = c.Error(errors.NewForbiddenError(demandConfirmDenied))
|
||||
return
|
||||
}
|
||||
roles := h.svc.ExpandTrainingRoles(ctx, tenantID, member.TrainingRoleList())
|
||||
if !types.HasTrainingRole(roles, types.TrainingRoleManager) {
|
||||
_ = c.Error(errors.NewForbiddenError(demandConfirmDenied))
|
||||
return
|
||||
}
|
||||
existing, err := h.svc.GetDemand(ctx, tenantID, c.Param("id"))
|
||||
if err != nil {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
}
|
||||
// 本部门口径:仅可核验本部门需求(部门缺失的需求先由人事/提报人补全部门)。
|
||||
if existing.DeptID == "" || existing.DeptID != member.DeptID {
|
||||
_ = c.Error(errors.NewForbiddenError(demandConfirmDenied))
|
||||
return
|
||||
}
|
||||
demand, err := h.svc.ConfirmDemand(ctx, tenantID, c.Param("id"), userID)
|
||||
if err != nil {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
}
|
||||
// 已确认需求自动生成草稿课程到课程管理(fail-open,不阻断确认)。
|
||||
h.syncDemandCourse(ctx, callerTenantID(c), demand, callerUserID(c))
|
||||
h.syncDemandCourse(ctx, tenantID, demand, userID)
|
||||
// 确认转月培训计划后自动推送讲师与部门课长维护(000157,站内+企微,fail-open)。
|
||||
h.notifyDemandConfirmed(ctx, tenantID, userID, demand)
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "data": demand})
|
||||
}
|
||||
|
||||
@@ -601,12 +654,25 @@ func (h *Handler) syncDemandCourse(ctx context.Context, tenantID uint64, demand
|
||||
DeptIDs: sliceToJSON([]string{demand.DeptID}),
|
||||
PostScope: demand.PostScope,
|
||||
}
|
||||
// 经理确认自动转月度计划(000153):回填来源需求 id 供列表/详情溯源;
|
||||
// 课程管理存在同名课程时直接关联(计划侧自动带出并锁定课程信息),
|
||||
// 无同名课程时课长在月度计划编辑弹窗手动选择课程管理课程。
|
||||
course.SourceDemandID = demand.ID
|
||||
if libItems, _, libErr := h.svc.ListCourseLibraryItems(ctx, tenantID, &interfaces.TrainingListQuery{Page: 1, PageSize: 500}); libErr == nil {
|
||||
for _, item := range libItems {
|
||||
if item != nil && item.Name == demand.CourseName {
|
||||
course.LibraryCourseID = item.ID
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
// 授课时间默认取需求「期望月份」(YYYY-MM,课程管理侧可修改并留版本记录)。
|
||||
if demand.Year > 0 && demand.ExpectMonth >= 1 && demand.ExpectMonth <= 12 {
|
||||
course.TeachTime = fmt.Sprintf("%04d-%02d", demand.Year, demand.ExpectMonth)
|
||||
}
|
||||
// 计划培训时间:需求已填则原样同步到课程(YYYY-MM-DD HH:mm / YYYY-MM-DD)。
|
||||
course.PlannedTime = trimSpace(demand.PlannedTime)
|
||||
// 计划培训月份:需求侧为「YYYY-M」(如 2027-1),归一为课程口径 YYYY-MM;
|
||||
// 旧日期格式(YYYY-MM-DD 等)原样同步。
|
||||
course.PlannedTime = demandPlannedMonthOf(trimSpace(demand.PlannedTime))
|
||||
// 需求录入信息全量同步(000150 补充的课程侧落点),课程详情弹窗只读回显。
|
||||
// 内/外培训、厂区、地点、培训次数、备注原样带入;外部讲师仅在无系统讲师时生效。
|
||||
externalLecturer := trimSpace(demand.LecturerExternal)
|
||||
@@ -701,6 +767,164 @@ func splitNames(raw string) []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// trainingDeptRoleRecipients 取指定部门具有任一目标职称角色(按权限分配展开后)
|
||||
// 的在职成员 user_id;部门为空或查询失败返回空(fail-open 供推送场景使用)。
|
||||
func (h *Handler) trainingDeptRoleRecipients(ctx context.Context, tenantID uint64, deptID string, want ...types.TrainingRole) []string {
|
||||
if deptID == "" {
|
||||
return nil
|
||||
}
|
||||
members, _, err := h.svc.ListMembers(ctx, tenantID, &interfaces.TrainingListQuery{Page: 1, PageSize: 500})
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
out := []string{}
|
||||
for _, m := range members {
|
||||
if m == nil || m.DeptID != deptID || m.UserID == "" {
|
||||
continue
|
||||
}
|
||||
roles := h.svc.ExpandTrainingRoles(ctx, tenantID, m.TrainingRoleList())
|
||||
for _, w := range want {
|
||||
if types.HasTrainingRole(roles, w) {
|
||||
out = append(out, m.UserID)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// notifyDemandVerify 需求导入后自动推送(000157):按部门聚合,站内+企微通知
|
||||
// 该部门经理(职称角色经理)进行核实【确认】;fail-open 不阻断导入。
|
||||
// 返回成功送达的通知数(写入导入响应,前端提示)。
|
||||
func (h *Handler) notifyDemandVerify(ctx context.Context, tenantID uint64, demands []*types.TrainingDemand) int {
|
||||
byDept := map[string][]string{}
|
||||
year := 0
|
||||
for _, d := range demands {
|
||||
if d == nil || d.DeptID == "" || trimSpace(d.CourseName) == "" {
|
||||
continue
|
||||
}
|
||||
byDept[d.DeptID] = append(byDept[d.DeptID], trimSpace(d.CourseName))
|
||||
if d.Year > 0 && year == 0 {
|
||||
year = d.Year
|
||||
}
|
||||
}
|
||||
if len(byDept) == 0 {
|
||||
return 0
|
||||
}
|
||||
deptNames := map[string]string{}
|
||||
if depts, err := h.svc.ListDepts(ctx, tenantID); err == nil {
|
||||
for _, d := range depts {
|
||||
if d != nil {
|
||||
deptNames[d.ID] = d.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
sent := 0
|
||||
for deptID, courses := range byDept {
|
||||
recipients := h.trainingDeptRoleRecipients(ctx, tenantID, deptID, types.TrainingRoleManager)
|
||||
if len(recipients) == 0 {
|
||||
continue
|
||||
}
|
||||
name := deptNames[deptID]
|
||||
if name == "" {
|
||||
name = deptID
|
||||
}
|
||||
title := fmt.Sprintf("【年度培训需求核验】%d年度 %s 培训需求待核验", year, name)
|
||||
content := fmt.Sprintf(
|
||||
"%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))
|
||||
if err != nil {
|
||||
logger.Error(ctx, "Failed to notify dept managers for demand verify", err)
|
||||
continue
|
||||
}
|
||||
sent += n
|
||||
}
|
||||
return sent
|
||||
}
|
||||
|
||||
// notifyDemandConfirmed 需求确认转月培训计划后自动推送(000157):站内+企微通知
|
||||
// 该课程讲师与部门课长维护培训相关信息(讲师维护课程信息,课长安排授课计划);
|
||||
// 确认操作人自身不重复通知;fail-open 不阻断确认。
|
||||
func (h *Handler) notifyDemandConfirmed(ctx context.Context, tenantID uint64, operatorID string, demand *types.TrainingDemand) {
|
||||
if demand == nil {
|
||||
return
|
||||
}
|
||||
recipients := h.trainingDeptRoleRecipients(ctx, tenantID, demand.DeptID, types.TrainingRoleSupervisor)
|
||||
recipients = append(recipients, trimSpace(demand.LecturerID))
|
||||
seen := map[string]bool{}
|
||||
final := []string{}
|
||||
for _, uid := range recipients {
|
||||
if uid == "" || uid == operatorID || seen[uid] {
|
||||
continue
|
||||
}
|
||||
seen[uid] = true
|
||||
final = append(final, uid)
|
||||
}
|
||||
if len(final) == 0 {
|
||||
return
|
||||
}
|
||||
title := fmt.Sprintf("【培训计划维护】%s 已确认转入月培训计划", demand.CourseName)
|
||||
content := fmt.Sprintf(
|
||||
"%d年度需求「%s」已核验确认并自动转入月培训计划:请讲师维护课程信息(课件/试题),课长安排授课时间/地点与学员名单。入口:AIDO → 企业培训 → 月培训计划。",
|
||||
demand.Year, demand.CourseName,
|
||||
)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// syncDemandLecturerToLibrary 需求讲师回写课程管理(000156):需求(导入/在线保存)
|
||||
// 按课程名称匹配课程管理条目,讲师与条目不一致时以需求讲师为准更新(改选讲师后
|
||||
// 课程管理同步追加为该讲师);同批同名取首条。fail-open:失败仅记日志不阻断导入。
|
||||
func (h *Handler) syncDemandLecturerToLibrary(ctx context.Context, tenantID uint64, updaterID string, demands []*types.TrainingDemand) {
|
||||
byName := map[string]*types.TrainingDemand{}
|
||||
for _, d := range demands {
|
||||
if d == nil || trimSpace(d.CourseName) == "" {
|
||||
continue
|
||||
}
|
||||
if trimSpace(d.LecturerID) == "" && trimSpace(d.LecturerExternal) == "" {
|
||||
continue
|
||||
}
|
||||
if _, ok := byName[d.CourseName]; !ok {
|
||||
byName[d.CourseName] = d
|
||||
}
|
||||
}
|
||||
if len(byName) == 0 {
|
||||
return
|
||||
}
|
||||
items, _, err := h.svc.ListCourseLibraryItems(ctx, tenantID, &interfaces.TrainingListQuery{Page: 1, PageSize: 500})
|
||||
if err != nil {
|
||||
logger.Error(ctx, "Failed to list course library for lecturer sync", err)
|
||||
return
|
||||
}
|
||||
for _, item := range items {
|
||||
if item == nil {
|
||||
continue
|
||||
}
|
||||
d, ok := byName[item.Name]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
lecturerID, lecturerExt := trimSpace(d.LecturerID), trimSpace(d.LecturerExternal)
|
||||
if item.LecturerID == lecturerID && item.LecturerExternal == lecturerExt {
|
||||
continue
|
||||
}
|
||||
updated := *item
|
||||
updated.LecturerID = lecturerID
|
||||
updated.LecturerExternal = lecturerExt
|
||||
if _, err := h.svc.SaveCourseLibraryItem(ctx, tenantID, &updated, updaterID); err != nil {
|
||||
logger.Error(ctx, "Failed to sync demand lecturer to course library", err)
|
||||
continue
|
||||
}
|
||||
// 系统员工讲师自动补齐讲师角色(讲师名册/下拉可见,fail-open)。
|
||||
if err := h.svc.EnsureLecturerRole(ctx, tenantID, lecturerID); err != nil {
|
||||
logger.Error(ctx, "Failed to ensure lecturer role on demand sync", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateAnnualPlan POST /training/annual-plans/generate — AI 汇总生成年度排期。
|
||||
func (h *Handler) GenerateAnnualPlan(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
@@ -923,6 +1147,8 @@ type saveCourseRequest struct {
|
||||
SessionCount int `json:"session_count"`
|
||||
LecturerExternal string `json:"lecturer_external"`
|
||||
Remark string `json:"remark"`
|
||||
// LibraryCourseID 课程管理条目 id(月培训计划「计划名称」选择课程后关联)。
|
||||
LibraryCourseID string `json:"library_course_id"`
|
||||
}
|
||||
|
||||
// SaveCourse POST /training/courses — 课程创建(线下/线上双向导数据源)。
|
||||
@@ -946,6 +1172,7 @@ func (h *Handler) SaveCourse(c *gin.Context) {
|
||||
PlannedTime: req.PlannedTime,
|
||||
TrainType: req.TrainType, Plant: req.Plant, Location: req.Location,
|
||||
SessionCount: req.SessionCount, LecturerExternal: req.LecturerExternal, Remark: req.Remark,
|
||||
LibraryCourseID: req.LibraryCourseID,
|
||||
}, callerUserID(c))
|
||||
if err != nil {
|
||||
_ = c.Error(err)
|
||||
@@ -1027,15 +1254,16 @@ func (h *Handler) ImportQuestionBankFromKnowledge(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
KnowledgeID string `json:"knowledge_id" binding:"required"`
|
||||
Name string `json:"name"`
|
||||
CourseID string `json:"course_id"`
|
||||
KnowledgeID string `json:"knowledge_id" binding:"required"`
|
||||
Name string `json:"name"`
|
||||
CourseID string `json:"course_id"`
|
||||
LibraryCourseID string `json:"library_course_id"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
_ = c.Error(errors.NewBadRequestError("请求参数不合法").WithDetails(err.Error()))
|
||||
return
|
||||
}
|
||||
bank, err := h.svc.ImportQuestionBankFromKnowledge(ctx, callerTenantID(c), req.KnowledgeID, req.Name, req.CourseID, callerUserID(c))
|
||||
bank, err := h.svc.ImportQuestionBankFromKnowledge(ctx, callerTenantID(c), req.KnowledgeID, req.Name, req.CourseID, req.LibraryCourseID, callerUserID(c))
|
||||
if err != nil {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
@@ -1112,15 +1340,16 @@ func (h *Handler) ImportGeneratedQuestionBank(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
CourseID string `json:"course_id"`
|
||||
Name string `json:"name"`
|
||||
Questions []*types.TrainingQuestion `json:"questions" binding:"required"`
|
||||
CourseID string `json:"course_id"`
|
||||
LibraryCourseID string `json:"library_course_id"`
|
||||
Name string `json:"name"`
|
||||
Questions []*types.TrainingQuestion `json:"questions" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
_ = c.Error(errors.NewBadRequestError("请求参数不合法").WithDetails(err.Error()))
|
||||
return
|
||||
}
|
||||
bank, err := h.svc.ImportGeneratedQuestionBank(ctx, callerTenantID(c), req.CourseID, req.Name, req.Questions, callerUserID(c))
|
||||
bank, err := h.svc.ImportGeneratedQuestionBank(ctx, callerTenantID(c), req.CourseID, req.LibraryCourseID, req.Name, req.Questions, callerUserID(c))
|
||||
if err != nil {
|
||||
_ = c.Error(err)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user