Browse Source

Merge branch 'pool/341' into debug

Roc 6 days ago
parent
commit
2be66f2e1c
3 changed files with 46 additions and 1 deletions
  1. 44 0
      controllers/report_v2.go
  2. 1 0
      models/report.go
  3. 1 1
      models/report_v2.go

+ 44 - 0
controllers/report_v2.go

@@ -779,6 +779,50 @@ func (this *ReportController) Detail() {
 
 	}
 
+	classifyMap := make(map[int]*models.Classify) // 分类map
+	classifyIdList := make([]int, 0)
+
+	if item.ClassifyIdFirst > 0 {
+		classifyIdList = append(classifyIdList, item.ClassifyIdFirst)
+	}
+	if item.ClassifyIdSecond > 0 {
+		classifyIdList = append(classifyIdList, item.ClassifyIdSecond)
+	}
+	if item.ClassifyIdThird > 0 {
+		classifyIdList = append(classifyIdList, item.ClassifyIdThird)
+	}
+
+	if len(classifyIdList) > 0 {
+		classifyList, e := models.GetClassifyListByIdList(classifyIdList)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取报告分类失败, Err: " + e.Error()
+			return
+		}
+		for _, v := range classifyList {
+			classifyMap[v.Id] = v
+		}
+		if item.ClassifyIdThird > 0 {
+			if classify, ok := classifyMap[item.ClassifyIdThird]; ok {
+				if classify.Enabled == 1 {
+					item.ClassifyEnabled = true
+				}
+			}
+		} else if item.ClassifyIdSecond > 0 {
+			if classify, ok := classifyMap[item.ClassifyIdSecond]; ok {
+				if classify.Enabled == 1 {
+					item.ClassifyEnabled = true
+				}
+			}
+		} else if item.ClassifyIdFirst > 0 {
+			if classify, ok := classifyMap[item.ClassifyIdFirst]; ok {
+				if classify.Enabled == 1 {
+					item.ClassifyEnabled = true
+				}
+			}
+		}
+	}
+
 	resp := &models.ReportDetailView{
 		ReportDetail: item,
 		ChapterList:  chapterList,

+ 1 - 0
models/report.go

@@ -378,6 +378,7 @@ type ReportDetail struct {
 	ReportLayout        int8      `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
 	IsPublicPublish     int8      `description:"是否公开发布,1:是,2:否"`
 	ReportCreateTime    time.Time `description:"报告时间创建时间"`
+	ClassifyEnabled     bool      `description:"分类是否禁用"`
 }
 
 func GetReportById(reportId int) (item *ReportDetail, err error) {

+ 1 - 1
models/report_v2.go

@@ -369,7 +369,7 @@ func GetReportListCountByAuthorized(condition string, pars []interface{}) (count
 func GetReportListByAuthorized(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportList, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 
-	sql := `SELECT id,classify_id_first,classify_name_first,classify_id_second,classify_name_second,classify_id_third,classify_name_third,title,stage,create_time,state,author,report_layout,collaborate_type,is_public_publish,abstract,has_chapter,publish_time FROM report as a WHERE 1=1  `
+	sql := `SELECT id,classify_id_first,classify_name_first,classify_id_second,classify_name_second,classify_id_third,classify_name_third,title,stage,create_time,modify_time,content_modify_time,report_create_time,state,author,report_layout,collaborate_type,is_public_publish,abstract,has_chapter,publish_time FROM report as a WHERE 1=1  `
 	if condition != "" {
 		sql += condition
 	}