package yidong

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

type CygxYidongActivity struct {
	Id                             string    `json:"id" comment:"主键ID"`
	YidongId                       string    `json:"yidong_id" comment:"活动唯一标识"`
	CompanyInfo                    string    `json:"company_info" comment:"公司信息"`
	Title                          string    `json:"title" comment:"活动标题"`
	Type                           string    `json:"type" comment:"活动类型"`
	IndustrySwName                 string    `json:"industry_sw_name" comment:"行业名称"`
	Start                          string    `json:"start" comment:"开始时间"`
	End                            string    `json:"end" comment:"结束时间"`
	SignUpStart                    string    `json:"sign_up_start" comment:"报名开始时间"`
	SignUpEnd                      string    `json:"sign_up_end" comment:"报名结束时间"`
	ActivityJoinType               string    `json:"activity_join_type" comment:"参与类型"`
	Banner                         string    `json:"banner" comment:"活动横幅链接"`
	Url                            string    `json:"url" comment:"活动链接"`
	SyncId                         string    `json:"sync_id" comment:"同步ID"`
	SyncFlag                       string    `json:"sync_flag" comment:"同步标志"`
	BusinessCardOpen               string    `json:"business_card_open" comment:"是否打开名片"`
	BusinessCardRequired           string    `json:"business_card_required" comment:"是否要求名片"`
	PersonNameOpen                 string    `json:"person_name_open" comment:"是否打开姓名"`
	PersonNameRequired             string    `json:"person_name_required" comment:"是否要求姓名"`
	PersonTelephoneOpen            string    `json:"person_telephone_open" comment:"是否打开电话"`
	PersonTelephoneRequired        string    `json:"person_telephone_required" comment:"是否要求电话"`
	MailOpen                       string    `json:"mail_open" comment:"是否打开邮件"`
	MailRequired                   string    `json:"mail_required" comment:"是否要求邮件"`
	CompanyShortNameOpen           string    `json:"company_short_name_open" comment:"是否打开公司简称"`
	CompanyShortNameRequired       string    `json:"company_short_name_required" comment:"是否要求公司简称"`
	CompanyCodeOpen                string    `json:"company_code_open" comment:"是否打开公司代码"`
	CompanyCodeRequired            string    `json:"company_code_required" comment:"是否要求公司代码"`
	JobNameOpen                    string    `json:"job_name_open" comment:"是否打开职位名称"`
	JobNameRequired                string    `json:"job_name_required" comment:"是否要求职位名称"`
	CertificateInformationOpen     string    `json:"certificate_information_open" comment:"是否打开证书信息"`
	CertificateInformationRequired string    `json:"certificate_information_required" comment:"是否要求证书信息"`
	InviteeOpen                    *string   `json:"invitee_open" comment:"是否打开受邀人"`
	InviteeRequired                *string   `json:"invitee_required" comment:"是否要求受邀人"`
	CreateUserId                   string    `json:"create_user_id" comment:"创建用户ID"`
	CreatePersonName               string    `json:"create_person_name" comment:"创建人姓名"`
	PublishFlag                    string    `json:"publish_flag" comment:"发布标志"`
	CompanyCode                    string    `json:"company_code" comment:"公司代码"`
	BackFlag                       string    `json:"back_flag" comment:"回退标志"`
	ActivityForm                   string    `json:"activity_form" comment:"活动形式"`
	ActivityAddress                string    `json:"activity_address" comment:"活动地址"`
	MeetingStatus                  string    `json:"meeting_status" comment:"会议状态"`
	CloudMeetingStatus             string    `json:"cloud_meeting_status" comment:"云会议状态"`
	InteractQaStatus               string    `json:"interact_qa_status" comment:"互动问答状态"`
	LiveStatus                     string    `json:"live_status" comment:"直播状态"`
	CreateTime                     time.Time `comment:"创建时间"`
}

// AddCygxYidongActivityMulti 批量添加
func AddCygxYidongActivityMulti(items []*CygxYidongActivity) (err error) {
	if len(items) == 0 {
		return
	}
	o, err := orm.NewOrm().Begin()
	if err != nil {
		return
	}
	defer func() {
		if err == nil {
			o.Commit()
		} else {
			o.Rollback()
		}
	}()
	if len(items) > 0 {
		_, err = o.InsertMulti(len(items), items)
	}
	return
}

// 列表
func GetCygxYidongActivityListByYidongIds(yidongIds []string) (items []*CygxYidongActivity, err error) {
	lenarr := len(yidongIds)
	if lenarr == 0 {
		return
	}
	o := orm.NewOrm()
	sql := `SELECT yidong_id  FROM cygx_yidong_activity   WHERE yidong_id   IN  (` + utils.GetOrmInReplace(lenarr) + `) `
	_, err = o.Raw(sql, yidongIds).QueryRows(&items)
	return
}
