1.将职称角色中的“从OA同步企微账号”及设置角色、“员工与部门在「组织架构」中统一维护,此处仅配置职称角色”迁移到组织架构页面中, 2.平台新增成员自动添加到“组织架构”页面自动匹配对应部门; 3.在“组织架构”页面可直接设置角色 4.“组织架构”页面职称按名称、工号、部门查找员工 5.新增成员默认放在最上面按时间倒序排列 6.所有登录平台的用户直接默认打开AI对话页面 7.页面3、4中的”AIDO“改为”和信智汇学院“
This commit is contained in:
1 parent
196478114c
commit
8f225ecea9
26 files changed
+644
-406
No files matched your search
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"academy/internal/errors"
|
||||
"academy/internal/logger"
|
||||
@@ -161,6 +162,66 @@ func firstDuplicateEmployeeNo(employees []*types.OrgEmployee) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// EnsureEmployeesForUsers 成员加入空间时自动入册(需求:平台新增成员自动添加
|
||||
// 到组织架构并匹配部门):按平台账号补建员工档案,部门按 Casdoor 同步字段
|
||||
// 自动匹配(dept_code 精确命中优先,dept_name 兜底;匹配范式与 Casdoor 同步
|
||||
// syncDepts 一致:小写去空格精确匹配)。档案已存在的成员跳过(仅补空),人工
|
||||
// 维护字段不被覆盖。fail-open:入册是成员加入的伴生动作,失败只记日志,
|
||||
// 不阻断成员关系本身。
|
||||
func (s *orgCenterService) EnsureEmployeesForUsers(ctx context.Context, tenantID uint64, userIDs []string) error {
|
||||
if len(userIDs) == 0 {
|
||||
return nil
|
||||
}
|
||||
users, err := s.repo.GetRosterUserInfos(ctx, tenantID, userIDs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(users) == 0 {
|
||||
return nil
|
||||
}
|
||||
depts, err := s.repo.ListDepts(ctx, tenantID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
byCode := make(map[string]string, len(depts))
|
||||
byName := make(map[string]string, len(depts))
|
||||
for _, d := range depts {
|
||||
if code := strings.ToLower(strings.TrimSpace(d.Code)); code != "" {
|
||||
byCode[code] = d.ID
|
||||
}
|
||||
if name := strings.ToLower(strings.TrimSpace(d.Name)); name != "" {
|
||||
if _, exists := byName[name]; !exists {
|
||||
byName[name] = d.ID // 首见优先,与 ListDepts 的 sort/created_at 序一致
|
||||
}
|
||||
}
|
||||
}
|
||||
employees := make([]*types.OrgEmployee, 0, len(users))
|
||||
for _, u := range users {
|
||||
deptID := ""
|
||||
if code := strings.ToLower(strings.TrimSpace(u.DeptCode)); code != "" {
|
||||
deptID = byCode[code]
|
||||
}
|
||||
if deptID == "" {
|
||||
if name := strings.ToLower(strings.TrimSpace(u.DeptName)); name != "" {
|
||||
deptID = byName[name]
|
||||
}
|
||||
}
|
||||
employees = append(employees, &types.OrgEmployee{
|
||||
ID: orgCenterNewID(),
|
||||
TenantID: tenantID,
|
||||
UserID: u.ID,
|
||||
EmployeeNo: u.Username, // 工号 = 平台账号(与导入回填同约定)
|
||||
DeptID: deptID, // 未匹配到已维护部门时留空,可后续手动修改
|
||||
Status: "active",
|
||||
})
|
||||
}
|
||||
if err := s.repo.InsertEmployeesIfAbsent(ctx, employees); err != nil {
|
||||
return err
|
||||
}
|
||||
logger.Infof(ctx, "[OrgCenter] members auto-rostered, tenant=%d count=%d", tenantID, len(employees))
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateEmployee updates one employee profile.
|
||||
func (s *orgCenterService) UpdateEmployee(ctx context.Context, tenantID uint64, employee *types.OrgEmployee) (*types.OrgEmployee, error) {
|
||||
if employee.ID == "" {
|
||||
|
||||
Reference in new issue
Block a user