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

This commit is contained in:
eson 2023-08-16 10:43:33 +08:00
commit 6fe706e9e7
63 changed files with 367 additions and 238 deletions

View File

@ -9,11 +9,9 @@ const (
//ws连接成功 //ws连接成功
WEBSOCKET_CONNECT_SUCCESS = "WEBSOCKET_CONNECT_SUCCESS" WEBSOCKET_CONNECT_SUCCESS = "WEBSOCKET_CONNECT_SUCCESS"
//请求恢复为上次连接的标识 //请求恢复为上次连接的标识
WEBSOCKET_REQUEST_RESUME_LAST_CONNECT = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT" WEBSOCKET_REQUEST_REUSE_LAST_CONNECT = "WEBSOCKET_REQUEST_REUSE_LAST_CONNECT"
//请求恢复为上次连接的标识错误 //请求恢复为上次连接的标识错误
WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR" WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR"
//请求恢复为上次连接的标识成功
WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_SUCCESS = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_SUCCESS"
//渲染前数据组装 //渲染前数据组装
WEBSOCKET_RENDER_IMAGE_ASSEMBLE = "WEBSOCKET_RENDER_IMAGE_ASSEMBLE" WEBSOCKET_RENDER_IMAGE_ASSEMBLE = "WEBSOCKET_RENDER_IMAGE_ASSEMBLE"
//图片渲染 //图片渲染

View File

@ -7,7 +7,7 @@ import (
// fs_product_template_tags 模板标签表 // fs_product_template_tags 模板标签表
type FsProductTemplateTags struct { type FsProductTemplateTags struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
Title *string `gorm:"default:'';" json:"title"` // 标题 Title *string `gorm:"unique_key;default:'';" json:"title"` // 标题
Cover *string `gorm:"default:'';" json:"cover"` // 封面图 Cover *string `gorm:"default:'';" json:"cover"` // 封面图
Status *int64 `gorm:"default:0;" json:"status"` // 状态 1可用 Status *int64 `gorm:"default:0;" json:"status"` // 状态 1可用
CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间 CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间

View File

@ -32,14 +32,18 @@ func (pt *FsProductTemplateTagsModel) GetList(ctx context.Context, page, limit i
err = db.Offset(offset).Limit(limit).Find(&resp).Error err = db.Offset(offset).Limit(limit).Find(&resp).Error
return resp, err return resp, err
} }
func (pt *FsProductTemplateTagsModel) GetListByTitles(ctx context.Context, titles []string, limit int, orderBy string) (resp []FsProductTemplateTags, err error) { func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tagNames []string, limit int, orderBy string) (resp []FsProductTemplateTags, err error) {
if len(titles) == 0 { if len(tagNames) == 0 {
return nil, nil return nil, nil
} }
db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` in (?) and `status` = ?", titles, 1) db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` in (?) and `status` = ?", tagNames, 1)
if orderBy != "" { if orderBy != "" {
db = db.Order(orderBy) db = db.Order(orderBy)
} }
err = db.Limit(limit).Find(&resp).Error err = db.Limit(limit).Find(&resp).Error
return resp, err return resp, err
} }
func (pt *FsProductTemplateTagsModel) FindOneByTagName(ctx context.Context, tagName string) (resp *FsProductTemplateTags, err error) {
err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` = ? and `status` = ?", tagName, 1).Take(&resp).Error
return resp, err
}

View File

@ -24,7 +24,7 @@ type FsProductTemplateV2 struct {
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除 IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // SwitchInfo *string `gorm:"default:'';" json:"switch_info"` //
GroupOptions *string `gorm:"default:'';" json:"group_options"` // GroupOptions *string `gorm:"default:'';" json:"group_options"` //
Version *int64 `gorm:"default:0;" json:"version"` // Version *int64 `gorm:"index;default:0;" json:"version"` // 默认1
} }
type FsProductTemplateV2Model struct { type FsProductTemplateV2Model struct {
db *gorm.DB db *gorm.DB

View File

@ -111,11 +111,11 @@ func (t *FsProductTemplateV2Model) GetProductTemplateListByParams(ctx context.Co
} }
// 获取第一个尺寸下的模板 // 获取第一个尺寸下的模板
func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx context.Context, productId int64, tagId string) (resp *FsProductTemplateV2, err error) { func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx context.Context, productId int64, templateTag string) (resp *FsProductTemplateV2, err error) {
err = t.db.WithContext(ctx).Table(t.name+" as t"). err = t.db.WithContext(ctx).Table(t.name+" as t").
Joins("left join fs_product_size as s on t.product_id = s.product_id"). Joins("left join fs_product_size as s on t.product_id = s.product_id").
Select("t.*"). Select("t.*").
Where("t.product_id = ? and t.tag = ? ", productId, tagId). Where("t.product_id = ? and t.tag = ? ", productId, templateTag).
Where("t.status = ? and t.is_del = ?", 1, 0). Where("t.status = ? and t.is_del = ?", 1, 0).
Where("s.status = ?", 1). Where("s.status = ?", 1).
Order("s.sort ASC"). Order("s.sort ASC").

View File

@ -0,0 +1,9 @@
Name: assistant
Host: 0.0.0.0
Port: 9950
Timeout: 15000 #服务超时时间
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth:
AccessSecret: fusen2023
AccessExpire: 2592000
RefreshAfter: 1592000

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/utils/auth" "fusenapi/utils/auth"
@ -23,7 +22,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
})) }))
defer server.Stop() defer server.Stop()

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/backend/internal/config" "fusenapi/server/backend/internal/config"
"fusenapi/server/backend/internal/handler" "fusenapi/server/backend/internal/handler"
@ -22,7 +21,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -1,6 +1,7 @@
Name: backend Name: backend
Host: localhost Host: localhost
Port: 9901 Port: 9901
Timeout: 15000 #服务超时时间
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen_backend_2023 AccessSecret: fusen_backend_2023

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/utils/auth" "fusenapi/utils/auth"
@ -23,7 +22,7 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
})) }))
defer server.Stop() defer server.Stop()

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/canteen/internal/config" "fusenapi/server/canteen/internal/config"
"fusenapi/server/canteen/internal/handler" "fusenapi/server/canteen/internal/handler"
@ -23,8 +22,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -1,7 +1,11 @@
Name: canteen Name: canteen
Host: localhost Host: localhost
Port: 9902 Port: 9902
<<<<<<< HEAD
ReplicaId: 15 ReplicaId: 15
=======
Timeout: 15000 #服务超时时间
>>>>>>> ac1800bb26ce44fba8be8271c7be2b8403c7d7f5
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -8,7 +8,6 @@ import (
svc2 "fusenapi/server/data-transfer/internal/svc" svc2 "fusenapi/server/data-transfer/internal/svc"
"fusenapi/utils/auth" "fusenapi/utils/auth"
"net/http" "net/http"
"time"
"github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest" "github.com/zeromicro/go-zero/rest"
@ -21,7 +20,6 @@ func main() {
var c config2.Config var c config2.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -1,7 +1,11 @@
Name: data-transfer Name: data-transfer
Host: localhost Host: localhost
Port: 9903 Port: 9903
<<<<<<< HEAD
ReplicaId: 20 ReplicaId: 20
=======
Timeout: 15000 #服务超时时间
>>>>>>> ac1800bb26ce44fba8be8271c7be2b8403c7d7f5
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -1,7 +1,11 @@
Name: home-user-auth Name: home-user-auth
Host: localhost Host: localhost
Port: 9904 Port: 9904
<<<<<<< HEAD
ReplicaId: 25 ReplicaId: 25
=======
Timeout: 15000 #服务超时时间
>>>>>>> ac1800bb26ce44fba8be8271c7be2b8403c7d7f5
MainAddress: "http://localhost:9900" MainAddress: "http://localhost:9900"
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/home-user-auth/internal/config" "fusenapi/server/home-user-auth/internal/config"
"fusenapi/server/home-user-auth/internal/handler" "fusenapi/server/home-user-auth/internal/handler"
@ -23,7 +22,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -1,7 +1,11 @@
Name: inventory Name: inventory
Host: localhost Host: localhost
Port: 9905 Port: 9905
<<<<<<< HEAD
ReplicaId: 30 ReplicaId: 30
=======
Timeout: 15000 #服务超时时间
>>>>>>> ac1800bb26ce44fba8be8271c7be2b8403c7d7f5
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/inventory/internal/config" "fusenapi/server/inventory/internal/config"
"fusenapi/server/inventory/internal/handler" "fusenapi/server/inventory/internal/handler"
@ -22,7 +21,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -1,7 +1,11 @@
Name: map-library Name: map-library
Host: localhost Host: localhost
Port: 9906 Port: 9906
<<<<<<< HEAD
ReplicaId: 35 ReplicaId: 35
=======
Timeout: 15000 #服务超时时间
>>>>>>> ac1800bb26ce44fba8be8271c7be2b8403c7d7f5
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/map-library/internal/config" "fusenapi/server/map-library/internal/config"
"fusenapi/server/map-library/internal/handler" "fusenapi/server/map-library/internal/handler"
@ -22,7 +21,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -1,7 +1,11 @@
Name: orders Name: orders
Host: localhost Host: localhost
Port: 9907 Port: 9907
<<<<<<< HEAD
ReplicaId: 40 ReplicaId: 40
=======
Timeout: 15000 #服务超时时间
>>>>>>> ac1800bb26ce44fba8be8271c7be2b8403c7d7f5
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/orders/internal/config" "fusenapi/server/orders/internal/config"
"fusenapi/server/orders/internal/handler" "fusenapi/server/orders/internal/handler"
@ -22,7 +21,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -1,7 +1,11 @@
Name: pay Name: pay
Host: 0.0.0.0 Host: 0.0.0.0
Port: 9915 Port: 9915
<<<<<<< HEAD
ReplicaId: 45 ReplicaId: 45
=======
Timeout: 15000 #服务超时时间
>>>>>>> ac1800bb26ce44fba8be8271c7be2b8403c7d7f5
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/utils/auth" "fusenapi/utils/auth"
@ -23,7 +22,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
})) }))
defer server.Stop() defer server.Stop()

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/product-model/internal/config" "fusenapi/server/product-model/internal/config"
"fusenapi/server/product-model/internal/handler" "fusenapi/server/product-model/internal/handler"
@ -22,7 +21,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -2,6 +2,7 @@ Name: product-template-tag
Host: 0.0.0.0 Host: 0.0.0.0
ReplicaId: 10 ReplicaId: 10
Port: 9917 Port: 9917
Timeout: 15000 #服务超时时间
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -1,6 +1,7 @@
package logic package logic
import ( import (
"context"
"encoding/json" "encoding/json"
"errors" "errors"
"fusenapi/model/gmodel" "fusenapi/model/gmodel"
@ -8,8 +9,6 @@ import (
"fusenapi/utils/basic" "fusenapi/utils/basic"
"gorm.io/gorm" "gorm.io/gorm"
"context"
"fusenapi/server/product-template-tag/internal/svc" "fusenapi/server/product-template-tag/internal/svc"
"fusenapi/server/product-template-tag/internal/types" "fusenapi/server/product-template-tag/internal/types"
@ -67,11 +66,13 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
logx.Error(err) logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata") return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata")
} }
templateTagNameList, ok := metaData["template_tagid"].([]string) var templateTagNameList []string
if !ok { b, _ := json.Marshal(metaData["template_tagid"])
return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`template_tagid") if err = json.Unmarshal(b, &templateTagNameList); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tagid")
} }
productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTitles(l.ctx, templateTagNameList, req.Limit, "id DESC") productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, "id DESC")
} }
} }
if err != nil { if err != nil {
@ -81,9 +82,9 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
list := make([]types.GetProductTemplateTagsRsp, 0, len(productTemplateTags)) list := make([]types.GetProductTemplateTagsRsp, 0, len(productTemplateTags))
for _, v := range productTemplateTags { for _, v := range productTemplateTags {
list = append(list, types.GetProductTemplateTagsRsp{ list = append(list, types.GetProductTemplateTagsRsp{
Id: v.Id, Id: v.Id,
Tag: *v.Title, TemplateTag: *v.Title,
Cover: *v.Cover, Cover: *v.Cover,
}) })
} }
return resp.SetStatusWithMessage(basic.CodeOK, "success", list) return resp.SetStatusWithMessage(basic.CodeOK, "success", list)

View File

@ -10,9 +10,9 @@ type GetProductTemplateTagsReq struct {
} }
type GetProductTemplateTagsRsp struct { type GetProductTemplateTagsRsp struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Tag string `json:"tag"` TemplateTag string `json:"template_tag"`
Cover string `json:"cover"` Cover string `json:"cover"`
} }
type Request struct { type Request struct {

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/utils/auth" "fusenapi/utils/auth"
@ -23,7 +22,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
})) }))
defer server.Stop() defer server.Stop()

