* Refactor the create and update method of entry.

This commit is contained in:
wangxuepeng
2023-10-23 09:30:03 +08:00
parent bb5a6b22cd
commit b9acfb080e
5 changed files with 55 additions and 27 deletions
+18 -2
View File
@@ -43,7 +43,15 @@ class entry extends control
{
if($_POST)
{
$id = $this->entry->create();
$entry = form::data($this->config->entry->form->create)
->setIF($this->post->allIP === 'on', 'ip', '*')
->setIF($this->post->freePasswd == '1', 'account', '')
->add('createdBy', $this->app->user->account)
->add('createdDate', helper::now())
->remove('allIP')
->get();
$id = $this->entry->create($entry);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->loadModel('action')->create('entry', $id, 'created');
@@ -67,7 +75,15 @@ class entry extends control
{
if($_POST)
{
$changes = $this->entry->update($id);
$entry = form::data($this->config->entry->form->create)
->setIF($this->post->allIP === 'on', 'ip', '*')
->setIF($this->post->freePasswd == '1', 'account', '')
->add('createdBy', $this->app->user->account)
->add('createdDate', helper::now())
->remove('allIP')
->get();
$changes = $this->entry->update($id, $entry);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
if($changes)