get_menu_list_logic.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package menu
  2. import (
  3. "context"
  4. "github.com/suyuan32/simple-admin-common/i18n"
  5. "github.com/suyuan32/simple-admin-common/utils/pointy"
  6. "github.com/suyuan32/simple-admin-core/api/internal/svc"
  7. "github.com/suyuan32/simple-admin-core/api/internal/types"
  8. "github.com/suyuan32/simple-admin-core/rpc/types/core"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type GetMenuListLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewGetMenuListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMenuListLogic {
  17. return &GetMenuListLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *GetMenuListLogic) GetMenuList() (resp *types.MenuPlainInfoListResp, err error) {
  24. data, err := l.svcCtx.CoreRpc.GetMenuList(l.ctx, &core.PageInfoReq{
  25. Page: 1,
  26. PageSize: 100,
  27. })
  28. if err != nil {
  29. return nil, err
  30. }
  31. resp = &types.MenuPlainInfoListResp{}
  32. resp.Data.Total = data.Total
  33. for _, v := range data.Data {
  34. resp.Data.Data = append(resp.Data.Data, types.MenuPlainInfo{
  35. Id: v.Id,
  36. CreatedAt: v.CreatedAt,
  37. UpdatedAt: v.UpdatedAt,
  38. Trans: pointy.GetPointer(l.svcCtx.Trans.Trans(l.ctx, *v.Meta.Title)),
  39. MenuType: v.MenuType,
  40. Level: v.Level,
  41. Path: v.Path,
  42. Name: v.Name,
  43. Redirect: v.Redirect,
  44. Component: v.Component,
  45. Sort: v.Sort,
  46. ParentId: v.ParentId,
  47. Title: v.Meta.Title,
  48. Icon: v.Meta.Icon,
  49. HideMenu: v.Meta.HideMenu,
  50. HideBreadcrumb: v.Meta.HideBreadcrumb,
  51. IgnoreKeepAlive: v.Meta.IgnoreKeepAlive,
  52. HideTab: v.Meta.HideTab,
  53. FrameSrc: v.Meta.FrameSrc,
  54. CarryParam: v.Meta.CarryParam,
  55. HideChildrenInMenu: v.Meta.HideChildrenInMenu,
  56. Affix: v.Meta.Affix,
  57. DynamicLevel: v.Meta.DynamicLevel,
  58. RealPath: v.Meta.RealPath,
  59. Disabled: v.Disabled,
  60. ServiceName: v.ServiceName,
  61. Permission: v.Permission,
  62. })
  63. }
  64. resp.Msg = l.svcCtx.Trans.Trans(l.ctx, i18n.Success)
  65. return resp, nil
  66. }