first commit

This commit is contained in:
编码猿
2024-09-27 01:32:49 +08:00
commit 28ebe05a64
7399 changed files with 1174529 additions and 0 deletions

View File

@@ -0,0 +1 @@
090fb2ac-13d8-44d6-9c0b-25b80b00af7d

View File

@@ -0,0 +1,109 @@
<?php
/**
* 后台公用模型
*/
namespace app\admin\controller;
use think\Controller;
use think\exception\HttpResponseException;
use app\admin\service\ModelService;
use app\admin\service\AuthService;
class AdminController extends Controller
{
/**
* 开启登录控制
* @var bool
*/
protected $is_login = true;
/**
* 开启权限控制
* @var bool
*/
protected $is_auth = '';
/**
* 网站栏目
* @var string
*/
protected $nav = '';
/**
* 登录用户信息
* @var string
*/
protected $user = '';
/**
* 后台配置信息
* @var array
*/
protected $SysInfo = [];
/**
* 网站标题
* @var string
*/
protected $title = '';
/**
* 初始化数据
* Index constructor.
*/
public function __construct()
{
parent::__construct();
list($this->nav, $this->title, $this->is_login, $this->is_auth,) = ['', '', true, true];
$this->SysInfo = cache('SysInfo');
//检测登录情况
if ($this->is_login == true) {
$this->__checkLogin();
}
//判断是否有权限进行访问
if ($this->is_auth == true) {
$this->__checkAuth();
}
}
/**
* 检测登录
*/
public function __checkLogin()
{
$user = session('user');
//判断是否登录
if (empty($user)) {
$data = ['type' => 'error', 'code' => 1, 'msg' => '抱歉,您还没有登录获取访问权限!', 'url' => url('@admin/login')];
}
//判断登录是否过期
(isset($this->SysInfo['LoginDuration']) && !empty($this->SysInfo['LoginDuration'])) ? $LoginDuration = $this->SysInfo['LoginDuration'] : $LoginDuration = '';
if (!empty($LoginDuration) && !empty($user)) {
if (time() - $user['login_at'] >= $LoginDuration) {
\app\admin\service\LogService::loginLog($user['id'], 0, 1, "【登录过期】正在退出后台系统!");
$data = ['type' => 'error', 'code' => 1, 'msg' => '登录已过期,请重新登录!', 'url' => url('@admin/login')];
}
}
//返回错误信息
if (!empty($data)) {
session('user', null);
throw new HttpResponseException($this->request->isAjax() ? json($data) : exit(msg_error($data['msg'], $data['url'])));
}
$this->user = $user;
}
/**
* 检测登录情况
*/
public function __checkAuth()
{
if (AuthService::checkNode() == false) {
$data = ['type' => 'error', 'code' => 1, 'msg' => '抱歉,您暂无该权限,请联系管理员!', 'url' => url('@admin')];
throw new HttpResponseException($this->request->isAjax() ? json($data) : exit(msg_error($data['msg'], $data['url'])));
}
}
}

View File

