瀏覽代碼

fix:审批详情接口新增返回布局方式字段

Roc 9 月之前
父節點
當前提交
11d2c7eea8
共有 3 個文件被更改,包括 20 次插入43 次删除
  1. 10 30
      controllers/report_approve/report_approve.go
  2. 9 12
      models/report.go
  3. 1 1
      models/report_approve/report_approve.go

+ 10 - 30
controllers/report_approve/report_approve.go

@@ -317,26 +317,6 @@ func (this *ReportApproveController) List() {
 		ormList = list
 	}
 
-	cnReportIdList := make([]int, 0)
-	for _, v := range ormList {
-		if v.ReportType == report_approve.FlowReportTypeChinese {
-			cnReportIdList = append(cnReportIdList, v.ReportId)
-		}
-	}
-
-	reportLayoutMap := make(map[int]int8)
-	if len(cnReportIdList) > 0 {
-		layoutList, e := models.GetReportLayoutByReportIdList(cnReportIdList)
-		if e != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "GetReportLayoutByReportIdList err: " + e.Error()
-			return
-		}
-		for _, v := range layoutList {
-			reportLayoutMap[v.Id] = v.ReportLayout
-		}
-	}
-
 	// 格式化列表
 	for _, v := range ormList {
 		t := report_approve.FormatReportApproveOrm2Item(v)
@@ -354,16 +334,6 @@ func (this *ReportApproveController) List() {
 			t.ReportClassify = reportClassify
 		}
 
-		// 布局方式
-		{
-			t.ReportLayout = 1
-			if v.ReportType == report_approve.FlowReportTypeChinese {
-				if layout, ok := reportLayoutMap[v.ReportId]; ok {
-					t.ReportLayout = layout
-				}
-			}
-		}
-
 		respList = append(respList, t)
 	}
 
@@ -547,9 +517,18 @@ func (this *ReportApproveController) Detail() {
 	detail.Report.ReportType = approveItem.ReportType
 	detail.Report.ReportId = approveItem.ReportId
 	detail.Report.ReportTitle = approveItem.ReportTitle
+	detail.Report.ReportLayout = 1
 
 	// 报告分类路由
 	if approveItem.ReportType == report_approve.FlowReportTypeChinese {
+		reportInfo, e := models.GetReportLayoutByReportId(approveItem.ReportId)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取报告失败, Err: " + e.Error()
+			return
+		}
+		detail.Report.ReportLayout = reportInfo.ReportLayout
+
 		detail.Report.ReportCode = utils.MD5(strconv.Itoa(approveItem.ReportId))
 		detail.Report.ReportClassify = fmt.Sprintf("%s/%s/%s", report_approve.FlowReportTypeMap[approveItem.ReportType], cnClassifyIdName[approveItem.ClassifyFirstId], cnClassifyIdName[approveItem.ClassifySecondId])
 	}
@@ -558,6 +537,7 @@ func (this *ReportApproveController) Detail() {
 		detail.Report.ReportClassify = fmt.Sprintf("%s/%s/%s/%s", report_approve.FlowReportTypeMap[approveItem.ReportType], enClassifyIdName[enRootIdMap[approveItem.ClassifySecondId]], enClassifyIdName[approveItem.ClassifyFirstId], enClassifyIdName[approveItem.ClassifySecondId])
 	}
 	if approveItem.ReportType == report_approve.FlowReportTypeSmart {
+		detail.Report.ReportLayout = 2
 		detail.Report.ReportCode = utils.MD5(fmt.Sprint("smart_", approveItem.ReportId))
 		detail.Report.ReportClassify = fmt.Sprintf("%s/%s/%s", report_approve.FlowReportTypeMap[approveItem.ReportType], cnClassifyIdName[approveItem.ClassifyFirstId], cnClassifyIdName[approveItem.ClassifySecondId])
 	}

+ 9 - 12
models/report.go

@@ -1457,21 +1457,18 @@ type ReportLayout struct {
 	ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
 }
 
-// GetReportLayoutByReportIdList
-// @Description: 根据报告id获取报告的布局列表
+// GetReportLayoutByReportId
+// @Description: 根据报告id获取报告的布局
 // @author: Roc
-// @datetime 2024-07-15 14:38:10
-// @param reportIdList []int
-// @return items []ReportLayout
+// @datetime 2024-07-15 15:27:05
+// @param reportId int
+// @return item ReportLayout
 // @return err error
-func GetReportLayoutByReportIdList(reportIdList []int) (items []ReportLayout, err error) {
-	num := len(reportIdList)
-	if num <= 0 {
-		return
-	}
+func GetReportLayoutByReportId(reportId int) (item ReportLayout, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 
-	sql := `SELECT id, report_layout  FROM report  WHERE id in (` + utils.GetOrmInReplace(num) + `) `
-	_, err = o.Raw(sql, reportIdList).QueryRows(&items)
+	sql := `SELECT id, report_layout  FROM report  WHERE id = ? `
+	err = o.Raw(sql, reportId).QueryRow(&item)
+
 	return
 }

+ 1 - 1
models/report_approve/report_approve.go

@@ -199,7 +199,6 @@ type ReportApproveItem struct {
 	HandleTime            string `description:"处理时间"`
 	CreateTime            string `description:"创建时间"`
 	ModifyTime            string `description:"修改时间"`
-	ReportLayout          int8   `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
 }
 
 // FormatReportApproveOrm2Item 格式化报告审批
@@ -387,6 +386,7 @@ type ReportApproveDetailReport struct {
 	ReportTitle    string `description:"报告标题"`
 	ReportCode     string `description:"报告code"`
 	ReportClassify string `description:"报告分类"`
+	ReportLayout   int8   `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
 	//ClassifyFirstId  int    `description:"一级分类ID"`
 	//ClassifySecondId int    `description:"二级分类ID"`
 	//Content          string `description:"报告内容"`