Sfoglia il codice sorgente

wesmiler 抢表商城

APPLE 3 anni fa
parent
commit
88667e6452
100 ha cambiato i file con 12739 aggiunte e 0 eliminazioni
  1. 41 0
      app/Console/Kernel.php
  2. 37 0
      app/Exceptions/Handler.php
  3. 238 0
      app/Exports/Export.php
  4. 191 0
      app/Helpers/Jwt.php
  5. 1584 0
      app/Helpers/common.php
  6. 22 0
      app/Helpers/constants.php
  7. 11 0
      app/Helpers/function.php
  8. 36 0
      app/Http/Controllers/Admin/ActionLogController.php
  9. 37 0
      app/Http/Controllers/Admin/AdController.php
  10. 50 0
      app/Http/Controllers/Admin/AdSortController.php
  11. 165 0
      app/Http/Controllers/Admin/Backend.php
  12. 36 0
      app/Http/Controllers/Admin/CityController.php
  13. 36 0
      app/Http/Controllers/Admin/ConfigController.php
  14. 36 0
      app/Http/Controllers/Admin/ConfigGroupController.php
  15. 22 0
      app/Http/Controllers/Admin/Controller.php
  16. 92 0
      app/Http/Controllers/Admin/IndexController.php
  17. 37 0
      app/Http/Controllers/Admin/LayoutController.php
  18. 37 0
      app/Http/Controllers/Admin/LayoutDescController.php
  19. 73 0
      app/Http/Controllers/Admin/LoginController.php
  20. 36 0
      app/Http/Controllers/Admin/LoginLogController.php
  21. 36 0
      app/Http/Controllers/Admin/MemberController.php
  22. 49 0
      app/Http/Controllers/Admin/MemberLevelController.php
  23. 36 0
      app/Http/Controllers/Admin/MenuController.php
  24. 49 0
      app/Http/Controllers/Admin/NoticeController.php
  25. 49 0
      app/Http/Controllers/Admin/PositionController.php
  26. 72 0
      app/Http/Controllers/Admin/RoleController.php
  27. 83 0
      app/Http/Controllers/Admin/UploadController.php
  28. 49 0
      app/Http/Controllers/Admin/UserController.php
  29. 26 0
      app/Http/Controllers/Api/LangController.php
  30. 62 0
      app/Http/Controllers/Api/LoginController.php
  31. 22 0
      app/Http/Controllers/Api/TestController.php
  32. 81 0
      app/Http/Controllers/Api/UploadController.php
  33. 254 0
      app/Http/Controllers/Api/webApp.php
  34. 97 0
      app/Http/Controllers/BaseController.php
  35. 71 0
      app/Http/Kernel.php
  36. 24 0
      app/Http/Middleware/ActionLog.php
  37. 21 0
      app/Http/Middleware/Authenticate.php
  38. 54 0
      app/Http/Middleware/EnableCrossRequestMiddleware.php
  39. 17 0
      app/Http/Middleware/EncryptCookies.php
  40. 17 0
      app/Http/Middleware/PreventRequestsDuringMaintenance.php
  41. 32 0
      app/Http/Middleware/RedirectIfAuthenticated.php
  42. 18 0
      app/Http/Middleware/TrimStrings.php
  43. 20 0
      app/Http/Middleware/TrustHosts.php
  44. 23 0
      app/Http/Middleware/TrustProxies.php
  45. 50 0
      app/Http/Middleware/UserLogin.php
  46. 17 0
      app/Http/Middleware/VerifyCsrfToken.php
  47. 69 0
      app/Http/Middleware/WebLogin.php
  48. 56 0
      app/Http/Validator/BaseValidator.php
  49. 47 0
      app/Http/Validator/MemberValidator.php
  50. 2 0
      app/Lib/phpqrcode/.gitignore
  51. 38 0
      app/Lib/phpqrcode/CHANGELOG
  52. 165 0
      app/Lib/phpqrcode/LICENSE
  53. 3719 0
      app/Lib/phpqrcode/QRcode.php
  54. 61 0
      app/Lib/phpqrcode/README
  55. 2 0
      app/Lib/phpqrcode/VERSION
  56. 144 0
      app/Models/ActionLogModel.php
  57. 61 0
      app/Models/AdModel.php
  58. 40 0
      app/Models/AdSortModel.php
  59. 1253 0
      app/Models/BaseModel.php
  60. 291 0
      app/Models/CacheModel.php
  61. 25 0
      app/Models/CityModel.php
  62. 25 0
      app/Models/ConfigGroupModel.php
  63. 25 0
      app/Models/ConfigModel.php
  64. 72 0
      app/Models/ItemCateModel.php
  65. 45 0
      app/Models/ItemModel.php
  66. 49 0
      app/Models/LayoutDescModel.php
  67. 54 0
      app/Models/LayoutModel.php
  68. 25 0
      app/Models/LevelModel.php
  69. 25 0
      app/Models/MemberLevelModel.php
  70. 57 0
      app/Models/MemberModel.php
  71. 59 0
      app/Models/MenuModel.php
  72. 25 0
      app/Models/NoticeModel.php
  73. 25 0
      app/Models/RoleMenuModel.php
  74. 25 0
      app/Models/RoleModel.php
  75. 52 0
      app/Models/User.php
  76. 56 0
      app/Models/UserModel.php
  77. 26 0
      app/Models/UserRoleModel.php
  78. 45 0
      app/Providers/AppServiceProvider.php
  79. 30 0
      app/Providers/AuthServiceProvider.php
  80. 21 0
      app/Providers/BroadcastServiceProvider.php
  81. 32 0
      app/Providers/EventServiceProvider.php
  82. 63 0
      app/Providers/RouteServiceProvider.php
  83. 230 0
      app/Services/BaseService.php
  84. 37 0
      app/Services/Common/ActionLogService.php
  85. 64 0
      app/Services/Common/AdService.php
  86. 49 0
      app/Services/Common/AdSortService.php
  87. 72 0
      app/Services/Common/CityService.php
  88. 36 0
      app/Services/Common/ConfigGroupService.php
  89. 62 0
      app/Services/Common/ConfigService.php
  90. 75 0
      app/Services/Common/LoginLogService.php
  91. 176 0
      app/Services/Common/LoginService.php
  92. 49 0
      app/Services/Common/MemberLevelService.php
  93. 72 0
      app/Services/Common/MemberService.php
  94. 304 0
      app/Services/Common/MenuService.php
  95. 64 0
      app/Services/Common/NoticeService.php
  96. 26 0
      app/Services/Common/RoleMenuService.php
  97. 122 0
      app/Services/Common/RoleService.php
  98. 92 0
      app/Services/Common/UserRoleService.php
  99. 254 0
      app/Services/Common/UserService.php
  100. 0 0
      app/Services/ConfigGroupService.php

+ 41 - 0
app/Console/Kernel.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace App\Console;
+
+use Illuminate\Console\Scheduling\Schedule;
+use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
+
+class Kernel extends ConsoleKernel
+{
+    /**
+     * The Artisan commands provided by your application.
+     *
+     * @var array
+     */
+    protected $commands = [
+        //
+    ];
+
+    /**
+     * Define the application's command schedule.
+     *
+     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
+     * @return void
+     */
+    protected function schedule(Schedule $schedule)
+    {
+        // $schedule->command('inspire')->hourly();
+    }
+
+    /**
+     * Register the commands for the application.
+     *
+     * @return void
+     */
+    protected function commands()
+    {
+        $this->load(__DIR__.'/Commands');
+
+        require base_path('routes/console.php');
+    }
+}

+ 37 - 0
app/Exceptions/Handler.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Exceptions;
+
+use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
+
+class Handler extends ExceptionHandler
+{
+    /**
+     * A list of the exception types that are not reported.
+     *
+     * @var array
+     */
+    protected $dontReport = [
+        //
+    ];
+
+    /**
+     * A list of the inputs that are never flashed for validation exceptions.
+     *
+     * @var array
+     */
+    protected $dontFlash = [
+        'password',
+        'password_confirmation',
+    ];
+
+    /**
+     * Register the exception handling callbacks for the application.
+     *
+     * @return void
+     */
+    public function register()
+    {
+        //
+    }
+}

+ 238 - 0
app/Exports/Export.php

@@ -0,0 +1,238 @@
+<?php
+
+namespace App\Exports;
+
+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;
+
+/**
+ * 导出Excel类
+ * @author 牧羊人
+ * @since 2021/4/10
+ * Class Export
+ * @package App\Exports
+ */
+class Export implements FromCollection, WithHeadings, WithEvents
+{
+    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();
+    }
+
+    public function headings(): array
+    {
+        return $this->headings;
+    }
+
+    //数组转集合
+    public function collection()
+    {
+        return new Collection($this->data);
+    }
+
+    //业务代码
+    public function createData()
+    {
+        $this->data = collect($this->data)->toArray();
+    }
+
+    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);
+                }
+
+                //设置区域单元格垂直居中
+                foreach ($this->vertical as $region => $position) {
+                    $event->sheet->getDelegate()
+                        ->getStyle($region)
+                        ->getAlignment()
+                        ->setVertical($position);
+                }
+
+                //设置区域单元格字体
+                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);
+                }
+
+                //设置区域单元格字体粗体
+                foreach ($this->bold as $region => $bool) {
+                    $event->sheet->getDelegate()
+                        ->getStyle($region)
+                        ->getFont()
+                        ->setBold($bool);
+                }
+
+
+                //设置区域单元格背景颜色
+                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);
+                if (!empty($this->sheetName)) {
+                    $event->sheet->getDelegate()->setTitle($this->sheetName);
+                }
+            }
+        ];
+    }
+
+    /**
+     * @return array
+     * [
+     *    'B' => 40,
+     *    'C' => 60
+     * ]
+     */
+    public function setColumnWidth(array $columnwidth)
+    {
+        $this->columnWidth = array_change_key_case($columnwidth, CASE_UPPER);
+    }
+
+    /**
+     * @return array
+     * [
+     *    1 => 40,
+     *    2 => 60
+     * ]
+     */
+    public function setRowHeight(array $rowHeight)
+    {
+        $this->rowHeight = $rowHeight;
+    }
+
+    /**
+     * @return array
+     * [
+     *    A1:K7 => '宋体'
+     * ]
+     */
+    public function setFont(array $font)
+    {
+        $this->font = array_change_key_case($font, CASE_UPPER);
+    }
+
+    /**
+     * @return array
+     * @2020/3/22 10:33
+     * [
+     *    A1:K7 => true
+     * ]
+     */
+    public function setBold(array $bold)
+    {
+        $this->bold = array_change_key_case($bold, CASE_UPPER);
+    }
+
+    /**
+     * @return array
+     * @2020/3/22 10:33
+     * [
+     *    A1:K7 => F0FF0F
+     * ]
+     */
+    public function setBackground(array $background)
+    {
+        $this->background = array_change_key_case($background, CASE_UPPER);
+    }
+
+    /**
+     * @return array
+     * [
+     *    A1:K7
+     * ]
+     */
+    public function setMergeCells(array $mergeCells)
+    {
+        $this->mergeCells = array_change_key_case($mergeCells, CASE_UPPER);
+    }
+
+    /**
+     * @return array
+     * [
+     *    A1:K7 => 14
+     * ]
+     */
+    public function setFontSize(array $fontSize)
+    {
+        $this->fontSize = array_change_key_case($fontSize, CASE_UPPER);
+    }
+
+    /**
+     * @return array
+     * [
+     *    A1:K7 => #000000
+     * ]
+     */
+    public function setBorders(array $borders)
+    {
+        $this->borders = array_change_key_case($borders, CASE_UPPER);
+    }
+}

+ 191 - 0
app/Helpers/Jwt.php

