Skip to content

Commit f3bfb2f

Browse files
Zhao-githubgitee-org
authored andcommitted
!17 fix 修复wiki接口列表
Merge pull request !17 from Stefan阿钢/master
2 parents 2337e87 + 00d8d2d commit f3bfb2f

File tree

16 files changed

+134
-84
lines changed

16 files changed

+134
-84
lines changed

application/admin/controller/App.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function refreshAppSecret() {
9090
if ($id) {
9191
$res = AdminApp::update($data, ['id' => $id]);
9292
if ($res === false) {
93-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
93+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
9494
}
9595
}
9696

@@ -124,9 +124,9 @@ public function add() {
124124
}
125125
$res = AdminApp::create($data);
126126
if ($res === false) {
127-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
127+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
128128
} else {
129-
return $this->buildSuccess([]);
129+
return $this->buildSuccess();
130130
}
131131
}
132132

@@ -144,11 +144,15 @@ public function changeStatus() {
144144
'id' => $id
145145
]);
146146
if ($res === false) {
147-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
147+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
148148
} else {
149149
$appInfo = AdminApp::get($id);
150150
cache('AccessToken:' . $appInfo['app_secret'], null);
151-
return $this->buildSuccess([]);
151+
if($oldWiki = cache('WikiLogin:' . $id)) {
152+
cache('WikiLogin:' . $oldWiki, null);
153+
}
154+
155+
return $this->buildSuccess();
152156
}
153157
}
154158

@@ -176,11 +180,15 @@ public function edit() {
176180
}
177181
$res = AdminApp::update($data, ['id' => $postData['id']]);
178182
if ($res === false) {
179-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
183+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
180184
} else {
181185
$appInfo = AdminApp::get($postData['id']);
182186
cache('AccessToken:' . $appInfo['app_secret'], null);
183-
return $this->buildSuccess([]);
187+
if($oldWiki = cache('WikiLogin:' . $postData['id'])) {
188+
cache('WikiLogin:' . $oldWiki, null);
189+
}
190+
191+
return $this->buildSuccess();
184192
}
185193
}
186194

@@ -198,7 +206,10 @@ public function del() {
198206
cache('AccessToken:' . $appInfo['app_secret'], null);
199207

200208
AdminApp::destroy($id);
209+
if($oldWiki = cache('WikiLogin:' . $id)) {
210+
cache('WikiLogin:' . $oldWiki, null);
211+
}
201212

202-
return $this->buildSuccess([]);
213+
return $this->buildSuccess();
203214
}
204215
}

application/admin/controller/AppGroup.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public function changeStatus() {
8080
'id' => $id
8181
]);
8282
if ($res === false) {
83-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
83+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
8484
} else {
85-
return $this->buildSuccess([]);
85+
return $this->buildSuccess();
8686
}
8787
}
8888

@@ -95,9 +95,9 @@ public function add() {
9595
$postData = $this->request->post();
9696
$res = AdminAppGroup::create($postData);
9797
if ($res === false) {
98-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
98+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
9999
} else {
100-
return $this->buildSuccess([]);
100+
return $this->buildSuccess();
101101
}
102102
}
103103

@@ -110,9 +110,9 @@ public function edit() {
110110
$postData = $this->request->post();
111111
$res = AdminAppGroup::update($postData);
112112
if ($res === false) {
113-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
113+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
114114
} else {
115-
return $this->buildSuccess([]);
115+
return $this->buildSuccess();
116116
}
117117
}
118118

@@ -134,6 +134,6 @@ public function del() {
134134

135135
AdminAppGroup::destroy(['hash' => $hash]);
136136

137-
return $this->buildSuccess([]);
137+
return $this->buildSuccess();
138138
}
139139
}

