Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop

This commit is contained in:
eson 2023-09-22 11:46:02 +08:00
commit fc50bf587f
3 changed files with 36 additions and 5 deletions

View File

@ -10,6 +10,8 @@ import (
"fusenapi/server/shopping-cart/internal/types" "fusenapi/server/shopping-cart/internal/types"
"fusenapi/utils/auth" "fusenapi/utils/auth"
"fusenapi/utils/basic" "fusenapi/utils/basic"
"fusenapi/utils/file"
"fusenapi/utils/hash"
"gorm.io/gorm" "gorm.io/gorm"
"time" "time"
@ -51,6 +53,31 @@ func (l *AddToCartLogic) AddToCart(req *types.AddToCartReq, userinfo *auth.UserI
if cartCount >= 100 { if cartCount >= 100 {
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "sorry,the count of your carts can`t greater than 100") return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "sorry,the count of your carts can`t greater than 100")
} }
if req.RenderImage != "" {
//上传base64文件
// 上传文件
var upload = file.Upload{
Ctx: l.ctx,
MysqlConn: l.svcCtx.MysqlConn,
AwsSession: l.svcCtx.AwsSession,
}
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
Source: "webGl render image",
FileHash: hash.JsonHashKey(req.RenderImage),
FileData: req.RenderImage,
Metadata: "",
UploadBucket: 1,
ApiType: 2,
UserId: userinfo.UserId,
GuestId: userinfo.GuestId,
FileByte: nil,
})
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "failed to upload webGl render image")
}
req.RenderImage = uploadRes.ResourceUrl
}
//获取产品是否存在 //获取产品是否存在
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOne(l.ctx, req.ProductId) productInfo, err := l.svcCtx.AllModels.FsProduct.FindOne(l.ctx, req.ProductId)
if err != nil { if err != nil {

View File

@ -16,6 +16,7 @@ type ServiceContext struct {
AllModels *gmodel.AllModelsGen AllModels *gmodel.AllModelsGen
RabbitMq *initalize.RabbitMqHandle RabbitMq *initalize.RabbitMqHandle
Repositories *initalize.Repositories Repositories *initalize.Repositories
AwsSession *session.Session
} }
func NewServiceContext(c config.Config) *ServiceContext { func NewServiceContext(c config.Config) *ServiceContext {
@ -24,10 +25,11 @@ func NewServiceContext(c config.Config) *ServiceContext {
Credentials: credentials.NewStaticCredentials(c.AWS.S3.Credentials.AccessKeyID, c.AWS.S3.Credentials.Secret, c.AWS.S3.Credentials.Token), Credentials: credentials.NewStaticCredentials(c.AWS.S3.Credentials.AccessKeyID, c.AWS.S3.Credentials.Secret, c.AWS.S3.Credentials.Token),
} }
return &ServiceContext{ return &ServiceContext{
Config: c, Config: c,
MysqlConn: conn, MysqlConn: conn,
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil), RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil),
AwsSession: session.Must(session.NewSession(&config)),
Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{ Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{
GormDB: conn, GormDB: conn,
BLMServiceUrl: &c.BLMService.Url, BLMServiceUrl: &c.BLMService.Url,

View File

@ -23,7 +23,7 @@ var (
//每个websocket渲染任务缓冲队列长度默认值 //每个websocket渲染任务缓冲队列长度默认值
renderChanLen = 500 renderChanLen = 500
//每个websocket渲染并发数 //每个websocket渲染并发数
renderChanConcurrency = 25 renderChanConcurrency = 100
) )
// 渲染处理器 // 渲染处理器
@ -73,10 +73,12 @@ func (w *wsConnectItem) consumeRenderImageData() {
case data := <-w.extendRenderProperty.renderChan: //消费数据 case data := <-w.extendRenderProperty.renderChan: //消费数据
//属性不同则不发送渲染 //属性不同则不发送渲染
if data.RenderData.TemplateTag != w.extendRenderProperty.templateTag { if data.RenderData.TemplateTag != w.extendRenderProperty.templateTag {
logx.Info("丢弃切换了标签之前的渲染")
continue continue
} }
//属性不同则不发送渲染 //属性不同则不发送渲染
if data.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.colorSelectedIndex { if data.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.colorSelectedIndex {
logx.Info("丢弃切换了颜色之前的渲染")
continue continue
} }
limitChan <- struct{}{} limitChan <- struct{}{}