Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
2c27b85c33
|
@ -22,6 +22,8 @@ type FsProductTemplateV2 struct {
|
|||
Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间
|
||||
Tag *string `gorm:"default:'';" json:"tag"` // 标签(用户自填)
|
||||
IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除
|
||||
GroupOptions *string `gorm:"default:'';" json:"group_options"` // 颜色分组
|
||||
Version *int64 `gorm:"default:0;" json:"version"` //
|
||||
}
|
||||
type FsProductTemplateV2Model struct {
|
||||
db *gorm.DB
|
||||
|
|
|
@ -17,6 +17,7 @@ type FsResource struct {
|
|||
Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式,存储图像分率
|
||||
MetaKey1 *string `gorm:"index;default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加
|
||||
ApiType *int64 `gorm:"default:1;" json:"api_type"` // 调用类型:1=对外,2=对内
|
||||
BucketName *string `gorm:"default:'';" json:"bucket_name"` // 存储桶名
|
||||
}
|
||||
type FsResourceModel struct {
|
||||
db *gorm.DB
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
// fs_user_material 用户素材表
|
||||
type FsUserMaterial struct {
|
||||
Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 用户 ID
|
||||
Module *string `gorm:"default:'';" json:"module"` // 所属模块
|
||||
Module *string `gorm:"default:'';" json:"module"` // 所属模块:logo
|
||||
UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户 ID
|
||||
GuestId *int64 `gorm:"index;default:0;" json:"guest_id"` // 游客 ID
|
||||
ResourceId *string `gorm:"default:'';" json:"resource_id"` // 资源ID
|
||||
|
|
|
@ -41,6 +41,29 @@ func (l *UploadCallbackLogic) UploadCallback(req *types.UploadCallbackReq, useri
|
|||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
var userId int64
|
||||
var guestId int64
|
||||
|
||||
// 检查用户是否是游客
|
||||
if userinfo.IsGuest() {
|
||||
// 如果是,使用游客ID和游客键名格式
|
||||
guestId = userinfo.GuestId
|
||||
} else {
|
||||
// 否则,使用用户ID和用户键名格式
|
||||
userId = userinfo.UserId
|
||||
}
|
||||
|
||||
// 定义存储桶名称
|
||||
var bucketName *string
|
||||
|
||||
// 根据类别选择存储桶
|
||||
switch req.UploadBucket {
|
||||
case 2:
|
||||
bucketName = basic.TempfileBucketName
|
||||
default:
|
||||
bucketName = basic.StorageBucketName
|
||||
}
|
||||
|
||||
resourceModel := gmodel.NewFsResourceModel(l.svcCtx.MysqlConn)
|
||||
err := resourceModel.Trans(l.ctx, func(ctx context.Context, connGorm *gorm.DB) (err error) {
|
||||
resourceModelTS := gmodel.NewFsResourceModel(l.svcCtx.MysqlConn)
|
||||
|
@ -49,12 +72,17 @@ func (l *UploadCallbackLogic) UploadCallback(req *types.UploadCallbackReq, useri
|
|||
return err
|
||||
}
|
||||
|
||||
var version string = "0.0.1"
|
||||
var fsResource = &gmodel.FsResource{}
|
||||
fsResource.UserId = &userId
|
||||
fsResource.GuestId = &guestId
|
||||
fsResource.ResourceId = req.ResourceId
|
||||
fsResource.ResourceType = &req.ResourceType
|
||||
fsResource.ResourceUrl = &req.ResourceUrl
|
||||
fsResource.Metadata = &req.Metadata
|
||||
fsResource.ApiType = &req.ApiType
|
||||
fsResource.BucketName = bucketName
|
||||
fsResource.Version = &version
|
||||
if resourceInfo.ResourceId == "" {
|
||||
_, err = resourceModelTS.Create(ctx, fsResource)
|
||||
} else {
|
||||
|
|
|
@ -140,6 +140,7 @@ func (l *UploadFileBaseLogic) UploadFileBase(req *types.UploadFileBaseReq, useri
|
|||
UploadedAt: &nowTime,
|
||||
Metadata: &req.Metadata,
|
||||
ApiType: &apiType,
|
||||
BucketName: bucketName,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
|
|
|
@ -195,6 +195,7 @@ func (l *UploadFilesBackendLogic) UploadFilesBackend(req *types.UploadFilesReq,
|
|||
UploadedAt: &nowTime,
|
||||
Metadata: &uploadDataInfo.Metadata,
|
||||
ApiType: &uploadDataInfo.ApiType,
|
||||
BucketName: bucketName,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
|
@ -228,7 +229,7 @@ func (l *UploadFilesBackendLogic) UploadFilesBackend(req *types.UploadFilesReq,
|
|||
|
||||
// 返回成功的响应和上传URL
|
||||
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
|
||||
"upload_urls": result,
|
||||
"upload_data": result,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,7 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
|
|||
logoHeight = 200
|
||||
}
|
||||
var resultStr string
|
||||
var err error
|
||||
|
||||
// apiUrl := l.svcCtx.Config.BLMService.ImageProcess.Url
|
||||
// var onlyScale = true
|
||||
|
@ -113,7 +114,7 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
|
|||
var nowTime = time.Now().Unix()
|
||||
// 新增记录
|
||||
userMaterialModel := gmodel.NewFsUserMaterialModel(l.svcCtx.MysqlConn)
|
||||
_, err := userMaterialModel.CreateOrUpdate(l.ctx, &gmodel.FsUserMaterial{
|
||||
_, err = userMaterialModel.CreateOrUpdate(l.ctx, &gmodel.FsUserMaterial{
|
||||
Module: &module,
|
||||
UserId: &userId,
|
||||
GuestId: &guestId,
|
||||
|
|
|
@ -36,11 +36,12 @@ type UploadFilesReq struct {
|
|||
}
|
||||
|
||||
type UploadCallbackReq struct {
|
||||
ResourceId string `form:"resource_id"` // 资源ID
|
||||
ResourceType string `form:"resource_type"` // 资源类型
|
||||
ResourceUrl string `form:"resource_url"` // 资源URL
|
||||
Metadata string `form:"metadata,optional"` // 元数据,json格式,存储图像分率
|
||||
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内
|
||||
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
|
||||
ResourceId string `form:"resource_id"` // 资源ID
|
||||
ResourceType string `form:"resource_type"` // 资源类型
|
||||
ResourceUrl string `form:"resource_url"` // 资源URL
|
||||
Metadata string `form:"metadata,optional"` // 元数据,json格式,存储图像分率
|
||||
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内
|
||||
}
|
||||
|
||||
type RequestUpFile struct {
|
||||
|
|
|
@ -79,11 +79,12 @@ type (
|
|||
UploadInfo string `form:"upload_info"` // 上传信息 json
|
||||
}
|
||||
UploadCallbackReq {
|
||||
ResourceId string `form:"resource_id"` // 资源ID
|
||||
ResourceType string `form:"resource_type"` // 资源类型
|
||||
ResourceUrl string `form:"resource_url"` // 资源URL
|
||||
Metadata string `form:"metadata,optional"` // 元数据,json格式,存储图像分率
|
||||
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内
|
||||
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
|
||||
ResourceId string `form:"resource_id"` // 资源ID
|
||||
ResourceType string `form:"resource_type"` // 资源类型
|
||||
ResourceUrl string `form:"resource_url"` // 资源URL
|
||||
Metadata string `form:"metadata,optional"` // 元数据,json格式,存储图像分率
|
||||
ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user