12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- package report_chapter_permission_mapping
- import (
- "hongze/hongze_yb/global"
- "time"
- )
- func GetReportChapterListByPermissionIdsAndReportId(permissionIds []int, reportId int) (reportChapterIdList []int, err error) {
- var items []*ReportChapterPermissionMapping
- obj := ReportChapterPermissionMapping{}
- err = global.MYSQL["rddp"].Table(obj.TableName()+" AS a ").
- Joins("INNER JOIN report_chapter AS b ON a.report_chapter_id = b.report_chapter_id").
- Select("DISTINCT a.report_chapter_id ").
- Where("a.chart_permission_id in (?) AND b.report_id = ? ", permissionIds, reportId).
- Scan(&items).Error
- if err != nil {
- return
- }
- for _, v := range items {
- reportChapterIdList = append(reportChapterIdList, v.ReportChapterID)
- }
- return
- }
- type ReportChapterPermissionMappingItem struct {
- ReportChapterPermissionMappingID int `gorm:"primaryKey;column:report_chapter_permission_mapping_id" json:"report_chapter_permission_mapping_id"`
- ReportChapterID int `gorm:"column:report_chapter_id" json:"report_chapter_id"`
- ChartPermissionID int `gorm:"column:chart_permission_id" json:"chart_permission_id"`
- TypeId int `gorm:"column:type_id" json:"type_id"`
- CreateTime time.Time `gorm:"column:create_time" json:"create_time"`
- }
- func GetReportChapterPermissionMappingItemListByReportId(reportId int) (items []*ReportChapterPermissionMappingItem, err error) {
- obj := ReportChapterPermissionMapping{}
- err = global.MYSQL["rddp"].Table(obj.TableName()+" AS a ").
- Joins("INNER JOIN report_chapter AS b ON a.report_chapter_id = b.report_chapter_id").
- Select("a.*,b.type_id").
- Where(" b.report_id = ? ", reportId).
- Scan(&items).Error
- return
- }
- func GetReportChapterListByReportId(reportId int) (reportChapterIdList []int, err error) {
- var items []*ReportChapterPermissionMapping
- obj := ReportChapterPermissionMapping{}
- err = global.MYSQL["rddp"].Table(obj.TableName()+" AS a ").
- Joins("INNER JOIN report_chapter AS b ON a.report_chapter_id = b.report_chapter_id").
- Select("DISTINCT report_chapter_id ").
- Where(" b.report_id = ? ", reportId).
- Scan(&items).Error
- if err != nil {
- return
- }
- for _, v := range items {
- reportChapterIdList = append(reportChapterIdList, v.ReportChapterID)
- }
- return
- }
|