diff --git a/server/home-user-auth/internal/logic/userlogodatasetlogic.go b/server/home-user-auth/internal/logic/userlogodatasetlogic.go index f2eec55b..80680ae4 100644 --- a/server/home-user-auth/internal/logic/userlogodatasetlogic.go +++ b/server/home-user-auth/internal/logic/userlogodatasetlogic.go @@ -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) // 新增素材记录 diff --git a/server/home-user-auth/internal/logic/userlogosetlogic.go b/server/home-user-auth/internal/logic/userlogosetlogic.go index 27b6a822..c6b36255 100644 --- a/server/home-user-auth/internal/logic/userlogosetlogic.go +++ b/server/home-user-auth/internal/logic/userlogosetlogic.go @@ -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 {