Browse Source

品种排序避免影响到其他的排序

xyxie 1 year ago
parent
commit
501e70abe7
1 changed files with 5 additions and 3 deletions
  1. 5 3
      models/crm/chart_permission.go

+ 5 - 3
models/crm/chart_permission.go

@@ -140,11 +140,13 @@ type PermissionMoveReq struct {
 
 // UpdateChartPermissionSortByParentId 根据父类id更新排序
 func UpdateChartPermissionSortByParentId(parentId, chartPermissionId, nowSort int, updateSort string, productId int) (err error) {
-	sql := ` update chart_permission set sort = ` + updateSort + ` WHERE parent_id=? AND sort > ? AND product_id = ? `
+	sql := ` update chart_permission set sort = ` + updateSort + ` WHERE parent_id=? AND product_id = ? AND (sort > ? `
 	if chartPermissionId > 0 {
-		sql += ` or ( chart_permission_id > ` + fmt.Sprint(chartPermissionId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
+		sql += ` or ( chart_permission_id > ` + fmt.Sprint(chartPermissionId) + ` and sort = ` + fmt.Sprint(nowSort) + `))`
+	} else {
+		sql += `)`
 	}
-	err = global.MYSQL["hz_crm"].Exec(sql, parentId, nowSort, productId).Error
+	err = global.MYSQL["hz_crm"].Exec(sql, parentId, nowSort, productId, productId).Error
 	return
 }