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