package models

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

type CygxActivitySpecialInheritPointsCompany struct {
	Id                  int       `orm:"column(id);pk"`
	CompanyId           int       // 公司ID
	CompanyName         string    // 公司名称
	Points              int   // 公司剩余点数
	CreateTime          time.Time // 创建时间
	ModifyTime          time.Time // 更新时间
	ChartPermissionId   int       // 品种ID
	ChartPermissionName string    // 品种名称
}

func AddCygxActivitySpecialPointsCompany(item *CygxActivitySpecialInheritPointsCompany) (err error) {
	o := orm.NewOrm()
	_, err = o.Insert(item)
	if err != nil {
		return
	}
	return
}

func AddCygxActivitySpecialInheritPointsCompanyMulti(items []*CygxActivitySpecialInheritPointsCompany) (err error) {
	o := orm.NewOrm()
	_, err = o.InsertMulti(1, items)
	return
}

func GetCygxActivitySpecialInheritPointsByCompanyId(companyId int) (list []*CygxActivitySpecialInheritPointsCompany, err error) {
	o := orm.NewOrm()
	sql := ` SELECT * FROM cygx_activity_special_inherit_points_company WHERE company_id = ?  `
	_, err = o.Raw(sql,companyId).QueryRows(&list)
	return
}
func DelCygxActivitySpecialInheritPointsByCompanyId(companyId int) (err error) {
	o := orm.NewOrm()
	sql := ` DELETE FROM cygx_activity_special_inherit_points_company WHERE company_id = ?  `
	_, err = o.Raw(sql,companyId).Exec()
	return
}