sys_user.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package services
  2. import "eta/eta_mini_crm_ht/models"
  3. func GetSysUserList(condition string, pars []interface{}, startSize, pageSize int) (items []*models.SysUserMapping, err error) {
  4. // 查询系统用户
  5. sysUserList, err := models.GetSysUserListByCondition(condition, pars, startSize, pageSize)
  6. if err != nil {
  7. return
  8. }
  9. // 建立部门id和名字的映射
  10. departmentList, err := models.GetSysDepartments()
  11. if err != nil {
  12. return
  13. }
  14. departmentIdToName := make(map[models.DepartmentType]map[int]string)
  15. for _, dep := range departmentList {
  16. if _, ok := departmentIdToName[dep.Type]; !ok {
  17. departmentIdToName[dep.Type] = make(map[int]string)
  18. }
  19. departmentIdToName[dep.Type][dep.OutId] = dep.SysDepartmentName
  20. }
  21. // 匹配系统用户
  22. items = make([]*models.SysUserMapping, 0)
  23. for _, user := range sysUserList {
  24. items = append(items,
  25. &models.SysUserMapping{
  26. SysUserId: user.SysUserId,
  27. SysUserName: user.SysUserName,
  28. SysRealName: user.SysRealName,
  29. Email: user.Email,
  30. Phone: user.Phone,
  31. AreaCode: user.AreaCode,
  32. SysRoleId: user.SysRoleId,
  33. SysRoleName: user.SysRoleName,
  34. SysDepartmentId: user.SysDepartmentId,
  35. SysDepartmentName1: departmentIdToName[models.SubCompany][user.SysDepartmentId1],
  36. SysDepartmentName2: departmentIdToName[models.Department][user.SysDepartmentId2],
  37. SysDepartmentName3: departmentIdToName[models.Department][user.SysDepartmentId3],
  38. SysDepartmentName4: departmentIdToName[models.Department][user.SysDepartmentId4],
  39. Province: user.Province,
  40. City: user.City,
  41. PositionName: user.PositionName,
  42. PositionCode: user.PositionCode,
  43. IsEnabled: user.IsEnabled,
  44. CreateTime: user.CreateTime,
  45. ModifyTime: user.ModifyTime,
  46. })
  47. }
  48. return
  49. }