@@ -0,0 +1,248 @@
<?php
namespace app\admin\controller;
use app\admin\controller\AdminController;
use think\facade\Cache;
class Auth extends AdminController {
/**
* Auth模型对象
*/
protected $model = null;
/**
* 初始化
* node constructor.
*/
public function __construct() {
parent::__construct();
$this->model = model('auth');
}
/**
* 角色列表
*/
public function index() {
if (!$this->request->isPost()) {
//ajax访问获取数据
if ($this->request->get('type') == 'ajax') {
$page = $this->request->get('page', 1);
$limit = $this->request->get('limit', 10);
$search = (array)$this->request->get('search', []);
return json($this->model->authList($page, $limit, $search));
}
//基础数据
$basic_data = [
'title' => '系统角色列表',
'data' => '',
'status' => [['id' => 1, 'title' => '启用'], ['id' => 0, 'title' => '禁用']],
];
return $this->fetch('', $basic_data);
} else {
$post = $this->request->post();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\Common.edit_field');
if (true !== $validate) return __error($validate);
//保存数据,返回结果
return $this->model->editField($post);
}
}
/**
* 添加角色
* @return mixed|\think\response\Json
*/
public function add() {
if (!$this->request->isPost()) {
//基础数据
$basic_data = [
'title' => '添加角色',
];
$this->assign($basic_data);
return $this->form();
} else {
$post = $this->request->post();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\Auth.add');
if (true !== $validate) return __error($validate);
//清空缓存
clear_menu();
//保存数据,返回结果
return $this->model->add($post);
}
}
/**
* 修改管理员信息
* @return mixed|string|\think\response\Json
*/
public function edit() {
if (!$this->request->isPost()) {
//查找所需修改角色
$auth = $this->model->where('id', $this->request->get('id'))->find();
if (empty($auth)) return msg_error('暂无数据,请重新刷新页面!');
//基础数据
$basic_data = [
'title' => '修改角色信息',
'auth' => $auth,
];
$this->assign($basic_data);
return $this->form();
} else {
$post = $this->request->post();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\Auth.edit');
if (true !== $validate) return __error($validate);
//清空菜单缓存
clear_menu();
//保存数据,返回结果
return $this->model->edit($post);
}
}
/**
* 表单模板
* @return mixed
*/
protected function form() {
return $this->fetch('form');
}
/**
* 删除角色
* @return \think\response\Json
* @throws \Exception
*/
public function del() {
$get = $this->request->get();
//验证数据
if (!is_array($get['id'])) {
$validate = $this->validate($get, 'app\admin\validate\Auth.del');
if (true !== $validate) return __error($validate);
}
//执行更新操作操作
if (!is_array($get['id'])) {
$del = $this->model->where('id', $get['id'])->delete();
model('auth_node')->where('auth', $get['id'])->delete();
} else {
$del = $this->model->whereIn('id', $get['id'])->delete();
model('auth_node')->whereIn('auth', $get['id'])->delete();
}
if ($del >= 1) {
//清空菜单缓存
clear_menu();
return __success('删除成功!');
} else {
return __error('数据有误,请刷新重试!');
}
}
/**
* 更改角色状态
* @return \think\response\Json
*/
public function status() {
$get = $this->request->get();
//验证数据
$validate = $this->validate($get, 'app\admin\validate\Auth.status');
if (true !== $validate) return __error($validate);
//判断菜单状态
$status = $this->model->where('id', $get['id'])->value('status');
$status == 1 ? list($msg, $status) = ['角色禁用成功', $status = 0] : list($msg, $status) = ['角色启用成功', $status = 1];
//执行更新操作操作
$update = $this->model->where('id', $get['id'])->update(['status' => $status]);
//清空菜单缓存
clear_menu();
if ($update >= 1) return __success($msg);
return __error('数据有误,请刷新重试!');
}
/**
* 授权信息
* @return mixed|string|\think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function authorize() {
if (!$this->request->isPost()) {
//查找所需授权角色
$auth = $this->model->where('id', $this->request->get('id'))->find();
if (empty($auth)) return msg_error('暂无数据,请重新刷新页面!');
$node = model('node')->where(['is_auth' => 1])->order('node asc')->select();
$auth_node = model('auth_node')->where(['auth' => $auth['id']])->select();
foreach ($node as &$vo) {
$i = 0;
foreach ($auth_node as $al) {
$vo['id'] == $al['node'] && $i++;
}
$i == 0 ? $vo['is_checked'] = false : $vo['is_checked'] = true;
}
//基础数据
$basic_data = [
'title' => '角色授权',
'auth' => $auth,
'node' => $node,
];
$this->assign($basic_data);
return $this->fetch();
} else {
$post = $this->request->post();
empty($post['node_id']) && $post['node_id'] = [];
//验证数据
$validate = $this->validate($post, 'app\admin\validate\Auth.authorize');
if (true !== $validate) return __error($validate);
$insertAll = [];
foreach ($post['node_id'] as $vo) {
$insertAll[] = [
'auth' => $post['auth_id'],
'node' => $vo,
];
}
//清空菜单缓存
clear_menu();
//清空旧数据
model('auth_node')->where(['auth' => $post['auth_id']])->delete();
//保存数据,返回结果
return model('auth_node')->authorize($insertAll);
}
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace app\admin\controller;
use app\admin\controller\AdminController;
/**
* 系统配置
* Class Config
* @package app\admin\controller
*/
class Config extends AdminController {
/**
* config模型对象
*/
protected $model = null;
/**
* 初始化
* node constructor.
*/
public function __construct() {
parent::__construct();
$this->model = model('config');
}
/**
* 系统配置信息列表
*/
public function index() {
if (!$this->request->isPost()) {
//ajax访问获取数据
if ($this->request->get('type') == 'ajax') {
$page = $this->request->get('page', 1);
$limit = $this->request->get('limit', 500);
$search = (array)$this->request->get('search', []);
return json($this->model->configList($page, $limit, $search));
}
//基础数据
$basic_data = [
'title' => '系统参数列表',
];
$this->assign($basic_data);
return $this->fetch('');
} else {
$post = $this->request->post();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\Common.edit_field');
if (true !== $validate) return __error($validate);
//保存数据,返回结果
return $this->model->editField($post);
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* 图标管理
* Class Icon
* @package app\admin\controller
*/
namespace app\admin\controller;
use app\admin\controller\AdminController;
class Icon extends AdminController {
/**
* 图标列表
*/
public function index() {
$basic_data = [
'title' => '图标列表',
];
return $this->fetch('', $basic_data);
}
public function fa(){
$basic_data = [
'title' => 'fa图标列表',
];
return $this->fetch('', $basic_data);
}
}

View File

@@ -0,0 +1,49 @@
<?php
/*
* 首页
* */
namespace app\admin\controller;
use app\admin\controller\AdminController;
use think\facade\Cache;
use think\facade\Request;
class Index extends AdminController {
/**
* 首页
* @return mixed
*/
public function index() {
Cache::remember('Home', function () {
return model('menu')->getHome();
});
$apimenu = new \app\admin\controller\api\Menu();
$sys_info = Cache::get('SysInfo');
$basic_data = [
'title' => $sys_info['ManageName'],
'nav' => $apimenu->getNav(),
'home' => Cache::get('Home'),
'data' => '',
];
return $this->fetch('', $basic_data);
}
/**
* 首页欢迎界面
* @return mixed
*/
public function welcome() {
$basic_data = [
'quick_nav' => \app\admin\model\Nav::getQuickNav(),
];
return $this->fetch('', $basic_data);
}
}

View File

@@ -0,0 +1,111 @@
<?php
/*
* 后台登录
* */
namespace app\admin\controller;
use think\Controller;
use think\facade\Cache;
class Login extends Controller {
/**
* User模型对象
*/
protected $model = null;
/**
* 初始化
* Login constructor.
*/
public function __construct() {
parent::__construct();
$this->model = model('User');
$action = $this->request->action();
if (!empty(session('user.id')) && $action !== 'out' && $action !== 'change') return $this->redirect('@admin');
}
/**
* 后台登录
* @return mixed|\think\response\Json
*/
public function index() {
if ($this->request->isGet()) {
//基础数据
$basic_data = [
'title' => '伊莎洗衣后台登录',
'data' => '',
];
$this->assign($basic_data);
return $this->fetch('');
} else {
$post = $this->request->post();
//判断是否开启验证码登录选择验证规则
$SysInfo = Cache::get('SysInfo');
$SysInfo['VercodeType'] != 1 ? $validate_type = 'app\admin\validate\Login.index_off' : $validate_type = 'app\admin\validate\Login.index_on';
//验证参数
$validate = $this->validate($post, $validate_type);
if (true !== $validate) {
return __error($validate);
}
//判断登录是否成功
$login = $this->model->login($post['username'], $post['password']);
if ($login['code'] == 1) {
isset($login['user']['id']) ? $user_id = $login['user']['id'] : $user_id = '';
\app\admin\service\LogService::loginLog($user_id, 1, 0, "【账号登录】{$login['msg']}");
return __error($login['msg']);
}
//储存session数据
$login['user']['login_at'] = time();
session('user', $login['user']);
\app\admin\service\LogService::loginLog($login['user']['id'], 1, 1, '【账号登录】登录成功,正在进入系统!');
return __success($login['msg']);
}
}
/**
* 切换账户
* @return mixed
*/
public function change() {
if ($this->request->isGet()) {
//基础数据
$basic_data = [
'title' => '伊莎洗衣后台登录',
'data' => '',
];
$this->assign($basic_data);
return $this->fetch('index');
}
}
/**
* 退出登录
* @return \think\response\Json
*/
public function out() {
//记录日志
\app\admin\service\LogService::loginLog(session('user.id'), 0, 1, "【主动退出】正在退出后台系统!");
//删除自身菜单缓存
Cache::rm(session('user.id') . '_AdminMenu');
//清空sesion数据
session('user', null);
return msg_success('退出登录成功', url('@admin/login'));
}
}

View File

@@ -0,0 +1,207 @@
<?php
/**
* 菜单管理
* Class Menu
* @package app\admin\controller
*/
namespace app\admin\controller;
use app\admin\controller\AdminController;
use think\facade\Cache;
class Menu extends AdminController {
/**
* User模型对象
*/
protected $model = null;
/**
* 初始化
* User constructor.
*/
public function __construct() {
parent::__construct();
$this->model = model('menu');
}
/**
* 菜单栏列表
* @return mixed|\think\response\Json
*/
public function index() {
if (!$this->request->isPost()) {
//ajax访问
if ($this->request->get('type') == 'ajax') {
$search = (array)$this->request->get('search', []);
$menu_list = $this->model->menuList($search);
return json($menu_list);
}
//基础数据
$basic_data = [
'status' => [
['id' => 1, 'title' => '启用'],
['id' => 0, 'title' => '禁用'],
],
'title' => '菜单栏管理',
'data' => '',
];
return $this->fetch('', $basic_data);
} else {
$post = $this->request->post();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\Common.edit_field');
if (true !== $validate) return __error($validate);
//保存数据,返回结果
return $this->model->editField($post);
}
}
/**
* 添加菜单
* @return mixed|\think\response\Json
*/
public function add() {
if (!$this->request->isPost()) {
$pid = $this->request->get('pid', '');
$basic_data = [
'title' => '添加菜单',
];
!empty($pid) && $basic_data['menu'] = ['pid' => $pid];
$this->assign($basic_data);
return $this->form();
} else {
$post = $this->request->post();
unset($post['id']);
//验证数据
$validate = $this->validate($post, 'app\admin\validate\Menu.add');
if (true !== $validate) return __error($validate);
//清空菜单缓存
clear_menu();
return $this->model->add($post);
}
}
/**
* 修改菜单
* @return mixed
*/
public function edit() {
if (!$this->request->isPost()) {
//查找所需修改菜单
$menu = $this->model->where('id', $this->request->get('id'))->find();
if (empty($menu)) return msg_error('暂无数据,请重新刷新页面!');
strpos($menu['icon'], 'fa-') !== false ? $menu['icon_type'] = 'fa' : $menu['icon_type'] = 'layui';
//基础数据
$basic_data = [
'title' => '修改菜单',
'menu' => $menu,
];
$this->assign($basic_data);
return $this->form();
} else {
$post = $this->request->post();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\Menu.edit');
if (true !== $validate) return __error($validate);
//清空菜单缓存
clear_menu();
return $this->model->edit($post);
}
}
/**
* 表单模板
* @return mixed
*/
protected function form() {
$basic_data = [
'up_menu' => $this->model->getUpMenu(),
];
$this->assign($basic_data);
return $this->fetch('form');
}
/**
* 删除菜单
* @return \think\response\Json
* @throws \Exception
*/
public function del() {
$get = $this->request->get();
//验证数据
if (!is_array($get['id'])) {
$validate = $this->validate($get, 'app\admin\validate\Menu.del');
if (true !== $validate) return __error($validate);
}
//执行删除操作
if (!is_array($get['id'])) {
$del = $this->model->where('id', $get['id'])->delete();
} else {
$del = $this->model->whereIn('id', $get['id'])->delete();
}
if ($del >= 1) {
//清空菜单缓存
clear_menu();
return __success('菜单删除成功!');
} else {
return __error('数据有误,请刷新重试!');
}
}
/**
* 更改菜单状态
* @return \think\response\Json
*/
public function status() {
$get = $this->request->get();
if ($get['id'] == 1) return __error('首页不允许更改状态');
//验证数据
$validate = $this->validate($get, 'app\admin\validate\Menu.status');
if (true !== $validate) return __error($validate);
//判断菜单状态
$status = $this->model->where('id', $get['id'])->value('status');
if ($status == 1) {
$msg = '菜单禁用成功';
$status = 0;
} else {
$msg = '菜单启用成功';
$status = 1;
}
//执行更新操作操作
$update = $this->model->where('id', $get['id'])->update(['status' => $status]);
if ($update >= 1) {
//清空菜单缓存
clear_menu();
return __success($msg);
} else {
return __error('数据有误,请刷新重试!');
}
}
}

View File

@@ -0,0 +1,84 @@
<?php
/**
* 节点管理
* Class Node
* @package app\admin\controller
*/
namespace app\admin\controller;
use app\admin\controller\AdminController;
class Node extends AdminController {
/**
* node模型对象
*/
protected $model = null;
/**
* 初始化
* node constructor.
*/
public function __construct() {
parent::__construct();
$this->model = model('node');
}
/**
* 节点列表
*/
public function index() {
if (!$this->request->isPost()) {
//ajax访问获取数据
if (!empty($this->request->get('module'))) {
return json($this->model->nodeModuleList($this->request->get('module')));
}
$module_list = $this->model->where(['type' => 1])->order(['node'=>'asc'])->select()->toArray();
foreach ($module_list as $k => $val) $k == 0 ? $module_list[$k]['is_selectd'] = true : $module_list[$k]['is_selectd'] = false;
//基础数据
$basic_data = [
'title' => '系统节点列表',
'module_list' => $module_list,
];
$this->assign($basic_data);
return $this->fetch('');
} else {
$post = $this->request->post();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\Common.edit_field');
if (true !== $validate) return __error($validate);
//保存数据,返回结果
return $this->model->editField($post);
}
}
/**
* 更改节点状态
* @return \think\response\Json
*/
public function status() {
$get = $this->request->get();
//验证数据
$validate = $this->validate($get, 'app\admin\validate\Node.status');
if (true !== $validate) return __error($validate);
//判断菜单状态
$status = $this->model->where('id', $get['id'])->value('is_auth');
$status == 1 ? list($msg, $status) = ['节点禁用成功', $status = 0] : list($msg, $status) = ['节点启用成功', $status = 1];
//执行更新操作操作
$update = $this->model->where('id', $get['id'])->update(['is_auth' => $status]);
//清空菜单缓存
clear_menu();
if ($update >= 1) return __success($msg);
return __error('数据有误,请刷新重试!');
}
}

View File

@@ -0,0 +1,355 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/28
* Time: 13:54
*/
namespace app\admin\controller;
use think\Db;
use think\Exception;
use think\facade\Cache;
use think\Log;
class Shell
{
//修改新高考mykemu字段
public function updateMykemu(){
ignore_user_abort(true);
set_time_limit(0);
$id = Cache::store('redis')->get('recLikekemus');
if(empty($id)){
$id = 3793738;
}
$count = Db::table('rec_js')->where('id','between',[$id,7592360])->count();
$num = 1000;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i-1)*$num;
$result = Db::table('rec_js')->field('id,mykemu')->where('id','between',[$id,7592360])->limit($offet,$num)->select();
$level = config('setsub.levelArr');
foreach ($result as $key => $val) {
$val['mykemu'] = $result = explode(',',$val['mykemu']);
$res = '';
foreach($val['mykemu'] as $k=>$v){
$res .= $level[$v];
}
Db::table('rec_js')->where('id','=',$val['id'])->update(['mykemu'=>$res]);
Cache::store('redis')->set("recLikekemus",$val['id'],36000);
}
}
echo 1;die;
}
/*
* 江苏同步public和majorNum
* */
public function pubMajorNumTojs(){
ignore_user_abort(true);
set_time_limit(0);
$id = Cache::store('redis')->get('recjsIDs');
if(empty($id)){
$id = 0;
}
$count = Db::table('rec_js')->where('id','between',[$id,7592360])->count();
$num = 10000;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i - 1) * $num;
$result = Db::table('rec_js')->field("id,sch_id")->where('id','between',[$id,7592360])->limit($offet, $num)->select();
foreach ($result as $key => $val) {
$resSch = Db::table('yzy_school')->field("is_public")->where('sch_id', '=', $val['sch_id'])->find();
$resCount = Db::table('rec_js_major')->where('rec_id','=',$val['id'])->find();
$count = count(json_decode($resCount['professions']));
Db::table('rec_js')->where([['id', '=', $val['id']]])->update(['is_public' => $resSch['is_public'],'majorNum'=>$count]);
Cache::store('redis')->set("recjsIDs",$val['id'],36000);
}
}
echo 1;
}
/*
* 同步数据到yzy_major_score表sch_name,cost,typeName
*/
public function getSchNameTypeNameToJs(){
ignore_user_abort(true);
set_time_limit(0);
$id = Cache::store('redis')->get('majorScoreID');
if(empty($id)){
$id = 0;
}
$count = Db::table('yzy_major_score')->where('id','between',[$id,3626706])->count();
$num = 10000;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i - 1) * $num;
$result = Db::table('yzy_major_score')->field("id,sch_id,majorCode")->where('id','between',[$id,3626706])->limit($offet, $num)->select();
foreach ($result as $key => $val) {
$resCode = Db::table('yzy_majors')->field('pid')->where([['level','=',3],['code','=',$val['majorCode']]])->find();
$relCode = empty($resCode)?Db::table('yzy_majors')->field('pid,title')->where([['level','=',2],['code','=',$val['majorCode']]])->find():Db::table('yzy_majors')->field('title')->where('id','=',$resCode['pid'])->find();
if(empty($relCode)){
$relCode['title'] = '';
}
$resSch = Db::table('yzy_school')->field("title")->where('sch_id', '=', $val['sch_id'])->find();
Db::table('yzy_major_score')->where('id','=',$val['id'])->update(['sch_name'=>$resSch['title'],'typeName'=>$relCode['title']]);
Cache::store('redis')->set("majorScoreID",$val['id'],36000);
}
}
echo 1;
}
/*
* 修改rec_zhejiang_majors表将classify中文转换成数字
* */
public function updateCollegeType(){
$result = Db::table('rec_zhejiang_schs')->field('id,classify')->select();
$cate = config('setsub.cateArr');
foreach ($result as $key => $val) {
$cateid = $cate[$val['classify']];
Db::table('rec_zhejiang_schs')->where('id','=',$val['id'])->update(['collegeType'=>$cateid]);
}
}
/*
* 最低分和位次迁移
* */
public function updateMajor(){
$result = Db::table('rec_wen_major')->select();
foreach($result as $key=>$val){
$res = json_decode($val['professions']);
foreach($res as $k => $v){
$data['rec_id'] = $result[$key]['rec_id'];
$data['title'] = $v->alias;
$data['code'] = $v->majorCode;
$resRank = json_decode($v->extended);
$data['lowestRank'] = $resRank[0]->ls;
$data['minScore'] = $resRank[0]->ms;
$data['scoreLineYear'] = $v->scoreLineYear;
$data['year'] = $v->year;
$data['enterNum'] = $v->enterNum;
$data['planNum'] = $v->planNum;
$data['probability'] = $v->probability;
Db::table('rec_majors')->insert($data);
}
}
}
/*
* 新高考
* 数据迁移yzy_zj_major_score 新增字段 sch_cate rankOfCn
* */
public function updateMajorScore(){
$result = Db::table('yzy_zj_major_score')->field("id,sch_id")->select();
$cate = config('setsub.cateName');
foreach ($result as $key =>$val){
$resClass = Db::table('yzy_school')->field('cate_id')->where('sch_id','=',$val['sch_id'])->find();
$cateName = $cate[$resClass['cate_id']];
$resRank = Db::table("yzy_school_exts")->field('rankOfCn')->where("sch_id",'=',$val['sch_id'])->find();
Db::table('yzy_zj_major_score')->where([['id','=',$val['id']],['sch_id','=',$val['sch_id']]])->update(['classify'=>$cateName,'rankOfCn'=>$resRank['rankOfCn']]);
}
}
/*
* school表排名更新
* */
public function updateSchoolRank(){
$result = Db::table('yzy_school')->field("id,sch_id")->select();
foreach ($result as $key =>$val){
$resRank = Db::table("yzy_school_exts")->field('rankOfCn')->where("sch_id",'=',$val['sch_id'])->find();
Db::table('yzy_school')->where([['id','=',$val['id']],['sch_id','=',$val['sch_id']]])->update(['rankOfCn'=>$resRank['rankOfCn']]);
}
}
/*
* 新高考
* 专业数量同步到院校表
* */
public function majorCountToSch(){
set_time_limit(0);
$count = Db::table('rec_zhejiang_majors')->count();
$num = 1000;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i - 1) * $num;
$result = Db::table('rec_zhejiang_schs')->field("id")->limit($offet, $num)->select();
foreach ($result as $key => $val) {
$resMajor = Db::table('rec_zhejiang_schs_majors')->field('professions')->where('rec_id', '=', $val['id'])->find();
$count = count(json_decode($resMajor['professions']));
Db::table('rec_zhejiang_schs')->where('id', '=', $val['id'])->update(['majorNum' => $count]);
}
}
}
/*
* 院校logo地址查询
* */
public function getSchoolLogos(){
$result = Db::table('yzy_school')->field("sch_id,logo")->select();
return api_return('ok',$result);
}
/*
* 新高考院校表同步is_yldx,is_ylxk
* */
public function ylxkyldxToNewSch(){
set_time_limit(0);
$count = Db::table('rec_zhejiang_schs')->count();
$num = 100;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i - 1) * $num;
$result = Db::table('rec_zhejiang_schs')->field("id,collegeId")->limit($offet, $num)->select();
foreach ($result as $key => $val) {
$resSch = Db::table('yzy_school')->field("is_yldx,is_ylxk")->where('sch_id', '=', $val['collegeId'])->find();
Db::table('rec_zhejiang_schs')->where([['id', '=', $val['id']], ['collegeId', '=', $val['collegeId']]])->update(['is_yldx' => $resSch['is_yldx'], 'is_ylxk' => $resSch['is_ylxk']]);
}
}
}
/*
* 新高考專業表同步is_yldx,is_ylxk
* */
public function ylxkyldxToNewSchMajor(){
ignore_user_abort(true);
set_time_limit(0);
$id = Cache::store('redis')->get('NewSchMajorIDso');
if(empty($id)){
$id = 0;
}
$count = Db::table('rec_zhejiang_majors')->where('id','>',$id)->count();
$num = 10000;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i - 1) * $num;
$result = Db::table('rec_zhejiang_majors')->field("id,collegeId")->where('id','>',$id)->limit($offet, $num)->select();
try {
foreach ($result as $key => $val) {
$resSch = Db::table('yzy_school')->field("is_public")->where('sch_id', '=', $val['collegeId'])->find();
Db::table('rec_zhejiang_majors')->where([['id', '=', $val['id']]])->update(['is_public' => $resSch['is_public']]);
Cache::store('redis')->set("NewSchMajorIDso",$val['id'],36000);
\think\facade\Log::error($val['id']);
}
}catch (\Exception $exception){
\think\facade\Log::error($exception);
}
}
echo 1;
}
/*
* 普通高考院校文科同步雙一流字段和majorNum,public
* */
public function sylMajorNumToWen(){
ignore_user_abort(true);
set_time_limit(0);
$id = Cache::store('redis')->get('recWenIDso');
if(empty($id)){
$id = 0;
}
$count = Db::table('rec_wen')->where('id','between',[$id,8175158])->count();
$num = 10000;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i - 1) * $num;
$result = Db::table('rec_wen')->field("id,sch_id")->where('id','between',[$id,8175158])->limit($offet, $num)->select();
foreach ($result as $key => $val) {
$resSch = Db::table('yzy_school')->field("is_public")->where('sch_id', '=', $val['sch_id'])->find();
Db::table('rec_wen')->where([['id', '=', $val['id']]])->update(['is_public' => $resSch['is_public']]);
Cache::store('redis')->set("recWenIDso",$val['id'],36000);
}
}
echo 1;
}
/*
* 普通高考院校理科同步雙一流字段和majorNum
* */
public function sylMajorNumToLi(){
ignore_user_abort(true);
set_time_limit(0);
$id = Cache::store('redis')->get('recLikeIDo');
if(empty($id)){
$id = 0;
}
$count = Db::table('rec_li')->where('id','between',[$id,10491664])->count();
$num = 10000;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i - 1) * $num;
$result = Db::table('rec_li')->field("id,sch_id")->where('id','between',[$id,10491664])->limit($offet, $num)->select();
foreach ($result as $key => $val) {
$resSch = Db::table('yzy_school')->field("is_public")->where('sch_id', '=', $val['sch_id'])->find();
Db::table('rec_li')->where([['id', '=', $val['id']]])->update(['is_public' => $resSch['is_public']]);
Cache::store('redis')->set("recLikeIDo",$val['id'],36000);
}
}
echo 1;
}
}

