Compare commits
34 Commits
Author | SHA1 | Date | |
---|---|---|---|
7283737f8e | |||
|
4b652aac8d | ||
|
09d4686437 | ||
|
425113a0d7 | ||
|
ca2af73a2c | ||
|
5d3ce0ff12 | ||
|
3d39d38287 | ||
|
b5c8abcb56 | ||
|
b0712fac25 | ||
|
b0d73eaccd | ||
|
ea86e944cf | ||
|
4cba3c47d9 | ||
|
af0167a44b | ||
|
92b1551284 | ||
|
e5af2418b0 | ||
|
4ad326a9af | ||
|
2418b0caa3 | ||
|
37034552e4 | ||
|
f1257d99b6 | ||
|
095c5cd81c | ||
|
1d3938a1dd | ||
|
727dc88fb1 | ||
|
0d94b22820 | ||
|
929e5cb543 | ||
|
c8414d2e0b | ||
|
07ef5cf755 | ||
|
af61b6a96b | ||
|
dc8c32e678 | ||
|
c1c9c881f7 | ||
|
47047b9c65 | ||
|
6b1b64a05d | ||
|
f128cb7e6d | ||
|
89680d3754 | ||
|
28ff4ea2d9 |
@ -2,7 +2,7 @@
|
||||
"name": "webman/admin",
|
||||
"type": "project",
|
||||
"license": "MIT",
|
||||
"description": "Webman Admin",
|
||||
"description": "基于Webman官方的Admin修改",
|
||||
"require": {
|
||||
"workerman/webman-framework": ">=1.4",
|
||||
"illuminate/database": ">=7.30",
|
||||
|
@ -1,13 +1,14 @@
|
||||
<?php
|
||||
namespace plugin\admin\api;
|
||||
|
||||
use ReflectionException;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
use Webman\MiddlewareInterface;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
/**
|
||||
* 对外提供的webman-admin鉴权中间件
|
||||
* 对外提供的鉴权中间件
|
||||
*/
|
||||
class Middleware implements MiddlewareInterface
|
||||
{
|
||||
@ -16,7 +17,7 @@ class Middleware implements MiddlewareInterface
|
||||
* @param Request $request
|
||||
* @param callable $handler
|
||||
* @return Response
|
||||
* @throws \ReflectionException
|
||||
* @throws ReflectionException
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public function process(Request $request, callable $handler): Response
|
||||
@ -30,7 +31,20 @@ class Middleware implements MiddlewareInterface
|
||||
if ($request->expectsJson()) {
|
||||
$response = json(['code' => $code, 'msg' => $msg, 'type' => 'error']);
|
||||
} else {
|
||||
$response = \response($msg, 401);
|
||||
if ($code === 401) {
|
||||
$response = response(<<<EOF
|
||||
<script>
|
||||
if (self !== top) {
|
||||
parent.location.reload();
|
||||
}
|
||||
</script>
|
||||
EOF
|
||||
);
|
||||
} else {
|
||||
$request->app = '';
|
||||
$request->plugin = 'admin';
|
||||
$response = view('common/error/403')->withStatus(403);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$response = $request->method() == 'OPTIONS' ? response('') : $handler($request);
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace plugin\admin\app\common;
|
||||
|
||||
use plugin\admin\app\common\Util;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
class Layui
|
||||
@ -124,6 +125,31 @@ EOF;
|
||||
</div>
|
||||
</div>
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输入框模糊查询
|
||||
* @param $options
|
||||
* @return void
|
||||
*/
|
||||
public function inputLike($options)
|
||||
{
|
||||
[$label, $field, $value, $props, $verify_string, $required_string, $class] = $this->options($options);
|
||||
$type = $props['type'] ?? 'text';
|
||||
|
||||
$this->htmlContent .= <<<EOF
|
||||
|
||||
<div class="layui-form-item">
|
||||
$label
|
||||
<div class="$class">
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" autocomplete="off" name="{$field}[]" value="like" class="layui-input inline-block">
|
||||
<input type="$type" autocomplete="off" name="{$field}[]" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
@ -138,6 +164,17 @@ EOF;
|
||||
$this->inputRange($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字输入框模糊查询
|
||||
* @param $options
|
||||
* @return void
|
||||
*/
|
||||
public function inputNumberLike($options)
|
||||
{
|
||||
$options['props']['type'] = 'number';
|
||||
$this->inputLike($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 密码输入框
|
||||
* @param $options
|
||||
@ -170,6 +207,58 @@ EOF;
|
||||
</div>
|
||||
</div>
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* 富文本
|
||||
* @param $options
|
||||
* @return void
|
||||
*/
|
||||
public function richText($options)
|
||||
{
|
||||
[$label, $field, $value, $props, $verify_string, $required_string, $class] = $this->options($options);
|
||||
|
||||
$placeholder_string = !empty($props['placeholder']) ? ' placeholder="'.$props['placeholder'].'"' : '';
|
||||
$disabled_string = !empty($props['disabled']) ? ' disabled' : '';
|
||||
$id = $field;
|
||||
|
||||
$this->htmlContent .= <<<EOF
|
||||
|
||||
<div class="layui-form-item">
|
||||
$label
|
||||
<div class="$class">
|
||||
<textarea id="$id" name="$field"$required_string$verify_string$placeholder_string$disabled_string class="layui-textarea">$value</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
EOF;
|
||||
|
||||
$options_string = '';
|
||||
if (!isset($props['images_upload_url'])) {
|
||||
$props['images_upload_url'] = '/app/admin/upload/image';
|
||||
}
|
||||
foreach ($props as $key => $item) {
|
||||
if (is_array($item)) {
|
||||
$item = json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
$options_string .= "\n $key: $item,";
|
||||
} else {
|
||||
$options_string .= "\n $key: \"$item\",";
|
||||
}
|
||||
}
|
||||
$this->jsContent .= <<<EOF
|
||||
|
||||
// 字段 {$options['label']} $field
|
||||
layui.use(["tinymce"], function() {
|
||||
var tinymce = layui.tinymce
|
||||
var edit = tinymce.render({
|
||||
elem: "#$id",$options_string
|
||||
});
|
||||
edit.on("blur", function(){
|
||||
layui.$("#$id").val(edit.getContent());
|
||||
});
|
||||
});
|
||||
|
||||
EOF;
|
||||
}
|
||||
|
||||
@ -612,6 +701,9 @@ EOF;
|
||||
$default_value_string = isset($props['initValue']) && $props['initValue'] != '' ? $props['initValue'] : $value;
|
||||
$url = $props['url'] ?? '';
|
||||
$options_string = '';
|
||||
if (isset($props['lay-verify'])) {
|
||||
$props['layVerify'] = $props['lay-verify'];
|
||||
}
|
||||
unset($props['lay-verify'], $props['url']);
|
||||
foreach ($props as $key => $item) {
|
||||
if (is_array($item)) {
|
||||
@ -673,7 +765,7 @@ EOF;
|
||||
<div class="layui-form-item">
|
||||
$select_label
|
||||
<div class="$class">
|
||||
<div name="$field" id="$id"$verify_string$required_string value="$default_value_string" ></div>
|
||||
<div name="$field" id="$id"$required_string value="$default_value_string" ></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -707,6 +799,7 @@ EOF;
|
||||
$field = $info['field'];
|
||||
$default = $columns[$key]['default'];
|
||||
$control = strtolower($info['control']);
|
||||
$auto_increment = $columns[$key]['auto_increment'];
|
||||
// 搜索框里上传组件替换为input
|
||||
if ($type == 'search' && in_array($control, ['upload', 'uploadimg'])) {
|
||||
$control = 'input';
|
||||
@ -715,20 +808,34 @@ EOF;
|
||||
|
||||
$props = Util::getControlProps($control, $info['control_args']);
|
||||
// 增加修改记录验证必填项
|
||||
if ($filter == 'form_show' && !isset($props['lay-verify']) && !$columns[$key]['nullable'] && $default === null && ($field !== 'password' || $type === 'insert')) {
|
||||
$props['lay-verify'] = 'required';
|
||||
if ($filter == 'form_show' && !$columns[$key]['nullable'] && $default === null && ($field !== 'password' || $type === 'insert')) {
|
||||
if (!isset($props['lay-verify'])) {
|
||||
$props['lay-verify'] = 'required';
|
||||
// 非类似字符串类型不允许传空
|
||||
} elseif (!in_array($columns[$key]['type'], ['string', 'text', 'mediumText', 'longText', 'char', 'binary', 'json'])
|
||||
&& strpos($props['lay-verify'], 'required') === false) {
|
||||
$props['lay-verify'] = 'required|' . $props['lay-verify'];
|
||||
}
|
||||
}
|
||||
// 增加记录显示默认值
|
||||
if ($type === 'insert' && !isset($props['value']) && $default !== null) {
|
||||
$props['value'] = $default;
|
||||
}
|
||||
// 表单不显示主键
|
||||
if ($filter == 'form_show' && $primary_key && $field == $primary_key) {
|
||||
// 主键是自增字段或者表单是更新类型不显示主键
|
||||
if ($primary_key && $field == $primary_key && (($type == 'insert' && $auto_increment) || $type == 'update')) {
|
||||
continue;
|
||||
}
|
||||
// 范围查询
|
||||
if ($type == 'search' && $info['search_type'] == 'between' && method_exists($form, "{$control}Range")) {
|
||||
$control = "{$control}Range";
|
||||
// 查询类型
|
||||
if ($type == 'search') {
|
||||
if ($info['search_type'] == 'between' && method_exists($form, "{$control}Range")) {
|
||||
$control = "{$control}Range";
|
||||
} elseif ($info['search_type'] == 'like' && method_exists($form, "{$control}Like")) {
|
||||
$control = "{$control}Like";
|
||||
}
|
||||
}
|
||||
// 查询类型移除lay-verify
|
||||
if ($type == 'search' && !empty($props['lay-verify'])) {
|
||||
$props['lay-verify'] = '';
|
||||
}
|
||||
|
||||
$options = [
|
||||
|
@ -2,12 +2,15 @@
|
||||
|
||||
namespace plugin\admin\app\common;
|
||||
|
||||
use process\Monitor;
|
||||
use Throwable;
|
||||
use Illuminate\Database\Connection;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use plugin\admin\app\model\Option;
|
||||
use support\exception\BusinessException;
|
||||
use support\Db;
|
||||
use Workerman\Timer;
|
||||
use Workerman\Worker;
|
||||
|
||||
class Util
|
||||
{
|
||||
@ -312,6 +315,8 @@ class Util
|
||||
'char' => ['Input'],
|
||||
|
||||
'binary' => ['Input'],
|
||||
|
||||
'json' => ['input']
|
||||
];
|
||||
}
|
||||
|
||||
@ -519,7 +524,7 @@ class Util
|
||||
|
||||
|
||||
/**
|
||||
* reload webman (不支持windows)
|
||||
* Reload webman
|
||||
* @return bool
|
||||
*/
|
||||
public static function reloadWebman()
|
||||
@ -529,8 +534,34 @@ class Util
|
||||
posix_kill(posix_getppid(), SIGUSR1);
|
||||
return true;
|
||||
} catch (Throwable $e) {}
|
||||
} else {
|
||||
Timer::add(1, function () {
|
||||
Worker::stopAll();
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause file monitor
|
||||
* @return void
|
||||
*/
|
||||
public static function pauseFileMonitor()
|
||||
{
|
||||
if (method_exists(Monitor::class, 'pause')) {
|
||||
Monitor::pause();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume file monitor
|
||||
* @return void
|
||||
*/
|
||||
public static function resumeFileMonitor()
|
||||
{
|
||||
if (method_exists(Monitor::class, 'resume')) {
|
||||
Monitor::resume();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -129,7 +129,9 @@ class Crud extends Base
|
||||
$model = $this->model;
|
||||
foreach ($where as $column => $value) {
|
||||
if (is_array($value)) {
|
||||
if (in_array($value[0], ['>', '=', '<', '<>', 'like', 'not like'])) {
|
||||
if ($value[0] === 'like') {
|
||||
$model = $model->where($column, 'like', "%$value[1]%");
|
||||
} elseif (in_array($value[0], ['>', '=', '<', '<>', 'not like'])) {
|
||||
$model = $model->where($column, $value[0], $value[1]);
|
||||
} elseif ($value[0] == 'in') {
|
||||
$model = $model->whereIn($column, $value[1]);
|
||||
@ -139,7 +141,7 @@ class Crud extends Base
|
||||
$model = $model->whereNull($column, $value[1]);
|
||||
} elseif ($value[0] == 'not null') {
|
||||
$model = $model->whereNotNull($column, $value[1]);
|
||||
} else {
|
||||
} elseif ($value[0] !== '' || $value[1] !== '') {
|
||||
$model = $model->whereBetween($column, $value);
|
||||
}
|
||||
} else {
|
||||
|
@ -4,7 +4,6 @@ namespace plugin\admin\app\controller;
|
||||
|
||||
use plugin\admin\app\common\Util;
|
||||
use plugin\admin\app\model\User;
|
||||
use support\Db;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
@ -61,7 +60,7 @@ class IndexController
|
||||
// 总用户数
|
||||
$user_count = User::count();
|
||||
// mysql版本
|
||||
$version = Db::select('select VERSION() as version');
|
||||
$version = Util::db()->select('select VERSION() as version');
|
||||
$mysql_version = $version[0]->version ?? 'unknown';
|
||||
|
||||
$day7_detail = [];
|
||||
|
@ -198,15 +198,17 @@ EOF;
|
||||
if ($password != $password_confirm) {
|
||||
return $this->json(1, '两次密码不一致');
|
||||
}
|
||||
if (Admin::first()) {
|
||||
return $this->json(1, '后台已经安装完毕,无法通过此页面创建管理员');
|
||||
}
|
||||
if (!is_file($config_file = base_path() . '/plugin/admin/config/database.php')) {
|
||||
return $this->json(1, '请先完成第一步数据库配置');
|
||||
}
|
||||
$config = include $config_file;
|
||||
$connection = $config['connections']['mysql'];
|
||||
$pdo = $this->getPdo($connection['host'], $connection['username'], $connection['password'], $connection['port'], $connection['database']);
|
||||
|
||||
if ($pdo->query('select * from `wa_admins`')->fetchAll()) {
|
||||
return $this->json(1, '后台已经安装完毕,无法通过此页面创建管理员');
|
||||
}
|
||||
|
||||
$smt = $pdo->prepare("insert into `wa_admins` (`username`, `password`, `nickname`, `created_at`, `updated_at`) values (:username, :password, :nickname, :created_at, :updated_at)");
|
||||
$time = date('Y-m-d H:i:s');
|
||||
$data = [
|
||||
@ -379,6 +381,7 @@ EOF;
|
||||
}
|
||||
$params = [
|
||||
\PDO::MYSQL_ATTR_INIT_COMMAND => "set names utf8mb4",
|
||||
\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
|
||||
\PDO::ATTR_EMULATE_PREPARES => false,
|
||||
\PDO::ATTR_TIMEOUT => 5,
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
|
@ -5,6 +5,7 @@ namespace plugin\admin\app\controller;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use plugin\admin\app\common\Util;
|
||||
use plugin\admin\app\controller\Base;
|
||||
use process\Monitor;
|
||||
use support\exception\BusinessException;
|
||||
use support\Log;
|
||||
@ -113,10 +114,7 @@ class PluginController extends Base
|
||||
}
|
||||
}
|
||||
|
||||
$monitor_support_pause = method_exists(Monitor::class, 'pause');
|
||||
if ($monitor_support_pause) {
|
||||
Monitor::pause();
|
||||
}
|
||||
Util::pauseFileMonitor();
|
||||
try {
|
||||
// 解压zip到plugin目录
|
||||
if ($has_zip_archive) {
|
||||
@ -154,9 +152,7 @@ class PluginController extends Base
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if ($monitor_support_pause) {
|
||||
Monitor::resume();
|
||||
}
|
||||
Util::resumeFileMonitor();
|
||||
}
|
||||
|
||||
Util::reloadWebman();
|
||||
@ -351,7 +347,7 @@ class PluginController extends Base
|
||||
protected function getUnzipCmd($zip_file, $extract_to)
|
||||
{
|
||||
if ($cmd = $this->findCmd('unzip')) {
|
||||
$cmd = "$cmd -qq $zip_file -d $extract_to";
|
||||
$cmd = "$cmd -o -qq $zip_file -d $extract_to";
|
||||
} else if ($cmd = $this->findCmd('7z')) {
|
||||
$cmd = "$cmd x -bb0 -y $zip_file -o$extract_to";
|
||||
} else if ($cmd = $this->findCmd('7zz')) {
|
||||
@ -369,8 +365,8 @@ class PluginController extends Base
|
||||
protected function unzipWithCmd($cmd)
|
||||
{
|
||||
$desc = [
|
||||
0 => STDIN,
|
||||
1 => STDOUT,
|
||||
0 => ["pipe", "r"],
|
||||
1 => ["pipe", "w"],
|
||||
2 => ["pipe", "w"],
|
||||
];
|
||||
$handler = proc_open($cmd, $desc, $pipes);
|
||||
|
@ -171,6 +171,11 @@ class RoleController extends Crud
|
||||
if (!Auth::isSupperAdmin() && array_diff($ids, Auth::getScopeRoleIds())) {
|
||||
return $this->json(1, '无删除权限');
|
||||
}
|
||||
$tree = new Tree(Role::get());
|
||||
$descendants = $tree->getDescendant($ids);
|
||||
if ($descendants) {
|
||||
$ids = array_merge($ids, array_column($descendants, 'id'));
|
||||
}
|
||||
$this->doDelete($ids);
|
||||
return $this->json(0);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ use plugin\admin\app\model\Option;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use Throwable;
|
||||
|
||||
class TableController extends Base
|
||||
{
|
||||
@ -58,16 +59,20 @@ class TableController extends Base
|
||||
*/
|
||||
public function show(Request $request): Response
|
||||
{
|
||||
$limit = (int)$request->get('limit', 10);
|
||||
$page = (int)$request->get('page', 1);
|
||||
$offset = ($page - 1) * $limit;
|
||||
$database = config('database.connections')['plugin.admin.mysql']['database'];
|
||||
$field = $request->get('field', 'TABLE_NAME');
|
||||
$field = Util::filterAlphaNum($field);
|
||||
$order = $request->get('order', 'asc');
|
||||
$allow_column = ['TABLE_NAME','TABLE_COMMENT','ENGINE','TABLE_ROWS','CREATE_TIME','UPDATE_TIME','TABLE_COLLATION'];
|
||||
$allow_column = ['TABLE_NAME', 'TABLE_COMMENT', 'ENGINE', 'TABLE_ROWS', 'CREATE_TIME', 'UPDATE_TIME', 'TABLE_COLLATION'];
|
||||
if (!in_array($field, $allow_column)) {
|
||||
$field = 'TABLE_NAME';
|
||||
}
|
||||
$order = $order === 'asc' ? 'asc' : 'desc';
|
||||
$tables = Util::db()->select("SELECT TABLE_NAME,TABLE_COMMENT,ENGINE,TABLE_ROWS,CREATE_TIME,UPDATE_TIME,TABLE_COLLATION FROM information_schema.`TABLES` WHERE TABLE_SCHEMA='$database' order by $field $order");
|
||||
$total = Util::db()->select("SELECT count(*)total FROM information_schema.`TABLES` WHERE TABLE_SCHEMA='$database'")[0]->total ?? 0;
|
||||
$tables = Util::db()->select("SELECT TABLE_NAME,TABLE_COMMENT,ENGINE,TABLE_ROWS,CREATE_TIME,UPDATE_TIME,TABLE_COLLATION FROM information_schema.`TABLES` WHERE TABLE_SCHEMA='$database' order by $field $order limit $offset,$limit");
|
||||
|
||||
if ($tables) {
|
||||
$table_names = array_column($tables, 'TABLE_NAME');
|
||||
@ -80,7 +85,7 @@ class TableController extends Base
|
||||
}
|
||||
}
|
||||
|
||||
return $this->json(0, 'ok', $tables);
|
||||
return json(['code' => 0, 'msg' => 'ok', 'count' => $total, 'data' => $tables]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,6 +108,7 @@ class TableController extends Base
|
||||
|
||||
$primary_key_count = 0;
|
||||
foreach ($columns as $index => $item) {
|
||||
$columns[$index]['field'] = trim($item['field']);
|
||||
if (!$item['field']) {
|
||||
unset($columns[$index]);
|
||||
continue;
|
||||
@ -207,6 +213,7 @@ class TableController extends Base
|
||||
|
||||
$primary_key_count = $auto_increment_count = 0;
|
||||
foreach ($columns as $index => $item) {
|
||||
$columns[$index]['field'] = trim($item['field']);
|
||||
if (!$item['field']) {
|
||||
unset($columns[$index]);
|
||||
continue;
|
||||
@ -464,45 +471,50 @@ class TableController extends Base
|
||||
$app = strtolower($explode[1]) !== 'controller' ? $explode[1] : '';
|
||||
}
|
||||
|
||||
$model_class = $model_file_name;
|
||||
$model_namespace = str_replace('/' , '\\', trim($model_path, '/'));
|
||||
Util::pauseFileMonitor();
|
||||
try {
|
||||
$model_class = $model_file_name;
|
||||
$model_namespace = str_replace('/', '\\', trim($model_path, '/'));
|
||||
|
||||
// 创建model
|
||||
$this->createModel($model_class, $model_namespace, base_path($model_file), $table_name);
|
||||
// 创建model
|
||||
$this->createModel($model_class, $model_namespace, base_path($model_file), $table_name);
|
||||
|
||||
$controller_suffix = $plugin ? config("plugin.$plugin.app.controller_suffix") : config('app.controller_suffix');
|
||||
$controller_class = $controller_file_name;
|
||||
$controller_namespace = str_replace('/' , '\\', trim($controller_path, '/'));
|
||||
// 创建controller
|
||||
$controller_url_name = $controller_suffix && substr($controller_class, -strlen($controller_suffix)) === $controller_suffix ? substr($controller_class, 0, -strlen($controller_suffix)) : $controller_class;
|
||||
$controller_url_name = str_replace('_', '-', $inflector->tableize($controller_url_name));
|
||||
$controller_suffix = $plugin ? config("plugin.$plugin.app.controller_suffix") : config('app.controller_suffix');
|
||||
$controller_class = $controller_file_name;
|
||||
$controller_namespace = str_replace('/', '\\', trim($controller_path, '/'));
|
||||
// 创建controller
|
||||
$controller_url_name = $controller_suffix && substr($controller_class, -strlen($controller_suffix)) === $controller_suffix ? substr($controller_class, 0, -strlen($controller_suffix)) : $controller_class;
|
||||
$controller_url_name = str_replace('_', '-', $inflector->tableize($controller_url_name));
|
||||
|
||||
if ($plugin) {
|
||||
array_splice($explode, 0, 2);
|
||||
}
|
||||
array_shift($explode);
|
||||
if ($app) {
|
||||
array_shift($explode);
|
||||
}
|
||||
foreach ($explode as $index => $item) {
|
||||
if (strtolower($item) === 'controller') {
|
||||
unset($explode[$index]);
|
||||
if ($plugin) {
|
||||
array_splice($explode, 0, 2);
|
||||
}
|
||||
array_shift($explode);
|
||||
if ($app) {
|
||||
array_shift($explode);
|
||||
}
|
||||
foreach ($explode as $index => $item) {
|
||||
if (strtolower($item) === 'controller') {
|
||||
unset($explode[$index]);
|
||||
}
|
||||
}
|
||||
|
||||
$controller_base = implode('/', $explode);
|
||||
$controller_class_with_namespace = "$controller_namespace\\$controller_class";
|
||||
$template_path = $controller_base ? "$controller_base/$controller_url_name" : $controller_url_name;
|
||||
$this->createController($controller_class, $controller_namespace, base_path($controller_file), $model_class, $model_namespace, $title, $template_path);
|
||||
|
||||
// 创建模版
|
||||
$template_file_path = ($plugin ? "/plugin/$plugin" : '') . '/app/' . ($app ? "$app/" : '') . 'view/' . $template_path;
|
||||
|
||||
$model_class_with_namespace = "$model_namespace\\$model_class";
|
||||
$primary_key = (new $model_class_with_namespace)->getKeyName();
|
||||
$url_path_base = ($plugin ? "/app/$plugin/" : '/') . ($app ? "$app/" : '') . $template_path;
|
||||
$this->createTemplate(base_path($template_file_path), $table_name, $url_path_base, $primary_key, "$controller_namespace\\$controller_class");
|
||||
} finally {
|
||||
Util::resumeFileMonitor();
|
||||
}
|
||||
|
||||
$controller_base = implode('/', $explode);
|
||||
$controller_class_with_namespace = "$controller_namespace\\$controller_class";
|
||||
$template_path = $controller_base ? "$controller_base/$controller_url_name" : $controller_url_name;
|
||||
$this->createController($controller_class, $controller_namespace, base_path($controller_file), $model_class, $model_namespace, $title, $template_path);
|
||||
|
||||
// 创建模版
|
||||
$template_file_path = ($plugin ? "/plugin/$plugin" : '') . '/app/' . ($app ? "$app/" : '') . 'view/' . $template_path;
|
||||
|
||||
$model_class_with_namespace = "$model_namespace\\$model_class";
|
||||
$primary_key = (new $model_class_with_namespace)->getKeyName();
|
||||
$url_path_base = ($plugin ? "/app/$plugin/" : '/') . ($app ? "$app/" : '') . $template_path;
|
||||
$this->createTemplate(base_path($template_file_path), $table_name, $url_path_base, $primary_key, "$controller_namespace\\$controller_class");
|
||||
|
||||
$menu = Rule::where('key', $controller_class_with_namespace)->first();
|
||||
if (!$menu) {
|
||||
$menu = new Rule;
|
||||
@ -551,6 +563,7 @@ class TableController extends Base
|
||||
$pk = 'id';
|
||||
$properties = '';
|
||||
$timestamps = '';
|
||||
$incrementing = '';
|
||||
$columns = [];
|
||||
try {
|
||||
$database = config('database.connections')['plugin.admin.mysql']['database'];
|
||||
@ -559,12 +572,24 @@ class TableController extends Base
|
||||
if ($item->COLUMN_KEY === 'PRI') {
|
||||
$pk = $item->COLUMN_NAME;
|
||||
$item->COLUMN_COMMENT .= "(主键)";
|
||||
if (strpos(strtolower($item->DATA_TYPE), 'int') === false) {
|
||||
$incrementing = <<<EOF
|
||||
/**
|
||||
* Indicates if the model's ID is auto-incrementing.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public \$incrementing = false;
|
||||
|
||||
EOF;
|
||||
;
|
||||
}
|
||||
}
|
||||
$type = $this->getType($item->DATA_TYPE);
|
||||
$properties .= " * @property $type \${$item->COLUMN_NAME} {$item->COLUMN_COMMENT}\n";
|
||||
$columns[$item->COLUMN_NAME] = $item->COLUMN_NAME;
|
||||
}
|
||||
} catch (\Throwable $e) {echo $e;}
|
||||
} catch (Throwable $e) {echo $e;}
|
||||
if (!isset($columns['created_at']) || !isset($columns['updated_at'])) {
|
||||
$timestamps = <<<EOF
|
||||
/**
|
||||
@ -573,6 +598,7 @@ class TableController extends Base
|
||||
* @var bool
|
||||
*/
|
||||
public \$timestamps = false;
|
||||
|
||||
EOF;
|
||||
|
||||
}
|
||||
@ -602,9 +628,8 @@ class $class extends Base
|
||||
* @var string
|
||||
*/
|
||||
protected \$primaryKey = '$pk';
|
||||
|
||||
$timestamps
|
||||
|
||||
$incrementing
|
||||
|
||||
}
|
||||
|
||||
@ -832,6 +857,9 @@ EOF
|
||||
// 表格顶部搜索事件
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
@ -844,6 +872,16 @@ EOF
|
||||
})
|
||||
});
|
||||
|
||||
// 字段允许为空
|
||||
form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
|
||||
// 表格排序事件
|
||||
table.on("sort(data-table)", function(obj){
|
||||
table.reload("data-table", {
|
||||
@ -982,6 +1020,15 @@ EOF;
|
||||
$js
|
||||
//提交事件
|
||||
layui.use(["form", "popup"], function () {
|
||||
// 字段验证允许为空
|
||||
layui.form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: INSERT_API,
|
||||
@ -1092,6 +1139,15 @@ EOF;
|
||||
|
||||
//提交事件
|
||||
layui.use(["form", "popup"], function () {
|
||||
// 字段验证允许为空
|
||||
layui.form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||
layui.$.ajax({
|
||||
@ -1170,17 +1226,21 @@ EOF;
|
||||
}
|
||||
if (isset($allow_column[$column])) {
|
||||
if (is_array($value)) {
|
||||
if (in_array($value[0], ['', 'undefined']) || in_array($value[1], ['', 'undefined'])) {
|
||||
continue;
|
||||
if ($value[0] === 'like') {
|
||||
$paginator = $paginator->where($column, 'like', "%$value[1]%");
|
||||
} elseif (in_array($value[0], ['>', '=', '<', '<>', 'not like'])) {
|
||||
$paginator = $paginator->where($column, $value[0], $value[1]);
|
||||
} else {
|
||||
if($value[0] !== '' || $value[1] !== '') {
|
||||
$paginator = $paginator->whereBetween($column, $value);
|
||||
}
|
||||
}
|
||||
$paginator = $paginator->whereBetween($column, $value);
|
||||
} else {
|
||||
$paginator = $paginator->where($column, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
$paginator = $paginator->orderBy($field, $order)->paginate($limit, '*', 'page', $page);
|
||||
|
||||
$items = $paginator->items();
|
||||
if ($format == 'tree') {
|
||||
$items_map = [];
|
||||
|
@ -3,11 +3,9 @@
|
||||
* Here is your custom functions.
|
||||
*/
|
||||
|
||||
use app\model\User;
|
||||
use plugin\admin\app\model\User;
|
||||
use plugin\admin\app\model\Admin;
|
||||
use plugin\admin\app\model\AdminRole;
|
||||
use plugin\admin\app\model\Role;
|
||||
use plugin\admin\app\model\Rule;
|
||||
|
||||
/**
|
||||
* 当前管理员id
|
||||
|
@ -37,6 +37,8 @@ class AccessControl implements MiddlewareInterface
|
||||
EOF
|
||||
);
|
||||
} else {
|
||||
$request->app = '';
|
||||
$request->plugin = 'admin';
|
||||
$response = view('common/error/403')->withStatus(403);
|
||||
}
|
||||
}
|
||||
|
@ -300,6 +300,9 @@
|
||||
// 表格顶部搜索事件
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
|
@ -156,6 +156,9 @@
|
||||
// 表格顶部搜索事件
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
|
@ -196,6 +196,9 @@
|
||||
// 表格顶部搜索事件
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
|
@ -96,7 +96,7 @@
|
||||
|
||||
<script type="text/html" id="col-type">
|
||||
<select name="columns[{{ d.LAY_INDEX-1 }}][type]" lay-verify="">
|
||||
{{# layui.each(["integer","string","text","date","enum","float","tinyInteger","smallInteger","mediumInteger","bigInteger","unsignedInteger","unsignedTinyInteger","unsignedSmallInteger","unsignedMediumInteger","unsignedBigInteger","decimal","double","mediumText","longText","dateTime","time","timestamp","char","binary"], function (index, item) { }}
|
||||
{{# layui.each(["integer","string","text","date","enum","float","tinyInteger","smallInteger","mediumInteger","bigInteger","unsignedInteger","unsignedTinyInteger","unsignedSmallInteger","unsignedMediumInteger","unsignedBigInteger","decimal","double","mediumText","longText","dateTime","time","timestamp","char","binary","json"], function (index, item) { }}
|
||||
<option value="{{ item }}" {{ d.type==item?"selected":""}}>{{ item }}</option>
|
||||
{{# }); }}
|
||||
</select>
|
||||
@ -132,7 +132,7 @@
|
||||
|
||||
<script type="text/html" id="form-control">
|
||||
<select name="forms[{{ d.LAY_INDEX-1 }}][control]" lay-verify="">
|
||||
{{# layui.each([["input", "文本框"],["inputNumber", "数字文本框"],["textArea", "多行文本"],["select", "下拉单选"],["selectMulti", "下拉多选"],["treeSelect", "树形单选"],["treeSelectMulti", "树形多选"],["datePicker", "日期选择"],["dateTimePicker", "日期时间选择"],["switch", "开关"],["upload", "上传文件"],["uploadImage", "上传图片"],["iconPicker", "图标选择"]], function (index, item) { }}
|
||||
{{# layui.each([["input", "文本框"],["inputNumber", "数字文本框"],["textArea", "多行文本"],["richText", "富文本"],["select", "下拉单选"],["selectMulti", "下拉多选"],["treeSelect", "树形单选"],["treeSelectMulti", "树形多选"],["datePicker", "日期选择"],["dateTimePicker", "日期时间选择"],["switch", "开关"],["upload", "上传文件"],["uploadImage", "上传图片"],["iconPicker", "图标选择"]], function (index, item) { }}
|
||||
<option value="{{ item[0] }}" {{ d.control.toLocaleLowerCase()==item[0].toLocaleLowerCase()?'selected':''}}>{{ item[1] }}</option>
|
||||
{{# }); }}
|
||||
</select>
|
||||
@ -160,7 +160,7 @@
|
||||
|
||||
<script type="text/html" id="form-search_type">
|
||||
<select name="forms[{{ d.LAY_INDEX-1 }}][search_type]" lay-verify="">
|
||||
{{# layui.each([["normal", "普通查询"], ["between", "范围查询"]], function (index, item) { }}
|
||||
{{# layui.each([["normal", "普通查询"], ["between", "范围查询"], ["like", "模糊查询"]], function (index, item) { }}
|
||||
<option value="{{ item[0] }}" {{ d.search_type==item[0]?'selected':''}}>{{ item[1] }}</option>
|
||||
{{# }); }}
|
||||
</select>
|
||||
|
@ -125,7 +125,6 @@
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
}
|
||||
|
@ -40,6 +40,17 @@
|
||||
<?=$form->js(3)?>
|
||||
|
||||
layui.use(["form", "popup"], function () {
|
||||
|
||||
// 字段验证允许为空
|
||||
layui.form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
|
@ -98,7 +98,7 @@
|
||||
|
||||
<script type="text/html" id="col-type">
|
||||
<select name="columns[{{ d.LAY_INDEX-1 }}][type]" lay-verify="">
|
||||
{{# layui.each(["integer","string","text","date","enum","float","tinyInteger","smallInteger","mediumInteger","bigInteger","unsignedInteger","unsignedTinyInteger","unsignedSmallInteger","unsignedMediumInteger","unsignedBigInteger","decimal","double","mediumText","longText","dateTime","time","timestamp","char","binary"], function (index, item) { }}
|
||||
{{# layui.each(["integer","string","text","date","enum","float","tinyInteger","smallInteger","mediumInteger","bigInteger","unsignedInteger","unsignedTinyInteger","unsignedSmallInteger","unsignedMediumInteger","unsignedBigInteger","decimal","double","mediumText","longText","dateTime","time","timestamp","char","binary","json"], function (index, item) { }}
|
||||
<option value="{{ item }}" {{ d.type==item?'selected':''}}>{{ item }}</option>
|
||||
{{# }); }}
|
||||
</select>
|
||||
@ -136,7 +136,7 @@
|
||||
|
||||
<script type="text/html" id="form-control">
|
||||
<select name="forms[{{ d.LAY_INDEX-1 }}][control]" lay-verify="">
|
||||
{{# layui.each([["input", "文本框"],["inputNumber", "数字文本框"],["textArea", "多行文本"],["select", "下拉单选"],["selectMulti", "下拉多选"],["treeSelect", "树形单选"],["treeSelectMulti", "树形多选"],["datePicker", "日期选择"],["dateTimePicker", "日期时间选择"],["switch", "开关"],["upload", "上传文件"],["uploadImage", "上传图片"],["iconPicker", "图标选择"]], function (index, item) { }}
|
||||
{{# layui.each([["input", "文本框"],["inputNumber", "数字文本框"],["textArea", "多行文本"],["richText", "富文本"],["select", "下拉单选"],["selectMulti", "下拉多选"],["treeSelect", "树形单选"],["treeSelectMulti", "树形多选"],["datePicker", "日期选择"],["dateTimePicker", "日期时间选择"],["switch", "开关"],["upload", "上传文件"],["uploadImage", "上传图片"],["iconPicker", "图标选择"]], function (index, item) { }}
|
||||
<option value="{{ item[0] }}" {{ d.control.toLocaleLowerCase()==item[0].toLocaleLowerCase()?'selected':''}}>{{ item[1] }}</option>
|
||||
{{# }); }}
|
||||
</select>
|
||||
@ -164,7 +164,7 @@
|
||||
|
||||
<script type="text/html" id="form-search_type">
|
||||
<select name="forms[{{ d.LAY_INDEX-1 }}][search_type]" lay-verify="">
|
||||
{{# layui.each([["normal", "普通查询"], ["between", "范围查询"]], function (index, item) { }}
|
||||
{{# layui.each([["normal", "普通查询"], ["between", "范围查询"], ["like", "模糊查询"]], function (index, item) { }}
|
||||
<option value="{{ item[0] }}" {{ d.search_type==item[0]?'selected':''}}>{{ item[1] }}</option>
|
||||
{{# }); }}
|
||||
</select>
|
||||
|
@ -76,6 +76,15 @@
|
||||
});
|
||||
|
||||
layui.use(["form", "popup"], function () {
|
||||
// 字段验证允许为空
|
||||
layui.form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
//提交事件
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
|
@ -237,6 +237,16 @@
|
||||
}
|
||||
});
|
||||
|
||||
// 字段验证允许为空
|
||||
form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: data.field
|
||||
|
@ -315,6 +315,9 @@
|
||||
// 表格顶部搜索事件
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
|
@ -305,6 +305,9 @@
|
||||
// 表格顶部搜索事件
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
|
@ -442,6 +442,9 @@
|
||||
// 表格顶部搜索事件
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
|
@ -17,5 +17,5 @@ return [
|
||||
'controller_suffix' => 'Controller',
|
||||
'controller_reuse' => false,
|
||||
'plugin_market_host' => 'https://www.workerman.net',
|
||||
'version' => '0.6.0'
|
||||
'version' => '0.6.12'
|
||||
];
|
||||
|
@ -21,5 +21,5 @@ return [
|
||||
// Fallback language
|
||||
'fallback_locale' => ['zh_CN', 'en'],
|
||||
// Folder where language files are stored
|
||||
'path' => base_path() . '/resource/translations',
|
||||
'path' => base_path() . '/plugin/admin/resource/translations'
|
||||
];
|
@ -68,17 +68,17 @@ CREATE TABLE IF NOT EXISTS `wa_rules` (
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `wa_uploads` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`name` varchar(255) NOT NULL COMMENT '名称',
|
||||
`name` varchar(128) NOT NULL COMMENT '名称',
|
||||
`url` varchar(255) NOT NULL COMMENT '文件',
|
||||
`admin_id` int(11) DEFAULT NULL COMMENT '管理员',
|
||||
`file_size` int(11) NOT NULL COMMENT '文件大小',
|
||||
`mime_type` varchar(255) NOT NULL COMMENT 'mime类型',
|
||||
`image_width` int(11) DEFAULT NULL COMMENT '图片宽度',
|
||||
`image_height` int(11) DEFAULT NULL COMMENT '图片高度',
|
||||
`ext` varchar(255) NOT NULL COMMENT '扩展名',
|
||||
`ext` varchar(128) NOT NULL COMMENT '扩展名',
|
||||
`storage` varchar(255) NOT NULL DEFAULT 'local' COMMENT '存储位置',
|
||||
`created_at` date DEFAULT NULL COMMENT '上传时间',
|
||||
`category` varchar(255) DEFAULT NULL COMMENT '类别',
|
||||
`category` varchar(128) DEFAULT NULL COMMENT '类别',
|
||||
`updated_at` date DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `category` (`category`),
|
||||
|
@ -25,9 +25,9 @@ layui.define(['jquery'],function (exports) {
|
||||
}
|
||||
, success: function (res, succFun, failFun) {//图片上传完成回调 根据自己需要修改
|
||||
if (res[this.response.statusName] == this.response.statusCode.ok) {
|
||||
succFun(res[this.response.dataName]);
|
||||
succFun(res[this.response.dataName]["url"]);
|
||||
} else {
|
||||
failFun(res[this.response.msgName]);
|
||||
failFun(res[this.response.msgName]["url"]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user