From 530fed8ec225453572d57b15c200ab062c335457 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 01 十一月 2023 19:20:21 +0800 Subject: [PATCH] 公海member_id使用0 --- source/menu.go | 114 +++++++++++++++++++++++++------------------------------- 1 files changed, 51 insertions(+), 63 deletions(-) diff --git a/source/menu.go b/source/menu.go index fa71fd3..08b1403 100644 --- a/source/menu.go +++ b/source/menu.go @@ -1,65 +1,53 @@ package system -import ( - "aps_crm/model" - "aps_crm/pkg/logx" - "aps_crm/service" - "context" - "github.com/pkg/errors" - "gorm.io/gorm" -) - -type initMenu struct{} - -// auto run -func init() { - service.RegisterInit(initMenuSequence, &initMenu{}) -} - -func (i initMenu) InitializerName() string { - return model.Menu{}.TableName() -} - -func (i *initMenu) InitializeData(ctx context.Context) (next context.Context, err error) { - entities := []*model.Menu{ - {ID: 1, Hidden: false, ParentId: 0, Path: "", Name: "", Title: "杞﹂棿绠$悊", Sort: 1, Icon: "home", Type: 0}, - {ID: 2, Hidden: false, ParentId: 1, Path: "/facilty", Name: "", Title: "璁惧绠$悊", Sort: 2, Icon: "object-ungroup", Type: 1}, - {ID: 3, Hidden: false, ParentId: 1, Path: "/faciltyResource", Name: "", Title: "璁惧璧勬簮", Sort: 3, Icon: "object-group", Type: 1}, - {ID: 4, Hidden: false, ParentId: 1, Path: "/oricedureDiagram", Name: "", Title: "璁惧宸ュ簭鍥�", Sort: 4, Icon: "object-group", Type: 1}, - - {ID: 5, Hidden: false, ParentId: 0, Path: "", Name: "", Title: "鐢熶骇璁″垝", Sort: 5, Icon: "paper-plane", Type: 0}, - {ID: 6, Hidden: false, ParentId: 5, Path: "/orderManagement", Name: "", Title: "璁㈠崟绠$悊", Sort: 6, Icon: "files-o", Type: 1}, - {ID: 7, Hidden: false, ParentId: 5, Path: "/plannedProduction", Name: "", Title: "璁″垝鐢熶骇", Sort: 7, Icon: "", Type: 1}, - {ID: 8, Hidden: false, ParentId: 5, Path: "/Scheduling", Name: "", Title: "鐢熶骇鎺掔▼", Sort: 8, Icon: "delicious", Type: 1}, - {ID: 9, Hidden: false, ParentId: 5, Path: "/productionProcess", Name: "", Title: "鐢熶骇宸ュ簭琛�", Sort: 9, Icon: "", Type: 1}, - - {ID: 10, Hidden: false, ParentId: 0, Path: "", Name: "", Title: "鍩虹鏁版嵁", Sort: 10, Icon: "database", Type: 0}, - {ID: 11, Hidden: false, ParentId: 10, Path: "/inventory", Name: "", Title: "BOM绠$悊", Sort: 11, Icon: "film", Type: 1}, - {ID: 12, Hidden: false, ParentId: 10, Path: "/bomCraft", Name: "", Title: "浜у搧/宸ュ簭", Sort: 12, Icon: "sliders", Type: 1}, - {ID: 13, Hidden: false, ParentId: 10, Path: "/humanResource", Name: "", Title: "浜哄姏璧勬簮", Sort: 13, Icon: "", Type: 1}, - {ID: 14, Hidden: false, ParentId: 10, Path: "/calendar", Name: "", Title: "鐢熶骇鏃ュ巻", Sort: 14, Icon: "user", Type: 1}, - {ID: 15, Hidden: false, ParentId: 10, Path: "/abilityModel", Name: "", Title: "妯℃澘绠$悊", Sort: 15, Icon: "connectdevelop", Type: 1}, - {ID: 16, Hidden: false, ParentId: 10, Path: "/mouldManagement", Name: "", Title: "妯″叿绠$悊", Sort: 16, Icon: "", Type: 1}, - {ID: 17, Hidden: false, ParentId: 10, Path: "/gauge", Name: "", Title: "妫�鍏风鐞�", Sort: 17, Icon: "", Type: 1}, - {ID: 18, Hidden: false, ParentId: 10, Path: "/transportation", Name: "", Title: "瑙勮寖绠$悊", Sort: 18, Icon: "", Type: 1}, - {ID: 19, Hidden: false, ParentId: 10, Path: "/proccessModel", Name: "", Title: "宸ヨ壓妯″瀷", Sort: 19, Icon: "", Type: 1}, - {ID: 20, Hidden: false, ParentId: 10, Path: "/dictionary", Name: "", Title: "鏁版嵁閰嶇疆", Sort: 20, Icon: "", Type: 1}, - - {ID: 21, Hidden: false, ParentId: 0, Path: "", Name: "", Title: "绯荤粺璁剧疆", Sort: 21, Icon: "database", Type: 0}, - {ID: 22, Hidden: false, ParentId: 21, Path: "/system/userManage", Name: "", Title: "绠$悊鍛樼鐞�", Sort: 22, Icon: "film", Type: 1}, - } - if err = model.NewMenuSearch(nil).CreateBatch(entities); err != nil { - return ctx, errors.Wrap(err, i.InitializerName()+"琛ㄦ暟鎹垵濮嬪寲澶辫触!") - } - next = context.WithValue(ctx, i.InitializerName(), entities) - logx.Infof("InitializeData success initName:%v", i.InitializerName()) - return next, nil -} - -func (i *initMenu) DataInserted(ctx context.Context) bool { - _, err := model.NewMenuSearch(nil).SetId(22).First() - if errors.Is(err, gorm.ErrRecordNotFound) { // 鍒ゆ柇鏄惁瀛樺湪鏁版嵁 - return false - } - return true -} +// +//import ( +// "aps_crm/model" +// "aps_crm/pkg/logx" +// "aps_crm/service" +// "context" +// "github.com/pkg/errors" +// "gorm.io/gorm" +//) +// +//type initMenu struct{} +// +//// auto run +//func init() { +// service.RegisterInit(initMenuSequence, &initMenu{}) +//} +// +//func (i initMenu) InitializerName() string { +// return model.Menu{}.TableName() +//} +// +//func (i *initMenu) InitializeData(ctx context.Context) (next context.Context, err error) { +// entities := []*model.Menu{ +// {ID: 1, ParentId: 0, Path: "", Name: "", Title: "瀹㈡埛绠$悊"}, +// {ID: 2, ParentId: 1, Path: "/client", Name: "", Title: "瀹㈡埛绠$悊"}, +// +// {ID: 3, ParentId: 0, Path: "", Name: "", Title: "閿�鍞鐞�"}, +// {ID: 4, ParentId: 3, Path: "/saleChance", Name: "", Title: "閿�鍞満浼�"}, +// +// {ID: 5, ParentId: 0, Path: "", Name: "", Title: "鏈嶅姟绠$悊"}, +// {ID: 6, ParentId: 5, Path: "/serviceContract", Name: "", Title: "鏈嶅姟鍚堝悓"}, +// +// {ID: 7, ParentId: 0, Path: "", Name: "", Title: "鍚庡彴璁剧疆"}, +// {ID: 8, ParentId: 7, Path: "/member", Name: "", Title: "鎴愬憳绠$悊"}, +// {ID: 9, ParentId: 7, Path: "/role", Name: "", Title: "瑙掕壊绠$悊"}, +// } +// if err = model.NewMenuSearch(nil).CreateBatch(entities); err != nil { +// return ctx, errors.Wrap(err, i.InitializerName()+"琛ㄦ暟鎹垵濮嬪寲澶辫触!") +// } +// next = context.WithValue(ctx, i.InitializerName(), entities) +// logx.Infof("InitializeData success initName:%v", i.InitializerName()) +// return next, nil +//} +// +//func (i *initMenu) DataInserted(ctx context.Context) bool { +// _, err := model.NewMenuSearch(nil).SetId(22).First() +// if errors.Is(err, gorm.ErrRecordNotFound) { // 鍒ゆ柇鏄惁瀛樺湪鏁版嵁 +// return false +// } +// return true +//} -- Gitblit v1.8.0