package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type CompanyReportPermission struct { CompanyReportPermissionId int `orm:"column(company_report_permission_id);pk"` CompanyId int `description:"客户id"` ReportPermissionId int `description:"报告权限id"` CreatedTime time.Time LastUpdatedTime time.Time ChartPermissionId int `description:"权限id"` StartDate string `description:"权限开始日期"` EndDate string `description:"权限结束日期"` ProductId int `description:"产品id"` ProductName string `description:"产品名称"` ModifyTime string `description:"修改时间"` CompanyContractId string `description:"合同id"` Status string `description:"状态 '正式','试用','关闭','永续','潜在' "` IsUpgrade int `description:"是否升级,1是,0否"` } // 通过查询条件获取详情 func GetCompanyReportPermissionDetailByCondition(condition string, pars []interface{}) (item *CompanyReportPermission, err error) { if condition == "" { return } o := orm.NewOrmUsingDB("weekly_report") sql := `SELECT * FROM company_report_permission WHERE 1 = 1 ` + condition err = o.Raw(sql, pars).QueryRow(&item) return } // 列表 func GetCompanyReportPermissionList(condition string, pars []interface{}) (items []*CompanyReportPermission, err error) { o := orm.NewOrmUsingDB("weekly_report") sql := `SELECT * FROM company_report_permission WHERE 1= 1 ` if condition != "" { sql += condition } _, err = o.Raw(sql, pars).QueryRows(&items) return } func GetCompanyPermissionCheck(companyId, permissionId int) (count int, err error) { o := orm.NewOrmUsingDB("weekly_report") sql := `SELECT COUNT(1) AS count FROM company_report_permission AS a WHERE a.company_id=? AND a.chart_permission_id=? ` err = o.Raw(sql, companyId, permissionId).QueryRow(&count) return }