package models

import (
	"eta_gn/eta_api/global"
	"time"
)

type ReportChapterTicker struct {
	Id              int       `gorm:"column:id;primaryKey"`     //`orm:"column(id);pk" gorm:"primaryKey"  description:"主键ID"`
	ReportChapterId int       `gorm:"column:report_chapter_id"` //`description:"报告章节ID"`
	Sort            int       `gorm:"column:sort"`              //`description:"排序"`
	Ticker          string    `gorm:"column:ticker"`            //`description:"ticker"`
	CreateTime      time.Time `gorm:"column:create_time"`       //`description:"创建时间"`
	UpdateTime      time.Time `gorm:"column:update_time"`       //`description:"更新时间"`
}

// 新增章节ticker
func InsertChapterTicker(tickerInfo *ReportChapterTicker) (lastId int64, err error) {
	err = global.DmSQL["rddp"].Create(tickerInfo).Error
	lastId = int64(tickerInfo.Id)
	return
}

// ClearReportChapterTicker 清空章节ticker
func ClearReportChapterTicker(reportChapterId int) (err error) {
	sql := ` DELETE FROM report_chapter_ticker WHERE report_chapter_id = ? `
	err = global.DmSQL["rddp"].Exec(sql, reportChapterId).Error
	return
}

// DailyBaseColumn 基础列
type DailyBaseColumn struct {
	BaseColumnId          int       `gorm:"column:base_column_id"`           //`orm:"column(base_column_id)" description:"主键ID"`
	TableName             string    `gorm:"column:table_name"`               //`description:"表名"`
	BaseColumnName        string    `gorm:"column:base_column_name"`         // `description:"列名称"`
	BaseColumnChapterType string    `gorm:"column:base_column_chapter_type"` // `description:"列类型"`
	BaseColumnTicker      string    `gorm:"column:base_column_ticker"`       // `description:"指标"`
	Enabled               int       `gorm:"column:enabled"`                  // `description:"状态"`
	CreatedTime           time.Time `gorm:"column:created_time"`             //`description:"创建时间"`
	LastUpdatedTime       time.Time `gorm:"column:last_updated_time"`        //`description:"更新时间"`
	Freq                  string    `gorm:"column:freq"`                     //`description:"频率 D-日度 W-周度 M-月度"`
	Catalog               string    `gorm:"column:catalog"`                  //`description:"分类名称"`
	ReportChapterTypeId   int       `gorm:"column:report_chapter_type_id"`   //`description:"分类ID"`
	Selected              int       `gorm:"column:selected"`                 //`description:"选中状态 0-未选中 1-已选中"`
}