package models

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

// 获取是否属于权益客户
func GetCountCompanyProductCompanyId(companyId, productId int) (count int, err error) {
	o := orm.NewOrmUsingDB("weekly_report")
	sql := `SELECT  COUNT(1) AS count FROM company_product WHERE company_id = ?  AND product_id = ?  `
	err = o.Raw(sql, companyId, productId).QueryRow(&count)
	return
}

// 获取列表
func GetCompanyProductList(condition string, pars []interface{}) (items []*CompanyProduct, err error) {
	o := orm.NewOrmUsingDB("weekly_report")
	sql := `SELECT *  FROM company_product WHERE 1= 1 `
	if condition != "" {
		sql += condition
	}
	_, err = o.Raw(sql, pars).QueryRows(&items)
	return
}
