Browse Source

Merge branch 'bzq1/sci_hq_custom' of eta_server/eta_api into debug

鲍自强 8 months ago
parent
commit
1819045f63
1 changed files with 40 additions and 1 deletions
  1. 40 1
      models/data_manage/base_from_sci_hq_index.go

+ 40 - 1
models/data_manage/base_from_sci_hq_index.go

@@ -294,8 +294,28 @@ func MoveUpSciHqIndexBySort(classifyId, nextSort, currentSort int) (err error) {
 
 func DeleteSciHqIndexById(indexId int) (err error) {
 	o := orm.NewOrmUsingDB("data")
+	to, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = to.Rollback()
+		} else {
+			_ = to.Commit()
+		}
+	}()
+
 	sql := `DELETE FROM base_from_sci_hq_index WHERE base_from_sci_hq_index_id=? `
-	_, err = o.Raw(sql, indexId).Exec()
+	_, err = to.Raw(sql, indexId).Exec()
+	if err != nil {
+		return
+	}
+	sql = `DELETE FROM base_from_sci_hq_data WHERE base_from_sci_hq_index_id=? `
+	_, err = to.Raw(sql, indexId).Exec()
+	if err != nil {
+		return
+	}
 	return
 }
 
@@ -304,8 +324,27 @@ func DeleteSciHqIndexByIds(indexIds []int) (err error) {
 		return
 	}
 	o := orm.NewOrmUsingDB("data")
+	to, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = to.Rollback()
+		} else {
+			_ = to.Commit()
+		}
+	}()
 	sql := `DELETE FROM base_from_sci_hq_index WHERE base_from_sci_hq_index_id IN (` + utils.GetOrmInReplace(len(indexIds)) + `) `
 	_, err = o.Raw(sql, indexIds).Exec()
+	if err != nil {
+		return
+	}
+	sql = `DELETE FROM base_from_sci_hq_data WHERE base_from_sci_hq_index_id IN (` + utils.GetOrmInReplace(len(indexIds)) + `) `
+	_, err = o.Raw(sql, indexIds).Exec()
+	if err != nil {
+		return
+	}
 	return
 }