@@ -0,0 +1,191 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Helpers;
+
+/**
+ * JWT鉴权
+ * @author laravel开发员
+ * @since 2020/11/14
+ * Class Jwt
+ * @package App\Helpers
+ */
+class Jwt
+{
+    // 头部
+    private static $header = [
+        'alg' => 'HS256', //生成signature的算法
+        'typ' => 'JWT'    //JWT 令牌统一写为JWT
+    ];
+
+    // 使用HMAC生成信息摘要时所使用的密钥
+    private static $key = '34c68cdccb5b6feb4f7f0a5ede9f5932';
+
+    /**
+     * alg属性表示签名的算法(algorithm),默认是 HMAC SHA256(写成 HS256);typ属性表示这个令牌(token)的类型(type),JWT 令牌统一写为JWT
+     * @return string
+     * @author laravel开发员
+     * @since 2020/11/14
+     */
+    public function getHeader()
+    {
+        return self::base64UrlEncode(json_encode(self::$header, JSON_UNESCAPED_UNICODE));
+    }
+
+    /**
+     * Payload 部分也是一个 JSON 对象,用来存放实际需要传递的数据
+     * JWT 规定了7个官方字段,供选用,这里可以存放私有信息,比如uid
+     * @param $uid
+     * @return string
+     * @author laravel开发员
+     * @since 2020/11/14
+     */
+    public function getPayload($uid)
+    {
+        $payload = [
+            'iss' => 'jwt_yh', //签发人
+            'exp' => time() + 60 * 60 * 24 * 7, //过期时间
+            'sub' => 'YH', //主题
+            'aud' => 'every', //受众
+            'nbf' => time(), //生效时间,该时间之前不接收处理该Token
+            'iat' => time(), //签发时间
+            'jti' => 10001, //编号(JWT ID用于标识该JWT)
+            'uid' => $uid, //私有信息,uid
+        ];
+        return self::base64UrlEncode(json_encode($payload, JSON_UNESCAPED_UNICODE));
+    }
+
+    /**
+     * 获取Token
+     * @param array $payload jwt载荷
+     * 格式如下非必须:
+     * [
+     *  'iss'=>'jwt_admin',  //该JWT的签发者
+     *  'iat'=>time(),  //签发时间
+     *  'exp'=>time()+7200,  //过期时间
+     *  'nbf'=>time()+60,  //该时间之前不接收处理该Token
+     *  'sub'=>'www.admin.com',  //面向的用户
+     *  'jti'=>md5(uniqid('JWT').time())  //该Token唯一标识
+     * ]
+     * @return bool|string 返回结果
+     * @author laravel开发员
+     * @since 2020/11/14
+     */
+    public function getToken($uid)
+    {
+        // 获取JWT头
+        $header = self::getHeader();
+        // 获取JWT有效载荷
+        $payload = self::getPayload($uid);
+        // JWT头拼接JWT有效载荷
+        $raw = $header . '.' . $payload;
+        // Token字符串
+        $token = $raw . '.' . self::signature($raw, self::$key, self::$header['alg']);
+        // 返回Token
+        return $token;
+    }
+
+    /**
+     * 验证token是否有效,默认验证exp,nbf,iat时间
+     * @param string $token token字符串
+     * @return bool|mixed 返回结果
+     * @author laravel开发员
+     * @since 2020/11/14
+     */
+    public function verifyToken(string $token)
+    {
+        if (!$token) {
+            return false;
+        }
+        $tokens = explode('.', $token);
+        if (count($tokens) != 3) {
+            return false;
+        }
+
+        list($base64header, $base64payload, $sign) = $tokens;
+
+        // 获取jwt算法
+        $base64decodeheader = json_decode(self::base64UrlDecode($base64header), JSON_OBJECT_AS_ARRAY);
+        if (empty($base64decodeheader['alg'])) {
+            return false;
+        }
+
+        //签名验证
+        if (self::signature($base64header . '.' . $base64payload, self::$key, $base64decodeheader['alg']) !== $sign) {
+            return false;
+        }
+
+        $payload = json_decode(self::base64UrlDecode($base64payload), JSON_OBJECT_AS_ARRAY);
+
+        //签发时间大于当前服务器时间验证失败
+        if (isset($payload['iat']) && $payload['iat'] > time()) {
+            return false;
+        }
+
+        //过期时间小宇当前服务器时间验证失败
+        if (isset($payload['exp']) && $payload['exp'] < time()) {
+            return false;
+        }
+
+        //该nbf时间之前不接收处理该Token
+        if (isset($payload['nbf']) && $payload['nbf'] > time()) {
+            return false;
+        }
+
+        return $payload['uid'];
+    }
+
+    /**
+     * base64UrlEncode编码实现
+     * @param string $str 需要编码的字符串
+     * @return mixed 返回结果
+     * @author laravel开发员
+     * @since 2020/11/14
+     */
+    private static function base64UrlEncode(string $str)
+    {
+        return str_replace('=', '', strtr(base64_encode($str), '+/', '-_'));
+    }
+
+    /**
+     * base64UrlDecode解码实现
+     * @param string $str 需要解码的字符串
+     * @return bool|string 返回结果
+     * @author laravel开发员
+     * @since 2020/11/14
+     */
+    private static function base64UrlDecode(string $str)
+    {
+        $remainder = strlen($str) % 4;
+        if ($remainder) {
+            $addlen = 4 - $remainder;
+            $str .= str_repeat('=', $addlen);
+        }
+        return base64_decode(strtr($str, '-_', '+/'));
+    }
+
+    /**
+     * HMACSHA256签名实现
+     * @param string $str 待签名字符串
+     * @param string $key 加密密钥
+     * @param string $alg 算法方式
+     * @return mixed 返回结果
+     * @author laravel开发员
+     * @since 2020/11/14
+     */
+    private static function signature(string $str, string $key, string $alg)
+    {
+        $alg_config = array(
+            'HS256' => 'sha256'
+        );
+        return self::base64UrlEncode(hash_hmac($alg_config[$alg], $str, $key, true));
+    }
+}

File diff suppressed because it is too large
+ 1584 - 0
app/Helpers/common.php


+ 22 - 0
app/Helpers/constants.php

@@ -0,0 +1,22 @@
+<?php
+/// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+// 自定义系统常量公共类
+
+define('MESSAGE_OK', '操作成功');
+define('MESSAGE_FAILED', '操作失败');
+define('MESSAGE_SYSTEM_ERROR', '系统繁忙,请稍后再试');
+define('MESSAGE_PARAMETER_MISSING', '参数丢失');
+define('MESSAGE_PARAMETER_ERROR', '参数错误');
+define('MESSAGE_PERMISSON_DENIED', '没有权限');
+define('MESSAGE_INTERNAL_ERROR', '服务器繁忙,请稍后再试');
+
+define('MESSAGE_NEEDLOGIN', '请登录');

+ 11 - 0
app/Helpers/function.php

@@ -0,0 +1,11 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+

+ 36 - 0
app/Http/Controllers/Admin/ActionLogController.php

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

+ 37 - 0
app/Http/Controllers/Admin/AdController.php

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

+ 50 - 0
app/Http/Controllers/Admin/AdSortController.php

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

+ 165 - 0
app/Http/Controllers/Admin/Backend.php

@@ -0,0 +1,165 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Admin;
+
+use App\Helpers\Jwt;
+use App\Http\Controllers\BaseController;
+use App\Models\UserModel;
+
+/**
+ * 后台控制器基类
+ * @author laravel开发员
+ * @since 2020/11/10
+ * Class Backend
+ * @package App\Http\Controllers
+ */
+class Backend extends BaseController
+{
+    // 模型
+    protected $model;
+    // 服务
+    protected $service;
+    // 校验
+    protected $validate;
+    // 登录ID
+    protected $userId;
+    // 登录信息
+    protected $userInfo;
+
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/10
+     * Backend constructor.
+     */
+    public function __construct()
+    {
+        parent::__construct();
+        // 初始化配置
+        $this->initConfig();
+
+        // 登录检测中间件
+        $this->middleware('user.login');
+
+        // 初始化登录信息
+        $this->middleware(function ($request, $next) {
+            // 请求头信息
+            $token = $request->headers->get('Authorization');
+            $token = str_replace("Bearer ", null, $token);
+            // JWT解密token
+            $jwt = new Jwt();
+            $userId = $jwt->verifyToken($token);
+
+            // 登录验证
+            $this->initLogin($userId);
+
+            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 laravel开发员
+     * @since 2020/8/31
+     */
+    public function initLogin($userId)
+    {
+        // 登录用户ID
+        $this->userId = $userId;
+
+        // 登录用户信息
+        if ($userId) {
+            $adminModel = new UserModel();
+            $userInfo = $adminModel->getInfo($this->userId);
+            $this->userInfo = $userInfo;
+        }
+
+    }
+
+    /**
+     * 获取数据列表
+     * @return mixed
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function index()
+    {
+        $result = $this->service->getList();
+        return $result;
+    }
+
+    /**
+     * 获取数据详情
+     * @return mixed
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function info()
+    {
+        $result = $this->service->info();
+        return $result;
+    }
+
+    /**
+     * 添加或编辑
+     * @return mixed
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function edit()
+    {
+        $result = $this->service->edit();
+        return $result;
+    }
+
+    /**
+     * 删除数据
+     * @return mixed
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function delete()
+    {
+        $result = $this->service->delete();
+        return $result;
+    }
+
+    /**
+     * 设置状态
+     * @return mixed
+     * @since 2020/11/21
+     * @author laravel开发员
+     */
+    public function status()
+    {
+        $result = $this->service->status();
+        return $result;
+    }
+
+}

+ 36 - 0
app/Http/Controllers/Admin/CityController.php

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

+ 36 - 0
app/Http/Controllers/Admin/ConfigController.php

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

+ 36 - 0
app/Http/Controllers/Admin/ConfigGroupController.php

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

+ 22 - 0
app/Http/Controllers/Admin/Controller.php

@@ -0,0 +1,22 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Admin;
+
+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
+use Illuminate\Foundation\Bus\DispatchesJobs;
+use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Routing\Controller as BaseController;
+
+class Controller extends BaseController
+{
+    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
+}

+ 92 - 0
app/Http/Controllers/Admin/IndexController.php

@@ -0,0 +1,92 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Admin;
+
+use App\Models\UserModel;
+use App\Models\AdminRomModel;
+use App\Services\Common\AdminService;
+use App\Services\Common\MenuService;
+use App\Services\Common\UserService;
+
+/**
+ * 系统主页控制器
+ * @author laravel开发员
+ * @since 2020/11/10
+ * Class IndexController
+ * @package App\Http\Controllers
+ */
+class IndexController extends Backend
+{
+
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/10
+     * IndexController constructor.
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * 后台主页
+     * @author laravel开发员
+     * @since 2020/11/10
+     */
+    public function getMenuList()
+    {
+        $menuService = new MenuService();
+        $menuList = $menuService->getPermissionList($this->userId);
+        return $menuList;
+    }
+
+    /**
+     * 获取个人信息
+     * @return array
+     * @since 2020/11/10
+     * @author laravel开发员
+     */
+    public function getUserInfo()
+    {
+        $userService = new UserService();
+        $result = $userService->getUserInfo($this->userId);
+        return $result;
+    }
+
+    /**
+     * 更新个人资料
+     * @return mixed
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function updateUserInfo()
+    {
+        $userService = new UserService();
+        $result = $userService->updateUserInfo($this->userId);
+        return $result;
+    }
+
+    /**
+     * 更新密码
+     * @return mixed
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function updatePwd()
+    {
+        $userService = new UserService();
+        $result = $userService->updatePwd($this->userId);
+        return $result;
+    }
+
+}

+ 37 - 0
app/Http/Controllers/Admin/LayoutController.php

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

+ 37 - 0
app/Http/Controllers/Admin/LayoutDescController.php

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

+ 73 - 0
app/Http/Controllers/Admin/LoginController.php

@@ -0,0 +1,73 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Admin;
+
+use App\Models\ActionLogModel;
+use App\Services\Common\LoginService;
+
+/**
+ * 登录控制器
+ * @author laravel开发员
+ * @since 2020/11/10
+ * Class LoginController
+ * @package App\Http\Controllers
+ */
+class LoginController extends Backend
+{
+
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/10
+     * LoginController constructor.
+     */
+    public function __construct()
+    {
+        parent::__construct();
+        $this->service = new LoginService();
+    }
+
+    /**
+     * 获取验证码
+     * @return mixed
+     * @since 2020/11/10
+     * @author laravel开发员
+     */
+    public function captcha()
+    {
+        $result = $this->service->captcha();
+        return $result;
+    }
+
+    /**
+     * 系统登录
+     * @author laravel开发员
+     * @since 2020/11/10
+     */
+    public function login()
+    {
+        $result = $this->service->login();
+        return $result;
+    }
+
+    /**
+     * 退出系统
+     * @author laravel开发员
+     * @since 2020/11/10
+     */
+    public function logout()
+    {
+        $result = $this->service->logout();
+        return $result;
+    }
+
+}

+ 36 - 0
app/Http/Controllers/Admin/LoginLogController.php

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

+ 36 - 0
app/Http/Controllers/Admin/MemberController.php

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

+ 49 - 0
app/Http/Controllers/Admin/MemberLevelController.php

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

+ 36 - 0
app/Http/Controllers/Admin/MenuController.php

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

+ 49 - 0
app/Http/Controllers/Admin/NoticeController.php

@@ -0,0 +1,49 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Admin;
+
+use App\Services\Common\NoticeService;
+
+/**
+ * 通知公告-控制器
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class NoticeController
+ * @package App\Http\Controllers
+ */
+class NoticeController extends Backend
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * NoticeController constructor.
+     */
+    public function __construct()
+    {
+        parent::__construct();
+        $this->service = new NoticeService();
+    }
+
+    /**
+     * 设置置顶
+     * @return mixed
+     * @since 2020/11/21
+     * @author laravel开发员
+     */
+    public function setIsTop()
+    {
+        $result = $this->service->setIsTop();
+        return $result;
+    }
+
+}

+ 49 - 0
app/Http/Controllers/Admin/PositionController.php

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

+ 72 - 0
app/Http/Controllers/Admin/RoleController.php

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

+ 83 - 0
app/Http/Controllers/Admin/UploadController.php

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

+ 49 - 0
app/Http/Controllers/Admin/UserController.php

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

+ 26 - 0
app/Http/Controllers/Api/LangController.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+use App\Services\RedisService;
+
+/**
+ * 语言控制器基类
+ * Class LangController
+ * @package App\Http\Controllers\Api
+ */
+class LangController extends webApp
+{
+    /**
+     * 切换语言
+     * @return array
+     */
+    public function switch(){
+        $locale = request()->get('locale');
+        if(empty($locale)){
+            return message('2101',false);
+        }
+        RedisService::set("stores:locale:lang_{$this->userId}", $locale, 24 * 3600);
+        session('lang_locale', $locale);
+        return message(2102);
+    }
+}

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

@@ -0,0 +1,62 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use App\Helpers\Jwt;
+use App\Services\RedisService;
+
+/**
+ * 授权登录控制器基类
+ * Class LoginController
+ * @package App\Http\Controllers
+ */
+class LoginController extends webApp
+{
+    /**
+     * 用户登录
+     * @return array
+     */
+    public function login(){
+        $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()
+    {
+
+    }
+
+    public function sendmsm()
+    {
+        $username = request()->post('username');
+        return message(1011, true);
+    }
+}

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

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+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('你好啊');
+    }
+}

+ 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;
+    }
+
+}

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

