fix:logo历史列表调整
This commit is contained in:
parent
b48417eee0
commit
818eee78be
@ -15,7 +15,7 @@ type RelaFsUserMaterial struct {
|
|||||||
FsUserMaterial
|
FsUserMaterial
|
||||||
// 关联字段填充
|
// 关联字段填充
|
||||||
ResourceInfo *RelaFsResource `json:"resource_info" gorm:"foreignkey:resource_id;references:resource_id"`
|
ResourceInfo *RelaFsResource `json:"resource_info" gorm:"foreignkey:resource_id;references:resource_id"`
|
||||||
MetaDataMap map[string]interface{} `json:"meta_data_map" gorm:"-"`
|
MetaDataMap map[string]interface{} `json:"metadata_map" gorm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *FsUserMaterialModel) CreateOrUpdate(ctx context.Context, req *FsUserMaterial) (resp *FsUserMaterial, err error) {
|
func (p *FsUserMaterialModel) CreateOrUpdate(ctx context.Context, req *FsUserMaterial) (resp *FsUserMaterial, err error) {
|
||||||
|
@ -95,16 +95,19 @@ func (l *UserInfoSetLogic) UserInfoSet(req *types.UserInfoSetReq, userinfo *auth
|
|||||||
|
|
||||||
var nowTime = time.Now().UTC()
|
var nowTime = time.Now().UTC()
|
||||||
if userInfo.Id != 0 {
|
if userInfo.Id != 0 {
|
||||||
var reqMetadata map[string]int64
|
var reqMetadata map[string]interface{}
|
||||||
json.Unmarshal([]byte(req.Metadata), &reqMetadata)
|
json.Unmarshal([]byte(req.Metadata), &reqMetadata)
|
||||||
|
var metadataMapOld map[string]interface{}
|
||||||
|
json.Unmarshal(*userInfo.Metadata, &metadataMapOld)
|
||||||
var metadataMap map[string]interface{}
|
var metadataMap map[string]interface{}
|
||||||
json.Unmarshal(*userInfo.Metadata, &metadataMap)
|
|
||||||
logoSelectedId, isEx := metadataMap["logo_selected_id"]
|
err = l.svcCtx.MysqlConn.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error {
|
||||||
if isEx {
|
|
||||||
var materialId int64 = int64(logoSelectedId.(float64))
|
|
||||||
// 更新merchant_category
|
// 更新merchant_category
|
||||||
if req.Module == "merchant_category" {
|
if req.Module == "merchant_category" {
|
||||||
err = l.svcCtx.MysqlConn.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error {
|
logoSelectedId, isEx := metadataMapOld["logo_selected_id"]
|
||||||
|
if isEx {
|
||||||
|
var materialId int64 = int64(logoSelectedId.(float64))
|
||||||
|
|
||||||
var userMaterialInfo gmodel.FsUserMaterial
|
var userMaterialInfo gmodel.FsUserMaterial
|
||||||
userMaterialGorm := tx.Where("id = ?", materialId)
|
userMaterialGorm := tx.Where("id = ?", materialId)
|
||||||
resUserMaterialInfo := userMaterialGorm.First(&userMaterialInfo)
|
resUserMaterialInfo := userMaterialGorm.First(&userMaterialInfo)
|
||||||
@ -113,7 +116,6 @@ func (l *UserInfoSetLogic) UserInfoSet(req *types.UserInfoSetReq, userinfo *auth
|
|||||||
logc.Errorf(l.ctx, "FsUserMaterial First err:%+v", err)
|
logc.Errorf(l.ctx, "FsUserMaterial First err:%+v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var metadataMap map[string]interface{}
|
|
||||||
var metadataMapOld map[string]interface{}
|
var metadataMapOld map[string]interface{}
|
||||||
if userMaterialInfo.Id > 0 {
|
if userMaterialInfo.Id > 0 {
|
||||||
err = json.Unmarshal(*userMaterialInfo.Metadata, &metadataMapOld)
|
err = json.Unmarshal(*userMaterialInfo.Metadata, &metadataMapOld)
|
||||||
@ -143,6 +145,31 @@ func (l *UserInfoSetLogic) UserInfoSet(req *types.UserInfoSetReq, userinfo *auth
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var metadataChild = make(map[string]interface{}, 1)
|
||||||
|
metadataChild["logo_selected_id"] = reqMetadata["logo_selected_id"]
|
||||||
|
metadataMap, err = metadata.SetMetadata(metadataChild, metadataMapOld)
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(l.ctx, "metadata SetMetadata err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
metadataB, err := json.Marshal(metadataMap)
|
||||||
|
if err != nil {
|
||||||
|
logc.Errorf(l.ctx, "metadata marshal err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
userInfo.Metadata = &metadataB
|
||||||
|
userInfo.Utime = &nowTime
|
||||||
|
resUpdates := tx.Model(&userInfo).Select("metadata").Where("id = ?", userInfo.Id).Updates(&userInfo)
|
||||||
|
err = resUpdates.Error
|
||||||
|
if err != nil {
|
||||||
|
if err != gorm.ErrRecordNotFound {
|
||||||
|
logc.Errorf(l.ctx, "FsUserInfo Updates err:%+v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -150,8 +177,7 @@ func (l *UserInfoSetLogic) UserInfoSet(req *types.UserInfoSetReq, userinfo *auth
|
|||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatus(basic.CodeDbSqlErr, "service fail")
|
return resp.SetStatus(basic.CodeDbSqlErr, "service fail")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return resp.SetStatus(basic.CodeOK)
|
return resp.SetStatus(basic.CodeOK)
|
||||||
} else {
|
} else {
|
||||||
userInfo.GuestId = &guestId
|
userInfo.GuestId = &guestId
|
||||||
|
@ -84,7 +84,7 @@ func (l *UserLogoListLogic) UserLogoList(req *types.UserLogoListReq, userinfo *a
|
|||||||
merchantCategoryId := int64(merchantCategory.(float64))
|
merchantCategoryId := int64(merchantCategory.(float64))
|
||||||
merchantCategoryIds = append(merchantCategoryIds, merchantCategoryId)
|
merchantCategoryIds = append(merchantCategoryIds, merchantCategoryId)
|
||||||
}
|
}
|
||||||
|
metadataMap["merchant_category_info"] = nil
|
||||||
v.MetaDataMap = metadataMap
|
v.MetaDataMap = metadataMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type UserInfoSetReq struct {
|
type UserInfoSetReq struct {
|
||||||
Module string `form:"module,options=[merchant_category,logo_merchant_category]"` // json格式字符串
|
Module string `form:"module,options=[merchant_category,logo_merchant_category,profile]"` // json格式字符串
|
||||||
Metadata string `form:"metadata"` // json格式字符串
|
Metadata string `form:"metadata"` // json格式字符串
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ service home-user-auth {
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
UserInfoSetReq {
|
UserInfoSetReq {
|
||||||
Module string `form:"module,options=[merchant_category,logo_merchant_category]"` // json格式字符串
|
Module string `form:"module,options=[merchant_category,logo_merchant_category,profile]"` // json格式字符串
|
||||||
Metadata string `form:"metadata"` // json格式字符串
|
Metadata string `form:"metadata"` // json格式字符串
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user