完善 php 7.1 ~ 8.2 的兼容性

This commit is contained in:
yumo 2023-12-07 14:21:09 +08:00
parent b8002d2503
commit 54934945cc
56 changed files with 337 additions and 299 deletions

View File

@ -7,7 +7,7 @@ if (!function_exists('un_camelize')) {
* @param string $separator
* @return string
*/
function un_camelize($camelCaps, $separator = '_'): string
function un_camelize($camelCaps, string $separator = '_'): string
{
return strtolower(preg_replace('/([a-z])([A-Z])/', "$1" . $separator . "$2", $camelCaps));
}
@ -108,7 +108,7 @@ if (!function_exists('get_dir')) {
* @return mixed
* @date 2021-02-17 21:27
*/
function get_dir($dir): mixed
function get_dir($dir)
{
$dirArray[] = NULL;
if (($handle = opendir($dir))) {

View File

@ -17,6 +17,7 @@ use think\Exception;
use think\facade\Db;
use think\Facade\Log;
use think\facade\Route as Url;
use think\Response;
/**
* 账号管理
@ -30,7 +31,7 @@ class Admin extends AuthController
* @return string
* @throws \Exception
*/
public function index()
public function index(): string
{
$this->assign("auths", rModel::getAuthLst());
return $this->fetch();
@ -44,7 +45,7 @@ class Admin extends AuthController
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request)
public function lst(Request $request): Response
{
$where = Util::postMore([
['username', ''],
@ -66,6 +67,7 @@ class Admin extends AuthController
* @throws DbException
* @throws FormBuilderException
* @throws ModelNotFoundException
* @throws \Exception
*/
public function add(): string
{
@ -86,7 +88,7 @@ class Admin extends AuthController
$form[] = Elm::input('tel', '电话')->col(10);
$form[] = Elm::email('email', '邮箱')->col(10);
$form[] = Elm::radio('status', '状态', 1)->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('save')->build());
$form = Form::make_post_form($form, url('/admin/admin/save')->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -99,19 +101,20 @@ class Admin extends AuthController
* @throws DbException
* @throws FormBuilderException
* @throws ModelNotFoundException
* @throws \Exception
*/
public function edit($id = ""): string
public function edit(string $id = ""): string
{
if (!$id) return app("json")->fail("账号id不能为空");
$ainfo = aModel::find($id);
if (!$ainfo) return app("json")->fail("没有该账号");
$info = (new \app\admin\model\Admin)->find($id);
if (!$info) return app("json")->fail("没有该账号");
$form = array();
$form[] = Elm::input('username', '登录账号', $ainfo['username'])->col(10);
$form[] = Elm::input('nickname', '昵称', $ainfo['nickname'])->col(10);
$form[] = Elm::frameImage('avatar', '头像', Url::buildUrl('admin/image/index', array('fodder' => 'avatar', 'limit' => 1)), $ainfo['avatar'])->icon("ios-image")->width('96%')->height('440px')->col(10);
$form[] = Elm::password('password', '密码', $ainfo['password'])->col(10);
$form[] = Elm::input('realname', '真实姓名', $ainfo['realname'])->col(10);
$form[] = Elm::select('role_id', '角色', $ainfo['role_id'])->options(function () {
$form[] = Elm::input('username', '登录账号', $info['username'])->col(10);
$form[] = Elm::input('nickname', '昵称', $info['nickname'])->col(10);
$form[] = Elm::frameImage('avatar', '头像', Url::buildUrl('admin/image/index', array('fodder' => 'avatar', 'limit' => 1)), $info['avatar'])->icon("ios-image")->width('96%')->height('440px')->col(10);
$form[] = Elm::password('password', '密码', $info['password'])->col(10);
$form[] = Elm::input('realname', '真实姓名', $info['realname'])->col(10);
$form[] = Elm::select('role_id', '角色', $info['role_id'])->options(function () {
$list = rModel::getAuthLst();
$menus = [];
foreach ($list as $menu) {
@ -119,10 +122,10 @@ class Admin extends AuthController
}
return $menus;
})->col(10);
$form[] = Elm::input('tel', '电话', $ainfo['tel'])->col(10);
$form[] = Elm::email('email', '邮箱', $ainfo['email'])->col(10);
$form[] = Elm::radio('status', '状态', $ainfo['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('save', ['id' => $id])->build());
$form[] = Elm::input('tel', '电话', $info['tel'])->col(10);
$form[] = Elm::email('email', '邮箱', $info['email'])->col(10);
$form[] = Elm::radio('status', '状态', $info['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('/admin/admin/save', ['id' => $id])->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -132,7 +135,7 @@ class Admin extends AuthController
* @param string $id
* @return mixed
*/
public function save(string $id = ""): mixed
public function save(string $id = "")
{
$data = Util::postMore([
['username', ''],
@ -203,14 +206,14 @@ class Admin extends AuthController
* @param Request $request
* @return mixed
*/
public function changePwd(Request $request): mixed
public function changePwd(Request $request)
{
$data = Util::postMore([
['oldpwd', ''],
['newpwd', '']
],$request);
if ($data['oldpwd'] == '' || $data['newpwd'] == '') return app("json")->fail("参数有误,新旧密码为空!");
$adminInfo = aModel::find($this->adminId);
$adminInfo = (new \app\admin\model\Admin)->find($this->adminId);
if ($adminInfo['password'] == md5(md5($data['oldpwd']))) return aModel::update(['password' => md5(md5($data['newpwd']))], ['id' => $this->adminId]) ? app("json")->success("操作成功") : app("json")->fail("操作失败");
return app("json")->fail("密码不正确!");
}
@ -220,7 +223,7 @@ class Admin extends AuthController
* @return string
* @throws \Exception
*/
public function profile()
public function profile(): string
{
$this->assign("info", aModel::find($this->adminId));
return $this->fetch();
@ -231,7 +234,7 @@ class Admin extends AuthController
* @param Request $request
* @return mixed
*/
public function changProfile(Request $request): mixed
public function changProfile(Request $request): Response
{
$data = Util::postMore([
['nickname', ''],

View File

@ -13,6 +13,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Route as Url;
use think\Response;
/**
* 权限管理
@ -21,7 +22,10 @@ use think\facade\Route as Url;
*/
class AdminAuth extends AuthController
{
public function index()
/**
* @throws Exception
*/
public function index(): string
{
return $this->fetch();
}
@ -29,12 +33,12 @@ class AdminAuth extends AuthController
/**
* 权限列表
* @param Request $request
* @return array
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request): array
public function lst(Request $request): Response
{
$where = Util::postMore([
['name', ''],
@ -53,7 +57,7 @@ class AdminAuth extends AuthController
* @throws ModelNotFoundException
* @throws Exception
*/
public function add(int $pid = 0)
public function add(int $pid = 0): string
{
$form = array();
$form[] = Elm::select('pid', '上级权限', (int)$pid)->options(aModel::returnOptions())->col(10);
@ -66,7 +70,7 @@ class AdminAuth extends AuthController
$form[] = Elm::number('rank', '排序')->col(10);
$form[] = Elm::radio('is_menu', '是否菜单', 1)->options([['label' => '是', 'value' => 1], ['label' => '否', 'value' => 0]])->col(10);
$form[] = Elm::radio('status', '状态', 1)->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('save')->build());
$form = Form::make_post_form($form, url('/admin/admin_auth/save')->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -81,7 +85,7 @@ class AdminAuth extends AuthController
* @throws ModelNotFoundException
* @throws Exception
*/
public function edit($id = 0): string
public function edit(int $id = 0): string
{
if (!$id) return app("json")->fail("权限id不能为空");
$info = (new \app\admin\model\AdminAuth)->find($id);
@ -97,17 +101,17 @@ class AdminAuth extends AuthController
$form[] = Elm::number('rank', '排序', $info['rank'])->col(10);
$form[] = Elm::radio('is_menu', '是否菜单', $info['is_menu'])->options([['label' => '是', 'value' => 1], ['label' => '否', 'value' => 0]])->col(10);
$form[] = Elm::radio('status', '状态', $info['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('save', ['id' => $id])->build());
$form = Form::make_post_form($form, url('/admin/admin_auth/save', ['id' => $id])->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
/**
* 保存
* @param $id
* @return
* @param string $id
* @return mixed
*/
public function save($id = "")
public function save(string $id = "")
{
$data = Util::postMore([
['name', ''],
@ -144,9 +148,9 @@ class AdminAuth extends AuthController
/**
* 修改字段
* @param $id
* @return aModel
* @return Response
*/
public function field($id)
public function field($id): Response
{
if (!$id) return app("json")->fail("参数有误Id为空");
$where = Util::postMore([['field', ''], ['value', '']]);

View File

@ -9,6 +9,7 @@ use Exception;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Response;
/**
* 日志
@ -24,7 +25,7 @@ class AdminLog extends AuthController
* @return string
* @throws Exception
*/
public function index()
public function index(): string
{
return $this->fetch();
}
@ -32,12 +33,10 @@ class AdminLog extends AuthController
/**
* 权限列表
* @param Request $request
* @return array
* @throws DataNotFoundException
* @return Response
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request): array
public function lst(Request $request): Response
{
$where = Util::postMore([
['name', ''],

View File

@ -18,7 +18,7 @@ class AdminNotify extends AuthController
* @return mixed
* @throws Exception
*/
public function index()
public function index() : string
{
$where = Util::postMore([
['title', ''],

View File

@ -12,10 +12,11 @@ use FormBuilder\Factory\Elm;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Response;
class AdminRole extends AuthController
{
public function index()
public function index(): string
{
return $this->fetch();
}
@ -28,7 +29,7 @@ class AdminRole extends AuthController
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request): array
public function lst(Request $request): Response
{
return app("json")->layui(rModel::systemPage());
}
@ -50,7 +51,7 @@ class AdminRole extends AuthController
$form[] = Elm::treeChecked('tree_data', '选择权限')->data(aModel::selectAndBuildTree(0, $pid != 0 ? explode(",", rModel::find($pid)['auth']) : ($this->adminId == 1 ? aModel::getIds() : $this->auth)))->col(18);
$form[] = Elm::number('rank', '排序')->col(18);
$form[] = Elm::radio('status', '状态', 1)->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(18);
$form = Form::make_post_form($form, url('save')->build());
$form = Form::make_post_form($form, url('/admin/admin_role/save')->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -75,7 +76,7 @@ class AdminRole extends AuthController
$form[] = Elm::treeChecked('tree_data', '选择权限', to_int_array(explode(",", $rinfo['tree_data'])))->data(aModel::selectAndBuildTree(0, $rinfo['pid'] == 0 ? aModel::getIds() : explode(",", rModel::find($rinfo['pid'])['auth'])))->col(18);
$form[] = Elm::number('rank', '排序', $rinfo['rank'])->col(18);
$form[] = Elm::radio('status', '状态', $rinfo['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(18);
$form = Form::make_post_form($form, url('save', ['id' => $id])->build());
$form = Form::make_post_form($form, url('/admin/admin_role/save', ['id' => $id])->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}

View File

@ -15,6 +15,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Route as Url;
use think\Response;
/**
* Class Advert
@ -25,7 +26,7 @@ use think\facade\Route as Url;
class Advert extends AuthController
{
public function index()
public function index() : string
{
return $this->fetch();
}
@ -33,9 +34,12 @@ class Advert extends AuthController
/**
* 列表
* @param Request $request
* @return
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request)
public function lst(Request $request): Response
{
$where = Util::postMore([
['title', ''],
@ -62,7 +66,7 @@ class Advert extends AuthController
$form[] = Elm::input('alias', '标识')->col(10);
$form[] = Elm::input('description', '描述')->col(20);
$form[] = Elm::radio('status', '状态', 1)->options([['label' => '禁用', 'value' => 0], ['label' => '启用', 'value' => 1]])->col(24);
$form = Form::make_post_form($form, url('save')->build());
$form = Form::make_post_form($form, url('/admin/advert/save')->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -83,7 +87,7 @@ class Advert extends AuthController
$form[] = Elm::input('alias', '标识', $info['alias'])->col(10);
$form[] = Elm::input('description', '描述', $info['description'])->col(20);
$form[] = Elm::radio('status', '状态', $info['status'])->options([['label' => '禁用', 'value' => 0], ['label' => '启用', 'value' => 1]])->col(24);
$form = Form::make_post_form($form, url('save', ["id" => $id])->build());
$form = Form::make_post_form($form, url('/admin/advert/save', ["id" => $id])->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -93,7 +97,7 @@ class Advert extends AuthController
* @param string $id
* @return mixed
*/
public function save($id = ""): mixed
public function save($id = "")
{
$data = Util::postMore([
['title', ''],
@ -124,7 +128,7 @@ class Advert extends AuthController
* @author 木子的忧伤
* @date 2021-02-16 23:12
*/
public function field($id): mixed
public function field($id)
{
if (!$id) return app("json")->fail("参数有误Id为空");
$where = Util::postMore([['field', ''], ['value', '']]);
@ -172,7 +176,7 @@ class Advert extends AuthController
* @author 木子的忧伤
* @date 2021-02-15 23:26
*/
public function infoList(Request $request): mixed
public function infoList(Request $request)
{
$where = Util::postMore([
['id', ''],
@ -208,7 +212,7 @@ class Advert extends AuthController
return $options;
})->col(10);
$form[] = Elm::radio('status', '状态', 1)->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('saveAdvert')->build());
$form = Form::make_post_form($form, url('/admin/advert/saveAdvert')->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -241,7 +245,7 @@ class Advert extends AuthController
return $options;
})->col(10);
$form[] = Elm::radio('status', '状态', $info['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('saveAdvert', ['id' => $id])->build());
$form = Form::make_post_form($form, url('/admin/advert/saveAdvert', ['id' => $id])->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -251,7 +255,7 @@ class Advert extends AuthController
* @param string $id
* @return mixed
*/
public function saveAdvert($id = ""): mixed
public function saveAdvert($id = "")
{
$data = Util::postMore([
['id', ''],

View File

@ -23,7 +23,7 @@ class Article extends AuthController
/**
* 构造方法 初始化一些参数
*/
public function initialize()
public function initialize(): void
{
parent::initialize();
//修正因为修改model名称和原来不能对应导致的model功能异常
@ -35,7 +35,7 @@ class Article extends AuthController
* @return string
* @throws \Exception
*/
public function index()
public function index(): string
{
return $this->fetch();
}
@ -125,15 +125,16 @@ class Article extends AuthController
/**
* 新增文章
* @param $category_id
* @param string $category_id
* @return string
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws \Exception
* @author 木子的忧伤
* @date 2021-03-10 14:46
*/
public function add($category_id = '')
public function add(string $category_id = '')
{
$where = [
'name' => '',
@ -177,7 +178,7 @@ class Article extends AuthController
* @return string
* @throws \Exception
*/
public function comment()
public function comment(): string
{
return $this->fetch();
}
@ -192,7 +193,7 @@ class Article extends AuthController
* @author 木子的忧伤
* @date 2021-11-03 23:28
*/
public function commentList(Request $request): mixed
public function commentList(Request $request)
{
$where = Util::postMore([
['document_id', ''],
@ -216,7 +217,7 @@ class Article extends AuthController
* @author 木子的忧伤
* @date 2021-02-16 23:12
*/
public function commentField($id): mixed
public function commentField($id)
{
if (!$id) return app("json")->fail("参数有误Id为空");
$where = Util::postMore([['field', ''], ['value', '']]);

View File

@ -154,7 +154,13 @@ abstract class AuthController extends SystemBasic
{
$path = explode(".", $this->request->controller());
$modelPath = "app\\common\\model"; //全部为common
foreach ($path as $v) $modelPath .= "\\" . $v;
foreach ($path as $v) {
if (substr($v,0,5) == "Admin"){
//后台用户相关的需要特殊处理
$modelPath = "app\\admin\\model"; //全部为common
}
$modelPath .= "\\" . $v;
}
if (class_exists($modelPath)) return app($modelPath);
return null;
}

View File

@ -10,6 +10,7 @@ use Exception;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Response;
/**
* Class Article
@ -26,7 +27,7 @@ class Category extends AuthController
* @author 木子的忧伤
* @date 2021-02-17 11:40
*/
public function index()
public function index(): string
{
return $this->fetch();
}
@ -34,12 +35,12 @@ class Category extends AuthController
/**
* 权限列表
* @param Request $request
* @return array
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request): array
public function lst(Request $request): Response
{
$where = Util::postMore([
['name', ''],
@ -50,8 +51,7 @@ class Category extends AuthController
/**
* 保存
* @param $id
* @return
* @return mixed
*/
public function save()
{
@ -103,7 +103,7 @@ class Category extends AuthController
* @throws DbException
* @throws ModelNotFoundException
*/
public function add($pid = ''): string
public function add(string $pid = ''): string
{
$templatePath = system_config('web_template');
$themeInfoFile = public_path('template' . DIRECTORY_SEPARATOR . $templatePath) . 'info.json';
@ -132,7 +132,7 @@ class Category extends AuthController
* @author 木子的忧伤
* @date 2021-02-20 17:00
*/
public function edit(Request $request)
public function edit(Request $request): string
{
$templatePath = system_config('web_template');
$themeInfoFile = public_path('template' . DIRECTORY_SEPARATOR . $templatePath) . 'info.json';

View File

@ -11,6 +11,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Db;
use think\Response;
/*
* 数据库备份还原控制器
@ -57,7 +58,7 @@ class Databases extends AuthController
* @author 木子的忧伤
* @date 2021-10-31 0:12
*/
public function lst(Request $request)
public function lst(Request $request): Response
{
$data = Util::postMore([
['type', 'export'],

View File

@ -70,7 +70,7 @@ class File extends AuthController
/**
* @单文件上传
* @param string $type 类型 files image documents banners
* @param Request $request
* @return mixed
*/
public function upload(Request $request)

View File

@ -14,6 +14,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Route as Url;
use think\Response;
/**
* Class Message
@ -28,7 +29,7 @@ class FriendLink extends AuthController
* @return string
* @throws Exception
*/
public function index()
public function index() : string
{
return $this->fetch();
}
@ -43,7 +44,7 @@ class FriendLink extends AuthController
* @author 木子的忧伤
* @date 2021-02-15 23:26
*/
public function lst(Request $request)
public function lst(Request $request): Response
{
$where = Util::postMore([
['title', ''],
@ -70,7 +71,7 @@ class FriendLink extends AuthController
$form[] = Elm::input('sort', '排序')->col(10);
$form[] = Elm::textarea('description', '描述')->col(10);
$form[] = Elm::radio('status', '状态', 1)->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('save')->build());
$form = Form::make_post_form($form, url('/admin/friend_link/save')->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -92,7 +93,7 @@ class FriendLink extends AuthController
$form[] = Elm::input('sort', '排序', $ainfo['sort'])->col(10);
$form[] = Elm::textarea('description', '描述', $ainfo['description'])->col(10);
$form[] = Elm::radio('status', '状态', $ainfo['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('save', ['id' => $id])->build());
$form = Form::make_post_form($form, url('/admin/friend_link/save', ['id' => $id])->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -102,7 +103,7 @@ class FriendLink extends AuthController
* @param string $id
* @return mixed
*/
public function save($id = "")
public function save(string $id = "")
{
$data = Util::postMore([
['id', ''],

View File

@ -9,7 +9,10 @@ namespace app\admin\controller;
*/
class Icon extends AuthController
{
public function index()
/**
* @throws \Exception
*/
public function index(): string
{
return $this->fetch();
}

View File

@ -26,7 +26,10 @@ class Image extends AuthController
*/
private $type = "image";
public function index()
/**
* @throws Exception
*/
public function index() : string
{
return $this->fetch();
}
@ -37,7 +40,7 @@ class Image extends AuthController
* @throws DbException
* @throws ModelNotFoundException
*/
public function category()
public function category(): array
{
return app("json")->success(AttachmentCategory::buildNodes($this->type, 0, $this->request->param("title", "")));
}
@ -48,8 +51,9 @@ class Image extends AuthController
* @param int $pid
* @return string
* @throws FormBuilderException
* @throws Exception
*/
public function addCategory($id = 0, $pid = 0)
public function addCategory($id = 0, $pid = 0): string
{
$form = array();
$form[] = Elm::select('pid', '上级分类', (int)$pid ?: (int)$id)->options(function () {
@ -61,19 +65,23 @@ class Image extends AuthController
})->col(18);
$form[] = Elm::input('name', '分类名称')->col(18);
$form[] = Elm::hidden('type', $this->type)->col(18);
$form = Form::make_post_form($form, url('saveCategory')->build());
$form = Form::make_post_form($form, url('admin/image/saveCategory')->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
/**
* 目录的修改
* @param $id
* @param int $id
* @param int $pid
* @return string
* @throws DataNotFoundException
* @throws DbException
* @throws FormBuilderException
* @throws ModelNotFoundException
* @throws Exception
*/
public function editCategory($id = 0, $pid = 0)
public function editCategory(int $id = 0, int $pid = 0): string
{
if ($id == 0) return app("json")->fail("没有选中分类");
$form = array();
@ -86,7 +94,7 @@ class Image extends AuthController
})->col(18);
$form[] = Elm::input('name', '分类名称', AttachmentCategory::getNameById($id))->col(18);
$form[] = Elm::hidden('type', $this->type)->col(18);
$form = Form::make_post_form($form, Url('saveCategory', ['id' => $id])->build());
$form = Form::make_post_form($form, Url('admin/image/saveCategory', ['id' => $id])->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -96,7 +104,7 @@ class Image extends AuthController
* @param string $id
* @return mixed
*/
public function saveCategory($id = "")
public function saveCategory(string $id = "")
{
$data = Util::postMore([
['pid', 0],
@ -117,7 +125,8 @@ class Image extends AuthController
/**
* 删除目录
* @param $id
* @return
* @return mixed
* @throws DbException
*/
public function delCategory($id)
{
@ -149,7 +158,7 @@ class Image extends AuthController
* @throws DbException
* @throws ModelNotFoundException
*/
public function editImage($id)
public function editImage($id): string
{
if ($id == 0) return app("json")->fail("没有选中图片");
$image = Attachment::find($id);

View File

@ -15,7 +15,7 @@ class Index extends AuthController
* @return string
* @throws Exception
*/
public function index()
public function index(): string
{
$this->assign("adminInfo", $this->adminInfo);
$this->assign("menu", AdminAuth::getAuthList($this->adminId,$this->auth));
@ -28,7 +28,7 @@ class Index extends AuthController
* @return string
* @throws Exception
*/
public function main()
public function main(): string
{
$this->assign("document_count", (new Document)->count());
$this->assign("user_count", (new User())->count());

View File

@ -9,6 +9,7 @@ use Exception;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Response;
/**
* Class Invitation
@ -21,7 +22,7 @@ class Invitation extends AuthController
/**
* 构造方法 初始化一些参数
*/
public function initialize()
public function initialize(): void
{
parent::initialize();
//修正因为修改model名称和原来不能对应导致的model功能异常
@ -35,7 +36,7 @@ class Invitation extends AuthController
* @author 木子的忧伤
* @date 2021-02-16 13:15
*/
public function index()
public function index(): string
{
return $this->fetch();
}
@ -50,7 +51,7 @@ class Invitation extends AuthController
* @author 木子的忧伤
* @date 2021-02-15 23:26
*/
public function lst(Request $request)
public function lst(Request $request): Response
{
$where = Util::postMore([
['code', ''],
@ -70,7 +71,7 @@ class Invitation extends AuthController
* @author 木子的忧伤
* @date 2021-02-20 14:32
*/
public function save($id = "")
public function save(string $id = "")
{
$data = Util::postMore([
['code', ''],
@ -102,21 +103,23 @@ class Invitation extends AuthController
* @author 木子的忧伤
* @date 2021-02-20 14:35
*/
public function addMultiple($id = "")
public function addMultiple(string $id = "")
{
$data = Util::postMore([
['name', ''],
['number', 1],
]);
if ($data['name'] == "") return app("json")->fail("邀请码前缀不能为空");
if ($data['number'] == "") return app("json")->fail("数量不是数字或者小于1");
$count = intval($data['number']);
$res = false;
for ($i = 0; $i < $count; $i++) {
$code['code'] = ($data['name'] . substr(time(), -6) . rand(0, 9999));
$code['status'] = 0;
$code['user'] = $this->adminId;
$check = aModel::where('code')->find();
if ($check == null || $check == false) {
$check = (new \app\common\model\InvitationCode)->where('code')->find();
if (!$check) {
$res = aModel::create($code);
} else {
continue;

View File

@ -52,7 +52,7 @@ class Login extends AuthController
* @return string
* @throws Exception
*/
public function register()
public function register(): string
{
return $this->fetch();
}
@ -62,7 +62,7 @@ class Login extends AuthController
* @return string
* @throws Exception
*/
public function forget()
public function forget(): string
{
return $this->fetch();
}
@ -81,7 +81,7 @@ class Login extends AuthController
* 验证码
* @return Response
*/
public function captcha()
public function captcha(): Response
{
ob_clean();
return captcha();

View File

@ -9,6 +9,7 @@ use Exception;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Response;
/**
* Class Message
@ -21,7 +22,7 @@ class Message extends AuthController
/**
* 构造方法 初始化一些参数
*/
public function initialize()
public function initialize(): void
{
parent::initialize();
//修正因为修改model名称和原来不能对应导致的model功能异常
@ -35,7 +36,7 @@ class Message extends AuthController
* @author 木子的忧伤
* @date 2021-02-19 11:53
*/
public function index()
public function index(): string
{
return $this->fetch();
}
@ -50,7 +51,7 @@ class Message extends AuthController
* @author 木子的忧伤
* @date 2021-02-19 11:54
*/
public function lst(Request $request)
public function lst(Request $request): Response
{
$where = Util::postMore([
['author', ''],

View File

@ -13,6 +13,7 @@ use FormBuilder\Factory\Elm;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Response;
/**
* Class Nav
@ -22,7 +23,10 @@ use think\db\exception\ModelNotFoundException;
*/
class Nav extends AuthController
{
public function index()
/**
* @throws Exception
*/
public function index() : string
{
return $this->fetch();
}
@ -35,7 +39,7 @@ class Nav extends AuthController
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request)
public function lst(Request $request): Response
{
$where = Util::postMore([
['title', ''],
@ -54,7 +58,7 @@ class Nav extends AuthController
* @throws ModelNotFoundException
* @throws Exception
*/
public function add($pid = 0)
public function add(int $pid = 0)
{
$form = array();
$form[] = Elm::select('pid', '上级导航', (int)$pid)->options(aModel::returnOptions())->col(10);
@ -64,7 +68,7 @@ class Nav extends AuthController
$form[] = Elm::input('params', '参数')->placeholder("php数组,不懂不要填写")->col(10);
$form[] = Elm::number('sort', '排序')->col(10);
$form[] = Elm::radio('status', '状态', 1)->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('save')->build());
$form = Form::make_post_form($form, url('/admin/nav/save')->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -78,20 +82,20 @@ class Nav extends AuthController
* @throws DbException
* @throws ModelNotFoundException
*/
public function edit($id = 0)
public function edit(int $id = 0)
{
if (!$id) return app("json")->fail("导航id不能为空");
$ainfo = aModel::find($id);
if (!$ainfo) return app("json")->fail("没有该导航");
$info = aModel::find($id);
if (!$info) return app("json")->fail("没有该导航");
$form = array();
$form[] = Elm::select('pid', '上级导航', $ainfo['pid'])->options(aModel::returnOptions())->col(10);
$form[] = Elm::input('title', '导航名称', $ainfo['title'])->col(10);
$form[] = Elm::select('pid', '上级导航', $info['pid'])->options(aModel::returnOptions())->col(10);
$form[] = Elm::input('title', '导航名称', $info['title'])->col(10);
//$form[] = Elm::frameInput('icon', '图标', Url::buildUrl('admin/widget.icon/index', array('fodder' => 'icon')), $ainfo['icon'])->icon("ios-ionic")->width('96%')->height('390px')->col(10);
$form[] = Elm::input('url', '链接地址', $ainfo['url'])->col(10);
$form[] = Elm::input('params', '参数', $ainfo['params'])->placeholder("php数组,不懂不要填写")->col(10);
$form[] = Elm::number('sort', '排序', $ainfo['sort'])->col(10);
$form[] = Elm::radio('status', '状态', $ainfo['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('save', ['id' => $id])->build());
$form[] = Elm::input('url', '链接地址', $info['url'])->col(10);
$form[] = Elm::input('params', '参数', $info['params'])->placeholder("php数组,不懂不要填写")->col(10);
$form[] = Elm::number('sort', '排序', $info['sort'])->col(10);
$form[] = Elm::radio('status', '状态', $info['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('/admin/nav/save', ['id' => $id])->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}

View File

@ -22,7 +22,7 @@ class Page extends AuthController
/**
* 构造方法 初始化一些参数
*/
public function initialize()
public function initialize(): void
{
parent::initialize();
//修正因为修改model名称和原来不能对应导致的model功能异常
@ -34,7 +34,7 @@ class Page extends AuthController
* @return string
* @throws \Exception
*/
public function index()
public function index(): string
{
return $this->fetch();
}
@ -64,8 +64,10 @@ class Page extends AuthController
/**
* 保存
* @param string $id
* @return mixed
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author 木子的忧伤
* @date 2021-02-28 22:43
*/
@ -124,7 +126,7 @@ class Page extends AuthController
* @return string
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws ModelNotFoundException|\Exception
* @author 木子的忧伤
* @date 2021-03-10 14:46
*/

View File

@ -16,13 +16,13 @@ class SystemBasic extends BaseController
/**
* 操作失败提示框
* @param string $msg 提示信息
* @param string $backUrl 跳转地址
* @param string $title 标题
* @param int $backUrl 跳转地址
* @param string $info
* @param int $duration 持续时间
* @return mixed
* @throws Exception
*/
protected function failedNotice($msg = '操作失败', $backUrl = 0, $info = '', $duration = 3)
protected function failedNotice(string $msg = '操作失败', $backUrl = 0, $info = '', $duration = 3)
{
$type = 'error';
$this->assign(compact('msg', 'backUrl', 'info', 'duration', 'type'));
@ -31,13 +31,13 @@ class SystemBasic extends BaseController
/**
* 失败提示一直持续
* @param $msg
* @param string $msg
* @param int $backUrl
* @param string $title
* @param string $info
* @return mixed
* @throws Exception
*/
protected function failedNoticeLast($msg = '操作失败', $backUrl = 0, $info = '')
protected function failedNoticeLast(string $msg = '操作失败', $backUrl = 0, $info = '')
{
return $this->failedNotice($msg, $backUrl, $info, 0);
}
@ -45,8 +45,8 @@ class SystemBasic extends BaseController
/**
* 操作成功提示框
* @param string $msg 提示信息
* @param string $backUrl 跳转地址
* @param string $title 标题
* @param int $backUrl 跳转地址
* @param string $info
* @param int $duration 持续时间
* @return mixed
* @throws Exception
@ -60,13 +60,13 @@ class SystemBasic extends BaseController
/**
* 成功提示一直持续
* @param $msg
* @param string $msg
* @param int $backUrl
* @param string $title
* @param string $info
* @return mixed
* @throws Exception
*/
protected function successfulNoticeLast($msg = '操作成功', $backUrl = 0, $info = '')
protected function successfulNoticeLast(string $msg = '操作成功', $backUrl = 0, $info = '')
{
return $this->successfulNotice($msg, $backUrl, $info, 0);
}
@ -77,7 +77,7 @@ class SystemBasic extends BaseController
* @param int $url
* @throws Exception
*/
protected function failed($msg = '哎呀…亲…您访问的页面出现错误', $url = 0)
protected function failed(string $msg = '哎呀…亲…您访问的页面出现错误', $url = 0)
{
if ($this->request->isAjax()) {
exit(app("json")->fail($msg, $url)->getContent());
@ -93,7 +93,7 @@ class SystemBasic extends BaseController
* @param int $url
* @throws Exception
*/
protected function successful($msg, $url = 0)
protected function successful(string $msg, $url = 0)
{
if ($this->request->isAjax()) {
exit(app("json")->success($msg, $url)->getContent());
@ -104,7 +104,7 @@ class SystemBasic extends BaseController
}
/**异常抛出
* @param $name
* @param string $msg
* @throws Exception
*/
protected function exception($msg = '无法打开页面')

View File

@ -16,6 +16,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Cache;
use think\Response;
/**
* 系统配置
@ -32,7 +33,7 @@ class SystemConfig extends AuthController
* @throws DbException
* @throws ModelNotFoundException
*/
public function base($tab_id = 1)
public function base($tab_id = 1): string
{
$system = cModel::getLstByTabId($tab_id);
//特殊处理主题信息,这里不允许修改主题信息
@ -55,38 +56,42 @@ class SystemConfig extends AuthController
/**
* @param Request $request
* @return
* @return string
* @throws InvalidArgumentException
* @throws Exception
*/
public function clearCache(Request $request)
{
if ($request->isPost()) {
$adminPath = config("cache.runtime") . "/admin/";
// $adminPath = config("cache.runtime") . "/admin/";
$commonPath = config("cache.runtime") . "/cache/";
$indexPath = config("cache.runtime") . "/index/";
$apiPath = config("cache.runtime") . "/api/";
// $indexPath = config("cache.runtime") . "/index/";
// $apiPath = config("cache.runtime") . "/api/";
Cache::clear();
if (remove_cache($adminPath) && remove_cache($indexPath) && remove_cache($apiPath) && remove_cache($commonPath)) return app("json")->success("操作成功");
return app("json")->error("操作失败");
// remove_cache($adminPath);
// remove_cache($indexPath);
// remove_cache($apiPath);
remove_cache($commonPath);
return app("json")->success("操作成功");
}
return $this->fetch();
}
/**
* 列表
* @param int $tab_id
* @param Request $request
* @return string
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request)
public function lst(Request $request): Response
{
$where = Util::postMore([
['page', 1],
['limit', 20],
['tab_id', 0]
]);
],$request);
return app("json")->layui(cModel::lst($where));
}
@ -96,7 +101,7 @@ class SystemConfig extends AuthController
* @return string
* @throws Exception
*/
public function index($tab_id = 0)
public function index(int $tab_id = 0): string
{
$this->assign("tab", tModel::find($tab_id));
return $this->fetch("list");
@ -108,7 +113,7 @@ class SystemConfig extends AuthController
* @return string
* @throws FormBuilderException
*/
public function add(Request $request)
public function add(Request $request): string
{
$form = array();
$form[] = Elm::hidden('tab_id', $request->param("tab_id"))->col(10);
@ -123,21 +128,24 @@ class SystemConfig extends AuthController
$form[] = Elm::radio('is_show', '是否显示', 1)->options([['label' => '隐藏', 'value' => 0], ['label' => '显示', 'value' => 1]])->col(10);
$form[] = Elm::radio('upload_type', '上传配置', 0)->options([['label' => '单选', 'value' => 0], ['label' => '多选', 'value' => 1]])->col(10);
$form[] = Elm::radio('status', '状态', 1)->options([['label' => '禁用', 'value' => 0], ['label' => '启用', 'value' => 1]])->col(10);
$form = Form::make_post_form($form, url('save')->build());
$form = Form::make_post_form($form, url('/admin/system_config/save')->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
/**
* 修改
* @param Request $request
* @param string $id
* @return string
* @throws DataNotFoundException
* @throws DbException
* @throws FormBuilderException
* @throws ModelNotFoundException
*/
public function edit($id = '')
public function edit(string $id = ''): string
{
if (!$id) return app("json")->fail("项目id不能为空");
$info = cModel::find($id);
$info = (new \app\common\model\SystemConfig)->find($id);
if (!$info) return app("json")->fail("没有该项目");
$form = array();
$form[] = Elm::hidden('tab_id', $info['tab_id'])->col(10);
@ -152,7 +160,7 @@ class SystemConfig extends AuthController
$form[] = Elm::radio('is_show', '是否显示', $info['is_show'])->options([['label' => '隐藏', 'value' => 0], ['label' => '显示', 'value' => 1]])->col(10);
$form[] = Elm::radio('upload_type', '上传配置', $info['upload_type'])->options([['label' => '单选', 'value' => 0], ['label' => '多选', 'value' => 1]])->col(10);
$form[] = Elm::radio('status', '状态', $info['status'])->options([['label' => '禁用', 'value' => 0], ['label' => '启用', 'value' => 1]])->col(10);
$form = Form::make_post_form($form, url('save', ["id" => $id])->build());
$form = Form::make_post_form($form, url('/admin/system_config/save', ["id" => $id])->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -162,7 +170,7 @@ class SystemConfig extends AuthController
* @param string $id
* @return mixed
*/
public function save($id = "")
public function save(string $id = "")
{
$data = Util::postMore([
['name', ''],
@ -199,7 +207,7 @@ class SystemConfig extends AuthController
/**
* 提交修改
* @param Request $request
* @return
* @return mixed
*/
public function ajaxSave(Request $request)
{

View File

@ -13,6 +13,7 @@ use FormBuilder\Factory\Elm;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Response;
/**
* 管理员配置
@ -21,7 +22,10 @@ use think\db\exception\ModelNotFoundException;
*/
class SystemConfigTab extends AuthController
{
public function index()
/**
* @throws \Exception
*/
public function index(): string
{
return $this->fetch();
}
@ -29,9 +33,12 @@ class SystemConfigTab extends AuthController
/**
* 列表
* @param Request $request
* @return
* @return Response
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request)
public function lst(Request $request): Response
{
$where = Util::postMore([
['page', 1],
@ -47,25 +54,29 @@ class SystemConfigTab extends AuthController
* @param Request $request
* @return string
* @throws FormBuilderException
* @throws \Exception
*/
public function add(Request $request)
public function add(Request $request): string
{
$form = array();
$form[] = Elm::input('name', '分类名称')->col(10);
$form[] = Elm::number('rank', '排序', 0)->col(24);
$form[] = Elm::radio('status', '状态', 1)->options([['label' => '禁用', 'value' => 0], ['label' => '启用', 'value' => 1]])->col(24);
$form = Form::make_post_form($form, url('save')->build());
$form = Form::make_post_form($form, url('/admin/system_config_tab/save')->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
/**
* 修改
* @param Request $request
* @param string $id
* @return string
* @throws DataNotFoundException
* @throws DbException
* @throws FormBuilderException
* @throws ModelNotFoundException
*/
public function edit($id = '')
public function edit($id = ''): string
{
if (!$id) return app("json")->fail("项目id不能为空");
$info = tModel::find($id);
@ -74,7 +85,7 @@ class SystemConfigTab extends AuthController
$form[] = Elm::input('name', '分类名称', $info['name'])->col(10);
$form[] = Elm::number('rank', '排序', $info['rank'])->col(24);
$form[] = Elm::radio('status', '状态', $info['status'])->options([['label' => '禁用', 'value' => 0], ['label' => '启用', 'value' => 1]])->col(24);
$form = Form::make_post_form($form, url('save', ["id" => $id])->build());
$form = Form::make_post_form($form, url('/admin/system_config_tab/save', ["id" => $id])->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -84,7 +95,7 @@ class SystemConfigTab extends AuthController
* @param string $id
* @return mixed
*/
public function save($id = "")
public function save(string $id = "")
{
$data = Util::postMore([
['name', ''],

View File

@ -11,7 +11,10 @@ use app\Request;
*/
trait TemplateTrait
{
public function index()
/**
* @throws \Exception
*/
public function index(): string
{
return $this->fetch();
}

View File

@ -3,6 +3,7 @@
namespace app\admin\controller;
use app\admin\extend\Util as Util;
use app\common\constant\Data;
use app\common\model\SystemConfig as cModel;
use Exception;
@ -21,7 +22,7 @@ class Theme extends AuthController
* @author 木子的忧伤
* @date 2021-02-17 11:40
*/
public function index()
public function index() : string
{
$themeList = [];
// 寻找有多少主题
@ -57,14 +58,14 @@ class Theme extends AuthController
* @author 木子的忧伤
* @date 2021-02-17 11:40
*/
public function change_theme()
public function change_theme(): string
{
$data = Util::postMore([
['value', ''],
]);
if ($data['value'] == "") return app("json")->fail("主题不能为空");
$res = cModel::update($data, ['form_name' => 'web_template']);
cache(Config::DATA_SYSTEM_CONFIG, null);//清除缓存
cache(Data::DATA_SYSTEM_CONFIG, null);//清除缓存
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败");
}
}

View File

@ -13,6 +13,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Route as Url;
use think\Response;
/**
* 用户管理
@ -28,7 +29,7 @@ class User extends AuthController
* @return string
* @throws Exception
*/
public function index()
public function index(): string
{
return $this->fetch();
}
@ -41,7 +42,7 @@ class User extends AuthController
* @throws DbException
* @throws ModelNotFoundException
*/
public function lst(Request $request)
public function lst(Request $request): Response
{
$where = Util::postMore([
['username', ''],
@ -61,8 +62,9 @@ class User extends AuthController
* @param Request $request
* @return string
* @throws FormBuilderException
* @throws Exception
*/
public function add(Request $request)
public function add(Request $request): string
{
$form = array();
$form[] = Elm::input('username', '登录账号')->col(10);
@ -73,31 +75,35 @@ class User extends AuthController
$form[] = Elm::email('email', '邮箱')->col(10);
$form[] = Elm::radio('is_admin', '管理员', 0)->options([['label' => '是', 'value' => 1], ['label' => '否', 'value' => 0]])->col(10);
$form[] = Elm::radio('status', '状态', 1)->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('save')->build());
$form = Form::make_post_form($form, url('/admin/user/save')->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
/**
* 修改账号
* @param string $id
* @return string
* @throws DataNotFoundException
* @throws DbException
* @throws FormBuilderException
* @throws ModelNotFoundException
*/
public function edit($id = "")
public function edit($id = ""): string
{
if (!$id) return app("json")->fail("账号id不能为空");
$ainfo = aModel::find($id);
if (!$ainfo) return app("json")->fail("没有该账号");
$info = aModel::find($id);
if (!$info) return app("json")->fail("没有该账号");
$form = array();
$form[] = Elm::input('username', '登录账号', $ainfo['username'])->col(10);
$form[] = Elm::input('nickname', '昵称', $ainfo['nickname'])->col(10);
$form[] = Elm::frameImage('avatar', '头像', Url::buildUrl('admin/image/index', array('fodder' => 'avatar', 'limit' => 1)), $ainfo['avatar'])->icon("ios-image")->width('96%')->height('440px')->col(10);
$form[] = Elm::password('password', '密码', $ainfo['password'])->col(10);
$form[] = Elm::input('tel', '电话', $ainfo['tel'])->col(10);
$form[] = Elm::email('email', '邮箱', $ainfo['email'])->col(10);
$form[] = Elm::radio('is_admin', '管理员', $ainfo['is_admin'])->options([['label' => '是', 'value' => 1], ['label' => '否', 'value' => 0]])->col(10);
$form[] = Elm::radio('status', '状态', $ainfo['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('save', ['id' => $id])->build());
$form[] = Elm::input('username', '登录账号', $info['username'])->col(10);
$form[] = Elm::input('nickname', '昵称', $info['nickname'])->col(10);
$form[] = Elm::frameImage('avatar', '头像', Url::buildUrl('admin/image/index', array('fodder' => 'avatar', 'limit' => 1)), $info['avatar'])->icon("ios-image")->width('96%')->height('440px')->col(10);
$form[] = Elm::password('password', '密码', $info['password'])->col(10);
$form[] = Elm::input('tel', '电话', $info['tel'])->col(10);
$form[] = Elm::email('email', '邮箱', $info['email'])->col(10);
$form[] = Elm::radio('is_admin', '管理员', $info['is_admin'])->options([['label' => '是', 'value' => 1], ['label' => '否', 'value' => 0]])->col(10);
$form[] = Elm::radio('status', '状态', $info['status'])->options([['label' => '启用', 'value' => 1], ['label' => '冻结', 'value' => 0]])->col(10);
$form = Form::make_post_form($form, url('/admin/user/save', ['id' => $id])->build());
$this->assign(compact('form'));
return $this->fetch("public/form-builder");
}
@ -106,8 +112,11 @@ class User extends AuthController
* 保存修改
* @param string $id
* @return mixed
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function save($id = "")
public function save(string $id = "")
{
$data = Util::postMore([
['username', ''],
@ -135,8 +144,8 @@ class User extends AuthController
$data['create_user'] = $this->adminId;
$res = aModel::create($data);
} else {
$ainfo = aModel::find($id);
if ($ainfo['password'] != $data['password']) $data['password'] = md5(md5($data['password']));
$info = (new \app\common\model\User)->find($id);
if ($info['password'] != $data['password']) $data['password'] = md5(md5($data['password']));
$data['update_user'] = $this->adminId;
$res = aModel::update($data, ['id' => $id]);
}

View File

@ -17,10 +17,10 @@ class FormBuilder
* 生成表单
* @param $rule
* @param $url
* @return string|IviewForm
* @return IviewForm
* @throws FormBuilderException
*/
public static function make_post_form($rule, $url): string|IviewForm
public static function make_post_form($rule, $url): IviewForm
{
$form = new IviewForm($url);
$form->setMethod('POST');

View File

@ -19,8 +19,8 @@ class Admin extends BaseModel
{
/**
* 登录
* @param $username
* @param $pwd
* @param string $username
* @param string $pwd
* @return bool
* @throws DataNotFoundException
* @throws DbException
@ -28,7 +28,7 @@ class Admin extends BaseModel
*/
public static function login(string $username, string $pwd): bool
{
$info = self::where("username|tel", "=", $username)->find();
$info = (new Admin)->where("username|tel", "=", $username)->find();
if (empty($info)) return self::setErrorInfo("登录账号不存在");
if ($info['password'] != md5(md5($pwd))) return self::setErrorInfo("密码不正确!");
if ($info['status'] != 1) return self::setErrorInfo("账号已被冻结!");
@ -41,7 +41,7 @@ class Admin extends BaseModel
* @param $info
* @return bool
*/
public static function setLoginInfo($info)
public static function setLoginInfo($info): bool
{
unset($info->password);//去除密码字段
$info->role_auth = AdminRole::getAuth($info['role_id'] ?? 0);//提前缓存auth字段避免频繁查询
@ -54,7 +54,7 @@ class Admin extends BaseModel
/**
* 退出登录
*/
public static function clearLoginInfo()
public static function clearLoginInfo(): bool
{
Session::delete(Data::SESSION_KEY_ADMIN_ID);
Session::delete(Data::SESSION_KEY_ADMIN_INFO);

View File

@ -133,7 +133,7 @@ class AdminAuth extends BaseModel
* @author 木子的忧伤
* @date 2021-06-09 17:24
*/
public static function getMenuCacheKey($adminId)
public static function getMenuCacheKey($adminId): string
{
return 'menu:List:' . $adminId;
}
@ -143,7 +143,7 @@ class AdminAuth extends BaseModel
* @author 木子的忧伤
* @date 2021-06-15 11:11
*/
public static function getAuthCacheKey()
public static function getAuthCacheKey(): string
{
return 'auth:key:list';
}
@ -161,7 +161,7 @@ class AdminAuth extends BaseModel
* @param int $num
* @param bool $clear
*/
public static function myOptions(array $data, &$list, $num = 0, $clear = true)
public static function myOptions(array $data, &$list, $num = 0, bool $clear = true)
{
foreach ($data as $k => $v) {
$list[] = ['value' => $v['id'], 'label' => cross($num) . $v['name']];
@ -218,8 +218,8 @@ class AdminAuth extends BaseModel
*/
public static function getIds(array $ids = []): array
{
if (empty($ids)) return self::where("status", 1)->column("id");
$pids = self::where("id", "in", $ids)->column("pid");
if (empty($ids)) return (new AdminAuth)->where("status", 1)->column("id");
$pids = (new AdminAuth)->where("id", "in", $ids)->column("pid");
return array_merge($ids, $pids) ?: [];
}
@ -230,7 +230,7 @@ class AdminAuth extends BaseModel
* @param string $action
* @return string
*/
public static function getNameByAction(string $module, string $controller, string $action)
public static function getNameByAction(string $module, string $controller, string $action): string
{
return self::where("module", $module)->where("controller", $controller)->where("action", $action)->value("name") ?: '未知操作';
}

View File

@ -42,9 +42,13 @@ class AdminNotify extends BaseModel
* @param array $data
* @return int|string
*/
public static function addLog(array $data): int|string
public static function addLog(array $data): bool
{
return self::create($data);
if (self::create($data)){
return true;
}else{
return false;
}
}
/**

View File

@ -128,7 +128,7 @@ class AdminRole extends BaseModel
* @param array $children
* @return array
*/
public static function buildTreeData($id, $title, $children = []): array
public static function buildTreeData($id, $title, array $children = []): array
{
$tree = Elm::TreeData($id, $title);
if (!empty($children)) $tree = $tree->children($children);

View File

@ -16,7 +16,7 @@ class AdminSubscribe
* 记录操作日志
* @param $event
*/
public function onAdminLog($event)
public function onAdminLog($event): void
{
list($adminInfo, $module, $controller, $action) = $event;
AdminLog::saveLog($adminInfo, $module, $controller, $action);

View File

@ -67,7 +67,7 @@
<script type="text/javascript">
$('#tb_departments').bootstrapTable({
classes: 'table table-bordered table-hover table-striped',
url: '/admin/admin_log/Lst',
url: '/admin/admin_log/lst',
method: 'post',
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
uniqueId: 'id',

View File

@ -58,7 +58,7 @@
<script type="text/javascript">
$('#tb_departments').bootstrapTable({
classes: 'table table-bordered table-hover table-striped',
url: '/admin/article/Lst',
url: '/admin/article/lst',
method: 'post',
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
uniqueId: 'id',

View File

@ -49,7 +49,7 @@
var loadIndex;
$('#tb_departments').bootstrapTable({
classes: 'table table-bordered table-hover table-striped',
url: '/admin/databases/Lst',
url: '/admin/databases/lst',
method: 'post',
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
uniqueId: 'id',

View File

@ -25,7 +25,7 @@
<script type="text/javascript">
$('#tb_departments').bootstrapTable({
classes: 'table table-bordered table-hover table-striped',
url: '/admin/databases/Lst?type=import',
url: '/admin/databases/lst?type=import',
method: 'post',
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
uniqueId: 'id',

View File

@ -97,7 +97,7 @@
<li class="dropdown dropdown-profile">
<a href="javascript:void(0)" data-toggle="dropdown">
<img class="img-avatar img-avatar-48 m-r-10" src="{$adminInfo.avatar}"
alt="{$adminInfo.nickname}" style="width: 32px;height: 32px;"/>
alt="{$adminInfo.nickname}" onerror="this.src='/static/admin/img/avatar.png'" style="width: 32px;height: 32px;"/>
<span>{$adminInfo.nickname} <span class="caret"></span></span>
</a>
<ul class="dropdown-menu dropdown-menu-right">

View File

@ -64,7 +64,7 @@
<script type="text/javascript">
$('#tb_departments').bootstrapTable({
classes: 'table table-bordered table-hover table-striped',
url: '/admin/invitation/Lst',
url: '/admin/invitation/lst',
method: 'post',
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
uniqueId: 'id',

View File

@ -74,7 +74,7 @@
<script type="text/javascript">
$('#tb_departments').bootstrapTable({
classes: 'table table-bordered table-hover table-striped',
url: '/admin/message/Lst',
url: '/admin/message/lst',
method: 'post',
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
uniqueId: 'id',

View File

@ -58,7 +58,7 @@
<script type="text/javascript">
$('#tb_departments').bootstrapTable({
classes: 'table table-bordered table-hover table-striped',
url: '/admin/page/Lst',
url: '/admin/page/lst',
method: 'post',
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
uniqueId: 'id',

View File

@ -15,7 +15,7 @@ class Index extends Base
/**
* 入口跳转链接
*/
public function index()
public function index() : string
{
return app("json")->success("获取成功", 'code');
}

View File

@ -116,7 +116,7 @@ class Json
/**
* layui返回
* @param array|string $msg
* @param array $data
* @param array|null $data
* @return Response
*/
public function layui($msg = '', ?array $data = []): Response

View File

@ -4,6 +4,10 @@
namespace app\common\model;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* Class attachment
* @package app\admin\model\widget
@ -38,12 +42,15 @@ class Attachment extends BaseModel
* 分页显示
* @param array $where
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public static function pagination(array $where)
public static function pagination(array $where): array
{
$model = self::where("type", $where['type']);
$model = (new Attachment)->where("type", $where['type']);
if ($where['cid'] != "") $model = $model->where("cid", $where['cid']);
$count = self::count();
$count = (new Attachment)->count();
$model = $model->order("id desc");
$model = $model->field("id,path");
$data = $model->page((int)$where['page'], (int)$where['limit'])->select();

View File

@ -43,49 +43,4 @@ trait ModelTrait
$map = !is_array($map) ? [$field => $map] : $map;
return 0 < $model->where($map)->count();
}
/**
* 分页
* @param null $model 模型
* @param null $eachFn 处理结果函数
* @param array $params 分页参数
* @param int $limit 分页数
* @return BaseQuery
*/
public static function page($model = null, $eachFn = null, $params = [], $limit = 20): BaseQuery|array|null
{
if (is_numeric($eachFn) && is_numeric($model)) {
return parent::page($model, $eachFn);
}
if (is_numeric($eachFn)) {
$limit = $eachFn;
$eachFn = null;
} else if (is_array($eachFn)) {
$params = $eachFn;
$eachFn = null;
}
if (is_callable($model)) {
$eachFn = $model;
$model = null;
} elseif (is_numeric($model)) {
$limit = $model;
$model = null;
} elseif (is_array($model)) {
$params = $model;
$model = null;
}
if (is_numeric($params)) {
$limit = $params;
$params = [];
}
$paginate = $model === null ? self::paginate($limit, false, ['query' => $params]) : $model->paginate($limit, false, ['query' => $params]);
$list = is_callable($eachFn) ? $paginate->each($eachFn) : $paginate;
$page = $list->render();
$total = $list->total();
return compact('list', 'page', 'total');
}
}

View File

@ -15,17 +15,17 @@ class PvLog extends BaseModel
public function del_data()
{
//获取七天前日期
$dateinfo = date('Y-m-d', strtotime('-7 days'));
$date_info = date('Y-m-d', strtotime('-7 days'));
//转换为时间戳
$shijianchuo = strtotime($dateinfo);
$start_time = strtotime($date_info);
//删除pv
$this->where('create_time', '<', $shijianchuo)->delete();
$this->where('create_time', '<', $start_time)->delete();
//删除url
$urlLogModel = new UrlLogModel();
$urlLogModel->where('create_time', '<', $shijianchuo)->delete();
$urlLogModel->where('create_time', '<', $start_time)->delete();
//删除uv
$uvLogModel = new UvLogModel();
$uvLogModel->where('create_time', '<', $shijianchuo)->delete();
$uvLogModel->where('create_time', '<', $start_time)->delete();
}
public function set_view()

View File

@ -17,7 +17,7 @@ class SystemConfig extends BaseModel
{
/**
* 列表
* @param int $tab_id
* @param $where
* @return array
* @throws DataNotFoundException
* @throws DbException
@ -27,7 +27,7 @@ class SystemConfig extends BaseModel
{
$model = new self;
if ($where['tab_id']) $model = $model->where('tab_id', $where['tab_id']);
$count = self::count();
$count = (new SystemConfig)->count();
if ($where['page'] && $where['limit']) $model = $model->page((int)$where['page'], (int)$where['limit']);
$data = $model->select();
if ($data) $data = $data->toArray();

View File

@ -20,7 +20,7 @@ class SystemConfigTab extends BaseModel
* @author 木子的忧伤
* @date 2022-02-28 9:19
*/
public static function lst($where)
public static function lst($where): array
{
$model = new self;
if ($where['status'] != "") $model = $model->where("status", $where['status']);

View File

@ -36,7 +36,7 @@ class Layer extends Paginator
* @param string $text
* @return string
*/
protected function getPreviousButton($text = "上一页")
protected function getPreviousButton($text = "上一页"): string
{
if ($this->currentPage() <= 1) {
@ -56,7 +56,7 @@ class Layer extends Paginator
* @param string $text
* @return string
*/
protected function getDisabledTextWrapper($text)
protected function getDisabledTextWrapper($text): string
{
return '<a class="layui-laypage-prev layui-disabled">' . $text . '</a>';
}
@ -83,7 +83,7 @@ class Layer extends Paginator
* @param string $text
* @return string
*/
protected function getActivePageWrapper($text)
protected function getActivePageWrapper($text): string
{
return '<span class="layui-laypage-curr"><em class="layui-laypage-em"></em><em>' . $text . '</em></span>';
}
@ -95,7 +95,7 @@ class Layer extends Paginator
* @param int $page
* @return string
*/
protected function getAvailablePageWrapper($url, $page)
protected function getAvailablePageWrapper($url, $page): string
{
return '<a href="' . htmlentities($url) . '">' . $page . '</a>';
}
@ -105,7 +105,7 @@ class Layer extends Paginator
* @param string $text
* @return string
*/
protected function getNextButton($text = '下一页')
protected function getNextButton($text = '下一页'): string
{
if (!$this->hasMore) {
return $this->getDisabledTextWrapper($text);
@ -120,7 +120,7 @@ class Layer extends Paginator
* 页码按钮
* @return string
*/
protected function getLinks()
protected function getLinks(): string
{
if ($this->simple)
return '';
@ -173,7 +173,7 @@ class Layer extends Paginator
* @param array $urls
* @return string
*/
protected function getUrlLinks(array $urls)
protected function getUrlLinks(array $urls): string
{
$html = '';
@ -189,7 +189,7 @@ class Layer extends Paginator
*
* @return string
*/
protected function getDots()
protected function getDots(): string
{
return $this->getDisabledTextWrapper('...');
}

View File

@ -286,7 +286,7 @@ function getSubs($categorys, $catId = 0, $level = 1)
/**
* @return array
*/
function get_document_category_all()
function get_document_category_all(): array
{
$documentCategoryList = get_document_category_list();
$tempArr = array();

View File

@ -104,7 +104,7 @@ class Article extends Base
* @author 木子的忧伤
* @date 2021-10-29 0:17
*/
public function detail()
public function detail(): string
{
$id = input('id');
if (!$id) {
@ -209,11 +209,11 @@ class Article extends Base
/**
* 文章标签页面
* @return string
* @throws ModelNotFoundException|\Exception
* @throws \Exception
* @author 木子的忧伤
* @date 2021-10-29 0:19
*/
public function tag()
public function tag(): string
{
$tag = input('t');
if (!trim($tag)) {
@ -246,13 +246,11 @@ class Article extends Base
/**
* 搜索页面
* @return string
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws \Exception
* @author 木子的忧伤
* @date 2021-10-29 0:18
*/
public function search()
public function search(): string
{
$kw = input('kw');
if (!trim($kw)) {
@ -284,7 +282,7 @@ class Article extends Base
/**
* 用户首页
* @return string
* @throws Exception
* @throws \Exception
* @author 木子的忧伤
* @date 2022-01-24 1:23
*/

View File

@ -27,8 +27,9 @@ class Index extends Base
{
/**
* 入口跳转链接
* @throws \Exception
*/
public function index()
public function index(): string
{
//判断后台统计配置是否开启 1 开启
if (web_config("web_statistics") == 1) {
@ -50,10 +51,11 @@ class Index extends Base
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws \Exception
* @author 木子的忧伤
* @date 2021-10-17 1:03
*/
public function applylink(Request $request)
public function applyLink(Request $request): string
{
if (request()->isPost()) {
$data = Util::postMore([
@ -94,13 +96,11 @@ class Index extends Base
* 留言页面
* @param Request $request
* @return string
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws \Exception
* @author 木子的忧伤
* @date 2021-10-17 1:03
*/
public function msg(Request $request)
public function msg(Request $request): string
{
if (request()->isPost()) {
$data = Util::postMore([

View File

@ -32,7 +32,7 @@ class Page extends Base
* @author 木子的忧伤
* @date 2021-10-29 0:17
*/
public function index()
public function index() : string
{
$id = input('id');
if (!$id) {
@ -88,7 +88,7 @@ class Page extends Base
* @author 木子的忧伤
* @date 2021-10-17 19:13
*/
public function create_comment(Request $request): mixed
public function create_comment(Request $request)
{
$data = Util::postMore([
['document_id', ''],

View File

@ -51,7 +51,7 @@ class User extends Base
* @throws DbException
* @throws ModelNotFoundException
*/
public function verify(): mixed
public function verify()
{
$data = Util::postMore(['username', 'password', 'captcha'], null, true);
try {
@ -84,7 +84,7 @@ class User extends Base
* @throws DbException
* @throws ModelNotFoundException
*/
public function register_verify(): mixed
public function register_verify()
{
$data = Util::postMore(['username', 'email', 'password', 'captcha'], null, true);
try {
@ -143,7 +143,7 @@ class User extends Base
* @return mixed
* @throws Exception
*/
public function logout(): mixed
public function logout()
{
if (userModel::clearLoginInfo()) {
return $this->success("操作成功", "/index/index/index");

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -47,7 +47,7 @@ jQuery( function() {
//图片加载失败
$("img").error(function(){
//当图片加载失败时,你要进行的操作
$(this).attr('src','/static/admin/img/logo-ico.png');
$(this).attr('src','/static/admin/img/logo1.png');
});
// 侧边栏导航