@@ -0,0 +1,97 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers;
+use Illuminate\Support\Facades\DB;
+
+/**
+ * 控制器基类
+ */
+class BaseController extends \Illuminate\Routing\Controller
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/10
+     * BaseController constructor.
+     */
+    public function __construct()
+    {
+        // 初始化网络请求配置
+        $this->initRequestConfig();
+
+        // 初始化系统常量
+        $this->initSystemConst();
+    }
+
+    /**
+     * 初始化请求配置
+     * @since 2020/11/10
+     * @author laravel开发员
+     */
+    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 laravel开发员
+     * @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 . "/temp");
+
+        // 定义普通图片域名
+        defined('IMG_URL') or define('IMG_URL', env('IMG_URL'));
+
+        // 数据表前缀
+        defined('DB_PREFIX') or define('DB_PREFIX', DB::connection()->getTablePrefix());
+
+        // 系统全称
+        define('SITE_NAME', env('SITE_NAME'));
+        // 系统简称
+        define('NICK_NAME', env('NICK_NAME'));
+        // 系统版本号
+        define('VERSION', env('VERSION'));
+    }
+
+}

+ 71 - 0
app/Http/Kernel.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace App\Http;
+
+use App\Http\Middleware\EnableCrossRequestMiddleware;
+use Illuminate\Foundation\Http\Kernel as HttpKernel;
+
+class Kernel extends HttpKernel
+{
+    /**
+     * The application's global HTTP middleware stack.
+     *
+     * These middleware are run during every request to your application.
+     *
+     * @var array
+     */
+    protected $middleware = [
+        // \App\Http\Middleware\TrustHosts::class,
+        \App\Http\Middleware\TrustProxies::class,
+        \Fruitcake\Cors\HandleCors::class,
+        \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
+        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
+        \App\Http\Middleware\TrimStrings::class,
+        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
+        \App\Http\Middleware\EnableCrossRequestMiddleware::class,
+    ];
+
+    /**
+     * The application's route middleware groups.
+     *
+     * @var array
+     */
+    protected $middlewareGroups = [
+        'web' => [
+            \App\Http\Middleware\EncryptCookies::class,
+            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
+            \Illuminate\Session\Middleware\StartSession::class,
+            // \Illuminate\Session\Middleware\AuthenticateSession::class,
+            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
+//            \App\Http\Middleware\VerifyCsrfToken::class,
+            \Illuminate\Routing\Middleware\SubstituteBindings::class,
+        ],
+
+        'api' => [
+//            'throttle:api',
+            \Illuminate\Routing\Middleware\SubstituteBindings::class,
+            \Illuminate\Session\Middleware\StartSession::class,
+        ],
+    ];
+
+    /**
+     * The application's route middleware.
+     *
+     * These middleware may be assigned to groups or used individually.
+     *
+     * @var array
+     */
+    protected $routeMiddleware = [
+        'auth' => \App\Http\Middleware\Authenticate::class,
+        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
+        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
+        'can' => \Illuminate\Auth\Middleware\Authorize::class,
+        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
+        'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
+        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
+        '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,
+    ];
+}

+ 24 - 0
app/Http/Middleware/ActionLog.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use App\Models\ActionLogModel;
+use Closure;
+
+class ActionLog
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param \Illuminate\Http\Request $request
+     * @param \Closure $next
+     * @return mixed
+     */
+    public function handle($request, Closure $next)
+    {
+        if ($request->isMethod('post')) {
+            ActionLogModel::record();
+        }
+        return $next($request);
+    }
+}

+ 21 - 0
app/Http/Middleware/Authenticate.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Auth\Middleware\Authenticate as Middleware;
+
+class Authenticate extends Middleware
+{
+    /**
+     * Get the path the user should be redirected to when they are not authenticated.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return string|null
+     */
+    protected function redirectTo($request)
+    {
+        if (! $request->expectsJson()) {
+            return route('login');
+        }
+    }
+}

+ 54 - 0
app/Http/Middleware/EnableCrossRequestMiddleware.php

@@ -0,0 +1,54 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Middleware;
+
+use Closure;
+use Illuminate\Http\Request;
+
+/**
+ * 跨域解决方案
+ * @author laravel开发员
+ * @since 2021/1/10
+ * Class EnableCrossRequestMiddleware
+ * @package App\Http\Middleware
+ */
+class EnableCrossRequestMiddleware
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param \Illuminate\Http\Request $request
+     * @param \Closure $next
+     * @return mixed
+     */
+    public function handle(Request $request, Closure $next)
+    {
+        $response = $next($request);
+        $origin = $request->server('HTTP_ORIGIN') ? $request->server('HTTP_ORIGIN') : '';
+        $allow_origin = [];
+        if (empty($allow_origin) || in_array($origin, $allow_origin)) {
+            //允许所有资源跨域
+            $response->header('Access-Control-Allow-Origin', $origin);
+            // 允许通过的响应报头
+            $response->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Cookie, X-CSRF-TOKEN, Accept, Authorization, X-XSRF-TOKEN');
+            // 允许axios获取响应头中的Authorization
+            $response->header('Access-Control-Expose-Headers', 'Authorization, authenticated');
+            // 允许的请求方法
+            $response->header('Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, OPTIONS, DELETE');
+            //允许的请求方法
+            $response->header('Allow', 'GET, POST, PATCH, PUT, OPTIONS, delete');
+            // 运行客户端携带证书式访问
+            $response->header('Access-Control-Allow-Credentials', 'true');
+        }
+        return $response;
+    }
+}

+ 17 - 0
app/Http/Middleware/EncryptCookies.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
+
+class EncryptCookies extends Middleware
+{
+    /**
+     * The names of the cookies that should not be encrypted.
+     *
+     * @var array
+     */
+    protected $except = [
+        //
+    ];
+}

+ 17 - 0
app/Http/Middleware/PreventRequestsDuringMaintenance.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
+
+class PreventRequestsDuringMaintenance extends Middleware
+{
+    /**
+     * The URIs that should be reachable while maintenance mode is enabled.
+     *
+     * @var array
+     */
+    protected $except = [
+        //
+    ];
+}

+ 32 - 0
app/Http/Middleware/RedirectIfAuthenticated.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use App\Providers\RouteServiceProvider;
+use Closure;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+
+class RedirectIfAuthenticated
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Closure  $next
+     * @param  string|null  ...$guards
+     * @return mixed
+     */
+    public function handle(Request $request, Closure $next, ...$guards)
+    {
+        $guards = empty($guards) ? [null] : $guards;
+
+        foreach ($guards as $guard) {
+            if (Auth::guard($guard)->check()) {
+                return redirect(RouteServiceProvider::HOME);
+            }
+        }
+
+        return $next($request);
+    }
+}

+ 18 - 0
app/Http/Middleware/TrimStrings.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
+
+class TrimStrings extends Middleware
+{
+    /**
+     * The names of the attributes that should not be trimmed.
+     *
+     * @var array
+     */
+    protected $except = [
+        'password',
+        'password_confirmation',
+    ];
+}

+ 20 - 0
app/Http/Middleware/TrustHosts.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Http\Middleware\TrustHosts as Middleware;
+
+class TrustHosts extends Middleware
+{
+    /**
+     * Get the host patterns that should be trusted.
+     *
+     * @return array
+     */
+    public function hosts()
+    {
+        return [
+            $this->allSubdomainsOfApplicationUrl(),
+        ];
+    }
+}

+ 23 - 0
app/Http/Middleware/TrustProxies.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Fideloper\Proxy\TrustProxies as Middleware;
+use Illuminate\Http\Request;
+
+class TrustProxies extends Middleware
+{
+    /**
+     * The trusted proxies for this application.
+     *
+     * @var array|string|null
+     */
+    protected $proxies;
+
+    /**
+     * The headers that should be used to detect proxies.
+     *
+     * @var int
+     */
+    protected $headers = Request::HEADER_X_FORWARDED_ALL;
+}

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

@@ -0,0 +1,50 @@
+<?php
+
+
+namespace App\Http\Middleware;
+
+use App\Helpers\Jwt;
+use App\Services\RedisService;
+use Closure;
+use Illuminate\Auth\Middleware\Authenticate as Middleware;
+
+class UserLogin extends Middleware
+{
+    /**
+     * 执行句柄
+     * @param \Illuminate\Http\Request $request
+     * @param Closure $next
+     * @param mixed ...$guards
+     * @return mixed
+     * @throws \Illuminate\Auth\AuthenticationException
+     * @since 2020/8/31
+     * @author laravel开发员
+     */
+    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'];
+        $token = $request->headers->get('Authorization');
+        if (strpos($token, 'Bearer ') !== false) {
+            $token = str_replace("Bearer ", null, $token);
+            // JWT解密token
+            $jwt = new Jwt();
+            $userId = $jwt->verifyToken($token);
+
+        } else {
+            $userId = 0;
+        }
+
+        if (!$userId && !in_array($controller, $noLoginActs)) {
+            // 判断用户未登录就跳转至登录页面
+            // 在这里可以定制你想要的返回格式, 亦或者是 JSON 编码格式
+            return response()->json(message("请登录", false, null, 401));
+        }
+        //如果已登录则执行正常的请求
+        return $response;
+    }
+}

+ 17 - 0
app/Http/Middleware/VerifyCsrfToken.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
+
+class VerifyCsrfToken extends Middleware
+{
+    /**
+     * The URIs that should be excluded from CSRF verification.
+     *
+     * @var array
+     */
+    protected $except = [
+        //
+    ];
+}

+ 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 1008;
+            }
+
+            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;
+    }
+}

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

