基础功能
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 模块 view path
|
||||
*
|
||||
*/
|
||||
|
||||
use think\helper\Arr;
|
||||
|
||||
if (!function_exists('getModuleViewPath()')) {
|
||||
function getModuleViewPath($module) {
|
||||
|
||||
if (file_exists($views = app()->getRuntimePath() . 'module' . DIRECTORY_SEPARATOR . 'view.php')) {
|
||||
$views = include $views;
|
||||
|
||||
return $views[$module];
|
||||
} else {
|
||||
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
namespace catchAdmin\index\controller;
|
||||
|
||||
use app\BaseController;
|
||||
|
||||
use catcher\base\BaseController;
|
||||
|
||||
class Index extends BaseController
|
||||
{
|
||||
public function index(): string
|
||||
{
|
||||
return $this->fetch('index::index');
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
@@ -4,10 +4,10 @@
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link href="./assets/images/favicon.ico" rel="icon">
|
||||
<title>EasyWeb后台开发框架</title>
|
||||
<link rel="stylesheet" href="/static/assets/libs/layui/css/layui.css"/>
|
||||
<link rel="stylesheet" href="/static/assets/module/admin.css?v=315"/>
|
||||
<link href="__CATCH_ADMIN_IMAGES__/favicon.ico" rel="icon">
|
||||
<title>CatchAdmin 后台管理系统</title>
|
||||
<link rel="stylesheet" href="__CATCH_ADMIN_LIBS__/layui/css/layui.css"/>
|
||||
<link rel="stylesheet" href="__CATCH_ADMIN_MODULE__/admin.css?v=315"/>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
@@ -18,8 +18,8 @@
|
||||
<!-- 头部 -->
|
||||
<div class="layui-header">
|
||||
<div class="layui-logo">
|
||||
<img src="/static/assets/images/logo.png"/>
|
||||
<cite> EasyWeb Iframe</cite>
|
||||
<img src="__CATCH_ADMIN_IMAGES__/logo.png"/>
|
||||
<cite>CatchAdmin</cite>
|
||||
</div>
|
||||
<ul class="layui-nav layui-layout-left">
|
||||
<li class="layui-nav-item" lay-unselect>
|
||||
@@ -44,7 +44,7 @@
|
||||
</li>
|
||||
<li class="layui-nav-item" lay-unselect>
|
||||
<a>
|
||||
<img src="assets/images/head.png" class="layui-nav-img">
|
||||
<img src="__CATCH_ADMIN_IMAGES__/head.png" class="layui-nav-img">
|
||||
<cite>管理员</cite>
|
||||
</a>
|
||||
<dl class="layui-nav-child">
|
||||
@@ -81,9 +81,9 @@
|
||||
</dl>
|
||||
</li>
|
||||
<li class="layui-nav-item">
|
||||
<a><i class="layui-icon layui-icon-set"></i> <cite>系统管理</cite></a>
|
||||
<a><i class="layui-icon layui-icon-set"></i> <cite>权限管理</cite></a>
|
||||
<dl class="layui-nav-child">
|
||||
<dd><a lay-href="page/system/user.html">用户管理</a></dd>
|
||||
<dd><a lay-href="{:url('user')}">用户管理</a></dd>
|
||||
<dd><a lay-href="page/system/role.html">角色管理</a></dd>
|
||||
<dd><a lay-href="page/system/authorities.html">菜单管理</a></dd>
|
||||
<dd><a lay-href="page/system/loginRecord.html">登录日志</a></dd>
|
||||
@@ -233,8 +233,8 @@
|
||||
</div>
|
||||
|
||||
<!-- js部分 -->
|
||||
<script type="text/javascript" src="/static/assets/libs/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/static/assets/js/common.js?v=315"></script>
|
||||
<script type="text/javascript" src="__CATCH_ADMIN_LIBS__/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="__CATCH_ADMIN_JS__/common.js?v=315"></script>
|
||||
<script>
|
||||
layui.use(['index'], function () {
|
||||
var $ = layui.jquery;
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace catchAdmin\login\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use catchAdmin\login\Auth;
|
||||
use catchAdmin\login\request\LoginRequest;
|
||||
use catcher\base\BaseController;
|
||||
|
||||
class Index extends BaseController
|
||||
{
|
||||
@@ -14,9 +14,9 @@ class Index extends BaseController
|
||||
* @throws \Exception
|
||||
* @return string
|
||||
*/
|
||||
public function index()
|
||||
public function index(): string
|
||||
{
|
||||
return $this->fetch('login::index');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,19 +1,23 @@
|
||||
<?php
|
||||
namespace catchAdmin\login\request;
|
||||
|
||||
use app\Request;
|
||||
use catchAdmin\login\validate\LoginValidate;
|
||||
use catcher\base\BaseRequest;
|
||||
|
||||
class LoginRequest extends Request
|
||||
class LoginRequest extends BaseRequest
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @time 2019年11月27日
|
||||
* @return string
|
||||
*/
|
||||
protected function getValidate()
|
||||
protected function rules(): array
|
||||
{
|
||||
// TODO: Implement getValidate() method.
|
||||
return new LoginValidate();
|
||||
// TODO: Implement rules() method.
|
||||
return [
|
||||
'name|用户名' => 'require|max:25',
|
||||
'password|密码' => 'require',
|
||||
'captcha|验证码' => 'require|captcha'
|
||||
];
|
||||
}
|
||||
|
||||
protected function message(): array
|
||||
{
|
||||
// TODO: Implement message() method.
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@@ -2,13 +2,17 @@
|
||||
|
||||
namespace catchAdmin\login\validate;
|
||||
|
||||
use think\Validate;
|
||||
use catcher\base\BaseValidate;
|
||||
|
||||
class LoginValidate extends Validate
|
||||
class LoginValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'name|用户名' => 'require|max:25',
|
||||
'password|密码' => 'require',
|
||||
'captcha|验证码' => 'require|captcha'
|
||||
];
|
||||
protected function getRules(): array
|
||||
{
|
||||
// TODO: Implement getRules() method.
|
||||
return [
|
||||
'name|用户名' => 'require|max:25',
|
||||
'password|密码' => 'require',
|
||||
'captcha|验证码' => 'require|captcha'
|
||||
];
|
||||
}
|
||||
}
|
@@ -5,9 +5,9 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>登录</title>
|
||||
<link rel="stylesheet" href="/static/assets/libs/layui/css/layui.css"/>
|
||||
<link rel="stylesheet" href="/static/assets/css/login.css?v=315">
|
||||
<link rel="stylesheet" href="/static/assets/module/admin.css?v=315">
|
||||
<link rel="stylesheet" href="__CATCH_ADMIN_LIBS__/layui/css/layui.css"/>
|
||||
<link rel="stylesheet" href="__CATCH_ADMIN_CSS__/login.css?v=315">
|
||||
<link rel="stylesheet" href="__CATCH_ADMIN_MODULE__/admin.css?v=315">
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
@@ -91,8 +91,8 @@
|
||||
</div>
|
||||
|
||||
<!-- js部分 -->
|
||||
<script type="text/javascript" src="/static/assets/libs/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/static/assets/js/common.js?v=315"></script>
|
||||
<script type="text/javascript" src="__CATCH_ADMIN_LIBS__/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="__CATCH_ADMIN_JS__/common.js?v=315"></script>
|
||||
<script>
|
||||
layui.use(['layer', 'form'], function () {
|
||||
var $ = layui.jquery;
|
||||
|
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
// This file is automatically generated at:2019-11-29 08:20:23
|
||||
declare (strict_types = 1);
|
||||
return array (
|
||||
'module\\index\\IndexService' => false,
|
||||
'module\\install\\InstallService' => false,
|
||||
'module\\login\\LoginService' => false,
|
||||
'module\\permissions\\PermissionService' => false,
|
||||
'module\\user\\UserService' => false,
|
||||
);
|
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
namespace catchAdmin\user\controller;
|
||||
|
||||
use app\BaseController;
|
||||
|
||||
class Index extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function save()
|
||||
{}
|
||||
|
||||
public function read()
|
||||
{}
|
||||
|
||||
public function edit()
|
||||
{}
|
||||
|
||||
public function update()
|
||||
{}
|
||||
|
||||
public function delete()
|
||||
{}
|
||||
|
||||
}
|
91
catchAdmin/user/controller/User.php
Normal file
91
catchAdmin/user/controller/User.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
namespace catchAdmin\user\controller;
|
||||
|
||||
use catchAdmin\user\model\Users;
|
||||
use catchAdmin\user\request\CreateRequest;
|
||||
use catchAdmin\user\request\UpdateRequest;
|
||||
use catcher\base\BaseController;
|
||||
use catcher\CatchForm;
|
||||
use catcher\CatchResponse;
|
||||
|
||||
class User extends BaseController
|
||||
{
|
||||
protected $user;
|
||||
|
||||
public function __construct(Users $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月04日
|
||||
* @throws \Exception
|
||||
* @return string
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$form = new CatchForm();
|
||||
|
||||
$form->text('name', '用户名')->id('id')->class('class');
|
||||
$form->select('names', '性别')->options(['请选择性别', '男', '女'])->default(1);
|
||||
//$form->select('namess', '用户名');
|
||||
|
||||
$form->render();
|
||||
return $this->fetch([
|
||||
'form' => $form->render()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月04日
|
||||
* @param CreateRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function create(CreateRequest $request)
|
||||
{
|
||||
return CatchResponse::success($this->user->storeBy($request->post()));
|
||||
}
|
||||
|
||||
public function save()
|
||||
{}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月04日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
return CatchResponse::success($this->user->findBy($id));
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月04日
|
||||
* @param $id
|
||||
* @param UpdateRequest $request
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function update($id, UpdateRequest $request)
|
||||
{
|
||||
return CatchResponse::success($this->user->updateBy($id, $request->post()));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月04日
|
||||
* @param $id
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return CatchResponse::success($this->user->deleteBy($id));
|
||||
}
|
||||
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace catchAdmin\user\model;
|
||||
|
||||
use catcher\Model;
|
||||
use catcher\base\BaseModel;
|
||||
|
||||
class Users extends Model
|
||||
class Users extends BaseModel
|
||||
{
|
||||
protected $name = 'users';
|
||||
|
||||
|
15
catchAdmin/user/request/CreateRequest.php
Normal file
15
catchAdmin/user/request/CreateRequest.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace catchAdmin\user\request;
|
||||
|
||||
use catchAdmin\user\validate\CreateValidate;
|
||||
use catcher\base\BaseRequest;
|
||||
|
||||
class CreateRequest extends BaseRequest
|
||||
{
|
||||
|
||||
protected function getValidate()
|
||||
{
|
||||
// TODO: Implement getValidate() method.
|
||||
return new CreateValidate();
|
||||
}
|
||||
}
|
14
catchAdmin/user/request/UpdateRequest.php
Normal file
14
catchAdmin/user/request/UpdateRequest.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace catchAdmin\user\request;
|
||||
|
||||
use catchAdmin\user\validate\UpdateValidate;
|
||||
use catcher\base\BaseRequest;
|
||||
|
||||
class UpdateRequest extends BaseRequest
|
||||
{
|
||||
protected function getValidate()
|
||||
{
|
||||
// TODO: Implement getValidate() method.
|
||||
return new UpdateValidate();
|
||||
}
|
||||
}
|
@@ -1,3 +1,3 @@
|
||||
<?php
|
||||
|
||||
$router->resource('user', '\catchAdmin\user\controller\Index');
|
||||
$router->resource('user', '\catchAdmin\user\controller\User');
|
17
catchAdmin/user/validate/CreateValidate.php
Normal file
17
catchAdmin/user/validate/CreateValidate.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace catchAdmin\user\validate;
|
||||
|
||||
use catcher\base\BaseValidate;
|
||||
|
||||
class CreateValidate extends BaseValidate
|
||||
{
|
||||
protected function getRules(): array
|
||||
{
|
||||
// TODO: Implement getRules() method.
|
||||
return [
|
||||
'username|用户名' => 'require|max:20',
|
||||
'password|密码' => 'require|max:20',
|
||||
'email|邮箱' => 'require|email'
|
||||
];
|
||||
}
|
||||
}
|
18
catchAdmin/user/validate/UpdateValidate.php
Normal file
18
catchAdmin/user/validate/UpdateValidate.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace catchAdmin\user\validate;
|
||||
|
||||
use catchAdmin\user\model\Users;
|
||||
use catcher\base\BaseValidate;
|
||||
|
||||
class UpdateValidate extends BaseValidate
|
||||
{
|
||||
protected function getRules(): array
|
||||
{
|
||||
// TODO: Implement getRules() method.
|
||||
return [
|
||||
'username|用户名' => 'require|max:20',
|
||||
'password|密码' => 'require|max:20',
|
||||
'email|邮箱' => 'require|email|unique:'.Users::class.',email,'.request()->route('user').',id',
|
||||
];
|
||||
}
|
||||
}
|
@@ -1,10 +1,190 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
{extend name="../../../view/layout"}
|
||||
{block name="title"}用户管理{/block}
|
||||
{block name="search"}
|
||||
<div class="layui-form toolbar">
|
||||
<div class="layui-form-item">
|
||||
{php}echo $form{/php}
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label w-auto">账 号:</label>
|
||||
<div class="layui-input-inline mr0">
|
||||
<input name="username" class="layui-input" type="text" placeholder="输入账号"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label w-auto">用户名:</label>
|
||||
<div class="layui-input-inline mr0">
|
||||
<input name="nickName" class="layui-input" type="text" placeholder="输入用户名"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label w-auto">性 别:</label>
|
||||
<div class="layui-input-inline mr0">
|
||||
<select name="sex">
|
||||
<option value="">选择性别</option>
|
||||
<option value="男">男</option>
|
||||
<option value="女">女</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline" style="padding-right: 110px;">
|
||||
<button class="layui-btn icon-btn" lay-filter="formSubSearchUser" lay-submit>
|
||||
<i class="layui-icon"></i>搜索
|
||||
</button>
|
||||
<button id="btnAddUser" class="layui-btn icon-btn"><i class="layui-icon"></i>添加</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
{block name="table"}
|
||||
<table class="layui-table" id="tableUser" lay-filter="tableUser"></table>
|
||||
{/block}
|
||||
{block name="script"}
|
||||
<script>
|
||||
layui.use(['layer', 'form', 'table', 'util', 'admin'], function () {
|
||||
var $ = layui.jquery;
|
||||
var layer = layui.layer;
|
||||
var form = layui.form;
|
||||
var table = layui.table;
|
||||
var util = layui.util;
|
||||
var admin = layui.admin;
|
||||
|
||||
</body>
|
||||
</html>
|
||||
// 渲染表格
|
||||
var insTb = table.render({
|
||||
elem: '#tableUser',
|
||||
url: '../../json/user.json',
|
||||
page: true,
|
||||
toolbar: true,
|
||||
cellMinWidth: 100,
|
||||
cols: [[
|
||||
{type: 'numbers', title: '#'},
|
||||
{field: 'username', sort: true, title: '账号'},
|
||||
{field: 'nickName', sort: true, title: '用户名'},
|
||||
{field: 'sex', sort: true, title: '性别'},
|
||||
{
|
||||
field: 'createTime', sort: true, templet: function (d) {
|
||||
return util.toDateString(d.createTime);
|
||||
}, title: '创建时间'
|
||||
},
|
||||
{field: 'state', sort: true, templet: '#tableStateUser', title: '状态'},
|
||||
{align: 'center', toolbar: '#tableBarUser', title: '操作', minWidth: 200}
|
||||
]]
|
||||
});
|
||||
|
||||
// 添加
|
||||
$('#btnAddUser').click(function () {
|
||||
showEditModel();
|
||||
});
|
||||
|
||||
// 搜索
|
||||
form.on('submit(formSubSearchUser)', function (data) {
|
||||
insTb.reload({where: data.field}, 'data');
|
||||
});
|
||||
|
||||
// 工具条点击事件
|
||||
table.on('tool(tableUser)', function (obj) {
|
||||
var data = obj.data;
|
||||
var layEvent = obj.event;
|
||||
if (layEvent === 'edit') { // 修改
|
||||
showEditModel(data);
|
||||
} else if (layEvent === 'del') { // 删除
|
||||
doDel(data.userId, data.nickName);
|
||||
} else if (layEvent === 'reset') { // 重置密码
|
||||
resetPsw(data.userId, data.nickName);
|
||||
}
|
||||
});
|
||||
|
||||
// 显示表单弹窗
|
||||
function showEditModel(mUser) {
|
||||
admin.open({
|
||||
type: 1,
|
||||
title: (mUser ? '修改' : '添加') + '用户',
|
||||
content: $('#modelUser').html(),
|
||||
success: function (layero, dIndex) {
|
||||
$(layero).children('.layui-layer-content').css('overflow', 'visible');
|
||||
var url = mUser ? '../../json/ok.json' : '../../json/ok.json';
|
||||
mUser && (mUser.roleId = mUser.roles[0].roleId);
|
||||
// 回显数据
|
||||
form.val('modelUserForm', mUser);
|
||||
// 表单提交事件
|
||||
form.on('submit(modelSubmitUser)', function (data) {
|
||||
layer.load(2);
|
||||
$.get(url, data.field, function (res) {
|
||||
layer.closeAll('loading');
|
||||
if (res.code == 200) {
|
||||
layer.close(dIndex);
|
||||
layer.msg(res.msg, {icon: 1});
|
||||
insTb.reload({}, 'data');
|
||||
} else {
|
||||
layer.msg(res.msg, {icon: 2});
|
||||
}
|
||||
}, 'json');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 删除
|
||||
function doDel(userId, nickName) {
|
||||
layer.confirm('确定要删除“' + nickName + '”吗?', {
|
||||
skin: 'layui-layer-admin',
|
||||
shade: .1
|
||||
}, function (i) {
|
||||
layer.close(i);
|
||||
layer.load(2);
|
||||
$.get('../../json/ok.json', {
|
||||
userId: userId
|
||||
}, function (res) {
|
||||
layer.closeAll('loading');
|
||||
if (res.code == 200) {
|
||||
layer.msg(res.msg, {icon: 1});
|
||||
insTb.reload({}, 'data');
|
||||
} else {
|
||||
layer.msg(res.msg, {icon: 2});
|
||||
}
|
||||
}, 'json');
|
||||
});
|
||||
}
|
||||
|
||||
// 修改用户状态
|
||||
form.on('switch(ckStateUser)', function (obj) {
|
||||
layer.load(2);
|
||||
$.get('../../json/ok.json', {
|
||||
userId: obj.elem.value,
|
||||
state: obj.elem.checked ? 0 : 1
|
||||
}, function (res) {
|
||||
layer.closeAll('loading');
|
||||
if (res.code == 200) {
|
||||
layer.msg(res.msg, {icon: 1});
|
||||
} else {
|
||||
layer.msg(res.msg, {icon: 2});
|
||||
$(obj.elem).prop('checked', !obj.elem.checked);
|
||||
form.render('checkbox');
|
||||
}
|
||||
}, 'json');
|
||||
});
|
||||
|
||||
// 重置密码
|
||||
function resetPsw(userId, nickName) {
|
||||
layer.confirm('确定要重置“' + nickName + '”的登录密码吗?', {
|
||||
skin: 'layui-layer-admin',
|
||||
shade: .1
|
||||
}, function (i) {
|
||||
layer.close(i);
|
||||
layer.load(2);
|
||||
$.get('../../json/ok.json', {
|
||||
userId: userId
|
||||
}, function (res) {
|
||||
layer.closeAll('loading');
|
||||
if (res.code == 200) {
|
||||
layer.msg(res.msg, {icon: 1});
|
||||
} else {
|
||||
layer.msg(res.msg, {icon: 2});
|
||||
}
|
||||
}, 'json');
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
{/block}
|
Reference in New Issue
Block a user