1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CompanyReportPermission struct {
- CompanyReportPermissionId int64 `orm:"column(company_report_permission_id);pk"`
- CompanyId int
- ReportPermissionId int
- CreatedTime time.Time
- LastUpdatedTime time.Time
- ChartPermissionId int
- StartDate string `description:"权限开始日期"`
- EndDate string `description:"权限结束日期"`
- ProductId int `description:"产品id"`
- ProductName string `description:"产品名称"`
- CompanyContractId int `description:"合同id"`
- Status string `description:"'正式','试用','关闭'"`
- ModifyTime time.Time `description:"修改时间"`
- IsUpgrade int `description:"是否升级,1是,0否"`
- ExpensiveYx int `description:"权益研选: 0-3w; 1-5w"`
- }
- func GetCompanyPermission(companyId int) (permission string, err error) {
- sql := ` SELECT GROUP_CONCAT(DISTINCT b.remark ORDER BY b.sort ASC SEPARATOR ',') AS permission
- FROM company_report_permission AS a
- INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
- INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
- WHERE a.company_id=?
- AND c.is_suspend=0
- AND b.cygx_auth=1
- AND c.status IN('正式','试用','永续')
- AND a.status IN('正式','试用','永续') `
- o := orm.NewOrm()
- err = o.Raw(sql, companyId).QueryRow(&permission)
- return
- }
- // GetCompanyReportPermissionByCompanyIdAndProductId 获取权限类型
- func GetCompanyReportPermissionByCompanyIdAndProductId(companyId, productId int) (items []*CompanyReportPermission, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- re.*
- FROM
- company_report_permission as re
- INNER JOIN chart_permission as c ON c.chart_permission_id = re.chart_permission_id
- WHERE
- re.company_id = ?
- AND re.product_id = ?
- AND STATUS = '正式' `
- _, err = o.Raw(sql, companyId, productId).QueryRows(&items)
- return
- }
|