@@ -0,0 +1,47 @@
+<?php
+namespace App\Http\Validator;
+class MemberValidator extends BaseValidator
+{
+    // 当前模型所有验证规则
+    public static $rules = [
+        'id' => 'required',
+        'avatar' => 'required',
+        'nickname' => 'required',
+        'gender' => 'required',
+    ];
+
+    // 当前模型所有错误提示信息
+    public static $msgs = [
+        'required' => ':attribute不能为空',
+        'string' => ':attribute必须是字符串',
+        'min' => ':attribute长度不能小于:min位',
+        'max' => ':attribute长度不能大于:max位',
+        'exists' => ':attribute不存在',
+        'rule' => ':attribute格式不正确',
+    ];
+
+    // 当前模型所有验证字段
+    public static $fields = [
+        'id' => 'ID',
+        'avatar' => '头像',
+        'gender' => '性别',
+        'nickname' => '昵称',
+    ];
+
+    // 当前模型所有验证场景
+    public static $scenes = [
+        'info'=> ['id'],
+        'save'=> ['mobile','nickname','gender'],
+    ];
+
+    /**
+     * 验证
+     * @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);
+    }
+}

+ 2 - 0
app/Lib/phpqrcode/.gitignore

@@ -0,0 +1,2 @@
+.idea/
+temp/*.png

+ 38 - 0
app/Lib/phpqrcode/CHANGELOG

@@ -0,0 +1,38 @@
+* 1.0.0 build 2010031920 
+
+  - first public release
+  - help in readme, install
+  - cleanup ans separation of QRtools and QRspec
+  - now TCPDF binding requires minimal changes in TCPDF, having most of job
+    done in QRtools tcpdfBarcodeArray
+  - nicer QRtools::timeBenchmark output
+  - license and copyright notices in files
+  - indent cleanup - from tab to 4spc, keep it that way please :)
+  - sf project, repository, wiki
+  - simple code generator in index.php
+  
+* 1.1.0 build 2010032113
+
+  - added merge tool wich generate merged version of code
+    located in phpqrcode.php
+  - splited qrconst.php from qrlib.php
+  
+* 1.1.1 build 2010032405
+
+  - patch by Rick Seymour allowing saving PNG and displaying it at the same time
+  - added version info in VERSION file
+  - modified merge tool to include version info into generated file
+  - fixed e-mail in almost all head comments
+  
+* 1.1.2 build 2010032722
+
+  - full integration with TCPDF thanks to Nicola Asuni, it's author
+  - fixed bug with alphanumeric encoding detection
+  
+* 1.1.3 build 2010081807
+
+  - short opening tags replaced with standard ones
+  
+* 1.1.4 build 2010100721
+
+  - added missing static keyword QRinput::check (found by Luke Brookhart, Onjax LLC)

+ 165 - 0
app/Lib/phpqrcode/LICENSE

@@ -0,0 +1,165 @@
+                  GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions.
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version.
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.

File diff suppressed because it is too large
+ 3719 - 0
app/Lib/phpqrcode/QRcode.php


+ 61 - 0
app/Lib/phpqrcode/README

@@ -0,0 +1,61 @@
+This is PHP implementation of QR Code 2-D barcode generator. It is pure-php
+LGPL-licensed implementation based on C libqrencode by Kentaro Fukuchi.
+
+== UPDATE ==
+Added support for eps export
+Usage : QRcode::eps('arguments');
+
+Added support for SVG export
+Usage : QRcode::svg('arguments');
+
+Added support for color export :
+example : 
+$back_color = 0xFFFF00;
+$fore_color = 0xFF00FF;
+QRcode::png('some othertext 1234', false, 'h', 20, 1, false, $back_color, $fore_color);
+
+
+Copyright (C) 2012 by Alexandre Assouad 
+
+== LICENSING ==
+
+Copyright (C) 2010 by Dominik Dzienia 
+
+This library is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free
+Software Foundation; either version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU Lesser General Public License (LICENSE file)
+for more details.
+
+You should have received a copy of the GNU Lesser General Public License along
+with this library; if not, write to the Free Software Foundation, Inc., 51
+Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+== INSTALATION AND USAGE ==
+
+ * INSTALL file
+ * http://sourceforge.net/apps/mediawiki/phpqrcode/index.php?title=Main_Page
+
+== CONTACT ==
+
+Fell free to contact me via e-mail (deltalab at poczta dot fm) or using
+folowing project pages:
+
+ * http://sourceforge.net/projects/phpqrcode/
+ * http://phpqrcode.sourceforge.net/
+  
+== ACKNOWLEDGMENTS ==
+
+Based on C libqrencode library (ver. 3.1.1) 
+Copyright (C) 2006-2010 by Kentaro Fukuchi
+http://megaui.net/fukuchi/works/qrencode/index.en.html
+
+QR Code is registered trademarks of DENSO WAVE INCORPORATED in JAPAN and other
+countries.
+
+Reed-Solomon code encoder is written by Phil Karn, KA9Q.
+Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q
+ 

+ 2 - 0
app/Lib/phpqrcode/VERSION

@@ -0,0 +1,2 @@
+1.1.4
+2010100721

+ 144 - 0
app/Models/ActionLogModel.php

@@ -0,0 +1,144 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Models;
+
+use Illuminate\Support\Facades\DB;
+
+/**
+ * 行为日志-模型
+ * @author laravel开发员
+ * @since 2020/11/10
+ * Class ActionLogModel
+ * @package App\Models
+ */
+class ActionLogModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = null;
+    // 自定义日志标题
+    protected static $title = '';
+    // 自定义日志内容
+    protected static $content = '';
+
+    public function __construct()
+    {
+        // 设置表名
+        $this->table = 'action_log_' . date('Y') . '_' . date('m');
+        // 初始化行为日志表
+        $this->initTable();
+    }
+
+    /**
+     * 初始化行为日志表
+     * @return string|null
+     * @since 2020/11/10
+     * @author laravel开发员
+     */
+    private function initTable()
+    {
+        $tbl = DB_PREFIX . $this->table;
+        if (!$this->tableExists($tbl)) {
+            $sql = "CREATE TABLE `{$tbl}` (
+                  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '唯一性标识',
+                  `username` varchar(60) CHARACTER SET utf8mb4 NOT NULL COMMENT '操作人用户名',
+                  `method` varchar(20) CHARACTER SET utf8mb4 NOT NULL COMMENT '请求类型',
+                  `module` varchar(30) NOT NULL COMMENT '模型',
+                  `action` varchar(255) NOT NULL COMMENT '操作方法',
+                  `url` varchar(200) CHARACTER SET utf8mb4 NOT NULL COMMENT '操作页面',
+                  `param` text CHARACTER SET utf8mb4 NOT NULL COMMENT '请求参数(JSON格式)',
+                  `title` varchar(100) NOT NULL COMMENT '日志标题',
+                  `type` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '操作类型:1登录系统 2注销系统',
+                  `content` varchar(1000) NOT NULL DEFAULT '' COMMENT '内容',
+                  `ip` varchar(18) CHARACTER SET utf8mb4 NOT NULL COMMENT 'IP地址',
+                  `user_agent` varchar(360) CHARACTER SET utf8mb4 NOT NULL COMMENT 'User-Agent',
+                  `create_user` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加人',
+                  `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
+                  `update_user` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新人',
+                  `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
+                  `mark` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '有效标识:1正常 0删除',
+                  PRIMARY KEY (`id`) USING BTREE
+                ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='系统行为日志表';";
+            DB::select($sql);
+        }
+        return $tbl;
+    }
+
+    /**
+     * 设置标题
+     * @param $title 标题
+     * @since 2020/11/10
+     * @author laravel开发员
+     */
+    public static function setTitle($title)
+    {
+        self::$title = $title;
+    }
+
+    /**
+     * 设置内容
+     * @param $content 内容
+     * @since 2020/11/10
+     * @author laravel开发员
+     */
+    public static function setContent($content)
+    {
+        self::$content = $content;
+    }
+
+    /**
+     * 创建行为日志
+     * @author laravel开发员
+     * @since 2020/11/10
+     */
+    public static function record()
+    {
+        if (!self::$title) {
+            // 操作控制器名
+            $menuModel = new MenuModel();
+            $info = $menuModel->getOne([
+                ['url', '=', request()->url()],
+            ]);
+            if ($info) {
+                if ($info['type'] == 1) {
+                    $menuInfo = $menuModel->getInfo($info['pid']);
+                    self::$title = $menuInfo['title'];
+                } else {
+                    self::$title = $info['title'];
+                }
+            }
+        }
+
+        // 登录用户ID
+        $userId = session('userId');
+        $userModel = new UserModel();
+        $userInfo = $userModel->getInfo($userId);
+
+        // 日志数据
+        $data = [
+            'username' => isset($userInfo['username']) ? $userInfo['username'] : '未知',
+            'module' => 'admin',
+            'action' => request()->path(),
+            'method' => request()->method(),
+            'url' => request()->url(true), // 获取完成URL
+            'param' => request()->all() ? json_encode(request()->all()) : '',
+            'title' => self::$title ? self::$title : '操作日志',
+            'type' => self::$title == '登录系统' ? 1 : (self::$title == '注销系统' ? 2 : 0),
+            'content' => self::$content,
+            'ip' => request()->ip(),
+            'user_agent' => request()->server('HTTP_USER_AGENT'),
+            'create_user' => empty(session('userId')) ? 0 : session('userId'),
+            'create_time' => time(),
+        ];
+        // 日志入库
+        self::insert($data);
+    }
+}

+ 61 - 0
app/Models/AdModel.php

@@ -0,0 +1,61 @@
+<?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 AdModel
+ * @package App\Models
+ */
+class AdModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'ad';
+
+    /**
+     * 获取广告信息
+     * @param int $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['cover']) {
+                $info['cover'] = get_image_url($info['cover']);
+            }
+            // 开始时间
+            if ($info['start_time']) {
+                $info['start_time'] = datetime($info['start_time']);
+            }
+            // 结束时间
+            if ($info['end_time']) {
+                $info['end_time'] = datetime($info['end_time']);
+            }
+            // 广告位
+            if ($info['ad_sort_id']) {
+                $adSortModel = new AdSortModel();
+                $adSortInfo = $adSortModel->getInfo($info['ad_sort_id']);
+                if ($adSortInfo) {
+                    $info['ad_sort_name'] = $adSortInfo['description'] . ">>" . $adSortInfo['loc_id'];
+                }
+            }
+        }
+        return $info;
+    }
+
+}

+ 40 - 0
app/Models/AdSortModel.php

@@ -0,0 +1,40 @@
+<?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 AdSortModel
+ * @package App\Models
+ */
+class AdSortModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'ad_sort';
+
+    public function getInfo($id)
+    {
+        $info = parent::getInfo($id); // TODO: Change the autogenerated stub
+        if ($info) {
+            // 获取栏目名称
+            if ($info['cate_id']) {
+                $itemCateModel = new ItemCateModel();
+                $itemCateName = $itemCateModel->getCateName($info['cate_id'], ">>");
+                $info['item_cate_name'] = $itemCateName;
+            }
+        }
+        return $info;
+    }
+
+}

File diff suppressed because it is too large
+ 1253 - 0
app/Models/BaseModel.php


+ 291 - 0
app/Models/CacheModel.php

@@ -0,0 +1,291 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Cache;
+
+/**
+ * 缓存模型
+ * @author zongjl
+ * @date 2019/5/23
+ * Class CacheModel
+ * @package App\Models
+ */
+class CacheModel extends Model
+{
+    // 是否启用缓存
+    protected $is_cache = true;
+
+    /**
+     * 重置缓存
+     * @param int $id 记录ID
+     * @param array $data 数据源
+     * @param bool $is_edit 是否编辑
+     * @return bool 返回结果
+     * @author zongjl
+     * @date 2019/5/23
+     */
+    public function cacheReset($id, $data = [], $is_edit = false)
+    {
+        if (!$data) {
+            $this->resetCacheFunc('info', $id);
+        }
+        $info = [];
+        if ($is_edit) {
+            $info = $this->getCacheFunc("info", $id);
+        }
+        if (is_array($data)) {
+            $info = array_merge($info, $data);
+        } else {
+            $info = $data;
+        }
+        $cache_key = $this->getCacheKey('info', $id);
+        $result = $this->setCache($cache_key, $info);
+        return $result;
+    }
+
+    /**
+     * 删除缓存
+     * @param int $id 删除缓存ID
+     * @return bool 返回true或false
+     * @author zongjl
+     * @date 2019/5/23
+     */
+    public function cacheDelete($id)
+    {
+        $cache_key = $this->getCacheKey("info", $id);
+        $result = $this->deleteCache($cache_key);
+        return $result;
+    }
+
+    /**
+     * 设置单条数据缓存
+     * @param int $id 记录ID
+     * @return array 返回结果
+     * @author zongjl
+     * @date 2019/5/23
+     */
+    public function cacheInfo($id)
+    {
+        if (!$id) {
+            return false;
+        }
+        $data = $this->find((int)$id);
+        return $data ? $data->toArray() : [];
+    }
+
+    /**
+     * 获取缓存KEY
+     * @return string 缓存KEY
+     * @author zongjl
+     * @date 2019/5/23
+     */
+    public function getCacheKey()
+    {
+        $arg_list = func_get_args();
+        if ($this->table) {
+            array_unshift($arg_list, $this->table);
+        }
+        foreach ($arg_list as $key => $val) {
+            if (is_array($val)) {
+                unset($arg_list[$key]);
+            }
+        }
+        $cache_key = implode("_", $arg_list);
+        return $cache_key;
+    }
+
+    /**
+     * 设置缓存
+     * @param string $cache_key 缓存KEY
+     * @param array $data 缓存数据
+     * @param int $ttl 过期时间
+     * @return bool 返回结果
+     * @author zongjl
+     * @date 2019/5/23
+     */
+    public function setCache($cache_key, $data, $ttl = 0)
+    {
+        if (isset($GLOBALS['trans']) && $GLOBALS['trans'] === true) {
+            $GLOBALS['trans_keys'][] = $cache_key;
+        }
+
+        // 不设置缓存,直接返回
+        if (!$this->is_cache) {
+            return true;
+        }
+        if (!$data) {
+            return Cache::put($cache_key, null, $ttl);
+        }
+        $isGzcompress = gzcompress(json_encode($data));
+        if ($isGzcompress) {
+            $result = Cache::put($cache_key, $isGzcompress);
+        }
+        return $result;
+    }
+
+    /**
+     * 获取缓存
+     * @param string $cache_key 缓存KEY
+     * @return mixed 返回缓存数据
+     * @author zongjl
+     * @date 2019/5/23
+     */
+    public function getCache($cache_key)
+    {
+        $data = Cache::get($cache_key);
+        if ($data) {
+            $data = json_decode(gzuncompress($data), true);
+        }
+        return $data;
+    }
+
+    /**
+     * 删除缓存
+     * @param string $cache_key 缓存KEY
+     * @return bool 返回结果true或false
+     * @author zongjl
+     * @date 2019/5/23
+     */
+    public function deleteCache($cache_key)
+    {
+        // 判断缓存键值是否存在,存在则删除
+        if (Cache::has($cache_key)) {
+            return Cache::forget($cache_key);
+        }
+        return false;
+    }
+
+    /**
+     * 设置缓存函数
+     * @param string $funcName 方法名
+     * @param string $id 缓存数据ID
+     * @return bool 返回结果true或false
+     * @author zongjl
+     * @date 2019/5/23
+     */
+    public function resetCacheFunc($funcName, $id = '')
+    {
+        // 获取缓存KEY
+        $cache_key = $this->getCacheKey($funcName, $id);
+        // 删除缓存
+        $result = $this->deleteCache($cache_key);
+
+        // 设置缓存
+        $arg_list = func_get_args();
+        if ($this->table) {
+            array_shift($arg_list);
+        }
+        $act = "cache" . ucfirst($funcName);
+        $data = call_user_func_array(array($this, $act), $arg_list);
+        return $this->setCache($cache_key, $data);
+    }
+
+    /**
+     * 获取缓存函数
+     * @param string $funcName 方法名
+     * @param string $id 缓存数据ID
+     * @return mixed 返回结果
+     * @author zongjl
+     * @date 2019/5/23
+     */
+    public function getCacheFunc($funcName, $id = '')
+    {
+        $cache_key = $this->getCacheKey($funcName, $id);
+        $data = $this->getCache($cache_key);
+        if (!$data) {
+            $arg_list = func_get_args();
+            if ($this->table) {
+                array_shift($arg_list);
+            }
+            $act = "cache" . ucfirst($funcName);
+            $data = call_user_func_array(array($this, $act), $arg_list);
+            $this->setCache($cache_key, $data, rand(3, 5));
+        }
+        return $data;
+    }
+
+    /**
+     * 获取整表缓存
+     * @param array $map 查询条件
+     * @param bool $is_pri 是否只缓存主键true或false
+     * @param bool $pri_key 是否以主键作为键值true或false
+     * @return mixed 返回结果
+     * @author zongjl
+     * @date 2019/6/5
+     */
+    public function getAll($map = [], $is_pri = false, $pri_key = false)
+    {
+        $list = $this->getCacheFunc('all', $map, $is_pri, $pri_key);
+        return $list;
+    }
+
+    /**
+     * 设置整表缓存
+     * @param array $map 查询条件
+     * @param bool $is_pri 是否只缓存主键true或false
+     * @param bool $pri_key 是否以主键作为键值true或false
+     * @return mixed 返回结果
+     * @author zongjl
+     * @date 2019/6/5
+     */
+    public function cacheAll($map = [], $is_pri = false, $pri_key = false)
+    {
+        // 必备查询条件
+        $map[] = ['mark', '=', 1];
+
+        // 格式化查询条件
+        if (method_exists($this, 'formatQuery')) {
+            $query = $this->formatQuery($this, $map);
+        }
+
+        // 是否缓存主键
+        if ($is_pri) {
+            if (is_array($is_pri)) {
+                // 字段数组
+                $query->select($is_pri);
+            } elseif (is_string($is_pri)) {
+                // 字段字符串
+                $fields = explode(',', $is_pri);
+                $query->select($fields);
+            } else {
+                // 默认主键ID
+                $query->select('id');
+            }
+        }
+
+        // 查询数据并转数组
+        $list = $query->get()->toArray();
+
+        // 设置主键ID为数组键值
+        if ($pri_key) {
+            $list = array_column($list, null, 'id');
+        }
+
+        return $list;
+    }
+
+    /**
+     * 重置全表缓存
+     * @param array $map 查询条件
+     * @param bool $is_pri 是否只缓存主键true或false
+     * @param bool $pri_key 是否以主键作为键值true或false
+     * @return bool 返回结果true(重置成功)或false(重置失败)
+     * @author zongjl
+     * @date 2019/6/5
+     */
+    public function cacheResetAll($map = [], $is_pri = false, $pri_key = false)
+    {
+        return $this->resetCacheFunc('all', $map, $is_pri, $pri_key);
+    }
+}

