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

This commit is contained in:
laodaming 2023-11-07 14:20:49 +08:00
commit 05df11bd7f
5 changed files with 55 additions and 0 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

@ -15,6 +15,7 @@ type FsUserMaterial struct {
ResourceUrl *string `gorm:"default:'';" json:"resource_url"` //
Metadata *[]byte `gorm:"default:'';" json:"metadata"` //
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 {
db *gorm.DB

View File

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

View File

@ -68,6 +68,29 @@ func (l *UserLogoDataSetLogic) UserLogoDataSet(req *types.UserLogoDataSetReq, us
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
if logoData.Metadata == nil {
var resultStr string
@ -101,6 +124,7 @@ func (l *UserLogoDataSetLogic) UserLogoDataSet(req *types.UserLogoDataSetReq, us
ResourceUrl: logoData.ResourceUrl,
Metadata: &userMaterialMetadata,
Ctime: &nowTime,
LogoId: &req.LogoDataId,
}
resCreate := l.svcCtx.MysqlConn.Create(&materialInfo)
err = resCreate.Error