package cygx

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

// 首页资源表与产业的关系
type CygxIndustrialAskserieVideoGroupManagement struct {
	Id                     int       `orm:"column(id);pk" description:"主键ID"`
	AskserieVideoId        int       `description:"askserie_video_id"`
	IndustrialManagementId int       `description:"cygx_industrial_management表的主键ID"`
	CreateTime             time.Time `description:"创建时间"`
}

type IndustrialAskserieVideoManagementRep struct {
	AskserieVideoId        int    `description:"askserie_video_id"`
	IndustrialManagementId int    `description:"cygx_industrial_management表的主键ID"`
	IndustryName           string `description:"产业名称"`
	ChartPermissionId      int    `description:"权限id"`
	PermissionName         string `description:"行业名称"`
}

// 列表GetCygxIndustrialAskserieVideoGroupManagementList
func GetCygxIndustrialAskserieVideoGroupManagementList(askserieVideoIds []int) (items []*IndustrialAskserieVideoManagementRep, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := `SELECT
			am.askserie_video_id,
			m.chart_permission_id,
			m.industrial_management_id,
			m.industry_name 
			FROM
			cygx_industrial_askserie_video_group_management AS am
			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = am.industrial_management_id
			WHERE
			am.askserie_video_id IN (` + utils.GetOrmInReplace(len(askserieVideoIds)) + `)`
	_, err = o.Raw(sql, askserieVideoIds).QueryRows(&items)
	return
}
