package models

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

type CygxXzsChooseSend struct {
	Id           int       `orm:"column(id);pk"`
	UserId       int       `description:"用户ID"`
	Mobile       string    `description:"手机号"`
	Email        string    `description:"邮箱"`
	CompanyId    int       `description:"公司id"`
	CompanyName  string    `description:"公司名称"`
	RealName     string    `description:"用户实际名称"`
	IsRefuse     int       `description:"是否拒绝推送,0否、1是  如果为1 则不做任何推送"`
	IsSubjective int       `description:"是否选择主观推送, 1 是 、 0否"`
	IsObjective  int       `description:"是否选择客观推送, 1 是 、 0否"`
	CreateTime   time.Time `description:"创建时间"`
	ModifyTime   time.Time `description:"更新时间"`
	AllInYiYao   int       `description:"是否选择医药全部赛道"`
	AllInXiaoFei int       `description:"是否选择消费全部赛道"`
	AllInKeJi    int       `description:"是否选择科技全部赛道"`
	AllInZhiZao  int       `description:"是否选择智造全部赛道"`
	AllInCeLue   int       `description:"是否选择策略全部赛道"`
	AllInYanXuan int       `description:"是否选择研选全部赛道"`
}

//获取提交过推送规则用户的userId
func GetCygxXzsChooseSend() (items []*CygxXzsChooseSend, err error) {
	o := orm.NewOrm()
	sql := `SELECT * FROM cygx_xzs_choose_send `
	_, err = o.Raw(sql).QueryRows(&items)
	return
}

//获取某个行业勾选全部赛道的用户
func GetCygxXzsChooseSendByAllIn(allIn string) (items []*CygxXzsChooseSend, err error) {
	o := orm.NewOrm()
	sql := `SELECT * FROM cygx_xzs_choose_send  WHERE ` + allIn + ` = 1	`
	_, err = o.Raw(sql).QueryRows(&items)
	return
}

//修改某个用户的行业是否勾选全部赛道
func UpdateCygxXzsChooseSendIsAllIn(allIn string, isAllIn, userId int) (err error) {
	o := orm.NewOrm()
	sql := `UPDATE cygx_xzs_choose_send SET ` + allIn + ` = ? WHERE user_id = ?`
	_, err = o.Raw(sql, isAllIn, userId).Exec()
	return
}