From b3a47cb555076c25c64d83dd455a472509291245 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期一, 13 十一月 2023 16:09:35 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/crm --- source/menu.go | 101 +++++++++++++++++++++++++------------------------- 1 files changed, 51 insertions(+), 50 deletions(-) diff --git a/source/menu.go b/source/menu.go index 18ed3aa..08b1403 100644 --- a/source/menu.go +++ b/source/menu.go @@ -1,52 +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, 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 -} +// +//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