application/admin/controller/Auth.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function add() {
109109
unset($postData['rules']);
110110
$res = AdminAuthGroup::create($postData);
111111
if ($res === false) {
112-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
112+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
113113
} else {
114114
if ($rules) {
115115
$insertData = [];
@@ -124,7 +124,7 @@ public function add() {
124124
(new AdminAuthRule())->saveAll($insertData);
125125
}
126126

127-
return $this->buildSuccess([]);
127+
return $this->buildSuccess();
128128
}
129129
}
130130

@@ -141,9 +141,9 @@ public function changeStatus() {
141141
'status' => $status
142142
]);
143143
if ($res === false) {
144-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
144+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
145145
} else {
146-
return $this->buildSuccess([]);
146+
return $this->buildSuccess();
147147
}
148148
}
149149

@@ -164,9 +164,9 @@ public function edit() {
164164
unset($postData['rules']);
165165
$res = AdminAuthGroup::update($postData);
166166
if ($res === false) {
167-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
167+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
168168
} else {
169-
return $this->buildSuccess([]);
169+
return $this->buildSuccess();
170170
}
171171
}
172172

@@ -199,7 +199,7 @@ public function del() {
199199
AdminAuthGroup::destroy($id);
200200
AdminAuthRule::destroy(['group_id' => $id]);
201201

202-
return $this->buildSuccess([]);
202+
return $this->buildSuccess();
203203
}
204204

