mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
优化 成功/失败 函数默认参数
This commit is contained in:
parent
5c494bc01f
commit
5247f32e27
@ -90,7 +90,7 @@ class App extends Base {
|
|||||||
if ($id) {
|
if ($id) {
|
||||||
$res = AdminApp::update($data, ['id' => $id]);
|
$res = AdminApp::update($data, ['id' => $id]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,9 +124,9 @@ class App extends Base {
|
|||||||
}
|
}
|
||||||
$res = AdminApp::create($data);
|
$res = AdminApp::create($data);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,11 +144,11 @@ class App extends Base {
|
|||||||
'id' => $id
|
'id' => $id
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
$appInfo = AdminApp::get($id);
|
$appInfo = AdminApp::get($id);
|
||||||
cache('AccessToken:' . $appInfo['app_secret'], null);
|
cache('AccessToken:' . $appInfo['app_secret'], null);
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,11 +176,11 @@ class App extends Base {
|
|||||||
}
|
}
|
||||||
$res = AdminApp::update($data, ['id' => $postData['id']]);
|
$res = AdminApp::update($data, ['id' => $postData['id']]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
$appInfo = AdminApp::get($postData['id']);
|
$appInfo = AdminApp::get($postData['id']);
|
||||||
cache('AccessToken:' . $appInfo['app_secret'], null);
|
cache('AccessToken:' . $appInfo['app_secret'], null);
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +199,6 @@ class App extends Base {
|
|||||||
|
|
||||||
AdminApp::destroy($id);
|
AdminApp::destroy($id);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,9 +80,9 @@ class AppGroup extends Base {
|
|||||||
'id' => $id
|
'id' => $id
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,9 +95,9 @@ class AppGroup extends Base {
|
|||||||
$postData = $this->request->post();
|
$postData = $this->request->post();
|
||||||
$res = AdminAppGroup::create($postData);
|
$res = AdminAppGroup::create($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,9 +110,9 @@ class AppGroup extends Base {
|
|||||||
$postData = $this->request->post();
|
$postData = $this->request->post();
|
||||||
$res = AdminAppGroup::update($postData);
|
$res = AdminAppGroup::update($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +134,6 @@ class AppGroup extends Base {
|
|||||||
|
|
||||||
AdminAppGroup::destroy(['hash' => $hash]);
|
AdminAppGroup::destroy(['hash' => $hash]);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class Auth extends Base {
|
|||||||
unset($postData['rules']);
|
unset($postData['rules']);
|
||||||
$res = AdminAuthGroup::create($postData);
|
$res = AdminAuthGroup::create($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
if ($rules) {
|
if ($rules) {
|
||||||
$insertData = [];
|
$insertData = [];
|
||||||
@ -124,7 +124,7 @@ class Auth extends Base {
|
|||||||
(new AdminAuthRule())->saveAll($insertData);
|
(new AdminAuthRule())->saveAll($insertData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,9 +141,9 @@ class Auth extends Base {
|
|||||||
'status' => $status
|
'status' => $status
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,9 +164,9 @@ class Auth extends Base {
|
|||||||
unset($postData['rules']);
|
unset($postData['rules']);
|
||||||
$res = AdminAuthGroup::update($postData);
|
$res = AdminAuthGroup::update($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ class Auth extends Base {
|
|||||||
AdminAuthGroup::destroy($id);
|
AdminAuthGroup::destroy($id);
|
||||||
AdminAuthRule::destroy(['group_id' => $id]);
|
AdminAuthRule::destroy(['group_id' => $id]);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,9 +226,9 @@ class Auth extends Base {
|
|||||||
'uid' => $uid
|
'uid' => $uid
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class Base extends Controller {
|
|||||||
$this->userInfo = $this->request->API_ADMIN_USER_INFO;
|
$this->userInfo = $this->request->API_ADMIN_USER_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildSuccess($data, $msg = '操作成功', $code = ReturnCode::SUCCESS) {
|
public function buildSuccess($data = [], $msg = '操作成功', $code = ReturnCode::SUCCESS) {
|
||||||
$return = [
|
$return = [
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
@ -56,7 +56,7 @@ class Base extends Controller {
|
|||||||
cache('Login:' . $apiAuth, json_encode($this->userInfo), config('apiadmin.ONLINE_TIME'));
|
cache('Login:' . $apiAuth, json_encode($this->userInfo), config('apiadmin.ONLINE_TIME'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildFailed($code, $msg, $data = []) {
|
public function buildFailed($code, $msg = '操作失败', $data = []) {
|
||||||
$return = [
|
$return = [
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
|
@ -104,9 +104,9 @@ class Fields extends Base {
|
|||||||
cache('ResponseFieldsRule:' . $postData['hash'], null);
|
cache('ResponseFieldsRule:' . $postData['hash'], null);
|
||||||
|
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess('操作成功');
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,9 +127,9 @@ class Fields extends Base {
|
|||||||
cache('ResponseFieldsRule:' . $postData['hash'], null);
|
cache('ResponseFieldsRule:' . $postData['hash'], null);
|
||||||
|
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ class Fields extends Base {
|
|||||||
|
|
||||||
AdminFields::destroy($id);
|
AdminFields::destroy($id);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,7 +200,7 @@ class Fields extends Base {
|
|||||||
cache('RequestFields:Rule:' . $hash, null);
|
cache('RequestFields:Rule:' . $hash, null);
|
||||||
cache('ResponseFieldsRule:' . $hash, null);
|
cache('ResponseFieldsRule:' . $hash, null);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function handle($data, &$dataArr, $prefix = 'data', $index = 'data') {
|
private function handle($data, &$dataArr, $prefix = 'data', $index = 'data') {
|
||||||
|
@ -79,9 +79,9 @@ class InterfaceGroup extends Base {
|
|||||||
'id' => $id
|
'id' => $id
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,9 +94,9 @@ class InterfaceGroup extends Base {
|
|||||||
$postData = $this->request->post();
|
$postData = $this->request->post();
|
||||||
$res = AdminGroup::create($postData);
|
$res = AdminGroup::create($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,9 +109,9 @@ class InterfaceGroup extends Base {
|
|||||||
$postData = $this->request->post();
|
$postData = $this->request->post();
|
||||||
$res = AdminGroup::update($postData);
|
$res = AdminGroup::update($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,6 +153,6 @@ class InterfaceGroup extends Base {
|
|||||||
|
|
||||||
AdminGroup::destroy(['hash' => $hash]);
|
AdminGroup::destroy(['hash' => $hash]);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,9 @@ class InterfaceList extends Base {
|
|||||||
|
|
||||||
$res = AdminList::create($postData);
|
$res = AdminList::create($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,11 +98,11 @@ class InterfaceList extends Base {
|
|||||||
'hash' => $hash
|
'hash' => $hash
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
cache('ApiInfo:' . $hash, null);
|
cache('ApiInfo:' . $hash, null);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,11 +119,11 @@ class InterfaceList extends Base {
|
|||||||
|
|
||||||
$res = AdminList::update($postData);
|
$res = AdminList::update($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
cache('ApiInfo:' . $postData['hash'], null);
|
cache('ApiInfo:' . $postData['hash'], null);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ class InterfaceList extends Base {
|
|||||||
|
|
||||||
cache('ApiInfo:' . $hash, null);
|
cache('ApiInfo:' . $hash, null);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,6 +191,6 @@ class InterfaceList extends Base {
|
|||||||
|
|
||||||
file_put_contents($apiRoutePath, $tplOriginStr);
|
file_put_contents($apiRoutePath, $tplOriginStr);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ class Log extends Base {
|
|||||||
}
|
}
|
||||||
AdminUserAction::destroy($id);
|
AdminUserAction::destroy($id);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class Menu extends Base {
|
|||||||
|
|
||||||
return $this->buildSuccess([
|
return $this->buildSuccess([
|
||||||
'list' => $list
|
'list' => $list
|
||||||
], '登录成功');
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,9 +42,9 @@ class Menu extends Base {
|
|||||||
}
|
}
|
||||||
$res = AdminMenu::create($postData);
|
$res = AdminMenu::create($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,9 +61,9 @@ class Menu extends Base {
|
|||||||
'hide' => $status
|
'hide' => $status
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,9 +79,9 @@ class Menu extends Base {
|
|||||||
}
|
}
|
||||||
$res = AdminMenu::update($postData);
|
$res = AdminMenu::update($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ class Menu extends Base {
|
|||||||
} else {
|
} else {
|
||||||
AdminMenu::destroy($id);
|
AdminMenu::destroy($id);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@ use app\util\ReturnCode;
|
|||||||
class Miss extends Base {
|
class Miss extends Base {
|
||||||
public function index() {
|
public function index() {
|
||||||
if ($this->request->isOptions()) {
|
if ($this->request->isOptions()) {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
} else {
|
} else {
|
||||||
return $this->buildFailed(ReturnCode::INVALID, '接口地址异常', []);
|
return $this->buildFailed(ReturnCode::INVALID, '接口地址异常');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,14 +95,14 @@ class User extends Base {
|
|||||||
}
|
}
|
||||||
$res = AdminUser::create($postData);
|
$res = AdminUser::create($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
AdminAuthGroupAccess::create([
|
AdminAuthGroupAccess::create([
|
||||||
'uid' => $res->id,
|
'uid' => $res->id,
|
||||||
'group_id' => $groups
|
'group_id' => $groups
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,9 +160,9 @@ class User extends Base {
|
|||||||
'status' => $status
|
'status' => $status
|
||||||
]);
|
]);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ class User extends Base {
|
|||||||
}
|
}
|
||||||
$res = AdminUser::update($postData);
|
$res = AdminUser::update($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
$has = AdminAuthGroupAccess::get(['uid' => $postData['id']]);
|
$has = AdminAuthGroupAccess::get(['uid' => $postData['id']]);
|
||||||
if ($has) {
|
if ($has) {
|
||||||
@ -202,7 +202,7 @@ class User extends Base {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,13 +232,13 @@ class User extends Base {
|
|||||||
unset($postData['head_img']);
|
unset($postData['head_img']);
|
||||||
$res = AdminUser::update($postData);
|
$res = AdminUser::update($postData);
|
||||||
if ($res === false) {
|
if ($res === false) {
|
||||||
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
|
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
|
||||||
} else {
|
} else {
|
||||||
$userData = AdminUserData::get(['uid' => $postData['id']]);
|
$userData = AdminUserData::get(['uid' => $postData['id']]);
|
||||||
$userData->head_img = $headImg;
|
$userData->head_img = $headImg;
|
||||||
$userData->save();
|
$userData->save();
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ class User extends Base {
|
|||||||
AdminUser::destroy($id);
|
AdminUser::destroy($id);
|
||||||
AdminAuthGroupAccess::destroy(['uid' => $id]);
|
AdminAuthGroupAccess::destroy(['uid' => $id]);
|
||||||
|
|
||||||
return $this->buildSuccess([]);
|
return $this->buildSuccess();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class Base extends Controller {
|
|||||||
// $this->userInfo = ''; 这部分初始化用户信息可以参考admin模块下的Base去自行处理
|
// $this->userInfo = ''; 这部分初始化用户信息可以参考admin模块下的Base去自行处理
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildSuccess($data, $msg = '操作成功', $code = ReturnCode::SUCCESS) {
|
public function buildSuccess($data = [], $msg = '操作成功', $code = ReturnCode::SUCCESS) {
|
||||||
$return = [
|
$return = [
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
@ -33,7 +33,7 @@ class Base extends Controller {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildFailed($code, $msg, $data = []) {
|
public function buildFailed($code, $msg = '操作失败', $data = []) {
|
||||||
$return = [
|
$return = [
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
|
@ -20,7 +20,7 @@ class Base extends Controller {
|
|||||||
$this->appInfo = $this->request->API_WIKI_USER_INFO;
|
$this->appInfo = $this->request->API_WIKI_USER_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildSuccess($data, $msg = '操作成功', $code = ReturnCode::SUCCESS) {
|
public function buildSuccess($data = [], $msg = '操作成功', $code = ReturnCode::SUCCESS) {
|
||||||
$return = [
|
$return = [
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
@ -30,7 +30,7 @@ class Base extends Controller {
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildFailed($code, $msg, $data = []) {
|
public function buildFailed($code, $msg = '操作失败', $data = []) {
|
||||||
$return = [
|
$return = [
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user