fix:上传logo--debug模式

This commit is contained in:
momo 2023-10-30 16:19:14 +08:00
parent 729b83f195
commit 9d8ae61a56
2 changed files with 30 additions and 15 deletions

View File

@ -88,8 +88,8 @@ func (l *UserLogoDataSetLogic) UserLogoDataSet(req *types.UserLogoDataSetReq, us
userMaterialMetadata = *logoData.Metadata
}
// 新增素材
var module = "logo"
// 新增素材--预备logo
var module = "logo-prepare"
var nowTime = time.Now().UTC()
var resourceId = s3url_to_s3id.GetS3ResourceIdFormUrl(*logoData.ResourceUrl)
// 新增素材记录

View File

@ -96,6 +96,10 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
logc.Errorf(l.ctx, "FsUserMaterial FindOne err%+v", err)
return resp.SetStatus(basic.CodeLogoSetCategory, "logo not find")
}
var materialModule string
if *userMaterialInfo.Module == "logo-prepare" {
materialModule = "logo"
}
err = l.svcCtx.MysqlConn.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error {
var metadataMapOldUserMaterial map[string]interface{}
@ -108,21 +112,32 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
}
var logoCategoryId int64
// 更新merchant_category
if req.SetLogoCategory == 1 {
var metadataChildUserMaterial = make(map[string]interface{}, 1)
metadataChildUserMaterial["merchant_category"] = req.CategoryId
metadataMapUserMaterial, err := metadata.SetMetadata(metadataChildUserMaterial, metadataMapOldUserMaterial)
if err != nil {
logc.Errorf(l.ctx, "userMaterialInfo Metadata SetMetadata err%+v", err)
return err
if req.SetLogoCategory == 1 || materialModule != "" {
var updateSelect []string
updateSelect = append(updateSelect, "utime")
if req.SetLogoCategory == 1 {
var metadataChildUserMaterial = make(map[string]interface{}, 1)
metadataChildUserMaterial["merchant_category"] = req.CategoryId
metadataMapUserMaterial, err := metadata.SetMetadata(metadataChildUserMaterial, metadataMapOldUserMaterial)
if err != nil {
logc.Errorf(l.ctx, "userMaterialInfo Metadata SetMetadata err%+v", err)
return err
}
metadataBUserMaterial, err := json.Marshal(metadataMapUserMaterial)
if err != nil {
logc.Errorf(l.ctx, "userMaterialInfo Metadata err%+v", err)
return err
}
userMaterialInfo.Metadata = &metadataBUserMaterial
updateSelect = append(updateSelect, "metadata")
}
metadataBUserMaterial, err := json.Marshal(metadataMapUserMaterial)
if err != nil {
logc.Errorf(l.ctx, "userMaterialInfo Metadata err%+v", err)
return err
if materialModule != "" {
userMaterialInfo.Module = &materialModule
updateSelect = append(updateSelect, "module")
}
userMaterialInfo.Metadata = &metadataBUserMaterial
resUpdates := tx.Model(&gmodel.FsUserMaterial{}).Select("metadata", "utime").Where("id = ?", req.LogoSelectedId).Updates(&userMaterialInfo)
resUpdates := tx.Model(&gmodel.FsUserMaterial{}).Select(updateSelect).Where("id = ?", req.LogoSelectedId).Updates(&userMaterialInfo)
err = resUpdates.Error
if err != nil {
if err != gorm.ErrRecordNotFound {