company_report_permission.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CompanyReportPermission struct {
  7. CompanyReportPermissionId int `orm:"column(company_report_permission_id);pk"`
  8. CompanyId int `description:"客户id"`
  9. ReportPermissionId int `description:"报告权限id"`
  10. CreatedTime time.Time
  11. LastUpdatedTime time.Time
  12. ChartPermissionId int `description:"权限id"`
  13. StartDate string `description:"权限开始日期"`
  14. EndDate string `description:"权限结束日期"`
  15. ProductId int `description:"产品id"`
  16. ProductName string `description:"产品名称"`
  17. ModifyTime string `description:"修改时间"`
  18. CompanyContractId string `description:"合同id"`
  19. Status string `description:"状态 '正式','试用','关闭','永续','潜在' "`
  20. IsUpgrade int `description:"是否升级,1是,0否"`
  21. }
  22. // 通过查询条件获取详情
  23. func GetCompanyReportPermissionDetailByCondition(condition string, pars []interface{}) (item *CompanyReportPermission, err error) {
  24. if condition == "" {
  25. return
  26. }
  27. o := orm.NewOrmUsingDB("weekly_report")
  28. sql := `SELECT * FROM company_report_permission WHERE 1 = 1 ` + condition
  29. err = o.Raw(sql, pars).QueryRow(&item)
  30. return
  31. }
  32. // 列表
  33. func GetCompanyReportPermissionList(condition string, pars []interface{}) (items []*CompanyReportPermission, err error) {
  34. o := orm.NewOrmUsingDB("weekly_report")
  35. sql := `SELECT * FROM company_report_permission WHERE 1= 1 `
  36. if condition != "" {
  37. sql += condition
  38. }
  39. _, err = o.Raw(sql, pars).QueryRows(&items)
  40. return
  41. }
  42. func GetCompanyPermissionCheck(companyId, permissionId int) (count int, err error) {
  43. o := orm.NewOrmUsingDB("weekly_report")
  44. sql := `SELECT COUNT(1) AS count FROM company_report_permission AS a WHERE a.company_id=? AND a.chart_permission_id=? `
  45. err = o.Raw(sql, companyId, permissionId).QueryRow(&count)
  46. return
  47. }