37 lines
922 B
Go
37 lines
922 B
Go
package models
|
|
|
|
import "time"
|
|
|
|
type AiFile struct {
|
|
Id uint `json:"id"`
|
|
FileName string `json:"file_name"`
|
|
CollectName string `json:"collect_name"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
//增加数据
|
|
func (this *AiFile) AddAiFile() uint {
|
|
DB.Create(this)
|
|
return this.Id
|
|
}
|
|
|
|
//根据条件查询一条
|
|
func FindAiFileRow(query interface{}, args ...interface{}) AiFile {
|
|
var res AiFile
|
|
DB.Table("ai_file").Where(query, args...).First(&res)
|
|
return res
|
|
}
|
|
|
|
//根据条件查询分页列表
|
|
func FindFileList(page, pagesize int, query interface{}, args ...interface{}) []AiFile {
|
|
offset := (page - 1) * pagesize
|
|
var res []AiFile
|
|
DB.Table("ai_file").Where(query, args...).Order("id desc").Offset(offset).Limit(pagesize).Find(&res)
|
|
return res
|
|
}
|
|
|
|
//根据条件删除
|
|
func DelFile(query interface{}, args ...interface{}) error {
|
|
return DB.Where(query, args...).Delete(&AiFile{}).Error
|
|
}
|