fix:更新已知bug,优化代码
This commit is contained in:
@@ -14,6 +14,7 @@ namespace app\admin\controller;
|
||||
use app\AdminController;
|
||||
use app\common\library\ResultCode;
|
||||
use app\common\library\Upload;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* Ajax类
|
||||
@@ -24,16 +25,16 @@ class Ajax extends AdminController
|
||||
{
|
||||
/**
|
||||
* 测试接口
|
||||
* @return \support\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function index(): \support\Response
|
||||
public function index(): Response
|
||||
{
|
||||
return json(ResultCode::SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
* @return \support\Response|void
|
||||
* @return Response|void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function upload()
|
||||
@@ -49,9 +50,9 @@ class Ajax extends AdminController
|
||||
|
||||
/**
|
||||
* 远程下载图片
|
||||
* @return mixed
|
||||
* @return Response
|
||||
*/
|
||||
public function getImage()
|
||||
public function getImage(): Response
|
||||
{
|
||||
if (request()->isPost()) {
|
||||
$file = Upload::instance()->download(input('url'));
|
||||
@@ -60,6 +61,8 @@ class Ajax extends AdminController
|
||||
}
|
||||
return json($file);
|
||||
}
|
||||
|
||||
return json(ResultCode::EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,48 +12,58 @@ declare(strict_types=1);
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\controller;
|
||||
|
||||
use Psr\SimpleCache\InvalidArgumentException;
|
||||
use support\Response;
|
||||
use think\db\exception\BindParamException;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
use Webman\Event\Event;
|
||||
use system\Random;
|
||||
use think\cache\driver\Memcached;
|
||||
use think\cache\driver\Redis;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use app\AdminController;
|
||||
use app\common\library\Email;
|
||||
use app\common\library\Ftp;
|
||||
use think\cache\driver\Memcached;
|
||||
use think\cache\driver\Redis;
|
||||
use think\facade\Cache;
|
||||
use Webman\Event\Event;
|
||||
use app\common\model\system\AdminNotice;
|
||||
use app\common\model\system\Attachment;
|
||||
use app\common\model\system\Config;
|
||||
use app\common\model\system\User;
|
||||
use app\common\model\system\UserGroup;
|
||||
use app\common\model\system\UserThird;
|
||||
use app\common\model\system\UserValidate;
|
||||
use system\Random;
|
||||
use think\facade\Db;
|
||||
|
||||
class Index extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* 初始化函数
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('index/index');
|
||||
$notice_count = AdminNotice::where('status', 0)->count();
|
||||
return view('index/index', [
|
||||
'notice_count' => $notice_count,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制台首页
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\BindParamException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws BindParamException
|
||||
*/
|
||||
public function console()
|
||||
{
|
||||
@@ -64,17 +74,14 @@ class Index extends AdminController
|
||||
if (request()->isPost()) {
|
||||
|
||||
$cycle = input('cycle');
|
||||
if (Event::hasListener('cmsuserEcharts')) {
|
||||
[$dataList, $seriesList] = Event::emit('cmsuserEcharts', $cycle, true);
|
||||
if (empty($seriesList)) {
|
||||
return $this->error('暂无数据');
|
||||
}
|
||||
|
||||
$userChartsOptions = $this->getEchartsData(array_values($dataList), $seriesList);
|
||||
return $this->success('操作成功', '', $userChartsOptions);
|
||||
[$dataList, $seriesList] = $this->getUserEcharts($cycle);
|
||||
if (empty($seriesList)) {
|
||||
return $this->error('暂无数据');
|
||||
}
|
||||
|
||||
return $this->error('请安装CMS插件');
|
||||
$userChartsOptions = $this->getEchartsData(array_values($dataList), $seriesList);
|
||||
return $this->success('操作成功', '', $userChartsOptions);
|
||||
}
|
||||
|
||||
for ($i = -29; $i <= 0; $i++) {
|
||||
@@ -87,13 +94,13 @@ class Index extends AdminController
|
||||
foreach ($columns as $index => $field) {
|
||||
$time = str_replace('invite_id', 'create_time', $field);
|
||||
$resultList = User::where($time, 'between time', [$dateBefore, $dateAfter])
|
||||
->when($condition, function ($query) use ($condition, $time, $field) {
|
||||
$query->field("FROM_UNIXTIME($time, '$condition') as day,count(*) as count");
|
||||
if ($field == 'invite_id') {
|
||||
$query->where('invite_id', '<>', 0);
|
||||
}
|
||||
$query->group($time);
|
||||
})->select()->toArray();
|
||||
->when($condition, function ($query) use ($condition, $time, $field) {
|
||||
$query->field("FROM_UNIXTIME($time, '$condition') as day,count(*) as count");
|
||||
if ($field == 'invite_id') {
|
||||
$query->where('invite_id', '<>', 0);
|
||||
}
|
||||
$query->group($time);
|
||||
})->select()->toArray();
|
||||
$tempList = [];
|
||||
foreach ($dataList as $key => $item) {
|
||||
$data = list_search($resultList, ['day' => $item]);
|
||||
@@ -139,11 +146,11 @@ class Index extends AdminController
|
||||
|
||||
// 搜索词云数据
|
||||
if (Event::hasListener('cmsHotSearch')) {
|
||||
$searchWords = Event::emit('cmsHotSearch', null, true);
|
||||
$searchWords = Event::emit('cmsHotSearch', [], true);
|
||||
} else { // 模拟数据
|
||||
for ($i = 0; $i < 50; $i++) {
|
||||
$searchWords[] = [
|
||||
'name' => Random::alpha(),
|
||||
'name' => Random::lower(),
|
||||
'value' => Random::number(),
|
||||
];
|
||||
}
|
||||
@@ -222,11 +229,105 @@ class Index extends AdminController
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $cycle
|
||||
* @return array
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
protected function getUserEcharts(string $cycle): array
|
||||
{
|
||||
$seriesList = [];
|
||||
$dataList = [];
|
||||
$condition = '%w';
|
||||
$dateBefore = date('Y-m-d', strtotime('-7 day'));
|
||||
$dateAfter = date('Y-m-d 23:59:59');
|
||||
switch ($cycle) {
|
||||
case 'week':
|
||||
$dataList = array('周日', '周一', '周二', '周三', '周四', '周五', '周六');
|
||||
break;
|
||||
case 'month':
|
||||
$condition = '%d';
|
||||
$dateBefore = date('Y-m-01');
|
||||
$dateAfter = date('Y-m-d', strtotime("+1 day"));
|
||||
$dataList = array('01' => ['1'], '02' => ['2'], '03' => ['3'], '04' => ['4'], '05' => ['5'], '06' => ['6'], '07' => ['7'], '08' => ['8'],
|
||||
'09' => ['9'], '10' => ['10'], '11' => ['11'], '12' => ['12'], '13' => ['13'], '14' => ['14'], '15' => ['15'], '16' => ['16'],
|
||||
'17' => ['17'], '18' => ['18'], '19' => ['19'], '20' => ['20'], '21' => ['21'], '22' => ['22'], '23' => ['23'], '24' => ['24'],
|
||||
'25' => ['25'], '26' => ['26'], '27' => ['27'], '28' => ['28'], '29' => ['29'], '30' => ['30'], '31' => ['31']);
|
||||
break;
|
||||
case 'year':
|
||||
$condition = '%m';
|
||||
$dateBefore = date('Y-01-01');
|
||||
$dateAfter = date('Y-12-31 23:59:59');
|
||||
$dataList = array('01' => ['一月'], '02' => ['二月'], '03' => ['三月'], '04' => ['四月'], '05' => ['五月'], '06' => ['六月'],
|
||||
'07' => ['七月'], '08' => ['八月'], '09' => ['九月'], '10' => ['十月'], '11' => ['十一月'], '12' => ['十二月']);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$resultList = $this->getCycleEcharts($dateBefore, $dateAfter, $condition);
|
||||
foreach ($resultList as $index => $item) {
|
||||
$tempList = [];
|
||||
|
||||
foreach ($dataList as $key => $value) {
|
||||
$data = list_search($item, ['day' => $key]);
|
||||
if (!empty($data)) {
|
||||
$tempList[$key] = $data;
|
||||
} else {
|
||||
$tempList[$key] = ['day' => $value, 'count' => 0];
|
||||
}
|
||||
}
|
||||
|
||||
$seriesList[] = [
|
||||
'name' => $index,
|
||||
'type' => 'line',
|
||||
'stack' => 'Total',
|
||||
'showSymbol' => false,
|
||||
'itemStyle' => ['normal' => ['areaStyle' => ['type' => 'default']]],
|
||||
'data' => array_column($tempList, 'count'),
|
||||
];
|
||||
}
|
||||
|
||||
return [$dataList, $seriesList];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一段时间内订单列表
|
||||
* @param $dateBefore
|
||||
* @param $dateAfter
|
||||
* @param $condition
|
||||
* @return array
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
protected function getCycleEcharts($dateBefore, $dateAfter, $condition): array
|
||||
{
|
||||
$resultList = [];
|
||||
$columns = ['用户注册' => 'create_time', '用户登录' => 'login_time', '邀请注册' => 'invite_id'];
|
||||
foreach ($columns as $index => $field) {
|
||||
$time = str_replace('invite_id', 'create_time', $field);
|
||||
$resultList[$index] = \app\common\model\system\User::where($time, 'between time', [$dateBefore, $dateAfter])
|
||||
->when($condition, function ($query) use ($condition, $time, $field) {
|
||||
$query->field("FROM_UNIXTIME($time, '$condition') as day,count(*) as count");
|
||||
if ($field == 'invite_id') {
|
||||
$query->where('invite_id', '<>', 0);
|
||||
}
|
||||
$query->group("FROM_UNIXTIME($time, '$condition')");
|
||||
})->order($time, 'asc')->select()->toArray();
|
||||
}
|
||||
|
||||
return $resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分析页
|
||||
* @return mixed
|
||||
*/
|
||||
public function analysis(): \support\Response
|
||||
public function analysis(): Response
|
||||
{
|
||||
return view('/index/analysis');
|
||||
}
|
||||
@@ -235,15 +336,19 @@ class Index extends AdminController
|
||||
* 监控页
|
||||
* @return mixed
|
||||
*/
|
||||
public function monitor(): \support\Response
|
||||
public function monitor(): Response
|
||||
{
|
||||
return view('/index/monitor');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统配置
|
||||
* @return Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function basecfg(): \support\Response
|
||||
public function basecfg(): Response
|
||||
{
|
||||
$config = Config::all();
|
||||
$config['fsockopen'] = function_exists('fsockopen');
|
||||
@@ -254,14 +359,13 @@ class Index extends AdminController
|
||||
/**
|
||||
* 编辑系统配置
|
||||
*
|
||||
* @param array $config
|
||||
* @return \support\Response
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function baseSet(): \support\Response
|
||||
public function baseSet(): Response
|
||||
{
|
||||
if (request()->isPost()) {
|
||||
$config = [];
|
||||
@@ -309,7 +413,7 @@ class Index extends AdminController
|
||||
/**
|
||||
* FTP测试上传
|
||||
*/
|
||||
public function testFtp(): \support\Response
|
||||
public function testFtp(): Response
|
||||
{
|
||||
if (request()->isPost()) {
|
||||
if (Ftp::instance()->ftpTest(request()->post())) {
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use support\Response;
|
||||
use Webman\Event\Event;
|
||||
use app\AdminController;
|
||||
use app\common\model\system\Admin;
|
||||
use app\common\model\system\LoginLog;
|
||||
use app\common\model\system\AdminLog;
|
||||
use Psr\SimpleCache\InvalidArgumentException;
|
||||
use support\Response;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use Webman\Event\Event;
|
||||
use Webman\Http\Request;
|
||||
|
||||
class Login extends AdminController
|
||||
{
|
||||
@@ -38,7 +37,7 @@ class Login extends AdminController
|
||||
public function index(): \support\Response
|
||||
{
|
||||
// 禁止重复访问
|
||||
if (isset(request()->adminInfo['id'])) {
|
||||
if (isset(request()->adminData['id'])) {
|
||||
return $this->redirect('/admin/index');
|
||||
}
|
||||
|
||||
@@ -47,10 +46,10 @@ class Login extends AdminController
|
||||
$user = request()->post('name');
|
||||
$pwd = request()->post('pwd');
|
||||
$captcha = request()->post('captcha');
|
||||
if ((isset(request()->adminInfo['count'])
|
||||
&& request()->adminInfo['count'] >= 5)
|
||||
&& (isset(request()->adminInfo['time'])
|
||||
&& request()->adminInfo['time'] >= strtotime('- 5 minutes'))
|
||||
if ((isset(request()->adminData['count'])
|
||||
&& request()->adminData['count'] >= 5)
|
||||
&& (isset(request()->adminData['time'])
|
||||
&& request()->adminData['time'] >= strtotime('- 5 minutes'))
|
||||
) {
|
||||
$error = '错误次数过多,请稍后再试!';
|
||||
$this->writeLoginLogs($error);
|
||||
@@ -58,7 +57,7 @@ class Login extends AdminController
|
||||
}
|
||||
|
||||
// 验证码
|
||||
if (isset(request()->adminInfo['isCaptcha'])) {
|
||||
if (isset(request()->adminData['isCaptcha'])) {
|
||||
if (!$captcha || !$this->captchaCheck($captcha)) {
|
||||
$error = '验证码错误!';
|
||||
$this->writeLoginLogs($error);
|
||||
@@ -75,10 +74,10 @@ class Login extends AdminController
|
||||
|
||||
$result = Admin::checkLogin($user, $pwd);
|
||||
if (empty($result)) {
|
||||
request()->adminInfo['time'] = time();
|
||||
request()->adminInfo['isCaptcha'] = true;
|
||||
request()->adminInfo['count'] = isset(request()->adminInfo['count']) ? request()->adminInfo['count'] + 1 : 1;
|
||||
request()->session()->set(AdminSession, request()->adminInfo);
|
||||
request()->adminData['time'] = time();
|
||||
request()->adminData['isCaptcha'] = true;
|
||||
request()->adminData['count'] = isset(request()->adminData['count']) ? request()->adminData['count'] + 1 : 1;
|
||||
request()->session()->set(AdminSession, request()->adminData);
|
||||
$error = '用户名或密码错误!';
|
||||
$this->writeLoginLogs($error);
|
||||
Event::emit('adminLoginError', \request()->all());
|
||||
@@ -98,7 +97,7 @@ class Login extends AdminController
|
||||
try {
|
||||
|
||||
$result->save();
|
||||
$session = array_merge(request()->adminInfo, $result->toArray());
|
||||
$session = array_merge(request()->adminData, $result->toArray());
|
||||
request()->session()->set(AdminSession, $session);
|
||||
} catch (\Throwable $th) {
|
||||
return $this->error($th->getMessage());
|
||||
@@ -112,7 +111,7 @@ class Login extends AdminController
|
||||
}
|
||||
|
||||
return view('login/index', [
|
||||
'captcha' => request()->adminInfo['isCaptcha'] ?? false,
|
||||
'captcha' => request()->adminData['isCaptcha'] ?? false,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -120,7 +119,6 @@ class Login extends AdminController
|
||||
* 写入登录日志
|
||||
* @param string $error
|
||||
* @param int $status
|
||||
* @return void
|
||||
*/
|
||||
private function writeLoginLogs(string $error, int $status = 0)
|
||||
{
|
||||
@@ -146,6 +144,6 @@ class Login extends AdminController
|
||||
'status' => $status,
|
||||
];
|
||||
|
||||
LoginLog::create($data);
|
||||
AdminLog::create($data);
|
||||
}
|
||||
}
|
||||
BIN
app/admin/controller/developer/stubs/data/plugin.stub
Normal file
BIN
app/admin/controller/developer/stubs/data/plugin.stub
Normal file
Binary file not shown.
@@ -14,14 +14,18 @@ declare(strict_types=1);
|
||||
namespace app\admin\controller\system;
|
||||
|
||||
use app\AdminController;
|
||||
use app\common\model\system\AdminNotice;
|
||||
use app\common\model\system\Jobs;
|
||||
use app\common\model\system\Department;
|
||||
use app\common\model\system\Admin as AdminModel;
|
||||
use app\common\model\system\AdminGroup as AdminGroupModel;
|
||||
use app\common\model\system\AdminAccess as AdminAccessModel;
|
||||
use support\Log;
|
||||
use support\Response;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\Exception;
|
||||
use think\facade\Cache;
|
||||
use Webman\Http\Request;
|
||||
|
||||
@@ -32,24 +36,23 @@ use Webman\Http\Request;
|
||||
*/
|
||||
class Admin extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* 用户管理组
|
||||
* @var null
|
||||
* @var mixed
|
||||
*/
|
||||
protected $group = null;
|
||||
protected mixed $group;
|
||||
|
||||
/**
|
||||
* 用户岗位
|
||||
* @var null
|
||||
* @var mixed
|
||||
*/
|
||||
public $jobs = null;
|
||||
public mixed $jobs;
|
||||
|
||||
/**
|
||||
* 用户部门
|
||||
* @var null
|
||||
* @var mixed
|
||||
*/
|
||||
public $department = null;
|
||||
public mixed $department;
|
||||
|
||||
// 初始化函数
|
||||
public function __construct()
|
||||
@@ -122,15 +125,18 @@ class Admin extends AdminController
|
||||
}
|
||||
|
||||
return view('/system/admin/index', [
|
||||
'jobs' => $this->jobs,
|
||||
'group' => $this->group,
|
||||
'jobs' => $this->jobs,
|
||||
'group' => $this->group,
|
||||
'department' => json_encode($this->department),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加管理员
|
||||
* @return \support\Response
|
||||
* @return Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function add(): \support\Response
|
||||
{
|
||||
@@ -294,58 +300,164 @@ class Admin extends AdminController
|
||||
|
||||
/**
|
||||
* 模版页面
|
||||
* @return Response
|
||||
*/
|
||||
public function theme()
|
||||
public function theme(): Response
|
||||
{
|
||||
return view('/system/admin/theme');
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息模板
|
||||
* @return Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function message()
|
||||
public function bells(): Response
|
||||
{
|
||||
// 配置消息
|
||||
$msg = [
|
||||
'msg' => [
|
||||
'0' => [
|
||||
'title' => '你收到了几份周报!',
|
||||
'type' => '周报类型',
|
||||
'create_time' => '1周前',
|
||||
],
|
||||
'1' => [
|
||||
'title' => '你收到了来自女下属的周报',
|
||||
'type' => '周报类型',
|
||||
'create_time' => '2周前',
|
||||
]
|
||||
],
|
||||
'comment' => [
|
||||
'0' => [
|
||||
'title' => '一个领导评论了你',
|
||||
'content' => '小伙子不错,继续努力!',
|
||||
'create_time' => '1周前',
|
||||
]
|
||||
],
|
||||
'things' => [
|
||||
'0' => [
|
||||
'title' => '客户说尽快修复瞟了么APP闪退的问题...',
|
||||
'type' => '0',
|
||||
'create_time' => '1周前',
|
||||
],
|
||||
'1' => [
|
||||
'title' => '秦老板和经销商的下季度合同尽快签订!',
|
||||
'type' => '1',
|
||||
'create_time' => '2周前',
|
||||
]
|
||||
],
|
||||
];
|
||||
$list = [];
|
||||
$count = [];
|
||||
$array = ['notice', 'message', 'todo'];
|
||||
$type = input('type', 'notice');
|
||||
|
||||
if (\request()->isAjax()) {
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 3);
|
||||
// 计算最大页码
|
||||
$data = AdminNotice::with(['admin'])->where(['type' => $type, 'admin_id' => \request()->admin_id])
|
||||
->order('id', 'desc')->paginate(['list_rows' => $limit, 'page' => $page])->toArray();
|
||||
return $this->success('获取成功', '', $data);
|
||||
}
|
||||
|
||||
return view('/system/admin/message', [
|
||||
'list' => $msg
|
||||
foreach ($array as $item) {
|
||||
$where = [
|
||||
['type', '=', $item],
|
||||
['admin_id', '=', request()->admin_id]
|
||||
];
|
||||
$count[$item] = AdminNotice::where($where)->where('status', 0)->count();
|
||||
$list[$item] = AdminNotice::with(['admin'])->withoutField('content')->where($where)->limit(3)->order('id desc')->select()->toArray();
|
||||
}
|
||||
|
||||
return view('/system/admin/bells', [
|
||||
'list' => $list,
|
||||
'count' => $count
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 阅读消息
|
||||
* @return response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function readNotice(): Response
|
||||
{
|
||||
$id = input('id', 0);
|
||||
$type = input('type', 'notice');
|
||||
|
||||
if (!empty($id)) {
|
||||
$detail = AdminNotice::with(['admin'])->where(['id' => $id, 'admin_id' => \request()->admin_id])->find();
|
||||
if (empty($detail)) {
|
||||
return $this->error('404 Not Found');
|
||||
}
|
||||
|
||||
// 默认已读
|
||||
if ($type !== 'todo') {
|
||||
$detail->status = 1;
|
||||
$detail->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->view('/system/admin/' . $type, [
|
||||
'detail' => $detail ?? []
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新即时消息
|
||||
* @return Response|void
|
||||
*/
|
||||
public function saveNotice()
|
||||
{
|
||||
if (\request()->post()) {
|
||||
$post = request()->post();
|
||||
$post['send_id'] = request()->admin_id;
|
||||
$post['type'] = 'message';
|
||||
$post['send_ip'] = request()->getRealIp();
|
||||
$post['create_time'] = time();
|
||||
|
||||
try {
|
||||
AdminNotice::sendNotice($post, 'none');
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('发送失败:' . $e->getMessage());
|
||||
}
|
||||
|
||||
return $this->success('发送成功');
|
||||
|
||||
} else if (\request()->isAjax()) {
|
||||
$id = input('id', 0);
|
||||
$status = input('status', 1);
|
||||
|
||||
try {
|
||||
if (empty($id)) {
|
||||
throw new Exception('参数错误');
|
||||
}
|
||||
AdminNotice::where(['id' => $id, 'admin_id' => request()->admin_id])->update(['status' => $status]);
|
||||
} catch (Exception $e) {
|
||||
return $this->error('更新失败');
|
||||
}
|
||||
|
||||
return $this->success('更新成功');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空消息
|
||||
* @return Response|void
|
||||
*/
|
||||
public function clearNotice()
|
||||
{
|
||||
if (\request()->isAjax()) {
|
||||
$type = input('type', 'notice');
|
||||
$where = [
|
||||
['type', '=', $type],
|
||||
['status', '=', 1],
|
||||
['admin_id', '=', request()->admin_id]
|
||||
];
|
||||
try {
|
||||
AdminNotice::where($where)->delete();
|
||||
} catch (Exception $e) {
|
||||
return $this->error('清空失败');
|
||||
}
|
||||
|
||||
return $this->success('清空成功');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部消息已读
|
||||
* @return Response|void
|
||||
*/
|
||||
public function readAllNotice()
|
||||
{
|
||||
if (\request()->isAjax()) {
|
||||
$type = input('type', 'notice');
|
||||
$where = [
|
||||
['type', '=', $type],
|
||||
['admin_id', '=', request()->admin_id]
|
||||
];
|
||||
try {
|
||||
AdminNotice::where($where)->update(['status' => 1]);
|
||||
} catch (Exception $e) {
|
||||
return $this->error('操作失败');
|
||||
}
|
||||
|
||||
return $this->success('全部已读成功');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人中心
|
||||
* @param Request $request
|
||||
@@ -359,7 +471,7 @@ class Admin extends AdminController
|
||||
|
||||
if (request()->isPost()) {
|
||||
$post = request()->post();
|
||||
$post['id'] = $request->adminId;
|
||||
$post['id'] = $request->admin_id;
|
||||
if ($this->model->update($post)) {
|
||||
return $this->success();
|
||||
}
|
||||
@@ -368,7 +480,7 @@ class Admin extends AdminController
|
||||
}
|
||||
|
||||
$title = [];
|
||||
$data = $this->model->find($request->adminId);
|
||||
$data = $this->model->find($request->admin_id);
|
||||
if (!empty($data['group_id'])) {
|
||||
$group = AdminGroupModel::field('title')
|
||||
->whereIn('id', $data['group_id'])
|
||||
@@ -393,7 +505,7 @@ class Admin extends AdminController
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
$post = request()->post();
|
||||
$id = $request->adminId;
|
||||
$id = $request->admin_id;
|
||||
try {
|
||||
//code...
|
||||
switch ($post['field']) {
|
||||
@@ -448,7 +560,7 @@ class Admin extends AdminController
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function pwd(Request $request): \support\Response
|
||||
public function pwd(): \support\Response
|
||||
{
|
||||
if (request()->isPost()) {
|
||||
|
||||
@@ -459,7 +571,7 @@ class Admin extends AdminController
|
||||
}
|
||||
|
||||
// 查找数据
|
||||
$where[] = ['id', '=', $request->admin_id];
|
||||
$where[] = ['id', '=', request()->admin_id];
|
||||
$where[] = ['pwd', '=', encryptPwd($pwd)];
|
||||
$result = $this->model->where($where)->find();
|
||||
|
||||
|
||||
@@ -24,9 +24,19 @@ use Webman\Http\Request;
|
||||
*/
|
||||
class Attachment extends AdminController
|
||||
{
|
||||
// 上传文件夹地址
|
||||
protected $upload;
|
||||
/**
|
||||
* 上传文件夹地址
|
||||
* @var mixed
|
||||
*/
|
||||
protected mixed $upload;
|
||||
|
||||
/**
|
||||
* 初始化函数
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
@@ -14,6 +14,10 @@ namespace app\admin\controller\system;
|
||||
|
||||
use app\AdminController;
|
||||
use app\common\model\system\Company as CompanyModel;
|
||||
use support\Response;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use Webman\Http\Request;
|
||||
|
||||
/**
|
||||
@@ -33,7 +37,10 @@ class Company extends AdminController
|
||||
|
||||
/**
|
||||
* 获取资源列表
|
||||
* @return \support\Response
|
||||
* @return Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index(): \support\Response
|
||||
{
|
||||
|
||||
@@ -11,14 +11,12 @@ declare (strict_types = 1);
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\controller\system;
|
||||
|
||||
|
||||
use app\AdminController;
|
||||
use app\common\model\system\Department as DepartmentModel;
|
||||
use support\Response;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use Webman\Http\Request;
|
||||
use app\common\model\system\Department as DepartmentModel;
|
||||
|
||||
/**
|
||||
* 部门管理
|
||||
|
||||
@@ -13,6 +13,10 @@ namespace app\admin\controller\system;
|
||||
|
||||
use app\AdminController;
|
||||
use app\common\model\system\Dictionary as DictionaryModel;
|
||||
use support\Response;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use Webman\Http\Request;
|
||||
|
||||
/**
|
||||
@@ -31,7 +35,10 @@ class Dictionary extends AdminController
|
||||
|
||||
/**
|
||||
* 字典首页
|
||||
* @return \support\Response
|
||||
* @return Response
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index(): \support\Response
|
||||
{
|
||||
@@ -46,7 +53,7 @@ class Dictionary extends AdminController
|
||||
if (request()->isAjax()) {
|
||||
|
||||
// 生成查询数据
|
||||
$pid = !strstr($pid,',') ? $pid : explode(',',$pid);
|
||||
$pid = !str_contains($pid, ',') ? $pid : explode(',',$pid);
|
||||
$where[] = ['pid','in',$pid];
|
||||
if (!empty($post['name'])) {
|
||||
$where[] = ['name','like','%'.$post['name'].'%'];
|
||||
|
||||
@@ -3,7 +3,7 @@ declare (strict_types = 1);
|
||||
namespace app\admin\controller\system;
|
||||
|
||||
use app\AdminController;
|
||||
use app\common\model\system\LoginLog as LoginLogModel;
|
||||
use app\common\model\system\AdminLog as LoginLogModel;
|
||||
use Webman\Http\Request;
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,11 +14,15 @@ namespace app\admin\controller\system;
|
||||
|
||||
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use support\Response;
|
||||
use system\File;
|
||||
use system\Http;
|
||||
use system\ZipArchives;
|
||||
use app\AdminController;
|
||||
use app\admin\library\Auth;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use Throwable;
|
||||
use app\common\library\DataBase;
|
||||
use app\common\model\system\AdminRules;
|
||||
@@ -32,21 +36,21 @@ class Plugin extends AdminController
|
||||
{
|
||||
/**
|
||||
* 查询最大数量
|
||||
* @var int
|
||||
* @var mixed
|
||||
*/
|
||||
protected $limit = 500;
|
||||
protected mixed $limit = 500;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
* @var array
|
||||
* @var mixed
|
||||
*/
|
||||
static $errData = [];
|
||||
static mixed $errData;
|
||||
|
||||
/**
|
||||
* 获取本地插件列表
|
||||
* @return \support\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function index(): \support\Response
|
||||
public function index(): Response
|
||||
{
|
||||
$pluginList = get_plugin_list();
|
||||
if (request()->isAjax()) {
|
||||
@@ -59,7 +63,7 @@ class Plugin extends AdminController
|
||||
|
||||
/**
|
||||
* 安装插件
|
||||
* @return \support\Response|void
|
||||
* @return Response|void
|
||||
* @throws \Exception|\Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function install()
|
||||
@@ -98,7 +102,7 @@ class Plugin extends AdminController
|
||||
|
||||
/**
|
||||
* 卸载插件
|
||||
* @return \support\Response|void
|
||||
* @return Response|void
|
||||
* @throws \Exception|\Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function uninstall()
|
||||
@@ -266,10 +270,10 @@ class Plugin extends AdminController
|
||||
|
||||
/**
|
||||
* 修改插件配置
|
||||
* @return \support\Response
|
||||
* @return Response
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function config(): \support\Response
|
||||
public function config(): Response
|
||||
{
|
||||
$name = input('name');
|
||||
if (preg_replace('/[^a-zA-Z0-9]/i', '', $name) !== $name) {
|
||||
@@ -298,7 +302,7 @@ class Plugin extends AdminController
|
||||
/**
|
||||
* 修改插件状态
|
||||
* 启用 / 禁用
|
||||
* @return \support\Response|void
|
||||
* @return Response|void
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
@@ -350,7 +354,6 @@ class Plugin extends AdminController
|
||||
* 执行SQL脚本文件
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
public static function executeSql(string $name, string $type = 'install')
|
||||
{
|
||||
@@ -362,10 +365,9 @@ class Plugin extends AdminController
|
||||
/**
|
||||
* 获取菜单项
|
||||
* @param string $name
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public static function pluginMenu(string $name)
|
||||
{
|
||||
|
||||
@@ -16,10 +16,8 @@ use support\Response;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use Webman\Http\Request;
|
||||
use app\common\model\system\SystemLog as SystemLogModel;
|
||||
|
||||
|
||||
/**
|
||||
* 系统日志
|
||||
* Class SystemLog
|
||||
|
||||
@@ -30,17 +30,11 @@ use Webman\Http\Request;
|
||||
*/
|
||||
class User extends AdminController
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $userGroup;
|
||||
|
||||
// 初始化函数
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->model = new UserModel();
|
||||
$this->userGroup = UserGroupModel::select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +46,7 @@ class User extends AdminController
|
||||
*/
|
||||
public function index(): \support\Response
|
||||
{
|
||||
|
||||
$userGroup = UserGroupModel::select()->toArray();
|
||||
if (request()->isAjax()) {
|
||||
|
||||
// 获取数据
|
||||
@@ -83,7 +77,7 @@ class User extends AdminController
|
||||
$region = Ip2Region::instance()->memorySearch($value['login_ip']);
|
||||
$region = explode('|', $region['region']);
|
||||
$list[$key]['region'] = $region;
|
||||
$result = list_search($this->userGroup, ['id' => $value['group_id']]);
|
||||
$result = list_search($userGroup, ['id' => $value['group_id']]);
|
||||
if (!empty($result)) {
|
||||
$list[$key]['group'] = $result['title'];
|
||||
}
|
||||
@@ -94,7 +88,7 @@ class User extends AdminController
|
||||
}
|
||||
|
||||
return view('/system/user/index', [
|
||||
'UserGroup' => $this->userGroup,
|
||||
'UserGroup' => $userGroup,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -175,7 +169,7 @@ class User extends AdminController
|
||||
/**
|
||||
* 删除会员
|
||||
*/
|
||||
public function del()
|
||||
public function del(): Response
|
||||
{
|
||||
return $this->error('不允许删除会员');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user