package services import "eta/eta_mini_crm_ht/models" func GetSysUserList(condition string, pars []interface{}, startSize, pageSize int) (items []*models.SysUserMapping, err error) { // 查询系统用户 sysUserList, err := models.GetSysUserListByCondition(condition, pars, startSize, pageSize) if err != nil { return } // 建立部门id和名字的映射 departmentList, err := models.GetSysDepartments() if err != nil { return } departmentIdToName := make(map[models.DepartmentType]map[int]string) for _, dep := range departmentList { if _, ok := departmentIdToName[dep.Type]; !ok { departmentIdToName[dep.Type] = make(map[int]string) } departmentIdToName[dep.Type][dep.OutId] = dep.SysDepartmentName } // 匹配系统用户 items = make([]*models.SysUserMapping, 0) for _, user := range sysUserList { items = append(items, &models.SysUserMapping{ SysUserId: user.SysUserId, SysUserName: user.SysUserName, SysRealName: user.SysRealName, Email: user.Email, Phone: user.Phone, AreaCode: user.AreaCode, SysRoleId: user.SysRoleId, SysRoleName: user.SysRoleName, SysDepartmentId: user.SysDepartmentId, SysDepartmentName1: departmentIdToName[models.SubCompany][user.SysDepartmentId1], SysDepartmentName2: departmentIdToName[models.Department][user.SysDepartmentId2], SysDepartmentName3: departmentIdToName[models.Department][user.SysDepartmentId3], SysDepartmentName4: departmentIdToName[models.Department][user.SysDepartmentId4], Province: user.Province, City: user.City, PositionName: user.PositionName, PositionCode: user.PositionCode, IsEnabled: user.IsEnabled, CreateTime: user.CreateTime, ModifyTime: user.ModifyTime, }) } return }