From b3ed5703a8a95832fb58fe67b0219aa2f554073a Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Fri, 22 Sep 2023 15:42:09 +0800 Subject: [PATCH] info --- model/gmodel/fs_user_logic.go | 33 ++++++++++---------- server/info/internal/logic/infologic_test.go | 12 +------ utils/fssql/metadata_test.go | 8 +---- 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/model/gmodel/fs_user_logic.go b/model/gmodel/fs_user_logic.go index a0a46b6d..78c77653 100644 --- a/model/gmodel/fs_user_logic.go +++ b/model/gmodel/fs_user_logic.go @@ -155,14 +155,16 @@ type SubscriptionStatus struct { type UserAddress struct { } +type UserProfile struct { + ProfileBase UserProfileBase `json:"base"` + SubStatus SubscriptionStatus `json:"sub_status"` +} + // UserProfileBase 个人信息 type UserProfileBase struct { - Base struct { - FirstName string `json:"first_name"` - LastName string `json:"last_name"` - Resetaurant string `json:"resetaurant"` - } `json:"base"` - SubStatus SubscriptionStatus `json:"sub_status"` + FirstName string `json:"first_name"` + LastName string `json:"last_name"` + Resetaurant string `json:"resetaurant"` } // 自平台的注册流程 @@ -194,17 +196,16 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT // 继承guest_id的资源表 err = InheritGuestIdResource(tx, user.Id, token.GuestId, func(txResouce, txUserMaterial, txUserInfo *gorm.DB) error { - userProfile := &UserProfileBase{ - Base: struct { - FirstName string "json:\"first_name\"" - LastName string "json:\"last_name\"" - Resetaurant string "json:\"resetaurant\"" - }{ - FirstName: FirstName, - LastName: LastName, - Resetaurant: Resetaurant, - }, + userProfileBase := UserProfileBase{ + FirstName: FirstName, + LastName: LastName, + Resetaurant: Resetaurant, } + + userProfile := &UserProfile{ + ProfileBase: userProfileBase, + } + metadata, err := json.Marshal(userProfile) if err != nil { return err diff --git a/server/info/internal/logic/infologic_test.go b/server/info/internal/logic/infologic_test.go index 18a434ca..17a9d104 100644 --- a/server/info/internal/logic/infologic_test.go +++ b/server/info/internal/logic/infologic_test.go @@ -157,17 +157,7 @@ func TestMain(t *testing.T) { func TestCaseJSON_EXTRACT(t *testing.T) { - userProfile := &gmodel.UserProfileBase{ - Base: struct { - FirstName string "json:\"first_name\"" - LastName string "json:\"last_name\"" - Resetaurant string "json:\"resetaurant\"" - }{ - FirstName: "FirstName", - LastName: "LastName", - Resetaurant: "Resetaurant", - }, - } + userProfile := &gmodel.UserProfile{} metadata, err := json.Marshal(userProfile) if err != nil { panic(err) diff --git a/utils/fssql/metadata_test.go b/utils/fssql/metadata_test.go index 30ed39e4..d38fded9 100644 --- a/utils/fssql/metadata_test.go +++ b/utils/fssql/metadata_test.go @@ -8,13 +8,7 @@ import ( ) func TestCase1(t *testing.T) { - u := gmodel.UserProfileBase{ - Base: struct { - FirstName string "json:\"first_name\"" - LastName string "json:\"last_name\"" - Resetaurant string "json:\"resetaurant\"" - }{}, - } + u := gmodel.UserProfile{} conn := initalize.InitMysql("fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen") err := fssql.MetadataModulePATCH(conn, "profile", gmodel.FsUserInfo{}, u, "id = ?", 90)