Browse Source

Merge branch 'eta_classify_bug_1025@guomengyuan' into debug

gmy 4 months ago
parent
commit
c99a3740ea
5 changed files with 76 additions and 0 deletions
  1. 9 0
      controllers/classify.go
  2. 13 0
      models/report.go
  3. 9 0
      routers/commentsRouter.go
  4. 35 0
      services/classify.go
  5. 10 0
      services/cmd/start_classify.go

+ 9 - 0
controllers/classify.go

@@ -863,3 +863,12 @@ func (this *ClassifyController) ClassifyPermissionV2() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// 处理禅道bug6445,对数据进行补偿刷新
+/*func init() {
+	err := services.DealBug6445()
+	if err != nil {
+		return
+	}
+}
+*/

+ 13 - 0
models/report.go

@@ -1537,3 +1537,16 @@ func UpdateReportInfo(reports *Report) (err error) {
 
 	return
 }
+
+func FindReportListByCondition(condition string, pars []interface{}) (items []*Report, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `SELECT * FROM report WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	if err != nil {
+		return nil, err
+	}
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -9322,6 +9322,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers:ClassifyController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers:ClassifyController"],
+        beego.ControllerComments{
+            Method: "DealBug6445",
+            Router: `/deal/bug/6445`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers:ClassifyController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers:ClassifyController"],
         beego.ControllerComments{
             Method: "Delete",

+ 35 - 0
services/classify.go

@@ -7,6 +7,7 @@ import (
 	"eta/eta_api/models/report_approve"
 	"eta/eta_api/utils"
 	"fmt"
+	"github.com/beego/beego/v2/core/logs"
 	"sort"
 	"time"
 )
@@ -828,3 +829,37 @@ func (a BySortAndCreateTime) Less(i, j int) bool {
 func SortClassifyListBySortAndCreateTime(classifyList []*models.ClassifyList) {
 	sort.Sort(BySortAndCreateTime(classifyList))
 }
+
+// DealBug6445 处理禅道bug6445,对数据进行补偿刷新
+func DealBug6445() error {
+	var condition string
+	var pars []interface{}
+	reportList, err := models.FindReportListByCondition(condition, pars)
+	if err != nil {
+		return err
+	}
+
+	for _, report := range reportList {
+		oldClassifyIdThird := report.ClassifyIdThird
+		oldClassifyNameThird := report.ClassifyNameThird
+		classifyIdList := []int{report.ClassifyIdSecond, report.ClassifyIdThird}
+
+		// 判断当前分类id的父id是否一样,如果系统则将3级分类置为0
+		classifies, err := models.GetClassifyListByIdList(classifyIdList)
+		if err != nil {
+			return err
+		}
+		if len(classifies) >= 2 {
+			if classifies[0].ParentId == classifies[1].ParentId && classifies[0].ParentId != 0 {
+				report.ClassifyIdThird = 0
+				report.ClassifyNameThird = ""
+				err := report.UpdateReport([]string{"classify_id_third", "classify_name_third"})
+				if err != nil {
+					return err
+				}
+				logs.Info("update report id: %d, classify_id_third: %d, classify_name_third: %s", report.Id, oldClassifyIdThird, oldClassifyNameThird)
+			}
+		}
+	}
+	return nil
+}

+ 10 - 0
services/cmd/start_classify.go

@@ -0,0 +1,10 @@
+package main
+
+import "eta/eta_api/services"
+
+func main() {
+	err := services.DealBug6445()
+	if err != nil {
+		return
+	}
+}