system_dept.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package model
  2. import (
  3. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  4. )
  5. type SystemDept struct {
  6. Id int64 `json:"id"`
  7. Name string `json:"name"`
  8. Remarks string `json:"remarks"`
  9. DeptType pasturePb.Depth_Kind `json:"dept_type"`
  10. LeaderId int64 `json:"leader_id"`
  11. ParentId int64 `json:"parent_id"`
  12. Sort int32 `json:"sort"`
  13. IsShow pasturePb.IsShow_Kind `json:"is_show"`
  14. IsDelete pasturePb.IsShow_Kind `json:"is_delete"`
  15. CreatedAt int64 `json:"created_at"`
  16. UpdatedAt int64 `json:"updated_at"`
  17. }
  18. func (s *SystemDept) TableName() string {
  19. return "system_dept"
  20. }
  21. type SystemDeptSlice []*SystemDept
  22. func (s SystemDeptSlice) ToPB(systemUserList []*SystemUser) []*pasturePb.SearchDeptRequest {
  23. res := make([]*pasturePb.SearchDeptRequest, len(s))
  24. for i, d := range s {
  25. leaderName := ""
  26. for _, v := range systemUserList {
  27. if d.LeaderId != v.Id {
  28. continue
  29. }
  30. leaderName = v.Name
  31. }
  32. res[i] = &pasturePb.SearchDeptRequest{
  33. Id: int32(d.Id),
  34. Name: d.Name,
  35. Remarks: d.Remarks,
  36. ParentId: int32(d.ParentId),
  37. DepthType: d.DeptType,
  38. LeaderId: int32(d.LeaderId),
  39. LeaderName: leaderName,
  40. Sort: d.Sort,
  41. IsShow: d.IsShow,
  42. IsDelete: d.IsDelete,
  43. CreatedAt: int32(d.CreatedAt),
  44. UpdatedAt: int32(d.UpdatedAt),
  45. }
  46. }
  47. return res
  48. }