Quellcode durchsuchen

fix:排序逻辑调整

Roc vor 1 Jahr
Ursprung
Commit
50d244bd31
1 geänderte Dateien mit 3 neuen und 2 gelöschten Zeilen
  1. 3 2
      models/data_manage/excel/excel_info.go

+ 3 - 2
models/data_manage/excel/excel_info.go

@@ -247,10 +247,11 @@ func GetFirstExcelInfoByClassifyId(classifyId int) (item *ExcelInfo, err error)
 // UpdateExcelInfoSortByClassifyId 根据表格id更新排序
 func UpdateExcelInfoSortByClassifyId(classifyId, nowSort, prevExcelInfoId int, updateSort string) (err error) {
 	o := orm.NewOrmUsingDB("data")
-	sql := ` update excel_info set sort = ` + updateSort + ` WHERE excel_classify_id=? and sort > ? AND is_delete=0 `
+	sql := ` update excel_info set sort = ` + updateSort + ` WHERE excel_classify_id=? AND is_delete=0 AND ( sort > ? `
 	if prevExcelInfoId > 0 {
-		sql += ` or (excel_info_id > ` + fmt.Sprint(prevExcelInfoId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
+		sql += ` or (excel_info_id < ` + fmt.Sprint(prevExcelInfoId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
 	}
+	sql += `)`
 	_, err = o.Raw(sql, classifyId, nowSort).Exec()
 	return
 }