* Refactor todoModel::finish/batchFinish.
This commit is contained in:
+24
-36
@@ -211,8 +211,8 @@ class todoModel extends model
|
||||
|
||||
|
||||
/**
|
||||
* 完成待办
|
||||
* Finish todo.
|
||||
* 完成一个待办。
|
||||
* Finish one todo.
|
||||
*
|
||||
* @param int $todoID
|
||||
* @access public
|
||||
@@ -220,12 +220,29 @@ class todoModel extends model
|
||||
*/
|
||||
public function finish(int $todoID): bool
|
||||
{
|
||||
return $this->dealFinishData($todoID);
|
||||
$todo = new stdClass();
|
||||
$todo->id = $todoID;
|
||||
$todo->status = 'done';
|
||||
$todo->finishedBy = $this->app->user->account;
|
||||
$todo->finishedDate = helper::now();
|
||||
$this->todoTao->updateRow($todoID, $todo);
|
||||
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$this->loadModel('action')->create('todo', $todoID, 'finished', '', 'done');
|
||||
|
||||
if(($this->config->edition == 'biz' || $this->config->edition == 'max'))
|
||||
{
|
||||
$todo = $this->todoTao->fetch($todoID);
|
||||
$feedbackID = $todo->objectID ? $todo->objectID : '' ;
|
||||
if($feedbackID) $this->loadModel('feedback')->updateStatus('todo', $feedbackID, 'done');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量完成待办.
|
||||
* Batch finish todo.
|
||||
* 批量完成待办。
|
||||
* Batch finish todos.
|
||||
*
|
||||
* @param int[] $todoIDList
|
||||
* @access public
|
||||
@@ -235,8 +252,8 @@ class todoModel extends model
|
||||
{
|
||||
foreach($todoIDList as $todoID)
|
||||
{
|
||||
$finishResult = $this->dealFinishData($todoID);
|
||||
if(!$finishResult) return $finishResult;
|
||||
$isFinished = $this->finish($todoID);
|
||||
if(!$isFinished) return $isFinished;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -508,35 +525,6 @@ class todoModel extends model
|
||||
return $projectIdList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理完成待办数据.
|
||||
* Deal finish todo data.
|
||||
*
|
||||
* @param int $todoID
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
private function dealFinishData(int $todoID): bool
|
||||
{
|
||||
$todo = new stdClass();
|
||||
$todo->id = $todoID;
|
||||
$todo->status = 'done';
|
||||
$todo->finishedBy = $this->app->user->account;
|
||||
$this->todoTao->updateRow($todoID, $todo);
|
||||
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$this->loadModel('action')->create('todo', $todoID, 'finished', '', 'done');
|
||||
|
||||
if(($this->config->edition == 'biz' || $this->config->edition == 'max'))
|
||||
{
|
||||
$todo = $this->todoTao->fetch($todoID);
|
||||
$feedbackID = $todo->objectID ? $todo->objectID : '' ;
|
||||
if($feedbackID) $this->loadModel('feedback')->updateStatus('todo', $feedbackID, 'done');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改待办事项的时间。
|
||||
* Edit the date of todo.
|
||||
|
||||
@@ -27,6 +27,9 @@ fields:
|
||||
prefix: '这是待办描述'
|
||||
- field: status
|
||||
range: 'wait,doing,done'
|
||||
|
||||
|
||||
|
||||
- field: finishedDate
|
||||
range: 1-9
|
||||
prefix: '2023-04-2'
|
||||
- field: closedDate
|
||||
range: 1-9
|
||||
prefix: '2023-04-2'
|
||||
|
||||
Reference in New Issue
Block a user