system_role.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package model
  2. import (
  3. "time"
  4. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  5. )
  6. type SystemRole struct {
  7. Id int64 `json:"id,omitempty"`
  8. Name string `json:"name,omitempty"`
  9. Remarks string `json:"remarks,omitempty"`
  10. IsShow pasturePb.IsShow_Kind `json:"is_show,omitempty"`
  11. IsDelete pasturePb.IsShow_Kind `json:"is_delete,omitempty"`
  12. CreatedAt int64 `json:"created_at,omitempty"`
  13. UpdatedAt int64 `json:"updated_at,omitempty"`
  14. }
  15. func (s *SystemRole) TableName() string {
  16. return "system_role"
  17. }
  18. const (
  19. LayoutTime = "2006-01-02 15:04:05"
  20. LayoutDate = "20060102"
  21. LayoutDate2 = "2006-01-02"
  22. LayoutMonth = "2006-01"
  23. )
  24. type SystemRoleSlice []*SystemRole
  25. func (s SystemRoleSlice) ToPB() []*pasturePb.SearchRoleRequest {
  26. res := make([]*pasturePb.SearchRoleRequest, len(s))
  27. for i, v := range s {
  28. res[i] = &pasturePb.SearchRoleRequest{
  29. Id: int32(v.Id),
  30. Name: v.Name,
  31. Remarks: v.Remarks,
  32. IsShow: v.IsShow,
  33. CreatedAtFormat: time.Unix(v.CreatedAt, 0).Format(LayoutTime),
  34. UpdatedAtFormat: time.Unix(v.UpdatedAt, 0).Format(LayoutTime),
  35. }
  36. }
  37. return res
  38. }