system_role.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. LayoutHour = "2006-01-02 15"
  24. )
  25. type SystemRoleSlice []*SystemRole
  26. func (s SystemRoleSlice) ToPB() []*pasturePb.SearchRoleRequest {
  27. res := make([]*pasturePb.SearchRoleRequest, len(s))
  28. for i, v := range s {
  29. res[i] = &pasturePb.SearchRoleRequest{
  30. Id: int32(v.Id),
  31. Name: v.Name,
  32. Remarks: v.Remarks,
  33. IsShow: v.IsShow,
  34. CreatedAtFormat: time.Unix(v.CreatedAt, 0).Format(LayoutTime),
  35. UpdatedAtFormat: time.Unix(v.UpdatedAt, 0).Format(LayoutTime),
  36. }
  37. }
  38. return res
  39. }