This commit is contained in:
mayue
2021-10-26 14:37:42 +08:00
parent aad6d4c76a
commit 17118b4595
3 changed files with 22 additions and 20 deletions
+1 -15
View File
@@ -414,21 +414,7 @@ class api extends control
{
if(helper::isAjaxRequest() && !empty($_POST))
{
$this->loadModel('api');
$now = helper::now();
$userId = $this->app->user->account;
$params = fixer::input('post')
->remove('type')
->skipSpecial('params,response')
->add('addedBy', $userId)
->add('addedDate', $now)
->add('editedBy', $userId)
->add('editedDate', $now)
->setDefault('product,module', 0)
->get();
$changes = $this->api->update($apiID, $params);
$changes = $this->api->update($apiID);
if(dao::isError()) return $this->sendError(dao::getError());
if($changes)
+20 -5
View File
@@ -192,14 +192,29 @@ class apiModel extends model
/**
* Update an api doc.
*
* @param int $id
* @param object $data
* @param int $apiID
* @access public
* @return void
*/
public function update($id, $data)
public function update($apiID)
{
$oldApi = $this->dao->findByID($id)->from(TABLE_API)->fetch();
$oldApi = $this->dao->findByID($apiID)->from(TABLE_API)->fetch();
if(!empty($_POST['editedDate']) and $oldApi->editedDate != $this->post->editedDate)
{
dao::$errors[] = $this->lang->error->editedByOther;
return false;
}
$now = helper::now();
$account = $this->app->user->account;
$data = fixer::input('post')
->remove('type')
->skipSpecial('params,response')
->add('editedBy', $account)
->add('editedDate', $now)
->setDefault('product,module', 0)
->get();
$data->id = $oldApi->id;
$data->version = $oldApi->version + 1;
@@ -212,7 +227,7 @@ class apiModel extends model
->data($data)
->autoCheck()
->batchCheck($this->config->api->edit->requiredFields, 'notempty')
->where('id')->eq($id)
->where('id')->eq($apiID)
->exec();
return common::createChanges($oldApi, $data);
+1
View File
@@ -227,6 +227,7 @@ js::set('api', $api);
<tr>
<td colspan='3' class='text-center form-actions'>
<?php echo html::submitButton();?>
<?php echo html::hidden('editedDate', $api->editedDate);?>
<?php if(empty($gobackLink)) echo html::backButton($lang->goback, "data-app='{$app->tab}'");?>
<?php if(!empty($gobackLink)) echo html::a($gobackLink, $lang->goback, '', "class='btn btn-back btn-wide'");?>
</td>