From 5f0170df9787c6f3ff17cc168b3f2e3f511453f6 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 31 十月 2023 20:04:16 +0800
Subject: [PATCH] 支持职级降级的情况
---
model/file.go | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/model/file.go b/model/file.go
index 3b919f3..11225f1 100644
--- a/model/file.go
+++ b/model/file.go
@@ -11,20 +11,17 @@
type (
// File 闄勪欢
File struct {
- Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
Name string `gorm:"name" json:"name"`
Size int64 `gorm:"size" json:"size"` // 鏂囦欢澶у皬
- FilePath string `gorm:"file_path" json:"filePath"` // 鏂囦欢璺緞
+ FilePath string `gorm:"file_path" json:"-"` // 鏂囦欢璺緞
Key string `gorm:"key" json:"key"` // 瀵硅薄瀛樺偍key
- Bucket string `gorm:"bucket" json:"bucket"` // 瀵硅薄瀛樺偍bucket
+ Bucket string `gorm:"bucket" json:"-"` // 瀵硅薄瀛樺偍bucket
DownloadCount int `gorm:"download_count" json:"downloadCount"` // 涓嬫娆℃暟
PreviewCount int `gorm:"preview_count" json:"previewCount"` // 棰勮娆℃暟
FileType string `gorm:"file_type" json:"fileType"` // 鏂囦欢绫诲瀷
SourceType string `gorm:"source_type" json:"sourceType"` // 闄勪欢鏉ユ簮
SourceId int `gorm:"source_id" json:"sourceId"` // 鏉ユ簮id
- CreateTime string `gorm:"create_time" json:"createTime"` // 鍒涘缓鏃堕棿
- UpdateTime string `gorm:"update_time" json:"updateTime"`
- Content string `gorm:"content" json:"content"` // 鏂囦欢鍐呭
+ gorm.Model `json:"-"`
}
// FileSearch 闄勪欢鎼滅储鏉′欢
@@ -51,8 +48,8 @@
func (slf *FileSearch) build() *gorm.DB {
var db = slf.Orm.Model(&File{})
- if slf.Id != 0 {
- db = db.Where("id = ?", slf.Id)
+ if slf.ID != 0 {
+ db = db.Where("id = ?", slf.ID)
}
return db
@@ -85,8 +82,8 @@
return record, err
}
-func (slf *FileSearch) SetId(id int) *FileSearch {
- slf.Id = id
+func (slf *FileSearch) SetId(id uint) *FileSearch {
+ slf.ID = id
return slf
}
@@ -108,7 +105,7 @@
}
func (slf *FileSearch) Save(record *File) error {
- if record.Id == 0 {
+ if record.ID == 0 {
return errors.New("id涓虹┖")
}
var db = slf.build()
--
Gitblit v1.8.0