|
@@ -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
|
|
|
}
|
|
|
|