fix:裁剪业务逻辑调整
This commit is contained in:
parent
7f23905e76
commit
1e25f79d4a
|
@ -78,6 +78,7 @@ func (l *UploadFileBaseLogic) UploadFileBase(req *types.UploadFileBaseReq, useri
|
|||
UserId: userId,
|
||||
GuestId: guestId,
|
||||
Source: req.Source,
|
||||
Refresh: req.Refresh,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -22,7 +22,7 @@ type UploadFileBaseReq struct {
|
|||
GuestId int64 `form:"guest_id,optional"` // 上传文件额外信息
|
||||
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
|
||||
Source string `form:"source"` // 上传来源
|
||||
Refresh bool `form:"refresh,optional"` // 强制更新
|
||||
Refresh int64 `form:"refresh,optional"` // 强制更新 10
|
||||
}
|
||||
|
||||
type UploadLogoReq struct {
|
||||
|
|
|
@ -67,7 +67,7 @@ type (
|
|||
GuestId int64 `form:"guest_id,optional"` // 上传文件额外信息
|
||||
UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久
|
||||
Source string `form:"source"` // 上传来源
|
||||
Refresh bool `form:"refresh,optional"` // 强制更新
|
||||
Refresh int64 `form:"refresh,optional"` // 强制更新 10
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ type Upload struct {
|
|||
}
|
||||
|
||||
type UploadBaseReq struct {
|
||||
Refresh bool
|
||||
Refresh int64
|
||||
Source string
|
||||
FileHash string
|
||||
FileData string
|
||||
|
@ -71,11 +71,11 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er
|
|||
err := upload.MysqlConn.Transaction(func(tx *gorm.DB) (err error) {
|
||||
var resourceInfo *gmodel.FsResource
|
||||
|
||||
if !req.Refresh {
|
||||
if req.Refresh == 0 {
|
||||
err = tx.Where("resource_id =?", resourceId).Take(&resourceInfo).Error
|
||||
}
|
||||
|
||||
if !req.Refresh && err == nil && resourceInfo.ResourceId != "" {
|
||||
if req.Refresh == 0 && err == nil && resourceInfo.ResourceId != "" {
|
||||
uploadBaseRes.Status = 1
|
||||
uploadBaseRes.ResourceId = resourceId
|
||||
uploadBaseRes.ResourceUrl = *resourceInfo.ResourceUrl
|
||||
|
@ -114,19 +114,36 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er
|
|||
uploadBaseRes.ResourceUrl = url
|
||||
var version string = "0.0.1"
|
||||
var nowTime = time.Now().UTC()
|
||||
err = tx.Create(&gmodel.FsResource{
|
||||
ResourceId: resourceId,
|
||||
UserId: &req.UserId,
|
||||
GuestId: &req.GuestId,
|
||||
ResourceType: &contentType,
|
||||
ResourceUrl: &url,
|
||||
Version: &version,
|
||||
UploadedAt: &nowTime,
|
||||
Metadata: &req.Metadata,
|
||||
ApiType: &apiType,
|
||||
BucketName: bucketName,
|
||||
Source: &req.Source,
|
||||
}).Error
|
||||
if req.Refresh == 1 {
|
||||
err = tx.Save(&gmodel.FsResource{
|
||||
ResourceId: resourceId,
|
||||
UserId: &req.UserId,
|
||||
GuestId: &req.GuestId,
|
||||
ResourceType: &contentType,
|
||||
ResourceUrl: &url,
|
||||
Version: &version,
|
||||
UploadedAt: &nowTime,
|
||||
Metadata: &req.Metadata,
|
||||
ApiType: &apiType,
|
||||
BucketName: bucketName,
|
||||
Source: &req.Source,
|
||||
}).Error
|
||||
} else {
|
||||
err = tx.Create(&gmodel.FsResource{
|
||||
ResourceId: resourceId,
|
||||
UserId: &req.UserId,
|
||||
GuestId: &req.GuestId,
|
||||
ResourceType: &contentType,
|
||||
ResourceUrl: &url,
|
||||
Version: &version,
|
||||
UploadedAt: &nowTime,
|
||||
Metadata: &req.Metadata,
|
||||
ApiType: &apiType,
|
||||
BucketName: bucketName,
|
||||
Source: &req.Source,
|
||||
}).Error
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logx.Errorf("err:%+v,desc:%+v", err, "fail.upload.resourceInfoAdd.mysql")
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue
Block a user