+ 25 - 0
app/Models/CityModel.php

@@ -0,0 +1,25 @@
+<?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 CityModel
+ * @package App\Models
+ */
+class CityModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'city';
+}

+ 25 - 0
app/Models/ConfigGroupModel.php

@@ -0,0 +1,25 @@
+<?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 ConfigGroupModel
+ * @package App\Models
+ */
+class ConfigGroupModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'config_group';
+}

+ 25 - 0
app/Models/ConfigModel.php

@@ -0,0 +1,25 @@
+<?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 ConfigModel
+ * @package App\Models
+ */
+class ConfigModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'config';
+}

+ 72 - 0
app/Models/ItemCateModel.php

@@ -0,0 +1,72 @@
+<?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 ItemCateModel
+ * @package App\Models
+ */
+class ItemCateModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'item_cate';
+
+    /**
+     * 获取记录信息
+     * @param int $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['cover']) {
+                $info['cover'] = get_image_url($info['cover']);
+            }
+        }
+        return $info;
+    }
+
+    /**
+     * 获取栏目名称
+     * @param $cateId 栏目ID
+     * @param string $delimiter 分隔符
+     * @return string|null
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function getCateName($cateId, $delimiter = "")
+    {
+        do {
+            $info = $this->getInfo($cateId);
+            $names[] = $info['name'];
+            $cateId = $info['pid'];
+        } while ($cateId > 0);
+        if (!empty($names)) {
+            $names = array_reverse($names);
+            if (count($names) >= 2) {
+                if (strpos($names[1], $names[0]) === 0) {
+                    unset($names[0]);
+                }
+            }
+            return implode($delimiter, $names);
+        }
+        return null;
+    }
+
+}

+ 45 - 0
app/Models/ItemModel.php

@@ -0,0 +1,45 @@
+<?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 ItemModel
+ * @package App\Models
+ */
+class ItemModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'item';
+
+    /**
+     * 获取数据信息
+     * @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']);
+            }
+        }
+        return $info;
+    }
+
+}

+ 49 - 0
app/Models/LayoutDescModel.php

@@ -0,0 +1,49 @@
+<?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 LayoutDescModel
+ * @package App\Models
+ */
+class LayoutDescModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'layout_desc';
+
+    /**
+     * 获取数据信息
+     * @param int $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['item_id']) {
+                $itemModel = new ItemModel();
+                $itemInfo = $itemModel->getInfo($info['item_id']);
+                if ($itemInfo) {
+                    $info['item_name'] = $itemInfo['name'];
+                }
+            }
+        }
+        return $info;
+    }
+
+}

+ 54 - 0
app/Models/LayoutModel.php

@@ -0,0 +1,54 @@
+<?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 LayoutModel
+ * @package App\Models
+ */
+class LayoutModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'layout';
+
+    /**
+     * 获取数据信息
+     * @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['item_id']) {
+                $itemModel = new ItemModel();
+                $itemInfo = $itemModel->getInfo($info['item_id']);
+                if ($itemInfo) {
+                    $info['item_name'] = $itemInfo['name'];
+                }
+            }
+        }
+        return $info;
+    }
+
+}

+ 25 - 0
app/Models/LevelModel.php

@@ -0,0 +1,25 @@
+<?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 LevelModel
+ * @package App\Models
+ */
+class LevelModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'level';
+}

+ 25 - 0
app/Models/MemberLevelModel.php

@@ -0,0 +1,25 @@
+<?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 MemberLevelModel
+ * @package App\Models
+ */
+class MemberLevelModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'member_level';
+}

+ 57 - 0
app/Models/MemberModel.php

@@ -0,0 +1,57 @@
+<?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 MemberModel
+ * @package App\Models
+ */
+class MemberModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'member';
+
+    /**
+     * 获取会员信息
+     * @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['avatar']) {
+                $info['avatar'] = get_image_url($info['avatar']);
+            }
+            // 出生日期
+            if ($info['birthday']) {
+                $info['birthday'] = datetime($info['birthday']);
+            }
+            // 城市
+            if ($info['province_id'] && $info['city_id'] && $info['district_id']) {
+                $city = [];
+                $city[] = $info['province_id'];
+                $city[] = $info['city_id'];
+                $city[] = $info['district_id'];
+                $info['city'] = $city;
+            }
+        }
+        return $info;
+    }
+
+}

+ 59 - 0
app/Models/MenuModel.php

@@ -0,0 +1,59 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Models;
+
+
+use Ramsey\Uuid\Type\Integer;
+
+/**
+ * 菜单管理-模型
+ * @author laravel开发员
+ * @since 2020/11/10
+ * Class MenuModel
+ * @package App\Models
+ */
+class MenuModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'menu';
+
+
+    /**
+     * 获取子级菜单列表
+     * @param $pid 父级ID
+     * @return mixed
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function getChilds($pid)
+    {
+        // 查询条件
+        $map = [];
+        // 父级ID
+        $map[] = ['pid', '=', $pid];
+        // 菜单状态
+        $map[] = ['status', '=', 1];
+        // 只取菜单
+        $map[] = ['type', '=', 0];
+        // 有效标识
+        $map[] = ['mark', '=', 1];
+
+        $list = $this->where($map)->orderBy("sort", "asc")->get()->toArray();
+        if (!empty($list)) {
+            foreach ($list as &$val) {
+                $val['children'] = $this->getChilds($val['id']);
+            }
+        }
+        return $list;
+    }
+
+}

+ 25 - 0
app/Models/NoticeModel.php

@@ -0,0 +1,25 @@
+<?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 NoticeModel
+ * @package App\Models
+ */
+class NoticeModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'notice';
+}

+ 25 - 0
app/Models/RoleMenuModel.php

@@ -0,0 +1,25 @@
+<?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 RoleMenuModel
+ * @package App\Models
+ */
+class RoleMenuModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'role_menu';
+}

+ 25 - 0
app/Models/RoleModel.php

@@ -0,0 +1,25 @@
+<?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 RoleModel
+ * @package App\Models
+ */
+class RoleModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'role';
+}

+ 52 - 0
app/Models/User.php

@@ -0,0 +1,52 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Models;
+
+use Illuminate\Contracts\Auth\MustVerifyEmail;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Foundation\Auth\User as Authenticatable;
+use Illuminate\Notifications\Notifiable;
+
+class User extends Authenticatable
+{
+    use HasFactory, Notifiable;
+
+    /**
+     * The attributes that are mass assignable.
+     *
+     * @var array
+     */
+    protected $fillable = [
+        'name',
+        'email',
+        'password',
+    ];
+
+    /**
+     * The attributes that should be hidden for arrays.
+     *
+     * @var array
+     */
+    protected $hidden = [
+        'password',
+        'remember_token',
+    ];
+
+    /**
+     * The attributes that should be cast to native types.
+     *
+     * @var array
+     */
+    protected $casts = [
+        'email_verified_at' => 'datetime',
+    ];
+}

+ 56 - 0
app/Models/UserModel.php

@@ -0,0 +1,56 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Models;
+
+use App\Services\Common\UserRoleService;
+
+/**
+ * 会员管理-模型
+ * @author laravel开发员
+ * @since 2020/11/10
+ * Class AdminModel
+ * @package App\Models
+ */
+class UserModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'user';
+
+    /**
+     * 获取数据信息
+     * @param int $id 用户ID
+     * @return array|string
+     * @author laravel开发员
+     * @since 2020/11/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']);
+            }
+
+            // 性别
+            if ($info['gender']) {
+                $info['gender_name'] = config('admin.gender_list')[$info['gender']];
+            }
+
+            // 获取用户角色列表
+            $userRoleService = new UserRoleService();
+            $roleList = $userRoleService->getUserRoleList($id);
+            $info['roles'] = $roleList;
+        }
+        return $info;
+    }
+}

+ 26 - 0
app/Models/UserRoleModel.php

@@ -0,0 +1,26 @@
+<?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 UserRoleModel
+ * @package App\Models
+ */
+class UserRoleModel extends BaseModel
+{
+    // 设置数据表
+    protected $table = 'user_role';
+
+}

+ 45 - 0
app/Providers/AppServiceProvider.php