205205
/**
@@ -226,9 +226,9 @@ public function delMember() {
226226
'uid' => $uid
227227
]);
228228
if ($res === false) {
229-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
229+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
230230
} else {
231-
return $this->buildSuccess([]);
231+
return $this->buildSuccess();
232232
}
233233
}
234234

application/admin/controller/Base.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public function __construct() {
2222
$this->userInfo = $this->request->API_ADMIN_USER_INFO;
2323
}
2424

25-
public function buildSuccess($data, $msg = '操作成功', $code = ReturnCode::SUCCESS) {
25+
public function buildSuccess($data = [], $msg = '操作成功', $code = ReturnCode::SUCCESS) {
2626
$return = [
2727
'code' => $code,
2828
'msg' => $msg,
2929
'data' => $data
3030
];
31-
if ($this->debug) {
31+
if (config('app.app_debug') && $this->debug) {
3232
$return['debug'] = $this->debug;
3333
}
3434

@@ -56,13 +56,13 @@ public function updateUserInfo($data, $isDetail = false) {
5656
cache('Login:' . $apiAuth, json_encode($this->userInfo), config('apiadmin.ONLINE_TIME'));
5757
}
5858

59-
public function buildFailed($code, $msg, $data = []) {
59+
public function buildFailed($code, $msg = '操作失败', $data = []) {
6060
$return = [
6161
'code' => $code,
6262
'msg' => $msg,
6363
'data' => $data
6464
];
65-
if ($this->debug) {
65+
if (config('app.app_debug') && $this->debug) {
6666
$return['debug'] = $this->debug;
6767
}
6868

application/admin/controller/Fields.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ public function add() {
104104
cache('ResponseFieldsRule:' . $postData['hash'], null);
105105

106106
if ($res === false) {
107-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
107+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
108108
} else {
109-
return $this->buildSuccess('操作成功');
109+
return $this->buildSuccess();
110110
}
111111
}
112112

@@ -127,9 +127,9 @@ public function edit() {
127127
cache('ResponseFieldsRule:' . $postData['hash'], null);
128128

129129
if ($res === false) {
130-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
130+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
131131
} else {
132-
return $this->buildSuccess([]);
132+
return $this->buildSuccess();
133133
}
134134
}
135135

@@ -152,7 +152,7 @@ public function del() {
152152

153153
AdminFields::destroy($id);
154154

155-
return $this->buildSuccess([]);
155+
return $this->buildSuccess();
156156
}
157157

158158
/**
@@ -200,7 +200,7 @@ public function upload() {
200200
cache('RequestFields:Rule:' . $hash, null);
201201
cache('ResponseFieldsRule:' . $hash, null);
202202

203-
return $this->buildSuccess([]);
203+
return $this->buildSuccess();
204204
}
205205

206206
private function handle($data, &$dataArr, $prefix = 'data', $index = 'data') {

application/admin/controller/InterfaceGroup.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ public function changeStatus() {
7979
'id' => $id
8080
]);
8181
if ($res === false) {
82-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
82+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
8383
} else {
84-
return $this->buildSuccess([]);
84+
return $this->buildSuccess();
8585
}
8686
}
8787

@@ -94,9 +94,9 @@ public function add() {
9494
$postData = $this->request->post();
9595
$res = AdminGroup::create($postData);
9696
if ($res === false) {
97-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
97+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
9898
} else {
99-
return $this->buildSuccess([]);
99+
return $this->buildSuccess();
100100
}
101101
}
102102

@@ -109,9 +109,9 @@ public function edit() {
109109
$postData = $this->request->post();
110110
$res = AdminGroup::update($postData);
111111
if ($res === false) {
112-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
112+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
113113
} else {
114-
return $this->buildSuccess([]);
114+
return $this->buildSuccess();
115115
}
116116
}
117117

@@ -153,6 +153,6 @@ public function del() {
153153

154154
AdminGroup::destroy(['hash' => $hash]);
155155

156-
return $this->buildSuccess([]);
156+
return $this->buildSuccess();
157157
}
158158
}

application/admin/controller/InterfaceList.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public function add() {
7878

7979
$res = AdminList::create($postData);
8080
if ($res === false) {
81-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
81+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
8282
} else {
83-
return $this->buildSuccess([]);
83+
return $this->buildSuccess();
8484
}
8585
}
8686

@@ -98,11 +98,11 @@ public function changeStatus() {
9898
'hash' => $hash
9999
]);
100100
if ($res === false) {
101-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
101+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
102102
} else {
103103
cache('ApiInfo:' . $hash, null);
104104

105-
return $this->buildSuccess([]);
105+
return $this->buildSuccess();
106106
}
107107
}
108108

@@ -119,11 +119,11 @@ public function edit() {
119119

120120
$res = AdminList::update($postData);
121121
if ($res === false) {
122-
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
122+
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR);
123123
} else {
124124
cache('ApiInfo:' . $postData['hash'], null);
125125

126-
return $this->buildSuccess([]);
126+
return $this->buildSuccess();
127127
}
128128
}
129129

@@ -166,7 +166,7 @@ public function del() {
166166

167167
cache('ApiInfo:' . $hash, null);
168168

169-
return $this->buildSuccess([]);
169+
return $this->buildSuccess();
170170
}
171171

172172
/**
@@ -183,14 +183,14 @@ public function refresh() {
183183

184184
$tplOriginStr = file_get_contents($tplPath);
185185
$listInfo = AdminList::all(['status' => 1]);
186-
$tplStr = '';
186+
$tplStr = [];
187187
foreach ($listInfo as $value) {
188-
$tplStr .= 'Route::rule(\'' . addslashes($value->hash) . '\',\'api/' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\')->middleware([\'ApiAuth\', \'ApiPermission\', \'RequestFilter\', \'ApiLog\']);';
188+
array_push($tplStr, 'Route::rule(\'' . addslashes($value->hash) . '\',\'api/' . addslashes($value->api_class) . '\', \'' . $methodArr[$value->method] . '\')->middleware([\'ApiAuth\', \'ApiPermission\', \'RequestFilter\', \'ApiLog\']);');
189189
}
190-
$tplOriginStr = str_replace(['{$API_RULE}'], [$tplStr], $tplOriginStr);
190+
$tplOriginStr = str_replace(['{$API_RULE}'], [implode($tplStr, "\n ")], $tplOriginStr);
191191

192192
file_put_contents($apiRoutePath, $tplOriginStr);
193193

194-
return $this->buildSuccess([]);
194+
return $this->buildSuccess();
195195
}
196196
}

application/admin/controller/Log.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function del() {
6464
}
6565
AdminUserAction::destroy($id);
6666

67-
return $this->buildSuccess([]);
67+
return $this->buildSuccess();
6868

6969
}
7070

0 commit comments

Comments
 (0)