diff --git a/model/gmodel/fs_tags_logic.go b/model/gmodel/fs_tags_logic.go index 35efa42c..b108a337 100755 --- a/model/gmodel/fs_tags_logic.go +++ b/model/gmodel/fs_tags_logic.go @@ -36,7 +36,8 @@ type GetAllTagByParamsReq struct { OrderBy string LevelPrefixLeftLike string //右模糊 WithChild bool //是否包含子层级 - Category int64 + Category int64 //分类 + Level int64 } func (t *FsTagsModel) GetAllTagByParams(ctx context.Context, req GetAllTagByParamsReq) (resp []FsTags, err error) { @@ -50,6 +51,9 @@ func (t *FsTagsModel) GetAllTagByParams(ctx context.Context, req GetAllTagByPara if req.Category != 0 { db = db.Where("`category` = ?", req.Category) } + if req.Level > 0 { + db = db.Where("`level` = ?", req.Level) + } if req.LevelPrefixLeftLike != "" { //查询子集 if req.WithChild { diff --git a/server/product/internal/logic/getfittingbypidlogic.go b/server/product/internal/logic/getfittingbypidlogic.go index 18f76892..53db5460 100644 --- a/server/product/internal/logic/getfittingbypidlogic.go +++ b/server/product/internal/logic/getfittingbypidlogic.go @@ -70,6 +70,9 @@ func (l *GetFittingByPidLogic) GetFittingByPid(req *types.GetFittingByPidReq, us } partIds := make([]int64, 0, len(modelList)) for _, v := range modelList { + if v.PartId == nil { + continue + } partIds = append(partIds, *v.PartId) } //获取配件数据 diff --git a/server/product/internal/logic/getrecommandproductlistlogic.go b/server/product/internal/logic/getrecommandproductlistlogic.go index 7f082fef..b4a48efc 100644 --- a/server/product/internal/logic/getrecommandproductlistlogic.go +++ b/server/product/internal/logic/getrecommandproductlistlogic.go @@ -160,8 +160,8 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec Sn: *v.Sn, Title: *v.Title, TitleCn: *v.TitleCn, - Cover: *productInfo.Cover, - CoverImg: *productInfo.CoverImg, + Cover: *v.Cover, + CoverImg: *v.CoverImg, CoverDefault: []types.CoverDefaultItem{}, Intro: *v.Intro, IsRecommend: isRecommend, diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index c8642633..b69736d0 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -51,6 +51,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR OrderBy: "`sort` DESC", WithChild: true, //需要子集 Category: 1, //前台网站用的 + Level: 2, //等级是2的 } //传入分类id if req.Cid > 0 { @@ -63,8 +64,8 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get tag info") } - //前台用的分类是1 - if *tagData.Category != 1 { + //前台用的分类是1,且等级是2 + if *tagData.Category != 1 && *tagData.Level != 2 { return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "invalid tag") } tReq.LevelPrefixLeftLike = *tagData.LevelPrefix diff --git a/server/product/internal/logic/savedesignlogic.go b/server/product/internal/logic/savedesignlogic.go index 21d2c226..55fa1322 100644 --- a/server/product/internal/logic/savedesignlogic.go +++ b/server/product/internal/logic/savedesignlogic.go @@ -10,9 +10,6 @@ import ( "fusenapi/utils/basic" "fusenapi/utils/encryption_decryption" "fusenapi/utils/id_generator" - "github.com/google/uuid" - "github.com/nfnt/resize" - "gorm.io/gorm" "image" "image/gif" "image/jpeg" @@ -22,6 +19,10 @@ import ( "path" "time" + "github.com/google/uuid" + "github.com/nfnt/resize" + "gorm.io/gorm" + "context" "fusenapi/server/product/internal/svc" @@ -77,7 +78,7 @@ func (l *SaveDesignLogic) SaveDesign(req *types.SaveDesignReq, userinfo *auth.Us } infoBytes, _ := json.Marshal(postInfo.Data) info := string(infoBytes) - now := time.Now() + now := time.Now().UTC() logoColorBytes, _ := json.Marshal(postInfo.Data.Logo.Colors) logoColor := string(logoColorBytes) saveData := gmodel.FsProductDesign{ diff --git a/server/shopping-cart-confirmation/internal/logic/cartaddlogic.go b/server/shopping-cart-confirmation/internal/logic/cartaddlogic.go index 50248582..54d345bf 100644 --- a/server/shopping-cart-confirmation/internal/logic/cartaddlogic.go +++ b/server/shopping-cart-confirmation/internal/logic/cartaddlogic.go @@ -5,10 +5,11 @@ import ( "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/basic" - "gorm.io/gorm" "strings" "time" + "gorm.io/gorm" + "context" "fusenapi/server/shopping-cart-confirmation/internal/svc" @@ -101,7 +102,7 @@ func (l *CartAddLogic) CartAdd(req *types.CartAddReq, userinfo *auth.UserInfo) ( return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get cart info") } now := time.Now().Unix() - nowTime := time.Now() + nowTime := time.Now().UTC() data := gmodel.FsCart{ UserId: &userinfo.UserId, ProductId: productPriceInfo.ProductId, diff --git a/server/shopping-cart-confirmation/internal/logic/createorderlogic.go b/server/shopping-cart-confirmation/internal/logic/createorderlogic.go index 21823c98..55c54953 100644 --- a/server/shopping-cart-confirmation/internal/logic/createorderlogic.go +++ b/server/shopping-cart-confirmation/internal/logic/createorderlogic.go @@ -1,7 +1,6 @@ package logic import ( - "errors" "fmt" "fusenapi/model/gmodel" "fusenapi/utils/auth" @@ -9,11 +8,12 @@ import ( "fusenapi/utils/format" "fusenapi/utils/id_generator" "fusenapi/utils/step_price" - "gorm.io/gorm" "math" "strings" "time" + "gorm.io/gorm" + "context" "fusenapi/server/shopping-cart-confirmation/internal/svc" @@ -109,7 +109,7 @@ func (l *CreateOrderLogic) CreateOrder(req *types.CreateOrderReq, userinfo *auth for _, cart := range cartList { priceIndex, ok := mapPrice[*cart.PriceId] if !ok { - return errors.New(fmt.Sprintf("price info is not exists,id = %d", *cart.PriceId)) + return fmt.Errorf("price info is not exists,id = %d", *cart.PriceId) } //订单详情模板数据 orderDetailTemplateSn, err := id_generator.GenSnowFlakeId() diff --git a/server/upload/internal/logic/uploadfilefrontendlogic.go b/server/upload/internal/logic/uploadfilefrontendlogic.go index 7789c86f..ed76bc82 100644 --- a/server/upload/internal/logic/uploadfilefrontendlogic.go +++ b/server/upload/internal/logic/uploadfilefrontendlogic.go @@ -60,7 +60,7 @@ func (l *UploadFileFrontendLogic) UploadFileFrontend(req *types.RequestUploadFil return resp.SetStatus(basic.CodeS3CategoryErr) } - now := time.Now() + now := time.Now().UTC() category := format.TypeCategory(req.Category) ObjectKey := aws.String(format.FormatS3KeyName( keytype, diff --git a/server/upload/internal/types/types.go b/server/upload/internal/types/types.go index 8aa84e78..5d38ea5a 100644 --- a/server/upload/internal/types/types.go +++ b/server/upload/internal/types/types.go @@ -22,6 +22,7 @@ type UploadFileBaseReq struct { GuestId int64 `form:"guest_id,optional"` // 上传文件额外信息 UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久 Source string `form:"source"` // 上传来源 + Refresh bool `form:"refresh,optional"` // 强制更新 } type UploadLogoReq struct { diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index 95472578..d9e3aab8 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -80,6 +80,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a //记录收到unity渲染结果时间 ws.modifyRenderTaskTimeConsuming(renderImageControlChanItem{ Option: 2, + TaskId: req.TaskId, TaskProperty: renderTask{ UnityRenderEndTime: time.Now().UTC().Unix(), }, diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 8c122170..8b994beb 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -182,6 +182,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re //记录刀版图合成开始时间 w.modifyRenderTaskTimeConsuming(renderImageControlChanItem{ Option: 2, + TaskId: taskId, TaskProperty: renderTask{ CombineBeginTime: time.Now().UTC().Unix(), }, @@ -212,6 +213,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re //记录刀版图合成结束时间 w.modifyRenderTaskTimeConsuming(renderImageControlChanItem{ Option: 2, + TaskId: taskId, TaskProperty: renderTask{ CombineEndTime: time.Now().UTC().Unix(), }, @@ -318,6 +320,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re //记录发送到unity时间 w.modifyRenderTaskTimeConsuming(renderImageControlChanItem{ Option: 2, + TaskId: taskId, TaskProperty: renderTask{ UnityRenderBeginTime: time.Now().UTC().Unix(), }, @@ -414,7 +417,7 @@ func (w *wsConnectItem) operationRenderTask() { if data.TaskProperty.UnityRenderEndTime != 0 { taskData.UnityRenderEndTime = data.TaskProperty.UnityRenderEndTime } - logx.Info("**********:", taskData) + //logx.Info("**********:", taskData) } } } diff --git a/server_api/upload.api b/server_api/upload.api index 7aaa9ec0..47d17443 100644 --- a/server_api/upload.api +++ b/server_api/upload.api @@ -67,6 +67,7 @@ type ( GuestId int64 `form:"guest_id,optional"` // 上传文件额外信息 UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久 Source string `form:"source"` // 上传来源 + Refresh bool `form:"refresh,optional"` // 强制更新 } ) diff --git a/utils/file/upload.go b/utils/file/upload.go index d561ae28..04fe7c69 100644 --- a/utils/file/upload.go +++ b/utils/file/upload.go @@ -22,6 +22,7 @@ type Upload struct { } type UploadBaseReq struct { + Refresh bool Source string FileHash string FileData string @@ -67,10 +68,14 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er var resourceId string = req.FileHash var uploadBaseRes = UploadBaseRes{} - err := upload.MysqlConn.Transaction(func(tx *gorm.DB) error { + err := upload.MysqlConn.Transaction(func(tx *gorm.DB) (err error) { var resourceInfo *gmodel.FsResource - err := tx.Where("resource_id =?", resourceId).Take(&resourceInfo).Error - if err == nil && resourceInfo.ResourceId != "" { + + if !req.Refresh { + err = tx.Where("resource_id =?", resourceId).Take(&resourceInfo).Error + } + + if !req.Refresh && err == nil && resourceInfo.ResourceId != "" { uploadBaseRes.Status = 1 uploadBaseRes.ResourceId = resourceId uploadBaseRes.ResourceUrl = *resourceInfo.ResourceUrl @@ -108,7 +113,7 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er uploadBaseRes.ResourceId = resourceId uploadBaseRes.ResourceUrl = url var version string = "0.0.1" - var nowTime = time.Now() + var nowTime = time.Now().UTC() err = tx.Create(&gmodel.FsResource{ ResourceId: resourceId, UserId: &req.UserId, @@ -202,7 +207,7 @@ func (upload *Upload) UploadFileByByte(req *UploadBaseReq) (*UploadBaseRes, erro uploadBaseRes.ResourceId = resourceId uploadBaseRes.ResourceUrl = url var version string = "0.0.1" - var nowTime = time.Now() + var nowTime = time.Now().UTC() err = tx.Create(&gmodel.FsResource{ ResourceId: resourceId, UserId: &req.UserId,