@@ -0,0 +1,45 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Providers;
+
+use Illuminate\Support\ServiceProvider;
+
+class AppServiceProvider extends ServiceProvider
+{
+    /**
+     * Register any application services.
+     *
+     * @return void
+     */
+    public function register()
+    {
+        //
+        \DB::listen(function ($query) {
+            $bindings = $query->bindings;
+            $sql = $query->sql;
+            foreach ($bindings as $replace) {
+                $value = is_numeric($replace) ? $replace : "'" . $replace . "'";
+                $sql = preg_replace('/\?/', $value, $sql, 1);
+            }
+        });
+    }
+
+    /**
+     * Bootstrap any application services.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        //
+    }
+}

+ 30 - 0
app/Providers/AuthServiceProvider.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Providers;
+
+use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
+use Illuminate\Support\Facades\Gate;
+
+class AuthServiceProvider extends ServiceProvider
+{
+    /**
+     * The policy mappings for the application.
+     *
+     * @var array
+     */
+    protected $policies = [
+        // 'App\Models\Model' => 'App\Policies\ModelPolicy',
+    ];
+
+    /**
+     * Register any authentication / authorization services.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        $this->registerPolicies();
+
+        //
+    }
+}

+ 21 - 0
app/Providers/BroadcastServiceProvider.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Providers;
+
+use Illuminate\Support\Facades\Broadcast;
+use Illuminate\Support\ServiceProvider;
+
+class BroadcastServiceProvider extends ServiceProvider
+{
+    /**
+     * Bootstrap any application services.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        Broadcast::routes();
+
+        require base_path('routes/channels.php');
+    }
+}

+ 32 - 0
app/Providers/EventServiceProvider.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Providers;
+
+use Illuminate\Auth\Events\Registered;
+use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
+use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
+use Illuminate\Support\Facades\Event;
+
+class EventServiceProvider extends ServiceProvider
+{
+    /**
+     * The event listener mappings for the application.
+     *
+     * @var array
+     */
+    protected $listen = [
+        Registered::class => [
+            SendEmailVerificationNotification::class,
+        ],
+    ];
+
+    /**
+     * Register any events for your application.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        //
+    }
+}

+ 63 - 0
app/Providers/RouteServiceProvider.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace App\Providers;
+
+use Illuminate\Cache\RateLimiting\Limit;
+use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\RateLimiter;
+use Illuminate\Support\Facades\Route;
+
+class RouteServiceProvider extends ServiceProvider
+{
+    /**
+     * The path to the "home" route for your application.
+     *
+     * This is used by Laravel authentication to redirect users after login.
+     *
+     * @var string
+     */
+    public const HOME = '/home';
+
+    /**
+     * The controller namespace for the application.
+     *
+     * When present, controller route declarations will automatically be prefixed with this namespace.
+     *
+     * @var string|null
+     */
+    // protected $namespace = 'App\\Http\\Controllers';
+
+    /**
+     * Define your route model bindings, pattern filters, etc.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        $this->configureRateLimiting();
+
+        $this->routes(function () {
+            Route::prefix('api')
+                ->middleware('api','web.login')
+                ->namespace($this->namespace)
+                ->group(base_path('routes/api.php'));
+
+            Route::middleware('web')
+                ->namespace($this->namespace)
+                ->group(base_path('routes/web.php'));
+        });
+    }
+
+    /**
+     * Configure the rate limiters for the application.
+     *
+     * @return void
+     */
+    protected function configureRateLimiting()
+    {
+        RateLimiter::for('api', function (Request $request) {
+            return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
+        });
+    }
+}

+ 230 - 0
app/Services/BaseService.php

@@ -0,0 +1,230 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services;
+
+/**
+ * 服务基类
+ * @author laravel开发员
+ * @since 2020/11/10
+ * Class BaseService
+ * @package App\Services
+ */
+class BaseService
+{
+    // 模型
+    protected $model;
+    // 验证类
+    protected $validate;
+
+    /**
+     * 获取数据列表
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function getList()
+    {
+        // 初始化变量
+        $map = [];
+        $sort = [['id', 'desc']];
+        $is_sql = 0;
+
+        // 获取参数
+        $argList = func_get_args();
+        if (!empty($argList)) {
+            // 查询条件
+            $map = (isset($argList[0]) && !empty($argList[0])) ? $argList[0] : [];
+            // 排序
+            $sort = (isset($argList[1]) && !empty($argList[1])) ? $argList[1] : [['id', 'desc']];
+            // 是否打印SQL
+            $is_sql = isset($argList[2]) ? isset($argList[2]) : 0;
+        }
+
+        // 打印SQL
+        if ($is_sql) {
+            $this->model->getLastSql(1);
+        }
+
+        // 常规查询条件
+        $param = request()->input();
+        if ($param) {
+            // 筛选名称
+            if (isset($param['name']) && $param['name']) {
+                $map[] = ['name', 'like', "%{$param['name']}%"];
+            }
+
+            // 筛选标题
+            if (isset($param['title']) && $param['title']) {
+                $map[] = ['title', 'like', "%{$param['title']}%"];
+            }
+
+            // 筛选类型
+            if (isset($param['type']) && $param['type']) {
+                $map[] = ['type', '=', $param['type']];
+            }
+
+            // 筛选状态
+            if (isset($param['status']) && $param['status']) {
+                $map[] = ['status', '=', $param['status']];
+            }
+
+            // 手机号码
+            if (isset($param['mobile']) && $param['mobile']) {
+                $map[] = ['mobile', '=', $param['mobile']];
+            }
+        }
+
+        // 设置查询条件
+        if (is_array($map)) {
+            $map[] = ['mark', '=', 1];
+        } elseif ($map) {
+            $map .= " AND mark=1 ";
+        } else {
+            $map .= " mark=1 ";
+        }
+
+        // 排序(支持多重排序)
+        $query = $this->model->where($map)->when($sort, function ($query, $sort) {
+            foreach ($sort as $v) {
+                $query->orderBy($v[0], $v[1]);
+            }
+        });
+        // 分页条件
+        $offset = (PAGE - 1) * PERPAGE;
+        $result = $query->offset($offset)->limit(PERPAGE)->select('id')->get();
+        $result = $result ? $result->toArray() : [];
+        $list = [];
+        if (is_array($result)) {
+            foreach ($result as $val) {
+                $info = $this->model->getInfo($val['id']);
+                $list[] = $info;
+            }
+        }
+
+        //获取数据总数
+        $count = $this->model->where($map)->count();
+
+        //返回结果
+        $message = array(
+            "msg" => '操作成功',
+            "code" => 0,
+            "data" => $list,
+            "count" => $count,
+        );
+        return $message;
+    }
+
+    /**
+     * 获取记录详情
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function info()
+    {
+        // 记录ID
+        $id = request()->input("id", 0);
+        $info = [];
+        if ($id) {
+            $info = $this->model->getInfo($id);
+        }
+        return message(MESSAGE_OK, true, $info);
+    }
+
+    /**
+     * 添加或编辑记录
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function edit()
+    {
+        // 获取参数
+        $argList = func_get_args();
+        // 查询条件
+        $data = isset($argList[0]) ? $argList[0] : [];
+        // 是否打印SQL
+        $is_sql = isset($argList[1]) ? $argList[1] : false;
+        if (!$data) {
+            $data = request()->all();
+        }
+        $error = '';
+        $rowId = $this->model->edit($data, $error, $is_sql);
+        if ($rowId) {
+            return message();
+        }
+        return message($error, false);
+    }
+
+    /**
+     * 删除记录
+     * @return array
+     * @since 2020/11/12
+     * @author laravel开发员
+     */
+    public function delete()
+    {
+        // 参数
+        $param = request()->all();
+        // 记录ID
+        $ids = getter($param, "id");
+        if (empty($ids)) {
+            return message("记录ID不能为空", false);
+        }
+        if (is_array($ids)) {
+            // 批量删除
+            $result = $this->model->deleteAll($ids);
+            if (!$result) {
+                return message("删除失败", false);
+            }
+            return message("删除成功");
+        } else {
+            // 单个删除
+            $info = $this->model->getInfo($ids);
+            if ($info) {
+                $result = $this->model->drop($ids);
+                if ($result !== false) {
+                    return message();
+                }
+            }
+            return message($this->model->getError(), false);
+        }
+    }
+
+    /**
+     * 设置记录状态
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function status()
+    {
+        $data = request()->all();
+        if (!$data['id']) {
+            return message('记录ID不能为空', false);
+        }
+        if (!$data['status']) {
+            return message('记录状态不能为空', false);
+        }
+        $error = '';
+        $item = [
+            'id' => $data['id'],
+            'status' => $data['status']
+        ];
+        $rowId = $this->model->edit($item, $error);
+        if (!$rowId) {
+            return message($error, false);
+        }
+        return message();
+    }
+
+}

+ 37 - 0
app/Services/Common/ActionLogService.php

@@ -0,0 +1,37 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+
+use App\Models\ActionLogModel;
+use App\Services\BaseService;
+
+/**
+ * 行为日志-服务类
+ * @author laravel开发员
+ * @since 2020/11/12
+ * Class ActionLogService
+ * @package App\Services\Common
+ */
+class ActionLogService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/12
+     * ActionLogService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new ActionLogModel();
+    }
+}

+ 64 - 0
app/Services/Common/AdService.php

@@ -0,0 +1,64 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\AdModel;
+use App\Services\BaseService;
+
+/**
+ * 广告管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class AdService
+ * @package App\Services\Common
+ */
+class AdService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * AdService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new AdModel();
+    }
+
+    /**
+     * 添加或编辑
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function edit()
+    {
+        $data = request()->all();
+        // 图片处理
+        $cover = trim($data['cover']);
+        if (strpos($cover, "temp")) {
+            $data['cover'] = save_image($cover, 'ad');
+        } else {
+            $data['cover'] = str_replace(IMG_URL, "", $data['cover']);
+        }
+        // 开始时间
+        if ($data['start_time']) {
+            $data['start_time'] = strtotime($data['start_time']);
+        }
+        // 结束时间
+        if ($data['end_time']) {
+            $data['end_time'] = strtotime($data['end_time']);
+        }
+        return parent::edit($data); // TODO: Change the autogenerated stub
+    }
+
+}

+ 49 - 0
app/Services/Common/AdSortService.php

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

+ 72 - 0
app/Services/Common/CityService.php

@@ -0,0 +1,72 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\CityModel;
+use App\Services\BaseService;
+
+/**
+ * 城市管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class CityService
+ * @package App\Services\Common
+ */
+class CityService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * CityService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new CityModel();
+    }
+
+    /**
+     * 获取城市列表
+     * @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];
+        }
+        // 城市名称
+        $name = getter($param, "name");
+        if ($name) {
+            $map[] = ['name', 'like', "%{$name}%"];
+        }
+        $list = $this->model->getList($map, [['sort', 'asc']]);
+        if (!empty($list)) {
+            foreach ($list as &$val) {
+                if ($val['level'] <= 2) {
+                    $val['hasChildren'] = true;
+                }
+            }
+        }
+        return message("操作成功", true, $list);
+    }
+
+}

+ 36 - 0
app/Services/Common/ConfigGroupService.php

@@ -0,0 +1,36 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\ConfigGroupModel;
+use App\Services\BaseService;
+
+/**
+ * 配置分组-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class ConfigGroupService
+ * @package App\Services\Common
+ */
+class ConfigGroupService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * ConfigGroupService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new ConfigGroupModel();
+    }
+}

+ 62 - 0
app/Services/Common/ConfigService.php

@@ -0,0 +1,62 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\ConfigModel;
+use App\Services\BaseService;
+
+/**
+ * 配置管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class ConfigService
+ * @package App\Services\Common
+ */
+class ConfigService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * ConfigService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new ConfigModel();
+    }
+
+    /**
+     * 获取配置列表
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function getList()
+    {
+        $param = request()->all();
+        // 查询条件
+        $map = [];
+        // 配置分组ID
+        $configgroupId = getter($param, "configgroupId", 0);
+        if ($configgroupId) {
+            $map[] = ['config_group_id', '=', $configgroupId];
+        }
+        // 配置标题
+        $title = getter($param, "title");
+        if ($title) {
+            $map[] = ['name', 'title', "%{$title}%"];
+        }
+        $list = $this->model->getList($map, [['sort', 'asc']]);
+        return message("操作成功", true, $list);
+    }
+
+}

+ 75 - 0
app/Services/Common/LoginLogService.php

@@ -0,0 +1,75 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\ActionLogModel;
+use App\Services\BaseService;
+
+/**
+ * 登录日志-服务类
+ * @author laravel开发员
+ * @since 2020/11/12
+ * Class LoginLogService
+ * @package App\Services\Common
+ */
+class LoginLogService extends BaseService
+{
+    /**
+     *
+     * @author laravel开发员
+     * @since 2020/11/12
+     * LoginLogService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new ActionLogModel();
+    }
+
+    /**
+     *
+     * @return array
+     * @since 2020/11/12
+     * @author laravel开发员
+     */
+    public function getList()
+    {
+        // 查询条件
+        $param = request()->all();
+
+        // 查询条件
+        $query = $this->model->where(function ($query) {
+            $query->where('title', 'like', '%登录系统%')
+                ->orWhere('title', 'like', '%注销系统%');
+        });
+        // 用户账号
+        $username = getter($param, "username");
+        if ($username) {
+            $query = $query->where("username", "=", $username);
+        }
+
+        //获取数据总数
+        $count = $query->count();
+
+        // 获取数据列表
+        $offset = (PAGE - 1) * PERPAGE;
+        $result = $query->orderByDesc("id")->offset($offset)->limit(PERPAGE)->get()->toArray();
+        //返回结果
+        $message = array(
+            "msg" => '操作成功',
+            "code" => 0,
+            "data" => $result,
+            "count" => $count,
+        );
+        return $message;
+    }
+
+}

+ 176 - 0
app/Services/Common/LoginService.php