View File

@@ -0,0 +1,212 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/28
* Time: 13:54
*/
namespace app\admin\controller;
use think\Db;
use think\Exception;
use think\facade\Cache;
use think\Log;
class Shellone
{
//修改新高考mykemu字段
public function updateMykemu(){
set_time_limit(0);
$count = Db::table('rec_js')->count();
$num = 100;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i-1)*$num;
$result = Db::table('rec_js')->field('id,mykemu')->limit($offet,$num)->select();
$level = config('setsub.levelArr');
foreach ($result as $key => $val) {
$val['mykemu'] = $result = explode(',',$val['mykemu']);
$res = '';
foreach($val['mykemu'] as $k=>$v){
$res .= $level[$v];
}
Db::table('rec_js')->where('id','=',$val['id'])->update(['mykemu'=>$res]);
}
}
echo ok;die;
}
/*
* 修改rec_zhejiang_majors表将classify中文转换成数字
* */
public function updateCollegeType(){
$result = Db::table('rec_zhejiang_schs')->field('id,classify')->select();
$cate = config('setsub.cateArr');
foreach ($result as $key => $val) {
$cateid = $cate[$val['classify']];
Db::table('rec_zhejiang_schs')->where('id','=',$val['id'])->update(['collegeType'=>$cateid]);
}
}
/*
* 最低分和位次迁移
* */
public function updateMajor(){
$result = Db::table('rec_wen_major')->select();
foreach($result as $key=>$val){
$res = json_decode($val['professions']);
foreach($res as $k => $v){
$data['rec_id'] = $result[$key]['rec_id'];
$data['title'] = $v->alias;
$data['code'] = $v->majorCode;
$resRank = json_decode($v->extended);
$data['lowestRank'] = $resRank[0]->ls;
$data['minScore'] = $resRank[0]->ms;
$data['scoreLineYear'] = $v->scoreLineYear;
$data['year'] = $v->year;
$data['enterNum'] = $v->enterNum;
$data['planNum'] = $v->planNum;
$data['probability'] = $v->probability;
Db::table('rec_majors')->insert($data);
}
}
}
/*
* 新高考
* 数据迁移yzy_zj_major_score 新增字段 sch_cate rankOfCn
* */
public function updateMajorScore(){
$result = Db::table('yzy_zj_major_score')->field("id,sch_id")->select();
$cate = config('setsub.cateName');
foreach ($result as $key =>$val){
$resClass = Db::table('yzy_school')->field('cate_id')->where('sch_id','=',$val['sch_id'])->find();
$cateName = $cate[$resClass['cate_id']];
$resRank = Db::table("yzy_school_exts")->field('rankOfCn')->where("sch_id",'=',$val['sch_id'])->find();
Db::table('yzy_zj_major_score')->where([['id','=',$val['id']],['sch_id','=',$val['sch_id']]])->update(['classify'=>$cateName,'rankOfCn'=>$resRank['rankOfCn']]);
}
}
/*
* school表排名更新
* */
public function updateSchoolRank(){
$result = Db::table('yzy_school')->field("id,sch_id")->select();
foreach ($result as $key =>$val){
$resRank = Db::table("yzy_school_exts")->field('rankOfCn')->where("sch_id",'=',$val['sch_id'])->find();
Db::table('yzy_school')->where([['id','=',$val['id']],['sch_id','=',$val['sch_id']]])->update(['rankOfCn'=>$resRank['rankOfCn']]);
}
}
/*
* 新高考
* 专业数量同步到院校表
* */
public function majorCountToSch(){
set_time_limit(0);
$count = Db::table('rec_zhejiang_majors')->count();
$num = 100;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i - 1) * $num;
$result = Db::table('rec_zhejiang_schs')->field("id")->limit($offet, $num)->select();
foreach ($result as $key => $val) {
$resMajor = Db::table('rec_zhejiang_schs_majors')->field('professions')->where('rec_id', '=', $val['id'])->find();
$count = count(json_decode($resMajor['professions']));
Db::table('rec_zhejiang_schs')->where('id', '=', $val['id'])->update(['majorNum' => $count]);
}
}
}
/*
* 院校logo地址查询
* */
public function getSchoolLogos(){
$result = Db::table('yzy_school')->field("sch_id,logo")->select();
return api_return('ok',$result);
}
/*
* 新高考院校表同步is_yldx,is_ylxk
* */
public function ylxkyldxToNewSch(){
set_time_limit(0);
$count = Db::table('rec_zhejiang_schs')->count();
$num = 1000;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i - 1) * $num;
$result = Db::table('rec_zhejiang_schs')->field("id,collegeId")->limit($offet, $num)->select();
foreach ($result as $key => $val) {
$resSch = Db::table('yzy_school')->field("is_yldx,is_ylxk")->where('sch_id', '=', $val['collegeId'])->find();
Db::table('rec_zhejiang_schs')->where([['id', '=', $val['id']], ['collegeId', '=', $val['collegeId']]])->update(['is_yldx' => $resSch['is_yldx'], 'is_ylxk' => $resSch['is_ylxk']]);
}
}
}
/*
* 新高考專業表同步is_yldx,is_ylxk
* */
public function ylxkyldxToNewSchMajor(){
ignore_user_abort(true);
ini_set('max_execution_time', '0');
set_time_limit(0);
$id = Cache::store('redis')->get('NewSchMajorID');
if(empty($id)){
$id = 3589199;
}
$count = Db::table('rec_zhejiang_majors')->where('id','>',$id)->count();
$num = 1000;//每次导入条数
$limit = ceil($count/$num);
for($i=1;$i<=$limit;$i++) {
$offet = ($i - 1) * $num;
$result = Db::table('rec_zhejiang_majors')->field("id,collegeId")->where('id','>',$id)->limit($offet, $num)->select();
try {
foreach ($result as $key => $val) {
$resSch = Db::table('yzy_school')->field("is_yldx,is_ylxk")->where('sch_id', '=', $val['collegeId'])->find();
Db::table('rec_zhejiang_majors')->where([['id', '=', $val['id']], ['collegeId', '=', $val['collegeId']]])->update(['is_yldx' => $resSch['is_yldx'], 'is_ylxk' => $resSch['is_ylxk']]);
Cache::store('redis')->set("NewSchMajorID",$val['id'],72000);
}
}catch (\Exception $exception){
\think\facade\Log::error($exception);
}
}
}
}

