package day_new

import (
	"github.com/beego/beego/v2/client/orm"
)

type DayNewDefault struct {
	Id                 int    `orm:"column(id);pk" description:"序号"`
	ClassifyIdFirst    int    `description:"一级分类id"`
	ClassifyNameFirst  string `description:"一级分类名称"`
	ClassifyIdSecond   int    `description:"二级分类id"`
	ClassifyNameSecond string `description:"二级分类名称"`
	ClassifyIdThird    int    `description:"三级分类ID"`
	ClassifyNameThird  string `description:"三级分类名称"`
	Title              string `description:"标题"`
	Abstract           string `description:"摘要"`
	Author             string `description:"作者"`
	Frequency          string `description:"频度"`
	CreateTime         string `description:"创建时间"`
	Overview           string `description:"英文概述部分"`
	ModifyTime         string `description:"修改时间"`
}

type EnglishReportDefaultSaveReq struct {
	ClassifyIdFirst    int    `description:"一级分类id"`
	ClassifyNameFirst  string `description:"一级分类名称"`
	ClassifyIdSecond   int    `description:"二级分类id"`
	ClassifyNameSecond string `description:"二级分类名称"`
	ClassifyIdThird    int    `description:"三级分类ID"`
	ClassifyNameThird  string `description:"三级分类名称"`
	Title              string `description:"标题"`
	Abstract           string `description:"摘要"`
	Author             string `description:"作者"`
	Frequency          string `description:"频度"`
	Overview           string `description:"英文概述部分"`
}

// 获取每日资讯的默认配置
func GetDayNewDefault() (item *DayNewDefault, err error) {
	o := orm.NewOrm()
	sql := `select * from day_new_default order by id desc limit 1`
	err = o.Raw(sql).QueryRow(&item)
	return
}

// AddDayNewDefault 新增默认值
func AddDayNewDefault(item *DayNewDefault) (err error) {
	o := orm.NewOrm()
	_, err = o.Insert(item)
	return
}

// Update 更新
func (item *DayNewDefault) Update(cols []string) (err error) {
	o := orm.NewOrm()
	_, err = o.Update(item, cols...)
	return
}
