system_role.go 1.4 KB

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