company_product.go 660 B

1234567891011121314151617181920212223
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. // 获取是否属于权益客户
  6. func GetCountCompanyProductCompanyId(companyId, productId int) (count int, err error) {
  7. sql := `SELECT COUNT(1) AS count FROM company_product WHERE company_id = ? AND product_id = ? `
  8. err = orm.NewOrm().Raw(sql, companyId, productId).QueryRow(&count)
  9. return
  10. }
  11. // 获取列表
  12. func GetCompanyProductList(condition string, pars []interface{}) (items []*CompanyProduct, err error) {
  13. o := orm.NewOrm()
  14. sql := `SELECT * FROM company_product WHERE 1= 1 `
  15. if condition != "" {
  16. sql += condition
  17. }
  18. _, err = o.Raw(sql, pars).QueryRows(&items)
  19. return
  20. }