123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\common\base\controller;
- use app\common\base\request\BaseRequest;
- use think\Controller;
- /**
- * 后台控制器基类
- * 接口方法权限 必传参数 接口返回 错误抛出 通用参数处理
- */
- abstract class BaseController
- {
- private $_request = null;
- private $_params = [];
- private $_token = null;
- protected $needToken = true;
- // 初始化
- public function __construct() {
- $this->beforeInit();
- $this->zskkInit();
- $this->afterInit();
- }
- protected function beforeInit() {}
- protected function afterInit() {}
- protected function zskkInit() {
- $this->beforeSetRequest();
- $this->mountRequest();
- $this->afterSetRequest();
- }
- protected function setToken($token) {
- $this->_token = $token;
- }
- protected function getToken() {
- return $this->_token;
- }
- protected function setParams($params) {
- $this->_params = $params;
- }
- protected function getParams() {
- return $this->_params;
- }
- protected function getRequest() {
- return $this->_request;
- }
- protected function setRequest($request) {
- $this->_request = $request;
- }
- protected abstract function checkToken();
- protected abstract function success($data);
- protected abstract function mountRequest();
- protected abstract function beforeSetRequest();
- protected abstract function afterSetRequest();
- }
|