123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- package model
- import (
- "time"
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- operationPb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/operation"
- )
- type SystemMenu struct {
- Id int64 `json:"id"`
- Name string `json:"name"`
- Title string `json:"title"`
- Path string `json:"path"`
- Icon string `json:"icon"`
- Component string `json:"component"`
- Redirect string `json:"redirect"`
- Auths string `json:"auths"`
- MenuType pasturePb.MenuType_Kind `json:"menu_type"`
- ParentId int64 `json:"parent_id"`
- Rank int32 `json:"rank"`
- ExtraIcon string `json:"extra_icon"`
- EnterTransition string `json:"enter_transition"`
- ActivePath string `json:"active_path"`
- FrameSrc string `json:"frame_src"`
- FrameLoading pasturePb.IsShow_Kind `json:"frame_loading"`
- Keepalive pasturePb.IsShow_Kind `json:"keepalive"`
- HiddenTag pasturePb.IsShow_Kind `json:"hidden_tag"`
- ShowLink pasturePb.IsShow_Kind `json:"show_link"`
- ShowParent pasturePb.IsShow_Kind `json:"show_parent"`
- IsShow pasturePb.IsShow_Kind `json:"is_show"`
- IsDelete pasturePb.IsShow_Kind `json:"is_delete"`
- CreatedAt int64 `json:"created_at"`
- UpdatedAt int64 `json:"updated_at"`
- }
- func (s *SystemMenu) TableName() string {
- return "system_menu"
- }
- func NewSystemMenu(req *operationPb.AddMenuRequest) *SystemMenu {
- return &SystemMenu{
- Name: req.Name,
- Title: req.Title,
- Path: req.Path,
- Component: req.Component,
- Icon: req.Icon,
- Redirect: req.Redirect,
- ParentId: int64(req.ParentId),
- IsShow: pasturePb.IsShow_Ok,
- IsDelete: pasturePb.IsShow_Ok,
- }
- }
- type SystemMenuSlice []*SystemMenu
- func (s SystemMenuSlice) ToPB() []*pasturePb.SearchMenuRequest {
- res := make([]*pasturePb.SearchMenuRequest, len(s))
- for i, menu := range s {
- var frameLoading, keepalive, hiddenTag, showLink, showParent bool
- if menu.FrameLoading == pasturePb.IsShow_Ok {
- frameLoading = true
- }
- if menu.Keepalive == pasturePb.IsShow_Ok {
- keepalive = true
- }
- if menu.HiddenTag == pasturePb.IsShow_Ok {
- hiddenTag = true
- }
- if menu.ShowLink == pasturePb.IsShow_Ok {
- showLink = true
- }
- if menu.ShowParent == pasturePb.IsShow_Ok {
- showParent = true
- }
- res[i] = &pasturePb.SearchMenuRequest{
- Id: int32(menu.Id),
- Name: menu.Name,
- ParentId: int32(menu.ParentId),
- MenuType: menu.MenuType,
- Title: menu.Title,
- Path: menu.Path,
- IsShow: menu.IsShow,
- Component: menu.Component,
- Icon: menu.Icon,
- Redirect: menu.Redirect,
- Auths: menu.Auths,
- Rank: menu.Rank,
- ExtraIcon: menu.ExtraIcon,
- EnterTransition: menu.EnterTransition,
- ActivePath: menu.ActivePath,
- FrameSrc: menu.FrameSrc,
- FrameLoading: frameLoading,
- Keepalive: keepalive,
- HiddenTag: hiddenTag,
- ShowLink: showLink,
- ShowParent: showParent,
- CreatedAtFormat: time.Unix(menu.CreatedAt, 0).Format(LayoutTime),
- UpdatedAtFormat: time.Unix(menu.UpdatedAt, 0).Format(LayoutTime),
- }
- }
- return res
- }
- func BooleanToIsShow(isShow bool) pasturePb.IsShow_Kind {
- showKind := pasturePb.IsShow_No
- if isShow {
- showKind = pasturePb.IsShow_Ok
- }
- return showKind
- }
|