后台优化
This commit is contained in:
77
application/admin/controller/Dashboard.php
Normal file
77
application/admin/controller/Dashboard.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\common\Base;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 系统概览控制器
|
||||
* 早熟预测后台独立实现,不再依赖common模块
|
||||
*/
|
||||
class Dashboard extends Base
|
||||
{
|
||||
/**
|
||||
* 后台首页概览
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->view->fetch('dashboard/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取统计数据
|
||||
* admin模块独立实现,使用wechat_user表
|
||||
*/
|
||||
public function getStatistics()
|
||||
{
|
||||
try {
|
||||
// admin模块使用的表名(固定)
|
||||
$userTable = 'wechat_user';
|
||||
$infoTable = 'wechat_real_time_info';
|
||||
$recordTable = 'wechat_calculate_record';
|
||||
|
||||
// 小程序注册用户数量
|
||||
$userCount = Db::name($userTable)->count();
|
||||
|
||||
// 首页资讯数量
|
||||
$infoCount = Db::name($infoTable)->count();
|
||||
|
||||
// 最近一次计算时间
|
||||
$lastCalculate = Db::name($recordTable)
|
||||
->order('create_time desc')
|
||||
->value('create_time');
|
||||
|
||||
// 今日新增用户
|
||||
$todayUserCount = Db::name($userTable)
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
|
||||
// 总计算次数
|
||||
$totalCalculateCount = Db::name($recordTable)->count();
|
||||
|
||||
return json([
|
||||
'status' => 1,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'user_count' => $userCount,
|
||||
'info_count' => $infoCount,
|
||||
'last_calculate_time' => $lastCalculate ?: '暂无',
|
||||
'today_user_count' => $todayUserCount,
|
||||
'total_calculate_count' => $totalCalculateCount
|
||||
]
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'status' => 0,
|
||||
'msg' => '获取失败:' . $e->getMessage(),
|
||||
'data' => [
|
||||
'user_count' => 0,
|
||||
'info_count' => 0,
|
||||
'last_calculate_time' => '暂无',
|
||||
'today_user_count' => 0,
|
||||
'total_calculate_count' => 0
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
138
application/admin/view/dashboard/index.html
Normal file
138
application/admin/view/dashboard/index.html
Normal file
@@ -0,0 +1,138 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit|ie-comp|ie-stand">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
||||
<title>系统概览</title>
|
||||
<link rel="stylesheet" href="/static/admin/layui/css/layui.css">
|
||||
<style>
|
||||
body{
|
||||
background:#f5f7fb;
|
||||
padding:24px 24px 40px;
|
||||
box-sizing:border-box;
|
||||
font-family:"Microsoft YaHei",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
|
||||
}
|
||||
.dash-card{
|
||||
background:#fff;
|
||||
border-radius:10px;
|
||||
box-shadow:0 10px 30px rgba(15,35,52,0.06);
|
||||
padding:20px 24px;
|
||||
margin-bottom:20px;
|
||||
}
|
||||
.dash-title{
|
||||
font-size:18px;
|
||||
font-weight:600;
|
||||
color:#1f2d3d;
|
||||
margin-bottom:4px;
|
||||
}
|
||||
.dash-sub{
|
||||
font-size:12px;
|
||||
color:#9aa4b1;
|
||||
margin-bottom:18px;
|
||||
}
|
||||
.dash-grid{
|
||||
display:flex;
|
||||
flex-wrap:wrap;
|
||||
gap:16px;
|
||||
}
|
||||
.dash-item{
|
||||
flex:1 1 200px;
|
||||
min-width:200px;
|
||||
background:#f8fafc;
|
||||
border-radius:8px;
|
||||
padding:14px 16px;
|
||||
cursor:pointer;
|
||||
transition:all 0.3s;
|
||||
}
|
||||
.dash-item:hover{
|
||||
background:#f0f4f8;
|
||||
transform:translateY(-2px);
|
||||
box-shadow:0 4px 12px rgba(15,35,52,0.1);
|
||||
}
|
||||
.dash-item-label{
|
||||
font-size:13px;
|
||||
color:#9aa4b1;
|
||||
}
|
||||
.dash-item-value{
|
||||
margin-top:6px;
|
||||
font-size:22px;
|
||||
font-weight:600;
|
||||
color:#1f2d3d;
|
||||
}
|
||||
.dash-item-desc{
|
||||
margin-top:4px;
|
||||
font-size:12px;
|
||||
color:#b0b7c3;
|
||||
}
|
||||
.dash-empty{
|
||||
margin-top:10px;
|
||||
font-size:13px;
|
||||
color:#9aa4b1;
|
||||
}
|
||||
.loading{
|
||||
text-align:center;
|
||||
padding:40px;
|
||||
color:#9aa4b1;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="dash-card">
|
||||
<div class="dash-title">欢迎使用后台管理系统</div>
|
||||
<div class="dash-sub">这里是系统概览,实时展示系统统计数据。</div>
|
||||
<div class="dash-grid" id="dashGrid">
|
||||
<div class="loading">数据加载中...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/admin/js/jquery.js"></script>
|
||||
<script>
|
||||
$(function(){
|
||||
// 加载统计数据
|
||||
loadStatistics();
|
||||
|
||||
function loadStatistics(){
|
||||
$.ajax({
|
||||
url: '/admin/Dashboard/getStatistics',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
success: function(res){
|
||||
if(res.status == 1){
|
||||
renderStatistics(res.data);
|
||||
} else {
|
||||
$('#dashGrid').html('<div class="loading">数据加载失败:' + res.msg + '</div>');
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
$('#dashGrid').html('<div class="loading">数据加载失败,请稍后重试</div>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderStatistics(data){
|
||||
var html = `
|
||||
<div class="dash-item" onclick="parent.location.href='/admin/wechatinfro/wechatUserList'">
|
||||
<div class="dash-item-label">小程序注册用户</div>
|
||||
<div class="dash-item-value">${data.user_count}</div>
|
||||
<div class="dash-item-desc">今日新增:${data.today_user_count} 人</div>
|
||||
</div>
|
||||
<div class="dash-item" onclick="parent.location.href='/admin/wechatset/wechatRealTimeInfo'">
|
||||
<div class="dash-item-label">首页资讯数量</div>
|
||||
<div class="dash-item-value">${data.info_count}</div>
|
||||
<div class="dash-item-desc">可在「咨询管理」菜单中维护展示内容</div>
|
||||
</div>
|
||||
<div class="dash-item" onclick="parent.location.href='/admin/wechatinfro/wechatRecordList'">
|
||||
<div class="dash-item-label">总计算次数</div>
|
||||
<div class="dash-item-value">${data.total_calculate_count}</div>
|
||||
<div class="dash-item-desc">最近一次:${data.last_calculate_time}</div>
|
||||
</div>
|
||||
`;
|
||||
$('#dashGrid').html(html);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div style='background:#e3e3e3;height:450px;width:100%;position:relative;'>
|
||||
<div style='width:350px;height:400px;background:#EDF1F5;float:right;margin-right:20%;margin-top:1.5%;box-shadow:#666 0px 0px 20px;'>
|
||||
<div class="login-top" style="padding-bottom:0;">
|
||||
<div style='color:#453A3E;margin:30px auto 10px auto;width:150px;font-size:18px;font-weight:bold;text-align:center;'>瑞莱医疗</div>
|
||||
<div style='color:#453A3E;margin:30px auto 10px auto;width:auto;max-width:90%;font-size:16px;font-weight:bold;text-align:center;padding:0 10px;'>女童成长发育早熟预测模型后台</div>
|
||||
</div>
|
||||
<div style='height:1px;width:100%;background:#DEDCDD;'>
|
||||
<div style='background:#e3e3e3;height:3px;width:80%;margin:0px auto 0 auto;'></div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
||||
<meta http-equiv="Cache-Control" content="no-siteapp">
|
||||
<title>瑞莱医疗后台</title>
|
||||
<title>女童成长发育早熟预测模型后台</title>
|
||||
|
||||
<link rel="stylesheet" href="/static/admin/layui/css/layui.css?t=1554901097999" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="/static/admin/css/nav.css" />
|
||||
@@ -33,17 +33,9 @@
|
||||
</div>
|
||||
<!--顶部-->
|
||||
<div class="top_right">
|
||||
<a href="javascript:void(0)" class="logo">
|
||||
<!-- <img id="packBtn" src="{S_URL}/templates/adminfactory/img/logo.png">-->
|
||||
</a>
|
||||
<b></b>
|
||||
<div class="header_title">女童成长发育早熟预测模型后台</div>
|
||||
<div class="user_right">
|
||||
<a href="javascript:;" id="user" style="position: absolute;left: 100px;top: 4px;font-size: 16px;"></a>
|
||||
<span id="inform">
|
||||
<!-- 您好!工厂
|
||||
<img id="u_headimg" src="{S_URL}/templates/adminfactory/img/logo.png" alt="">
|
||||
<i>荣麟</i> -->
|
||||
</span>
|
||||
<span id="inform"></span>
|
||||
<b class="out" id="sign_out">退出</b>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,10 +9,9 @@ use think\Response;
|
||||
class Base extends Controller
|
||||
{
|
||||
protected function _initialize()
|
||||
{var_dump(1111);exit;
|
||||
{
|
||||
if(!session('adminghd_user_id')){//没有登录信息
|
||||
// $this->redirect('login/index');
|
||||
var_dump(url('Login/logoutJump'));exit;
|
||||
return $this->error('您还未登录',url('Login/logoutJump'));
|
||||
//Response::create(['status' => '0','msg'=> '还未登录,验证失败'], 'json')->send();
|
||||
exit;
|
||||
|
||||
77
application/adminghd/controller/Dashboard.php
Normal file
77
application/adminghd/controller/Dashboard.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
namespace app\adminghd\controller;
|
||||
|
||||
use app\adminghd\common\Base;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 系统概览控制器
|
||||
* GHD预测后台独立实现,不再依赖common模块
|
||||
*/
|
||||
class Dashboard extends Base
|
||||
{
|
||||
/**
|
||||
* 后台首页概览
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->view->fetch('dashboard/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取统计数据
|
||||
* adminghd模块独立实现,使用ghd_wechat_user表
|
||||
*/
|
||||
public function getStatistics()
|
||||
{
|
||||
try {
|
||||
// adminghd模块使用的表名(固定)
|
||||
$userTable = 'ghd_wechat_user';
|
||||
$infoTable = 'wechat_real_time_info';
|
||||
$recordTable = 'wechat_calculate_record';
|
||||
|
||||
// 小程序注册用户数量
|
||||
$userCount = Db::name($userTable)->count();
|
||||
|
||||
// 首页资讯数量
|
||||
$infoCount = Db::name($infoTable)->count();
|
||||
|
||||
// 最近一次计算时间
|
||||
$lastCalculate = Db::name($recordTable)
|
||||
->order('create_time desc')
|
||||
->value('create_time');
|
||||
|
||||
// 今日新增用户
|
||||
$todayUserCount = Db::name($userTable)
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
|
||||
// 总计算次数
|
||||
$totalCalculateCount = Db::name($recordTable)->count();
|
||||
|
||||
return json([
|
||||
'status' => 1,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'user_count' => $userCount,
|
||||
'info_count' => $infoCount,
|
||||
'last_calculate_time' => $lastCalculate ?: '暂无',
|
||||
'today_user_count' => $todayUserCount,
|
||||
'total_calculate_count' => $totalCalculateCount
|
||||
]
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'status' => 0,
|
||||
'msg' => '获取失败:' . $e->getMessage(),
|
||||
'data' => [
|
||||
'user_count' => 0,
|
||||
'info_count' => 0,
|
||||
'last_calculate_time' => '暂无',
|
||||
'today_user_count' => 0,
|
||||
'total_calculate_count' => 0
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
138
application/adminghd/view/dashboard/index.html
Normal file
138
application/adminghd/view/dashboard/index.html
Normal file
@@ -0,0 +1,138 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit|ie-comp|ie-stand">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
||||
<title>系统概览</title>
|
||||
<link rel="stylesheet" href="/static/adminghd/layui/css/layui.css">
|
||||
<style>
|
||||
body{
|
||||
background:#f5f7fb;
|
||||
padding:24px 24px 40px;
|
||||
box-sizing:border-box;
|
||||
font-family:"Microsoft YaHei",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
|
||||
}
|
||||
.dash-card{
|
||||
background:#fff;
|
||||
border-radius:10px;
|
||||
box-shadow:0 10px 30px rgba(15,35,52,0.06);
|
||||
padding:20px 24px;
|
||||
margin-bottom:20px;
|
||||
}
|
||||
.dash-title{
|
||||
font-size:18px;
|
||||
font-weight:600;
|
||||
color:#1f2d3d;
|
||||
margin-bottom:4px;
|
||||
}
|
||||
.dash-sub{
|
||||
font-size:12px;
|
||||
color:#9aa4b1;
|
||||
margin-bottom:18px;
|
||||
}
|
||||
.dash-grid{
|
||||
display:flex;
|
||||
flex-wrap:wrap;
|
||||
gap:16px;
|
||||
}
|
||||
.dash-item{
|
||||
flex:1 1 200px;
|
||||
min-width:200px;
|
||||
background:#f8fafc;
|
||||
border-radius:8px;
|
||||
padding:14px 16px;
|
||||
cursor:pointer;
|
||||
transition:all 0.3s;
|
||||
}
|
||||
.dash-item:hover{
|
||||
background:#f0f4f8;
|
||||
transform:translateY(-2px);
|
||||
box-shadow:0 4px 12px rgba(15,35,52,0.1);
|
||||
}
|
||||
.dash-item-label{
|
||||
font-size:13px;
|
||||
color:#9aa4b1;
|
||||
}
|
||||
.dash-item-value{
|
||||
margin-top:6px;
|
||||
font-size:22px;
|
||||
font-weight:600;
|
||||
color:#1f2d3d;
|
||||
}
|
||||
.dash-item-desc{
|
||||
margin-top:4px;
|
||||
font-size:12px;
|
||||
color:#b0b7c3;
|
||||
}
|
||||
.dash-empty{
|
||||
margin-top:10px;
|
||||
font-size:13px;
|
||||
color:#9aa4b1;
|
||||
}
|
||||
.loading{
|
||||
text-align:center;
|
||||
padding:40px;
|
||||
color:#9aa4b1;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="dash-card">
|
||||
<div class="dash-title">欢迎使用后台管理系统</div>
|
||||
<div class="dash-sub">这里是系统概览,实时展示系统统计数据。</div>
|
||||
<div class="dash-grid" id="dashGrid">
|
||||
<div class="loading">数据加载中...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/adminghd/js/jquery.js"></script>
|
||||
<script>
|
||||
$(function(){
|
||||
// 加载统计数据
|
||||
loadStatistics();
|
||||
|
||||
function loadStatistics(){
|
||||
$.ajax({
|
||||
url: '/adminghd/Dashboard/getStatistics',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
success: function(res){
|
||||
if(res.status == 1){
|
||||
renderStatistics(res.data);
|
||||
} else {
|
||||
$('#dashGrid').html('<div class="loading">数据加载失败:' + res.msg + '</div>');
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
$('#dashGrid').html('<div class="loading">数据加载失败,请稍后重试</div>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderStatistics(data){
|
||||
var html = `
|
||||
<div class="dash-item" onclick="parent.location.href='/adminghd/wechatinfro/wechatUserList'">
|
||||
<div class="dash-item-label">小程序注册用户</div>
|
||||
<div class="dash-item-value">${data.user_count}</div>
|
||||
<div class="dash-item-desc">今日新增:${data.today_user_count} 人</div>
|
||||
</div>
|
||||
<div class="dash-item" onclick="parent.location.href='/adminghd/wechatset/wechatRealTimeInfo'">
|
||||
<div class="dash-item-label">首页资讯数量</div>
|
||||
<div class="dash-item-value">${data.info_count}</div>
|
||||
<div class="dash-item-desc">可在「咨询管理」菜单中维护展示内容</div>
|
||||
</div>
|
||||
<div class="dash-item" onclick="parent.location.href='/adminghd/wechatinfro/wechatRecordList'">
|
||||
<div class="dash-item-label">总计算次数</div>
|
||||
<div class="dash-item-value">${data.total_calculate_count}</div>
|
||||
<div class="dash-item-desc">最近一次:${data.last_calculate_time}</div>
|
||||
</div>
|
||||
`;
|
||||
$('#dashGrid').html(html);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div style='background:#e3e3e3;height:450px;width:100%;position:relative;'>
|
||||
<div style='width:350px;height:400px;background:#EDF1F5;float:right;margin-right:20%;margin-top:1.5%;box-shadow:#666 0px 0px 20px;'>
|
||||
<div class="login-top" style="padding-bottom:0;">
|
||||
<div style='color:#453A3E;margin:30px auto 10px auto;width:150px;font-size:18px;font-weight:bold;text-align:center;'>瑞莱医疗</div>
|
||||
<div style='color:#453A3E;margin:30px auto 10px auto;width:auto;max-width:90%;font-size:16px;font-weight:bold;text-align:center;padding:0 10px;'>生长激素缺乏预测模型后台</div>
|
||||
</div>
|
||||
<div style='height:1px;width:100%;background:#DEDCDD;'>
|
||||
<div style='background:#e3e3e3;height:3px;width:80%;margin:0px auto 0 auto;'></div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
||||
<meta http-equiv="Cache-Control" content="no-siteapp">
|
||||
<title>瑞莱医疗后台</title>
|
||||
<title>生长激素缺乏预测模型后台</title>
|
||||
|
||||
<link rel="stylesheet" href="/static/adminghd/layui/css/layui.css?t=1554901097999" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="/static/adminghd/css/nav.css" />
|
||||
@@ -33,22 +33,14 @@
|
||||
</div>
|
||||
<!--顶部-->
|
||||
<div class="top_right">
|
||||
<a href="javascript:void(0)" class="logo">
|
||||
<!-- <img id="packBtn" src="{S_URL}/templates/adminfactory/img/logo.png">-->
|
||||
</a>
|
||||
<b></b>
|
||||
<div class="header_title">生长激素缺乏预测模型后台</div>
|
||||
<div class="user_right">
|
||||
<a href="javascript:;" id="user" style="position: absolute;left: 100px;top: 4px;font-size: 16px;"></a>
|
||||
<span id="inform">
|
||||
<!-- 您好!工厂
|
||||
<img id="u_headimg" src="{S_URL}/templates/adminfactory/img/logo.png" alt="">
|
||||
<i>荣麟</i> -->
|
||||
</span>
|
||||
<span id="inform"></span>
|
||||
<b class="out" id="sign_out">退出</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main_content">
|
||||
<iframe id="iframeId" src="" frameborder="0"></iframe>
|
||||
<iframe id="iframeId" src="/adminghd/Dashboard/index" frameborder="0"></iframe>
|
||||
</div>
|
||||
|
||||
<script src="/static/adminghd/js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
71
application/common/common/BaseController.php
Normal file
71
application/common/common/BaseController.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* 公共基础控制器
|
||||
* 统一处理登录验证和业务类型识别
|
||||
*/
|
||||
namespace app\common\common;
|
||||
|
||||
use think\Controller;
|
||||
use think\Session;
|
||||
use app\common\config\BusinessConfig;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* 当前业务类型
|
||||
* @var string
|
||||
*/
|
||||
protected $businessType;
|
||||
|
||||
/**
|
||||
* 数据表映射
|
||||
* @var array
|
||||
*/
|
||||
protected $tableMap;
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
protected function _initialize()
|
||||
{
|
||||
// 获取业务类型
|
||||
$this->businessType = BusinessConfig::getBusinessTypeByModule();
|
||||
$this->tableMap = BusinessConfig::getTableMap($this->businessType);
|
||||
|
||||
// 验证登录
|
||||
$this->checkLogin();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查登录状态
|
||||
*/
|
||||
protected function checkLogin()
|
||||
{
|
||||
$sessionKey = BusinessConfig::getSessionKey($this->businessType);
|
||||
$loginTimeKey = BusinessConfig::getLoginTimeKey($this->businessType);
|
||||
|
||||
if (!session($sessionKey)) {
|
||||
// 没有登录信息
|
||||
return $this->error('您还未登录', url('Login/logoutJump'));
|
||||
exit;
|
||||
} else {
|
||||
// 登录信息超时
|
||||
$logTime = session($loginTimeKey) - time();
|
||||
if ($logTime < 0) {
|
||||
Session::clear();
|
||||
return $this->error('登录超时', url('Login/logoutJump'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据表名
|
||||
* @param string $tableKey 表键名
|
||||
* @return string
|
||||
*/
|
||||
protected function getTableName($tableKey)
|
||||
{
|
||||
return isset($this->tableMap[$tableKey]) ? $this->tableMap[$tableKey] : $tableKey;
|
||||
}
|
||||
}
|
||||
92
application/common/config/BusinessConfig.php
Normal file
92
application/common/config/BusinessConfig.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* 业务配置类
|
||||
* 用于区分不同小程序业务的数据表映射
|
||||
*/
|
||||
namespace app\common\config;
|
||||
|
||||
class BusinessConfig
|
||||
{
|
||||
// 业务类型常量
|
||||
const BUSINESS_ADMIN = 'admin'; // 通用后台
|
||||
const BUSINESS_ADMINGHD = 'adminghd'; // GHD项目后台
|
||||
|
||||
/**
|
||||
* 获取业务类型对应的数据表映射
|
||||
* @param string $businessType 业务类型
|
||||
* @return array
|
||||
*/
|
||||
public static function getTableMap($businessType)
|
||||
{
|
||||
$maps = [
|
||||
self::BUSINESS_ADMIN => [
|
||||
'user' => 'wechat_user',
|
||||
'real_time_info' => 'wechat_real_time_info',
|
||||
'calculate_record' => 'wechat_calculate_record',
|
||||
],
|
||||
self::BUSINESS_ADMINGHD => [
|
||||
'user' => 'ghd_wechat_user',
|
||||
'real_time_info' => 'wechat_real_time_info',
|
||||
'calculate_record' => 'wechat_calculate_record',
|
||||
],
|
||||
];
|
||||
|
||||
return isset($maps[$businessType]) ? $maps[$businessType] : $maps[self::BUSINESS_ADMIN];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取业务类型对应的Session标识
|
||||
* @param string $businessType 业务类型
|
||||
* @return string
|
||||
*/
|
||||
public static function getSessionKey($businessType)
|
||||
{
|
||||
$keys = [
|
||||
self::BUSINESS_ADMIN => 'admin_user_id',
|
||||
self::BUSINESS_ADMINGHD => 'adminghd_user_id',
|
||||
];
|
||||
|
||||
return isset($keys[$businessType]) ? $keys[$businessType] : 'admin_user_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取业务类型对应的登录时间Session标识
|
||||
* @param string $businessType 业务类型
|
||||
* @return string
|
||||
*/
|
||||
public static function getLoginTimeKey($businessType)
|
||||
{
|
||||
$keys = [
|
||||
self::BUSINESS_ADMIN => 'admin_user_login_time',
|
||||
self::BUSINESS_ADMINGHD => 'adminghd_user_login_time',
|
||||
];
|
||||
|
||||
return isset($keys[$businessType]) ? $keys[$businessType] : 'admin_user_login_time';
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前模块名获取业务类型
|
||||
* @return string
|
||||
*/
|
||||
public static function getBusinessTypeByModule()
|
||||
{
|
||||
$module = request()->module();
|
||||
return $module === 'adminghd' ? self::BUSINESS_ADMINGHD : self::BUSINESS_ADMIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据表名
|
||||
* @param string $tableKey 表键名(user, real_time_info, calculate_record)
|
||||
* @param string|null $businessType 业务类型,为空则自动检测
|
||||
* @return string
|
||||
*/
|
||||
public static function getTableName($tableKey, $businessType = null)
|
||||
{
|
||||
if ($businessType === null) {
|
||||
$businessType = self::getBusinessTypeByModule();
|
||||
}
|
||||
|
||||
$map = self::getTableMap($businessType);
|
||||
return isset($map[$tableKey]) ? $map[$tableKey] : $tableKey;
|
||||
}
|
||||
}
|
||||
68
application/common/controller/DashboardBase.php
Normal file
68
application/common/controller/DashboardBase.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* 系统概览公共控制器
|
||||
* 提供统一的业务逻辑,供admin和adminghd模块继承使用
|
||||
*/
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\common\BaseController;
|
||||
use think\Db;
|
||||
|
||||
class DashboardBase extends BaseController
|
||||
{
|
||||
/**
|
||||
* 获取统计数据
|
||||
*/
|
||||
public function getStatistics()
|
||||
{
|
||||
try {
|
||||
// 获取表名
|
||||
$userTable = $this->getTableName('user');
|
||||
$infoTable = $this->getTableName('real_time_info');
|
||||
$recordTable = $this->getTableName('calculate_record');
|
||||
|
||||
// 小程序注册用户数量
|
||||
$userCount = Db::name($userTable)->count();
|
||||
|
||||
// 首页资讯数量
|
||||
$infoCount = Db::name($infoTable)->count();
|
||||
|
||||
// 最近一次计算时间
|
||||
$lastCalculate = Db::name($recordTable)
|
||||
->order('create_time desc')
|
||||
->value('create_time');
|
||||
|
||||
// 今日新增用户
|
||||
$todayUserCount = Db::name($userTable)
|
||||
->whereTime('create_time', 'today')
|
||||
->count();
|
||||
|
||||
// 总计算次数
|
||||
$totalCalculateCount = Db::name($recordTable)->count();
|
||||
|
||||
return json([
|
||||
'status' => 1,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'user_count' => $userCount,
|
||||
'info_count' => $infoCount,
|
||||
'last_calculate_time' => $lastCalculate ?: '暂无',
|
||||
'today_user_count' => $todayUserCount,
|
||||
'total_calculate_count' => $totalCalculateCount
|
||||
]
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return json([
|
||||
'status' => 0,
|
||||
'msg' => '获取失败:' . $e->getMessage(),
|
||||
'data' => [
|
||||
'user_count' => 0,
|
||||
'info_count' => 0,
|
||||
'last_calculate_time' => '暂无',
|
||||
'today_user_count' => 0,
|
||||
'total_calculate_count' => 0
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
100
application/common/controller/WechatinfroBase.php
Normal file
100
application/common/controller/WechatinfroBase.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* 微信用户信息管理公共控制器
|
||||
* 提供统一的业务逻辑,供admin和adminghd模块继承使用
|
||||
*/
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\common\BaseController;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
|
||||
class WechatinfroBase extends BaseController
|
||||
{
|
||||
/**
|
||||
* 查看小程序注册用户信息
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function getWechatUserList(Request $request)
|
||||
{
|
||||
$post = $request->param();
|
||||
|
||||
$page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1; // 页数
|
||||
$page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30; // 每页条数
|
||||
|
||||
// 搜索
|
||||
$where = [];
|
||||
if (isset($post['title']) && !empty($post['title'])) {
|
||||
$where['nickname'] = ['like', '%' . $post['title'] . '%'];
|
||||
}
|
||||
|
||||
// 获取用户表名
|
||||
$tableName = $this->getTableName('user');
|
||||
|
||||
// 升序获取菜单列表
|
||||
$res = Db::name($tableName)
|
||||
->field('uid,nickname,headimg,create_time')
|
||||
->where($where)
|
||||
->order('create_time desc')
|
||||
->paginate($page_size, false, ['page' => $page]);
|
||||
|
||||
$lists = $res->items();
|
||||
$start = ($page - 1) * $page_size;
|
||||
foreach ($lists as $k => $v) {
|
||||
$start += 1;
|
||||
$lists[$k]['no_id'] = $start;
|
||||
}
|
||||
|
||||
$result['lists'] = $lists;
|
||||
$result['lastPage'] = $res->lastPage(); // 总页数
|
||||
$result['currentPage'] = $res->currentPage(); // 当前页
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = '查询成功';
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看小程序记录
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function getWechatRecordList(Request $request)
|
||||
{
|
||||
$post = $request->param();
|
||||
|
||||
$page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1; // 页数
|
||||
$page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30; // 每页条数
|
||||
|
||||
// 搜索
|
||||
$where = [];
|
||||
if (isset($post['title']) && !empty($post['title'])) {
|
||||
$where['name'] = ['like', '%' . $post['title'] . '%'];
|
||||
}
|
||||
|
||||
// 获取计算记录表名
|
||||
$tableName = $this->getTableName('calculate_record');
|
||||
|
||||
// 查询列表
|
||||
$res = Db::name($tableName)
|
||||
->field('id,name,age,height,bone_age,father_height,mother_height,IGF,LH,uterus_thickness,calculate_resutlt,create_time')
|
||||
->where($where)
|
||||
->order('create_time desc')
|
||||
->paginate($page_size, false, ['page' => $page]);
|
||||
|
||||
$lists = $res->items();
|
||||
$start = ($page - 1) * $page_size;
|
||||
foreach ($lists as $k => $v) {
|
||||
$start += 1;
|
||||
$lists[$k]['no_id'] = $start;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['lists'] = $lists;
|
||||
$result['lastPage'] = $res->lastPage(); // 总页数
|
||||
$result['currentPage'] = $res->currentPage(); // 当前页
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = '查询成功';
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
169
application/common/controller/WechatsetBase.php
Normal file
169
application/common/controller/WechatsetBase.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* 微信设置管理公共控制器
|
||||
* 提供统一的业务逻辑,供admin和adminghd模块继承使用
|
||||
*/
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\common\BaseController;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
|
||||
class WechatsetBase extends BaseController
|
||||
{
|
||||
/**
|
||||
* 查询小程序资讯信息
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function getWechatRealTimeInfoList(Request $request)
|
||||
{
|
||||
$post = $request->param();
|
||||
|
||||
$page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1; // 页数
|
||||
$page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30; // 每页条数
|
||||
|
||||
// 搜索
|
||||
$where = [];
|
||||
if (isset($post['title']) && !empty($post['title'])) {
|
||||
$where['title_plain'] = ['like', '%' . $post['title'] . '%'];
|
||||
}
|
||||
|
||||
// 获取资讯表名
|
||||
$tableName = $this->getTableName('real_time_info');
|
||||
|
||||
// 升序获取菜单列表
|
||||
$res = Db::name($tableName)
|
||||
->field('id,title_plain,thumbnail,excerpt_plain,url,create_time')
|
||||
->where($where)
|
||||
->order('create_time desc')
|
||||
->paginate($page_size, false, ['page' => $page]);
|
||||
|
||||
$lists = $res->items();
|
||||
$start = ($page - 1) * $page_size;
|
||||
foreach ($lists as $k => $v) {
|
||||
$start += 1;
|
||||
$lists[$k]['no_id'] = $start;
|
||||
}
|
||||
|
||||
$result['lists'] = $lists;
|
||||
$result['lastPage'] = $res->lastPage(); // 总页数
|
||||
$result['currentPage'] = $res->currentPage(); // 当前页
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = '查询成功';
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除小程序资讯信息
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function delWechatRealTimeInfo(Request $request)
|
||||
{
|
||||
$post = $request->param();
|
||||
if (!isset($post['id']) || empty($post['id'])) {
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "请选择要删除的记录";
|
||||
return json($result);
|
||||
}
|
||||
|
||||
$tableName = $this->getTableName('real_time_info');
|
||||
$id = Db::name($tableName)->where('id', $post['id'])->value('id');
|
||||
|
||||
if (empty($id)) {
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "该记录异常,无法删除";
|
||||
return json($result);
|
||||
}
|
||||
|
||||
$res = Db::name($tableName)->where('id', $id)->delete();
|
||||
if ($res > 0) {
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = '删除成功';
|
||||
} else {
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = '删除失败';
|
||||
}
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存小程序资讯信息
|
||||
* @author hjc
|
||||
*/
|
||||
public function saveWechatRealTimeInfo(Request $request)
|
||||
{
|
||||
$post = $request->param();
|
||||
|
||||
if (!isset($post['title_plain']) || empty($post['title_plain'])) {
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "未传入标题";
|
||||
return json($result);
|
||||
}
|
||||
if (!isset($post['thumbnail']) || empty($post['thumbnail'])) {
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "未传入图片";
|
||||
return json($result);
|
||||
}
|
||||
if (!isset($post['excerpt_plain']) || empty($post['excerpt_plain'])) {
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "未传入简介";
|
||||
return json($result);
|
||||
}
|
||||
if (!isset($post['url']) || empty($post['url'])) {
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "未传入资讯跳转链接";
|
||||
return json($result);
|
||||
}
|
||||
|
||||
// 提交数据
|
||||
$data = [];
|
||||
$data['title_plain'] = $post['title_plain']; // 标题
|
||||
$data['thumbnail'] = $post['thumbnail']; // 图片
|
||||
$data['excerpt_plain'] = $post['excerpt_plain']; // 介绍
|
||||
$data['url'] = $post['url']; // 跳转连接
|
||||
|
||||
$tableName = $this->getTableName('real_time_info');
|
||||
|
||||
if (isset($post['id']) && !empty($post['id'])) {
|
||||
// 修改数据
|
||||
$res = Db::name($tableName)->where('id', $post['id'])->update($data);
|
||||
} else {
|
||||
// 保存记录数据
|
||||
$data['id'] = md5(time() . rand(100000, 999999));
|
||||
$data['create_time'] = date('Y-m-d H:i:s');
|
||||
$res = Db::name($tableName)->insert($data);
|
||||
}
|
||||
|
||||
if ($res === false) {
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "添加失败";
|
||||
return json($result);
|
||||
} else {
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = "添加成功";
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询资讯信息详情
|
||||
* @author hjc
|
||||
*/
|
||||
public function getRealTimeInfoDetail(Request $request)
|
||||
{
|
||||
$post = $request->param();
|
||||
if (!isset($post['id']) || empty($post['id'])) {
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "未传入资讯id";
|
||||
return json($result);
|
||||
}
|
||||
|
||||
$tableName = $this->getTableName('real_time_info');
|
||||
$result['infro'] = Db::name($tableName)->where('id', $post['id'])->find();
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = "查询成功";
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user