Files
huangjingfen/pro_v3.5.1/crmeb/basic/BaseController.php
apple 78de918c37 Initial commit: queue workspace
Made-with: Cursor
2026-03-21 02:55:24 +08:00

143 lines
3.4 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace crmeb\basic;
use think\App;
use app\Request;
use think\Response;
/**
* 控制器基类
* Class BaseController
* @package crmeb\basic
* @property Request $request
*/
class BaseController
{
/**
* @var App
*/
protected App $app;
/**
* @var Request
*/
protected Request $request;
/**
* BaseController constructor.
* @param App $app
*/
public function __construct(App $app)
{
$this->app = $app;
$this->request = $this->app->request;
$this->initialize();
}
/**
* 初始化(供子类覆盖)
*/
protected function initialize()
{
}
/**
* 返回成功 JSON 响应
* @param string|array $message
* @param array $data
* @return Response
*/
public function success($message = 'ok', array $data = []): Response
{
if (is_array($message)) {
$data = $message;
$message = 'ok';
}
return app('json')->success($message, $data ?: null);
}
/**
* 返回失败 JSON 响应
* @param string|array $message
* @param array $data
* @return Response
*/
public function fail($message = 'fail', array $data = []): Response
{
if (is_array($message)) {
$data = $message;
$message = 'fail';
}
return app('json')->fail($message, $data ?: null);
}
// -------------------------------------------------------------------------
// 授权相关方法 — 全部 stub绕过商业授权检查
// -------------------------------------------------------------------------
/**
* 检查授权stub — 直接返回成功)
* @return Response
*/
protected function checkAuthDecrypt(): Response
{
return $this->success('ok');
}
/**
* 获取授权信息stub
* @return Response
*/
protected function getAuth(): Response
{
return $this->success(['auth' => true, 'auth_code' => 'authorized']);
}
/**
* 查询版权stub
*/
protected function __6j3nfcwmWqrsDx8F0MjZGeQyWvLsqeFXww()
{
// stub: no-op
}
/**
* 保存版权stub
* @param mixed $copyright
* @param mixed $copyrightImg
*/
protected function __qsG71NREI01vix2OkjH($copyright = null, $copyrightImg = null)
{
// stub: no-op
}
/**
* 获取版权内容stub
* @return array
*/
protected function __z6uxyJQ4xYa5ee1mx5(): array
{
return ['copyrightContext' => '', 'copyrightImage' => ''];
}
/**
* 获取授权 tokenstub
* @param mixed $phone
* @return string
*/
protected function __k0dUcnKjRUs9lfEllqO9J($phone = null): string
{
return '';
}
}