更新目录结构

This commit is contained in:
molong committed 2023-10-21 21:18:46 +08:00
1 parent 664295167d
commit 1153b13299
298 files changed
+1326 -467

No files matched your search

+8 -69
View File
@@ -1,79 +1,18 @@
![](https://www.thinkphp.cn/uploads/images/20230630/300c856765af4d8ae758c503185f8739.png) # sentos
ThinkPHP 8.0
===============
## 特性 ## 特性
* 基于PHP`8.0+`重构 - 后端基于thinkphp8 开发
* 升级`PSR`依赖 - 前端基于vue + aiox + vuex + electron + element plus开发
* 依赖`think-orm`3.0版本
* `6.0`/`6.1`无缝升级
> ThinkPHP8.0的运行环境要求PHP8.0.0+
现在开始,你可以使用官方提供的[ThinkChat](https://chat.topthink.com/),让你在学习ThinkPHP的旅途中享受私人AI助理服务!
![](https://www.topthink.com/uploads/assistant/20230630/4d1a3f0ad2958b49bb8189b7ef824cb0.png)
## 文档
[完全开发手册](https://doc.thinkphp.cn)
## 服务
ThinkPHP生态服务由[顶想云](https://www.topthink.com)(TOPThink Cloud)提供,为生态提供专业的开发者服务和价值之选。
## 赞助
全新的[赞助计划](https://www.thinkphp.cn/sponsor)可以让你通过我们的网站、手册、欢迎页及GIT仓库获得巨大曝光,同时提升企业的品牌声誉,也更好保障ThinkPHP的可持续发展。
[![](https://www.thinkphp.cn/uploads/images/20230630/48396092a0515886a3da6bd268131c8f.png)](http://github.crmeb.net/u/TPSY)
[![](https://www.thinkphp.cn/uploads/images/20230630/a12bd248beee0e7491dd0f79dc4dd5e9.png)](https://www.thinkphp.cn/sponsor)
[![](https://www.thinkphp.cn/uploads/images/20230630/e7f48d909d41dd5ebaf4a5aa982d0455.png)](https://www.thinkphp.cn/sponsor)
## 安装 ## 安装
~~~ - 后端安装
composer create-project topthink/think tp
~~~
启动服务 系统根目录下执行命令,安装后端扩展
~~~ > composer install
cd tp
php think run
~~~
然后就可以在浏览器中访问 配置好数据库链接,并导入数据库文件
~~~ - 前端安装
http://localhost:8000
~~~
如果需要更新框架使用
~~~
composer update topthink/framework
~~~
## 命名规范
`ThinkPHP`遵循PSR-2命名规范和PSR-4自动加载规范。
## 参与开发
直接提交PR或者Issue即可
## 版权信息
ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
本项目包含的第三方源码和二进制文件之版权信息另行标注。
版权所有Copyright © 2006-2023 by ThinkPHP (http://thinkphp.cn) All rights reserved。
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
更多细节参阅 [LICENSE.txt](LICENSE.txt)
+15
View File
@@ -9,8 +9,23 @@
namespace app\controller; namespace app\controller;
use app\BaseController; use app\BaseController;
use think\facade\Cache;
use app\services\system\DictionaryService;
class Base extends BaseController{ class Base extends BaseController{
public $data = ['code' => 1, 'data' => '', 'message' => '']; public $data = ['code' => 1, 'data' => '', 'message' => ''];
public function initialize(){
$this->cacheData($this->request); //缓存基础数据
}
protected function cacheData($request) {
$diction = Cache::get('diction');
if(!$diction){
$service = app()->make(DictionaryService::class);
$data = $service->getDictionaryAll();
Cache::set('diction', $data);
}
}
} }
+30 -1
View File
@@ -8,7 +8,10 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller; namespace app\controller;
use think\facade\Console;
use app\controller\Base; use app\controller\Base;
use Dcat\EasyExcel\Excel;
use app\services\FieldService;
/** /**
* @title 首页 * @title 首页
@@ -24,11 +27,37 @@ class Index extends Base{
if(request()->isAjax()){ if(request()->isAjax()){
return ['code' => 1, 'data' => 'SentOS']; return ['code' => 1, 'data' => 'SentOS'];
}else{ }else{
return `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible"content="IE=edge"><meta name="viewport"content="width=device-width, initial-scale=1"><title>SentOS</title><style>html,body{background-color:#fff;color:#3c4042;font-family:'Raleway',sans-serif;font-weight:100;height:80vh;margin:0}.top{text-align:right;line-height:35px;padding:0 20px}.top a{color:#333333;padding:0 10px}.full-height{height:90vh}.flex-center{align-items:center;display:flex;justify-content:center}.position-ref{position:relative}.top-right{position:absolute;right:10px;top:18px}.content{text-align:center}.title{font-size:84px}.links>a{color:#3c4042;padding:0 25px;font-size:12px;font-weight:600;letter-spacing:.1rem;text-decoration:none;text-transform:uppercase}.m-b-md{margin-bottom:30px}</style></head><body><div class="flex-center position-ref full-height"><div class="content"><div class="title m-b-md">SentOS</div><div class="links"></div></div></div><div style="text-align: center; font-size: 12px;"><p><a href="https://beian.miit.gov.cn/"target="_blank"style="color: #333333; text-decoration: none;">赣ICP备13006622号-1</a></p><p>技术支持:<a href="https://www.tensent.cn"target="_blank"style="color: #333333; text-decoration: none;">腾速科技</a></p></div></body></html>`; return view(`<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible"content="IE=edge"><meta name="viewport"content="width=device-width, initial-scale=1"><title>SentOS</title><style>html,body{background-color:#fff;color:#3c4042;font-family:'Raleway',sans-serif;font-weight:100;height:80vh;margin:0}.top{text-align:right;line-height:35px;padding:0 20px}.top a{color:#333333;padding:0 10px}.full-height{height:90vh}.flex-center{align-items:center;display:flex;justify-content:center}.position-ref{position:relative}.top-right{position:absolute;right:10px;top:18px}.content{text-align:center}.title{font-size:84px}.links>a{color:#3c4042;padding:0 25px;font-size:12px;font-weight:600;letter-spacing:.1rem;text-decoration:none;text-transform:uppercase}.m-b-md{margin-bottom:30px}</style></head><body><div class="flex-center position-ref full-height"><div class="content"><div class="title m-b-md">SentOS</div><div class="links"></div></div></div><div style="text-align: center; font-size: 12px;"><p><a href="https://beian.miit.gov.cn/"target="_blank"style="color: #333333; text-decoration: none;">赣ICP备13006622号-1</a></p><p>技术支持:<a href="https://www.tensent.cn"target="_blank"style="color: #333333; text-decoration: none;">腾速科技</a></p></div></body></html>`);
} }
} }
public function test(){ public function test(){
// $output = Console::call('worker:gateway');
$service = app()->make(\app\services\wechat\OauthService::class);
print_r($service->getQrCode($this->request)) ;
// return $output->fetch();
// $array = [
// ['id' => 1, 'name' => 'Brakus', 'email' => 'treutel@eg.com', 'created_at' => '...'],
// ];
// Excel::export($array)->download('users.xlsx');
// $area = \think\facade\Db::name('areas')->select();
// $save = [];
// foreach($area as $val){
// $save[] = ['title' => $val['area'], 'code' => $val['area_id'], 'parent_id' => $val['city_id'], 'first' => '', 'create_time' => time(), 'update_time' => time()];
// }
// \think\facade\Db::name('area')->insertAll($save);
}
/**
* @title 导出模版
*
* @return void
*/
public function template(FieldService $service){
$model = $this->request->param('model');
$array = [];
$headings = array_flip($service->getFields($model));
return Excel::export($array)->headings($headings)->download($model . time() . '.xlsx');
} }
public function miss(){ public function miss(){
@@ -6,7 +6,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\auth; namespace app\controller\admin\auth;
use think\facade\Request; use think\facade\Request;
use app\model\auth\Departments; use app\model\auth\Departments;
@@ -6,7 +6,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\auth; namespace app\controller\admin\auth;
use app\controller\Base; use app\controller\Base;
use app\services\auth\AuthService; use app\services\auth\AuthService;
@@ -6,7 +6,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\auth; namespace app\controller\admin\auth;
use app\controller\Base; use app\controller\Base;
use app\services\auth\RoleService; use app\services\auth\RoleService;
@@ -27,6 +27,24 @@ class Role extends Base{
return $this->data; return $this->data;
} }
/**
* @title 角色添加
* @time 2019年12月11日
* @param $id
* @param Request $request
* @return Array
*/
public function add(RoleService $service) {
try {
$service->createRole($this->request);
$this->data['code'] = 1;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/** /**
* @title 角色修改 * @title 角色修改
* @time 2019年12月11日 * @time 2019年12月11日
@@ -6,7 +6,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\auth; namespace app\controller\admin\auth;
use app\services\auth\UsersService; use app\services\auth\UsersService;
use app\controller\Base; use app\controller\Base;
+81
View File
@@ -0,0 +1,81 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\controller\admin\operate;
use app\controller\Base;
use app\services\operate\AdsService;
class Ads extends Base{
/**
* @title 广告列表
*
* @param AdsService $service
* @return void
*/
public function index(AdsService $service){
$this->data['data'] = $service->getDataList($this->request);
return $this->data;
}
/**
* @title 添加广告
*
* @param AdsService $service
* @return void
*/
public function add(AdsService $service){
try {
$data = $service->create($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/**
* @title 编辑广告
*
* @param AdsService $service
* @return void
*/
public function edit(AdsService $service){
try {
$data = $service->update($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/**
* @title 删除广告
*
* @param AdsService $service
* @return void
*/
public function delete(AdsService $service){
try {
$data = $service->delete($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
}
+202
View File
@@ -0,0 +1,202 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\controller\admin\operate;
use app\controller\Base;
use app\services\operate\ClientService;
use app\services\operate\ClientMenuService;
use app\services\operate\ClientConfigService;
class Client extends Base{
/**
* @title 客户端列表
*
* @param ClientService $service
* @return void
*/
public function index(ClientService $service){
$this->data['data'] = $service->getDataList($this->request);
return $this->data;
}
/**
* @title 添加客户端
*
* @param ClientService $service
* @return void
*/
public function add(ClientService $service){
try {
$data = $service->create($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/**
* @title 编辑客户端
*
* @param ClientService $service
* @return void
*/
public function edit(ClientService $service){
try {
$data = $service->update($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/**
* @title 删除客户端
*
* @param ClientService $service
* @return void
*/
public function delete(ClientService $service){
try {
$data = $service->delete($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/**
* @title 客户端菜单列表
*
* @param ClientMenuService $service
* @return void
*/
public function menu(ClientMenuService $service){
$this->data['data'] = $service->getDataList($this->request);
return $this->data;
}
/**
* @title 添加客户端菜单
*
* @param ClientMenuService $service
* @return void
*/
public function addmenu(ClientMenuService $service){
try {
$data = $service->create($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/**
* @title 编辑客户端菜单
*
* @param ClientMenuService $service
* @return void
*/
public function editmenu(ClientMenuService $service){
try {
$data = $service->update($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/**
* @title 删除客户端菜单
*
* @param ClientMenuService $service
* @return void
*/
public function delmenu(ClientMenuService $service){
try {
$data = $service->delete($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/**
* @title 添加客户端配置
*
* @param ClientConfigService $service
* @return void
*/
public function addconfig(ClientConfigService $service){
try {
$data = $service->create($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/**
* @title 添加客户端配置
*
* @param ClientConfigService $service
* @return void
*/
public function editconfig(ClientConfigService $service){
try {
$data = $service->update($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
/**
* @title 删除客户端配置
*
* @param ClientConfigService $service
* @return void
*/
public function delconfig(ClientConfigService $service){
try {
$data = $service->delete($this->request);
$this->data['code'] = 1;
$this->data['data'] = $data;
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
}
@@ -6,7 +6,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\system; namespace app\controller\admin\system;
use app\controller\Base; use app\controller\Base;
use app\services\system\DictionaryService; use app\services\system\DictionaryService;
@@ -124,4 +124,10 @@ class Dict extends Base{
$this->data['data'] = $list; $this->data['data'] = $list;
return $this->data; return $this->data;
} }
public function all(DictionaryService $dic){
$list = $dic->getDictionaryAll($this->request);
$this->data['data'] = $list;
return $this->data;
}
} }
@@ -6,7 +6,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\system; namespace app\controller\admin\system;
use app\controller\Base; use app\controller\Base;
use app\validate\File as Files; use app\validate\File as Files;
@@ -6,7 +6,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\system; namespace app\controller\admin\system;
use app\controller\Base; use app\controller\Base;
use app\services\system\ConfigService; use app\services\system\ConfigService;
@@ -6,7 +6,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\system; namespace app\controller\admin\system;
use app\controller\Base; use app\controller\Base;
use app\services\auth\UsersLogService; use app\services\auth\UsersLogService;
@@ -6,7 +6,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\controller\system; namespace app\controller\admin\system;
use app\controller\Base; use app\controller\Base;
use app\services\auth\MenuService; use app\services\auth\MenuService;
+26
View File
@@ -0,0 +1,26 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\controller\api\auth;
use app\controller\Base;
use app\services\wechat\OauthService;
class Index extends Base{
public function wxlogin(OauthService $service){
try {
$this->data['data'] = $service->oauth($this->request);
} catch (\Exception $e) {
$this->data['code'] = 0;
$this->data['message'] = $e->getMessage();
}
return $this->data;
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\controller\api\operate;
use app\controller\Base;
use app\services\operate\AdsService;
class Ads extends Base{
/**
* @title 客户端菜单
*
* @return void
*/
public function detail(AdsService $service){
$this->data['data'] = $service->getAdsDetail($this->request);
return $this->data;
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\controller\api\operate;
use app\controller\Base;
use app\services\operate\ClientService;
class Client extends Base{
/**
* @title 客户端菜单
*
* @return void
*/
public function menu(ClientService $service){
$this->data['data'] = $service->getClientMenu($this->request);
return $this->data;
}
}
-71
View File
@@ -1,71 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\controller\customer;
use app\controller\Base;
use app\services\company\CompanyService;
/**
* @title 企业信息模型
*/
class Company extends Base{
/**
* @title 企业列表
*
* @time 2020年01月09日
* @param CompanyService $service
* @return Array
*/
public function index(CompanyService $service) {
$data = $service->getCompanyList($this->request);
$this->data['data'] = $data;
return $this->data;
}
/**
* @title 企业详情
*
* @time 2020年01月09日
* @param CompanyService $service
* @return Array
*/
public function detail(CompanyService $service) {
$data = $service->getCompanyDetail($this->request);
$this->data['data'] = $data;
return $this->data;
}
/**
* @title 修改企业
*
* @time 2020年01月09日
* @param CompanyService $service
* @return Array
*/
public function edit(CompanyService $service) {
$data = $service->editCompany($this->request);
$this->data['data'] = $data;
return $this->data;
}
/**
* @title 导入企业信息
*
* @param CompanyService $service
* @return void
*/
public function insert(CompanyService $service){
$this->data['data'] = $service->insertCompanyData($this->request);
return $this->data;
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ class AllowCrossDomain{
]; ];
public function __construct(Config $config){ public function __construct(Config $config){
$this->header = array_merge($this->header, $config->get('cross', '')); $this->header = array_merge($this->header, $config->get('cross', []));
} }
/** /**
+47
View File
@@ -0,0 +1,47 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace app\middleware;
use think\App;
use think\Response;
use leruge\exception\JWTTokenNotFoundException;
class ApiCheck{
protected $app;
public function __construct(App $app){
$this->app = $app;
}
/**
* @title 处理请求
*
* @param [type] $request
* @param \Closure $next
* @param [type] $store
* @return void
*/
public function handle($request, \Closure $next, $store = null){
try {
$verify = \leruge\facade\JWT::validate();;
if (true === $verify) {
$student = \leruge\facade\JWT::auth();
if ($student->id) {
// 路由注入
$request->student = $student;
}
return $next($request);
}
} catch (JWTTokenNotFoundException $e) {
return Response::create(['message' => '未登录或登录过期!', 'code' => 2000], 'json', 401);
}
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ class Validate {
if (!$v->check($params)) { if (!$v->check($params)) {
//校验不通过则直接返回错误信息 //校验不通过则直接返回错误信息
$data = array( $data = array(
'msg' => $v->getError(), 'message' => $v->getError(),
'code' => 0, 'code' => 0,
'data' => '', 'data' => '',
'time' => time(), 'time' => time(),
+15 -4
View File
@@ -10,6 +10,7 @@ namespace app\model;
use think\Model; use think\Model;
use think\facade\Config; use think\facade\Config;
use think\facade\Env;
use think\facade\Db; use think\facade\Db;
class BaseModel extends Model{ class BaseModel extends Model{
@@ -18,22 +19,32 @@ class BaseModel extends Model{
$auth = request()->auth(); $auth = request()->auth();
$uid = request()->user['uid']; $uid = request()->user['uid'];
$map = []; $map = [];
if(!in_array($uid, Config::get('auth.admin_root'))){ if($uid != Env::get('admin')){
$subMap = []; $subMap = [];
if($auth['data_range'] == 2){ if($auth['data_range'] == 2){
$subMap[] = ['department_id', 'IN', getDepartmentChild($auth['department_id'])]; $subMap[] = ['department_id', 'IN', getDepartmentChild($auth['department_id'])];
}elseif($auth['data_range'] == 3){ }elseif($auth['data_range'] == 3){
$subMap[] = ['department_id', 'IN', $auth['department_id']]; $subMap[] = ['department_id', 'IN', $auth['department_id']];
}elseif($auth['data_range'] == 4){ }elseif($auth['data_range'] == 4){
$map[] = ['uid', '=', $uid]; $map[] = ['user_id', '=', $uid];
}else{
$m = [['user_id', '=', $uid], ['user_id', '=', 0]];
$query->where(function($q) use($m){
$q->whereOr($m);
});
} }
if(!empty($subMap)){ if(!empty($subMap)){
$subsql = Db::name('users')->where($subMap)->field('uid')->buildSql(); $subsql = Db::name('users')->where($subMap)->field('uid')->buildSql();
$subsql = str_replace(" AS thinkphp) AS T1 )", "", $subsql); $subsql = str_replace(" AS thinkphp) AS T1 )", "", $subsql);
$subsql = str_replace("SELECT T1.* FROM (SELECT thinkphp.*, ROW_NUMBER() OVER ( ORDER BY rand()) AS ROW_NUMBER FROM (", "", $subsql); $subsql = str_replace("SELECT T1.* FROM (SELECT thinkphp.*, ROW_NUMBER() OVER ( ORDER BY rand()) AS ROW_NUMBER FROM (", "", $subsql);
$map[] = ['uid', 'IN', Db::raw($subsql)]; $map[] = ['user_id', 'IN', Db::raw($subsql)];
} }
} }
$query->where($where)->where($map); if(!empty($map)){
$query->where($map);
}
if(!empty($where)){
$query->where($where);
}
} }
} }
-67
View File
@@ -1,67 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model\customer;
use app\model\BaseModel;
use think\model\concern\SoftDelete;
use think\facade\Cache;
class Company extends BaseModel{
use SoftDelete;
protected $deleteTime = 'delete_time';
protected $defaultSoftDelete = 0;
public $insertFieldAlis = [
'企业编号' => ['name' => 'org_code', 'table' => 'company'],
'公司名称' => ['name' => 'name', 'table' => 'company'],
'网址' => ['name' => 'web_site', 'table' => 'company'],
'一级行业' => ['name' => 'industry', 'table' => 'company'],
'二级行业' => ['name' => 'industry_sub', 'table' => 'company'],
'三级行业' => ['name' => 'industry_three', 'table' => 'company'],
'省份' => ['name' => 'province', 'table' => 'company'],
'城市' => ['name' => 'city', 'table' => 'company'],
'区县' => ['name' => 'area', 'table' => 'company'],
'年营业额' => ['name' => 'turnover_text', 'table' => 'company',],
'员工人数' => ['name' => 'staff_num_text', 'table' => 'company'],
'注册资金' => ['name' => 'reg_capital', 'table' => 'company'],
'资金类型' => ['name' => 'reg_capital_type', 'table' => 'company'],
'PC数量' => ['name' => 'pc_num_text', 'table' => 'company'],
'营收规模' => ['name' => 'turnover', 'table' => 'company'],
'社保人数' => ['name' => 'social_insurance', 'table' => 'company'],
'企业性质' => ['name' => 'company_type', 'table' => 'company'],
'是否上市' => ['name' => 'is_ipo_text', 'table' => 'company'],
'融资信息' => ['name' => 'finance_info', 'table' => 'company'],
'企业标签' => ['name' => 'tags', 'table' => 'company'],
'企业状态' => ['name' => 'status', 'table' => 'company'],
'成立时间' => ['name' => 'reg_date', 'table' => 'company'],
'注册地址' => ['name' => 'reg_address', 'table' => 'company'],
'联系人' => ['name' => 'name', 'table' => 'contact'],
'岗位' => ['name' => 'job','table' => 'contact'],
'固定电话' => ['name' => 'phone', 'table' => 'contact'],
'手机号码' => ['name' => 'mobile', 'table' => 'contact'],
'邮箱' => ['name' => 'email', 'table' => 'contact'],
'是否法人' => ['name' => 'is_faren', 'table' => 'contact']
];
public function getAreaTAttr($value, $data){
$text = [$data['province'], $data['city'], $data['area']];
return implode(",", array_filter($text));
}
public function getIndustryTAttr($value, $data){
$text = [$data['industry'], $data['industry_sub'], $data['industry_three']];
return implode(",", array_filter($text));
}
public function contact(){
return $this->hasMany(Contact::class);
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model\operate;
use app\model\BaseModel;
use think\model\concern\SoftDelete;
use think\facade\Cache;
class Ads extends BaseModel{
protected function getStatusTextAttr($value, $data){
$status = ['禁用', '启用'];
return isset($status[$data['status']]) ? $status[$data['status']] : '';
}
public function getPhotoAttr($value, $data){
if($data['photo_list']){
if($data['type'] == 1){
return explode(",", $data['photo_list']);
}else{
return $data['photo_list'];
}
}else{
if($data['type'] == 1){
return [];
}else{
return '';
}
}
}
}
+25
View File
@@ -0,0 +1,25 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\model\operate;
use app\model\BaseModel;
use think\model\concern\SoftDelete;
use think\facade\Cache;
class Client extends BaseModel{
protected function getStatusTextAttr($value, $data){
$status = ['禁用', '启用'];
return isset($status[$data['status']]) ? $status[$data['status']] : '';
}
public function setting(){
return $this->hasMany(ClientConfig::class, 'client_id', 'id');
}
}
@@ -6,9 +6,16 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
use think\facade\Route; namespace app\model\operate;
Route::group('auth', function(){ use app\model\BaseModel;
Route::post('login', 'auth.Index/login'); use think\model\concern\SoftDelete;
Route::get('member', 'auth.Index/member'); use think\facade\Cache;
});
class ClientConfig extends BaseModel{
protected function getStatusTextAttr($value, $data){
$status = ['禁用', '启用'];
return isset($status[$data['status']]) ? $status[$data['status']] : '';
}
}
@@ -6,16 +6,16 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\model\customer; namespace app\model\operate;
use app\model\BaseModel; use app\model\BaseModel;
use think\model\concern\SoftDelete; use think\model\concern\SoftDelete;
use think\facade\Cache;
class Contact extends BaseModel{ class ClientMenu extends BaseModel{
use SoftDelete;
protected $deleteTime = 'delete_time';
protected $defaultSoftDelete = 0;
protected $name = "company_contact";
protected function getStatusTextAttr($value, $data){
$status = ['禁用', '启用'];
return isset($status[$data['status']]) ? $status[$data['status']] : '';
}
} }
-1
View File
@@ -16,5 +16,4 @@ class Dictionary extends BaseModel{
use SoftDelete; use SoftDelete;
protected $deleteTime = 'delete_time'; protected $deleteTime = 'delete_time';
protected $defaultSoftDelete = 0; protected $defaultSoftDelete = 0;
} }
+41
View File
@@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services;
class FieldService{
public function getFields($model = 'student'){
if(method_exists(new self(), $model)){
return $this->$model();
}else{
return [];
}
}
/**
* @title 学员导入字段
*
* @return void
*/
public function student(){
return ['学生姓名' => 'name', '性别' => 'sex', '电话' => 'mobile', '身份证号码' => 'id_card'];
}
/**
* @title 题库导入字段
*
* @return void
*/
public function exam(){
return [
'题目类型' => 'type_text', '题干' => 'title', '答案' => 'answer', '解析' => 'analysis',
'选项A' => 'A', '选项B' => 'B', '选项C' => 'C', '选项D' => 'D', '选项E' => 'E'
];
}
}
+8 -2
View File
@@ -49,11 +49,11 @@ class RoleService{
} }
$role = Roles::find($id); $role = Roles::find($id);
// 删除权限 // 删除权限
PermissionAccess::where('role_id', '=', $role_id)->delete(); PermissionAccess::where('role_id', '=', $id)->delete();
// 删除部门关联 // 删除部门关联
// $role->detachDepartments(); // $role->detachDepartments();
// 删除用户关联 // 删除用户关联
RolesAccess::where('role_id', '=', $role_id)->delete(); RolesAccess::where('role_id', '=', $id)->delete();
// 删除 // 删除
$role->delete(); $role->delete();
} }
@@ -73,6 +73,7 @@ class RoleService{
(new PermissionAccess())->saveAll($save); (new PermissionAccess())->saveAll($save);
return true; return true;
} }
public function updateRoleAuth($request){ public function updateRoleAuth($request){
$role_id = $request->param('role_id', ''); $role_id = $request->param('role_id', '');
$data_range = $request->param('data_range', ''); $data_range = $request->param('data_range', '');
@@ -87,6 +88,11 @@ class RoleService{
return $role->save($save); return $role->save($save);
} }
public function createRole($request){
$data = $request->param();
return Roles::create($data);
}
public function updateRole($request){ public function updateRole($request){
$data = $request->param(); $data = $request->param();
return Roles::update($data); return Roles::update($data);
-119
View File
@@ -1,119 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\company;
use app\model\customer\Company;
use app\model\customer\Contact;
/**
* Undocumented class
*/
class CompanyService {
/**
* @title 获取企业列表
*
* @param [type] $request
* @return void
*/
public function getCompanyList($request) {
$param = $request->param();
$map = [];
if (isset($param['name']) && $param['name']) {
$map[] = ['name', 'LIKE', '%' . $param['name'] . '%'];
}
if (isset($param['org_code']) && $param['org_code']) {
$map[] = ['org_code', '=', $param['org_code']];
}
$list = Company::with(['contact'])->where($map)->order('id desc')->paginate($request->pageConfig);
return $list->append(['area_t', 'industry_t']);
}
/**
* @title 获取企业详情
*
* @param [type] $request
* @return void
*/
public function getCompanyDetail($request) {
$param = $request->param();
if (!isset($param['id'])) {
return [];
}
$map = [];
$map[] = ['id', '=', $param['id']];
$data = Company::with(['contact'])->where($map)->find();
return $data->append(['area_t', 'industry_t']);
}
/**
* @title 导入数据
*
* @return void
*/
public function insertCompanyData($request) {
$data = $request->post('data');
$company = new Company();
$contactM = new Contact();
$resultData = [];
foreach ($data as $k => $item) {
$info = [];
if (!is_array($item)) {
continue;
}
foreach ($item as $key => $value) {
if (isset($company->insertFieldAlis[$key])) {
$info[$company->insertFieldAlis[$key]['table']][$company->insertFieldAlis[$key]['name']] = trim($value);
}
}
$info['company']['uid'] = $info['contact']['uid'] = request()->user['uid'];
if (isset($info['company']) && isset($info['company']['name'])) {
$customer = $company->where('name', '=', trim($info['company']['name']))->find();
$company_id = isset($customer['id']) ? $customer['id'] : 0;
if (!$company_id) {
$info['company']['turnover'] = '';
$info['company']['staff_num'] = '';
$info['company']['come_from'] = '';
$info['company']['company_type'] = '';
$info['company']['pc_count'] = '';
$customer = Company::create($info['company']);
$company_id = $customer->id;
} else {
$save_coustomer = $info['company'];
if (!empty($save_coustomer)) {
$save_coustomer['id'] = $company_id;
$result = $customer->save($save_coustomer);
}
}
if (isset($info['contact']['name'])) {
$map = [];
$map[] = ['name', '=', $info['contact']['name']];
$map[] = ['mobile', '=', isset($info['contact']['mobile']) ? $info['contact']['mobile'] : ''];
$map[] = ['company_id', '=', $company_id];
$contact = $contactM->where($map)->find(); //每次查询重新实例化
$contact_id = isset($contact['id']) ? $contact['id'] : 0;
if (!$contact_id) {
$info['contact']['company_id'] = $company_id;
$res = Contact::create($info['contact']);
$contact_id = $res->id;
} else {
$info['contact']['id'] = $contact_id;
$contact->save($info['contact']);
}
} else {
$contact_id = 0;
}
$resultData[] = ['company_id' => $company_id, 'contact_id' => (int) $contact_id, 'company' => $info['company'], 'contact' => $info['contact']];
}
}
return empty($resultData) ? false : $resultData;
}
}
+81
View File
@@ -0,0 +1,81 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\operate;
use app\model\operate\Ads;
class AdsService{
/**
* @title 获取广告
*
* @param [type] $request
* @return void
*/
public function getDataList($request){
$param = $request->param();
$order = "id desc";
$map = [];
if(isset($param['title']) && $param['title'] != ''){
$map[] = ['title', 'LIKE', '%' . $param['title'] . '%'];
}
if(isset($param['name']) && $param['name'] != ''){
$map[] = ['name', '=', $param['name']];
}
$list = Ads::where($map)->order($order)->append(['status_text', 'photo'])->paginate($request->pageConfig);
return $list;
}
/**
* @title 添加广告
*
* @param [type] $request
* @return void
*/
public function create($request){
$data = $request->param();
$data['user_id'] = $request->user['uid'];
return Ads::create($data);
}
/**
* @title 编辑广告
*
* @param [type] $request
* @return void
*/
public function update($request){
$data = $request->param();
$ads = Ads::find($data['id']);
return $ads->save($data);
}
/**
* @title 删除广告
*
* @param [type] $request
* @return void
*/
public function delete($request){
$id = $request->post('id', 0);
if(!$id){
throw new \think\Exception("非法操作!", 1);
}
return Ads::where('id', $id)->delete();
}
public function getAdsDetail($request){
$name = $request->param('name', '');
return Ads::where('name', $name)->append(['photo'])->find();
}
}
@@ -0,0 +1,75 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\operate;
use app\model\operate\ClientConfig;
class ClientConfigService{
/**
* @title 获取广告
*
* @param [type] $request
* @return void
*/
public function getDataList($request){
$param = $request->param();
$order = "id desc";
$map = [];
if(isset($param['title']) && $param['title'] != ''){
$map[] = ['title', 'LIKE', '%' . $param['title'] . '%'];
}
if(isset($param['name']) && $param['name'] != ''){
$map[] = ['name', '=', $param['name']];
}
$list = ClientConfig::where($map)->order($order)->append(['status_text'])->paginate($request->pageConfig);
return $list;
}
/**
* @title 添加广告
*
* @param [type] $request
* @return void
*/
public function create($request){
$data = $request->param();
return ClientConfig::create($data);
}
/**
* @title 编辑配置
*
* @param [type] $request
* @return void
*/
public function update($request){
$data = $request->param();
$config = ClientConfig::find($data['id']);
$config->save($data);
return $config;
}
/**
* @title 删除配置
*
* @param [type] $request
* @return void
*/
public function delete($request){
$data = $request->param();
$config = ClientConfig::find($data['id']);
return $config->delete();
}
}
@@ -0,0 +1,75 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\operate;
use app\model\operate\ClientMenu;
class ClientMenuService{
/**
* @title 获取广告
*
* @param [type] $request
* @return void
*/
public function getDataList($request){
$param = $request->param();
$order = "id desc";
$map = [];
if(isset($param['title']) && $param['title'] != ''){
$map[] = ['title', 'LIKE', '%' . $param['title'] . '%'];
}
if(isset($param['name']) && $param['name'] != ''){
$map[] = ['name', '=', $param['name']];
}
$list = ClientMenu::where($map)->order($order)->append(['status_text'])->paginate($request->pageConfig);
return $list;
}
/**
* @title 添加广告
*
* @param [type] $request
* @return void
*/
public function create($request){
$data = $request->param();
$data['user_id'] = $request->user['uid'];
return ClientMenu::create($data);
}
/**
* @title 编辑广告
*
* @param [type] $request
* @return void
*/
public function update($request){
$data = $request->param();
$menu = ClientMenu::find($data['id']);
return $client->save($data);
}
/**
* @title 删除配置
*
* @param [type] $request
* @return void
*/
public function delete($request){
$data = $request->param();
$menu = ClientMenu::find($data['id']);
return $menu->delete();
}
}
+91
View File
@@ -0,0 +1,91 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\operate;
use app\model\operate\Client;
class ClientService{
/**
* @title 获取广告
*
* @param [type] $request
* @return void
*/
public function getDataList($request){
$param = $request->param();
$order = "id desc";
$map = [];
if(isset($param['title']) && $param['title'] != ''){
$map[] = ['title', 'LIKE', '%' . $param['title'] . '%'];
}
if(isset($param['name']) && $param['name'] != ''){
$map[] = ['name', '=', $param['name']];
}
$list = Client::with(['setting'])->where($map)->order($order)->append(['status_text'])->paginate($request->pageConfig);
return $list;
}
/**
* @title 添加广告
*
* @param [type] $request
* @return void
*/
public function create($request){
$data = $request->param();
$data['user_id'] = $request->user['uid'];
return Client::create($data);
}
/**
* @title 编辑广告
*
* @param [type] $request
* @return void
*/
public function update($request){
$data = $request->param();
$client = Client::find($data['id']);
return $client->save($data);
}
public function getClientMenu($request){
$param = $request->param();
$list = [];
if(isset($param['type'])){
if($param['type'] == 'home'){
$list = [
['title' => '常考题', 'image' => request()->static() . 'images/icon/5.jpg', 'url' => '/pages/exam/index/index'],
['title' => '模拟考', 'image' => request()->static() . 'images/icon/6.jpg', 'url' => '/pages/exam/index/index'],
['title' => '题库练习', 'image' => request()->static() . 'images/icon/7.jpg', 'url' => '/pages/exam/index/index'],
['title' => '易错题', 'image' => request()->static() . 'images/icon/8.jpg', 'url' => '/pages/exam/index/index'],
['title' => '我的错题', 'image' => request()->static() . 'images/icon/10.png', 'url' => '/pages/exam/my/index', 'desc' => '巩固错题,轻轻松松过考'],
['title' => '我的收藏', 'image' => request()->static() . 'images/icon/9.png', 'url' => '/pages/exam/my/index', 'desc' => '您收藏的题目,都在这里'],
];
}else{
$list = [
['title' => '我的资料', 'icon' => 'profile', 'iconColor' => 'green', 'url' => '/pages/ucenter/profile/index'],
['title' => '我的报名', 'icon' => 'edit', 'iconColor' => 'green', 'url' => '/pages/ucenter/enter/index'],
['title' => '我的记录', 'icon' => 'list', 'iconColor' => 'green', 'url' => '/pages/ucenter/exam/index'],
['title' => '我的订单', 'icon' => 'shop', 'iconColor' => 'green', 'url' => '/pages/ucenter/order/index'],
['title' => '邀请推广', 'icon' => 'qrcode', 'iconColor' => 'green', 'url' => '/pages/ucenter/invite/index'],
['title' => '关于我们', 'icon' => 'info', 'iconColor' => 'green', 'url' => '/pages/ucenter/about/index'],
];
}
}
return $list;
}
}
+14
View File
@@ -30,6 +30,20 @@ class DictionaryService{
$list = Dictionary::where($map)->order('id desc')->paginate($request->pageConfig); $list = Dictionary::where($map)->order('id desc')->paginate($request->pageConfig);
return $list; return $list;
} }
/**
* @title 所有字典数据
*
* @return void
*/
public function getDictionaryAll(){
$list = Dictionary::where([])->select();
$data = [];
foreach($list as $value){
$data[$value['dic_type']][] = $value->toArray();
}
return $data;
}
/** /**
* @title 获取字典明细 * @title 获取字典明细
* *
+60
View File
@@ -0,0 +1,60 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\wechat;
use EasyWeChat\Factory;
use think\facade\Config;
use app\model\student\Student;
use app\model\student\Wechat;
class OauthService{
public function oauth($request){
$code = $request->post('code');
$config = Config::get('wechat.miniapp');
$app = Factory::miniProgram($config);
try {
//获取openid
$session_code = $app->auth->session($code);
$wechat = Wechat::where('openid', '=', $session_code['openid'])->findOrEmpty();
if($wechat->isEmpty()){
$userInfo = $app->encryptor->decryptData($session_code['session_key'], $request->post('iv'), $request->post('encrypted'));
$data = [
'headimgurl' => $userInfo['avatarUrl'],
'nickname' => $userInfo['nickName'],
'openid'=> $userInfo['openId'],
'sex' => $userInfo['gender'],
'city' => $userInfo['city'],
'country' => $userInfo['country'],
'province' => $userInfo['province'],
'language' => $userInfo['language']
];
$wechat = Wechat::create($data);
}
if($wechat['uid'] > 0){
$wechat['users'] = Student::with(['enter'])->visible(['name', 'mobile', 'sex', 'address', 'id', 'id_card', 'invite_id', 'exam_num', 'incorrect_num', 'point'])->find($wechat['uid'])->append(['token']);
}
return $wechat;
} catch (\Exception $e) {
throw new \think\Exception($e->getMessage(), 100);
}
}
public function getQrCode($request){
$config = Config::get('wechat.miniapp');
$app = Factory::miniProgram($config);
$res = $app->url_link->generate([]);
return $res;
}
}
+4 -3
View File
@@ -13,13 +13,14 @@ use think\Validate;
class File extends Validate{ class File extends Validate{
protected $rule = [ protected $rule = [
'avatar' => 'fileSize:102400|fileExt:jpg,png', 'avatar' => 'fileSize:1048576|fileExt:jpg,png',
'image' => 'fileSize:204800|fileExt:jpg,jpeg,png,webp', 'image' => 'fileSize:1048576 * 2|fileExt:jpg,jpeg,png,webp',
'file' => 'fileSize:1024 * 1000|fileExt:doc,xls,zip,rar' 'file' => 'fileSize:1048576 * 5|fileExt:doc,xls,zip,rar'
]; ];
protected $message = [ protected $message = [
'avatar.fileSize' => '图片不大于1M', 'avatar.fileSize' => '图片不大于1M',
'avatar.fileExt' => '头像后缀不正确', 'avatar.fileExt' => '头像后缀不正确',
'avatar.image' => '头像尺寸不正确', 'avatar.image' => '头像尺寸不正确',
'image.fileSize' => '图片大小超过允许上传大小'
]; ];
} }
@@ -6,14 +6,14 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\validate\auth; namespace app\validate\admin\auth;
use think\Validate; use think\Validate;
class Index extends Validate{ class Index extends Validate{
protected $rule = [ protected $rule = [
'username' => 'require:id', 'username' => 'require',
'password' => 'require' 'password' => 'require'
]; ];
protected $message = [ protected $message = [
@@ -6,7 +6,7 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn> // | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\validate\auth; namespace app\validate\admin\auth;
use think\Validate; use think\Validate;
+30
View File
@@ -0,0 +1,30 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\validate\api\student;
use think\Validate;
class Enter extends Validate{
protected $rule = [
'category_id' => 'require',
'id_card' => 'require|idCard',
'mobile' => 'require|mobile'
];
protected $message = [
'category_id.require' => '科目必选',
'id_card.require' => '身份证号码必填',
'id_card.idCard' => '身份证号码格式错误',
'mobile.require' => '手机号码必填',
'mobile.mobile' => '手机号码格式错误'
];
protected $scene = [
'add' => ['category_id', 'id_card']
];
}
+36
View File
@@ -0,0 +1,36 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\validate\api\student;
use think\Validate;
class Login extends Validate{
protected $rule = [
'name' => 'require|chsAlpha',
'mobile' => 'require|mobile|unique:student',
'password' => 'require',
'repassword'=>'require|confirm:password'
];
protected $message = [
'password.require' => '登录密码必须',
'mobile.require' => '手机号码必须',
'mobile.mobile' => '手机号码不正确',
'mobile.unique' => '当前手机号码已注册',
'name.require' => '姓名必须',
'name.chsAlpha' => '姓名格式不正确',
'repassword.require' => '确认密码必须',
'repassword.confirm' => '两次密码输入不同'
];
protected $scene = [
'login' => ['name', 'mobile', 'password'],
'register' => ['name', 'mobile', 'password', 'repassword'],
'resetpasswd' => ['name', 'password']
];
}
+31
View File
@@ -0,0 +1,31 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;
Route::rule('/', 'Index/index');
Route::rule('test', 'Index/test');
Route::group('/admin', function(){
Route::rule('auth/user/:action', 'admin.auth.User/:action');
Route::rule('auth/department/:action', 'admin.auth.Department/:action');
Route::rule('auth/role/:action', 'admin.auth.Role/:action');
Route::rule('system/:controller/:action', 'admin.system.:controller/:action');
Route::rule('student/:controller/:action', 'admin.student.:controller/:action');
Route::rule('exam/:controller/:action', 'admin.exam.:controller/:action');
Route::rule('point/:controller/:action', 'admin.point.:controller/:action');
Route::rule('operate/:controller/:action', 'admin.operate.:controller/:action');
})->middleware(['Api', 'Auth']);
Route::group('admin/auth', function(){
Route::post('login', 'admin.auth.Index/login');
})->middleware(['Api']);
Route::miss('index/miss');
+17
View File
@@ -0,0 +1,17 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;
Route::group('/api', function(){
Route::rule('operate/:controller/:action', 'api.operate.:controller/:action')->middleware(['ApiAuth']);
})->middleware(['Api']);
Route::miss('index/miss');
+1 -12
View File
@@ -10,15 +10,4 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
use think\facade\Route; use think\facade\Route;
Route::rule('/', 'Index/index'); Route::rule('template', 'index/template');
Route::rule('test', 'Index/test');
Route::group('/', function(){
Route::rule('system/:controller/:action', 'system.:controller/:action');
Route::rule('auth/user/:action', 'auth.User/:action');
Route::rule('auth/department/:action', 'auth.Department/:action');
Route::rule('auth/role/:action', 'auth.Role/:action');
Route::rule('customer/company/:action', 'customer.Company/:action');
})->middleware([\app\middleware\Check::class], 'api');
Route::miss('index/miss');
+9 -23
View File
@@ -1,24 +1,10 @@
.DS_Store
node_modules node_modules
/dist out/
logs/
# local env files run/
.env.local .idea/
.env.*.local package-lock.json
data/
# Log files .vscode/launch.json
npm-debug.log* public/electron/
yarn-debug.log* pnpm-lock.yaml
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
/package-lock.json
File renamed without changes.
File renamed without changes.
File renamed without changes.
+24
View File
@@ -0,0 +1,24 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
/package-lock.json
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+74
View File
@@ -0,0 +1,74 @@
{
"name": "scui",
"version": "1.6.6",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build --report",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@element-plus/icons-vue": "2.0.6",
"@tinymce/tinymce-vue": "5.0.0",
"axios": "0.27.2",
"codemirror": "5.65.5",
"core-js": "3.24.1",
"cropperjs": "1.5.12",
"crypto-js": "4.1.1",
"echarts": "5.3.3",
"element-plus": "2.2.12",
"nprogress": "0.2.0",
"qrcodejs2": "0.0.2",
"sortablejs": "1.15.0",
"tinymce": "6.1.2",
"vue": "3.2.37",
"vue-i18n": "9.2.2",
"vue-router": "4.1.3",
"vuedraggable": "4.0.3",
"vuex": "4.0.2",
"xgplayer": "2.31.7",
"xgplayer-hls": "2.5.2",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@babel/core": "7.18.9",
"@babel/eslint-parser": "7.18.9",
"@vue/cli-plugin-babel": "5.0.8",
"@vue/cli-plugin-eslint": "5.0.8",
"@vue/cli-service": "5.0.8",
"eslint": "8.21.0",
"eslint-plugin-vue": "9.3.0",
"sass": "1.37.5",
"sass-loader": "10.1.1"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"globals": {
"APP_CONFIG": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser",
"requireConfigFile": false
},
"rules": {
"indent": 0,
"no-tabs": 0,
"no-mixed-spaces-and-tabs": 0,
"vue/no-unused-components": 0,
"vue/multi-word-component-names": 0
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 298 files, more files were not shown because too many files have changed in this diff. Show more