kefu/models/ai_files.go

41 lines
1.1 KiB
Go
Raw Normal View History

2024-12-10 02:50:12 +00:00
package models
import "time"
type AiFile struct {
Id uint `json:"id"`
FileName string `json:"file_name"`
CollectName string `json:"collect_name"`
FileSize string `json:"file_size"`
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 (this *AiFile) SaveAiFile(query interface{}, args ...interface{}) {
DB.Model(&AiFile{}).Where(query, args...).Update(this)
}
//根据条件查询分页列表
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
}