View File

@ -1,6 +1,7 @@
Name: product-template Name: product-template
Host: localhost Host: localhost
Port: 9910 Port: 9910
Timeout: 15000 #服务超时时间
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/product-template/internal/config" "fusenapi/server/product-template/internal/config"
"fusenapi/server/product-template/internal/handler" "fusenapi/server/product-template/internal/handler"
@ -22,7 +21,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -1,7 +1,11 @@
Name: product Name: product
Host: localhost Host: localhost
Port: 9908 Port: 9908
<<<<<<< HEAD
ReplicaId: 50 ReplicaId: 50
=======
Timeout: 15000 #服务超时时间
>>>>>>> ac1800bb26ce44fba8be8271c7be2b8403c7d7f5
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -36,7 +36,7 @@ func NewGetRecommandProductListLogic(ctx context.Context, svcCtx *svc.ServiceCon
func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRecommandProductListReq, userinfo *auth.UserInfo) (resp *basic.Response) { func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRecommandProductListReq, userinfo *auth.UserInfo) (resp *basic.Response) {
req.Num = 4 //写死4个 req.Num = 4 //写死4个
if req.Size > 0 { if req.Size > 0 {
req.Size = image.GetCurrentSize(req.Size) req.Size = int32(image.GetCurrentSize(uint32(req.Size)))
} }
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Sn) productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Sn)
if err != nil { if err != nil {

View File

@ -228,7 +228,7 @@ type OtherProductListRsp struct {
} }
type GetRecommandProductListReq struct { type GetRecommandProductListReq struct {
Size uint32 `form:"size,optional"` Size int32 `form:"size,optional"`
Num int64 `form:"num,optional"` Num int64 `form:"num,optional"`
Sn string `form:"sn"` Sn string `form:"sn"`
} }

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/product/internal/config" "fusenapi/server/product/internal/config"
"fusenapi/server/product/internal/handler" "fusenapi/server/product/internal/handler"
@ -22,7 +21,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -9,12 +9,10 @@ import (
"fusenapi/initalize" "fusenapi/initalize"
"fusenapi/server/render/internal/svc" "fusenapi/server/render/internal/svc"
"fusenapi/service/repositories" "fusenapi/service/repositories"
"fusenapi/utils/hash"
"fusenapi/utils/websocket_data" "fusenapi/utils/websocket_data"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm" "gorm.io/gorm"
"strconv" "strconv"
"time"
) )
// 这里请求的py接口返回数据 // 这里请求的py接口返回数据
@ -51,8 +49,18 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
return nil //不返回错误就删除消息 return nil //不返回错误就删除消息
} }
rabbitmq := initalize.RabbitMqHandle{} rabbitmq := initalize.RabbitMqHandle{}
//根据templateTag获取templateTagId(后续模板表的tag改成template_tag后可能就不需要这个步骤了)
templateTag, err := svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(ctx, parseInfo.RenderData.TemplateTag)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
logx.Error("can`t find template tag info by template tag:", parseInfo.RenderData.TemplateTag)
return nil
}
logx.Error("failed to get template tag info")
return nil
}
//获取模板(模板标签下的对一个物料的的模板) //获取模板(模板标签下的对一个物料的的模板)
productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, fmt.Sprintf("%d", parseInfo.RenderData.TemplateTagId)) productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, fmt.Sprintf("%d", templateTag.Id))
if err != nil { if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) { if errors.Is(err, gorm.ErrRecordNotFound) {
logx.Error("template info is not found") logx.Error("template info is not found")
@ -61,33 +69,17 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
logx.Error("failed to get template info:", err) logx.Error("failed to get template info:", err)
return nil //不返回错误就删除消息 return nil //不返回错误就删除消息
} }
time.Now().UTC()
resourceKey := hash.JsonHashKey(parseInfo)
combineParam := map[string]interface{}{
"logo_url": parseInfo.RenderData.Logo,
"website": "",
"slogan": "",
"address": "",
"phone": "",
"colors": []string{},
"template_tagid": "b1a",
"is_crop": false,
"shape": "rectangle",
"ratio": 0,
"line": "",
"other": "",
"other1": "",
}
combineParamBytes, _ := json.Marshal(combineParam)
//获取刀版图 //获取刀版图
res, err := svcCtx.Repositories.ImageHandle.LogoCombine(ctx, &repositories.LogoCombineReq{ res, err := svcCtx.Repositories.ImageHandle.LogoCombine(ctx, &repositories.LogoCombineReq{
ResourceKey: resourceKey, UserId: parseInfo.RenderData.UserId,
TemplateId: productTemplate.Id, GuestId: parseInfo.RenderData.GuestId,
CombineParam: string(combineParamBytes), TemplateId: productTemplate.Id,
UserId: parseInfo.RenderData.UserId, TemplateTag: parseInfo.RenderData.TemplateTag,
GuestId: parseInfo.RenderData.GuestId, Website: parseInfo.RenderData.Website,
Slogan: parseInfo.RenderData.Slogan,
Address: parseInfo.RenderData.Address,
Phone: parseInfo.RenderData.Phone,
}) })
if err != nil { if err != nil {
logx.Error("合成刀版图失败:", err) logx.Error("合成刀版图失败:", err)
return nil return nil
@ -99,7 +91,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
logx.Error("合成刀版图失败,合成的刀版图是空指针:", err) logx.Error("合成刀版图失败,合成的刀版图是空指针:", err)
return nil return nil
} }
logx.Info("合成刀版图成功") logx.Info("合成刀版图成功:", *res.ResourceUrl)
//获取渲染设置信息 //获取渲染设置信息
element, err := svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(ctx, *productTemplate.ModelId) element, err := svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(ctx, *productTemplate.ModelId)
if err != nil { if err != nil {

View File

@ -1,7 +1,11 @@
Name: render Name: render
Host: 0.0.0.0 Host: 0.0.0.0
Port: 9919 Port: 9919
<<<<<<< HEAD
ReplicaId: 55 ReplicaId: 55
=======
Timeout: 15000 #服务超时时间
>>>>>>> ac1800bb26ce44fba8be8271c7be2b8403c7d7f5
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -39,30 +39,15 @@ func NewRenderNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Rend
// } // }
func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) { func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) {
/*if time.Now().Unix()-120 > req.Time || req.Time > time.Now().Unix() { if req.TaskId == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param time")
}*/
if req.Info.TaskId == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
} }
if req.Info.Image == "" { if req.Image == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image")
} }
if req.Info.UserId == 0 && req.Info.GuestId == 0 { if req.UserId == 0 && req.GuestId == 0 {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid user_id or guest_id") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid user_id or guest_id")
} }
/* if req.Sign == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param sign")
}*/
//验证签名 sha256
/*notifyByte, _ := json.Marshal(req.Info)
h := sha256.New()
h.Write([]byte(fmt.Sprintf(constants.RENDER_NOTIFY_SIGN_KEY, string(notifyByte), req.Time)))
signHex := h.Sum(nil)
sign := hex.EncodeToString(signHex)
if req.Sign != sign {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid sign")
}*/
// 上传文件 // 上传文件
var upload = file.Upload{ var upload = file.Upload{
Ctx: l.ctx, Ctx: l.ctx,
@ -70,12 +55,12 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
AwsSession: l.svcCtx.AwsSession, AwsSession: l.svcCtx.AwsSession,
} }
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{ uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
FileHash: req.Info.TaskId, FileHash: req.TaskId,
FileData: req.Info.Image, FileData: req.Image,
UploadBucket: 1, UploadBucket: 1,
ApiType: 2, ApiType: 2,
UserId: req.Info.UserId, UserId: req.UserId,
GuestId: req.Info.GuestId, GuestId: req.GuestId,
}) })
if err != nil { if err != nil {
logx.Error(err) logx.Error(err)
@ -83,13 +68,13 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
} }
//发送消息到对应的rabbitmq //发送消息到对应的rabbitmq
data := websocket_data.RenderImageNotify{ data := websocket_data.RenderImageNotify{
TaskId: req.Info.TaskId, TaskId: req.TaskId,
Image: uploadRes.ResourceUrl, Image: uploadRes.ResourceUrl,
} }
d, _ := json.Marshal(data) d, _ := json.Marshal(data)
if err = l.svcCtx.RabbitMq.SendMsg(constants.RABBIT_MQ_RENDER_RESULT_DATA, d); err != nil { if err = l.svcCtx.RabbitMq.SendMsg(constants.RABBIT_MQ_RENDER_RESULT_DATA, d); err != nil {
logx.Error(err) logx.Error(err)
return resp.SetStatus(basic.CodeServiceErr, "failed to send data") return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to send data")
} }
return resp.SetStatus(basic.CodeOK) return resp.SetStatusWithMessage(basic.CodeOK, "success")
} }

