Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
c61c8a4933
1
go.mod
1
go.mod
|
@ -123,4 +123,5 @@ require (
|
|||
google.golang.org/grpc v1.56.2 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gorm.io/datatypes v1.2.0
|
||||
)
|
||||
|
|
2
go.sum
2
go.sum
|
@ -986,6 +986,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
|
|||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/datatypes v1.2.0 h1:5YT+eokWdIxhJgWHdrb2zYUimyk0+TaFth+7a0ybzco=
|
||||
gorm.io/datatypes v1.2.0/go.mod h1:o1dh0ZvjIjhH/bngTpypG6lVRJ5chTBxE09FH/71k04=
|
||||
gorm.io/driver/mysql v1.5.1 h1:WUEH5VF9obL/lTtzjmML/5e6VfFR/788coz2uaVCAZw=
|
||||
gorm.io/driver/mysql v1.5.1/go.mod h1:Jo3Xu7mMhCyj8dlrb3WoCaRd1FhsVh+yMXb1jUInf5o=
|
||||
gorm.io/gorm v1.25.1 h1:nsSALe5Pr+cM3V1qwwQ7rOkw+6UeLrX5O4v3llhHa64=
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"fusenapi/initalize"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/check"
|
||||
"log"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -96,3 +98,31 @@ func TestMain(t *testing.T) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
func TestCaseJSON_EXTRACT(t *testing.T) {
|
||||
|
||||
userProfile := &gmodel.UserProfile{
|
||||
FirstName: "FirstName",
|
||||
LastName: "LastName",
|
||||
Resetaurant: "Resetaurant",
|
||||
}
|
||||
metadata, err := json.Marshal(userProfile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
updatesql := `UPDATE fusen.fs_change_code
|
||||
SET metadata = CASE
|
||||
WHEN metadata IS NULL THEN '%s'
|
||||
ELSE JSON_MERGE_PATCH(metadata, '%s')
|
||||
END
|
||||
WHERE id = ?;`
|
||||
|
||||
updatesql = fmt.Sprintf(updatesql, metadata, metadata)
|
||||
log.Println(string(updatesql))
|
||||
|
||||
conn := initalize.InitMysql("fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen")
|
||||
// err = conn.Exec(updatesql, 6).Error
|
||||
log.Println(conn.Model(&gmodel.FsChangeCode{}).Select("id").Where("id = 5").Take(nil).Error)
|
||||
log.Println(err)
|
||||
}
|
||||
|
|
|
@ -193,6 +193,7 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
|||
Intro: *v.Intro,
|
||||
IsRecommend: isRecommend,
|
||||
MinPrice: minPrice,
|
||||
IsCustomization: *productInfo.IsCustomization,
|
||||
}
|
||||
if _, ok := mapTagProp[productInfo.Id]; ok {
|
||||
item.CoverDefault = mapTagProp[productInfo.Id]
|
||||
|
|
|
@ -444,6 +444,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
|||
Recommended: *productInfo.IsRecommend > 0,
|
||||
Cover: *productInfo.Cover,
|
||||
CoverMetadata: req.MapResourceMetadata[*productInfo.Cover],
|
||||
IsCustomization: *productInfo.IsCustomization,
|
||||
}
|
||||
if _, ok = req.MapTagProp[productInfo.Id]; ok {
|
||||
item.CoverDefault = req.MapTagProp[productInfo.Id]
|
||||
|
|
|
@ -217,6 +217,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
|||
SizeNum: uint32(sizeNum),
|
||||
MinPrice: minPrice,
|
||||
HaveOptionalFitting: haveOptionalFitting,
|
||||
IsCustomization: *productInfo.IsCustomization,
|
||||
}
|
||||
if _, ok = mapTagProp[productInfo.Id]; ok {
|
||||
item.CoverDefault = mapTagProp[productInfo.Id]
|
||||
|
|
|
@ -246,6 +246,7 @@ type GetRecommandProductListRsp struct {
|
|||
Intro string `json:"intro"`
|
||||
IsRecommend int64 `json:"is_recommend"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
}
|
||||
|
||||
type GetTagProductListReq struct {
|
||||
|
@ -281,6 +282,7 @@ type TagProduct struct {
|
|||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
Recommended bool `json:"recommended"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
}
|
||||
|
||||
type CoverDefaultItem struct {
|
||||
|
@ -409,6 +411,7 @@ type HomePageRecommendProductListRsp struct {
|
|||
MinPrice int64 `json:"min_price"`
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
|
|
|
@ -94,6 +94,22 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
|||
logx.Error("invalid format of websocket render image message", err)
|
||||
return
|
||||
}
|
||||
//获取产品信息
|
||||
productInfo, err := w.logic.svcCtx.AllModels.FsProduct.FindOne(w.logic.ctx, renderImageData.RenderData.ProductId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "该产品不存在", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
return
|
||||
}
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取产品失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
logx.Error(err)
|
||||
return
|
||||
}
|
||||
//不可定制
|
||||
if *productInfo.IsCustomization == 0 {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "该产品不可定制", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
return
|
||||
}
|
||||
//获取上传最近的logo
|
||||
userMaterial, err := w.logic.svcCtx.AllModels.FsUserMaterial.FindLatestOne(w.logic.ctx, w.userId, w.guestId)
|
||||
if err != nil {
|
||||
|
|
|
@ -298,6 +298,7 @@ type GetRecommandProductListRsp {
|
|||
Intro string `json:"intro"`
|
||||
IsRecommend int64 `json:"is_recommend"`
|
||||
MinPrice int64 `json:"min_price"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
}
|
||||
//获取分类产品列表
|
||||
type GetTagProductListReq {
|
||||
|
@ -331,6 +332,7 @@ type TagProduct {
|
|||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
Recommended bool `json:"recommended"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
}
|
||||
type CoverDefaultItem {
|
||||
TemplateTag string `json:"template_tag"`
|
||||
|
@ -451,4 +453,5 @@ type HomePageRecommendProductListRsp {
|
|||
MinPrice int64 `json:"min_price"`
|
||||
CoverDefault []CoverDefaultItem `json:"cover_default"`
|
||||
HaveOptionalFitting bool `json:"have_optional_fitting"`
|
||||
IsCustomization int64 `json:"is_customization"`
|
||||
}
|
Loading…
Reference in New Issue
Block a user