12345678910111213141516171819202122232425262728293031 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- )
- // 获取是否属于权益客户
- func GetCompanyProductCount(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 = ? AND company_id > 1 `
- 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
- }
- func GetCompanyProductDetailByCompanyId(companyId, productId int) (item *CompanyProduct, err error) {
- sql := ` SELECT * FROM company_product WHERE company_id = ? AND product_id = ?; `
- o := orm.NewOrmUsingDB("weekly_report")
- err = o.Raw(sql, companyId, productId).QueryRow(&item)
- return
- }
|