View File

@ -12,12 +12,6 @@ type RequestReadImages struct {
} }
type RenderNotifyReq struct { type RenderNotifyReq struct {
Sign string `json:"sign"`
Time int64 `json:"time"`
Info NotifyInfo `json:"info"`
}
type NotifyInfo struct {
TaskId string `json:"task_id"` //任务id TaskId string `json:"task_id"` //任务id
UserId int64 `json:"user_id"` UserId int64 `json:"user_id"`
GuestId int64 `json:"guest_id"` GuestId int64 `json:"guest_id"`

View File

@ -7,7 +7,6 @@ import (
"fusenapi/constants" "fusenapi/constants"
"fusenapi/server/render/consumer" "fusenapi/server/render/consumer"
"net/http" "net/http"
"time"
"fusenapi/utils/auth" "fusenapi/utils/auth"
@ -26,7 +25,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
})) }))
defer server.Stop() defer server.Stop()

View File

@ -17,6 +17,7 @@ AWS:
Token: Token:
BLMService: BLMService:
Url: "http://18.119.109.254:8999" Url: "http://18.119.109.254:8999"
# Url: "http://192.168.1.7:8999"
LogoCombine: LogoCombine:
#Url: "http://192.168.1.7:8999/LogoCombine" #Url: "http://192.168.1.7:8999/LogoCombine"
Url: "http://18.119.109.254:8999/LogoCombine" Url: "http://18.119.109.254:8999/LogoCombine"

