From dbffda69fda6d97c0246a07e13f61bec5b098289 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Fri, 13 Oct 2023 17:44:02 +0800
Subject: [PATCH 01/20] fix
---
.../internal/logic/uploadfilebackendlogic.go | 3 +-
utils/curl/http_curl.go | 47 +++++++++++++++++++
2 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/server/upload/internal/logic/uploadfilebackendlogic.go b/server/upload/internal/logic/uploadfilebackendlogic.go
index 6bd578e1..1323304c 100644
--- a/server/upload/internal/logic/uploadfilebackendlogic.go
+++ b/server/upload/internal/logic/uploadfilebackendlogic.go
@@ -1,7 +1,6 @@
package logic
import (
- "fmt"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/file"
@@ -63,7 +62,7 @@ func (l *UploadFileBackendLogic) UploadFileBackend(req *types.UploadFileBackendR
l.r.ParseMultipartForm(32 << 20)
fileObject, _, err := l.r.FormFile("file")
- fmt.Printf("%#v", fileObject)
+ //fmt.Printf("%#v", fileObject)
if err != nil {
logx.Error(err)
return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,no files")
diff --git a/utils/curl/http_curl.go b/utils/curl/http_curl.go
index 0fbef756..e704569d 100644
--- a/utils/curl/http_curl.go
+++ b/utils/curl/http_curl.go
@@ -1,6 +1,8 @@
package curl
import (
+ "bufio"
+ "bytes"
"errors"
"io"
"net/http"
@@ -32,3 +34,48 @@ func ApiCall(url, method string, header map[string]string, body io.Reader, timeO
}
return client.Do(requestHandle)
}
+
+// 请求(读取返回字节内容)
+func ApiCall2(url, method string, header map[string]string, body io.Reader, timeOut time.Duration) (result []byte, err error) {
+ method = strings.ToUpper(method)
+ if method != "GET" && method != "POST" && method != "PUT" && method != "DELETE" {
+ return nil, errors.New("invalid http method")
+ }
+ if url == "" {
+ return nil, errors.New("request url can`t be empty")
+ }
+ client := &http.Client{}
+ if timeOut <= 0 {
+ client.Timeout = time.Second * 15
+ } else {
+ client.Timeout = timeOut
+ }
+ requestHandle, err := http.NewRequest(method, url, body)
+ if err != nil {
+ return nil, err
+ }
+ for k, v := range header {
+ requestHandle.Header.Set(k, v)
+ }
+ rsp, err := client.Do(requestHandle)
+ if err != nil {
+ return nil, err
+ }
+ defer rsp.Body.Close()
+ buff := bytes.Buffer{}
+ reader := bufio.NewReader(rsp.Body)
+ for {
+ line, _, err := reader.ReadLine()
+ if err == io.EOF {
+ break
+ }
+ if err != nil {
+ return nil, err
+ }
+ _, err = buff.Write(line)
+ if err != nil {
+ return nil, err
+ }
+ }
+ return buff.Bytes(), nil
+}
From 23b2eded5a1b9098acc8a5435293e5f4ee8e60c9 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Fri, 13 Oct 2023 18:17:31 +0800
Subject: [PATCH 02/20] fix
---
.../logic/getproducttemplatetagslogic.go | 38 +++++++++----------
.../internal/types/types.go | 3 +-
server_api/product-template-tag.api | 3 +-
3 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go
index d97c768a..7191f110 100644
--- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go
+++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go
@@ -6,7 +6,6 @@ import (
"fusenapi/model/gmodel"
"fusenapi/server/product-template-tag/internal/svc"
"fusenapi/server/product-template-tag/internal/types"
- "fusenapi/service/repositories"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/s3url_to_s3id"
@@ -55,16 +54,17 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
productTemplateTags []gmodel.FsProductTemplateTags
err error
)
- //获取用户需要渲染logo
- logoInfo, err := l.svcCtx.Repositories.ImageHandle.LogoInfo(l.ctx, &repositories.LogoInfoReq{
- UserId: userinfo.UserId,
- GuestId: userinfo.GuestId,
- })
+ if req.Logo == "" {
+ return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "logo is required")
+ }
+ logoResourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(req.Logo)
+ logoInfo, err := l.svcCtx.AllModels.FsUserMaterial.FindOneByLogoResourceId(l.ctx, logoResourceId)
if err != nil {
logx.Error(err)
- return
+ return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get logo info")
}
- if logoInfo.Metadata == nil || *logoInfo.Metadata == "" {
+ //查询logo素材信息
+ if logoInfo.Metadata == nil || len(*logoInfo.Metadata) == 0 {
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "logo info`s metadata is not set")
}
//解析用户素材元数据
@@ -89,18 +89,16 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
}
//从用户元数据获取选中的颜色数据
mapSelectColor := make(map[string]int) //key是模板标签val是选中的索引
- if logoInfo.UserInfoMetadata != nil && *logoInfo.UserInfoMetadata != "" {
- //解析用户信息元数据
- var logoSelectInfo LogoSelect
- if err = json.Unmarshal([]byte(*logoInfo.UserInfoMetadata), &logoSelectInfo); err != nil {
- logx.Error(err)
- return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user info metadata")
- }
- //设置选中
- key := logoSelectInfo.LogoSelected.TemplateTagSelected.TemplateTag
- if _, ok := mapMaterialTemplateTagColors[key]; ok {
- mapSelectColor[key] = logoSelectInfo.LogoSelected.TemplateTagSelected.SelectedIndex
- }
+ //解析用户信息元数据
+ var logoSelectInfo LogoSelect
+ if err = json.Unmarshal(*logoInfo.Metadata, &logoSelectInfo); err != nil {
+ logx.Error(err)
+ return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user info metadata")
+ }
+ //设置选中
+ key := logoSelectInfo.LogoSelected.TemplateTagSelected.TemplateTag
+ if _, ok := mapMaterialTemplateTagColors[key]; ok {
+ mapSelectColor[key] = logoSelectInfo.LogoSelected.TemplateTagSelected.SelectedIndex
}
var templateTagNameList []string
for templateTag, _ := range mapMaterialTemplateTagColors {
diff --git a/server/product-template-tag/internal/types/types.go b/server/product-template-tag/internal/types/types.go
index 0a83336c..21280e74 100644
--- a/server/product-template-tag/internal/types/types.go
+++ b/server/product-template-tag/internal/types/types.go
@@ -6,7 +6,8 @@ import (
)
type GetProductTemplateTagsReq struct {
- Limit int `form:"limit"`
+ Limit int `form:"limit"`
+ Logo string `form:"logo"`
}
type GetProductTemplateTagsRsp struct {
diff --git a/server_api/product-template-tag.api b/server_api/product-template-tag.api
index c424cd91..d550070b 100644
--- a/server_api/product-template-tag.api
+++ b/server_api/product-template-tag.api
@@ -20,7 +20,8 @@ service product-template-tag {
//获取产品模板标签列表
type GetProductTemplateTagsReq {
- Limit int `form:"limit"`
+ Limit int `form:"limit"`
+ Logo string `form:"logo"`
}
type GetProductTemplateTagsRsp {
Id int64 `json:"id"`
From 4a620d46d5f922cf168c66d37a7b5cc1b8c3dc31 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 10:04:30 +0800
Subject: [PATCH 03/20] fix
---
utils/curl/http_curl.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/utils/curl/http_curl.go b/utils/curl/http_curl.go
index e704569d..aa87c095 100644
--- a/utils/curl/http_curl.go
+++ b/utils/curl/http_curl.go
@@ -67,6 +67,10 @@ func ApiCall2(url, method string, header map[string]string, body io.Reader, time
for {
line, _, err := reader.ReadLine()
if err == io.EOF {
+ _, err = buff.Write(line)
+ if err != nil {
+ return nil, err
+ }
break
}
if err != nil {
From 2e421a29688e6c76dd34e1090196de0cb01378c9 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 10:57:33 +0800
Subject: [PATCH 04/20] fix
---
utils/curl/http_curl.go | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/utils/curl/http_curl.go b/utils/curl/http_curl.go
index aa87c095..eb7dd652 100644
--- a/utils/curl/http_curl.go
+++ b/utils/curl/http_curl.go
@@ -65,15 +65,15 @@ func ApiCall2(url, method string, header map[string]string, body io.Reader, time
buff := bytes.Buffer{}
reader := bufio.NewReader(rsp.Body)
for {
- line, _, err := reader.ReadLine()
- if err == io.EOF {
- _, err = buff.Write(line)
- if err != nil {
- return nil, err
- }
- break
- }
+ line, err := reader.ReadBytes('\n')
if err != nil {
+ if err == io.EOF {
+ _, err = buff.Write(line)
+ if err != nil {
+ return nil, err
+ }
+ break
+ }
return nil, err
}
_, err = buff.Write(line)
From ce413c494cb7aebdcf1309953dde59e0b78703f7 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 11:16:39 +0800
Subject: [PATCH 05/20] fix
---
model/gmodel/fs_user_info_logic.go | 4 ++++
.../internal/logic/getproducttemplatetagslogic.go | 15 +++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/model/gmodel/fs_user_info_logic.go b/model/gmodel/fs_user_info_logic.go
index d21f79cf..52af5439 100644
--- a/model/gmodel/fs_user_info_logic.go
+++ b/model/gmodel/fs_user_info_logic.go
@@ -79,3 +79,7 @@ func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId in
}
return info, nil
}
+func (m *FsUserInfoModel) FindOneByUser(ctx context.Context, userId, guestId int64) (resp *FsUserInfo, err error) {
+ err = m.db.WithContext(ctx).Model(&FsUserInfo{}).Where("user_id = ? and guest_id = ?", userId, guestId).Take(&resp).Error
+ return resp, err
+}
diff --git a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go
index 7191f110..47803452 100644
--- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go
+++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go
@@ -3,12 +3,14 @@ package logic
import (
"context"
"encoding/json"
+ "errors"
"fusenapi/model/gmodel"
"fusenapi/server/product-template-tag/internal/svc"
"fusenapi/server/product-template-tag/internal/types"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/s3url_to_s3id"
+ "gorm.io/gorm"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -67,9 +69,18 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
if logoInfo.Metadata == nil || len(*logoInfo.Metadata) == 0 {
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "logo info`s metadata is not set")
}
+ //获取userInfo信息
+ userProfile, err := l.svcCtx.AllModels.FsUserInfo.FindOneByUser(l.ctx, userinfo.UserId, userinfo.GuestId)
+ if err != nil {
+ if errors.Is(err, gorm.ErrRecordNotFound) {
+ return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "user profile info is not found")
+ }
+ logx.Error(err)
+ return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get user profile info")
+ }
//解析用户素材元数据
var metaData map[string]interface{}
- if err = json.Unmarshal([]byte(*logoInfo.Metadata), &metaData); err != nil {
+ if err = json.Unmarshal(*logoInfo.Metadata, &metaData); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata")
}
@@ -91,7 +102,7 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu
mapSelectColor := make(map[string]int) //key是模板标签val是选中的索引
//解析用户信息元数据
var logoSelectInfo LogoSelect
- if err = json.Unmarshal(*logoInfo.Metadata, &logoSelectInfo); err != nil {
+ if err = json.Unmarshal(*userProfile.Metadata, &logoSelectInfo); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user info metadata")
}
From b95c2f90d5e06580a8fdee48c062591185d7bc5e Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 12:04:27 +0800
Subject: [PATCH 06/20] fix
---
model/gmodel/fs_user_info_logic.go | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/model/gmodel/fs_user_info_logic.go b/model/gmodel/fs_user_info_logic.go
index 52af5439..0521b912 100644
--- a/model/gmodel/fs_user_info_logic.go
+++ b/model/gmodel/fs_user_info_logic.go
@@ -80,6 +80,10 @@ func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId in
return info, nil
}
func (m *FsUserInfoModel) FindOneByUser(ctx context.Context, userId, guestId int64) (resp *FsUserInfo, err error) {
- err = m.db.WithContext(ctx).Model(&FsUserInfo{}).Where("user_id = ? and guest_id = ?", userId, guestId).Take(&resp).Error
+ if userId > 0 {
+ err = m.db.WithContext(ctx).Model(&FsUserInfo{}).Where("user_id = ?", userId).Take(&resp).Error
+ } else {
+ err = m.db.WithContext(ctx).Model(&FsUserInfo{}).Where("user_id = ? and guest_id = ?", userId, guestId).Take(&resp).Error
+ }
return resp, err
}
From 57f3270af28a8ef1e025c99a8c02dfe43a310259 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 12:27:39 +0800
Subject: [PATCH 07/20] fix
---
service/repositories/image_handle.go | 103 ---------------------------
1 file changed, 103 deletions(-)
diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go
index ebcde563..0773d96d 100644
--- a/service/repositories/image_handle.go
+++ b/service/repositories/image_handle.go
@@ -38,9 +38,6 @@ type (
}
ImageHandle = interface {
- // 获取logo最新信息
- LogoInfo(ctx context.Context, in *LogoInfoReq) (*LogoInfoRes, error)
-
// logo信息
LogoInfoSet(ctx context.Context, in *LogoInfoSetReq) (*LogoInfoSetRes, error)
@@ -65,106 +62,6 @@ type (
}
)
-func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*LogoInfoRes, error) {
- var metadata *string
- var logoUrl *string
- var userInfoMetadata *string
- // 更新用户信息
- var module = "profile"
- userInfoGorm := l.MysqlConn.Where("module = ?", module)
- userInfo := gmodel.FsUserInfo{}
- userInfoGorm.Where("user_id = ? and guest_id = ?", in.UserId, in.GuestId)
- userInfo.UserId = &in.UserId
- userInfo.GuestId = &in.GuestId
- /*if in.UserId == 0 && in.GuestId == 0 {
- userInfoGorm.Where("user_id = ? and guest_id = ?", in.UserId, in.GuestId)
- } else {
- if in.UserId > 0 {
- userInfoGorm.Where("user_id = ?", in.UserId)
- userInfo.UserId = &in.UserId
- } else {
- userInfoGorm.Where("guest_id = ?", in.GuestId)
- userInfo.GuestId = &in.GuestId
- }
- }*/
- resFirst := userInfoGorm.First(&userInfo)
- err := resFirst.Error
- if err != nil {
- if err != gorm.ErrRecordNotFound {
- logc.Errorf(ctx, "FsUserInfo First err:%+v", err)
- return nil, err
- }
- }
- if userInfo.Id != 0 {
- tmp := string(*userInfo.Metadata)
- userInfoMetadata = &tmp
- }
- var userMaterialInfo gmodel.FsUserMaterial
- userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn)
- var metadataUserInfo struct {
- LogoSelected struct {
- TemplateTagSelected *struct {
- Color [][]string `json:"color"`
- TemplateTag string `json:"template_tag"`
- SelectedIndex int64 `json:"selected_index"`
- } `json:"template_tag_selected"`
- LogoSelectedId int64 `json:"logo_selected_id"`
- } `json:"logo_selected"`
- }
- userInfo.Id = 0
- if userInfo.Id == 0 {
- userMaterialInfo, err = userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId)
- if err != nil && err != gorm.ErrRecordNotFound {
- logc.Errorf(ctx, "FsUserMaterial FindLatestOne err:%+v", err)
- return nil, err
- }
- } else {
- if userInfo.Metadata != nil {
- err = json.Unmarshal([]byte(*userInfo.Metadata), &metadataUserInfo)
- if err != nil {
- logc.Errorf(ctx, "userInfo.Metadata Unmarshal err:%+v", err)
- return nil, err
- }
-
- if metadataUserInfo.LogoSelected.LogoSelectedId != 0 {
- userMaterialInfos, err := userMaterialModel.FindOneById(ctx, metadataUserInfo.LogoSelected.LogoSelectedId)
- if err != nil {
- if err != gorm.ErrRecordNotFound {
- logc.Errorf(ctx, "userMaterial findOneById err:%+v", err)
- return nil, err
- }
- }
- if userMaterialInfos.Id != 0 {
- userMaterialInfo = *userMaterialInfos
- }
- }
- }
- }
-
- if userMaterialInfo.Id == 0 {
- userMaterialInfoDefault, err := userMaterialModel.FindOneById(ctx, 0)
- if err != nil {
- if err != gorm.ErrRecordNotFound {
- logc.Errorf(ctx, "userMaterialModel FindOneById defaul err:%+v", err)
- return nil, err
- }
- }
- metadataB := string(*userMaterialInfoDefault.Metadata)
- metadata = &metadataB
- logoUrl = userMaterialInfoDefault.ResourceUrl
-
- } else {
- metadataB := string(*userMaterialInfo.Metadata)
- metadata = &metadataB
- logoUrl = userMaterialInfo.ResourceUrl
- }
- return &LogoInfoRes{
- Metadata: metadata,
- LogoUrl: logoUrl,
- UserInfoMetadata: userInfoMetadata,
- }, nil
-}
-
/* 获取logo最新信息 */
/* logo信息 */
From 669be27e0af7ca923579280b5ac835d99cc31eeb Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 15:05:03 +0800
Subject: [PATCH 08/20] fix
---
.../internal/logic/datatransferlogic.go | 26 ++------
.../internal/logic/ws_err_response.go | 60 ++++++++++---------
.../internal/logic/ws_render_image.go | 52 +++++++++-------
3 files changed, 65 insertions(+), 73 deletions(-)
diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go
index ff929843..ce77f9b8 100644
--- a/server/websocket/internal/logic/datatransferlogic.go
+++ b/server/websocket/internal/logic/datatransferlogic.go
@@ -72,13 +72,6 @@ var (
websocketInChanLen = 2000
//每个websocket连接出口缓冲队列长度默认值
websocketOutChanLen = 2000
- //是否开启debug
- openDebug = true
- //允许跨域的origin
- mapAllowOrigin = map[string]struct{}{
- "https://www.fusen.3718.cn": struct{}{},
- "http://www.fusen.3718.cn": struct{}{},
- }
)
// 用户标识的连接增删操作队列传输的值的结构
@@ -102,6 +95,7 @@ type wsConnectItem struct {
inChan chan []byte //接受消息缓冲队列(基本属性)
outChan chan []byte //要发送回客户端的消息缓冲队列(基本属性)
mutex sync.Mutex //互斥锁(基本属性)
+ openDebug bool //是否开启debug
userId int64 //用户id(基本属性)
guestId int64 //游客id(基本属性)
extendRenderProperty extendRenderProperty //扩展云渲染属性(扩展属性)
@@ -109,20 +103,10 @@ type wsConnectItem struct {
// 请求建立连接,升级websocket协议
func (l *DataTransferLogic) DataTransfer(req *types.DataTransferReq, w http.ResponseWriter, r *http.Request) {
- origin := r.Header.Get("Origin")
- //判断是不是允许的跨域
- if !openDebug {
- upgrader.CheckOrigin = func(r *http.Request) bool {
- if _, ok := mapAllowOrigin[origin]; !ok {
- return false
- }
- return true
- }
- }
//把子协议携带的token设置到标准token头信息中
token := r.Header.Get("Sec-Websocket-Protocol")
oldWid := req.Wid
- oldWid = strings.ReplaceAll(oldWid, " ", "+")
+ oldWid = strings.Trim(oldWid, " ")
//有token是正常用户,无则是白板用户,也可以连接
if token != "" {
r.Header.Set("Authorization", "Bearer "+token)
@@ -238,6 +222,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
renderCtx: renderCtx,
renderCtxCancelFunc: renderCtxCancelFunc,
},
+ openDebug: true, //默认都开debug
}
//保存连接
mapConnPool.Store(uniqueId, ws)
@@ -254,10 +239,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
// 获取websocket发送到前端使用的数据传输类型(debug开启是文本,否则是二进制)
func getWebsocketBaseTransferDataFormat() int {
- if openDebug {
- return websocket.TextMessage
- }
- return websocket.BinaryMessage
+ return websocket.TextMessage
}
// 获取唯一id
diff --git a/server/websocket/internal/logic/ws_err_response.go b/server/websocket/internal/logic/ws_err_response.go
index 01f5a9b2..52a9f993 100644
--- a/server/websocket/internal/logic/ws_err_response.go
+++ b/server/websocket/internal/logic/ws_err_response.go
@@ -4,37 +4,41 @@ import "fusenapi/constants"
// 入口数据格式错误
func (w *wsConnectItem) incomeDataFormatErrResponse(data interface{}) {
- w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, data))
+ if w.openDebug {
+ w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, data))
+ }
}
// 渲染错误通知
func (w *wsConnectItem) renderErrResponse(renderId, requestId, templateTag, taskId, description string, productId, userId, guestId, templateId, modelId, sizeId, elementModelId int64) {
- data := make(map[string]interface{})
- data["render_id"] = renderId
- data["request_id"] = requestId
- data["description"] = description
- data["template_tag"] = templateTag
- data["product_id"] = productId
- if taskId != "" {
- data["task_id"] = taskId
+ if w.openDebug {
+ data := make(map[string]interface{})
+ data["render_id"] = renderId
+ data["request_id"] = requestId
+ data["description"] = description
+ data["template_tag"] = templateTag
+ data["product_id"] = productId
+ if taskId != "" {
+ data["task_id"] = taskId
+ }
+ /*if userId >= 0 {
+ data["user_id"] = userId
+ }
+ if guestId >= 0 {
+ data["guest_id"] = guestId
+ }*/
+ if templateId > 0 {
+ data["template_id"] = templateId
+ }
+ if modelId > 0 {
+ data["model_id"] = modelId
+ }
+ if sizeId > 0 {
+ data["size_id"] = sizeId
+ }
+ if elementModelId > 0 {
+ data["element_model_id"] = elementModelId
+ }
+ w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, data))
}
- /*if userId >= 0 {
- data["user_id"] = userId
- }
- if guestId >= 0 {
- data["guest_id"] = guestId
- }*/
- if templateId > 0 {
- data["template_id"] = templateId
- }
- if modelId > 0 {
- data["model_id"] = modelId
- }
- if sizeId > 0 {
- data["size_id"] = sizeId
- }
- if elementModelId > 0 {
- data["element_model_id"] = elementModelId
- }
- w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, data))
}
diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go
index 97baee20..14fad832 100644
--- a/server/websocket/internal/logic/ws_render_image.go
+++ b/server/websocket/internal/logic/ws_render_image.go
@@ -439,36 +439,42 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
// 发送合图完毕阶段通知消息
func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId, combineImage string, sizeId, modelId, templateId, combineTime, uploadTime int64) {
- combineTakesTime := "cache"
- uploadCombineImageTakesTime := "cache"
- if combineTime > 0 {
- combineTakesTime = fmt.Sprintf("%dms", combineTime)
+ if w.openDebug {
+ combineTakesTime := "cache"
+ uploadCombineImageTakesTime := "cache"
+ if combineTime > 0 {
+ combineTakesTime = fmt.Sprintf("%dms", combineTime)
+ }
+ if uploadTime > 0 {
+ uploadCombineImageTakesTime = fmt.Sprintf("%dms", uploadTime)
+ }
+ w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
+ RenderId: renderId,
+ RequestId: requestId,
+ CombineImage: combineImage,
+ SizeId: sizeId,
+ ModelId: modelId,
+ TemplateId: templateId,
+ CombineProcessTime: websocket_data.CombineProcessTime{
+ CombineTakesTime: combineTakesTime,
+ UploadCombineImageTakesTime: uploadCombineImageTakesTime,
+ },
+ }))
}
- if uploadTime > 0 {
- uploadCombineImageTakesTime = fmt.Sprintf("%dms", uploadTime)
- }
- w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
- RenderId: renderId,
- RequestId: requestId,
- CombineImage: combineImage,
- SizeId: sizeId,
- ModelId: modelId,
- TemplateId: templateId,
- CombineProcessTime: websocket_data.CombineProcessTime{
- CombineTakesTime: combineTakesTime,
- UploadCombineImageTakesTime: uploadCombineImageTakesTime,
- },
- }))
}
-// 发送组装unity渲染数据完毕阶段通知消息
+// 发送组装unity需要的数据完毕消息
func (w *wsConnectItem) sendAssembleRenderDataStepResponseMessage(renderId string, requestId string) {
- w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RenderId: renderId, RequestId: requestId}))
+ if w.openDebug {
+ w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RenderId: renderId, RequestId: requestId}))
+ }
}
-// 发送组装unity渲染数据完毕阶段通知消息
+// 发送组装数据到unity完毕阶段通知消息
func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(renderId string, requestId string) {
- w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RenderId: renderId, RequestId: requestId}))
+ if w.openDebug {
+ w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RenderId: renderId, RequestId: requestId}))
+ }
}
// 发送渲染最终结果数据到前端
From 7f88233f28ea3dbdf6798c4ffc0225ed218c9bb5 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 15:18:43 +0800
Subject: [PATCH 09/20] fix
---
server/websocket/internal/logic/ws_err_response.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/server/websocket/internal/logic/ws_err_response.go b/server/websocket/internal/logic/ws_err_response.go
index 52a9f993..5f81ea5d 100644
--- a/server/websocket/internal/logic/ws_err_response.go
+++ b/server/websocket/internal/logic/ws_err_response.go
@@ -21,12 +21,12 @@ func (w *wsConnectItem) renderErrResponse(renderId, requestId, templateTag, task
if taskId != "" {
data["task_id"] = taskId
}
- /*if userId >= 0 {
+ if userId >= 0 {
data["user_id"] = userId
}
if guestId >= 0 {
data["guest_id"] = guestId
- }*/
+ }
if templateId > 0 {
data["template_id"] = templateId
}
From 8af873ac421c27d1163bf4ceb372a2ec61a48ed1 Mon Sep 17 00:00:00 2001
From: eson <9673575+githubcontent@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 15:19:25 +0800
Subject: [PATCH 10/20] fix
---
model/gmodel/fs_guest_logic.go | 11 ++++++++++-
model/gmodel/var.go | 5 +++++
.../auth/internal/logic/useremailconfirmationlogic.go | 1 -
server_api/auth.api | 7 +++++++
4 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/model/gmodel/fs_guest_logic.go b/model/gmodel/fs_guest_logic.go
index 7216deb5..1b88e95d 100755
--- a/model/gmodel/fs_guest_logic.go
+++ b/model/gmodel/fs_guest_logic.go
@@ -32,7 +32,16 @@ func (m *FsGuestModel) GenerateGuestID(ctx context.Context, AccessSecret uint64)
logx.Error(err)
return err
}
- return nil
+
+ uinfo := &FsUserInfo{
+ Module: FsString("module"),
+ UserId: FsInt64(0),
+ GuestId: &record.GuestId,
+ Metadata: FsBytes("{}"),
+ Ctime: &now,
+ Utime: &now,
+ }
+ return tx.Model(FsUserInfo{}).Create(uinfo).Error
})
if err != nil {
diff --git a/model/gmodel/var.go b/model/gmodel/var.go
index 71fd02ff..9f707822 100644
--- a/model/gmodel/var.go
+++ b/model/gmodel/var.go
@@ -36,6 +36,11 @@ func FsBool(v bool) *bool {
return &v
}
+func FsBytes(v string) *[]byte {
+ bs := []byte(v)
+ return &bs
+}
+
// SubscriptionStatus 订阅状态
type SubscriptionStatus struct {
NotificationEmail struct {
diff --git a/server/auth/internal/logic/useremailconfirmationlogic.go b/server/auth/internal/logic/useremailconfirmationlogic.go
index 94330ab3..38de3d7c 100644
--- a/server/auth/internal/logic/useremailconfirmationlogic.go
+++ b/server/auth/internal/logic/useremailconfirmationlogic.go
@@ -48,7 +48,6 @@ func FinishRegister(svcCtx *svc.ServiceContext, user *gmodel.FsUser, token *auth
)
if err != nil {
-
return err
}
diff --git a/server_api/auth.api b/server_api/auth.api
index 514d1b61..b3a34545 100644
--- a/server_api/auth.api
+++ b/server_api/auth.api
@@ -10,21 +10,27 @@ info (
import "basic.api"
service auth {
+ // 登录接口
@handler UserLoginHandler
post /api/auth/login(RequestUserLogin) returns (response);
+ // 注册
@handler UserRegisterHandler
post /api/auth/register(RequestUserRegister) returns (response);
+ // 获取cookie, 成为游客
@handler AcceptCookieHandler
post /api/auth/accept-cookie(request) returns (response);
+ // 谷歌第三方登录
@handler UserGoogleLoginHandler
get /api/auth/oauth2/login/google(RequestGoogleLogin) returns (response);
+ // 邮箱校验
@handler UserEmailConfirmationHandler
get /api/auth/email/confirmation(RequestEmailConfirmation) returns (response);
+ // 第三方登录,确认使用邮箱
@handler UserEmailRegisterHandler
post /api/auth/oauth2/register(RequestEmailRegister) returns (response);
@@ -40,6 +46,7 @@ service auth {
@handler UserResetPasswordHtmlHandler
get /api/auth/reset/password/html(RequestUserResetHtml) returns (response);
+ // 用于debug 删除帐号
@handler DebugAuthDeleteHandler
post /api/auth/debug/delete(RequestAuthDelete) returns (response);
}
From a1e6be40db98c886a3992f90e203b209f28c97c9 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 15:26:45 +0800
Subject: [PATCH 11/20] fix
---
.../internal/logic/ws_render_image.go | 55 ++++++++++---------
.../internal/logic/ws_user_connect_pool.go | 30 +++++-----
2 files changed, 43 insertions(+), 42 deletions(-)
diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go
index 14fad832..e4659274 100644
--- a/server/websocket/internal/logic/ws_render_image.go
+++ b/server/websocket/internal/logic/ws_render_image.go
@@ -437,6 +437,34 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
return nil
}
+// 组装渲染任务id
+func (w *wsConnectItem) genRenderTaskId(combineImage string, renderImageData websocket_data.RenderImageReqMsg, model3dInfo *gmodel.FsProductModel3d, productTemplate *gmodel.FsProductTemplateV2, element *gmodel.FsProductTemplateElement) string {
+ //生成任务id(需要把user_id,guest_id设为0)
+ incomeHashParam := renderImageData.RenderData
+ incomeHashParam.UserId = 0 //设为0(渲染跟用户id无关)
+ incomeHashParam.GuestId = 0 //设为0(渲染跟用户id无关)
+ incomeHashBytes, _ := json.Marshal(incomeHashParam)
+ modelHashStr := ""
+ templateHashStr := ""
+ if model3dInfo.ModelInfo != nil {
+ modelHashStr = *model3dInfo.ModelInfo
+ }
+ if productTemplate.TemplateInfo != nil {
+ templateHashStr = *productTemplate.TemplateInfo
+ }
+ elementHashBytes, _ := json.Marshal(element)
+ hashMap := map[string]interface{}{
+ "income_param": incomeHashBytes,
+ "model_info": modelHashStr,
+ "template_info": templateHashStr,
+ "material_image": *productTemplate.MaterialImg,
+ "render_element": elementHashBytes,
+ "combine_image": combineImage,
+ }
+ return hash.JsonHashKey(hashMap)
+}
+
+// ****************************下面的发送消息的*********************************
// 发送合图完毕阶段通知消息
func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId, combineImage string, sizeId, modelId, templateId, combineTime, uploadTime int64) {
if w.openDebug {
@@ -481,30 +509,3 @@ func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(renderId string
func (w *wsConnectItem) sendRenderResultData(data websocket_data.RenderImageRspMsg) {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, data))
}
-
-// 组装渲染任务id
-func (w *wsConnectItem) genRenderTaskId(combineImage string, renderImageData websocket_data.RenderImageReqMsg, model3dInfo *gmodel.FsProductModel3d, productTemplate *gmodel.FsProductTemplateV2, element *gmodel.FsProductTemplateElement) string {
- //生成任务id(需要把user_id,guest_id设为0)
- incomeHashParam := renderImageData.RenderData
- incomeHashParam.UserId = 0 //设为0(渲染跟用户id无关)
- incomeHashParam.GuestId = 0 //设为0(渲染跟用户id无关)
- incomeHashBytes, _ := json.Marshal(incomeHashParam)
- modelHashStr := ""
- templateHashStr := ""
- if model3dInfo.ModelInfo != nil {
- modelHashStr = *model3dInfo.ModelInfo
- }
- if productTemplate.TemplateInfo != nil {
- templateHashStr = *productTemplate.TemplateInfo
- }
- elementHashBytes, _ := json.Marshal(element)
- hashMap := map[string]interface{}{
- "income_param": incomeHashBytes,
- "model_info": modelHashStr,
- "template_info": templateHashStr,
- "material_image": *productTemplate.MaterialImg,
- "render_element": elementHashBytes,
- "combine_image": combineImage,
- }
- return hash.JsonHashKey(hashMap)
-}
diff --git a/server/websocket/internal/logic/ws_user_connect_pool.go b/server/websocket/internal/logic/ws_user_connect_pool.go
index a83fd8ed..ebdcedf3 100644
--- a/server/websocket/internal/logic/ws_user_connect_pool.go
+++ b/server/websocket/internal/logic/ws_user_connect_pool.go
@@ -46,21 +46,6 @@ func deleteUserConnPoolElement(userId, guestId int64, uniqueId string) {
userConnPoolCtlChan <- data
}
-// 根据用户索引发现链接并发送(广播)消息到出口队列
-func sendToOutChanByUserIndex(userId, guestId int64, message []byte) {
- data := userConnPoolCtlChanItem{
- userId: userId,
- guestId: guestId,
- uniqueId: "",
- message: message,
- option: 2,
- }
- select {
- case userConnPoolCtlChan <- data:
- return
- }
-}
-
// 消费用户索引创建/删除/发送消息中的任务数据
func ConsumeUserConnPoolCtlChanData(ctx context.Context) {
defer func() {
@@ -130,3 +115,18 @@ func getmapUserConnPoolUniqueId(userId, guestId int64) (uniqueId string) {
}
return fmt.Sprintf("%d_%d", userId, guestId)
}
+
+// 根据用户索引发现链接并发送(广播)消息到出口队列
+func sendToOutChanByUserIndex(userId, guestId int64, message []byte) {
+ data := userConnPoolCtlChanItem{
+ userId: userId,
+ guestId: guestId,
+ uniqueId: "",
+ message: message,
+ option: 2,
+ }
+ select {
+ case userConnPoolCtlChan <- data:
+ return
+ }
+}
From 95b7f1f8598b5e3a54f82defba1fe0ddb56754f5 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 15:29:06 +0800
Subject: [PATCH 12/20] fix
---
server/websocket/internal/logic/datatransferlogic.go | 3 +++
1 file changed, 3 insertions(+)
diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go
index ce77f9b8..28cbec94 100644
--- a/server/websocket/internal/logic/datatransferlogic.go
+++ b/server/websocket/internal/logic/datatransferlogic.go
@@ -224,6 +224,9 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
},
openDebug: true, //默认都开debug
}
+ if userInfo.UserId == 127 {
+ ws.openDebug = false
+ }
//保存连接
mapConnPool.Store(uniqueId, ws)
//非白板用户,需要为这个用户建立map索引便于通过用户查询
From 58978104bff879d6b317bfc1bd0a54a52f2ecbad Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 15:31:35 +0800
Subject: [PATCH 13/20] fix
---
server/websocket/internal/logic/datatransferlogic.go | 3 ---
1 file changed, 3 deletions(-)
diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go
index 28cbec94..ce77f9b8 100644
--- a/server/websocket/internal/logic/datatransferlogic.go
+++ b/server/websocket/internal/logic/datatransferlogic.go
@@ -224,9 +224,6 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
},
openDebug: true, //默认都开debug
}
- if userInfo.UserId == 127 {
- ws.openDebug = false
- }
//保存连接
mapConnPool.Store(uniqueId, ws)
//非白板用户,需要为这个用户建立map索引便于通过用户查询
From 2aeff0963920f7cfb95e8bc7df777a98ad7c0567 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 15:56:02 +0800
Subject: [PATCH 14/20] fix
---
.../internal/logic/ws_err_response.go | 64 ++++++++++---------
.../internal/logic/ws_render_image.go | 53 +++++++--------
2 files changed, 61 insertions(+), 56 deletions(-)
diff --git a/server/websocket/internal/logic/ws_err_response.go b/server/websocket/internal/logic/ws_err_response.go
index 5f81ea5d..afbb2b11 100644
--- a/server/websocket/internal/logic/ws_err_response.go
+++ b/server/websocket/internal/logic/ws_err_response.go
@@ -4,41 +4,43 @@ import "fusenapi/constants"
// 入口数据格式错误
func (w *wsConnectItem) incomeDataFormatErrResponse(data interface{}) {
- if w.openDebug {
- w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, data))
+ if !w.openDebug {
+ return
}
+ w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, data))
}
// 渲染错误通知
func (w *wsConnectItem) renderErrResponse(renderId, requestId, templateTag, taskId, description string, productId, userId, guestId, templateId, modelId, sizeId, elementModelId int64) {
- if w.openDebug {
- data := make(map[string]interface{})
- data["render_id"] = renderId
- data["request_id"] = requestId
- data["description"] = description
- data["template_tag"] = templateTag
- data["product_id"] = productId
- if taskId != "" {
- data["task_id"] = taskId
- }
- if userId >= 0 {
- data["user_id"] = userId
- }
- if guestId >= 0 {
- data["guest_id"] = guestId
- }
- if templateId > 0 {
- data["template_id"] = templateId
- }
- if modelId > 0 {
- data["model_id"] = modelId
- }
- if sizeId > 0 {
- data["size_id"] = sizeId
- }
- if elementModelId > 0 {
- data["element_model_id"] = elementModelId
- }
- w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, data))
+ if !w.openDebug {
+ return
}
+ data := make(map[string]interface{})
+ data["render_id"] = renderId
+ data["request_id"] = requestId
+ data["description"] = description
+ data["template_tag"] = templateTag
+ data["product_id"] = productId
+ if taskId != "" {
+ data["task_id"] = taskId
+ }
+ if userId >= 0 {
+ data["user_id"] = userId
+ }
+ if guestId >= 0 {
+ data["guest_id"] = guestId
+ }
+ if templateId > 0 {
+ data["template_id"] = templateId
+ }
+ if modelId > 0 {
+ data["model_id"] = modelId
+ }
+ if sizeId > 0 {
+ data["size_id"] = sizeId
+ }
+ if elementModelId > 0 {
+ data["element_model_id"] = elementModelId
+ }
+ w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, data))
}
diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go
index e4659274..b21fbea0 100644
--- a/server/websocket/internal/logic/ws_render_image.go
+++ b/server/websocket/internal/logic/ws_render_image.go
@@ -467,42 +467,45 @@ func (w *wsConnectItem) genRenderTaskId(combineImage string, renderImageData web
// ****************************下面的发送消息的*********************************
// 发送合图完毕阶段通知消息
func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId, combineImage string, sizeId, modelId, templateId, combineTime, uploadTime int64) {
- if w.openDebug {
- combineTakesTime := "cache"
- uploadCombineImageTakesTime := "cache"
- if combineTime > 0 {
- combineTakesTime = fmt.Sprintf("%dms", combineTime)
- }
- if uploadTime > 0 {
- uploadCombineImageTakesTime = fmt.Sprintf("%dms", uploadTime)
- }
- w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
- RenderId: renderId,
- RequestId: requestId,
- CombineImage: combineImage,
- SizeId: sizeId,
- ModelId: modelId,
- TemplateId: templateId,
- CombineProcessTime: websocket_data.CombineProcessTime{
- CombineTakesTime: combineTakesTime,
- UploadCombineImageTakesTime: uploadCombineImageTakesTime,
- },
- }))
+ if !w.openDebug {
+ return
}
+ combineTakesTime := "cache"
+ uploadCombineImageTakesTime := "cache"
+ if combineTime > 0 {
+ combineTakesTime = fmt.Sprintf("%dms", combineTime)
+ }
+ if uploadTime > 0 {
+ uploadCombineImageTakesTime = fmt.Sprintf("%dms", uploadTime)
+ }
+ w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
+ RenderId: renderId,
+ RequestId: requestId,
+ CombineImage: combineImage,
+ SizeId: sizeId,
+ ModelId: modelId,
+ TemplateId: templateId,
+ CombineProcessTime: websocket_data.CombineProcessTime{
+ CombineTakesTime: combineTakesTime,
+ UploadCombineImageTakesTime: uploadCombineImageTakesTime,
+ },
+ }))
}
// 发送组装unity需要的数据完毕消息
func (w *wsConnectItem) sendAssembleRenderDataStepResponseMessage(renderId string, requestId string) {
- if w.openDebug {
- w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RenderId: renderId, RequestId: requestId}))
+ if !w.openDebug {
+ return
}
+ w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RenderId: renderId, RequestId: requestId}))
}
// 发送组装数据到unity完毕阶段通知消息
func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(renderId string, requestId string) {
- if w.openDebug {
- w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RenderId: renderId, RequestId: requestId}))
+ if !w.openDebug {
+ return
}
+ w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RenderId: renderId, RequestId: requestId}))
}
// 发送渲染最终结果数据到前端
From 06303361e0a79a49e29663dd7952a84a9038dbc9 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 16:54:07 +0800
Subject: [PATCH 15/20] fix
---
server/websocket/internal/logic/ws_render_image.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go
index b21fbea0..bcc86cb1 100644
--- a/server/websocket/internal/logic/ws_render_image.go
+++ b/server/websocket/internal/logic/ws_render_image.go
@@ -352,7 +352,7 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
if element.Base != nil && *element.Base != "" {
tempData = append(tempData, map[string]interface{}{
"name": "model",
- "data": "0," + combineImage + "," + *element.Base + " " + fmt.Sprintf("%d", time.Now().UTC().UnixMilli()),
+ "data": "0," + combineImage + "," + *element.Base, /* + " " + fmt.Sprintf("%d", time.Now().UTC().UnixMilli()),*/
"type": "other",
"layer": "0",
"is_update": 1,
From a0d619692f146687d88ac6c399ee47eac9b9cf80 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 17:01:58 +0800
Subject: [PATCH 16/20] fix
---
server/websocket/internal/logic/ws_render_image.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go
index bcc86cb1..7b3d2f7d 100644
--- a/server/websocket/internal/logic/ws_render_image.go
+++ b/server/websocket/internal/logic/ws_render_image.go
@@ -352,7 +352,7 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
if element.Base != nil && *element.Base != "" {
tempData = append(tempData, map[string]interface{}{
"name": "model",
- "data": "0," + combineImage + "," + *element.Base, /* + " " + fmt.Sprintf("%d", time.Now().UTC().UnixMilli()),*/
+ "data": "0," + combineImage + "," + *element.Base,
"type": "other",
"layer": "0",
"is_update": 1,
From 7495d458e64751b9afc34406626f79710738a72b Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 17:06:17 +0800
Subject: [PATCH 17/20] fix
---
server/websocket/internal/logic/ws_render_image.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go
index 7b3d2f7d..6bc3e1d5 100644
--- a/server/websocket/internal/logic/ws_render_image.go
+++ b/server/websocket/internal/logic/ws_render_image.go
@@ -352,7 +352,7 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
if element.Base != nil && *element.Base != "" {
tempData = append(tempData, map[string]interface{}{
"name": "model",
- "data": "0," + combineImage + "," + *element.Base,
+ "data": "0," + combineImage + "," + *element.Base + ",0",
"type": "other",
"layer": "0",
"is_update": 1,
From d97fbfdebfb2be8eb5df769cb0c2567583645900 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 17:09:15 +0800
Subject: [PATCH 18/20] fix
---
server/websocket/internal/logic/ws_render_image.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go
index 6bc3e1d5..7b3d2f7d 100644
--- a/server/websocket/internal/logic/ws_render_image.go
+++ b/server/websocket/internal/logic/ws_render_image.go
@@ -352,7 +352,7 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
if element.Base != nil && *element.Base != "" {
tempData = append(tempData, map[string]interface{}{
"name": "model",
- "data": "0," + combineImage + "," + *element.Base + ",0",
+ "data": "0," + combineImage + "," + *element.Base,
"type": "other",
"layer": "0",
"is_update": 1,
From 49872fd6209fb78b42051835bc3f748fe14867f2 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 17:15:18 +0800
Subject: [PATCH 19/20] fix
---
constants/invoice_html.go | 243 --------------------------------------
1 file changed, 243 deletions(-)
diff --git a/constants/invoice_html.go b/constants/invoice_html.go
index e3d67adc..1255fc8b 100644
--- a/constants/invoice_html.go
+++ b/constants/invoice_html.go
@@ -1,244 +1 @@
package constants
-
-// 发票主体页面
-const MAIN_INVOICE_HTML = `
-
-
-
-
-
-
-
- Invoice
-
-
-
-
-
-
-
-
-
-
-
- {{product_loop_html}}
-
-
-
-
-
- Subtotal |
- ${{subtotal_price}} |
-
-
- Shipping Fee |
- Free |
-
-
- Tax |
- ${{tax}} |
-
-
- Total |
- ${{total_price}} |
-
-
- Deposit Requested |
- ${{deposit_price}} |
-
-
- Deposit Due |
- ${{deposit_price}} |
-
-
-
-
-
- Payment Method: |
- Notes: |
-
-
- {{payment_method}} |
- {{notes}} |
-
-
- Account No. {{account_number}} |
-
-
-
-
-
-
-`
-
-// 产品循环部分{{product_loop_html}}
-const PRODUCT_LOOP_HTML_CONTENT = `
- {{product_name}} |
- ${{product_item_price}} |
- {{purchase_quantity}} |
- ${{product_total_price}} |
-
`
From 35293e8404b5411f2a0031cb0d5f4543b41954fd Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Mon, 16 Oct 2023 17:16:14 +0800
Subject: [PATCH 20/20] fix
---
constants/invoice_html.go | 283 ++++++++++++++++++++++++++++++++++++++
1 file changed, 283 insertions(+)
diff --git a/constants/invoice_html.go b/constants/invoice_html.go
index 1255fc8b..d6181ef1 100644
--- a/constants/invoice_html.go
+++ b/constants/invoice_html.go
@@ -1 +1,284 @@
package constants
+
+const INVOICE_TEMPLATE = `
+
+
+
+
+
+
+
+ Invoice
+
+
+
+
+
+
+
+
+
+
+
+ Product Name |
+ Price |
+ Quantity |
+ Total |
+
+
+ Plastic bowl |
+ $01.00 |
+ 20,000 Units |
+ $99.00 |
+
+
+ Paper bag with handlexxxxxxxxxxxxxxx second line |
+ $01.00 |
+ 20,000 Units |
+ $99.00 |
+
+
+
+
+
+ Subtotal |
+ $198.00 |
+
+
+ Shipping Fee |
+ Free |
+
+
+ Tax |
+ $0.00 |
+
+
+ Total |
+ $198.00 |
+
+
+ Deposit Requested |
+ $99.00 |
+
+
+ Deposit Due |
+ $99.00 |
+
+
+
+
+
+ Payment Method: |
+ Notes: |
+
+
+ ICBC |
+ Thank you for your business ! |
+
+
+ Account No. :****4589 |
+
+
+
+
+
+
+ `