Forráskód Böngészése

Weenier utc项目部署 0623

wesmiler 3 éve
szülő
commit
a69b02c207
43 módosított fájl, 1150 hozzáadás és 1989 törlés
  1. 122 122
      app/Exports/Export.php
  2. 16 3
      app/Helpers/common.php
  3. 12 1
      app/Helpers/function.php
  4. 9 10
      app/Http/Controllers/ItemCateController.php
  5. 94 0
      app/Http/Controllers/Api/LoginController.php
  6. 29 0
      app/Http/Controllers/Api/TestController.php
  7. 81 0
      app/Http/Controllers/Api/UploadController.php
  8. 254 0
      app/Http/Controllers/Api/webApp.php
  9. 0 2
      app/Http/Controllers/BaseController.php
  10. 0 52
      app/Http/Controllers/Demo3Controller.php
  11. 0 50
      app/Http/Controllers/GenerateController.php
  12. 0 49
      app/Http/Controllers/ItemController.php
  13. 0 91
      app/Http/Controllers/LevelController.php
  14. 0 36
      app/Http/Controllers/LinkController.php
  15. 3 1
      app/Http/Kernel.php
  16. 3 0
      app/Http/Middleware/UserLogin.php
  17. 69 0
      app/Http/Middleware/WebLogin.php
  18. 56 0
      app/Http/Validator/BaseValidator.php
  19. 58 0
      app/Http/Validator/MemberValidator.php
  20. 0 46
      app/Models/Demo3Model.php
  21. 0 25
      app/Models/DeptModel.php
  22. 0 25
      app/Models/DictModel.php
  23. 0 25
      app/Models/DictTypeModel.php
  24. 0 51
      app/Models/LinkModel.php
  25. 0 25
      app/Models/PositionModel.php
  26. 2 15
      app/Models/UserModel.php
  27. 14 8
      app/Providers/AppServiceProvider.php
  28. 1 1
      app/Providers/RouteServiceProvider.php
  29. 25 0
      app/Services/BaseService.php
  30. 12 11
      app/Http/Controllers/DictController.php
  31. 0 128
      app/Services/Demo3Service.php
  32. 0 65
      app/Services/DictService.php
  33. 116 0
      app/Services/EmailService.php
  34. 0 646
      app/Services/GenerateService.php
  35. 0 89
      app/Services/ItemCateService.php
  36. 0 96
      app/Services/ItemService.php
  37. 0 57
      app/Services/LayoutDescService.php
  38. 0 59
      app/Services/LayoutService.php
  39. 0 53
      app/Services/LevelService.php
  40. 0 80
      app/Services/LinkService.php
  41. 0 53
      app/Services/PositionService.php
  42. 148 0
      app/Services/RedisService.php
  43. 26 14
      app/Http/Controllers/DictTypeController.php

+ 122 - 122
app/Exports/Export.php

@@ -1,139 +1,139 @@
-<?pp
+<?php
 
-aespaeApp\Epos;
+namespace App\Exports;
 
