fix:裁剪业务逻辑调整

This commit is contained in:
momo 2023-08-23 15:44:59 +08:00
parent de52fd3ad2
commit 47401c49bd

View File

@ -70,27 +70,26 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er
var uploadBaseRes = UploadBaseRes{}
// var refresh bool
var refresh bool
// if req.ResourceId != "" {
// refresh = true
// }
if req.ResourceId != "" {
refresh = true
resourceId = req.ResourceId
}
err := upload.MysqlConn.Transaction(func(tx *gorm.DB) (err error) {
var resourceInfo *gmodel.FsResource
if req.ResourceId == "" {
if !refresh {
err = tx.Where("resource_id =?", resourceId).Take(&resourceInfo).Error
}
if req.ResourceId == "" && err == nil && resourceInfo.ResourceId != "" {
if err == nil && resourceInfo.ResourceId != "" {
uploadBaseRes.Status = 1
uploadBaseRes.ResourceId = resourceId
uploadBaseRes.ResourceUrl = *resourceInfo.ResourceUrl
} else {
if req.ResourceId != "" {
resourceId = req.ResourceId
refresh = true
}
}
if refresh {
dist, contentType, err := FileBase64ToByte(req.FileData)
if err != nil {
@ -125,7 +124,7 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er
uploadBaseRes.ResourceUrl = url
var version string = "0.0.1"
var nowTime = time.Now().UTC()
if req.Refresh == 1 {
if refresh {
err = tx.Save(&gmodel.FsResource{
ResourceId: resourceId,
UserId: &req.UserId,