package roadshow

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

type Researcher struct {
	AdminId      int    `description:"研究员id"`
	RealName     string `description:"研究员名称"`
	GroupId      int    `description:"分组id"`
	GroupName    string `description:"分组名称"`
	RoleTypeCode string `description:"角色编码"`
}

type ResearcherGroup struct {
	GroupId        int    `description:"分组id"`
	GroupName      string `description:"分组名称"`
	ResearcherList []*Researcher
}

func GetResearcherGroup() (list []*ResearcherGroup, err error) {
	o := orm.NewOrm()
	sql := ` SELECT group_id,group_name FROM admin AS a
			WHERE a.role_type_code IN('researcher','ficc_researcher','ficc_admin')
			AND a.enabled=1
			AND a.group_id>0
			AND a.group_name<>'无'
			GROUP BY a.group_id 
            ORDER BY a.group_id ASC `
	_, err = o.Raw(sql).QueryRows(&list)
	return
}

func GetResearcher() (list []*Researcher, err error) {
	o := orm.NewOrm()
	sql := ` SELECT * FROM admin AS a
			WHERE a.role_type_code IN('researcher','rai_researcher','ficc_researcher','ficc_admin')
			AND a.enabled=1 AND a.real_name<>'于菲' `
	_, err = o.Raw(sql).QueryRows(&list)
	return
}
