优化backend端相关功能
This commit is contained in:
@@ -251,16 +251,35 @@ func (c *BackendOaCompensationController) Employees() {
|
||||
c.compensationError(500, "员工查询失败")
|
||||
return
|
||||
}
|
||||
orgNames := compensationOrgNameMap(claims.TenantId)
|
||||
list := make([]map[string]interface{}, 0, len(employees))
|
||||
for _, employee := range employees {
|
||||
department := compensationString(employee.Department)
|
||||
list = append(list, map[string]interface{}{
|
||||
"id": employee.ID, "name": employee.Name, "account": employee.Account,
|
||||
"department": compensationString(employee.Department), "position": compensationString(employee.Position),
|
||||
"department": department, "department_name": efOrgNameByID(orgNames, department),
|
||||
"position": compensationString(employee.Position),
|
||||
})
|
||||
}
|
||||
c.compensationOK(list)
|
||||
}
|
||||
|
||||
// compensationOrgNameMap 组织ID -> 名称映射,用于把员工 department 字段(存的是组织ID)解析为部门名称展示。
|
||||
func compensationOrgNameMap(tid int) map[uint64]string {
|
||||
var rows []models.BackendOrganization
|
||||
if _, err := models.Orm.QueryTable(new(models.BackendOrganization)).
|
||||
Filter("tid", tid).
|
||||
Filter("delete_time__isnull", true).
|
||||
All(&rows, "ID", "OrgName"); err != nil {
|
||||
return map[uint64]string{}
|
||||
}
|
||||
names := make(map[uint64]string, len(rows))
|
||||
for _, row := range rows {
|
||||
names[row.ID] = row.OrgName
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
// SchemeList GET /backend/oa/compensation/schemes
|
||||
func (c *BackendOaCompensationController) SchemeList() {
|
||||
claims, err := c.compensationClaims()
|
||||
|
||||
Reference in New Issue
Block a user