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

This commit is contained in:
laodaming 2023-10-30 16:19:51 +08:00
commit a9bec4c4fd
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 userMaterialMetadata = *logoData.Metadata
} }
// 新增素材 // 新增素材--预备logo
var module = "logo" var module = "logo-prepare"
var nowTime = time.Now().UTC() var nowTime = time.Now().UTC()
var resourceId = s3url_to_s3id.GetS3ResourceIdFormUrl(*logoData.ResourceUrl) 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) logc.Errorf(l.ctx, "FsUserMaterial FindOne err%+v", err)
return resp.SetStatus(basic.CodeLogoSetCategory, "logo not find") 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 { err = l.svcCtx.MysqlConn.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error {
var metadataMapOldUserMaterial map[string]interface{} var metadataMapOldUserMaterial map[string]interface{}
@ -108,21 +112,32 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth
} }
var logoCategoryId int64 var logoCategoryId int64
// 更新merchant_category // 更新merchant_category
if req.SetLogoCategory == 1 { if req.SetLogoCategory == 1 || materialModule != "" {
var metadataChildUserMaterial = make(map[string]interface{}, 1) var updateSelect []string
metadataChildUserMaterial["merchant_category"] = req.CategoryId updateSelect = append(updateSelect, "utime")
metadataMapUserMaterial, err := metadata.SetMetadata(metadataChildUserMaterial, metadataMapOldUserMaterial) if req.SetLogoCategory == 1 {
if err != nil { var metadataChildUserMaterial = make(map[string]interface{}, 1)
logc.Errorf(l.ctx, "userMaterialInfo Metadata SetMetadata err%+v", err) metadataChildUserMaterial["merchant_category"] = req.CategoryId
return err 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 { if materialModule != "" {
logc.Errorf(l.ctx, "userMaterialInfo Metadata err%+v", err) userMaterialInfo.Module = &materialModule
return err 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 err = resUpdates.Error
if err != nil { if err != nil {
if err != gorm.ErrRecordNotFound { if err != gorm.ErrRecordNotFound {