Commit bda6b766 authored by rlgy's avatar rlgy

结构规范

parent 9b1035ad
......@@ -24,10 +24,12 @@ class BaseResponse extends Response
if (empty($data)) {
$return['code'] = 1;
$return['msg'] = '数据为空';
} else {
} elseif (is_array($data) && !isset($data['code'])) {
$return['code'] = 0;
$return['count'] = count($data);
$return['data'] = $data;
} else {
$return = $data;
}
\Yii::$app->response->data = $return;
parent::send();
......
......@@ -52,6 +52,6 @@ class ArticleController extends BaseController
}
$data = Article::getList($page, $limit, $condition);
Yii::$app->response->data = $data;
return $data;
}
}
\ No newline at end of file
......@@ -25,6 +25,7 @@ class NoticeController extends BaseController
* @var $page
* @var $limit
* @var $condition 筛选条件
* @return array
*/
public function actionList()
{
......@@ -62,7 +63,6 @@ class NoticeController extends BaseController
$condition[] = ['>=', 'update_at', $post['update_at']];
}
$data = Notice::getList($page, $limit, $condition);
Yii::$app->response->data = $data;
return $data;
}
}
\ No newline at end of file
......@@ -24,26 +24,6 @@ class SiteController extends BaseController
*/
public function actionError()
{
// $page = 'error';
// $e = Yii::$app->errorHandler->exception;
// $errMsg = $e->getMessage();
// $errCode = isset($e->statusCode) ? $e->statusCode :
// (isset(Yii::$app->response->statusCode) ? Yii::$app->response->statusCode : 500);
// if ($e !== null) {
//
// switch ($errCode) {
// case 404:
// $page = 404;
// break;
// case 500:
// $page = 500;
// break;
// }
// }
//
// return $this->render($page, [
// 'code' => isset($errCode) ? $errCode : 500,
// 'message' => isset($errMsg) ? $errMsg : ''
// ]);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment