@@ -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}
0 commit comments