@@ -0,0 +1,176 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Helpers\Jwt;
+use App\Models\ActionLogModel;
+use App\Models\UserModel;
+use App\Services\BaseService;
+use Carbon\Carbon;
+use Illuminate\Support\Facades\Session;
+use Illuminate\Support\Facades\Validator;
+use Gregwar\Captcha\CaptchaBuilder;
+use Gregwar\Captcha\PhraseBuilder;
+use Ramsey\Uuid\Uuid;
+
+/**
+ * 登录服务类
+ * @author laravel开发员
+ * @since 2020/11/10
+ * Class LoginService
+ * @package App\Services\Common
+ */
+class LoginService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/10
+     * LoginService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new UserModel();
+    }
+
+    /**
+     * 获取验证码
+     * @author laravel开发员
+     * @since 2020/11/10
+     */
+    public function captcha()
+    {
+        $phrase = new PhraseBuilder;
+        // 设置验证码位数
+        $code = $phrase->build(4);
+        // 生成验证码图片的Builder对象,配置相应属性
+        $builder = new CaptchaBuilder($code, $phrase);
+        // 设置背景颜色25,25,112
+        $builder->setBackgroundColor(255, 255, 255);
+        // 设置倾斜角度
+        $builder->setMaxAngle(25);
+        // 设置验证码后面最大行数
+        $builder->setMaxBehindLines(10);
+        // 设置验证码前面最大行数
+        $builder->setMaxFrontLines(10);
+        // 设置验证码颜色
+        $builder->setTextColor(230, 81, 175);
+        // 可以设置图片宽高及字体
+        $builder->build($width = 165, $height = 45, $font = null);
+        // 获取验证码的内容
+        $phrase = $builder->getPhrase();
+        // 把内容存入 cache,10分钟后过期
+        $key = Uuid::uuid1()->toString();
+        $this->model->setCache($key, $phrase, Carbon::now()->addMinutes(10));
+        // 组装接口数据
+        $data = [
+            'key' => $key,
+            'captcha' => $builder->inline(),
+        ];
+        return message("操作成功", true, $data);
+    }
+
+    /**
+     * 系统登录
+     * @return mixed
+     * @since 2020/11/10
+     * @author laravel开发员
+     */
+    public function login()
+    {
+        // 参数
+        $param = request()->all();
+        // 用户名
+        $username = trim($param['username']);
+        // 密码
+        $password = trim($param['password']);
+        // 验证规则
+        $rules = [
+            'username' => 'required|min:2|max:20',
+            'password' => 'required|min:6|max:20',
+            'captcha' => ['required'],
+        ];
+        // 规则描述
+        $messages = [
+            'required' => ':attribute为必填项',
+            'min' => ':attribute长度不符合要求',
+            'captcha.required' => '验证码不能为空',
+        ];
+        // 验证
+        $validator = Validator::make($param, $rules, $messages, [
+            'username' => '用户名称',
+            'password' => '登录密码'
+        ]);
+        if ($validator->fails()) {
+            $errors = $validator->errors()->getMessages();
+            foreach ($errors as $key => $value) {
+                return message($value[0], false);
+            }
+        }
+        // 验证码校验
+        $key = trim($param['key']);
+        $captcha = $this->model->getCache($key);
+        if (strtolower($captcha) != strtolower($param['captcha'])) {
+            return message("请输入正确的验证码", false);
+        }
+
+        // 用户验证
+        $info = $this->model->getOne([
+            ['username', '=', $username],
+        ]);
+
+        if (!$info) {
+            return message('您的登录用户名不存在', false);
+        }
+        // 密码校验
+        $password = get_password($password . $username);
+        if ($password != $info['password']) {
+            return message("您的登录密码不正确", false);
+        }
+        // 使用状态校验
+        if ($info['status'] != 1) {
+            return message("您的帐号已被禁用", false);
+        }
+
+        // 设置日志标题
+        ActionLogModel::setTitle("登录系统");
+        ActionLogModel::record();
+
+        // JWT生成token
+        $jwt = new Jwt();
+        $token = $jwt->getToken($info['id']);
+
+        // 结果返回
+        $result = [
+            'access_token' => $token,
+        ];
+        return message('登录成功', true, $result);
+    }
+
+    /**
+     * 退出系统
+     * @return array
+     * @since 2020/11/12
+     * @author laravel开发员
+     */
+    public function logout()
+    {
+        // 清空SESSION值
+        session()->put("userId", null);
+        // 记录退出日志
+        ActionLogModel::setTitle("注销系统");
+        // 创建退出日志
+        ActionLogModel::record();
+        return message();
+    }
+
+}

+ 49 - 0
app/Services/Common/MemberLevelService.php

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

+ 72 - 0
app/Services/Common/MemberService.php

@@ -0,0 +1,72 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\MemberModel;
+use App\Services\BaseService;
+
+/**
+ * 会员管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class MemberService
+ * @package App\Services\Common
+ */
+class MemberService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * MemberService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new MemberModel();
+    }
+
+    /**
+     * 添加会编辑会员
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function edit()
+    {
+        // 请求参数
+        $data = request()->all();
+        // 头像处理
+        $avatar = trim($data['avatar']);
+        if (strpos($avatar, "temp")) {
+            $data['avatar'] = save_image($avatar, 'member');
+        } else {
+            $data['avatar'] = str_replace(IMG_URL, "", $data['avatar']);
+        }
+        // 出生日期
+        if ($data['birthday']) {
+            $data['birthday'] = strtotime($data['birthday']);
+        }
+        // 城市处理
+        $city = isset($data['city']) ? $data['city'] : [3];
+        if (!empty($data['city'])) {
+            // 省份
+            $data['province_id'] = $city[0];
+            // 城市
+            $data['city_id'] = $city[1];
+            // 县区
+            $data['district_id'] = $city[2];
+        }
+        unset($data['city']);
+        return parent::edit($data); // TODO: Change the autogenerated stub
+    }
+
+}

+ 304 - 0
app/Services/Common/MenuService.php

@@ -0,0 +1,304 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+
+use App\Models\MenuModel;
+use App\Services\BaseService;
+
+/**
+ * 菜单管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/10
+ * Class MenuService
+ * @package App\Services\Common
+ */
+class MenuService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * MenuService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new MenuModel();
+    }
+
+    /**
+     * 获取数据列表
+     * @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];
+        }
+
+        // 菜单标题
+        $title = getter($param, "title");
+        if ($title) {
+            $map[] = ['title', 'like', "%{$title}%"];
+        }
+        $list = $this->model->getList($map, [['sort', 'asc']]);
+        if (!empty($list)) {
+            foreach ($list as &$val) {
+                if ($val['type'] == 0) {
+                    $val['hasChildren'] = true;
+                }
+            }
+        }
+        return message("操作成功", true, $list);
+    }
+
+    /**
+     * 获取菜单详情
+     * @return array
+     * @since 2021/4/10
+     * @author laravel开发员
+     */
+    public function info()
+    {
+        // 记录ID
+        $id = request()->input("id", 0);
+        $info = [];
+        if ($id) {
+            $info = $this->model->getInfo($id);
+        }
+        // 获取权限节点
+        $checkedList = array();
+        if ($info['type'] == 0) {
+            $permissionList = $this->model
+                ->select("sort")
+                ->where("pid", "=", $info['id'])
+                ->where("mark", "=", 1)
+                ->get()
+                ->toArray();
+            if (is_array($permissionList)) {
+                $checkedList = array_key_value($permissionList, "sort");
+            }
+            $info['checkedList'] = $checkedList;
+        }
+        return message(MESSAGE_OK, true, $info);
+    }
+
+    /**
+     * 添加或编辑
+     * @return array
+     * @since 2021/4/10
+     * @author laravel开发员
+     */
+    public function edit()
+    {
+        // 参数
+        $param = request()->all();
+        // 权限节点
+        $checkedList = isset($param['checkedList']) ? $param['checkedList'] : array();
+        unset($param['checkedList']);
+        // 保存数据
+        $result = $this->model->edit($param);
+        if (!$result) {
+            return message("操作失败", false);
+        }
+
+        // 设置权限节点
+        if ($param['type'] == 0 && !empty($param['path']) && !empty($checkedList)) {
+            $item = explode("/", $param['path']);
+            // 模块名称
+            $moduleName = $item[count($item) - 1];
+            // 模块标题
+            $moduleTitle = str_replace("管理", "", $param['title']);
+            // 遍历权限节点
+            foreach ($checkedList as $val) {
+                $data = [];
+                $data['pid'] = $result;
+                $data['type'] = 1;
+                $data['status'] = 1;
+                $data['sort'] = intval($val);
+                $data['target'] = $param['target'];
+
+                // 判断当前节点是否已存在
+                $permissionInfo = $this->model
+                    ->where("pid", "=", $result)
+                    ->where("type", "=", 1)
+                    ->where("sort", "=", $val)
+                    ->where("mark", "=", 1)
+                    ->first();
+                if ($permissionInfo) {
+                    $data['id'] = $permissionInfo['id'];
+                }
+                if ($val == 1) {
+                    // 查询
+                    $data['title'] = "查询" . $moduleTitle;
+                    $data['permission'] = "sys:{$moduleName}:index";
+                } else if ($val == 5) {
+                    // 添加
+                    $data['title'] = "添加" . $moduleTitle;
+                    $data['permission'] = "sys:{$moduleName}:add";
+                } else if ($val == 10) {
+                    // 修改
+                    $data['title'] = "修改" . $moduleTitle;
+                    $data['permission'] = "sys:{$moduleName}:edit";
+                } else if ($val == 15) {
+                    // 删除
+                    $data['title'] = "删除" . $moduleTitle;
+                    $data['permission'] = "sys:{$moduleName}:delete";
+                } else if ($val == 20) {
+                    // 状态
+                    $data['title'] = "设置状态";
+                    $data['permission'] = "sys:{$moduleName}:status";
+                } else if ($val == 25) {
+                    // 批量删除
+                    $data['title'] = "批量删除";
+                    $data['permission'] = "sys:{$moduleName}:dall";
+                } else if ($val == 30) {
+                    // 全部展开
+                    $data['title'] = "全部展开";
+                    $data['permission'] = "sys:{$moduleName}:expand";
+                } else if ($val == 35) {
+                    // 全部折叠
+                    $data['title'] = "全部折叠";
+                    $data['permission'] = "sys:{$moduleName}:collapse";
+                } else if ($val == 40) {
+                    // 添加子级
+                    $data['title'] = "添加子级";
+                    $data['permission'] = "sys:{$moduleName}:addz";
+                } else if ($val == 45) {
+                    // 导出数据
+                    $data['title'] = "导出数据";
+                    $data['permission'] = "sys:{$moduleName}:export";
+                } else if ($val == 50) {
+                    // 导入数据
+                    $data['title'] = "导入数据";
+                    $data['permission'] = "sys:{$moduleName}:import";
+                } else if ($val == 55) {
+                    // 分配权限
+                    $data['title'] = "分配权限";
+                    $data['permission'] = "sys:{$moduleName}:permission";
+                }
+                if (empty($data['title'])) {
+                    continue;
+                }
+                $menuModel = new MenuModel();
+                $menuModel->edit($data);
+            }
+        }
+        return message();
+    }
+
+    /**
+     * 获取权限菜单列表
+     * @param $userId
+     * @return array
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function getPermissionList($userId)
+    {
+        $list = [];
+        if ($userId == 1) {
+            // 管理员拥有全部权限
+            $list = $this->model->getChilds(0);
+        } else {
+            // 其他角色
+            $list = $this->getPermissionMenu($userId, 0);
+        }
+        return message("操作成功", true, $list);
+    }
+
+    /**
+     * 获取菜单权限列表
+     * @param $userId 用户ID
+     * @param $pid 上级ID
+     * @return mixed
+     * @since 2020/11/14
+     * @author laravel开发员
+     */
+    public function getPermissionMenu($userId, $pid = 0)
+    {
+        $menuModel = new MenuModel();
+        $menuList = $menuModel::from("menu as m")
+            ->select('m.*')
+            ->join('role_menu as rm', 'rm.menu_id', '=', 'm.id')
+            ->join('user_role as ur', 'ur.role_id', '=', 'rm.role_id')
+            ->distinct(true)
+            ->where('ur.user_id', '=', $userId)
+            ->where('m.type', '=', 0)
+            ->where('m.pid', '=', $pid)
+            ->where('m.status', '=', 1)
+            ->where('m.mark', '=', 1)
+            ->orderBy('m.pid')
+            ->orderBy('m.sort')
+            ->get()->toArray();
+        if (!empty($menuList)) {
+            foreach ($menuList as &$val) {
+                $childList = $this->getPermissionMenu($userId, $val['id']);
+                if (is_array($childList) && !empty($childList)) {
+                    $val['children'] = $childList;
+                }
+            }
+        }
+        return $menuList;
+    }
+
+    /**
+     * 获取权限节点
+     * @param $userId 用户ID
+     * @return array
+     * @author laravel开发员
+     * @since 2021/4/9
+     */
+    public function getPermissionsList($userId)
+    {
+        $list = [];
+        if ($userId == 1) {
+            // 管理员拥有全部权限
+            $permissionList = $this->model
+                ->select("permission")
+                ->where("type", "=", 1)
+                ->where("mark", "=", 1)
+                ->get()
+                ->toArray();
+            $list = empty($permissionList) ? array() : array_key_value($permissionList, 'permission');
+        } else {
+            // 其他角色
+            $menuModel = new MenuModel();
+            $permissionList = $menuModel::from("menu as m")
+                ->select('m.permission')
+                ->join('role_menu as rm', 'rm.menu_id', '=', 'm.id')
+                ->join('user_role as ur', 'ur.role_id', '=', 'rm.role_id')
+                ->distinct(true)
+                ->where('ur.user_id', '=', $userId)
+                ->where('m.type', '=', 1)
+                ->where('m.status', '=', 1)
+                ->where('m.mark', '=', 1)
+                ->orderBy('m.pid')
+                ->orderBy('m.sort')
+                ->get()
+                ->toArray();
+            $list = empty($permissionList) ? array() : array_key_value($permissionList, 'permission');
+        }
+        return array_filter(array_values($list));
+    }
+
+}

