This commit is contained in:
laodaming 2023-10-16 12:27:39 +08:00
parent b95c2f90d5
commit 57f3270af2

View File

@ -38,9 +38,6 @@ type (
}
ImageHandle = interface {
// 获取logo最新信息
LogoInfo(ctx context.Context, in *LogoInfoReq) (*LogoInfoRes, error)
// logo信息
LogoInfoSet(ctx context.Context, in *LogoInfoSetReq) (*LogoInfoSetRes, error)
@ -65,106 +62,6 @@ type (
}
)
func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*LogoInfoRes, error) {
var metadata *string
var logoUrl *string
var userInfoMetadata *string
// 更新用户信息
var module = "profile"
userInfoGorm := l.MysqlConn.Where("module = ?", module)
userInfo := gmodel.FsUserInfo{}
userInfoGorm.Where("user_id = ? and guest_id = ?", in.UserId, in.GuestId)
userInfo.UserId = &in.UserId
userInfo.GuestId = &in.GuestId
/*if in.UserId == 0 && in.GuestId == 0 {
userInfoGorm.Where("user_id = ? and guest_id = ?", in.UserId, in.GuestId)
} else {
if in.UserId > 0 {
userInfoGorm.Where("user_id = ?", in.UserId)
userInfo.UserId = &in.UserId
} else {
userInfoGorm.Where("guest_id = ?", in.GuestId)
userInfo.GuestId = &in.GuestId
}
}*/
resFirst := userInfoGorm.First(&userInfo)
err := resFirst.Error
if err != nil {
if err != gorm.ErrRecordNotFound {
logc.Errorf(ctx, "FsUserInfo First err%+v", err)
return nil, err
}
}
if userInfo.Id != 0 {
tmp := string(*userInfo.Metadata)
userInfoMetadata = &tmp
}
var userMaterialInfo gmodel.FsUserMaterial
userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn)
var metadataUserInfo struct {
LogoSelected struct {
TemplateTagSelected *struct {
Color [][]string `json:"color"`
TemplateTag string `json:"template_tag"`
SelectedIndex int64 `json:"selected_index"`
} `json:"template_tag_selected"`
LogoSelectedId int64 `json:"logo_selected_id"`
} `json:"logo_selected"`
}
userInfo.Id = 0
if userInfo.Id == 0 {
userMaterialInfo, err = userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId)
if err != nil && err != gorm.ErrRecordNotFound {
logc.Errorf(ctx, "FsUserMaterial FindLatestOne err%+v", err)
return nil, err
}
} else {
if userInfo.Metadata != nil {
err = json.Unmarshal([]byte(*userInfo.Metadata), &metadataUserInfo)
if err != nil {
logc.Errorf(ctx, "userInfo.Metadata Unmarshal err%+v", err)
return nil, err
}
if metadataUserInfo.LogoSelected.LogoSelectedId != 0 {
userMaterialInfos, err := userMaterialModel.FindOneById(ctx, metadataUserInfo.LogoSelected.LogoSelectedId)
if err != nil {
if err != gorm.ErrRecordNotFound {
logc.Errorf(ctx, "userMaterial findOneById err%+v", err)
return nil, err
}
}
if userMaterialInfos.Id != 0 {
userMaterialInfo = *userMaterialInfos
}
}
}
}
if userMaterialInfo.Id == 0 {
userMaterialInfoDefault, err := userMaterialModel.FindOneById(ctx, 0)
if err != nil {
if err != gorm.ErrRecordNotFound {
logc.Errorf(ctx, "userMaterialModel FindOneById defaul err%+v", err)
return nil, err
}
}
metadataB := string(*userMaterialInfoDefault.Metadata)
metadata = &metadataB
logoUrl = userMaterialInfoDefault.ResourceUrl
} else {
metadataB := string(*userMaterialInfo.Metadata)
metadata = &metadataB
logoUrl = userMaterialInfo.ResourceUrl
}
return &LogoInfoRes{
Metadata: metadata,
LogoUrl: logoUrl,
UserInfoMetadata: userInfoMetadata,
}, nil
}
/* 获取logo最新信息 */
/* logo信息 */