fix:设置logo数据库为用户自己素材

This commit is contained in:
momo 2023-11-07 14:13:07 +08:00
parent ebb7354d23
commit a875e13e55
6 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,26 @@
package gmodel
import (
"gorm.io/gorm"
"time"
)
// fs_feishu_config 飞书app配置表
type FsFeishuConfig struct {
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID
AppId *string `gorm:"default:'';" json:"app_id"` //
AppName *string `gorm:"default:'';" json:"app_name"` // 项目名称
AppSecret *string `gorm:"default:'';" json:"app_secret"` // app密钥
EncryptKey *string `gorm:"default:'';" json:"encrypt_key"` //
VerificationToken *string `gorm:"default:'';" json:"verification_token"` //
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
}
type FsFeishuConfigModel struct {
db *gorm.DB
name string
}
func NewFsFeishuConfigModel(db *gorm.DB) *FsFeishuConfigModel {
return &FsFeishuConfigModel{db: db, name: "fs_feishu_config"}
}

View File

@ -0,0 +1,2 @@
package gmodel
// TODO: 使用model的属性做你想做的

View File

@ -21,9 +21,9 @@ type FsPreprocessLogo struct {
IsBranch *int64 `gorm:"default:0;" json:"is_branch"` // 是否分店 IsBranch *int64 `gorm:"default:0;" json:"is_branch"` // 是否分店
Metadata *[]byte `gorm:"default:'';" json:"metadata"` // Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
Source *string `gorm:"index;default:'';" json:"source"` // Source *string `gorm:"index;default:'';" json:"source"` //
IsDel *int64 `gorm:"index;default:0;" json:"is_del"` // 是否删除
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` // Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` //
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` // Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` //
IsDel *int64 `gorm:"index;default:0;" json:"is_del"` // 是否删除
} }
type FsPreprocessLogoModel struct { type FsPreprocessLogoModel struct {
db *gorm.DB db *gorm.DB

View File

@ -15,6 +15,7 @@ type FsUserMaterial struct {
ResourceUrl *string `gorm:"default:'';" json:"resource_url"` // ResourceUrl *string `gorm:"default:'';" json:"resource_url"` //
Metadata *[]byte `gorm:"default:'';" json:"metadata"` // Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` // 上传时间 Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` // 上传时间
LogoId *int64 `gorm:"index;default:0;" json:"logo_id"` // logo库ID
} }
type FsUserMaterialModel struct { type FsUserMaterialModel struct {
db *gorm.DB db *gorm.DB

View File

@ -49,6 +49,7 @@ type AllModelsGen struct {
FsFactoryProduct *FsFactoryProductModel // fs_factory_product 工厂生产表(废弃) FsFactoryProduct *FsFactoryProductModel // fs_factory_product 工厂生产表(废弃)
FsFactoryShipTmp *FsFactoryShipTmpModel // fs_factory_ship_tmp FsFactoryShipTmp *FsFactoryShipTmpModel // fs_factory_ship_tmp
FsFaq *FsFaqModel // fs_faq 常见问题 FsFaq *FsFaqModel // fs_faq 常见问题
FsFeishuConfig *FsFeishuConfigModel // fs_feishu_config 飞书app配置表
FsFont *FsFontModel // fs_font 字体配置 FsFont *FsFontModel // fs_font 字体配置
FsGerent *FsGerentModel // fs_gerent 管理员表 FsGerent *FsGerentModel // fs_gerent 管理员表
FsGuest *FsGuestModel // fs_guest 游客表 FsGuest *FsGuestModel // fs_guest 游客表
@ -167,6 +168,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
FsFactoryProduct: NewFsFactoryProductModel(gdb), FsFactoryProduct: NewFsFactoryProductModel(gdb),
FsFactoryShipTmp: NewFsFactoryShipTmpModel(gdb), FsFactoryShipTmp: NewFsFactoryShipTmpModel(gdb),
FsFaq: NewFsFaqModel(gdb), FsFaq: NewFsFaqModel(gdb),
FsFeishuConfig: NewFsFeishuConfigModel(gdb),
FsFont: NewFsFontModel(gdb), FsFont: NewFsFontModel(gdb),
FsGerent: NewFsGerentModel(gdb), FsGerent: NewFsGerentModel(gdb),
FsGuest: NewFsGuestModel(gdb), FsGuest: NewFsGuestModel(gdb),

View File

@ -68,6 +68,29 @@ func (l *UserLogoDataSetLogic) UserLogoDataSet(req *types.UserLogoDataSetReq, us
return resp.SetStatus(basic.CodeApiErr) return resp.SetStatus(basic.CodeApiErr)
} }
var materialInfoOld gmodel.FsUserMaterial
result1 := l.svcCtx.MysqlConn.Model(&gmodel.FsUserMaterial{}).Where("logo_id = ?", req.LogoDataId).Take(&materialInfoOld)
err = result1.Error
if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
logc.Errorf(l.ctx, "FsUserMaterial logoData find err%+v", err)
return resp.SetStatus(basic.CodeApiErr)
}
} else {
// 返回成功的响应和上传URL
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
"id": materialInfoOld.Id,
"module": materialInfoOld.Module,
"user_id": materialInfoOld.UserId,
"guest_id": materialInfoOld.GuestId,
"resource_id": materialInfoOld.ResourceId,
"resource_url": materialInfoOld.ResourceUrl,
"metadata": materialInfoOld.Metadata,
"ctime": materialInfoOld.Ctime,
"resource_info": nil,
})
}
var userMaterialMetadata []byte var userMaterialMetadata []byte
if logoData.Metadata == nil { if logoData.Metadata == nil {
var resultStr string var resultStr string