fix:base上传强制更新
This commit is contained in:
parent
5e00447da3
commit
80a9517a1f
|
@ -22,6 +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"` // 强制更新
|
||||
}
|
||||
|
||||
type UploadLogoReq struct {
|
||||
|
|
|
@ -67,6 +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"` // 强制更新
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ type Upload struct {
|
|||
}
|
||||
|
||||
type UploadBaseReq struct {
|
||||
Refresh bool
|
||||
Source string
|
||||
FileHash string
|
||||
FileData string
|
||||
|
@ -67,10 +68,14 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er
|
|||
var resourceId string = req.FileHash
|
||||
|
||||
var uploadBaseRes = UploadBaseRes{}
|
||||
err := upload.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
||||
err := upload.MysqlConn.Transaction(func(tx *gorm.DB) (err error) {
|
||||
var resourceInfo *gmodel.FsResource
|
||||
err := tx.Where("resource_id =?", resourceId).Take(&resourceInfo).Error
|
||||
if err == nil && resourceInfo.ResourceId != "" {
|
||||
|
||||
if !req.Refresh {
|
||||
err = tx.Where("resource_id =?", resourceId).Take(&resourceInfo).Error
|
||||
}
|
||||
|
||||
if !req.Refresh && err == nil && resourceInfo.ResourceId != "" {
|
||||
uploadBaseRes.Status = 1
|
||||
uploadBaseRes.ResourceId = resourceId
|
||||
uploadBaseRes.ResourceUrl = *resourceInfo.ResourceUrl
|
||||
|
|
Loading…
Reference in New Issue
Block a user