package chart_permission

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

// ChartPermission 报告权限表
type ChartPermission struct {
	ChartPermissionId   int       `orm:"column(chart_permission_id);pk" description:"问题ID"`
	ChartPermissionName string    `description:"名称"`
	PermissionName      string    `description:"权限名"`
	Sort                int       `description:"排序"`
	Enabled             int       `description:"是否可用"`
	CreatedTime         time.Time `description:"创建时间"`
	LastUpdatedTime     time.Time `description:"更新时间"`
	TeleconferenceSort  int       `description:"电话会类型排序"`
	Remark              string    `description:"备注"`
	ClassifyName        string    `description:"分类名称"`
	ProductName         string    `description:"产品名称"`
	ProductID           int       `description:"产品ID"`
	ImageURL            string    `description:"图片地址"`
	ShowType            int       `description:"1:查研观向小程序展示"`
	IsOther             int       `description:"是否是其他，用于查研观向小程序后台展示"`
	IsReport            int       `description:"是否是报告，用于查研观向小程序前台报告展示"`
	CygxAuth            int       `description:"是否是权限，用于查研观向小程序前台权限校验"`
	YbImgUrl            string    `description:"研报小程序报告列表icon"`
	PriceDrivenState    int       `description:"品种价格驱动开启状态 0-关闭 1-开启"`
}

// GetListByIds 通过IDs获取图表权限集合
func GetListByIds(permissionIds []int) (list []*ChartPermission, err error) {
	lenNum := len(permissionIds)
	if lenNum == 0 {
		return
	}
	o := orm.NewOrm()
	sql := "SELECT * from chart_permission_chapter_mapping WHERE chart_permission_id in (" + utils.GetOrmInReplace(lenNum) + ") "
	_, err = o.Raw(sql, permissionIds).QueryRows(&list)
	return
}