View File

@ -57,11 +57,15 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
userId = userinfo.UserId userId = userinfo.UserId
} }
res, err := l.svcCtx.Repositories.ImageHandle.LogoCombine(l.ctx, &repositories.LogoCombineReq{ res, err := l.svcCtx.Repositories.ImageHandle.LogoCombine(l.ctx, &repositories.LogoCombineReq{
ResourceKey: req.ResourceKey, UserId: userId,
TemplateId: req.TemplateId, GuestId: guestId,
CombineParam: req.CombineParam, TemplateId: req.TemplateId,
UserId: userId, TemplateTag: req.TemplateTag,
GuestId: guestId, Website: req.Website,
Slogan: req.Slogan,
Phone: req.Phone,
Address: req.Address,
Qrcode: req.Qrcode,
}) })
if err != nil { if err != nil {

View File

@ -11,9 +11,13 @@ type ResourceInfoReq struct {
} }
type LogoCombineReq struct { type LogoCombineReq struct {
ResourceKey string `form:"resource_key"` // 资源唯一标识 TemplateId int64 `form:"template_id"` // 合图参数
CombineParam string `form:"combine_param"` // 合图参数 TemplateTag string `form:"template_tag"` // 合图参数
TemplateId int64 `form:"template_id"` // 合图参数 Website string `form:"website,optional"` // 合图参数
Slogan string `form:"slogan,optional"` // 合图参数
Address string `form:"address,optional"` // 合图参数
Phone string `form:"phone,optional"` // 合图参数
Qrcode string `form:"qrcode,optional"` // 合图参数
} }
type Request struct { type Request struct {

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/utils/auth" "fusenapi/utils/auth"
@ -23,7 +22,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
})) }))
defer server.Stop() defer server.Stop()

View File

