1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package chart_permission_chapter_mapping
- import (
- "hongze/hongze_yb/global"
- )
- // GetReportIdsByPermisssionIds 根据权限ID筛选报告ID, rddp 类型表示新后台新增的报告,区分老后台
- func GetReportIdsByPermisssionIds(permissionIds []int, researchType string) (reportIds []int, err error) {
- var charPermissionMapping []*ChartPermissionChapterMapping
- err = global.MYSQL["rddp"].Model(ChartPermissionChapterMapping{}).Select("DISTINCT report_chapter_type_id ").Where("chart_permission_id in (?) AND research_type = ? ", permissionIds, researchType).Scan(&charPermissionMapping).Error
- if err != nil {
- return
- }
- for _, v := range charPermissionMapping {
- reportIds = append(reportIds, v.ReportChapterTypeId)
- }
- return
- }
- // GetPermissionIdsByReportId 根据报告ID筛选出对应的权限
- func GetPermissionIdsByReportId(reportId int, researchType string) (permissionIds []int, err error) {
- var charPermissionMapping []*ChartPermissionChapterMapping
- err = global.MYSQL["rddp"].Model(ChartPermissionChapterMapping{}).
- Select("DISTINCT chart_permission_id").
- Where("report_chapter_type_id = ? and research_type = ? ", reportId, researchType).
- Scan(&charPermissionMapping).Error
- if err != nil {
- return
- }
- for _, v := range charPermissionMapping {
- permissionIds = append(permissionIds, v.ChartPermissionId)
- }
- return
- }
- // GetPermissionIdsByWeek 根据报告ID筛选出对应的权限
- func GetPermissionIdsByWeek() (permissionIds []int, err error) {
- var charPermissionMapping []*ChartPermissionChapterMapping
- err = global.MYSQL["rddp"].Model(ChartPermissionChapterMapping{}).
- Select("DISTINCT chart_permission_id").
- Where("research_type = 'week'").
- Scan(&charPermissionMapping).Error
- if err != nil {
- return
- }
- for _, v := range charPermissionMapping {
- permissionIds = append(permissionIds, v.ChartPermissionId)
- }
- return
- }
|