package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type CygxActivityPointsCompany struct { Id int `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"` CompanyId int `gorm:"column:company_id;default:0" json:"company_id"` // 公司ID CompanyName string `gorm:"column:company_name" json:"company_name"` // 公司名称 Points float64 `gorm:"column:points;default:0;NOT NULL" json:"points"` // 公司剩余点数 CreateTime time.Time `gorm:"column:create_time;NOT NULL" json:"create_time"` // 创建时间 ModifyTime time.Time `gorm:"column:modify_time;NOT NULL" json:"modify_time"` // 更新时间 } // 获取公司剩余点数 func GetCompanyPoints(companyId int) (comapnyPointsNum float64, err error) { o := orm.NewOrm() sql := `SELECT points FROM cygx_activity_points_company WHERE company_id=? ` err = o.Raw(sql, companyId).QueryRow(&comapnyPointsNum) return } // 列表 func GetCygxActivityPointsCompanyList(condition string, pars []interface{}) (items []*CygxActivityPointsCompany, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_activity_points_company as art WHERE 1= 1 ` if condition != "" { sql += condition } _, err = o.Raw(sql, pars).QueryRows(&items) return } // 获取数量 func GetCygxActivityPointsCompanyCountByCompanyId(companyId int) (count int, err error) { sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity_points_company WHERE company_id=? ` o := orm.NewOrm() err = o.Raw(sqlCount, companyId).QueryRow(&count) return }