| | |
| | | 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"` // 文件路径 |
| | |
| | | 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 附件搜索条件 |
| | |
| | | |
| | | 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 |
| | |
| | | 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 |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | func (slf *FileSearch) Save(record *File) error { |
| | | if record.Id == 0 { |
| | | if record.ID == 0 { |
| | | return errors.New("id为空") |
| | | } |
| | | var db = slf.build() |