@ -1,7 +1,11 @@
Name: shopping-cart-confirmation Name: shopping-cart-confirmation
Host: localhost Host: localhost
Port: 9911 Port: 9911
<<<<<<< HEAD
ReplicaId: 65 ReplicaId: 65
=======
Timeout: 15000 #服务超时时间
>>>>>>> ac1800bb26ce44fba8be8271c7be2b8403c7d7f5
SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/shopping-cart-confirmation/internal/config" "fusenapi/server/shopping-cart-confirmation/internal/config"
"fusenapi/server/shopping-cart-confirmation/internal/handler" "fusenapi/server/shopping-cart-confirmation/internal/handler"
@ -22,7 +21,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -1,7 +1,11 @@
Name: upload Name: upload
Host: localhost Host: localhost
Port: 9912 Port: 9912
<<<<<<< HEAD
ReplicaId: 70 ReplicaId: 70
=======
Timeout: 15000 #服务超时时间
>>>>>>> ac1800bb26ce44fba8be8271c7be2b8403c7d7f5
SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest" SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest"
Env: "test" Env: "test"
Auth: Auth:
@ -16,5 +20,5 @@ AWS:
Token: Token:
BLMService: BLMService:
ImageProcess: ImageProcess:
#Url: "http://192.168.1.7:45678/FeatureExtraction" # Url: "http://192.168.1.7:8999/FeatureExtraction"
Url: "http://18.119.109.254:8999/FeatureExtraction" Url: "http://18.119.109.254:8999/FeatureExtraction"

View File

