package models import ( "github.com/beego/beego/v2/client/orm" ) type ChartPermissionResp struct { ChartPermissionId int `description:"权限id"` PermissionName string `description:"权限名称"` } type ChartPermission struct { ChartPermissionId int `description:"权限id"` PermissionName string `description:"权限名称"` IsShowSustainable bool `description:"是否展示限免标签"` ImageUrlM string `description:"图片地址"` } type ChartPermissionItemResp struct { ChartPermissionId int `description:"权限id"` PermissionName string `description:"权限名称"` IsShowSustainable bool `description:"是否展示限免标签"` ImageUrlM string `description:"图片地址"` IsChoose bool `description:"是否选择"` MatchTypeName string `description:"匹配类型名称"` } type ChartPermissionListResp struct { List []*ChartPermissionResp CheckList []int `description:"权限"` } func GetChartPermissionReportAll(condition string) (items []*ChartPermissionResp, err error) { o := orm.NewOrmUsingDB("weekly_report") sql := `SELECT * FROM chart_permission WHERE product_id=2 AND is_report=1 AND permission_type!=2 ` + condition + ` ORDER BY sort ASC ` _, err = o.Raw(sql).QueryRows(&items) return } func GetCategoryId(chartPermissionId int) (category_id string, err error) { o := orm.NewOrm() sql := ` SELECT GROUP_CONCAT(a.category_id) AS category_id FROM cygx_report_mapping AS a WHERE a.chart_permission_id=? GROUP BY a.chart_permission_id ` err = o.Raw(sql, chartPermissionId).QueryRow(&category_id) return } func GetCategoryIdHome(chartPermissionId int) (category_id string, err error) { o := orm.NewOrm() sql := `SELECT GROUP_CONCAT(a.category_id) AS category_id FROM cygx_report_mapping AS a WHERE a.chart_permission_id=? AND a.is_summary = 1 GROUP BY a.chart_permission_id ` err = o.Raw(sql, chartPermissionId).QueryRow(&category_id) return } func GetChartPermissionById(chartPermissionId int) (item *ChartPermission, err error) { o := orm.NewOrmUsingDB("weekly_report") sql := `SELECT * FROM chart_permission WHERE chart_permission_id = ? ` err = o.Raw(sql, chartPermissionId).QueryRow(&item) return } func GetChartPermissionListRai() (items []*ChartPermission, err error) { o := orm.NewOrmUsingDB("weekly_report") sql := `SELECT * FROM chart_permission WHERE product_id=2 ORDER BY sort ASC ` _, err = o.Raw(sql).QueryRows(&items) return }