Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-11-23 14:17:56 +08:00
commit d3cb276293

View File

@ -90,6 +90,7 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er
// 是否强制刷新
var refresh bool
if req.ResourceId != "" {
resourceId = req.ResourceId
}
@ -145,34 +146,23 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er
uploadBaseRes.ResourceUrl = url
var version string = "0.0.1"
var nowTime = time.Now().UTC()
var dbData = gmodel.FsResource{
ResourceId: resourceId,
UserId: &req.UserId,
GuestId: &req.GuestId,
ResourceType: &contentType,
ResourceUrl: &url,
Version: &version,
UploadedAt: &nowTime,
Metadata: &metadataB,
ApiType: &apiType,
BucketName: bucketName,
Source: &req.Source,
}
if refresh {
err = tx.Save(&gmodel.FsResource{
ResourceId: resourceId,
UserId: &req.UserId,
GuestId: &req.GuestId,
ResourceType: &contentType,
ResourceUrl: &url,
Version: &version,
UploadedAt: &nowTime,
Metadata: &metadataB,
ApiType: &apiType,
BucketName: bucketName,
Source: &req.Source,
}).Error
err = tx.Save(&dbData).Error
} else {
err = tx.Create(&gmodel.FsResource{
ResourceId: resourceId,
UserId: &req.UserId,
GuestId: &req.GuestId,
ResourceType: &contentType,
ResourceUrl: &url,
Version: &version,
UploadedAt: &nowTime,
Metadata: &metadataB,
ApiType: &apiType,
BucketName: bucketName,
Source: &req.Source,
}).Error
err = tx.Create(&dbData).Error
}
if err != nil {
@ -275,34 +265,23 @@ func (upload *Upload) UploadFileByByte(req *UploadBaseReq) (*UploadBaseRes, erro
uploadBaseRes.ResourceUrl = url
var version string = "0.0.1"
var nowTime = time.Now().UTC()
var dbData = gmodel.FsResource{
ResourceId: resourceId,
UserId: &req.UserId,
GuestId: &req.GuestId,
ResourceType: &contentType,
ResourceUrl: &url,
Version: &version,
UploadedAt: &nowTime,
Metadata: &metadataB,
ApiType: &apiType,
BucketName: bucketName,
Source: &req.Source,
}
if refresh {
err = tx.Save(&gmodel.FsResource{
ResourceId: resourceId,
UserId: &req.UserId,
GuestId: &req.GuestId,
ResourceType: &contentType,
ResourceUrl: &url,
Version: &version,
UploadedAt: &nowTime,
Metadata: &metadataB,
ApiType: &apiType,
BucketName: bucketName,
Source: &req.Source,
}).Error
err = tx.Save(&dbData).Error
} else {
err = tx.Create(&gmodel.FsResource{
ResourceId: resourceId,
UserId: &req.UserId,
GuestId: &req.GuestId,
ResourceType: &contentType,
ResourceUrl: &url,
Version: &version,
UploadedAt: &nowTime,
Metadata: &metadataB,
ApiType: &apiType,
BucketName: bucketName,
Source: &req.Source,
}).Error
err = tx.Create(&dbData).Error
}
if err != nil {
logx.Errorf("err:%+vdesc:%+v", err, "fail.upload.resourceInfoAdd.mysql")