Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
25bf157977
|
@ -70,27 +70,26 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er
|
||||||
|
|
||||||
var uploadBaseRes = UploadBaseRes{}
|
var uploadBaseRes = UploadBaseRes{}
|
||||||
|
|
||||||
// var refresh bool
|
var refresh bool
|
||||||
|
|
||||||
// if req.ResourceId != "" {
|
if req.ResourceId != "" {
|
||||||
// refresh = true
|
refresh = true
|
||||||
// }
|
resourceId = req.ResourceId
|
||||||
|
}
|
||||||
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.ResourceId == "" {
|
if !refresh {
|
||||||
err = tx.Where("resource_id =?", resourceId).Take(&resourceInfo).Error
|
err = tx.Where("resource_id =?", resourceId).Take(&resourceInfo).Error
|
||||||
}
|
if err == nil && resourceInfo.ResourceId != "" {
|
||||||
|
uploadBaseRes.Status = 1
|
||||||
if req.ResourceId == "" && err == nil && resourceInfo.ResourceId != "" {
|
uploadBaseRes.ResourceId = resourceId
|
||||||
uploadBaseRes.Status = 1
|
uploadBaseRes.ResourceUrl = *resourceInfo.ResourceUrl
|
||||||
uploadBaseRes.ResourceId = resourceId
|
} else {
|
||||||
uploadBaseRes.ResourceUrl = *resourceInfo.ResourceUrl
|
refresh = true
|
||||||
} else {
|
|
||||||
if req.ResourceId != "" {
|
|
||||||
resourceId = req.ResourceId
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if refresh {
|
||||||
dist, contentType, err := FileBase64ToByte(req.FileData)
|
dist, contentType, err := FileBase64ToByte(req.FileData)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -125,7 +124,7 @@ 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()
|
||||||
if req.Refresh == 1 {
|
if refresh {
|
||||||
err = tx.Save(&gmodel.FsResource{
|
err = tx.Save(&gmodel.FsResource{
|
||||||
ResourceId: resourceId,
|
ResourceId: resourceId,
|
||||||
UserId: &req.UserId,
|
UserId: &req.UserId,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user