package models

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

type UserSellerRelation struct {
	RelationId int64     `orm:"column(relation_id);pk"`
	UserId     int       `description:"用户id"`
	CompanyId  int       `description:"企业用户id"`
	SellerId   int       `description:"销售id"`
	Seller     string    `description:"销售员名称"`
	ProductId  int       `description:"产品id"`
	Mobile     string    `description:"手机号"`
	Email      string    `description:"邮箱"`
	ModifyTime time.Time `description:"修改时间"`
	CreateTime time.Time `description:"创建时间"`
}

// DeleteUserSellerRelationByProductId 根据产品id删除销售员与员工的关系
func DeleteUserSellerRelationByProductId(userId, productId int) (err error) {
	o := orm.NewOrmUsingDB("weekly")
	sql := ` DELETE FROM user_seller_relation WHERE user_id=? and product_id = ?`
	_, err = o.Raw(sql, userId, productId).Exec()
	return
}
