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