system_menu.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package model
  2. import (
  3. operationPb "kpt-tmr-group/proto/go/backend/operation"
  4. "time"
  5. )
  6. type SystemMenu struct {
  7. Id int64 `json:"id,omitempty"`
  8. Name string `json:"name,omitempty"`
  9. MenuType int32 `json:"menu_type,omitempty"`
  10. GroupType int32 `json:"group_type,omitempty"`
  11. Title string `json:"title,omitempty"`
  12. Path string `json:"path,omitempty"`
  13. IsShow operationPb.IsShow_Kind `json:"is_show,omitempty"`
  14. IsDelete operationPb.IsShow_Kind `json:"is_delete,omitempty"`
  15. Component string `json:"component,omitempty"`
  16. Icon string `json:"icon,omitempty"`
  17. Sort int32 `json:"sort,omitempty"`
  18. ParentId int64 `json:"parent_id"`
  19. Redirect string `json:"redirect,omitempty"`
  20. CreatedAt int64 `json:"created_at,omitempty"`
  21. UpdatedAt int64 `json:"updated_at,omitempty"`
  22. }
  23. func (s *SystemMenu) TableName() string {
  24. return "system_menu"
  25. }
  26. type SystemMenuSlice []*SystemMenu
  27. func (s SystemMenuSlice) ToPB() []*operationPb.AddMenuRequest {
  28. res := make([]*operationPb.AddMenuRequest, len(s))
  29. for i, v := range s {
  30. res[i] = &operationPb.AddMenuRequest{
  31. Id: v.Id,
  32. Name: v.Name,
  33. MenuType: v.MenuType,
  34. Title: v.Title,
  35. IsShow: v.IsShow,
  36. Component: v.Component,
  37. Icon: v.Icon,
  38. Sort: v.Sort,
  39. Redirect: v.Redirect,
  40. ParentId: v.ParentId,
  41. CreatedAt: v.CreatedAt,
  42. CratedAtFormat: time.Unix(v.CreatedAt, 0).Format(LayoutTime),
  43. }
  44. }
  45. return res
  46. }
  47. func (s *SystemMenu) ToPb() *operationPb.AddMenuRequest {
  48. return &operationPb.AddMenuRequest{
  49. Id: s.Id,
  50. Name: s.Name,
  51. MenuType: s.MenuType,
  52. Title: s.Title,
  53. Path: s.Path,
  54. Component: s.Component,
  55. Icon: s.Icon,
  56. Sort: s.Sort,
  57. Redirect: s.Redirect,
  58. ParentId: s.ParentId,
  59. IsShow: s.IsShow,
  60. CreatedAt: s.CreatedAt,
  61. }
  62. }
  63. type SystemMenuResponse struct {
  64. Page int32 `json:"page"`
  65. Total int32 `json:"total"`
  66. List []*operationPb.AddMenuRequest `json:"list"`
  67. }
  68. func (s *SystemMenuResponse) ToPB() *operationPb.SearchMenuResponse {
  69. return &operationPb.SearchMenuResponse{
  70. Page: s.Page,
  71. Total: s.Total,
  72. List: s.List,
  73. }
  74. }