package order

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

type CygxUserBusinessCard struct {
	Id               int    `orm:"column(id);pk"`
	BusinessCardUrl  string `description:"名片地址"`
	UserId           int    `description:"用户ID"`
	RealName         string `description:"用户实际名称"`
	Mobile           string `description:"手机号"`
	CompanyName      string `description:"公司名称"`
	CreateTime       time.Time
	ModifyTime       time.Time `description:"修改时间"`
	RegisterPlatform int       `description:"来源"`
	InviteName       string    `description:"邀请人"`
}

type CygxUserBusinessCardReq struct {
	BusinessCardUrl string `description:"名片地址"`
	RealName        string `description:"用户实际名称"`
	Mobile          string `description:"手机号"`
	CompanyName     string `description:"公司名称"`
	InviteName      string `description:"邀请人"`
}

func GetCygxUserBusinessCardCount(userId int) (count int, err error) {
	o := orm.NewOrm()
	sql := `SELECT COUNT(1) AS count FROM cygx_user_business_card WHERE user_id=?  `
	err = o.Raw(sql, userId).QueryRow(&count)
	return
}

// 新增
func AddCygxUserBusinessCard(item *CygxUserBusinessCard) (err error) {
	o := orm.NewOrm()
	_, err = o.Insert(item)
	return
}
