From 52688dba48a706d9810539532121de4c832ce8c7 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 14 Sep 2023 13:54:15 +0800 Subject: [PATCH] * Adjust file comment. --- module/program/control.php | 16 +++++++--------- module/program/model.php | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/module/program/control.php b/module/program/control.php index a75db57295..91cd893e28 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -1,11 +1,12 @@ * @package program - * @version $Id * @link http://www.zentao.net */ class program extends control @@ -640,15 +641,12 @@ class program extends control public function updateOrder() { $programs = $this->post->programs; - foreach($programs as $id => $order) - { - $this->dao->update(TABLE_PROJECT) - ->set('`order`')->eq($order) - ->where('id')->eq($id) - ->exec(); - } + if(!$programs) return $this->send(array('result' => 'success')); - $this->send(array('result' => 'success')); + foreach($programs as $programID => $order) $this->program->updateOrder((int) $programID, (int) $order); + + if(dao::isError()) return $this->sendError(dao::getError()); + return $this->send(array('result' => 'success')); } /* diff --git a/module/program/model.php b/module/program/model.php index 04230b4c00..e50b0bec78 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1,4 +1,14 @@ + * @package program + * @link http://www.zentao.net + */ class programModel extends model { /** @@ -1783,4 +1793,19 @@ class programModel extends model ->orderBy('order_asc') ->fetchGroup('program'); } + + /** + * 更新项目集排序。 + * Update the order of the program. + * + * @param int $programID + * @param int $order + * @access public + * @return bool + */ + public function updateOrder(int $programID, int $order): bool + { + $this->dao->update(TABLE_PROGRAM)->set('`order`')->eq($order)->where('id')->eq($programID)->exec(); + return !dao::isError(); + } }