modified 完成规则生产方缓存支持

This commit is contained in:
zhaoxiang 2018-03-14 01:39:32 +08:00
parent 551bc0b009
commit 55268df761
2 changed files with 27 additions and 2 deletions

View File

@ -97,6 +97,11 @@ class Fields extends Base {
$postData['default'] = $postData['defaults'];
unset($postData['defaults']);
$res = AdminFields::create($postData);
cache('RequestFields:NewRule:' . $postData['hash'], null);
cache('RequestFields:Rule:' . $postData['hash'], null);
cache('ResponseFieldsRule:' . $postData['hash'], null);
if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else {
@ -115,6 +120,11 @@ class Fields extends Base {
$postData['default'] = $postData['defaults'];
unset($postData['defaults']);
$res = AdminFields::update($postData);
cache('RequestFields:NewRule:' . $postData['hash'], null);
cache('RequestFields:Rule:' . $postData['hash'], null);
cache('ResponseFieldsRule:' . $postData['hash'], null);
if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else {
@ -126,12 +136,19 @@ class Fields extends Base {
* 字段删除
* @author zhaoxiang <zhaoxiang051405@gmail.com>
* @return array
* @throws \think\exception\DbException
*/
public function del() {
$id = $this->request->get('id');
if (!$id) {
return $this->buildFailed(ReturnCode::EMPTY_PARAMS, '缺少必要参数');
}
$fieldsInfo = AdminFields::get($id);
cache('RequestFields:NewRule:' . $fieldsInfo->hash, null);
cache('RequestFields:Rule:' . $fieldsInfo->hash, null);
cache('ResponseFieldsRule:' . $fieldsInfo->hash, null);
AdminFields::destroy($id);
return $this->buildSuccess([]);
@ -178,6 +195,10 @@ class Fields extends Base {
(new AdminFields())->insertAll($addData);
}
cache('RequestFields:NewRule:' . $hash, null);
cache('RequestFields:Rule:' . $hash, null);
cache('ResponseFieldsRule:' . $hash, null);
return $this->buildSuccess([]);
}

View File

@ -91,16 +91,17 @@ class InterfaceList extends Base {
* @author zhaoxiang <zhaoxiang051405@gmail.com>
*/
public function changeStatus() {
$id = $this->request->get('id');
$hash = $this->request->get('hash');
$status = $this->request->get('status');
$res = AdminList::update([
'status' => $status
], [
'id' => $id
'hash' => $hash
]);
if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else {
cache('ApiInfo:' . $hash, null);
return $this->buildSuccess([]);
}
}
@ -116,6 +117,7 @@ class InterfaceList extends Base {
if ($res === false) {
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
} else {
cache('ApiInfo:' . $postData['hash'], null);
return $this->buildSuccess([]);
}
}
@ -157,6 +159,8 @@ class InterfaceList extends Base {
AdminList::destroy(['hash' => $hash]);
AdminFields::destroy(['hash' => $hash]);
cache('ApiInfo:' . $hash, null);
return $this->buildSuccess([]);
}