Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
		
						commit
						bd8a74701e
					
				| @ -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 | ||||||
|  | } | ||||||
|  | |||||||
| @ -72,7 +72,7 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu | |||||||
| 				logx.Error(err) | 				logx.Error(err) | ||||||
| 				return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tagid") | 				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 { | ||||||
|  | |||||||
| @ -4,6 +4,7 @@ import ( | |||||||
| 	"context" | 	"context" | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"errors" | 	"errors" | ||||||
|  | 	"fmt" | ||||||
| 	"fusenapi/constants" | 	"fusenapi/constants" | ||||||
| 	"fusenapi/initalize" | 	"fusenapi/initalize" | ||||||
| 	"fusenapi/server/render/internal/svc" | 	"fusenapi/server/render/internal/svc" | ||||||
| @ -48,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, parseInfo.RenderData.TemplateTag) | 	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") | ||||||
| @ -80,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 { | ||||||
|  | |||||||
| @ -303,7 +303,7 @@ 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") | ||||||
| 		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) | ||||||
|  | |||||||
| @ -27,23 +27,23 @@ 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.TemplateTag == "" { | 	if renderImageData.RenderData.TemplateTag == "" { | ||||||
| 		w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:template_tag ") | 		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") | 		logx.Error("invalid format of websocket render image message:template_tag") | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| @ -51,12 +51,22 @@ func (w *wsConnectItem) renderImage(data []byte) { | |||||||
| 	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 | ||||||
| 	} | 	} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user