company_report_permission.go 2.0 KB

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