@ -1,6 +1,7 @@
package logic package logic
import ( import (
"fmt"
"fusenapi/utils/auth" "fusenapi/utils/auth"
"fusenapi/utils/basic" "fusenapi/utils/basic"
"fusenapi/utils/file" "fusenapi/utils/file"
@ -44,28 +45,25 @@ func NewUploadFileBackendLogic(r *http.Request, svcCtx *svc.ServiceContext) *Upl
func (l *UploadFileBackendLogic) UploadFileBackend(req *types.UploadFileBackendReq, userinfo *auth.UserInfo) (resp *basic.Response) { func (l *UploadFileBackendLogic) UploadFileBackend(req *types.UploadFileBackendReq, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null // userinfo 传入值时, 一定不为null
if userinfo.IsOnlooker() { var userId int64 = 0
// 如果是,返回未授权的错误码 var guestId int64 = 0
return resp.SetStatus(basic.CodeUnAuth)
}
// 定义用户ID和S3键名格式
var userId int64
var guestId int64
// 检查用户是否是游客 // 检查用户是否是游客
if userinfo.IsGuest() { if userinfo != nil {
// 如果是使用游客ID和游客键名格式 if userinfo.IsGuest() {
guestId = userinfo.GuestId // 如果是使用游客ID和游客键名格式
} else { guestId = userinfo.GuestId
// 否则使用用户ID和用户键名格式 } else {
userId = userinfo.UserId // 否则使用用户ID和用户键名格式
userId = userinfo.UserId
}
} }
//设置内存大小 //设置内存大小
l.r.ParseMultipartForm(32 << 20) l.r.ParseMultipartForm(32 << 20)
fileObject, _, err := l.r.FormFile("file") fileObject, _, err := l.r.FormFile("file")
fmt.Printf("%#v", fileObject)
if err != nil { if err != nil {
logx.Error(err) logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,no files") return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,no files")

View File

@ -2,6 +2,7 @@ package logic
import ( import (
"encoding/json" "encoding/json"
"errors"
"fusenapi/model/gmodel" "fusenapi/model/gmodel"
"fusenapi/utils/auth" "fusenapi/utils/auth"
"fusenapi/utils/basic" "fusenapi/utils/basic"
@ -69,11 +70,29 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
//设置内存大小 //设置内存大小
l.r.ParseMultipartForm(32 << 20) l.r.ParseMultipartForm(32 << 20)
fileObject, _, err := l.r.FormFile("file") fileObject, fileHeader, err := l.r.FormFile("file")
if err != nil { if err != nil {
logx.Error(err) logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,no files") return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,no files")
} }
defer fileObject.Close()
// 获取文件的MIME类型
fileType := fileHeader.Header.Get("Content-Type")
var imageTypes = make(map[string]struct{}, 7)
imageTypes["image/jpg"] = struct{}{}
imageTypes["image/jpeg"] = struct{}{}
imageTypes["image/png"] = struct{}{}
imageTypes["image/gif"] = struct{}{}
imageTypes["image/bmp"] = struct{}{}
imageTypes["image/tiff"] = struct{}{}
imageTypes["image/webp"] = struct{}{}
imageTypes["image/svg+xml"] = struct{}{}
// 判断文件类型是否为图片
_, ok := imageTypes[fileType]
if !ok {
return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,file is not image")
}
// 读取数据流 // 读取数据流
ioData, err := io.ReadAll(fileObject) ioData, err := io.ReadAll(fileObject)
@ -143,10 +162,30 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
logx.Error(err) logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail") return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
} }
resultStr = string(b)
if resultStr == "Internal Server Error" { if string(b) == "Internal Server Error" {
return resp.SetStatus(basic.CodeFileUploadLogoErr, resultStr) err = errors.New("BLMService fail Internal Server Error")
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
} else {
var resData map[string]interface{}
err = json.Unmarshal(b, &resData)
if err != nil || resData == nil {
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
}
if resData != nil {
if resData["code"].(string) == "200" {
resultStr = resData["data"].(string)
} else {
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErrType, "service fail")
}
} else {
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
}
} }
var module = "logo" var module = "logo"

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/upload/internal/config" "fusenapi/server/upload/internal/config"
"fusenapi/server/upload/internal/handler" "fusenapi/server/upload/internal/handler"
@ -22,7 +21,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -2,6 +2,7 @@ Name: webset
Host: localhost Host: localhost
Port: 9913 Port: 9913
ReplicaId: 75 ReplicaId: 75
Timeout: 15000 #服务超时时间
SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest" SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest"
Auth: Auth:
AccessSecret: fusen2023 AccessSecret: fusen2023

View File

@ -4,7 +4,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"time"
"fusenapi/server/webset/internal/config" "fusenapi/server/webset/internal/config"
"fusenapi/server/webset/internal/handler" "fusenapi/server/webset/internal/handler"
@ -22,7 +21,6 @@ func main() {
var c config.Config var c config.Config
conf.MustLoad(*configFile, &c) conf.MustLoad(*configFile, &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@ -3,6 +3,7 @@ package logic
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"fusenapi/constants" "fusenapi/constants"
"fusenapi/initalize" "fusenapi/initalize"
"fusenapi/model/gmodel" "fusenapi/model/gmodel"
@ -99,7 +100,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp
) )
isAuth, userInfo = l.checkAuth(svcCtx, r) isAuth, userInfo = l.checkAuth(svcCtx, r)
if !isAuth { if !isAuth {
time.Sleep(time.Second * 2) //兼容下火狐 time.Sleep(time.Second * 1) //兼容下火狐
rsp := websocket_data.DataTransferData{ rsp := websocket_data.DataTransferData{
T: constants.WEBSOCKET_UNAUTH, T: constants.WEBSOCKET_UNAUTH,
D: nil, D: nil,
@ -134,7 +135,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
publicMutex.Lock() publicMutex.Lock()
defer publicMutex.Unlock() defer publicMutex.Unlock()
//生成连接唯一标识 //生成连接唯一标识
uniqueId := l.getUniqueId() uniqueId := l.getUniqueId(userInfo)
ws := wsConnectItem{ ws := wsConnectItem{
conn: conn, conn: conn,
ctx: l.ctx, ctx: l.ctx,
@ -155,22 +156,27 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
mapConnPool.Store(uniqueId, ws) mapConnPool.Store(uniqueId, ws)
go func() { go func() {
//把连接成功消息发回去 //把连接成功消息发回去
time.Sleep(time.Second * 2) //兼容下火狐 time.Sleep(time.Second * 1) //兼容下火狐
b := ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId) ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId))
_ = conn.WriteMessage(websocket.TextMessage, b)
}() }()
return ws return ws
} }
// 获取唯一id // 获取唯一id
func (l *DataTransferLogic) getUniqueId() string { func (l *DataTransferLogic) getUniqueId(userInfo auth.UserInfo) string {
uniqueId := uuid.New().String() + time.Now().Format("20060102150405") //后面拼接上用户id
uniqueId := uuid.New().String() + getUserPart(userInfo.UserId, userInfo.GuestId)
if _, ok := mapConnPool.Load(uniqueId); ok { if _, ok := mapConnPool.Load(uniqueId); ok {
uniqueId = l.getUniqueId() uniqueId = l.getUniqueId(userInfo)
} }
return uniqueId return uniqueId
} }
// 获取用户拼接部分
func getUserPart(userId, guestId int64) string {
return fmt.Sprintf("_%d_%d", userId, guestId)
}
// 鉴权 // 鉴权
func (l *DataTransferLogic) checkAuth(svcCtx *svc.ServiceContext, r *http.Request) (isAuth bool, userInfo *auth.UserInfo) { func (l *DataTransferLogic) checkAuth(svcCtx *svc.ServiceContext, r *http.Request) (isAuth bool, userInfo *auth.UserInfo) {
// 解析JWT token,并对空用户进行判断 // 解析JWT token,并对空用户进行判断
@ -286,7 +292,9 @@ func (w *wsConnectItem) sendToOutChan(data []byte) {
case <-w.closeChan: case <-w.closeChan:
return return
case w.outChan <- data: case w.outChan <- data:
logx.Info("notify send render result to out chan") return
case <-time.After(time.Second * 3): //阻塞超过3秒丢弃
return
} }
} }
@ -304,8 +312,8 @@ func (w *wsConnectItem) respondDataFormat(msgType string, data interface{}) []by
func (w *wsConnectItem) dealwithReciveData(data []byte) { func (w *wsConnectItem) dealwithReciveData(data []byte) {
var parseInfo websocket_data.DataTransferData var parseInfo websocket_data.DataTransferData
if err := json.Unmarshal(data, &parseInfo); err != nil { if err := json.Unmarshal(data, &parseInfo); err != nil {
logx.Error("invalid format of websocket message") logx.Error("invalid format of websocket message:", err)
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket message:"+string(data)) w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket message:"+string(data)))
return return
} }
d, _ := json.Marshal(parseInfo.D) d, _ := json.Marshal(parseInfo.D)
@ -315,8 +323,8 @@ func (w *wsConnectItem) dealwithReciveData(data []byte) {
case constants.WEBSOCKET_RENDER_IMAGE: case constants.WEBSOCKET_RENDER_IMAGE:
w.renderImage(d) w.renderImage(d)
//刷新重连请求恢复上次连接的标识 //刷新重连请求恢复上次连接的标识
case constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT: case constants.WEBSOCKET_REQUEST_REUSE_LAST_CONNECT:
w.resumeLateConnect(d) w.reuseLastConnect(d)
default: default:
} }

View File

@ -28,39 +28,48 @@ type renderImageControlChanItem struct {
func (w *wsConnectItem) renderImage(data []byte) { func (w *wsConnectItem) renderImage(data []byte) {
var renderImageData websocket_data.RenderImageReqMsg var renderImageData websocket_data.RenderImageReqMsg
if err := json.Unmarshal(data, &renderImageData); err != nil { if err := json.Unmarshal(data, &renderImageData); err != nil {
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:"+string(data)) w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:"+string(data)))
logx.Error("invalid format of websocket render image message", err) logx.Error("invalid format of websocket render image message", err)
return return
} }
logx.Info("收到请求云渲染图片数据:", renderImageData) logx.Info("收到请求云渲染图片数据:", renderImageData)
if renderImageData.RenderId == "" { if renderImageData.RenderId == "" {
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:render_id is empty") w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:render_id is empty"))
logx.Error("invalid format of websocket render image message:render_id is empty") logx.Error("invalid format of websocket render image message:render_id is empty")
return return
} }
if renderImageData.RenderData.ProductId <= 0 { if renderImageData.RenderData.ProductId <= 0 {
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:product_id ") w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:product_id "))
logx.Error("invalid format of websocket render image message:product_id") logx.Error("invalid format of websocket render image message:product_id")
return return
} }
if renderImageData.RenderData.TemplateTagId <= 0 { if renderImageData.RenderData.TemplateTag == "" {
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:template_tag_id ") w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:template_tag "))
logx.Error("invalid format of websocket render image message:template_tag_id") logx.Error("invalid format of websocket render image message:template_tag")
return return
} }
//获取上传最近的logo //获取上传最近的logo
userMaterial, err := w.allModels.FsUserMaterial.FindLatestOne(w.ctx, w.userId, w.guestId) userMaterial, err := w.allModels.FsUserMaterial.FindLatestOne(w.ctx, w.userId, w.guestId)
if err != nil { if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) { if !errors.Is(err, gorm.ErrRecordNotFound) {
w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get user logo") w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get user logo"))
logx.Error("failed to get user logo") logx.Error("failed to get user logo")
return return
} }
//使用默认logo(写死一个默认) //使用默认logo(id=0)
renderImageData.RenderData.Logo = "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/f5ccd11365099fa47a6316b1cd639f6dd6064dcd2d37c8d2fcd0a322160b33cc" userMaterialDefault, err := w.allModels.FsUserMaterial.FindOneById(w.ctx, 0)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "default logo is not exists"))
return
}
logx.Error("default logo is not exists")
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get default logo"))
return
}
renderImageData.RenderData.Logo = *userMaterialDefault.ResourceUrl
} else { } else {
renderImageData.RenderData.Logo = *userMaterial.ResourceUrl renderImageData.RenderData.Logo = *userMaterial.ResourceUrl
renderImageData.RenderData.UserMaterialId = userMaterial.Id
} }
//用户id赋值 //用户id赋值
renderImageData.RenderData.UserId = w.userId renderImageData.RenderData.UserId = w.userId
@ -99,7 +108,7 @@ func (w *wsConnectItem) renderImage(data []byte) {
} }
d, _ := json.Marshal(tmpData) d, _ := json.Marshal(tmpData)
//发送给对应的流水线组装数据 //发送给对应的流水线组装数据
if err := w.rabbitMq.SendMsg(constants.RABBIT_MQ_ASSEMBLE_RENDER_DATA, d); err != nil { if err = w.rabbitMq.SendMsg(constants.RABBIT_MQ_ASSEMBLE_RENDER_DATA, d); err != nil {
logx.Error("发送渲染任务数据到MQ失败:", string(d), "err:", err) logx.Error("发送渲染任务数据到MQ失败:", string(d), "err:", err)
return return
} }

