package cygx

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

type CygxMinutesSummaryLog struct {
	ArticleSunId        int       `orm:"column(article_sun_id);pk"description:"子级报告id"`
	ArticleId           int       `description:"父级报告Id"`
	Type                string    `description:"类型'SSGS：上市公司调研纪要,’CYDYJY：产业调研纪要’,’YANX：研选"`
	Sort                string    `description:"排序"`
	ChartPermissionId   int       `description:"行业ID"`
	ChartPermissionSort string    `description:"行业排序"`
	CreateTime          time.Time `description:"创建时间"`
	Body                string    `description:"内容"`
	ReportLink          string    `description:"报告链接"`
	LinkArticleId       int       `description:"报告ID链接"`
}

type CygxMinutesSummaryLogRep struct {
	Sort                string `description:"排序"`
	ChartPermissionId   int    `description:"行业ID"`
	ChartPermissionName string `description:"行业名称"`
	ChartPermissionSort string `description:"行业排序"`
	Body                string `description:"内容"`
	ReportLink          string `description:"报告链接"`
	IcoLink             string `description:"图标链接"`
}

type AddCygxMinutesSummaryLog struct {
	Body       string `description:"内容"`
	ReportLink string `description:"报告链接"`
	Sort       string `description:"排序"`
}

type CygxMSlChartPermission struct {
	ChartPermissionId   int    `description:"行业ID"`
	ChartPermissionSort string `description:"行业排序"`
	List                []*AddCygxMinutesSummaryLog
}

type CygxMSlChartPermissionIco struct {
	ChartPermissionId   int    `description:"行业ID"`
	ChartPermissionName string `description:"行业名称"`
	ChartPermissionSort string `description:"行业排序"`
	IcoLink             string `description:"图标链接"`
	List                []*AddCygxMinutesSummaryLog
}

type CygxMSlChartPermissionIcoTmp struct {
	ChartPermissionId   int    `description:"行业ID"`
	ChartPermissionName string `description:"行业名称"`
	ChartPermissionSort string `description:"行业排序"`
	IcoLink             string `description:"图标链接"`
	List                []string
	//List                make([]string, 0)
}

type CygxMSlFirstList struct {
	ListSdbg   []*CygxRSlChartPermission   `description:"类型——’SDBG：深度报告片篇’"`
	SortSdbg   string                      `description:"深度报告排序"`
	ListCydyjy []*CygxRSlChartPermission   `description:"类型——’CYDYJY：产业调研纪要’"`
	SortCydyjy string                      `description:"产业调研纪要排序"`
	ListSjdp   []*AddCygxMinutesSummaryLog `description:"类型——’SJDP：事件点评"`
	SortSjdp   string                      `description:"事件点评排序"`
	ListBzchjh []*CygxRSlChartPermission   `description:"类型——’BZCHJH：本周晨会精华’"`
	SortBzchjh string                      `description:"本周晨会精华排序"`
}

func GetCygxMinutesSummaryLogRepList(articleId int, typeStr string) (items []*CygxMinutesSummaryLogRep, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := `SELECT l.*
			FROM cygx_minutes_summary_log AS l
			WHERE  1= 1 AND article_id=?  AND type =? GROUP BY l.chart_permission_id `
	_, err = o.Raw(sql, articleId, typeStr).QueryRows(&items)
	return
}

func GetCygxMinutesSummaryLogRepListSon(articleId, chartPermissionId int, typeStr string) (items []*AddCygxResearchSummaryLog, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := `SELECT l.* FROM cygx_minutes_summary_log AS l
			WHERE  1= 1 AND l.article_id=?  AND l.chart_permission_id =? AND l.type =? `
	_, err = o.Raw(sql, articleId, chartPermissionId, typeStr).QueryRows(&items)
	return
}

func GetCygxMinutesSummaryYanxList(articleId int, typeStr string) (items []*AddCygxMinutesSummaryLog, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := `SELECT l.* FROM cygx_minutes_summary_log AS l
			WHERE  1= 1 AND l.article_id=? AND l.type =?  `
	_, err = o.Raw(sql, articleId, typeStr).QueryRows(&items)
	return
}