View File

@@ -0,0 +1,91 @@
<?php
/**
* 系统服务
* Class System
* @package app\admin\controller
*/
namespace app\admin\controller;
use app\admin\controller\AdminController;
use app\admin\model\SysNode;
use app\admin\service\NodeService;
use think\facade\Cache;
class System extends AdminController {
/**
* 刷新缓存
*/
public function refresh() {
if (app('cache')->clear()) {
echo '缓存刷新成功';
return msg_success('缓存刷新成功!');
} else {
echo '缓存刷新失败';
return msg_error('缓存刷新失败!');
}
}
/**
* 刷新节点
*/
public function refresh_node() {
if (!$this->request->isPost()) {
//get ajax 访问
if ($this->request->get('type') == 'ajax') {
$node_list = NodeService::refreshNode();
if (!empty($node_list)) return __success('节点刷新成功!');
return __error('暂无数据变化');
}
$modules = NodeService::getFolders(env('app_path'));
$module_list = [];
foreach ($modules as $k => $val) {
$node = model('node')->where(['node' => $val, 'type' => 1])->find();
!empty($node) ? $module_list[$k] = ['module' => $val, 'title' => $node['title']] : $module_list[$k] = ['module' => $val, 'title' => ''];
$val == 'admin' ? $module_list[$k]['is_checked'] = true : $module_list[$k]['is_checked'] = false;
}
$basic_data = [
'title' => '系统节点列表',
'module_list' => $module_list,
];
return $this->fetch('', $basic_data);
} else {
$post = $this->request->post();
if (empty($post['module'])) return __error('请选中需要刷新节点的模块!');
$node_list = NodeService::refreshNode($post['module']);
if ($node_list['code'] == 0) {
//清空菜单缓存
clear_menu();
return __success($node_list['msg']);
} else {
return __error($node_list['msg']);
}
}
}
/**
* 清除失效节点
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function clear_node() {
if (!$this->request->isPost()) {
$basic_data = [
'title' => '清除失效节点',
];
return $this->fetch('', $basic_data);
} else {
$clean = NodeService::cleanNode();
if ($clean['code'] == 0) {
return __success($clean['msg']);
} else {
return __error($clean['msg']);
}
}
}
}

View File

@@ -0,0 +1,161 @@
<?php
// +----------------------------------------------------------------------
// | Think.Admin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/Think.Admin
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\service\ModelService;
use app\common\service\CurlService;
use app\common\service\NodeService;
use think\Db;
use think\Controller;
use think\facade\Env;
use think\facade\Cache;
class Test extends Controller {
/**
* 测试
*/
public function index() {
return $this->fetch('');
}
public function upload() {
$data = [
'cur' => 'complete',
'url' => time() . '.jpg',
];
return json($data);
}
public function test() {
$redis = Cache::handler();
while (true) {
try {
$value = $redis->LPOP('click');
if (!$value) {
break;
}
echo $value . '<br>';
} catch (Exception $e) {
return $e->getMessage();
}
}
}
public function url() {
redirect('install/index/index');
exit;
}
public function curl() {
$test = curl()->Get('http://www.baidu.com');
dump($test);
}
public function add() {
$insert = [
'username' => 'admin',
'password' => password('bsafe2016'),
'id' => '1',
'auth_id' => '[]',
'status' => 1,
];
Db::startTrans();
try {
Db::table('system_user')->insert($insert);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
}
/**
* 生成数据库配置文件
* @return array
*/
private function mkDatabase($data = []) {
$code = <<<INFO
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
return [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => '{$data['hostname']}',
// 数据库名
'database' => '{$data['database']}',
// 用户名
'username' => '{$data['username']}',
// 密码
'password' => '{$data['password']}',
// 端口
'hostport' => '{$data['hostport']}',
// 连接dsn
'dsn' => '',
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
'charset' => 'utf8',
// 数据库表前缀
'prefix' => '{$data['prefix']}',
// 数据库调试模式
'debug' => false,
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
'deploy' => 0,
// 数据库读写是否分离 主从式有效
'rw_separate' => false,
// 读写分离后 主服务器数量
'master_num' => 1,
// 指定从服务器序号
'slave_no' => '',
// 是否严格检查字段是否存在
'fields_strict' => false,
// 数据集返回类型
'resultset_type' => 'array',
// 自动写入时间戳字段
'auto_timestamp' => false,
// 时间字段取出后的默认时间格式
'datetime_format' => 'Y-m-d H:i:s',
// 是否需要进行SQL性能分析
'sql_explain' => false,
// Builder类
'builder' => '',
// Query类
'query' => '\\think\\db\\Query',
];
INFO;
file_put_contents(Env::get('config_path') . 'database1.php', $code);
// 判断写入是否成功
$config = include Env::get('config_path') . 'database1.php';
if (empty($config['database']) || $config['database'] != $data['database']) {
return $this->error('[application/database.php]数据库配置写入失败!');
exit;
}
}
}

View File

@@ -0,0 +1,258 @@
<?php
/*
* 管理员信息管理
* */
namespace app\admin\controller;
use app\admin\controller\AdminController;
use think\facade\Cache;
class User extends AdminController {
/**
* User模型对象
*/
protected $model = null;
/**
* 初始化
* User constructor.
*/
public function __construct() {
parent::__construct();
$this->model = model('user');
}
/**
* 管理员列表
*/
public function index() {
//ajax访问
if ($this->request->get('type') == 'ajax') {
$page = $this->request->get('page', 1);
$limit = $this->request->get('limit', 10);
$search = (array)$this->request->get('search', []);
return json($this->model->userList($page, $limit, $search));
}
//基础数据
$basic_data = [
'title' => '管理员列表',
'data' => '',
];
return $this->fetch('', $basic_data);
}
/**
* 添加管理员
* @return mixed
*/
public function add() {
if (!$this->request->isPost()) {
//基础数据
$basic_data = [
'title' => '添加管理员',
'auth' => model('auth')->getList(),
];
$this->assign($basic_data);
return $this->form();
} else {
$post = $this->request->post();
!isset($post['auth_id']) && $post['auth_id'] = [];
//数组转json
$post['auth_id'] = json_encode($post['auth_id']);
//验证数据
$validate = $this->validate($post, 'app\admin\validate\User.add');
if (true !== $validate) return __error($validate);
//保存数据,返回结果
$post['password'] = password($post['password']);
return $this->model->add($post);
}
}
/**
* 修改管理员信息
* @return mixed|string|\think\response\Json
*/
public function edit() {
if (!$this->request->isPost()) {
//查找所需修改用户
$user = $this->model->where('id', $this->request->get('id'))->find();
if (empty($user)) return msg_error('暂无数据,请重新刷新页面!');
$auth = model('auth')->getList()->toArray();
$auth_id = json_decode($user['auth_id'], true);
foreach ($auth as $k => $val) {
$is_checked = false;
foreach ($auth_id as $k_1) $val['id'] == $k_1 && $is_checked = true;
$auth[$k]['is_checked'] = $is_checked;
}
//基础数据
$basic_data = [
'title' => '修改管理员信息',
'user' => $user->hidden(['password']),
'auth' => $auth,
];
$this->assign($basic_data);
return $this->form();
} else {
$post = $this->request->post();
!isset($post['auth_id']) && $post['auth_id'] = [];
//数组转json
$post['auth_id'] = json_encode($post['auth_id']);
//验证数据
$validate = $this->validate($post, 'app\admin\validate\User.edit');
if (true !== $validate) return __error($validate);
//清空菜单缓存
clear_menu();
//保存数据,返回结果
return $this->model->edit($post);
}
}
/**
* 表单模板
* @return mixed
*/
protected function form() {
return $this->fetch('form');
}
/**
* 管理员的删除
* @return \think\response\Json
*/
public function del() {
$get = $this->request->get();
//验证数据
if (!is_array($get['id'])) {
$validate = $this->validate($get, 'app\admin\validate\User.del');
if (true !== $validate) return __error($validate);
}
//执行删除操作
if (!is_array($get['id'])) {
$del = $this->model->where('id', $get['id'])->update(['is_deleted' => 1]);
} else {
$del = $this->model->whereIn('id', $get['id'])->update(['is_deleted' => 1]);
}
if ($del >= 1) {
//清空菜单缓存
clear_menu();
return __success('删除成功!');
} else {
return __error('数据有误,请刷新重试!');
}
}
/**
* 修改用户密码
* @return mixed|string|\think\response\Json
*/
public function edit_password() {
if (!$this->request->isPost()) {
if (empty($this->request->get('id'))) return msg_error('暂无用户信息!');
$where_user = [
'id' => $this->request->get('id'),
'is_deleted' => 0,
];
$user = $this->model->where($where_user)->field('id, username')->find();
if (empty($user)) return msg_error('暂无用户信息,请关闭页面刷新重试!');
$basic_data = [
'title' => '修改管理员密码',
'user' => $user,
];
return $this->fetch('', $basic_data);
} else {
$post = $this->request->post();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\User.edit_password');
if (true !== $validate) return __error($validate);
//修改密码数据
return $this->model->editPassword($post);
}
}
/**
* 更改管理员状态
* @return \think\response\Json
*/
public function status() {
$get = $this->request->get();
//验证数据
$validate = $this->validate($get, 'app\admin\validate\User.status');
if (true !== $validate) return __error($validate);
//判断管理员状态
$status = $this->model->where('id', $get['id'])->value('status');
$status == 1 ? list($msg, $status) = ['禁用成功', $status = 0] : list($msg, $status) = ['启用成功', $status = 1];
//执行更新操作操作
$update = $this->model->where('id', $get['id'])->update(['status' => $status]);
//清空菜单缓存
clear_menu();
if ($update >= 1) return __success($msg);
return __error('数据有误,请刷新重试!');
}
/**
* 修改自己的信息
* @return mixed|string|\think\response\Json
*/
public function edit_self() {
if (!$this->request->isPost()) {
//查找所需修改用户
$user = $this->model->where('id', $this->user['id'])->find();
if (empty($user)) return msg_error('暂无数据,请重新刷新页面!');
//基础数据
$basic_data = [
'title' => '修改管理员信息',
'user' => $user->hidden(['password']),
];
$this->assign($basic_data);
return $this->fetch('form_self');
} else {
$post = $this->request->post();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\User.editSelf');
if (true !== $validate) return __error($validate);
//清空菜单缓存
clear_menu();
//保存数据,返回结果
return $this->model->editSelf($post);
}
}
}

View File

@@ -0,0 +1 @@
44e9deb2-eea3-4463-8100-5169958e89b1

View File

@@ -0,0 +1,58 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/1
* Time: 1:10
*/
namespace app\admin\controller\api;
use app\admin\controller\AdminController;
use think\facade\Cache;
/**
* 后台公共接口
* Class Common
* @package app\api\controller\admin
*/
class Common extends AdminController {
/**
* 获取菜单接口
*/
public function getMenu() {
$SysInfo = Cache::get('SysInfo');
if (!isset($SysInfo['AdminModuleName'])) {
return __error('后台绑定模块名数据有误,请刷新缓存或修改数据库配置!');
}
$this->redirect(url("{$SysInfo['AdminModuleName']}.php\api.menu\getMenu"));
}
/**
* 打开图片上传窗口
* @return \think\response\Json
*/
public function uploadIamge($type = 'one') {
$SysInfo = Cache::get('SysInfo');
if (!isset($SysInfo['AdminModuleName'])) {
return __error('后台绑定模块名数据有误,请刷新缓存或修改数据库配置!');
}
$this->redirect(url("{$SysInfo['AdminModuleName']}.php\\tool.upload\image") . "?type=" . $type);
}
/**
* 后台刷新缓存接口
* @return \think\response\Json
*/
public function clearCache() {
if (app('cache')->clear()) {
return __success('缓存刷新成功!');
} else {
return __error('缓存刷新失败!');
}
}
}

View File

@@ -0,0 +1,62 @@
<?php
/*
* 菜单控制接口
* */
namespace app\admin\controller\api;
use app\admin\controller\AdminController;
use think\facade\Cache;
class Menu extends AdminController
{
/**
* 根据权限规则生成菜单栏数据
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getMenu()
{
if (!empty(Cache::tag('menu')->get(session('user.id') . '_AdminMenu'))) {
return json(Cache::get(session('user.id') . '_AdminMenu'));
} else {
$menu_list = \app\admin\model\Menu::getMenuApi();
Cache::tag('menu')->set(session('user.id') . '_AdminMenu', $menu_list, 86400);
return json($menu_list);
}
}
/**
* 获取顶部菜单栏
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getNav()
{
if (!empty(Cache::tag('menu')->get(session('user.id') . '_AdminMenu'))) {
$menu_list = Cache::get(session('user.id') . '_AdminMenu');
} else {
$menu_list = \app\admin\model\Menu::getMenuApi();
Cache::tag('menu')->set(session('user.id') . '_AdminMenu', $menu_list, 86400);
}
$memu_id_list = [];
foreach ($menu_list as $key => $val) {
$menu_id = explode("66ysx_", $key);
isset($menu_id[1]) && $memu_id_list[] = $menu_id[1];
}
$nav = model('menu')->whereIn('id', $memu_id_list)->field('id, title, icon')
->order([
'sort' => 'asc',
'create_at' => 'asc',
])->select();
foreach ($nav as $key => $val) {
(strpos($nav[$key]['icon'], 'fa-') !== false) ? $nav[$key]['icon_type'] = true : $nav[$key]['icon_type'] = false;
}
return $nav;
}
}

View File

@@ -0,0 +1,66 @@
<?php
/*
* 系统节点接口
* */
namespace app\admin\controller\api;
use app\admin\controller\AdminController;
class Node extends AdminController {
/**
* 获取对应角色的节点数据
* @param $id
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getNodeTree($id) {
$list = [];
$module = model('node')->where(['type' => 1, 'is_auth' => 1])->order(['node' => 'asc'])->select();
foreach ($module as $k => $val) {
$list[$k] = [
'title' => $this->__biuldGetNodeTree($val['node'], $val['title']),
'value' => $val['id'],
'data' => [],
];
$is_checked = model('auth_node')->where(['auth' => $id, 'node' => $val['id']])->find();
!empty($is_checked) && $list[$k]['checked'] = true;
$data_1 = model('node')->where([['type', '=', 2], ['is_auth', '=', 1], ['node', 'LIKE', "{$val['node']}/%"]])->select();
foreach ($data_1 as $k_1 => $val_1) {
$list[$k]['data'][$k_1] = [
'title' => $this->__biuldGetNodeTree($val_1['node'], $val_1['title']),
'value' => $val_1['id'],
'data' => [],
];
$is_checked_1 = model('auth_node')->where(['auth' => $id, 'node' => $val_1['id']])->find();
!empty($is_checked_1) && $list[$k]['data'][$k_1]['checked'] = true;
$data_2 = model('node')->where([['type', '=', 3], ['is_auth', '=', 1], ['node', 'LIKE', "{$val_1['node']}/%"]])->select();
foreach ($data_2 as $k_2 => $val_2) {
$list[$k]['data'][$k_1]['data'][$k_2] = [
'title' => $this->__biuldGetNodeTree($val_2['node'], $val_2['title']),
'value' => $val_2['id'],
'data' => [],
];
$is_checked_2 = model('auth_node')->where(['auth' => $id, 'node' => $val_2['id']])->find();
!empty($is_checked_2) && $list[$k]['data'][$k_1]['data'][$k_2]['checked'] = true;
}
}
}
return json($list);
}
/**
* 组合数据
* @param $node
* @param $title
* @return string
*/
protected function __biuldGetNodeTree($node, $title) {
if (empty($title)) return $node;
else return $title . '【' . $node . '】';
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* 后台上传通用接口
* Class Upload
* @package app\admin\controller\api
*/
namespace app\admin\controller\api;
use app\admin\controller\AdminController;
use app\admin\service\QiniuService;
use think\Db;
class Upload extends AdminController {
/**
* 编辑器多图片上传
* @return \think\response\Json
*/
public function image() {
$files = request()->file();
if (is_array($files)) {
foreach ($files as $vo) {
$info = $vo->move('../public/static/uploads');
if ($info) {
$url[] = '/static/uploads/' . date('Ymd') . '/' . $info->getFilename();
} else {
return json(['code' => 1, 'msg' => $vo->getError()]);
}
}
} else {
$info = $files->move('../public/static/uploads');
if ($info) {
$url[] = '/static/uploads/' . date('Ymd') . '/' . $info->getFilename();
} else {
return json(['code' => 1, 'msg' => $files->getError()]);
}
}
//判断是否使用七牛云上传
$file_type = Db::name('SystemConfig')->where(['name' => 'FileType', 'group' => 'file'])->value('value');
if ($file_type == 2) {
foreach ($url as &$vo) {
$vo = QiniuService::upload($vo);
}
}
return json(['code' => 0, 'msg' => '上传成功!', 'url' => $url]);
}
}

View File

@@ -0,0 +1,17 @@
<?php
/**
* 欢迎页接口
* Class Welcome
* @package app\admin\controller\api
*/
namespace app\admin\controller\api;
use app\admin\controller\AdminController;
class Welcome extends AdminController {
}

View File

@@ -0,0 +1 @@
abd2f604-0e26-4a3e-ae75-60639c9df448

View File

@@ -0,0 +1,86 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/24
* Time: 15:05
*/
namespace app\admin\controller\custom;
use app\admin\controller\AdminController;
class Message extends AdminController
{
/**
* User模型对象
*/
protected $model = null;
/**
* 初始化
* User constructor.
*/
public function __construct() {
parent::__construct();
$this->model = new \app\admin\model\costom\Message;
}
/**
* 留言建议列表
*/
public function index() {
//ajax访问
if ($this->request->get('type') == 'ajax') {
$page = $this->request->get('page', 1);
$limit = $this->request->get('limit', 10);
$search = (array)$this->request->get('search', []);
return json($this->model->messageList($page, $limit, $search));
}
$basic_data = [
'title' => '留言建议列表',
'data' => '',
];
return $this->fetch('', $basic_data);
}
/**
* 留言回复
* @return mixed|string|\think\response\Json
*/
public function reply() {
if (!$this->request->isPost()) {
//查找所需修改的数据
$data = $this->model->where('id', $this->request->get('id'))->find();
if($data['img1']){
$data['img1'] = config('secure.mpic_url'). $data['img1'];
}
if($data['img2']){
$data['img2'] = config('secure.mpic_url'). $data['img2'];
}
if (empty($data)) return msg_error('暂无数据,请重新刷新页面!');
//基础数据
$basic_data = [
'title' => '工单回复',
'result' => $data,
];
return $this->fetch('form', $basic_data);
} else {
$post = $this->request->post();
$post['reply_time'] = time();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\custom\Message.reply');
if (true !== $validate) return __error($validate);
//保存数据,返回结果
return $this->model->reply($post);
}
}
}

View File

@@ -0,0 +1,130 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/24
* Time: 11:25
*/
namespace app\admin\controller\custom;
use app\admin\controller\AdminController;
use think\Db;
use app\admin\model\costom\Order as OrderModel;
class Order extends AdminController
{
/**
* User模型对象
*/
protected $model = null;
/**
* 初始化
* User constructor.
*/
public function __construct() {
parent::__construct();
$this->model = new \app\admin\model\costom\Order;
}
/**
* 订单列表
*/
public function index() {
//ajax访问
if ($this->request->get('type') == 'ajax') {
$page = $this->request->get('page', 1);
$limit = $this->request->get('limit', 10);
$search = (array)$this->request->get('search', []);
return json($this->model->orderList($page, $limit, $search));
}
//获取配置表的省份数据
$resProvince = config('province.province');
//基础数据
$basic_data = [
'title' => '订单列表',
'resProvince' => $resProvince,
'data' => '',
];
return $this->fetch('', $basic_data);
}
/*
* 订单详情
* */
public function details(){
//订单商品列表
if ($this->request->get('type') == 'ajax') {
$id = $this->request->get('user_id');
$result = Db::table('orders')->where('user_id','=',$id)->limit(30)->select();
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
//获取配置权限名称
$vipNameArr = config('product.vipName');
foreach($result as $key => $val){
$result[$key]['vipName'] = $vipNameArr[$val['vip']];
$result[$key]['add_time'] = date('Y-m-d H:i:s',$val['add_time']);
if($val['pay_time']){
$result[$key]['pay_time'] = date('Y-m-d H:i:s',$val['pay_time']);
}
$val['wenli'] = $val['wenli'] = config('setSub.subTypeName')[$val['wenli']];
//拼接用户信息
$result[$key]['userInfo'] = $val['province_title']."_".$val['score']."_".$val['wenli']."_".$val['mykemustr'];
}
$list = [
'code' => 0,
'msg' => $msg,
'data' => $result
];
return json($list);
}
$id = $this->request->get('id',0);
$basic_data = [
'title' => '订单详情列表',
'data' => '',
'user_id' => $id
];
$this->assign($basic_data);
return $this->fetch('custom/student/details');
}
/*
* 订单退款
* */
public function refundOrder(){
$post = $this->request->post();
$validate = $this->validate($post, 'app\admin\validate\custom\Student.refundOrder');
if (true !== $validate){
$list = [
'code' => 0,
'msg' => $validate
];
return $list;
exit;
};
$result = OrderModel::orderRefund($post);
if($result){
$list = [
'code' => 1,
'msg' => '退款成功!'
];
}else{
$list = [
'code' => 2,
'msg' => '退款失败!'
];
}
return $list;
}
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/25
* Time: 15:09
*/
namespace app\admin\controller\custom;
use app\admin\controller\AdminController;
use think\Db;
class Proscore extends AdminController
{
/**
* 默认模型对象
*/
protected $model = null;
/**
* 初始化
* User constructor.
*/
public function __construct() {
parent::__construct();
$this->model = new \app\admin\model\costom\Proscore();
}
/**
* 省控分數列表
* @return mixed|\think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index() {
if (!$this->request->isPost()) {
if ($this->request->get('type') == 'ajax') {
$page = $this->request->get('page', 1);
$limit = $this->request->get('limit', 10);
$search = (array)$this->request->get('search', []);
return json($this->model->getList($page, $limit, $search));
}
//获取配置表的省份数据
$resProvince = config('province.province');
//基础数据
$basic_data = [
'title' => '省控分数列表',
'resProvince' => $resProvince,
'data' => '',
];
return $this->fetch('', $basic_data);
}
}
/**
* 添加
* @return mixed
*/
public function add() {
if (!$this->request->isPost()) {
$province_list = config('province.province');
$basic_data = [
'province_list' => $province_list,
'title' => '添加',
];
return $this->fetch('form', $basic_data);
} else {
$post = $this->request->post();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\custom\Proscore.add');
if (true !== $validate) return __error($validate);
//保存数据,返回结果
return $this->model->addData($post);
}
}
/**
* 修改
* @return mixed|string|\think\response\Json
*/
public function edit() {
if (!$this->request->isPost()) {
$province_list = config('province.province');
//查找所需修改的数据
$data = $this->model->where('id', $this->request->get('id'))->find();
if (empty($data)) return msg_error('暂无数据,请重新刷新页面!');
//基础数据
$basic_data = [
'title' => '修改信息',
'res' => $data,
'province_list'=> $province_list
];
return $this->fetch('form', $basic_data);
} else {
$post = $this->request->post();
//验证数据
$validate = $this->validate($post, 'app\admin\validate\custom\Proscore.edit');
if (true !== $validate) return __error($validate);
//保存数据,返回结果
return $this->model->editData($post);
}
}
/**
* 删除
* @return \think\response\Json
*/
public function del() {
$get = $this->request->get();
//验证数据
if (!is_array($get['id'])) {
$validate = $this->validate($get, 'app\admin\validate\custom\Proscore.del');
if (true !== $validate) return __error($validate);
}
//执行删除操作
return $this->model->delData($get['id'], true);
}
}

View File

@@ -0,0 +1,132 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/23
* Time: 8:53
*/
namespace app\admin\controller\custom;
use app\admin\controller\AdminController;
use think\Db;
use app\admin\model\costom\Order;
class Student extends AdminController
{
/**
* User模型对象
*/
protected $model = null;
/**
* 初始化
* User constructor.
*/
public function __construct() {
parent::__construct();
$this->model = new \app\admin\model\costom\User;
}
/**
* 用戶列表
*/
public function index() {
//ajax访问
if ($this->request->get('type') == 'ajax') {
$page = $this->request->get('page', 1);
$limit = $this->request->get('limit', 10);
$search = (array)$this->request->get('search', []);
return json($this->model->userList($page, $limit, $search));
}
//获取配置表的省份数据
$resProvince = config('province.province');
//基础数据
$basic_data = [
'title' => '用戶列表',
'resProvince' => $resProvince,
'data' => '',
];
return $this->fetch('', $basic_data);
}
/*
* 订单详情
* */
public function details(){
//订单商品列表
if ($this->request->get('type') == 'ajax') {
$id = $this->request->get('user_id');
$result = Db::table('orders')->where('user_id','=',$id)->limit(30)->select();
empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!';
//获取配置权限名称
$vipNameArr = config('product.vipName');
foreach($result as $key => $val){
$result[$key]['vipName'] = $vipNameArr[$val['vip']];
$result[$key]['add_time'] = date('Y-m-d H:i:s',$val['add_time']);
if($val['pay_time']){
$result[$key]['pay_time'] = date('Y-m-d H:i:s',$val['pay_time']);
}
$val['wenli'] = $val['wenli'] = config('setSub.subTypeName')[$val['wenli']];
//拼接用户信息
$result[$key]['userInfo'] = $val['province_title']."_".$val['score']."_".$val['wenli']."_".$val['mykemustr'];
}
$list = [
'code' => 0,
'msg' => $msg,
'data' => $result
];
return json($list);
}
$id = $this->request->get('id',0);
$basic_data = [
'title' => '订单详情列表',
'data' => '',
'user_id' => $id
];
$this->assign($basic_data);
return $this->fetch();
}
/*
* 订单退款
* */
public function refundOrder(){
$post = $this->request->post();
$validate = $this->validate($post, 'app\admin\validate\custom\Student.refundOrder');
if (true !== $validate){
$list = [
'code' => 0,
'msg' => $validate
];
return $list;
exit;
};
$result = Order::orderRefund($post);
if($result){
$list = [
'code' => 1,
'msg' => '退款成功!'
];
}else{
$list = [
'code' => 2,
'msg' => '退款失败!'
];
}
return $list;
}
}

View File

@@ -0,0 +1 @@
69df9137-96a1-4de5-a0ee-79d0e3e649fd

View File

@@ -0,0 +1,38 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/15
* Time: 21:51
*/
namespace app\admin\controller\tool;
use app\admin\controller\AdminController;
/**
* 图标管理
* Class Icon
* @package app\admin\controller
*/
class Icon extends AdminController {
/**
* 图标列表
*/
public function index() {
$basic_data = [
'title' => '图标列表',
];
return $this->fetch('', $basic_data);
}
public function fa(){
$basic_data = [
'title' => 'fa图标列表',
];
return $this->fetch('', $basic_data);
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/15
* Time: 21:58
*/
namespace app\admin\controller\tool;
use app\admin\controller\AdminController;
/**
* 上传图片插件
* Class Upload
* @package app\admin\controller\tool
*/
class Upload extends AdminController {
/**
* 上传图片
* @param string $type ['multi','one']
* @return mixed
*/
public function image($type = 'one') {
return $this->fetch('', ['type' => $type]);
}
}