package models

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

type CygxArticleApplyAppointmentExpert struct {
	Id               int       `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
	ArticleId        int       `gorm:"column:article_id" json:"article_id"`                                  // cygx_article表article_id
	UserId           int       `gorm:"column:user_id" json:"user_id"`                                        // 用户ID
	Mobile           string    `gorm:"column:mobile" json:"mobile"`                                          // 手机号
	Email            string    `gorm:"column:email" json:"email"`                                            // 邮箱
	CompanyId        int       `gorm:"column:company_id;default:0" json:"company_id"`                        // 公司ID
	CompanyName      string    `gorm:"column:company_name" json:"company_name"`                              // 公司名称
	RealName         string    `gorm:"column:real_name" json:"real_name"`                                    // 用户实际名称
	SellerName       string    `gorm:"column:seller_name" json:"seller_name"`                                // 所属销售
	CreateTime       time.Time `gorm:"column:create_time" json:"create_time"`                                // 创建时间
	ModifyTime       time.Time `gorm:"column:modify_time" json:"modify_time"`                                // 修改时间
	RegisterPlatform int       `gorm:"column:register_platform;default:1;NOT NULL" json:"register_platform"` // 来源 1小程序,2:网页
}

// 添加历史信息
func AddCygxArticleApplyAppointmentExpert(item *CygxArticleApplyAppointmentExpert) (lastId int64, err error) {
	o := orm.NewOrm()
	lastId, err = o.Insert(item)
	return
}

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