fix(培训课程):优化培训课程

This commit is contained in:
runny committed 2026-11-17 08:21:59 +08:00
1 parent e378e8b7fd
commit aae041a0b4
19 files changed
+777 -188

No files matched your search

+36
View File
@@ -153,6 +153,42 @@ func (h *Handler) ImportEmployees(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"imported": count}})
}
// updateEmployeeRequest is the body of PUT /org/employees/:id.
// 姓名/工号随平台账号维护,不在可编辑范围;部门必填(与导入同规)。
type updateEmployeeRequest struct {
DeptID string `json:"dept_id" binding:"required"`
Post string `json:"post"`
Status string `json:"status"`
}
// UpdateEmployee PUT /org/employees/:id — 修改员工档案。
// Read-modify-write:先取现有档案再覆盖可编辑字段,wecom_userid/lecturer_rate
// 等由 OA 同步/业务模块维护的字段保持不动;状态留空表示不变更。
func (h *Handler) UpdateEmployee(c *gin.Context) {
ctx := c.Request.Context()
var req updateEmployeeRequest
if err := c.ShouldBindJSON(&req); err != nil {
_ = c.Error(errors.NewBadRequestError("请求参数不合法").WithDetails(err.Error()))
return
}
employee, err := h.svc.GetEmployee(ctx, callerTenantID(c), c.Param("id"))
if err != nil {
_ = c.Error(err)
return
}
employee.DeptID = req.DeptID
employee.Post = req.Post
if req.Status != "" {
employee.Status = req.Status
}
updated, err := h.svc.UpdateEmployee(ctx, callerTenantID(c), employee)
if err != nil {
_ = c.Error(err)
return
}
c.JSON(http.StatusOK, gin.H{"success": true, "data": updated})
}
// ListPlatformUsers GET /org/platform-users — 员工导入的用户选择器数据源。
func (h *Handler) ListPlatformUsers(c *gin.Context) {
users, err := h.svc.ListTenantUsers(c.Request.Context(), callerTenantID(c))