-uselluae\Suppo\olleo;
-useaawebse\Eel\oes\oolleo;
-useaawebse\Eel\oes\WEves;
-useaawebse\Eel\oes\Weadgs;
-useaawebse\Eel\Eves\AeSee;
-usePpOe\PpSpeadsee\Syle\Bode;
+use Illuminate\Support\Collection;
+use Maatwebsite\Excel\Concerns\FromCollection;
+use Maatwebsite\Excel\Concerns\WithEvents;
+use Maatwebsite\Excel\Concerns\WithHeadings;
+use Maatwebsite\Excel\Events\AfterSheet;
+use PhpOffice\PhpSpreadsheet\Style\Border;
 
 /**
-*导出Eel类
-*@auolaravel开发员
-*@se2021/4/10
-*lassEpo
-*@paageApp\Epos
-*/
-lassEpopleesoolleo,Weadgs,WEves
+ * 导出Excel类
+ * @author 牧羊人
+ * @since 2021/4/10
+ * Class Export
+ * @package App\Exports
+ */
+class Export implements FromCollection, WithHeadings, WithEvents
 {
-poeed$daa;
-poeed$eadgs;
-poeed$oluWd=[];//设置列宽ey:列value:宽
-poeed$oweg=[];//设置行高ey:行value:高
-poeed$egeells=[];//合并单元格value:A1:8
-poeed$o=[];//设置字体ey:A1:8value:Aal
-poeed$oSze=[];//设置字体大小ey:A1:8value:11
-poeed$bold=[];//设置粗体ey:A1:8value:ue
-poeed$bagoud=[];//设置背景颜色ey:A1:8value:#000
-poeed$veal=[];//设置定位ey:A1:8value:ee
-poeed$seeae;//seele
-poeed$bodes=[];//设置边框颜色ey:A1:8value:#000000
-//设置页面属性时如果无效更改eel格式尝试即可
-//构造函数传值
-publuo__osu($daa,$eadgs,$seeae)
-{
-$s->daa=$daa;
-$s->eadgs=$eadgs;
-$s->seeae=$seeae;
-$s->eaeDaa();
-}
+    protected $data;
+    protected $headings;
+    protected $columnWidth = [];//设置列宽       key:列  value:宽
+    protected $rowHeight = [];  //设置行高       key:行  value:高
+    protected $mergeCells = []; //合并单元格    value:A1:K8
+    protected $font = [];       //设置字体       key:A1:K8  value:Arial
+    protected $fontSize = [];       //设置字体大小       key:A1:K8  value:11
+    protected $bold = [];       //设置粗体       key:A1:K8  value:true
+    protected $background = []; //设置背景颜色    key:A1:K8  value:#F0F0F0F
+    protected $vertical = [];   //设置定位       key:A1:K8  value:center
+    protected $sheetName; //sheet title
+    protected $borders = []; //设置边框颜色  key:A1:K8  value:#000000
+    //设置页面属性时如果无效   更改excel格式尝试即可
+    //构造函数传值
+    public function __construct($data, $headings, $sheetName)
+    {
+        $this->data = $data;
+        $this->headings = $headings;
+        $this->sheetName = $sheetName;
+        $this->createData();
+    }
 
-publuoeadgs():aay
-{
-eu$s->eadgs;
-}
+    public function headings(): array
+    {
+        return $this->headings;
+    }
 
-//数组转集合
-publuoolleo()
-{
-euewolleo($s->daa);
-}
+    //数组转集合
+    public function collection()
+    {
+        return new Collection($this->data);
+    }
 
-//业务代码
-publuoeaeDaa()
-{
-$s->daa=olle($s->daa)->oAay();
-}
+    //业务代码
+    public function createData()
+    {
+        $this->data = collect($this->data)->toArray();
+    }
 
-publuoegseEves():aay
-{
-eu[
-AeSee::lass=>uo(AeSee$eve){
-//设置区域单元格垂直居中
-$eve->see->geDelegae()->geSyle('A1:Z1265')->geAlge()->seVeal('ee');
-//设置区域单元格水平居中
-$eve->see->geDelegae()->geSyle('A1:Z1265')->geAlge()->seozoal('ee');
-//设置列宽
-oea($s->oluWdas$olu=>$wd){
-$eve->see->geDelegae()
-->geoluDeso($olu)
-->seWd($wd);
-}
-//设置行高,$为数据行数
-oea($s->owegas$ow=>$eg){
-$eve->see->geDelegae()
-->geowDeso($ow)
-->seoweg($eg);
-}
+    public function registerEvents(): array
+    {
+        return [
+            AfterSheet::class => function (AfterSheet $event) {
+                //设置区域单元格垂直居中
+                $event->sheet->getDelegate()->getStyle('A1:Z1265')->getAlignment()->setVertical('center');
+                //设置区域单元格水平居中
+                $event->sheet->getDelegate()->getStyle('A1:Z1265')->getAlignment()->setHorizontal('center');
+                //设置列宽
+                foreach ($this->columnWidth as $column => $width) {
+                    $event->sheet->getDelegate()
+                        ->getColumnDimension($column)
+                        ->setWidth($width);
+                }
+                //设置行高,$i为数据行数
+                foreach ($this->rowHeight as $row => $height) {
+                    $event->sheet->getDelegate()
+                        ->getRowDimension($row)
+                        ->setRowHeight($height);
+                }
 
-//设置区域单元格垂直居中
-oea($s->vealas$ego=>$poso){
-$eve->see->geDelegae()
-->geSyle($ego)
-->geAlge()
-->seVeal($poso);
-}
+                //设置区域单元格垂直居中
+                foreach ($this->vertical as $region => $position) {
+                    $event->sheet->getDelegate()
+                        ->getStyle($region)
+                        ->getAlignment()
+                        ->setVertical($position);
+                }
 
-//设置区域单元格字体
-oea($s->oas$ego=>$value){
-$eve->see->geDelegae()
-->geSyle($ego)
-->geo()->seae($value);
-}
-//设置区域单元格字体大小
-oea($s->oSzeas$ego=>$value){
-$eve->see->geDelegae()
-->geSyle($ego)
-->geo()
-->seSze($value);
-}
+                //设置区域单元格字体
+                foreach ($this->font as $region => $value) {
+                    $event->sheet->getDelegate()
+                        ->getStyle($region)
+                        ->getFont()->setName($value);
+                }
+                //设置区域单元格字体大小
+                foreach ($this->fontSize as $region => $value) {
+                    $event->sheet->getDelegate()
+                        ->getStyle($region)
+                        ->getFont()
+                        ->setSize($value);
+                }
 
-//设置区域单元格字体粗体
-oea($s->boldas$ego=>$bool){
-$eve->see->geDelegae()
-->geSyle($ego)
-->geo()
-->seBold($bool);
-}
+                //设置区域单元格字体粗体
+                foreach ($this->bold as $region => $bool) {
+                    $event->sheet->getDelegate()
+                        ->getStyle($region)
+                        ->getFont()
+                        ->setBold($bool);
+                }
 
 
-//设置区域单元格背景颜色
-oea($s->bagoudas$ego=>$e){
-$eve->see->geDelegae()->geSyle($ego)->applyoAay([
-'ll'=>[
-'llype'=>'lea',//线性填充,类似渐变
-'saolo'=>[
-'gb'=>$e//初始颜色
-],
-//结束颜色,如果需要单一背景色,请和初始颜色保持一致
-'edolo'=>[
-'agb'=>$e
-]
-]
-]);
-}
-//设置边框颜色
-oea($s->bodesas$ego=>$e){
-$eve->see->geDelegae()->geSyle($ego)->applyoAay([
-'bodes'=>[
-'allBodes'=>[
-'bodeSyle'=>Bode::BODE_,
-'olo'=>['agb'=>$e],
-],
-],
-                   ]);
+                //设置区域单元格背景颜色
+                foreach ($this->background as $region => $item) {
+                    $event->sheet->getDelegate()->getStyle($region)->applyFromArray([
+                        'fill' => [
+                            'fillType' => 'linear', //线性填充,类似渐变
+                            'startColor' => [
+                                'rgb' => $item //初始颜色
+                            ],
+                            //结束颜色,如果需要单一背景色,请和初始颜色保持一致
+                            'endColor' => [
+                                'argb' => $item
+                            ]
+                        ]
+                    ]);
+                }
+                //设置边框颜色
+                foreach ($this->borders as $region => $item) {
+                    $event->sheet->getDelegate()->getStyle($region)->applyFromArray([
+                        'borders' => [
+                            'allBorders' => [
+                                'borderStyle' => Border::BORDER_THIN,
+                                'color' => ['argb' => $item],
+                            ],
+                        ],
+                    ]);
                 }
                 //合并单元格
                 $event->sheet->getDelegate()->setMergeCells($this->mergeCells);

+ 16 - 3
app/Helpers/common.php

@@ -1060,6 +1060,17 @@ if (!function_exists('copydirs')) {
     }
 }
 
+if(!function_exists('lang')){
+    function lang($msg, $replace=[], $local=''){
+        $local = $local? $local : config('app.locale');
+        $data = __('api.'.$msg, $replace, $local);
+        if(strpos($data,'api',0) !== false){
+            return __($msg, $replace, $local);
+        }
+        return __('api.'.$msg, $replace, $local);
+    }
+}
+
 if (!function_exists('message')) {
 
     /**
@@ -1072,18 +1083,20 @@ if (!function_exists('message')) {
      * @author laravel开发员
      * @date 2019/5/28
      */
-    function message($msg = "操作成功", $success = true, $data = [], $code = 0)
+    function message($msg = "1002", $success = true, $data = [], $code = 0)
     {
-        $result = ['success' => $success, 'msg' => $msg, 'data' => $data];
+        $result = ['success' => $success, 'msg' => lang($msg), 'data' => $data];
         if ($success) {
             $result['code'] = 0;
         } else {
             $result['code'] = $code ? $code : -1;
         }
-        return $result;
+        return json_encode($result, 256);
     }
 }
 
+
+
 if (!function_exists('num2rmb')) {
 
     /**

+ 12 - 1
app/Helpers/function.php

@@ -9,4 +9,15 @@
 // | Author: laravel开发员 <laravel.qq.com>
 // +----------------------------------------------------------------------
 
-// 为方便系统核心模块升级,二次开发中需要用到的公共函数请写在此文件中,不允许修改系统核心公共函数common.php文件
+if (!function_exists('getValidatorError')) {
+    /**
+     * 错误验证
+     * @param $error
+     * @return mixed
+     */
+    function getValidatorError($validator)
+    {
+        $errors = $validator->errors()->all();
+        return isset($errors[0]) ? $errors[0] : 1013;
+    }
+}

+ 9 - 10
app/Http/Controllers/ItemCateController.php

@@ -9,29 +9,28 @@
 // | Author: laravel开发员 <laravel.qq.com>
 // +----------------------------------------------------------------------
 
-namespace App\Http\Controllers;
+namespace App\Http\Controllers\Admin;
 
-
-use App\Services\ItemCateService;
+use App\Services\Common\ActionLogService;
 
 /**
- * 栏目管理-控制器
+ * 行为日志-控制器
  * @author laravel开发员
- * @since 2020/11/11
- * Class ItemCateController
+ * @since 2020/11/12
+ * Class ActionLogController
  * @package App\Http\Controllers
  */
-class ItemCateController extends Backend
+class ActionLogController extends Backend
 {
     /**
      * 构造函数
      * @author laravel开发员
-     * @since 2020/11/11
-     * ItemCateController constructor.
+     * @since 2020/11/12
+     * ActionLogController constructor.
      */
     public function __construct()
     {
         parent::__construct();
-        $this->service = new ItemCateService();
+        $this->service = new ActionLogService();
     }
 }

+ 94 - 0
app/Http/Controllers/Api/LoginController.php

@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use App\Helpers\Jwt;
+use App\Http\Validator\MemberValidator;
+use App\Services\EmailService;
+use App\Services\RedisService;
+use App\Services\SmsService;
+
+/**
+ * 授权登录控制器基类
+ * Class LoginController
+ * @package App\Http\Controllers
+ */
+class LoginController extends webApp
+{
+    /**
+     * 用户登录
+     * @return array
+     */
+    public function login(MemberValidator  $validator){
+        $code = request()->all();
+        if(empty($code)){
+            return message('code参数错误',false);
+        }
+
+        // 授权
+        $openid = isset($this->userInfo['openid'])? $this->userInfo['openid'] : '';
+        $status = isset($this->userInfo['status'])? $this->userInfo['status'] : '';
+        $userId = isset($this->userInfo['id'])? $this->userInfo['id'] : 0;
+        if(empty($this->userInfo) || empty($openid) || $userId<=0){
+            return message('用户授权失败',false);
+        }
+
+        if($status != 1){
+            return message('用户账户已被冻结不可操作',false);
+        }
+
+        // 获取授权TOKEN
+        $jwt = new Jwt('jwt_wx');
+        $token = $jwt->getToken($userId, 3);
+
+        // 结果返回
+        $result = [
+            'access_token' => $token,
+            'info'=> $this->userInfo,
+        ];
+
+        // 用户信息
+        RedisService::set("auths:info:{$userId}", $this->userInfo, 4*24*3600);
+        return message('获取授权成功', true, $result);
+    }
+
+    public function register(MemberValidator  $validator)
+    {
+        $params = request()->all();
+        $params = $validator->check($params, 'register');
+        if(!is_array($params)){
+            return message($params, true);
+        }
+
+
+    }
+
+    /**
+     * 发送验证码
+     * @param MemberValidator $validator
+     * @return array
+     */
+    public function sendmsm(MemberValidator  $validator)
+    {
+        $username = request()->post('username');
+        $check1 = $validator->check(['mobile'=> $username],'mobile');
+        $type = !is_array($check1)? 2 : 1;
+        $check2 = $validator->check(['email'=> $username], 'email');
+        if(!is_array($check1) && !is_array($check2)){
+            return message(!is_array($check1)? $check1 : $check2, true);
+        }
+
+        // 手机短信
+        if($type == 1){
+            if(!SmsService::make()->sendCode($username, 'reg')){
+                return message(SmsService::getError());
+            }
+        }else{
+            if(!EmailService::make()->sendCode($username, 'reg')){
+                return message(EmailService::getError());
+            }
+        }
+
+        return message($type==1? 1012 : 1016, true);
+    }
+}

+ 29 - 0
app/Http/Controllers/Api/TestController.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use App\Services\ConfigService;
+use App\Services\EmailService;
+use App\Services\RedisService;
+use Illuminate\Http\Request;
+
+/**
+ * 测试
+ * Class TestController
+ * @package App\Http\Controllers\Api
+ */
+class TestController extends webApp
+{
+
+    public function changeLang()
+    {
+        session('locale_lang','en');
+        app()->setLocale('en');
+        return message('你好啊');
+    }
+
+    public function setMail()
+    {
+        EmailService::initConfig();
+    }
+}

+ 81 - 0
app/Http/Controllers/Api/UploadController.php

@@ -0,0 +1,81 @@
+<?php
+// +----------------------------------------------------------------------
+// | Laravel框架 [ Laravel ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 Laravel研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: wesmiler <12345678@qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Api;
+
+use Illuminate\Http\Request;
+
+/**
+ * 上传文件-控制器
+ * @since 2020/11/11
+ * Class UploadController
+ * @package App\Http\Controllers
+ */
+class UploadController extends webApp
+{
+
+    /**
+     * 上传图片
+     * @param Request $request 网络请求
+     * @return array
+     * @since 2020/11/11
+     */
+    public function uploadImage(Request $request)
+    {
+
+        // 上传单图统一调取方法
+        $result = upload_image($request, 'file');
+        if (!$result['success']) {
+            return ['url'=> '', 'message'=>$result['msg'], 'error'=> true];
+        }
+
+        // 文件路径
+        $file_path = $result['data']['img_path'];
+        if (!$file_path) {
+            return ['url'=> '', 'message'=>'文件上传失败', 'error'=> true];
+        }
+
+        // 网络域名拼接
+        if ($file_path && strpos($file_path, IMG_URL) === false) {
+            $file_path = IMG_URL . $file_path;
+        }
+
+        // 返回结果
+        return ['url'=> $file_path, 'path'=> $result['data']['img_path'], 'error'=> false];
+    }
+
+    /**
+     * 上传文件(单个上传)
+     * @param Request $request
+     * @since 2020/11/11
+     */
+    public function uploadFile(Request $request)
+    {
+        $result = upload_file($request);
+        if (!$result['success']) {
+            return message(MESSAGE_FAILED, false, $result['msg']);
+        }
+        // 文件路径
+        $file_path = isset($result['data']['file_path'])? $result['data']['file_path'] : '';
+        if (!$file_path) {
+            return message(message("文件上传失败"));
+        }
+
+        // 网络域名拼接
+        if (strpos($file_path, IMG_URL) === false) {
+            $file_path = IMG_URL . $file_path;
+        }
+
+        // 返回结果
+        return message(MESSAGE_OK, true, $file_path);
+    }
+
+}

+ 254 - 0
app/Http/Controllers/Api/webApp.php

@@ -0,0 +1,254 @@
+<?php
+// +----------------------------------------------------------------------
+// | Laravel框架 [ Laravel ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 Laravel研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: wesmiler <12345678@qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Api;
+
+use App\Helpers\Jwt;
+use App\Http\Controllers\BaseController;
+use App\Models\MemberModel;
+use App\Services\ConfigService;
+use App\Services\RedisService;
+use Illuminate\Support\Facades\DB;
+
+/**
+ * 控制器基类
+ * @since 2020/11/10
+ * Class BaseController
+ * @package App\Http\Controllers
+ */
+class webApp extends BaseController
+{
+    // 模型
+    protected $model;
+    // 服务
+    protected $service;
+    // 校验
+    protected $validate;
+    // 登录ID
+    protected $userId = 0;
+    // 登录信息
+    protected $userInfo = [];
+
+    /**
+     * 构造函数
+     * @author wesmiler
+     * @since 2020/11/10
+     * Backend constructor.
+     */
+    public function __construct()
+    {
+        // 初始化分页参数
+        $this->initConfig();
+
+        // 登录检测中间件
+        $this->middleware('web.login');
+
+        // 初始化登录信息
+        $this->middleware(function ($request, $next) {
+            // 请求头信息
+            $token = $request->headers->get('Authorization');
+            $token = str_replace("Bearer ", null, $token);
+
+            if($token == 'app123'){
+                $userId = ConfigService::make()->getConfigByCode('test_uid');
+                $userId = $userId? $userId : 58;
+            }else{
+                // JWT解密token
+                $jwt = new Jwt('jwt_app');
+                $userId = $jwt->verifyToken($token);
+            }
+
+            // 登录验证
+            $userInfo = RedisService::get("stores:auths:info:{$userId}");
+            if(empty($userInfo) && $userId){
+                $this->initLogin($userId);
+            }else{
+                $this->userId = $userId;
+                $this->userInfo = $userInfo;
+            }
+
+            return $next($request);
+        });
+    }
+
+    /**
+     * 初始化配置
+     * @author laravel开发员
+     * @since 2020/11/10
+     */
+    public function initConfig()
+    {
+        // 请求参数
+        $this->param = \request()->input();
+
+        // 分页基础默认值
+        defined('PERPAGE') or define('PERPAGE', isset($this->param['limit']) ? $this->param['limit'] : 20);
+        defined('PAGE') or define('PAGE', isset($this->param['page']) ? $this->param['page'] : 1);
+    }
+
+    /**
+     * 登录验证
+     * @param $userId 用户ID
+     * @return
+     * @author wesmiler
+     * @since 2020/8/31
+     */
+    public function initLogin($userId)
+    {
+        // 登录用户ID
+        $this->userId = $userId;
+
+        // 登录用户信息
+        if ($userId) {
+            $memberModel = new MemberModel();
+            $userInfo = $memberModel->getInfo($this->userId);
+            $this->userInfo = $userInfo;
+            RedisService::set("auths:info:{$userId}", $this->userInfo, 4*24*3600);
+        }
+
+    }
+
+    /**
+     * 初始化请求配置
+     * @since 2020/11/10
+     * @author wesmiler
+     */
+    private function initRequestConfig()
+    {
+        // 定义是否GET请求
+        defined('IS_GET') or define('IS_GET', \request()->isMethod('GET'));
+
+        // 定义是否POST请求
+        defined('IS_POST') or define('IS_POST', \request()->isMethod('POST'));
+
+        // 定义是否AJAX请求
+        defined('IS_AJAX') or define('IS_AJAX', \request()->ajax());
+
+        // 定义是否PAJAX请求
+        defined('IS_PJAX') or define('IS_PJAX', \request()->pjax());
+
+        // 定义是否PUT请求
+        defined('IS_PUT') or define('IS_PUT', \request()->isMethod('PUT'));
+
+        // 定义是否DELETE请求
+        defined('IS_DELETE') or define('IS_DELETE', \request()->isMethod('DELETE'));
+
+        // 请求方式
+        defined('REQUEST_METHOD') or define('REQUEST_METHOD', \request()->method());
+    }
+
+    /**
+     * 初始化系统常量
+     * @author wesmiler
+     * @since 2020/11/10
+     */
+    private function initSystemConst()
+    {
+        // 项目根目录
+        defined('ROOT_PATH') or define('ROOT_PATH', base_path());
+
+        // 文件上传目录
+        defined('ATTACHMENT_PATH') or define('ATTACHMENT_PATH', base_path('public/uploads'));
+
+        // 图片上传目录
+        defined('IMG_PATH') or define('IMG_PATH', base_path('public/uploads/images'));
+
+        // 临时存放目录
+        defined('UPLOAD_TEMP_PATH') or define('UPLOAD_TEMP_PATH', ATTACHMENT_PATH . "/img");
+
+        // 文件存放目录
+        defined('UPLOAD_FILE_PATH') or define('UPLOAD_FILE_PATH', ATTACHMENT_PATH . "/file");
+
+        // cert目录
+        defined('WECHAT_PAY_CERT_PATH') or define('WECHAT_PAY_CERT_PATH', base_path('public/certs'));
+
+        // 定义普通图片域名
+        defined('IMG_URL') or define('IMG_URL', env('IMG_URL'));
+
+        // 数据表前缀
+        defined('DB_PREFIX') or define('DB_PREFIX', DB::connection()->getTablePrefix());
+
+        // 系统全称
+        defined('SITE_NAME') or define('SITE_NAME', env('SITE_NAME'));
+        // 系统简称
+        defined('NICK_NAME') or define('NICK_NAME', env('NICK_NAME'));
+        // 系统版本号
+        defined('VERSION') or define('VERSION', env('VERSION'));
+
+        // 请求参数
+        $this->param = \request()->input();
+
+        // 分页基础默认值
+        defined('PERPAGE') or define('PERPAGE', isset($this->param['limit']) ? $this->param['limit'] : 20);
+        defined('PAGE') or define('PAGE', isset($this->param['page']) ? $this->param['page'] : 1);
+    }
+
+    /**
+     * 获取数据列表
+     * @return mixed
+     * @since 2020/11/11
+     * @author wesmiler
+     */
+    public function index()
+    {
+        $result = $this->service->getList();
+        return $result;
+    }
+
+    /**
+     * 获取数据详情
+     * @return mixed
+     * @since 2020/11/11
+     * @author wesmiler
+     */
+    public function info()
+    {
+        $result = $this->service->info();
+        return $result;
+    }
+
+    /**
+     * 添加或编辑
+     * @return mixed
+     * @since 2020/11/11
+     * @author wesmiler
+     */
+    public function edit()
+    {
+        $result = $this->service->edit();
+        return $result;
+    }
+
+    /**
+     * 删除数据
+     * @return mixed
+     * @since 2020/11/11
+     * @author wesmiler
+     */
+    public function delete()
+    {
+        $result = $this->service->delete();
+        return $result;
+    }
+
+    /**
+     * 设置状态
+     * @return mixed
+     * @since 2020/11/21
+     * @author wesmiler
+     */
+    public function status()
+    {
+        $result = $this->service->status();
+        return $result;
+    }
+
+}

+ 0 - 2
app/Http/Controllers/BaseController.php

@@ -10,8 +10,6 @@
 // +----------------------------------------------------------------------
 
 namespace App\Http\Controllers;
-
-use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 
 /**

+ 0 - 52
app/Http/Controllers/Demo3Controller.php

@@ -1,52 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2020 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Http\Controllers;
-
-
-use App\Services\Demo3Service;
-
-/**
- * 演示管理-控制器
- * @author laravel开发员
- * @since: 2021/04/10
- * Class Demo3Controller
- * @package App\Http\Controllers
- */
-class Demo3Controller extends Backend
-{
-    /**
-     * 构造函数
-     * @param Request $request
-     * @since 2021/04/10
-     * LevelController constructor.
-     * @author laravel开发员
-     */
-    public function __construct()
-    {
-        parent::__construct();
-        $this->service = new Demo3Service();
-    }
-
-
-	/**
-	 * 设置是否VIP
-	 * @return mixed
-	 * @since 2021/04/10
-	 * @author laravel开发员
-	 */
-	public function setIsVip()
-	{
-        $result = $this->service->setIsVip();
-        return $result;
-	}
-
-}

+ 0 - 50
app/Http/Controllers/GenerateController.php

@@ -1,50 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Http\Controllers;
-
-
-use App\Services\GenerateService;
-
-/**
- * 代码生成器-控制器
- * @author laravel开发员
- * @since 2020/11/12
- * Class GenerateController
- * @package App\Http\Middleware
- */
-class GenerateController extends Backend
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/12
-     * GenerateController constructor.
-     */
-    public function __construct()
-    {
-        parent::__construct();
-        $this->service = new GenerateService();
-    }
-
-    /**
-     * 一键生成模块
-     * @return mixed
-     * @since 2020/11/12
-     * @author laravel开发员
-     */
-    public function generate()
-    {
-        $result = $this->service->generate();
-        return $result;
-    }
-
-}

+ 0 - 49
app/Http/Controllers/ItemController.php

@@ -1,49 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Http\Controllers;
-
-use App\Services\ItemService;
-
-/**
- * 站点管理-控制器
- * @author laravel开发员
- * @since 2020/11/11
- * Class ItemController
- * @package App\Http\Controllers
- */
-class ItemController extends Backend
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * ItemController constructor.
-     */
-    public function __construct()
-    {
-        parent::__construct();
-        $this->service = new ItemService();
-    }
-
-    /**
-     * 获取站点列表
-     * @return mixed
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function getItemList()
-    {
-        $result = $this->service->getItemList();
-        return $result;
-    }
-
-}

+ 0 - 91
app/Http/Controllers/LevelController.php

@@ -1,91 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Http\Controllers;
-
-use App\Exports\Export;
-use App\Models\LevelModel;
-use App\Services\LevelService;
-use Maatwebsite\Excel\Facades\Excel;
-
-/**
- * 职级管理-控制器
- * @author laravel开发员
- * @since 2020/11/11
- * Class LevelController
- * @package App\Http\Controllers
- */
-class LevelController extends Backend
-{
-
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * LevelController constructor.
-     */
-    public function __construct()
-    {
-        parent::__construct();
-        $this->model = new LevelModel();
-        $this->service = new LevelService();
-    }
-
-    /**
-     * 获取职级列表
-     * @return mixed
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function getLevelList()
-    {
-        $result = $this->service->getLevelList();
-        return $result;
-    }
-
-    /**
-     * 导出Excel
-     * @author laravel开发员
-     * @since 2021/4/10
-     */
-    public function exportExcel()
-    {
-        // 参数
-        $param = request()->all();
-        // 文件名称
-        $fileName = date('YmdHis') . '.xlsx';
-        // 表格头
-        $header = ['职级ID', '职级名称', '职级状态', '排序'];
-        // 获取数据源
-        $result = $this->model->where("mark", "=", 1)->get()->toArray();
-        $list = [];
-        if (!empty($result)) {
-            foreach ($result as $key => $val) {
-                $data = [];
-                $data['id'] = $val['id'];
-                $data['name'] = $val['name'];
-                $data['status'] = $val['status'] == 1 ? "在用" : "停用";
-                $data['sort'] = $val['sort'];
-                $list[] = $data;
-            }
-        }
-        // 保存文件
-        if (!Excel::store(new Export($list, $header, "职级列表"), "" . $fileName)) {
-            return message(MESSAGE_FAILED, false);
-        }
-        // 移动文件
-        copy(storage_path("app") . "/" . $fileName, UPLOAD_TEMP_PATH . "/" . $fileName);
-        // 下载地址
-        $fileUrl = get_image_url(str_replace(ATTACHMENT_PATH, "", UPLOAD_TEMP_PATH) . "/" . $fileName);
-        return message(MESSAGE_OK, true, $fileUrl);
-    }
-
-}

+ 0 - 36
app/Http/Controllers/LinkController.php

@@ -1,36 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Http\Controllers;
-
-use App\Services\LinkService;
-
-/**
- * 友链管理-控制器
- * @author laravel开发员
- * @since 2020/11/11
- * Class LinkController
- * @package App\Http\Controllers
- */
-class LinkController extends Backend
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * LinkController constructor.
-     */
-    public function __construct()
-    {
-        parent::__construct();
-        $this->service = new LinkService();
-    }
-}

+ 3 - 1
app/Http/Kernel.php

@@ -42,8 +42,9 @@ class Kernel extends HttpKernel
         ],
 
         'api' => [
-            'throttle:api',
+//            'throttle:api',
             \Illuminate\Routing\Middleware\SubstituteBindings::class,
+            \Illuminate\Session\Middleware\StartSession::class,
         ],
     ];
 
@@ -65,5 +66,6 @@ class Kernel extends HttpKernel
         'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
         'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
         'user.login' => \App\Http\Middleware\UserLogin::class,
+        'web.login' => \App\Http\Middleware\WebLogin::class,
     ];
 }

+ 3 - 0
app/Http/Middleware/UserLogin.php

@@ -4,6 +4,7 @@
 namespace App\Http\Middleware;
 
 use App\Helpers\Jwt;
+use App\Services\RedisService;
 use Closure;
 use Illuminate\Auth\Middleware\Authenticate as Middleware;
 
@@ -33,9 +34,11 @@ class UserLogin extends Middleware
             // JWT解密token
             $jwt = new Jwt();
             $userId = $jwt->verifyToken($token);
+
         } else {
             $userId = 0;
         }
