新增后台基础公共库
This commit is contained in:
parent
4a5993160f
commit
d53b0bae73
@ -126,6 +126,25 @@ class CatchAdmin
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月12日
|
||||
* @return array
|
||||
*/
|
||||
public static function getModulesInfo(): array
|
||||
{
|
||||
$modules = [];
|
||||
foreach (self::getModulesDirectory() as $module) {
|
||||
$moduleInfo = self::getModuleInfo($module);
|
||||
$modules[] = [
|
||||
'value' => $moduleInfo['alias'],
|
||||
'title' => $moduleInfo['name'],
|
||||
];
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年11月30日
|
||||
|
@ -355,12 +355,12 @@ class CatchForm
|
||||
*/
|
||||
private function selectField($field)
|
||||
{
|
||||
$select = sprintf('<select name="%s">', $field['name']);
|
||||
$select = sprintf('<select name="%s" %s>', $field['name'], $field['verify'] ?? '');
|
||||
|
||||
$default = $field['default'] ?? '';
|
||||
|
||||
foreach ($field['options'] as $key => $option) {
|
||||
$select .= sprintf('<option value="%s"%s>%s</option>', $key, $default == $key ? ' selected' : '',$option);
|
||||
$select .= sprintf('<option value="%s"%s>%s</option>', $option['value'], $default == $key ? ' selected' : '',$option['title']);
|
||||
}
|
||||
|
||||
return $select . '</select>';
|
||||
|
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace catcher;
|
||||
|
||||
use think\facade\View;
|
||||
use think\Paginator;
|
||||
use think\Response;
|
||||
|
||||
class CatchResponse
|
||||
{
|
||||
@ -16,11 +18,13 @@ class CatchResponse
|
||||
*/
|
||||
public static function success($data = [], $msg = 'success', $code = 10000): \think\response\Json
|
||||
{
|
||||
return json([
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
'data' => $data,
|
||||
]);
|
||||
if (request()->isAjax()) {
|
||||
return json([
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,13 +51,18 @@ class CatchResponse
|
||||
* @time 2019年12月02日
|
||||
* @param string $msg
|
||||
* @param int $code
|
||||
* @return \think\response\Json
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function fail($msg = '', $code = 10001): \think\response\Json
|
||||
public static function fail($msg = '', $code = 10001)
|
||||
{
|
||||
return json([
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
]);
|
||||
if (request()->isAjax()) {
|
||||
return json([
|
||||
'code' => $code,
|
||||
'msg' => $msg,
|
||||
]);
|
||||
}
|
||||
|
||||
return Response::create(config('catch.error'), 'view', $code)->assign(['msg' => $msg]);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ use think\facade\View;
|
||||
|
||||
abstract class CatchController
|
||||
{
|
||||
protected $middleware = ['check_auth'];
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年11月28日
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace cather\exceptions;
|
||||
namespace catcher\exceptions;
|
||||
|
||||
class LoginFailedException extends \Exception
|
||||
{
|
||||
protected $code = 10002;
|
||||
}
|
||||
protected $code = 10010;
|
||||
}
|
@ -1 +1,9 @@
|
||||
<?php
|
||||
namespace catcher\exceptions;
|
||||
|
||||
class PermissionForbiddenException extends \Exception
|
||||
{
|
||||
protected $code = 10005;
|
||||
|
||||
protected $message = 'permission forbidden';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user