package models

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

type UserInvitee struct {
	Id                int       `orm:"column(id);pk"`
	InviteeUserId     string    `description:"产业D"`
	InviteedUserId    string    `description:"用户ID"`
	CreateTime        time.Time `description:"创建时间"`
	InviteedMobile    string    `description:"手机号"`
	InviteedCompanyId int       `description:"公司ID"`
	InviteeMobile     string    `description:"邀请人手机号"`
	InviteeCompany    string    `description:"邀请人公司名称"`
	InviteeCompanyId  int       `description:"邀请人公司ID"`
	InviteeEmail      string    `description:"邀请人邮箱"`
}

// 添加收藏信息
func AddUserInvite(item *UserInvitee) (lastId int64, err error) {
	o := orm.NewOrmUsingDB("weekly_report")
	lastId, err = o.Insert(item)
	return
}

// 获取数量
func GetUserInviteeCount(userId int) (count int, err error) {
	o := orm.NewOrmUsingDB("weekly_report")
	sql := `SELECT COUNT(1) AS count FROM user_invitee WHERE inviteed_user_id=? `
	err = o.Raw(sql, userId).QueryRow(&count)
	return
}