+
         if (!$userId && !in_array($controller, $noLoginActs)) {
             // 判断用户未登录就跳转至登录页面
             // 在这里可以定制你想要的返回格式, 亦或者是 JSON 编码格式

+ 69 - 0
app/Http/Middleware/WebLogin.php

@@ -0,0 +1,69 @@
+<?php
+
+
+namespace App\Http\Middleware;
+
+use App\Helpers\Jwt;
+use App\Services\RedisService;
+use App\Services\ConfigService;
+use Closure;
+use Illuminate\Auth\Middleware\Authenticate as Middleware;
+
+class WebLogin extends Middleware
+{
+    /**
+     * 执行句柄
+     * @param \Illuminate\Http\Request $request
+     * @param Closure $next
+     * @param mixed ...$guards
+     * @return mixed
+     * @throws \Illuminate\Auth\AuthenticationException
+     * @since 2020/8/31
+     * @author wesmiler
+     */
+    public function handle($request, Closure $next, ...$guards)
+    {
+        $response = $next($request);
+        $action = app('request')->route()->getAction();
+        $controller = class_basename($action['controller']);
+        list($controller, $action) = explode('@', $controller);
+        $noLoginActs = ['LoginController','TestController','NotifyController','IndexController','TaskController'];
+        $token = $request->headers->get('Authorization');
+        if (strpos($token, 'Bearer ') !== false) {
+            $token = str_replace("Bearer ", null, $token);
+            if($token == 'app123'){
+                $userId = ConfigService::make()->getConfigByCode('test_uid');
+                $userId = $userId? $userId : 0;
+            }else{
+                // JWT解密token
+                $jwt = new Jwt('jwt_app');
+                $userId = $jwt->verifyToken($token);
+            }
+
+        } else {
+            $userId = 0;
+        }
+
+        // 语言本地化,参数预处理
+        $locale = session('locale_lang');
+        if($userId>0){
+            $locale = RedisService::get("stores:locale:lang_{$userId}");
+            $locale = $locale? $locale : session('locale_lang');
+            if($locale){
+                session('locale_lang', $locale);
+                app()->setLocale($locale);
+            }
+        }else if ($locale){
+            app()->setLocale($locale);
+        }
+
+        if (!$userId && !in_array($controller, $noLoginActs)) {
+            // 判断用户未登录就跳转至登录页面
+            // 在这里可以定制你想要的返回格式, 亦或者是 JSON 编码格式
+            return response()->json(message(1004, false, null, 403));
+        }
+
+        //如果已登录则执行正常的请求
+        return $response;
+    }
+}

+ 56 - 0
app/Http/Validator/BaseValidator.php

@@ -0,0 +1,56 @@
+<?php
+namespace App\Http\Validator;
+use Illuminate\Support\Facades\Validator;
+class BaseValidator extends Validator
+{
+    // 当前模型所有验证规则
+    public static $rules = [];
+
+    // 当前模型所有错误提示信息
+    public static $msgs = [];
+
+    // 当前模型所有验证字段
+    public static $fields = [];
+
+    // 当前模型所有验证场景
+    public static $scenes = [];
+
+    public function __construct($rules=[], $msgs=[], $fields=[], $scens=[])
+    {
+        self::$rules = $rules;
+        self::$msgs = $msgs;
+        self::$fields = $fields;
+        self::$scenes = $scens;
+    }
+
+    /**
+     * 验证表单或请求参数
+     * @param $request 请求数据
+     * @param string $scene 场景,为空则全部验证
+     * @return int|mixed
+     */
+    public function checkParams($request, $scene=''){
+        // 存在验证场景
+        if($scene){
+            $sceneFields = isset(self::$scenes[$scene])? self::$scenes[$scene] : [];
+            if(empty($sceneFields)){
+                return 1013;
+            }
+
+            foreach (self::$rules as $key => $rule){
+                if(!in_array($key, $sceneFields)){
+                    unset(self::$rules[$key]);
+                    unset(self::$fields[$key]);
+                }
+            }
+        }
+
+        // 验证数据
+        $validator = Validator::make($request, self::$rules, self::$msgs, self::$fields);
+        if ($validator->fails()) {
+            return getValidatorError($validator);
+        }
+
+        return $request;
+    }
+}

+ 58 - 0
app/Http/Validator/MemberValidator.php

@@ -0,0 +1,58 @@
+<?php
+namespace App\Http\Validator;
+class MemberValidator extends BaseValidator
+{
+    // 当前模型所有验证规则
+    public static $rules = [
+        'id' => 'required',
+        'username' => 'required|username|min:2|max:20',
+        'password' => 'required|max:30',
+        'verify_code' => 'required',
+        'mobile'=> 'required|mobile',
+        'email'=> 'required|email',
+    ];
+
+    // 当前模型所有错误提示信息
+    public static $msgs = [
+        'required' => ':attribute不能为空',
+        'string' => ':attribute必须是字符串',
+        'min' => ':attribute长度不能小于:min位',
+        'max' => ':attribute长度不能大于:max位',
+        'exists' => ':attribute不存在',
+        'rule' => ':attribute格式不正确',
+        'mobile' => ':attribute格式不正确',
+        'email' => ':attribute格式不正确',
+    ];
+
+    // 当前模型所有验证字段
+    public static $fields = [
+        'id' => 'ID',
+        'password' => '登录密码',
+        'username' => '用户名',
+        'verify_code' => '验证码',
+        'mobile' => '手机号码',
+        'email' => '邮箱',
+    ];
+
+    // 当前模型所有验证场景
+    public static $scenes = [
+        'info'=> ['id'],
+        'register'=> ['username','password','verify_code'],
+        'login'=> ['username','password'],
+        'forget'=> ['username','verify_code'],
+        'save'=> ['username','realname','gender'],
+        'mobile'=> ['mobile'],
+        'email'=> ['email'],
+    ];
+
+    /**
+     * 验证
+     * @param $request
+     * @param string $scene
+     * @return int|mixed
+     */
+    public static function check($request, $scene=''){
+        $validator = new BaseValidator(self::$rules, self::$msgs, self::$fields, self::$scenes);
+        return $validator->checkParams($request, $scene);
+    }
+}

+ 0 - 46
app/Models/Demo3Model.php

@@ -1,46 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2020 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Models;
-
-/**
- * 演示-模型
- * @author laravel开发员
- * @since 2021/04/10
- * Class Demo3Model
- * @package App\Models
- */
-class Demo3Model extends BaseModel
-{
-    // 设置数据表
-    protected $table = "demo3";
-
-    /**
-     * 获取记录信息
-     * @param int $id 记录ID
-     * @return array|string
-     * @author laravel开发员
-     * @since: 2021/04/10
-     */
-    public function getInfo($id)
-    {
-        $info = parent::getInfo($id); // TODO: Change the autogenerated stub
-        if ($info) {
-
-            // 头像
-            if ($info['avatar']) {
-                $info['avatar'] = get_image_url($info['avatar']);
-            }
-
-        }
-        return $info;
-    }
-}

+ 0 - 25
app/Models/DeptModel.php

@@ -1,25 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Models;
-
-/**
- * 部门管理-模型
- * @author laravel开发员
- * @since 2020/11/11
- * Class DeptModel
- * @package App\Models
- */
-class DeptModel extends BaseModel
-{
-    // 设置数据表
-    protected $table = 'dept';
-}

+ 0 - 25
app/Models/DictModel.php

@@ -1,25 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Models;
-
-/**
- * 字典-模型
- * @author laravel开发员
- * @since 2020/11/11
- * Class DictModel
- * @package App\Models
- */
-class DictModel extends BaseModel
-{
-    // 设置数据表
-    protected $table = 'dict';
-}

+ 0 - 25
app/Models/DictTypeModel.php

@@ -1,25 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Models;
-
-/**
- * 字典类型-模型
- * @author laravel开发员
- * @since 2020/11/11
- * Class DictTypeModel
- * @package App\Models
- */
-class DictTypeModel extends BaseModel
-{
-    // 设置数据表
-    protected $table = 'dict_type';
-}

+ 0 - 51
app/Models/LinkModel.php

@@ -1,51 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Models;
-
-/**
- * 友链管理-模型
- * @author laravel开发员
- * @since 2020/11/11
- * Class LinkModel
- * @package App\Models
- */
-class LinkModel extends BaseModel
-{
-    // 设置数据表
-    protected $table = 'link';
-
-    /**
-     * 获取记录信息
-     * @param int $id 记录ID
-     * @return array|string
-     * @author laravel开发员
-     * @since 2020/11/11
-     */
-    public function getInfo($id)
-    {
-        $info = parent::getInfo($id); // TODO: Change the autogenerated stub
-        if ($info) {
-            // 友链图片
-            if ($info['image']) {
-                $info['image'] = get_image_url($info['image']);
-            }
-            // 获取栏目名称
-            if ($info['cate_id']) {
-                $itemCateModel = new ItemCateModel();
-                $itemCateName = $itemCateModel->getCateName($info['cate_id'], ">>");
-                $info['item_cate_name'] = $itemCateName;
-            }
-        }
-        return $info;
-    }
-
-}

+ 0 - 25
app/Models/PositionModel.php

@@ -1,25 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Models;
-
-/**
- * 岗位-模型
- * @author laravel开发员
- * @since 2020/11/11
- * Class PositionModel
- * @package App\Models
- */
-class PositionModel extends BaseModel
-{
-    // 设置数据表
-    protected $table = 'position';
-}

+ 2 - 15
app/Models/UserModel.php

@@ -11,10 +11,10 @@
 
 namespace App\Models;
 
-use App\Services\UserRoleService;
+use App\Services\Common\UserRoleService;
 
 /**
- * 员管理-模型
+ * 员管理-模型
  * @author laravel开发员
  * @since 2020/11/10
  * Class AdminModel
@@ -46,19 +46,6 @@ class UserModel extends BaseModel
                 $info['gender_name'] = config('admin.gender_list')[$info['gender']];
             }
 
-            // 岗位
-            if ($info['position_id']) {
-                $positionModel = new PositionModel();
-                $positionInfo = $positionModel->getInfo($info['position_id']);
-                $info['position_name'] = $positionInfo['name'];
-            }
-
-            // 职级
-            if ($info['level_id']) {
-                $levelMod = new LevelModel();
-                $levelInfo = $levelMod->getInfo($info['level_id']);
-                $info['level_name'] = $levelInfo['name'];
-            }
             // 获取用户角色列表
             $userRoleService = new UserRoleService();
             $roleList = $userRoleService->getUserRoleList($id);

+ 14 - 8
app/Providers/AppServiceProvider.php

@@ -11,6 +11,7 @@
 
 namespace App\Providers;
 
+use Illuminate\Support\Facades\Validator;
 use Illuminate\Support\ServiceProvider;
 
 class AppServiceProvider extends ServiceProvider
@@ -30,13 +31,6 @@ class AppServiceProvider extends ServiceProvider
                 $value = is_numeric($replace) ? $replace : "'" . $replace . "'";
                 $sql = preg_replace('/\?/', $value, $sql, 1);
             }
-//            $time = $query->time;
-//            if ($time > 10) {  //when time > 10 print
-//                \Log::debug(var_export(compact(['sql', 'bindings', 'time']), true));
-//            }
-//            \Log::debug(var_export(compact(['sql', 'bindings', 'time']), true));
-//            print_r($sql);
-//            echo $sql;
         });
     }
 
@@ -47,6 +41,18 @@ class AppServiceProvider extends ServiceProvider
      */
     public function boot()
     {
-        //
+        //验证手机号码
+        Validator::extend('mobile', function ($attribute, $value, $parameters, $validator) {
+            // 返回true/false
+            $reg='/^1[3-9]\d{9}$/';
+            return preg_match($reg,$value);
+        });
+
+        Validator::extend('username', function ($attribute, $value, $parameters, $validator) {
+            // 返回true/false
+            $reg='/^1[3-9]\d{9}$/';
+            $reg1='/^[0-9a-zA-Z]+@(([0-9a-zA-Z]+)[.])+[a-z]{2,4}$/i';
+            return preg_match($reg,$value) || preg_match($reg1,$value);
+        });
     }
 }