+ 64 - 0
app/Services/Common/NoticeService.php

@@ -0,0 +1,64 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\NoticeModel;
+use App\Services\BaseService;
+
+/**
+ * 通知公告-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class NoticeService
+ * @package App\Services\Common
+ */
+class NoticeService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * NoticeService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new NoticeModel();
+    }
+
+    /**
+     * 设置置顶
+     * @return array
+     * @since 2020/11/21
+     * @author laravel开发员
+     */
+    public function setIsTop()
+    {
+        $data = request()->all();
+        if (!$data['id']) {
+            return message('记录ID不能为空', false);
+        }
+        if (!$data['is_top']) {
+            return message('设置置顶不能为空', false);
+        }
+        $error = '';
+        $item = [
+            'id' => $data['id'],
+            'is_top' => $data['is_top']
+        ];
+        $rowId = $this->model->edit($item, $error);
+        if (!$rowId) {
+            return message($error, false);
+        }
+        return message();
+    }
+
+}

+ 26 - 0
app/Services/Common/RoleMenuService.php

@@ -0,0 +1,26 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Services\BaseService;
+
+/**
+ * 角色菜单关系-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class RoleMenuService
+ * @package App\Services\Common
+ */
+class RoleMenuService extends BaseService
+{
+
+}

+ 122 - 0
app/Services/Common/RoleService.php

@@ -0,0 +1,122 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\MenuModel;
+use App\Models\RoleMenuModel;
+use App\Models\RoleModel;
+use App\Services\BaseService;
+
+/**
+ * 角色管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class RoleService
+ * @package App\Services\Common
+ */
+class RoleService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * RoleService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new RoleModel();
+    }
+
+    /**
+     * 获取角色列表
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function getRoleList()
+    {
+        $list = $this->model->where([
+            ['status', '=', 1],
+            ['mark', '=', 1],
+        ])->orderBy("sort", "asc")
+            ->get()
+            ->toArray();
+        return message("操作成功", true, $list);
+    }
+
+    /**
+     * 获取角色权限列表
+     * @return mixed
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function getPermissionList()
+    {
+        // 请求参数
+        $param = request()->all();
+        // 角色ID
+        $roleId = intval(getter($param, "role_id", 0));
+        // 获取全部菜单
+        $menuModel = new MenuModel();
+        $menuList = $menuModel->where([
+            ['status', '=', 1],
+            ['mark', '=', 1],
+        ])->orderBy("sort", "asc")->get()->toArray();
+        if (!empty($menuList)) {
+            $roleMenuModel = new RoleMenuModel();
+            $roleMenuList = $roleMenuModel->where("role_id", $roleId)->get("menu_id")->toArray();
+            $menuIdList = array_key_value($roleMenuList, "menu_id");
+            foreach ($menuList as &$val) {
+                if (in_array($val['id'], $menuIdList)) {
+                    $val['checked'] = true;
+                    $val['open'] = true;
+                }
+            }
+        }
+        return message(MESSAGE_OK, true, $menuList);
+    }
+
+    /**
+     * 保存角色菜单权限数据
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function savePermission()
+    {
+        // 请求参数
+        $param = request()->all();
+        // 角色ID
+        $roleId = intval(getter($param, "role_id", 0));
+        if (!$roleId) {
+            return message("角色ID不能为空", false);
+        }
+        unset($param['role_id']);
+        // 删除角色菜单关系数据
+        $roleMenuModel = new RoleMenuModel();
+        $roleMenuModel->where("role_id", $roleId)->delete();
+        // 插入角色菜单关系数据
+        if (is_array($param) && !empty($param)) {
+            $list = [];
+            foreach ($param as $val) {
+                $data = [
+                    'role_id' => $roleId,
+                    'menu_id' => $val,
+                ];
+                $list[] = $data;
+            }
+        }
+        $roleMenuModel->insert($list);
+        return message();
+    }
+
+}

+ 92 - 0
app/Services/Common/UserRoleService.php

@@ -0,0 +1,92 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\UserRoleModel;
+use App\Services\BaseService;
+
+/**
+ * 用户角色关系-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class UserRoleService
+ * @package App\Services\Common
+ */
+class UserRoleService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * UserRoleService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new UserRoleModel();
+    }
+
+    /**
+     * 根据用户ID获取角色列表
+     * @param $userId 用户ID
+     * @return mixed
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function getUserRoleList($userId)
+    {
+        $userRoleModel = new UserRoleModel();
+        $roleList = $userRoleModel::from("role as r")
+            ->select('r.*')
+            ->join('user_role as ur', 'ur.role_id', '=', 'r.id')
+            ->distinct(true)
+            ->where('ur.user_id', '=', $userId)
+            ->where('r.status', '=', 1)
+            ->where('r.mark', '=', 1)
+            ->orderBy('r.sort')
+            ->get()->toArray();
+        return $roleList;
+    }
+
+    /**
+     * 删除用户角色关系数据
+     * @param $userId 用户ID
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function deleteUserRole($userId)
+    {
+        $this->model->where("user_id", '=', $userId)->delete();
+    }
+
+    /**
+     * 批量插入用户角色关系数据
+     * @param $userId 用户ID
+     * @param $roleIds 角色ID集合
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function insertUserRole($userId, $roleIds)
+    {
+        if (!empty($roleIds)) {
+            $list = [];
+            foreach ($roleIds as $val) {
+                $data = [
+                    'user_id' => $userId,
+                    'role_id' => $val,
+                ];
+                $list[] = $data;
+            }
+            $this->model->insert($list);
+        }
+    }
+
+}

+ 254 - 0
app/Services/Common/UserService.php

@@ -0,0 +1,254 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Services\Common;
+
+use App\Models\UserModel;
+use App\Services\BaseService;
+
+/**
+ * 用户管理-服务类
+ * @author laravel开发员
+ * @since 2020/11/11
+ * Class UserService
+ * @package App\Services\Common
+ */
+class UserService extends BaseService
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     * UserService constructor.
+     */
+    public function __construct()
+    {
+        $this->model = new UserModel();
+    }
+
+    /**
+     * 获取用户列表
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function getList()
+    {
+        $param = request()->all();
+
+        // 查询条件
+        $map = [];
+
+        // 用户账号
+        $username = getter($param, "username");
+        if ($username) {
+            $map[] = ["username", 'like', "%{$username}%"];
+        }
+        // 用户姓名
+        $realname = getter($param, "realname");
+        if ($realname) {
+            $map[] = ['realname', 'like', "%{$realname}%"];
+        }
+        // 用户性别
+        $gender = getter($param, "gender");
+        if ($gender) {
+            $map[] = ['gender', '=', $gender];
+        }
+        return parent::getList($map); // TODO: Change the autogenerated stub
+    }
+
+    /**
+     * 添加或编辑用户
+     * @return array
+     * @since 2020/11/11
+     * @author laravel开发员
+     */
+    public function edit()
+    {
+        // 请求参数
+        $data = request()->all();
+        // 用户名
+        $username = trim($data['username']);
+        // 密码
+        $password = trim($data['password']);
+
+        // 添加时设置密码
+        if (empty($data['id'])) {
+            $data['password'] = get_password($password . $username);
+            // 用户名重复性验证
+            $count = $this->model
+                ->where("username", '=', $username)
+                ->where("mark", "=", 1)
+                ->count();
+            if ($count > 0) {
+                return message("系统中已存在相同的用户名", false);
+            }
+        } else {
+            // 用户名重复性验证
+            $count = $this->model
+                ->where("username", '=', $username)
+                ->where("id", "<>", $data['id'])
+                ->where("mark", "=", 1)
+                ->count();
+            if ($count > 0) {
+                return message("系统中已存在相同的用户名", false);
+            }
+        }
+
+
+        // 头像处理
+        $avatar = isset($data['avatar']) ? trim($data['avatar']) : '';
+        if (strpos($avatar, "temp")) {
+            $data['avatar'] = save_image($avatar, 'user');
+        } else {
+            $data['avatar'] = str_replace(IMG_URL, "", $data['avatar']);
+        }
+        $error = "";
+        $result = $this->model->edit($data, $error);
+        if (!$result) {
+            return message($error, false);
+        }
+        // 删除已存在的用户角色关系数据
+        $userRoleService = new UserRoleService();
+        $userRoleService->deleteUserRole($result);
+        // 插入用户角色关系数据
+        $userRoleService->insertUserRole($result, $data['role_ids']);
+        return message();
+    }
+
+    /**
+     * 获取用户信息
+     * @param $userId 用户ID
+     * @return array
+     * @author laravel开发员
+     * @since 2020/11/10
+     */
+    public function getUserInfo($userId)
+    {
+        $userInfo = $this->model->getInfo($userId);
+        $userInfo['roles'] = [];
+        $userInfo['authorities'] = [];
+        // 权限节点列表
+        $menuService = new MenuService();
+        $permissionList = $menuService->getPermissionsList($userId);
+        $userInfo['permissionList'] = $permissionList;
+        return message("操作成功", true, $userInfo);
+    }
+
+    /**
+     * 更新个人资料
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function updateUserInfo($userId)
+    {
+        // 参数
+        $param = request()->all();
+        // 个人信息
+        $data = [
+            'id' => $userId,
+            'realname' => $param['realname'],
+            'nickname' => $param['nickname'],
+            'gender' => $param['gender'],
+            'mobile' => $param['mobile'],
+            'email' => $param['email'],
+            'intro' => $param['intro'],
+        ];
+        // 头像处理
+        $avatar = isset($param['avatar']) ? $param['avatar'] : "";
+        if (strpos($avatar, "data:image") !== false) {
+            $expData = explode(';', $avatar);
+            $fileInfo = explode('/', $expData[0]);
+            $fileExt = $fileInfo[1] == 'jpeg' ? 'jpg' : $fileInfo[1];
+            // 文件存储路径
+            $filePath = create_image_path("user", $fileExt);
+
+            // 获取图片流
+            $item = explode(',', $avatar);
+            file_put_contents(ATTACHMENT_PATH . $filePath, base64_decode($item[1]));
+
+            $data['avatar'] = $filePath;
+        } else {
+            $data['avatar'] = str_replace(IMG_URL, "", $param['avatar']);
+        }
+        $result = $this->model->edit($data);
+        if (!$result) {
+            return message("更新资料信息失败", false);
+        }
+        return message("更新资料信息成功");
+    }
+
+    /**
+     * 更新密码
+     * @param $userId 用户ID
+     * @return array
+     * @author laravel开发员
+     * @since 2020/11/14
+     */
+    public function updatePwd($userId)
+    {
+        // 获取参数
+        $param = request()->all();
+        // 原始密码
+        $oldPassword = trim(getter($param, "oldPassword"));
+        if (!$oldPassword) {
+            return message("旧密码不能为空", false);
+        }
+        // 新密码
+        $newPassword = trim(getter($param, "newPassword"));
+        if (!$newPassword) {
+            return message("新密码不能为空", false);
+        }
+        $userInfo = $this->model->getInfo($userId);
+        if (!$userInfo) {
+            return message("用户信息不存在", false);
+        }
+        if ($userInfo['password'] != get_password($oldPassword . $userInfo['username'])) {
+            return message("旧密码输入不正确", false);
+        }
+        // 设置新密码
+        $userInfo['password'] = get_password($newPassword . $userInfo['username']);
+        $result = $this->model->edit($userInfo);
+        if (!$result) {
+            return message("修改失败", false);
+        }
+        return message("修改成功");
+    }
+
+    /**
+     * 重置密码
+     * @return array
+     * @since 2020/11/14
+     * @author laravel开发员
+     */
+    public function resetPwd()
+    {
+        // 获取参数
+        $param = request()->all();
+        // 用户ID
+        $userId = getter($param, "id");
+        if (!$userId) {
+            return message("用户ID不能为空", false);
+        }
+        $userInfo = $this->model->getInfo($userId);
+        if (!$userInfo) {
+            return message("用户信息不存在", false);
+        }
+        // 设置新密码
+        $userInfo['password'] = get_password("123456" . $userInfo['username']);
+        $result = $this->model->edit($userInfo);
+        if (!$result) {
+            return message("重置密码失败", false);
+        }
+        return message("重置密码成功");
+    }
+
+}

+ 0 - 0
app/Services/ConfigGroupService.php


Some files were not shown because too many files changed in this diff