package models import ( "eta_gn/eta_api/global" "fmt" "github.com/rdlucklib/rdluck_tools/paging" "time" ) type PptV2History struct { Id int `gorm:"primaryKey"` PptId int `description:"ppt ID"` TemplateType int `description:"模板类型"` BackgroundImg string `description:"背景图"` Title string `description:"标题"` ReportType string `description:"报告类型"` PptDate string `description:"选择日期"` Content string `description:"内容"` AdminId int `description:"操作人ID"` AdminRealName string `description:"操作人真实姓名"` CreateTime time.Time `description:"创建时间"` CoverContent string `description:"封面内容"` TitleSetting string `description:"标题设置"` } // 获取表名 func (p *PptV2History) TableName() string { return "ppt_v2_history" } func (p *PptV2History) Add() (err error) { err = global.DmSQL["rddp"].Create(p).Error return } func (p *PptV2History) GetNoContentPageList(condition string, pars []interface{}, startSize, pageSize int) (list []*PptV2History, err error) { sql := fmt.Sprintf(`SELECT id, ppt_id, template_type, background_img, title, report_type, ppt_date, create_time, admin_id, admin_real_name FROM %s WHERE 1=1 `, p.TableName()) if condition != "" { sql += condition } sql += ` ORDER BY create_time DESC, id DESC LIMIT ?, ?` pars = append(pars, startSize, pageSize) err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&list).Error return } func (p *PptV2History) GetPageListCount(condition string, pars []interface{}) (count int, err error) { sql := fmt.Sprintf(`SELECT COUNT(1) AS count FROM %s WHERE 1=1 `, p.TableName()) if condition != "" { sql += condition } err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error return } // 删除接口 func (p *PptV2History) Delete() (err error) { err = global.DmSQL["rddp"].Delete(p).Error return } // 查询单条记录 func (p *PptV2History) GetById(id int) (item *PptV2History, err error) { err = global.DmSQL["rddp"].Where("id = ?", id).First(&item).Error return } // PptV2HistoryListItem 定义PPT历史记录列表项的结构体 type PptV2HistoryListItem struct { Id int `description:"PPT历史记录id"` PptId int `description:"ppt ID"` TemplateType int `description:"模板类型"` BackgroundImg string `description:"背景图"` Title string `description:"标题"` ReportType string `description:"报告类型"` PptDate string `description:"选择日期"` AdminId int `description:"操作人ID"` AdminRealName string `description:"操作人真实姓名"` CreateTime string `description:"创建时间"` } type PptV2HistoryListResp struct { List []*PptV2HistoryListItem Paging *paging.PagingItem `description:"分页数据"` } type DeletePptV2HistoryReq struct { Id int `description:"PPT历史记录id"` }