View File

@ -1,27 +0,0 @@
package logic
import "fusenapi/constants"
// 刷新重连请求恢复上次连接的标识
func (w *wsConnectItem) resumeLateConnect(data []byte) {
clientId := string(data)
//id长度不对
if len(clientId) != 50 {
rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "request id is invalid")
w.sendToOutChan(rsp)
return
}
publicMutex.Lock()
defer publicMutex.Unlock()
//存在是不能给他申请重新绑定
if _, ok := mapConnPool.Load(clientId); ok {
rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "id has bound by other connect ")
w.sendToOutChan(rsp)
return
}
//重新绑定
w.uniqueId = clientId
rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_SUCCESS, clientId)
w.sendToOutChan(rsp)
return
}

View File

@ -0,0 +1,49 @@
package logic
import (
"encoding/json"
"fusenapi/constants"
"github.com/zeromicro/go-zero/core/logx"
)
// 刷新重连请求恢复上次连接的标识
func (w *wsConnectItem) reuseLastConnect(data []byte) {
logx.Info("收到请求恢复上次连接标识数据:", string(data))
var clientId string
if err := json.Unmarshal(data, &clientId); err != nil {
logx.Error(" invalid format of client id :", clientId)
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "invalid format of client id"))
return
}
lenClientId := len(clientId)
//id长度不对
if lenClientId > 100 {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "length of client id is to long"))
return
}
//合成client后缀,不是同个后缀的不能复用
userPart := getUserPart(w.userId, w.guestId)
lenUserPart := len(userPart)
if lenClientId <= lenUserPart {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "length of client id is to short"))
return
}
//尾部不同不能复用
if clientId[lenClientId-lenUserPart:] != userPart {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "the client id is not belong you before"))
return
}
publicMutex.Lock()
defer publicMutex.Unlock()
//存在是不能给他申请重新绑定
if _, ok := mapConnPool.Load(clientId); ok {
rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "id has bound by other connect ")
w.sendToOutChan(rsp)
return
}
//重新绑定
w.uniqueId = clientId
rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, clientId)
w.sendToOutChan(rsp)
return
}

View File

@ -20,7 +20,7 @@ type GetProductTemplateTagsReq {
Limit int `form:"limit"` Limit int `form:"limit"`
} }
type GetProductTemplateTagsRsp { type GetProductTemplateTagsRsp {
Id int64 `json:"id"` Id int64 `json:"id"`
Tag string `json:"tag"` TemplateTag string `json:"template_tag"`
Cover string `json:"cover"` Cover string `json:"cover"`
} }

View File

@ -281,7 +281,7 @@ type OtherProductListRsp {
} }
//获取详情页推荐产品列表 //获取详情页推荐产品列表
type GetRecommandProductListReq { type GetRecommandProductListReq {
Size uint32 `form:"size,optional"` Size int32 `form:"size,optional"`
Num int64 `form:"num,optional"` Num int64 `form:"num,optional"`
Sn string `form:"sn"` Sn string `form:"sn"`
} }

View File