+ 1 - 1
app/Providers/RouteServiceProvider.php

@@ -39,7 +39,7 @@ class RouteServiceProvider extends ServiceProvider
 
         $this->routes(function () {
             Route::prefix('api')
-                ->middleware('api')
+                ->middleware('api','web.login')
                 ->namespace($this->namespace)
                 ->group(base_path('routes/api.php'));
 

+ 25 - 0
app/Services/BaseService.php

@@ -24,6 +24,31 @@ class BaseService
     protected $model;
     // 验证类
     protected $validate;
+    // 错误信息
+    public $error = '';
+    // 静态对象
+    protected static $instance = null;
+
+    /**
+     * 静态入口
+     * @return static|null
+     */
+    public static function make()
+    {
+        if(!self::$instance){
+            self::$instance = (new static());
+        }
+        return self::$instance;
+    }
+
+    /**
+     * 获得错误信息
+     * @return string
+     */
+    public static function getError()
+    {
+        return self::make()->error;
+    }
 
     /**
      * 获取数据列表

+ 12 - 11
app/Http/Controllers/DictController.php

@@ -9,28 +9,29 @@
 // | Author: laravel开发员 <laravel.qq.com>
 // +----------------------------------------------------------------------
 
-namespace App\Http\Controllers;
+namespace App\Services\Common;
 
-use App\Services\DictService;
+
+use App\Models\ActionLogModel;
+use App\Services\BaseService;
 
 /**
- * 字典管理-控制器
+ * 行为日志-服务类
  * @author laravel开发员
- * @since 2020/11/11
- * Class DictController
- * @package App\Http\Controllers
+ * @since 2020/11/12
+ * Class ActionLogService
+ * @package App\Services\Common
  */
-class DictController extends Backend
+class ActionLogService extends BaseService
 {
     /**
      * 构造函数
      * @author laravel开发员
-     * @since 2020/11/11
-     * DictController constructor.
+     * @since 2020/11/12
+     * ActionLogService constructor.
      */
     public function __construct()
     {
-        parent::__construct();
-        $this->service = new DictService();
+        $this->model = new ActionLogModel();
     }
 }

+ 0 - 128
app/Services/Demo3Service.php

@@ -1,128 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2020 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services;
-
-
-use App\Models\Demo3Model;
-
-/**
- * 演示管理-服务类
- * @author laravel开发员
- * @since: 2021/04/10
- * Class Demo3Service
-* @package App\Services
- */
-class Demo3Service extends BaseService
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2021/04/10
-     * LevelService constructor.
-     */
-    public function __construct()
-    {
-        $this->model = new Demo3Model();
-    }
-
-	/**
-     * 获取数据列表
-     * @return array
-     * @since 2021/04/10
-     * @author laravel开发员
-     */
-    public function getList()
-    {
-        $param = request()->all();
-
-        // 查询条件
-        $map = [];
-
-	    // 职级名称
-        $name = isset($param['name']) ? trim($param['name']) : '';
-        if ($name) {
-            $map[] = ['name', 'like', "%{$name}%"];
-        }
-
-	    // 状态
-        $status = isset($param['status']) ? (int)$param['status'] : 0;
-        if ($status) {
-            $map[] = ['status', '=', $status];
-        }
-
-	    // 类型
-        $type = isset($param['type']) ? (int)$param['type'] : 0;
-        if ($type) {
-            $map[] = ['type', '=', $type];
-        }
-
-	    // 是否VIP
-        $is_vip = isset($param['is_vip']) ? (int)$param['is_vip'] : 0;
-        if ($is_vip) {
-            $map[] = ['is_vip', '=', $is_vip];
-        }
-
-        return parent::getList($map); // TODO: Change the autogenerated stub
-    }
-
-	/**
-     * 添加或编辑
-     * @return array
-     * @since 2021/04/10
-     * @author laravel开发员
-     */
-    public function edit()
-    {
-        // 参数
-        $data = request()->all();
-
-		// 头像处理
-        $avatar = trim($data['avatar']);
-        if (strpos($avatar, "temp")) {
-            $data['avatar'] = save_image($avatar, 'demo3');
-        } else {
-            $data['avatar'] = str_replace(IMG_URL, "", $data['avatar']);
-        }
-
-        return parent::edit($data); // TODO: Change the autogenerated stub
-    }
-
-
-	/**
-     * 设置是否VIP
-	 * @return array
-     * @since 2021/04/10
-	 * @author laravel开发员
-	 */
-    public function setIsVip()
-    {
-		// 参数
-        $data = request()->all();
-        if (!$data['id']) {
-            return message('记录ID不能为空', false);
-        }
-		if (!$data['is_vip']) {
-            return message('记录是否VIP不能为空', false);
-        }
-        $error = '';
-        $item = [
-            'id' => $data['id'],
-            'is_vip' => $data['is_vip']
-        ];
-        $rowId = $this->model->edit($item, $error);
-        if (!$rowId) {
-            return message($error, false);
-        }
-        return message();
-    }
-
-}

+ 0 - 65
app/Services/DictService.php

@@ -1,65 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services;
-
-use App\Models\DictModel;
-
-/**
- * 字典-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class DictService
- * @package App\Services
- */
-class DictService extends BaseService
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * DictService constructor.
-     */
-    public function __construct()
-    {
-        $this->model = new DictModel();
-    }
-
-    /**
-     * 获取字典列表
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function getList()
-    {
-        $param = request()->all();
-        // 查询条件
-        $map = [];
-        // 字典类型ID
-        $dicttypeId = getter($param, "dicttypeId", 0);
-        if ($dicttypeId) {
-            $map[] = ['dicttype_id', '=', $dicttypeId];
-        }
-        // 字典名称
-        $name = getter($param, "name");
-        if ($name) {
-            $map[] = ['name', 'like', "%{$name}%"];
-        }
-        // 字典编码
-        $code = getter($param, 'code');
-        if ($code) {
-            $map[] = ['code', '=', $code];
-        }
-        $list = $this->model->getList($map, [['sort', 'asc']]);
-        return message("操作成功", true, $list);
-    }
-}

+ 116 - 0
app/Services/EmailService.php

@@ -0,0 +1,116 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services;
+
+use App\Models\ConfigModel;
+use Illuminate\Support\Facades\Mail;
+
+/**
+ * 邮件管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class ConfigService
+ * @package App\Services
+ */
+class EmailService extends BaseService
+{
+    /**
+     * 配置参数
+     * @var array
+     */
+    protected $config = [];
+
+    /**
+     * 初始化配置
+     * @return bool
+     */
+    public function __construct()
+    {
+        $config = ConfigService::make()->getConfigByGroup(3);
+        $mail = config('mail');
+        $mailKey = md5(json_encode($mail));
+        $mail['default'] = isset($config['mail_mailer']['value']) && $config['mail_mailer']['value'] ? $config['mail_mailer']['value'] : $mail['default'];
+        $mail['markdown']['paths'] = [resource_path('views/vendor/mail')];
+        $smtp = isset($mail['mailers']['smtp']) ? $mail['mailers']['smtp'] : [];
+        $smtp['host'] = isset($config['mail_host']['value']) && $config['mail_host']['value'] ? $config['mail_host']['value'] : $smtp['host'];
+        $smtp['port'] = isset($config['mail_port']['value']) && $config['mail_port']['value'] ? $config['mail_port']['value'] : $smtp['port'];
+        $smtp['username'] = isset($config['mail_username']['value']) && $config['mail_username']['value'] ? $config['mail_username']['value'] : $smtp['host'];
+        $smtp['password'] = isset($config['mail_password']['value']) && $config['mail_password']['value'] ? $config['mail_password']['value'] : $smtp['password'];
+        $smtp['timeout'] = isset($config['mail_timeout']['value']) && $config['mail_timeout']['value'] ? $config['mail_timeout']['value'] : $smtp['timeout'];
+        if ($mail['default'] != 'smtp') {
+            return false;
+        }
+
+
+        $mail['mailers']['smtp'] = $smtp;
+        $mail['from']['address'] = $smtp['username'];
+        $mail['from']['name'] = 'UTC';
+        $this->config = array_merge($config, $smtp);
+        if ($mailKey != md5(json_encode($mail))) {
+            //file_put_contents(base_path() . '/config/mail.php', '<?php \\n /* 邮箱服务配置 */ \\n return ' . var_export($mail, true) . ';' . '\\n');
+        }
+
+        return true;
+    }
+
+    /**
+     * 发送邮件验证码
+     * @param $email
+     * @param string $scene 场景:默认reg-注册
+     * @return bool
+     */
+    public function sendCode($email, $scene = 'reg')
+    {
+        try {
+            $cacheKey = "stores:codes:email_{$scene}:" . md5($email);
+            // 发送频繁
+            if (RedisService::get($cacheKey . '_lock')) {
+                $this->error = '1014';
+//                return false;
+            }
+
+            $title = isset($this->config['mail_title_' . $scene]['value']) && $this->config['mail_title_' . $scene]['value'] ? $this->config['mail_title_' . $scene]['value'] : "UTC网站注册邮箱验证码";
+            $template = isset($this->config['mail_template_' . $scene]['value']) && $this->config['mail_template_' . $scene]['value'] ? $this->config['mail_template_' . $scene]['value'] : "您的验证码是:{code},5分钟有效期!!!";
+
+            // 生成验证码
+            $code = rand(100000, 999999);
+            $template = str_replace('{code}', $code, $template);
+            // 上锁
+            RedisService::set($cacheKey.'_lock', ['email'=> $email, 'code'=> $code, 'date'=> date('Y-m-d H:i:s')], rand(5, 10));
+            if (Mail::send('emails.index', ['title' => $title,'template'=> $template], function ($message) use ($email, $template) {
+                $to = $email;
+                $message->to($to)->subject($template);
+            })) {
+                RedisService::set($cacheKey, ['email'=> $email, 'code'=> $code, 'date'=> date('Y-m-d H:i:s')], 300);
+                return true;
+            }
+        } catch (\Exception $exception){
+            $this->error = $exception->getMessage();
+            return false;
+        }
+
+        $this->error = '1005';
+        return false;
+    }
+
+    /**
+     * 验证邮件验证码
+     * @param $email
+     * @param string $scene 场景:默认reg-注册
+     * @return bool
+     */
+    public function check($email, $scene = 'reg')
+    {
+        return true;
+    }
+
+}

+ 0 - 646
app/Services/GenerateService.php

@@ -1,646 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services;
-
-use App\Models\MenuModel;
-use Illuminate\Support\Facades\DB;
-
-/**
- * 代码生成器-服务类
- * @author laravel开发员
- * @since 2020/11/12
- * Class GenerateService
- * @package App\Services
- */
-class GenerateService extends BaseService
-{
-
-    /**
-     * 获取数据表
-     * @return array
-     * @since 2020/11/12
-     * @author laravel开发员
-     */
-    public function getList()
-    {
-        $list = DB::select('SHOW TABLE STATUS');
-        $list = json_decode(json_encode($list), true);
-        $list = array_map('array_change_key_case', $list);
-
-        return $message = array(
-            "msg" => '操作成功',
-            "code" => 0,
-            "data" => $list,
-            "count" => 100,
-        );
-    }
-
-    /**
-     * 一键生成模块文件
-     * @return array
-     * @since 2020/11/12
-     * @author laravel开发员
-     */
-    public function generate()
-    {
-        // 参数
-        $param = request()->all();
-        // 数据表名
-        $name = getter($param, "name");
-        if (!$name) {
-            return message("数据表名称不能为空", false);
-        }
-//        if ($name != DB_PREFIX . 'demo') {
-//            return message("演示环境禁止操作", false);
-//        }
-        // 数据表名称
-        $tableName = str_replace(DB_PREFIX, null, $name);
-        // 模型名称
-        $moduleName = str_replace(' ', null, ucwords(strtolower(str_replace('_', ' ', $tableName))));
-        // 控制器名称
-        $controllerName = ucfirst(strtolower(str_replace('_', '', $tableName)));
-
-        // 数据表描述
-        $comment = getter($param, "comment");
-        if (!$comment) {
-            return message("数据表名称不能为空", false);
-        }
-        // 去除表描述中的`表`
-        if (strpos($comment, "表") !== false) {
-            $comment = str_replace("表", null, $comment);
-            $menuName = $comment;
-        }
-        // 去除表描述中的`管理`
-        if (strpos($comment, "管理") !== false) {
-            $comment = str_replace("管理", null, $comment);
-        }
-        // 作者花名
-        $author = "laravel开发员";
-
-        // 生成模型
-        $this->generateModel($author, $moduleName, $comment, $tableName);
-        // 生成服务类
-        $this->generateService($author, $moduleName, $comment, $tableName);
-        // 生成控制器
-        $this->generateController($author, $controllerName, $comment, $tableName);
-        // 生成列表文件
-        $this->generateVueIndex($comment, $moduleName, $tableName);
-        // 生成菜单
-        $this->generateMenu(strtolower(str_replace('_', '', $tableName)), $menuName);
-        return message("模块生成成功");
-    }
-
-    /**
-     * 生成模型
-     * @param $author 作者
-     * @param $moduleName 模块名
-     * @param $moduleTitle 模块标题
-     * @param $tableName 数据表名
-     * @author laravel开发员
-     * @since 2020/11/12
-     */
-    public function generateModel($author, $moduleName, $moduleTitle, $tableName)
-    {
-        // 判断是否有图片
-        $moduleImage = false;
-        // 获取数据列表
-        $columnList = $this->getColumnList(DB_PREFIX . "{$tableName}");
-        if ($columnList) {
-            foreach ($columnList as &$val) {
-                // 图片字段处理
-                if (strpos($val['columnName'], "cover") !== false ||
-                    strpos($val['columnName'], "avatar") !== false ||
-                    strpos($val['columnName'], "image") !== false ||
-                    strpos($val['columnName'], "logo") !== false ||
-                    strpos($val['columnName'], "pic") !== false) {
-                    $val['columnImage'] = true;
-                    $moduleImage = true;
-                }
-            }
-        }
-        // 参数
-        $param = [
-            'author' => $author,
-            'since' => date('Y/m/d', time()),
-            'moduleName' => $moduleName,
-            'moduleTitle' => $moduleTitle,
-            'tableName' => $tableName,
-            'columnList' => $columnList,
-            'moduleImage' => $moduleImage,
-        ];
-        // 存储目录
-        $FILE_PATH = app_path() . '/Models';
-        if (!is_dir($FILE_PATH)) {
-            // 创建目录并赋予权限
-            mkdir($FILE_PATH, 0777, true);
-        }
-        // 文件名
-        $filename = $FILE_PATH . "/{$moduleName}Model.php";
-        // 拆解参数
-        extract($param);
-        // 开启缓冲区
-        ob_start();
-        // 引入模板文件
-        require(resource_path() . '/views/templates/model.blade.php');
-        // 获取缓冲区内容
-        $out = ob_get_clean();
-        // 打开文件
-        $f = fopen($filename, 'w');
-        // 写入内容
-        fwrite($f, "<?php " . $out);
-        // 关闭
-        fclose($f);
-    }
-
-    /**
-     * 生成服务类
-     * @param $author 作者
-     * @param $moduleName 模块名
-     * @param $moduleTitle 模块标题
-     * @param $tableName 数据表
-     * @author laravel开发员
-     * @since 2020/11/12
-     */
-    public function generateService($author, $moduleName, $moduleTitle, $tableName)
-    {
-        // 判断是否有图片
-        $moduleImage = false;
-        // 查询条件
-        $queryList = [];
-        // 获取数据列表
-        $columnList = $this->getColumnList(DB_PREFIX . "{$tableName}");
-        if ($columnList) {
-            foreach ($columnList as &$val) {
-                // 图片字段处理
-                if (strpos($val['columnName'], "cover") !== false ||
-                    strpos($val['columnName'], "avatar") !== false ||
-                    strpos($val['columnName'], "image") !== false ||
-                    strpos($val['columnName'], "logo") !== false ||
-                    strpos($val['columnName'], "pic") !== false) {
-                    $val['columnImage'] = true;
-                    $moduleImage = true;
-                }
-                // 下拉筛选
-                if (isset($val['columnValue'])) {
-                    $queryList[] = $val;
-                }
-                // 名称
-                if ($val['columnName'] == "name") {
-                    $queryList[] = $val;
-                }
-                // 标题
-                if ($val['columnName'] == "title") {
-                    $queryList[] = $val;
-                }
-            }
-        }
-
-        // 参数
-        $param = [
-            'author' => $author,
-            'since' => date('Y/m/d', time()),
-            'moduleName' => $moduleName,
-            'moduleTitle' => $moduleTitle,
-            'columnList' => $columnList,
-            'moduleImage' => $moduleImage,
-            'queryList' => $queryList,
-        ];
-        // 存储目录
-        $FILE_PATH = app_path() . '/Services/';
-        if (!is_dir($FILE_PATH)) {
-            // 创建目录并赋予权限
-            mkdir($FILE_PATH, 0777, true);
-        }
-        // 文件名
-        $filename = $FILE_PATH . "/{$moduleName}Service.php";
-        // 拆解参数
-        extract($param);
-        // 开启缓冲区
-        ob_start();
-        // 引入模板文件
-        require(resource_path() . '/views/templates/service.blade.php');
-        // 获取缓冲区内容
-        $out = ob_get_clean();
-        // 打开文件
-        $f = fopen($filename, 'w');
-        // 写入内容
-        fwrite($f, "<?php " . $out);
-        // 关闭
-        fclose($f);
-    }
-
-    /**
-     * 生成控制器
-     * @param $author 作者
-     * @param $moduleName 模块名
-     * @param $moduleTitle 模块标题
-     * @param $tableName 数据表名
-     * @author laravel开发员
-     * @since 2020/11/12
-     */
-    public function generateController($author, $moduleName, $moduleTitle, $tableName)
-    {
-        // 获取数据列表
-        $columnList = $this->getColumnList(DB_PREFIX . "{$tableName}");
-        // 参数
-        $param = [
-            'author' => $author,
-            'since' => date('Y/m/d', time()),
-            'moduleName' => $moduleName,
-            'moduleTitle' => $moduleTitle,
-            'columnList' => $columnList,
-        ];
-        // 存储目录
-        $FILE_PATH = app_path() . '\Http\Controllers';
-        if (!is_dir($FILE_PATH)) {
-            // 创建目录并赋予权限
-            mkdir($FILE_PATH, 0777, true);
-        }
-        // 文件名
-        $filename = $FILE_PATH . "/{$param['moduleName']}Controller.php";
-        // 拆解参数
-        extract($param);
-        // 开启缓冲区
-        ob_start();
-        // 引入模板文件
-        require(resource_path() . '/views/templates/controller.blade.php');
-        // 获取缓冲区内容
-        $out = ob_get_clean();
-        // 打开文件
-        $f = fopen($filename, 'w');
-        // 写入内容
-        fwrite($f, "<?php " . $out);
-        // 关闭
-        fclose($f);
-    }
-
-    /**
-     * 生成列表文件
-     * @param $moduleTitle 模块标题
-     * @param $tableName 数据表名
-     * @author laravel开发员
-     * @since 2020/7/15
-     */
-    public function generateVueIndex($moduleTitle, $moduleName, $tableName)
-    {
-        // 获取数据列表
-        $columnList = $this->getColumnList(DB_PREFIX . "{$tableName}");
-        $queryList = [];
-        if ($columnList) {
-            foreach ($columnList as $val) {
-                // 下拉筛选
-                if (isset($val['columnValue'])) {
-                    $queryList[] = $val;
-                }
-                // 名称
-                if ($val['columnName'] == "name") {
-                    $queryList[] = $val;
-                }
-                // 标题
-                if ($val['columnName'] == "title") {
-                    $queryList[] = $val;
-                }
-            }
-        }
-        // 获取编辑表单数据源
-        // 剔除非表单呈现字段
-        $arrayList = [];
-        $tempList = [];
-        $rowList = [];
-        $columnSplit = false;
-        if ($columnList) {
-            foreach ($columnList as $val) {
-                // 记录ID
-                if ($val['columnName'] == "id") {
-                    continue;
-                }
-                // 创建人
-                if ($val['columnName'] == "create_user") {
-                    continue;
-                }
-                // 创建时间
-                if ($val['columnName'] == "create_time") {
-                    continue;
-                }
-                // 更新人
-                if ($val['columnName'] == "update_user") {
-                    continue;
-                }
-                // 更新时间
-                if ($val['columnName'] == "update_time") {
-                    continue;
-                }
-                // 有效标识
-                if ($val['columnName'] == "mark") {
-                    continue;
-                }
-                // 图片字段处理
-                if (strpos($val['columnName'], "cover") !== false ||
-                    strpos($val['columnName'], "avatar") !== false ||
-                    strpos($val['columnName'], "image") !== false ||
-                    strpos($val['columnName'], "logo") !== false ||
-                    strpos($val['columnName'], "pic") !== false) {
-                    $val['columnUpload'] = true;
-                    $tempList[] = $val;
-                    continue;
-                }
-                // 多行文本输入框
-                if (strpos($val['columnName'], "note") !== false ||
-                    strpos($val['columnName'], "content") !== false ||
-                    strpos($val['columnName'], "description") !== false ||
-                    strpos($val['columnName'], "intro") !== false) {
-                    $val['columnRow'] = true;
-                    $rowList[] = $val;
-                    continue;
-                }
-                // 由于目前时间字段采用int类型,所以这里根据字段描述模糊确定是否是时间选择
-                if (strpos($val['columnComment'], "时间") !== false) {
-                    $val['dataType'] = 'datetime';
-                } elseif (strpos($val['columnComment'], "日期") !== false) {
-                    $val['dataType'] = 'date';
-                }
-
-                // 图片字段处理
-                if (strpos($val['columnName'], "cover") !== false ||
-                    strpos($val['columnName'], "avatar") !== false ||
-                    strpos($val['columnName'], "image") !== false ||
-                    strpos($val['columnName'], "logo") !== false ||
-                    strpos($val['columnName'], "pic") !== false) {
-                    $val['columnImage'] = true;
-                }
-                $arrayList[] = $val;
-            }
-        }
-        if (count($arrayList) + count($tempList) + count($rowList) > 105) {
-            $dataList = [];
-            // 分两个一组
-            $dataList = array_chunk($arrayList, 2);
-            // 图片
-            if (count($tempList) > 0) {
-                array_unshift($dataList, $tempList);
-            }
-            // 多行文本
-            if (count($rowList) > 0) {
-                foreach ($rowList as $val) {
-                    $dataList[][] = $val;
-                }
-            }
-            $columnList = $dataList;
-            $columnSplit = true;
-        } else {
-            $dataList = $arrayList;
-//            // 图片
-//            if (count($tempList) > 0) {
-//                array_unshift($dataList, $tempList);
-//            }
-            // 多行文本
-            if (count($rowList) > 0) {
-                foreach ($rowList as $val) {
-                    $dataList[][] = $val;
-                }
-            }
-            $columnList = $dataList;
-            $columnSplit = false;
-        }
-
-        // 参数
-        $param = [
-            'moduleName' => $moduleName,
-            'moduleName2' => strtolower($moduleName),
-            'moduleTitle' => $moduleTitle,
-            'queryList' => $queryList,
-            'columnList' => $columnList,
-        ];
-        // 存储目录
-        if (strpos($tableName, "_") !== false) {
-            $tableName = str_replace('_', null, $tableName);
-        }
-        $FILE_PATH = ROOT_PATH . '/evui/src/views/system/' . strtolower($tableName);
-        if (!is_dir($FILE_PATH)) {
-            // 创建目录并赋予权限
-            mkdir($FILE_PATH, 0777, true);
-        }
-        // 文件名
-        $filename = $FILE_PATH . "/index.vue";
-        // 拆解参数
-        extract($param);
-        // 开启缓冲区
-        ob_start();
-        // 引入模板文件
-        require(resource_path() . '/views/templates/index.blade.php');
-        // 获取缓冲区内容
-        $out = ob_get_clean();
-        // 打开文件
-        $f = fopen($filename, 'w');
-        // 写入内容
-        fwrite($f, $out);
-        // 关闭
-        fclose($f);
-    }
-
-    /**
-     * 生成字段列表
-     * @param $tableName 数据表名
-     * @return array
-     * @author laravel开发员
-     * @since 2020/11/12
-     */
-    public function getColumnList($tableName)
-    {
-        // 获取表列字段信息
-        $columnList = DB::select("SELECT COLUMN_NAME,COLUMN_DEFAULT,DATA_TYPE,COLUMN_TYPE,COLUMN_COMMENT FROM information_schema.`COLUMNS` where TABLE_NAME like '{$tableName}'");
-        $columnList = json_decode(json_encode($columnList), true);
-        $fields = [];
-        if ($columnList) {
-            foreach ($columnList as $val) {
-                $column = [];
-                // 列名称
-                $column['columnName'] = $val['COLUMN_NAME'];
-                // 列默认值
-                $column['columnDefault'] = $val['COLUMN_DEFAULT'];
-                // 数据类型
-                $column['dataType'] = $val['DATA_TYPE'];
-                // 列描述
-                if (strpos($val['COLUMN_COMMENT'], ':') !== false) {
-                    $item = explode(":", $val['COLUMN_COMMENT']);
-                    $column['columnComment'] = $item[0];
-
-                    // 拆解字段描述
-                    $param = explode(" ", $item[1]);
-                    $columnValue = [];
-                    $columnValueList = [];
-                    foreach ($param as $vo) {
-                        // 键值
-                        $key = preg_replace('/[^0-9]/', '', $vo);
-                        // 键值内容
-                        $value = str_replace($key, null, $vo);
-                        $columnValue[] = "{$key}={$value}";
-                        $columnValueList[] = $value;
-                    }
-                    $column['columnValue'] = implode(',', $columnValue);
-                    if ($val['COLUMN_NAME'] == "status" || substr($val['COLUMN_NAME'], 0, 3) == "is_") {
-                        $column['columnSwitch'] = true;
-                        $column['columnSwitchValue'] = implode('|', $columnValueList);
-                        if ($val['COLUMN_NAME'] == "status") {
-                            $column['columnSwitchName'] = "status";
-                        } else {
-                            $column['columnSwitchName'] = 'set' . str_replace(' ', null, ucwords(strtolower(str_replace('_', ' ', $val['COLUMN_NAME']))));
-                        }
-                    } else {
-                        $column['columnSwitch'] = false;
-                    }
-                } else {
-                    $column['columnComment'] = $val['COLUMN_COMMENT'];
-                }
-                $fields[] = $column;
-            }
-        }
-        return $fields;
-    }
-
-    /**
-     * 生成模块菜单
-     * @param $moduleName 模块名称
-     * @param $moduleTitle 模块标题
-     * @author laravel开发员
-     * @since 2020/11/12
-     */
-    public function generateMenu($moduleName, $moduleTitle)
-    {
-        // 查询已存在的菜单
-        $menuModel = new MenuModel();
-        $info = $menuModel->getOne([
-            ['permission', '=', "sys:{$moduleName}:view"],
-        ]);
-        $data = [
-            'id' => isset($info['id']) ? intval($info['id']) : 0,
-            'title' => $moduleTitle,
-            'icon' => 'el-icon-house',
-            'path' => "/system/{$moduleName}",
-            'component' => "/system/{$moduleName}",
-            'pid' => 154,
-            'type' => 0,
-            'permission' => "sys:{$moduleName}:view",
-        ];
-        $result = $menuModel->edit($data);
-        if ($result) {
-            // 去除表描述中的`管理`
-            if (strpos($moduleTitle, "管理") !== false) {
-                $moduleTitle = str_replace("管理", null, $moduleTitle);
-            }
-            // 创建节点
-            $funcList = [1, 5, 10, 15, 25, 30];
-            foreach ($funcList as $val) {
-                $item = [];
-                if ($val == 1) {
-                    // 查询列表
-                    $menuModel = new MenuModel();
-                    $info = $menuModel->getOne([
-                        ['pid', '=', $result],
-                        ['title', '=', "查询" . $moduleTitle]
-                    ]);
-                    $item = [
-                        'id' => isset($info['id']) ? intval($info['id']) : 0,
-                        'title' => "查询" . $moduleTitle,
-                        'permission' => "sys:{$moduleName}:index",
-                        'pid' => $result,
-                        'type' => 1,
-                        'status' => 1,
-                        'sort' => $val,
-                    ];
-                } else if ($val == 5) {
-                    // 添加
-                    $menuModel = new MenuModel();
-                    $info = $menuModel->getOne([
-                        ['pid', '=', $result],
-                        ['title', '=', "添加" . $moduleTitle]
-                    ]);
-                    $item = [
-                        'id' => isset($info['id']) ? intval($info['id']) : 0,
-                        'title' => "添加" . $moduleTitle,
-                        'permission' => "sys:{$moduleName}:add",
-                        'pid' => $result,
-                        'type' => 1,
-                        'status' => 1,
-                        'sort' => $val,
-                    ];
-                } else if ($val == 10) {
-                    // 修改
-                    $menuModel = new MenuModel();
-                    $info = $menuModel->getOne([
-                        ['pid', '=', $result],
-                        ['title', '=', "修改" . $moduleTitle]
-                    ]);
-                    $item = [
-                        'id' => isset($info['id']) ? intval($info['id']) : 0,
-                        'title' => "修改" . $moduleTitle,
-                        'permission' => "sys:{$moduleName}:edit",
-                        'pid' => $result,
-                        'type' => 1,
-                        'status' => 1,
-                        'sort' => $val,
-                    ];
-                } else if ($val == 15) {
-                    // 删除
-                    $menuModel = new MenuModel();
-                    $info = $menuModel->getOne([
-                        ['pid', '=', $result],
-                        ['title', '=', "删除" . $moduleTitle]
-                    ]);
-                    $item = [
-                        'id' => isset($info['id']) ? intval($info['id']) : 0,
-                        'title' => "删除" . $moduleTitle,
-                        'permission' => "sys:{$moduleName}:delete",
-                        'pid' => $result,
-                        'type' => 1,
-                        'status' => 1,
-                        'sort' => $val,
-                    ];
-                } else if ($val == 20) {
-                    // 状态
-                    $menuModel = new MenuModel();
-                    $info = $menuModel->getOne([
-                        ['pid', '=', $result],
-                        ['title', '=', "设置状态"]
-                    ]);
-                    $item = [
-                        'id' => isset($info['id']) ? intval($info['id']) : 0,
-                        'title' => "设置状态",
-                        'permission' => "sys:{$moduleName}:status",
-                        'pid' => $result,
-                        'type' => 1,
-                        'status' => 1,
-                        'sort' => $val,
-                    ];
-                } else if ($val == 25) {
-                    // 批量删除
-                    $info = $menuModel->getOne([
-                        ['pid', '=', $result],
-                        ['title', '=', "批量删除"]
-                    ]);
-                    $item = [
-                        'id' => isset($info['id']) ? intval($info['id']) : 0,
-                        'title' => "批量删除",
-                        'permission' => "sys:{$moduleName}:dall",
-                        'pid' => $result,
-                        'type' => 1,
-                        'status' => 1,
-                        'sort' => $val,
-                    ];
-                }
-                $menuModel = new MenuModel();
-                $menuModel->edit($item);
-            }
-        }
-    }
-
-}

+ 0 - 89
app/Services/ItemCateService.php

@@ -1,89 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services;
-
-use App\Models\ItemCateModel;
-
-/**
- * 栏目管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class ItemCateService
- * @package App\Services
- */
-class ItemCateService extends BaseService
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * ItemCateService constructor.
-     */
-    public function __construct()
-    {
-        $this->model = new ItemCateModel();
-    }
-
-    /**
-     * 获取栏目列表
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function getList()
-    {
-        $param = request()->all();
-
-        // 查询条件
-        $map = [];
-        // 上级ID
-        $pid = intval(getter($param, 'pid', 0));
-        if (!$pid) {
-            $map[] = ['pid', '=', 0];
-        } else {
-            $map[] = ['pid', '=', $pid];
-        }
-        $list = $this->model->getList($map, [['sort', 'asc']]);
-        if (!empty($list)) {
-            foreach ($list as &$val) {
-                if ($val['pid'] == 0) {
-                    $val['hasChildren'] = true;
-                }
-            }
-        }
-        return message("操作成功", true, $list);
-    }
-
-    /**
-     * 添加或编辑
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function edit()
-    {
-        // 参数
-        $data = request()->all();
-        // 封面地址
-        $cover = trim($data['cover']);
-        if (!$data['id'] && !$cover) {
-            return message('请上传栏目封面', false);
-        }
-        if (strpos($cover, "temp")) {
-            $data['cover'] = save_image($cover, 'itemcate');
-        } else {
-            $data['cover'] = str_replace(IMG_URL, "", $data['cover']);
-        }
-        return parent::edit($data); // TODO: Change the autogenerated stub
-    }
-
-}

+ 0 - 96
app/Services/ItemService.php

@@ -1,96 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services;
-
-use App\Models\ItemModel;
-
-/**
- * 站点管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class ItemService
- * @package App\Services
- */
-class ItemService extends BaseService
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * ItemService constructor.
-     */
-    public function __construct()
-    {
-        $this->model = new ItemModel();
-    }
-
-    /**
-     * 获取站点列表
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function getList()
-    {
-        $param = request()->all();
-
-        // 查询条件
-        $map = [];
-        // 站点类型
-        $type = getter($param, "type", 0);
-        if ($type) {
-            $map[] = ["type", '=', $type];
-        }
-        return parent::getList($map); // TODO: Change the autogenerated stub
-    }
-
-
-    /**
-     * 添加或编辑
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function edit()
-    {
-        $data = request()->all();
-
-        // 图片处理
-        $image = trim($data['image']);
-        if (!$data['id'] && !$image) {
-            return message('请上传站点图片', false);
-        }
-        if (strpos($image, "temp")) {
-            $data['image'] = save_image($image, 'item');
-        } else {
-            $data['image'] = str_replace(IMG_URL, "", $data['image']);
-        }
-        return parent::edit($data); // TODO: Change the autogenerated stub
-    }
-
-    /**
-     * 获取站点列表
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function getItemList()
-    {
-        $list = $this->model->where("status", "=", 1)
-            ->where("mark", "=", 1)
-            ->orderBy("sort", "asc")
-            ->get()
-            ->toArray();
-        return message("操作成功", true, $list);
-    }
-
-}

+ 0 - 57
app/Services/LayoutDescService.php

@@ -1,57 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services;
-
-use App\Models\LayoutDescModel;
-
-/**
- * 布局描述-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class LayoutDescService
- * @package App\Services
- */
-class LayoutDescService extends BaseService
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * LayoutDescService constructor.
-     */
-    public function __construct()
-    {
-        $this->model = new LayoutDescModel();
-    }
-
-    /**
-     * 获取数据列表
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function getList()
-    {
-        $param = request()->all();
-
-        // 查询条件
-        $map = [];
-
-        // 布局描述
-        $loc_desc = getter($param, "loc_desc");
-        if ($loc_desc) {
-            $map[] = ["loc_desc", '=', $loc_desc];
-        }
-        return parent::getList($map); // TODO: Change the autogenerated stub
-    }
-
-}

+ 0 - 59
app/Services/LayoutService.php

@@ -1,59 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services;
-
-use App\Models\LayoutModel;
-
-/**
- * 布局管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class LayoutService
- * @package App\Services
- */
-class LayoutService extends BaseService
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * LayoutService constructor.
-     */
-    public function __construct()
-    {
-        $this->model = new LayoutModel();
-    }
-
-    /**
-     * 添加或编辑
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function edit()
-    {
-        $data = request()->all();
-
-        // 图片处理
-        $image = trim($data['image']);
-        if (!$data['id'] && !$image) {
-            return message('请上传布局图片', false);
-        }
-        if (strpos($image, "temp")) {
-            $data['image'] = save_image($image, 'layout');
-        } else {
-            $data['image'] = str_replace(IMG_URL, "", $data['image']);
-        }
-        return parent::edit($data); // TODO: Change the autogenerated stub
-    }
-
-}

+ 0 - 53
app/Services/LevelService.php

@@ -1,53 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services;
-
-use App\Models\LevelModel;
-
-/**
- * 职级管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class LevelService
- * @package App\Services
- */
-class LevelService extends BaseService
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * LevelService constructor.
-     */
-    public function __construct()
-    {
-        $this->model = new LevelModel();
-    }
-
-    /**
-     * 获取职级列表
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function getLevelList()
-    {
-        $list = $this->model->where([
-            ['status', '=', 1],
-            ['mark', '=', 1],
-        ])->orderBy("sort", "asc")
-            ->get()
-            ->toArray();
-        return message("操作成功", true, $list);
-    }
-
-}

+ 0 - 80
app/Services/LinkService.php

@@ -1,80 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services;
-
-use App\Models\LinkModel;
-
-/**
- * 友链管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class LinkService
- * @package App\Services
- */
-class LinkService extends BaseService
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * LinkService constructor.
-     */
-    public function __construct()
-    {
-        $this->model = new LinkModel();
-    }
-
-    /**
-     * 获取友链列表
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function getList()
-    {
-        $param = request()->all();
-
-        // 查询条件
-        $map = [];
-
-        // 友链平台
-        $platform = getter($param, "platform");
-        if ($platform) {
-            $map[] = ["platform", '=', $platform];
-        }
-        return parent::getList($map); // TODO: Change the autogenerated stub
-    }
-
-    /**
-     * 添加或编辑
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function edit()
-    {
-        $data = request()->all();
-
-        // 图片处理
-        $image = trim($data['image']);
-        if (!$data['id'] && !$image) {
-            return message('请上传友链图片', false);
-        }
-        if (strpos($image, "temp")) {
-            $data['image'] = save_image($image, 'item');
-        } else {
-            $data['image'] = str_replace(IMG_URL, "", $data['image']);
-        }
-        return parent::edit($data); // TODO: Change the autogenerated stub
-    }
-
-}

+ 0 - 53
app/Services/PositionService.php

@@ -1,53 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
-// +----------------------------------------------------------------------
-// | 版权所有 2017~2021 LARAVEL研发中心
-// +----------------------------------------------------------------------
-// | 官方网站: http://www.laravel.cn
-// +----------------------------------------------------------------------
-// | Author: laravel开发员 <laravel.qq.com>
-// +----------------------------------------------------------------------
-
-namespace App\Services;
-
-use App\Models\PositionModel;
-
-/**
- * 岗位管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class PositionService
- * @package App\Services
- */
-class PositionService extends BaseService
-{
-    /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * PositionService constructor.
-     */
-    public function __construct()
-    {
-        $this->model = new PositionModel();
-    }
-
-    /**
-     * 获取岗位列表
-     * @return array
-     * @since 2020/11/11
-     * @author laravel开发员
-     */
-    public function getPositionList()
-    {
-        $list = $this->model->where([
-            ['status', '=', 1],
-            ['mark', '=', 1],
-        ])->orderBy("sort", "asc")
-            ->get()
-            ->toArray();
-        return message("操作成功", true, $list);
-    }
-
-}

+ 148 - 0
app/Services/RedisService.php

@@ -0,0 +1,148 @@
+<?php
+/**
+ * REDIS缓存模块服务层
+ * Class RedisService
+ */
+namespace App\Services;
+use Illuminate\Support\Facades\Redis as BaseRedis;
+
+class RedisService extends BaseRedis
+{
+    /**
+     * 设置缓存
+     * @param $key 键名
+     * @param $data 数据:数组和字符串,数组自动转化JSON
+     * @param int $expire 有效期:0为永久
+     * @return mixed
+     */
+    public static function set($key, $data, $expire =null)
+    {
+        $expire = $expire !=null ? $expire : env('REDIS_EXPIRE', 24 * 3600);
+        $data = is_array($data) && !empty($data)? json_encode($data, 256) : $data;
+        $data = !empty($data)? $data : null;
+        if ($expire > 0) {
+            return BaseRedis::setex($key, $expire, $data);
+        } else {
+            return BaseRedis::set($key, $data);
+        }
+    }
+
+    /**
+     * 获取缓存数据
+     * @param $key 键名
+     * @return array|mixed
+     */
+    public static function get($key)
+    {
+        $data = BaseRedis::get($key);
+        $jsonData = $data ? json_decode($data, true) : [];
+        return $jsonData ? $jsonData : $data;
+    }
+
+    /**
+     * 键名是否存在
+     * @param $key
+     * @param $expire
+     * @return mixed
+     */
+    public static function exists($key){
+        return BaseRedis::exists($key);
+    }
+
+    /**
+     * 递增
+     * @param $key
+     * @return bool
+     */
+    public static function incr($key, $step=1){
+        return BaseRedis::incrby($key, $step);
+    }
+
+    /**
+     * 递减
+     * @param $key
+     * @return bool
+     */
+    public static function decr($key, $step=1){
+        return BaseRedis::decrby($key, $step);
+    }
+
+    /**
+     * 进队列缓存
+     * @param $key 键名
+     * @param $data 队列数据
+     * @param bool $clear 是否清除之前数据
+     * @return mixed
+     */
+    public static function rPush($key, $data, $clear = false)
+    {
+        if ($clear) {
+            BaseRedis::del($key);
+        }
+        $data = is_array($data) ? json_encode($data, 256) : $data;
+        return BaseRedis::rPush($key, $data);
+
+    }
+
+    /**
+     * 出队列
+     * @param $key 键名
+     * @return array|mixed
+     */
+    public static function lPop($key)
+    {
+        $data = BaseRedis::lPop($key);
+        $jsonData = $data ? json_decode($data, true) : [];
+        return $jsonData ? $jsonData : $data;
+    }
+
+    /**
+     * 清除缓存
+     * @param $key 键名
+     * @return mixed
+     */
+    public static function clear($key)
+    {
+        return BaseRedis::del($key);
+    }
+
+    /**
+     * 按键名匹配删除
+     * @param $key
+     * @return bool
+     */
+    public static function keyDel($key){
+        $keys = BaseRedis::keys($key);
+        foreach($keys as $key){
+            BaseRedis::del($key);
+        }
+
+        return true;
+    }
+
+    /**
+     * 有效期设置
+     * @param $key
+     * @param $expire
+     * @return mixed
+     */
+    public static function expire($key, $expire){
+        return BaseRedis::expire($key, $expire);
+    }
+
+    /**
+     * 原子锁
+     * @param $key
+     * @param $value
+     * @param int $expire
+     * @return mixed
+     */
+    public static function setnx($key, $value, $expire=0){
+        $res = BaseRedis::setnx($key, $value);
+        if($expire){
+            BaseRedis::expire($key, $expire);
+        }
+
+        return $res;
+    }
+}

+ 26 - 14
app/Http/Controllers/DictTypeController.php

@@ -9,28 +9,40 @@
 // | Author: laravel开发员 <laravel.qq.com>
 // +----------------------------------------------------------------------
 
-namespace App\Http\Controllers;
+namespace App\Services;
 
-use App\Services\DictTypeService;
+use App\Models\ConfigModel;
 
 /**
- * 字典类型-控制器
- * @author laravel开发员
+ * 手机短信管理-服务类
+ * @author
  * @since 2020/11/11
- * Class DictTypeController
- * @package App\Http\Controllers
+ * Class SmsService
+ * @package App\Services
  */
-class DictTypeController extends Backend
+class SmsService extends BaseService
 {
     /**
-     * 构造函数
-     * @author laravel开发员
-     * @since 2020/11/11
-     * DictTypeController constructor.
+     * 发送手机短信
+     * @param $email
+     * @param string $scene 场景:默认reg-注册
+     * @return bool
      */
-    public function __construct()
+    public function sendCode($mobile, $scene='reg')
     {
-        parent::__construct();
-        $this->service = new DictTypeService();
+        return true;
     }
+
+    /**
+     * 验证手机短信
+     * @param $mobile
+     * @param string $scene 场景:默认reg-注册
+     * @return bool
+     */
+    public function check($mobile, $scene='reg')
+    {
+        return true;
+    }
+
+
 }