* Adjusted todo model the assignTo and getCount function.
This commit is contained in:
+7
-12
@@ -579,32 +579,27 @@ class todoModel extends model
|
||||
*/
|
||||
public function assignTo(object $todo): bool
|
||||
{
|
||||
$result = $this->todoTao->updateRow((int)$todo->id, $todo);
|
||||
$todoID = (int)$todo->id;
|
||||
$result = $this->todoTao->updateRow($todoID, $todo);
|
||||
if(!$result) return false;
|
||||
|
||||
$this->loadModel('action')->create('todo', (int)$todo->id, 'assigned', '', $todo->assignedTo);
|
||||
$this->loadModel('action')->create('todo', $todoID, 'assigned', '', $todo->assignedTo);
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待办事项的数量。
|
||||
* Get todo count.
|
||||
*
|
||||
* @param string $account
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function getCount($account = '')
|
||||
public function getCount(string $account = ''): int
|
||||
{
|
||||
if(empty($account)) $account = $this->app->user->account;
|
||||
return $this->dao->select('count(*) as count')->from(TABLE_TODO)
|
||||
->where('cycle')->eq('0')
|
||||
->andWhere('deleted')->eq('0')
|
||||
->andWhere('vision')->eq($this->config->vision)
|
||||
->andWhere('account', true)->eq($account)
|
||||
->orWhere('assignedTo')->eq($account)
|
||||
->orWhere('finishedBy')->eq($account)
|
||||
->markRight(1)
|
||||
->fetch('count');
|
||||
|
||||
return $this->todoTao->getTodoCountByAccount($account);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -324,4 +324,25 @@ class todoTao extends todoModel
|
||||
$this->dao->update(TABLE_TODO)->set('date')->eq($date)->where('id')->in($todoIdList)->exec();
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的待办事项数量。
|
||||
* Get todo count on the account.
|
||||
*
|
||||
* @param string $account
|
||||
* @access protected
|
||||
* @return int
|
||||
*/
|
||||
protected function getTodoCountByAccount(string $account): int
|
||||
{
|
||||
return $this->dao->select('count(*) as count')->from(TABLE_TODO)
|
||||
->where('cycle')->eq('0')
|
||||
->andWhere('deleted')->eq('0')
|
||||
->andWhere('vision')->eq($this->config->vision)
|
||||
->andWhere('account', true)->eq($account)
|
||||
->orWhere('assignedTo')->eq($account)
|
||||
->orWhere('finishedBy')->eq($account)
|
||||
->markRight(1)
|
||||
->fetch('count');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user