@ -26,11 +26,6 @@ service render {
//渲染完了通知接口 //渲染完了通知接口
type RenderNotifyReq { type RenderNotifyReq {
Sign string `json:"sign"`
Time int64 `json:"time"`
Info NotifyInfo `json:"info"`
}
type NotifyInfo {
TaskId string `json:"task_id"` //任务id TaskId string `json:"task_id"` //任务id
UserId int64 `json:"user_id"` UserId int64 `json:"user_id"`
GuestId int64 `json:"guest_id"` GuestId int64 `json:"guest_id"`

View File

@ -26,8 +26,12 @@ type (
type ( type (
LogoCombineReq { LogoCombineReq {
ResourceKey string `form:"resource_key"` // 资源唯一标识 TemplateId int64 `form:"template_id"` // 合图参数
CombineParam string `form:"combine_param"` // 合图参数 TemplateTag string `form:"template_tag"` // 合图参数
TemplateId int64 `form:"template_id"` // 合图参数 Website string `form:"website,optional"` // 合图参数
Slogan string `form:"slogan,optional"` // 合图参数
Address string `form:"address,optional"` // 合图参数
Phone string `form:"phone,optional"` // 合图参数
Qrcode string `form:"qrcode,optional"` // 合图参数
} }
) )

View File

@ -43,11 +43,15 @@ type (
/* logo合图 */ /* logo合图 */
type ( type (
LogoCombineReq struct { LogoCombineReq struct {
ResourceKey string `json:"resource_key"` UserId int64 `json:"user_id"`
TemplateId int64 `json:"template_id"` GuestId int64 `json:"guest_id"`
CombineParam string `json:"combine_param"` TemplateId int64 `json:"template_id"`
UserId int64 `json:"user_id"` TemplateTag string `json:"resource_key"`
GuestId int64 `json:"guest_id"` Website string `json:"website"` // 合图参数
Slogan string `json:"slogan"` // 合图参数
Address string `json:"address"` // 合图参数
Phone string `json:"phone"` // 合图参数
Qrcode string `json:"qrcode"` // 合图参数
} }
LogoCombineRes struct { LogoCombineRes struct {
ResourceId string ResourceId string
@ -58,7 +62,8 @@ type (
func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) { func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) {
// 根据hash 查询数据资源 // 根据hash 查询数据资源
var resourceId string = hash.JsonHashKey(in.ResourceKey) var resourceId string = hash.JsonHashKey(in)
resourceModel := gmodel.NewFsResourceModel(l.MysqlConn) resourceModel := gmodel.NewFsResourceModel(l.MysqlConn)
resourceInfo, err := resourceModel.FindOneById(ctx, resourceId) resourceInfo, err := resourceModel.FindOneById(ctx, resourceId)
if err == nil && resourceInfo.ResourceId != "" { if err == nil && resourceInfo.ResourceId != "" {
@ -111,8 +116,36 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
moduleDataMap["groupOptions"] = groupOptions moduleDataMap["groupOptions"] = groupOptions
moduleDataMap["materialList"] = materialList moduleDataMap["materialList"] = materialList
// 查询logo最新基础信息
var metadata *string
userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn)
userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
userMaterialInfoDefault, err := userMaterialModel.FindOneById(ctx, 0)
if err != nil {
logx.Error(err)
return nil, err
}
metadata = userMaterialInfoDefault.Metadata
} else {
logx.Error(err)
return nil, err
}
} else {
metadata = userMaterialInfo.Metadata
}
var combineParam map[string]interface{} var combineParam map[string]interface{}
json.Unmarshal([]byte(in.CombineParam), &combineParam) json.Unmarshal([]byte(*metadata), &combineParam)
combineParam["template_tagid"] = in.TemplateTag
combineParam["website"] = in.Website
combineParam["slogan"] = in.Slogan
combineParam["phone"] = in.Phone
combineParam["address"] = in.Address
combineParam["qrcode"] = in.Qrcode
var postMap = make(map[string]interface{}, 2) var postMap = make(map[string]interface{}, 2)
postMap["module_data"] = moduleDataMap postMap["module_data"] = moduleDataMap
postMap["param_data"] = combineParam postMap["param_data"] = combineParam
@ -132,16 +165,35 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
logx.Error(err) logx.Error(err)
return nil, err return nil, err
} }
ress := string(b) var resultStr string
if string(b) == "Internal Server Error" {
if ress == "Internal Server Error" { err = errors.New("BLMService fail Internal Server Error")
logx.Error(errors.New("BLMService fail Internal Server Error")) logx.Error(err)
return nil, err return nil, err
} else {
var resData map[string]interface{}
err = json.Unmarshal(b, &resData)
if err != nil || resData == nil {
logx.Error(err)
return nil, err
}
if resData != nil {
if resData["code"].(string) == "200" {
resultStr = resData["data"].(string)
} else {
logx.Error(err)
return nil, err
}
} else {
logx.Error(err)
return nil, err
}
} }
var resultData map[string]interface{} var resultData map[string]interface{}
err = json.Unmarshal(b, &resultData) err = json.Unmarshal([]byte(resultStr), &resultData)
if err != nil { if err != nil || resultData == nil {
logx.Error(err) logx.Error(err)
return nil, err return nil, err
} }

View File

@ -87,9 +87,10 @@ var (
CodeSharedStateErr = &StatusResponse{5201, "shared state server err"} // 状态机错误 CodeSharedStateErr = &StatusResponse{5201, "shared state server err"} // 状态机错误
CodeEmailConfirmationErr = &StatusResponse{5202, "email confirmation err"} // email 验证错误 CodeEmailConfirmationErr = &StatusResponse{5202, "email confirmation err"} // email 验证错误
CodeFileUploadErr = &StatusResponse{5110, "file upload err"} // 文件上传失败 CodeFileUploadErr = &StatusResponse{5110, "file upload err"} // 文件上传失败
CodeFileUploadLogoErr = &StatusResponse{5111, "logo upload err"} // 用户上传LOGO失败 CodeFileUploadLogoErr = &StatusResponse{5111, "logo upload err"} // 用户上传LOGO失败
CodeFileLogoCombineErr = &StatusResponse{5112, "logo upload err"} // 用户合图失败 CodeFileUploadLogoErrType = &StatusResponse{5111, "logo upload err file is not image"} // 用户上位LOGO失败"}
CodeFileLogoCombineErr = &StatusResponse{5112, "logo upload err"} // 用户合图失败
) )
type Response struct { type Response struct {

View File

@ -12,16 +12,15 @@ type RenderImageReqMsg struct {
RenderData RenderData `json:"render_data"` RenderData RenderData `json:"render_data"`
} }
type RenderData struct { type RenderData struct {
TemplateTagId int64 `json:"template_tag_id"` //模板标签id TemplateTag string `json:"template_tag"` //模板标签(必须)
ProductId int64 `json:"product_id"` //产品id ProductId int64 `json:"product_id"` //产品id(必须)
UserMaterialId int64 `json:"user_material_id"` //用户素材id Website string `json:"website"` //网站(可选)
Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值) Slogan string `json:"slogan"` //slogan(可选)
/*Website string `json:"website"` //网站 Address string `json:"address"` //地址(可选)
Slogan string `json:"slogan"` //slogan Phone string `json:"phone"` //电话(可选)
Address string `json:"address"` //地址 UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值)
Phone string `json:"phone"` //电话*/ GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值) Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值)
GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
} }
// websocket发送渲染完的数据 // websocket发送渲染完的数据