package cygx

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

type CygxActivitySignin struct {
	Id           int    `orm:"column(id);pk"`
	ActivityId   int    `description:"活动ID"`
	UserId       int    `description:"用户ID"`
	CreateTime   string `description:"创建时间"`
	Mobile       string `description:"手机号"`
	Email        string `description:"邮箱"`
	CompanyId    int    `description:"公司id"`
	CompanyName  string `description:"公司名称"`
	BusinessCard string `description:"名片"`
	RealName     string `description:"用户实际名称"`
	IsSignup     int    `description:"是否报名了"`
	CountryCode  string `description:"手机国家区号"`
}

type CygxActivitySigninResp struct {
	ActivityId   int    `description:"活动ID"`
	ActivityName string `description:"活动名称"`
	RealName     string `description:"用户实际名称"`
	Mobile       string `description:"手机号"`
	CompanyName  string `description:"公司名称"`
	BusinessCard string `description:"名片"`
	IsNewUser    bool   `description:"是否属于新客户"`
	IsSignup     bool   `description:"是否报名了"`
}

type CygxActivitySigninDetailResp struct {
	Detail          *CygxActivitySigninResp
	IsBindingMobile bool `description:"是否绑定手机号"`
}

// 获取数量
func GetCygxActivitySigninCount(condition string, pars []interface{}) (count int, err error) {
	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_signin as art WHERE 1= 1  `
	if condition != "" {
		sqlCount += condition
	}
	o := orm.NewOrmUsingDB("hz_cygx")
	err = o.Raw(sqlCount, pars).QueryRow(&count)
	return
}

// 列表
func GetCygxActivitySigninList(condition string, pars []interface{}) (items []*CygxActivitySignin, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := ` SELECT * FROM cygx_activity_signin as s  WHERE  1= 1  ` + condition
	_, err = o.Raw(sql, pars).QueryRows(&items)
	return
}
