mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-02-23 06:26:38 +08:00
refactor: remove default time tracking in file model
This commit is contained in:
parent
74bae5fdc2
commit
126a2c4af3
3 changed files with 9 additions and 17 deletions
|
@ -21,6 +21,6 @@ type File struct {
|
|||
ParentID sql.NullString `gorm:"type:uuid;index"`
|
||||
Parts datatypes.JSONSlice[api.Part] `gorm:"type:jsonb"`
|
||||
ChannelID *int64 `gorm:"type:bigint"`
|
||||
CreatedAt time.Time `gorm:"default:timezone('utc'::text, now())"`
|
||||
UpdatedAt time.Time `gorm:"default:timezone('utc'::text, now())"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime:false"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime:false"`
|
||||
}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package schemas
|
||||
|
||||
type ShareAccess struct {
|
||||
Password string `json:"password" binding:"required"`
|
||||
}
|
||||
|
||||
type ShareFileQuery struct {
|
||||
Path string `form:"path"`
|
||||
Sort string `form:"sort"`
|
||||
Order string `form:"order"`
|
||||
Limit int `form:"limit"`
|
||||
Page int `form:"page"`
|
||||
}
|
|
@ -12,6 +12,7 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/gotd/td/telegram"
|
||||
|
@ -492,6 +493,8 @@ func (a *apiService) FilesUpdate(ctx context.Context, req *api.FileUpdate, param
|
|||
}
|
||||
if req.UpdatedAt.IsSet() {
|
||||
updateDb.UpdatedAt = req.UpdatedAt.Value
|
||||
} else {
|
||||
updateDb.UpdatedAt = time.Now().UTC()
|
||||
}
|
||||
|
||||
if err := a.db.Model(&models.File{}).Where("id = ?", params.ID).Updates(updateDb).Error; err != nil {
|
||||
|
@ -544,12 +547,14 @@ func (a *apiService) FilesUpdateParts(ctx context.Context, req *api.FilePartsUpd
|
|||
Valid: true,
|
||||
}
|
||||
}
|
||||
|
||||
updatePayload.UpdatedAt = req.UpdatedAt
|
||||
|
||||
err := a.db.Transaction(func(tx *gorm.DB) error {
|
||||
if err := tx.Where("id = ?", params.ID).First(&file).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Model(models.File{}).Where("id = ?", params.ID).Updates(updatePayload).
|
||||
Update("updated_at", req.UpdatedAt).Error; err != nil {
|
||||
if err := tx.Model(models.File{}).Where("id = ?", params.ID).Updates(updatePayload).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if req.UploadId.Value != "" {
|
||||
|
|
Loading…
Reference in a new issue