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/user.go |  132 ++++++++++++++++++++++----------------------
 1 files changed, 66 insertions(+), 66 deletions(-)

diff --git a/source/user.go b/source/user.go
index b8e334e..c3c3db8 100644
--- a/source/user.go
+++ b/source/user.go
@@ -1,68 +1,68 @@
 package system
 
-import (
-	"aps_crm/constvar"
-	"aps_crm/model"
-	"aps_crm/pkg/encrypt"
-	"aps_crm/pkg/logx"
-	"aps_crm/pkg/snowflake"
-	"aps_crm/service"
-	"context"
-	"fmt"
-	"github.com/pkg/errors"
-	"gorm.io/gorm"
-)
-
-const (
-	initMenuSequence = iota + 1
-	initUserSequence
-)
-
-type initUser struct{}
-
-// auto run
-func init() {
-	service.RegisterInit(initUserSequence, &initUser{})
-}
-
-func (i initUser) InitializerName() string {
-	return model.User{}.TableName()
-}
-
-func (i *initUser) InitializeData(ctx context.Context) (next context.Context, err error) {
-	adminPassword := encrypt.BcryptHash("123456")
-	entities := []*model.User{
-		{
-			UUID:     fmt.Sprintf("u%v", snowflake.GenerateId()),
-			Username: "admin",
-			Password: adminPassword,
-			NickName: "admin",
-			UserType: constvar.UserTypeSuper,
-			//ParentId: "basic", // 瓒呯骇绠$悊鍛樿处鎴风殑鐖朵翰涓虹┖瀛楃涓诧紝鎴栬�呰捣涓悕瀛�
-			//Enable:   true,
-		},
-	}
-	if err = model.NewUserSearch(nil).CreateBatch(entities); err != nil {
-		return ctx, errors.Wrap(err, model.User{}.TableName()+"琛ㄦ暟鎹垵濮嬪寲澶辫触!")
-	}
-	next = context.WithValue(ctx, i.InitializerName(), entities)
-
-	menuEntities, ok := ctx.Value(initMenu{}.InitializerName()).([]*model.Menu)
-	if !ok {
-		return next, errors.New("no find menus")
-	}
-
-	if err = model.NewUserSearch(nil).ReplaceMenu(entities[0], menuEntities); err != nil {
-		return next, err
-	}
-	logx.Infof("InitializeData success initName:%v", i.InitializerName())
-	return next, err
-}
-
-func (i *initUser) DataInserted(ctx context.Context) bool {
-	_, err := model.NewUserSearch(nil).SetUserName("admin").First()
-	if errors.Is(err, gorm.ErrRecordNotFound) { // 鍒ゆ柇鏄惁瀛樺湪鏁版嵁
-		return false
-	}
-	return true
-}
+//import (
+//	"aps_crm/constvar"
+//	"aps_crm/model"
+//	"aps_crm/pkg/encrypt"
+//	"aps_crm/pkg/logx"
+//	"aps_crm/pkg/snowflake"
+//	"aps_crm/service"
+//	"context"
+//	"fmt"
+//	"github.com/pkg/errors"
+//	"gorm.io/gorm"
+//)
+//
+//const (
+//	initMenuSequence = iota + 1
+//	initUserSequence
+//)
+//
+//type initUser struct{}
+//
+//// auto run
+//func init() {
+//	service.RegisterInit(initUserSequence, &initUser{})
+//}
+//
+//func (i initUser) InitializerName() string {
+//	return model.User{}.TableName()
+//}
+//
+//func (i *initUser) InitializeData(ctx context.Context) (next context.Context, err error) {
+//	adminPassword := encrypt.BcryptHash("123456")
+//	entities := []*model.User{
+//		{
+//			UUID:     fmt.Sprintf("u%v", snowflake.GenerateId()),
+//			Username: "admin",
+//			Password: adminPassword,
+//			NickName: "admin",
+//			UserType: constvar.UserTypeSuper,
+//			//ParentId: "basic", // 瓒呯骇绠$悊鍛樿处鎴风殑鐖朵翰涓虹┖瀛楃涓诧紝鎴栬�呰捣涓悕瀛�
+//			//Enable:   true,
+//		},
+//	}
+//	if err = model.NewUserSearch(nil).CreateBatch(entities); err != nil {
+//		return ctx, errors.Wrap(err, model.User{}.TableName()+"琛ㄦ暟鎹垵濮嬪寲澶辫触!")
+//	}
+//	next = context.WithValue(ctx, i.InitializerName(), entities)
+//
+//	menuEntities, ok := ctx.Value(initMenu{}.InitializerName()).([]*model.Menu)
+//	if !ok {
+//		return next, errors.New("no find menus")
+//	}
+//
+//	if err = model.NewUserSearch(nil).ReplaceMenu(entities[0], menuEntities); err != nil {
+//		return next, err
+//	}
+//	logx.Infof("InitializeData success initName:%v", i.InitializerName())
+//	return next, err
+//}
+//
+//func (i *initUser) DataInserted(ctx context.Context) bool {
+//	_, err := model.NewUserSearch(nil).SetUserName("admin").First()
+//	if errors.Is(err, gorm.ErrRecordNotFound) { // 鍒ゆ柇鏄惁瀛樺湪鏁版嵁
+//		return false
+//	}
+//	return true
+//}

--
Gitblit v1.8.0