package models

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

type CygxMorningMeetingGather struct {
	Id          int       `orm:"column(id);pk"`
	MeetingIds  string    `description:"主表ID多个用 , 隔开"`
	PublishTime string    `description:"发布日期"`
	CreateTime  time.Time `description:"创建时间"`
	ModifyTime  time.Time `description:"更新时间"`
	Title       string    `description:"标题"`
	Status      int       `description:"0:未发布,1:已发布"`
}

// 添加
func AddCygxMorningMeetingGather(item *CygxMorningMeetingGather) (err error) {
	o := orm.NewOrm()
	_, err = o.Insert(item)
	return
}

func GetCygxMorningMeetingGatherCount(condition string, pars []interface{}) (count int, err error) {
	o := orm.NewOrm()
	sql := `SELECT COUNT(1) AS count FROM cygx_morning_meeting_gather WHERE 1=1 `
	if condition != "" {
		sql += condition
	}
	err = o.Raw(sql, pars).QueryRow(&count)
	return
}

type CygxMorningMeetingGatherResp struct {
	Id           int    `description:"ID"`
	Title        string `description:"标题"`
	IndustryName string `description:"多个产业名称"`
}

type CygxMorningMeetingGatherListResp struct {
	Paging *paging.PagingItem `description:"分页数据"`
	List   []*CygxMorningMeetingGatherResp
}

// 列表
func GetCygxMorningMeetingGatherList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxMorningMeetingGather, err error) {
	o := orm.NewOrm()
	sql := `SELECT * FROM cygx_morning_meeting_gather WHERE 1=1 `
	if condition != "" {
		sql += condition
	}
	sql += ` LIMIT ?,? `
	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
	return
}

func GetCygxMorningMeetingGatherById(condition string, pars []interface{}) (item *CygxMorningMeetingGather, err error) {
	o := orm.NewOrm()
	sql := `SELECT * FROM cygx_morning_meeting_gather WHERE  1= 1`
	if condition != "" {
		sql += condition
	}
	err = o.Raw(sql, pars).QueryRow(&item)
	return
}

type CygxMorningMeetingGatherDetailListResp struct {
	Id                   int                      `description:"ID"`
	IndustryId           int                      `description:"产业id"` // 产业id
	IndustryName         string                   `description:"产业名称"` // 产业名称
	ChartPermissionName  string                   `description:"行业名称"` // 行业名称
	ChartPermissionId    int                      `description:"行业id"` // 行业id
	MeetingId            int                      `description:"主表id"` // 主表id
	Content              string                   `description:"内容"`   // 内容
	PublishTime          string                   `description:"发布日期"`
	ReportLink           string                   `description:"报告链接"`
	LinkArticleId        int                      `description:"报告ID链接"`
	Title                string                   `description:"标题"`
	IndustrialSubjectIds string                   `description:"标的id"`
	ListSubject          []*CygxIndustrialSubject `description:"标的列表"`
}

type CygxMorningMeetingGatherDetailResp struct {
	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
	Detail        *CygxMorningMeetingGatherDetail
}

type CygxMorningMeetingGatherDetail struct {
	Id          int    `description:"ID"`
	Title       string `description:"标题"`
	PublishTime string `description:"发布日期"`
	Department  string `description:"作者"`
	List        []*CygxMorningMeetingGatherDetailListResp
}