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