123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- package models
- import (
- "database/sql"
- "eta/eta_index_lib/global"
- "fmt"
- "time"
- )
- // IndexTaskRecord AI任务的子记录
- type IndexTaskRecord struct {
- IndexTaskRecordID int `gorm:"primaryKey;column:index_task_record_id" description:"任务记录id"`
- IndexTaskID int `gorm:"column:index_task_id" description:"任务id"`
- Parameters string `gorm:"column:parameters" description:"子任务参数"`
- Status string `gorm:"column:status" description:"状态,枚举值:待处理,处理成功,处理失败,暂停处理"`
- Remark string `gorm:"column:remark" description:"备注"`
- ModifyTime time.Time `gorm:"column:modify_time" description:"最后一次修改时间"`
- CreateTime time.Time `gorm:"column:create_time" description:"任务创建时间"`
- }
- // TableName get sql table name.获取数据库表名
- func (m *IndexTaskRecord) TableName() string {
- return "index_task_record"
- }
- // IndexTaskRecordColumns get sql column name.获取数据库列名
- var IndexTaskRecordColumns = struct {
- IndexTaskRecordID string
- IndexTaskID string
- Parameters string
- Status string
- Remark string
- ModifyTime string
- CreateTime string
- }{
- IndexTaskRecordID: "index_task_record_id",
- IndexTaskID: "index_task_id",
- Parameters: "parameters",
- Status: "status",
- Remark: "remark",
- ModifyTime: "modify_time",
- CreateTime: "create_time",
- }
- func (m *IndexTaskRecord) Create() (err error) {
- err = global.DEFAULT_DB.Create(&m).Error
- return
- }
- func (m *IndexTaskRecord) Update(updateCols []string) (err error) {
- err = global.DEFAULT_DB.Select(updateCols).Updates(&m).Error
- return
- }
- func (m *IndexTaskRecord) Del() (err error) {
- err = global.DEFAULT_DB.Delete(&m).Error
- return
- }
- func (m *IndexTaskRecord) GetByID(id int) (item *IndexTaskRecord, err error) {
- err = global.DEFAULT_DB.Where(fmt.Sprintf("%s = ?", IndexTaskRecordColumns.IndexTaskRecordID), id).First(&item).Error
- return
- }
- func (m *IndexTaskRecord) GetByCondition(condition string, pars []interface{}) (item *IndexTaskRecord, err error) {
- sqlStr := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s`, m.TableName(), condition)
- err = global.DEFAULT_DB.Raw(sqlStr, pars...).First(&item).Error
- return
- }
- func (m *IndexTaskRecord) GetAllListByCondition(field, condition string, pars []interface{}) (items []*IndexTaskRecord, err error) {
- if field == "" {
- field = "*"
- }
- sqlStr := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s order by index_task_record_id desc `, field, m.TableName(), condition)
- err = global.DEFAULT_DB.Raw(sqlStr, pars...).Find(&items).Error
- return
- }
- func (m *IndexTaskRecord) GetListByCondition(field, condition string, pars []interface{}, startSize, pageSize int) (items []*IndexTaskRecord, err error) {
- if field == "" {
- field = "*"
- }
- sqlStr := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s order by index_task_record_id desc LIMIT ?,?`, field, m.TableName(), condition)
- pars = append(pars, startSize, pageSize)
- err = global.DEFAULT_DB.Raw(sqlStr, pars...).Find(&items).Error
- return
- }
- func (m *IndexTaskRecord) GetCountByCondition(condition string, pars []interface{}) (total int, err error) {
- var intNull sql.NullInt64
- sqlStr := fmt.Sprintf(`SELECT COUNT(1) total FROM %s WHERE 1=1 %s`, m.TableName(), condition)
- err = global.DEFAULT_DB.Raw(sqlStr, pars...).Scan(&intNull).Error
- if err == nil && intNull.Valid {
- total = int(intNull.Int64)
- }
- return
- }
- // QuestionGenerateAbstractParam
- // @Description:
- type QuestionGenerateAbstractParam struct {
- QuestionId int `json:"questionId"`
- ArticleType string `json:"articleType"`
- ArticleId int `json:"articleId"`
- }
|