Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
@@ -11,6 +11,7 @@ type FsChangeCode struct {
|
||||
Code *string `gorm:"default:'';" json:"code"` //
|
||||
CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // 创建时间
|
||||
IsUse *int64 `gorm:"default:0;" json:"is_use"` // 是否使用 1已使用 0未使用
|
||||
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
|
||||
}
|
||||
type FsChangeCodeModel struct {
|
||||
db *gorm.DB
|
||||
|
||||
@@ -35,6 +35,7 @@ type FsProduct struct {
|
||||
RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` //
|
||||
RecommendProductSort *string `gorm:"default:'';" json:"recommend_product_sort"` //
|
||||
SceneIds *string `gorm:"default:'';" json:"scene_ids"` //
|
||||
IsCustomization *int64 `gorm:"default:0;" json:"is_customization"` // 是否可定制
|
||||
}
|
||||
type FsProductModel struct {
|
||||
db *gorm.DB
|
||||
|
||||
@@ -14,6 +14,7 @@ type FsQuotation struct {
|
||||
PageNum *int64 `gorm:"default:0;" json:"page_num"` // 页数
|
||||
ProductNum *int64 `gorm:"default:0;" json:"product_num"` // 产品数量
|
||||
GiftNum *int64 `gorm:"default:0;" json:"gift_num"` // 赠品数
|
||||
SequenceNum *string `gorm:"default:'';" json:"sequence_num"` //
|
||||
Status *int64 `gorm:"default:0;" json:"status"` // 状态位 0停用 1待设计 2设计中 3待报价 4报价中 5完成
|
||||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
DesignId *int64 `gorm:"default:0;" json:"design_id"` // 设计人员
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package gmodel
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// fs_resource 资源表
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -146,15 +147,16 @@ func (u *FsUserModel) RegisterByGoogleOAuth(ctx context.Context, token *auth.Reg
|
||||
// SubscriptionStatus 订阅状态
|
||||
type SubscriptionStatus struct {
|
||||
SubEmail bool `json:"all_emails"`
|
||||
ItemMap struct {
|
||||
ItemMap *struct {
|
||||
} `json:"item_map"`
|
||||
}
|
||||
|
||||
// UserProfile 个人信息
|
||||
type UserProfile struct {
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Resetaurant string `json:"resetaurant"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Resetaurant string `json:"resetaurant"`
|
||||
SubStatus SubscriptionStatus `json:"sub_status"`
|
||||
}
|
||||
|
||||
// 自平台的注册流程
|
||||
@@ -188,6 +190,7 @@ 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 := &UserProfile{
|
||||
FirstName: FirstName,
|
||||
LastName: LastName,
|
||||
@@ -197,6 +200,9 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// txUserInfo.Where("user_id = ?", user.Id).Row().Err()
|
||||
|
||||
now := time.Now()
|
||||
uinfo := &FsUserInfo{
|
||||
Module: FsString("profile"),
|
||||
@@ -207,9 +213,30 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
||||
Utime: &now,
|
||||
}
|
||||
|
||||
err = txUserInfo.Create(uinfo).Error
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil
|
||||
err = txUserInfo.Where("user_id = ?", uinfo.UserId).Take(nil).Error
|
||||
// txUserInfo.Statement.Table
|
||||
|
||||
if err != nil {
|
||||
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
err = txUserInfo.Create(uinfo).Error
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
updatesql := `UPDATE %s
|
||||
SET metadata = CASE
|
||||
WHEN metadata IS NULL THEN ?
|
||||
ELSE JSON_MERGE_PATCH(metadata, ?)
|
||||
END
|
||||
WHERE id = ?;`
|
||||
updatesql = fmt.Sprintf(updatesql, txUserInfo.Statement.Table)
|
||||
logx.Error(updatesql)
|
||||
err = txUserInfo.Raw(updatesql, metadata, metadata, uinfo.UserId).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return err
|
||||
})
|
||||
@@ -217,6 +244,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user