shawdonH 2 months ago
commit
92e39a67ac
100 changed files with 6154 additions and 0 deletions
  1. 1 0
      .env
  2. 109 0
      .env.bjcy
  3. 0 0
      .htaccess
  4. 26 0
      404.html
  5. 79 0
      README.md
  6. 160 0
      app/Admin/Controllers/ActivityController.php
  7. 68 0
      app/Admin/Controllers/ActivityRangeController.php
  8. 10 0
      app/Admin/Controllers/AuthController.php
  9. 76 0
      app/Admin/Controllers/BannerController.php
  10. 20 0
      app/Admin/Controllers/ChatController.php
  11. 77 0
      app/Admin/Controllers/DiaryMoodLevelController.php
  12. 75 0
      app/Admin/Controllers/DiaryMoodTagController.php
  13. 79 0
      app/Admin/Controllers/DiarySleepLevelController.php
  14. 67 0
      app/Admin/Controllers/ExampleController.php
  15. 220 0
      app/Admin/Controllers/FourActivityController.php
  16. 23 0
      app/Admin/Controllers/HomeController.php
  17. 96 0
      app/Admin/Controllers/MentalityDrillExtendController.php
  18. 115 0
      app/Admin/Controllers/MentalityDrillsSubjectController.php
  19. 207 0
      app/Admin/Controllers/OpenWeixinController.php
  20. 17 0
      app/Admin/Controllers/RemoteSsoController.php
  21. 33 0
      app/Admin/Controllers/RowAction/CustomAction.php
  22. 101 0
      app/Admin/Controllers/ScaleCategoryController.php
  23. 113 0
      app/Admin/Controllers/ScaleController.php
  24. 96 0
      app/Admin/Controllers/SpecialistColumnController.php
  25. 118 0
      app/Admin/Controllers/SpecialistColumnSecondController.php
  26. 97 0
      app/Admin/Controllers/SpecialistColumnTagController.php
  27. 138 0
      app/Admin/Controllers/SpecialistContentController.php
  28. 75 0
      app/Admin/Controllers/SysConfigController.php
  29. 89 0
      app/Admin/Controllers/SysVersionController.php
  30. 164 0
      app/Admin/Controllers/TrainCategoryController.php
  31. 159 0
      app/Admin/Controllers/TrainDrillController.php
  32. 49 0
      app/Admin/Controllers/UploadController.php
  33. 27 0
      app/Admin/bootstrap.php
  34. 103 0
      app/Admin/routes.php
  35. 41 0
      app/Console/Kernel.php
  36. 64 0
      app/Exceptions/HOError.php
  37. 74 0
      app/Exceptions/Handler.php
  38. 10 0
      app/Exceptions/Repositories/HOException.php
  39. 16 0
      app/Facades/AiChatContentFacade.php
  40. 17 0
      app/Facades/ApiSignFacade.php
  41. 16 0
      app/Facades/BannerFacade.php
  42. 19 0
      app/Facades/BrowseRecordFacade.php
  43. 19 0
      app/Facades/CollectFacade.php
  44. 19 0
      app/Facades/DiaryLetterFacade.php
  45. 23 0
      app/Facades/DiaryMoodFacade.php
  46. 20 0
      app/Facades/DiaryMoodLevelFacade.php
  47. 20 0
      app/Facades/DiaryMoodTagFacade.php
  48. 20 0
      app/Facades/DiarySleepFacade.php
  49. 20 0
      app/Facades/DiarySleepLevelFacade.php
  50. 20 0
      app/Facades/MentalityDrillCategoryFacade.php
  51. 24 0
      app/Facades/MentalityDrillFacade.php
  52. 20 0
      app/Facades/PatientCardFacade.php
  53. 19 0
      app/Facades/RemoteSsoFacade.php
  54. 19 0
      app/Facades/ScaleCategoryFacade.php
  55. 21 0
      app/Facades/ScaleFacade.php
  56. 20 0
      app/Facades/SpecialistCloumnFacade.php
  57. 24 0
      app/Facades/SpecialistInfoFacade.php
  58. 17 0
      app/Facades/StatisticsFacade.php
  59. 20 0
      app/Facades/SysConfigFacade.php
  60. 30 0
      app/Facades/ThirdConsultFacade.php
  61. 16 0
      app/Facades/ThirdH5ChatFacade.php
  62. 20 0
      app/Facades/ThirdScaleFacade.php
  63. 16 0
      app/Facades/ThirdUpFacade.php
  64. 17 0
      app/Facades/ThirdWxFacade.php
  65. 16 0
      app/Facades/UploadFacade.php
  66. 20 0
      app/Facades/UserFacade.php
  67. 19 0
      app/Facades/VersionFacade.php
  68. 22 0
      app/Facades/WxDecryptFacade.php
  69. 15 0
      app/Facades/WxNotificationFacade.php
  70. 23 0
      app/Facades/WxServiceFacade.php
  71. 16 0
      app/Facades/WxServiceKfFacade.php
  72. 17 0
      app/Facades/WxUserFacade.php
  73. 272 0
      app/Helper.php
  74. 72 0
      app/Http/Controllers/Api/V1/BannerController.php
  75. 19 0
      app/Http/Controllers/Api/V1/BaseController.php
  76. 43 0
      app/Http/Controllers/Api/V1/Chat/AiChatController.php
  77. 90 0
      app/Http/Controllers/Api/V1/CommendController.php
  78. 65 0
      app/Http/Controllers/Api/V1/LoginOutController.php
  79. 74 0
      app/Http/Controllers/Api/V1/Mentality/BrowseRecordController.php
  80. 77 0
      app/Http/Controllers/Api/V1/Mentality/CollectController.php
  81. 76 0
      app/Http/Controllers/Api/V1/Mentality/DrillCategoryController.php
  82. 163 0
      app/Http/Controllers/Api/V1/Mentality/DrillController.php
  83. 104 0
      app/Http/Controllers/Api/V1/Mentality/LetterController.php
  84. 87 0
      app/Http/Controllers/Api/V1/Mentality/MoodController.php
  85. 71 0
      app/Http/Controllers/Api/V1/Mentality/MoodLevelController.php
  86. 71 0
      app/Http/Controllers/Api/V1/Mentality/MoodTagController.php
  87. 91 0
      app/Http/Controllers/Api/V1/Mentality/PatientCardController.php
  88. 69 0
      app/Http/Controllers/Api/V1/Mentality/PlayController.php
  89. 71 0
      app/Http/Controllers/Api/V1/Mentality/ScaleCategoryController.php
  90. 98 0
      app/Http/Controllers/Api/V1/Mentality/ScaleController.php
  91. 78 0
      app/Http/Controllers/Api/V1/Mentality/SleepController.php
  92. 71 0
      app/Http/Controllers/Api/V1/Mentality/SleepLevelController.php
  93. 91 0
      app/Http/Controllers/Api/V1/Mentality/StatisticsController.php
  94. 65 0
      app/Http/Controllers/Api/V1/Mentality/WeekController.php
  95. 65 0
      app/Http/Controllers/Api/V1/MpService/JsapiSignController.php
  96. 65 0
      app/Http/Controllers/Api/V1/MpUser/AccessTokenController.php
  97. 79 0
      app/Http/Controllers/Api/V1/MpUser/MpUserController.php
  98. 65 0
      app/Http/Controllers/Api/V1/ScoketConfigController.php
  99. 78 0
      app/Http/Controllers/Api/V1/Specialist/IndexController.php
  100. 148 0
      app/Http/Controllers/Api/V1/Specialist/SpecialistInfoController.php

+ 1 - 0
.env

@@ -0,0 +1 @@
+bjcy

+ 109 - 0
.env.bjcy

@@ -0,0 +1,109 @@
+APP_NAME=cydsyy_produce
+APP_ENV=cydsyy
+APP_KEY=base64:cW0zUlkY/ex0w7M2bkHKaEHs3flBoe0fCb0Jvk/LPuc=
+APP_DEBUG=true
+APP_URL=http://cydsyy-api.qingerai.com/
+
+LOG_CHANNEL=daily
+
+DB_CONNECTION=mysql
+DB_HOST=127.0.0.1
+DB_PORT=3306
+DB_DATABASE=cydsyy
+DB_USERNAME=root
+DB_PASSWORD=root
+
+#DB_CONNECTION=mysql
+#DB_HOST=120.46.162.88
+#DB_PORT=3306
+#DB_DATABASE=cydsyy
+#DB_USERNAME=cydsyy
+#DB_PASSWORD=5mkBa8CxnJ562mBk
+
+BROADCAST_DRIVER=log
+CACHE_DRIVER=file
+QUEUE_CONNECTION=sync
+SESSION_DRIVER=file
+SESSION_LIFETIME=120
+
+REDIS_HOST=127.0.0.1
+REDIS_PASSWORD=null
+REDIS_PORT=6379
+REDIS_CLIENT=predis
+
+MAIL_MAILER=smtp
+MAIL_HOST=smtp.mailtrap.io
+MAIL_PORT=2525
+MAIL_USERNAME=null
+MAIL_PASSWORD=null
+MAIL_ENCRYPTION=null
+MAIL_FROM_ADDRESS=null
+MAIL_FROM_NAME="${APP_NAME}"
+
+AWS_ACCESS_KEY_ID=
+AWS_SECRET_ACCESS_KEY=
+AWS_DEFAULT_REGION=us-east-1
+AWS_BUCKET=
+
+PUSHER_APP_ID=
+PUSHER_APP_KEY=
+PUSHER_APP_SECRET=
+PUSHER_APP_CLUSTER=mt1
+
+MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
+MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
+
+CHECK_API_AUth=false
+FILESYSTEM_DRIVER=public
+
+PIC_PATH='https://cydsyy-api.qingerai.com/'
+
+#天气预报请求地址
+WEATHER_URL='https://tianqiapi.com/free/day?appid=74232635&appsecret=iOi5hazu&cityid=101270301'
+
+#微信服务号	此环境未启用
+MP_APPID=wxdda5ddc92e82fa5f
+MP_APPSECRET=1df69a54692c989099091691fcae5897
+MP_TOKEN=LIlin211Xe3
+MP_ENCODINGAESKEY=S1BY3U3Q6tgp0sR6crjMmX0xKszkWT8YdSMJcnlnshW
+
+#统一微信入口
+THIRDWX_WEID=55
+THIRDWX_KEY='a1f073170fa3e945365ba15746861e141'
+THIRDWX_BACKURL='http://cydsyy-m.qingerai.com/#/pages/login?t=1'
+#THIRDWX_BACKURL='http://localhost:8080/#/pages/login?t=1
+#统一量表
+#THIRDSCALE_APPID='6edP8dV1u79Z9wa1TMGxSg=='
+#THIRDSCALE_KEY='9kcwmtt0m3ri9iQHrHxDEvh497zsj2nY'
+
+#THIRDSCALE_APPID='D+DOHEGhFQP6SQwEhYtYUQ=='
+#THIRDSCALE_KEY='3YmyrNy2Z2JVDMqRaht9J0Z8jp41gCzj'
+
+THIRDSCALE_APPID='vDC3mzAC7OytTDhmrkb8ww=='
+THIRDSCALE_KEY='qSaz3c8qBXyNz3De290aaimu3r7kdZT9'
+
+#统一用户名密码登陆 此环境未启用
+THIRDUP_APPID='6edP8dV1u79Z9wa1TMGxSg=='
+THIRDUP_KEY='9kcwmtt0m3ri9iQHrHxDEvh497zsj2nY'
+
+#统一H5聊天	此环境未启用
+THIRDH5CHAT_APPID='10001'
+THIRDH5CHAT_SECRET='bg32v15a7n9hvfg3ff86fjnbuav4h6jf'
+
+#在线咨询
+THIRDCONSULT_URL='http://zgd5-sync-psy.qingerai.com/api.php'
+THIRDCONSULT_APPID='pNBcapRj+C8wywx0fuLP3g=='
+THIRDCONSULT_SECRET='snEUlDFUUHDJs9dJPH3eDvjGj2j0hxkK'
+THIRDCONSULT_SCOKET_ADDRESS='wss://tyy_cp1.qingerai.com:23902'
+THIRDCONSULT_UPLOAD_URL='https://stjsby-api.qingerai.com/api/third_upload'
+
+
+#AI机器人
+AI_URL='http://124.222.239.66'
+AI_SECRET='app-HJ3rwl4vGkXlTYeMDXPXTOpA'
+
+#远程授权访问
+REMOTE_SSO_APPID='iog+hayCB57Kuo4lyuKWZQ=='
+REMOTE_SSO_SECRET='5wKrVVAbUlZ1nuPMPGXEar3JVnKgQEPu'
+REMOTE_SSO_URL='https://bjcy-visit-sso.qingerai.com'
+

+ 0 - 0
.htaccess


+ 26 - 0
404.html

@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
+<title>404</title>
+<style>
+	body{
+		background-color:#444;
+		font-size:14px;
+	}
+	h3{
+		font-size:60px;
+		color:#eee;
+		text-align:center;
+		padding-top:30px;
+		font-weight:normal;
+	}
+</style>
+</head>
+
+<body>
+<h3>404,您请求的文件不存在!</h3>
+</body>
+</html>

+ 79 - 0
README.md

@@ -0,0 +1,79 @@
+<p align="center"><img src="https://res.cloudinary.com/dtfbvvkyp/image/upload/v1566331377/laravel-logolockup-cmyk-red.svg" width="400"></p>
+
+<p align="center">
+<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
+<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
+</p>
+
+## About Laravel
+
+Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
+
+- [Simple, fast routing engine](https://laravel.com/docs/routing).
+- [Powerful dependency injection container](https://laravel.com/docs/container).
+- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
+- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
+- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
+- [Robust background job processing](https://laravel.com/docs/queues).
+- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
+
+Laravel is accessible, powerful, and provides tools required for large, robust applications.
+
+## Learning Laravel
+
+Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
+
+If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
+
+## Laravel Sponsors
+
+We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
+
+- **[Vehikl](https://vehikl.com/)**
+- **[Tighten Co.](https://tighten.co)**
+- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
+- **[64 Robots](https://64robots.com)**
+- **[Cubet Techno Labs](https://cubettech.com)**
+- **[Cyber-Duck](https://cyber-duck.co.uk)**
+- **[British Software Development](https://www.britishsoftware.co)**
+- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
+- **[DevSquad](https://devsquad.com)**
+- [UserInsights](https://userinsights.com)
+- [Fragrantica](https://www.fragrantica.com)
+- [SOFTonSOFA](https://softonsofa.com/)
+- [User10](https://user10.com)
+- [Soumettre.fr](https://soumettre.fr/)
+- [CodeBrisk](https://codebrisk.com)
+- [1Forge](https://1forge.com)
+- [TECPRESSO](https://tecpresso.co.jp/)
+- [Runtime Converter](http://runtimeconverter.com/)
+- [WebL'Agence](https://weblagence.com/)
+- [Invoice Ninja](https://www.invoiceninja.com)
+- [iMi digital](https://www.imi-digital.de/)
+- [Earthlink](https://www.earthlink.ro/)
+- [Steadfast Collective](https://steadfastcollective.com/)
+- [We Are The Robots Inc.](https://watr.mx/)
+- [Understand.io](https://www.understand.io/)
+- [Abdel Elrafa](https://abdelelrafa.com)
+- [Hyper Host](https://hyper.host)
+- [Appoly](https://www.appoly.co.uk)
+- [OP.GG](https://op.gg)
+- [云软科技](http://www.yunruan.ltd/)
+
+## Contributing
+
+Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
+
+## Code of Conduct
+
+In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
+
+## Security Vulnerabilities
+
+If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
+
+## License
+
+The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

+ 160 - 0
app/Admin/Controllers/ActivityController.php

@@ -0,0 +1,160 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Activity;
+use App\Models\ActivityRange;
+use App\Models\ActivityWorkStation;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ActivityController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '六进活动';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Activity());
+        //权限
+        $grid->actions(function ($actions) {
+
+            // 没有`delete-image`权限的角色不显示删除按钮
+            if (!Admin::user()->can('delete-activite')) {
+                $actions->disableDelete();
+            }
+        });
+
+        $grid->filter(function($filter){
+            $filter->disableIdFilter();
+            // $filter->where(function($query){
+            //     $query->where('activity_range_id=' . $_GET['activity_range_id']);
+            // },'hidden');
+            // 在这里添加字段过滤器
+            $filter->like('title', '活动标题');
+            $filter->equal('organiz_type', '机关类型')->select([1=>'党政机关', 2=>'学校', 3=>'企业', 4=>'公共场所', 5=>'社区', 6=>'农村']);
+            $filter->expand();
+            // $filter->equal('activity_range_id', '活动区域');
+        });
+        //单个区域查询条件
+        if(isset($_GET['belong'])) {
+            $grid->model()->where('belong', '=', $_GET['belong']);
+        }
+
+        $grid->column('id', __('Id'));
+        $grid->column('workstation.name', __('开展单位'));
+        $grid->column('organiz_type', __('单位类型'))->using([1=>'党政机关', 2=>'学校', 3=>'企业', 4=>'公共场所', 5=>'社区', 6=>'农村']);
+        $grid->column('range.name', __('活动区域'));
+        $grid->column('title', __('活动标题'));
+        $grid->column('organiz_name', __('单位名称'));
+        $grid->column('member_num', __('参加人数'));
+        // $grid->column('content', __('活动内容'));
+        // $grid->column('ext', __('附件资料'));
+        $grid->column('active_time', __('活动时间'));
+        $grid->column('creater.name', __('创建者'));
+        $grid->column('updater.name', __('修改者'));
+        // $grid->column('created_at', __('创建时间'));
+        // $grid->column('updated_at', __('修改时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Activity::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('workstation.name', __('开展单位'));
+        $show->field('organiz_type', __('单位类型'))->using([1=>'党政机关', 2=>'学校', 3=>'企业', 4=>'公共场所', 5=>'社区', 6=>'农村']);
+        $show->field('range.name', __('开展区域'));
+        $show->field('title', __('活动标题'));
+        $show->field('active_time', __('活动时间'));
+        $show->field('organiz_name', __('单位名称'));
+        $show->field('member_num', __('参加人数'));
+        $show->field('content', __('活动内容'));
+        $show->field('ext', __('附件资料'));
+        $show->field('creater.name', __('创建者'));
+        $show->field('updator.name', __('更新者'));
+        // $show->field('created_at', __('Created at'));
+        // $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+       
+        $form = new Form(new Activity());
+        $form->tools(function (Form\Tools $tools) {
+
+            // 去掉`列表`按钮
+            $tools->disableList();
+        
+            // // 去掉`删除`按钮
+            // $tools->disableDelete();
+        
+            // // 去掉`查看`按钮
+            // $tools->disableView();
+        
+            
+        });
+        $form->select('belong', __('开展单位'))->options(function(){
+            $ret = [];
+            $stations = ActivityWorkStation::select(['work_station_id as id', 'name'])->get();
+            if($stations){
+                foreach($stations as $v){
+                    $ret[$v->id] = $v->name;
+                }
+            }
+            return $ret;
+        })->required();
+        $form->select('organiz_type', __('被开展单位类型'))->options([1=>'党政机关', 2=>'学校', 3=>'企事业单位', 4=>'公共场所', 5=>'社区', 6=>'农村'])->required();
+        $form->select('activity_range_id', __('活动区域'))->options(function(){
+            $ret = [];
+            $range = ActivityRange::select(['id', 'name'])->get();
+            if($range){
+                foreach($range as $v){
+                    $ret[$v->id] = $v->name;
+                }
+            }
+            return $ret;
+        })->required();
+        $form->datetime('active_time', __('活动时间'))->required();
+
+        $form->text('title', __('活动标题'))->required();
+        $form->text('organiz_name', __('单位名称'))->required();
+        $form->text('member_num', __('参加人数'))->required();
+        $form->text('member', __('主要参加人员'))->required();
+        $form->textarea('content', __('活动内容'));
+       
+        // 多文件
+        $form->multipleFile('ext', __('附件资料'))->removable();
+        // $form->number('creater', __('Creater'));
+        // $form->number('updator', __('Updator'));
+
+        return $form;
+    }
+}

+ 68 - 0
app/Admin/Controllers/ActivityRangeController.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\ActivityRange;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ActivityRangeController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = 'ActivityRange';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new ActivityRange());
+
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('区域名称'));
+        // $grid->column('created_at', __('创建时间'));
+        // $grid->column('updated_at', __('修改时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(ActivityRange::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('区域名称'));
+        $show->field('created_at', __('创建时间'));
+        $show->field('updated_at', __('修改时间'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new ActivityRange());
+
+        $form->text('name', __('区域名称'));
+
+        return $form;
+    }
+}

+ 10 - 0
app/Admin/Controllers/AuthController.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use Encore\Admin\Controllers\AuthController as BaseAuthController;
+
+class AuthController extends BaseAuthController
+{
+
+}

+ 76 - 0
app/Admin/Controllers/BannerController.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+use App\Models\Banner;
+
+class BannerController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = 'Banner 管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Banner);
+
+        $grid->column('id', __('ID'))->sortable();
+        $grid->column('name', __('位置名称'));
+        $grid->column('local_id',  __('位置'))->display(function ($localId) {
+         return isset(Banner::$localMap[$localId])?Banner::$localMap[$localId]:"未知";
+        });
+        $grid->column('rank', __('排序(越大越靠前)'))->sortable();
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed   $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Banner::findOrFail($id));
+
+        $show->field('id', __('ID'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Banner);
+
+        $form->display('id', __('ID'));
+        $form->select('local_id',  __('位置'))->options(Banner::$localMap)->rules('required');
+        $form->text('name', __('名称'))->rules('required');
+        $form->image('pic', __('图片'))->uniqueName()->move('pics/'.date('Y').'/'.date('m'))->rules('required');
+        $form->text('url', __('链接地址'))->rules('required');
+        $form->number('rank', __('排序(越大越靠前)'))->default(0);
+
+        return $form;
+    }
+}

+ 20 - 0
app/Admin/Controllers/ChatController.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use Encore\Admin\Layout\Content;
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+
+class ChatController extends Controller
+{
+    public function index(Content $content, Request $request)
+    {
+
+        $content->view('admin.chat.message', [
+            'kefuUid' => 1
+        ]);
+
+        return $content;
+    }
+}

+ 77 - 0
app/Admin/Controllers/DiaryMoodLevelController.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\DiaryMoodLevel;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class DiaryMoodLevelController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '心情等级';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new DiaryMoodLevel());
+
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('级别名'));
+        $grid->column('color', __('颜色'));
+        $grid->column('rank', __('排序 越大越靠前'));
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(DiaryMoodLevel::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('Name'));
+        $show->field('pic', __('Pic'));
+        $show->field('color', __('Color'));
+        $show->field('rank', __('Rank'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+        $show->field('deleted_at', __('Deleted at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new DiaryMoodLevel());
+
+        $form->text('name', __('级别名'));
+        $form->image('pic', __('图片'));
+        $form->color('color', __('颜色'));
+        $form->number('rank', __('排序 越大越靠前'));
+
+        return $form;
+    }
+}

+ 75 - 0
app/Admin/Controllers/DiaryMoodTagController.php

@@ -0,0 +1,75 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\DiaryMoodTag;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class DiaryMoodTagController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '心情标签';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new DiaryMoodTag());
+
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('标签名'));
+        $grid->column('color', __('颜色'));
+        $grid->column('rank', __('排序 越大越靠前'));
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(DiaryMoodTag::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('Name'));
+        $show->field('color', __('Color'));
+        $show->field('rank', __('Rank'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+        $show->field('deleted_at', __('Deleted at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new DiaryMoodTag());
+
+        $form->text('name', __('标签名'));
+        $form->color('color', __('颜色'));
+        $form->number('rank', __('排序 越大越靠前'));
+
+        return $form;
+    }
+}

+ 79 - 0
app/Admin/Controllers/DiarySleepLevelController.php

@@ -0,0 +1,79 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\DiarySleepLevel;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class DiarySleepLevelController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '睡眠等级';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new DiarySleepLevel());
+
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('级别名'));
+        $grid->column('color', __('颜色'));
+        $grid->column('rank', __('排序 越大越靠前'));
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(DiarySleepLevel::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('Name'));
+        $show->field('pic', __('Pic'));
+        $show->field('hover_pic', __('Hover pic'));
+        $show->field('color', __('Color'));
+        $show->field('rank', __('Rank'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+        $show->field('deleted_at', __('Deleted at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new DiarySleepLevel());
+
+        $form->text('name', __('级别名'));
+        $form->image('pic', __('未选中的图片'));
+        $form->image('hover_pic', __('选中时的图片'));
+        $form->color('color', __('文字颜色'));
+        $form->number('rank', __('排序 越大越靠前'));
+
+        return $form;
+    }
+}

+ 67 - 0
app/Admin/Controllers/ExampleController.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ExampleController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = 'Example controller';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new ExampleModel);
+
+        $grid->column('id', __('ID'))->sortable();
+        $grid->column('created_at', __('Created at'));
+        $grid->column('updated_at', __('Updated at'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed   $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(ExampleModel::findOrFail($id));
+
+        $show->field('id', __('ID'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new ExampleModel);
+
+        $form->display('id', __('ID'));
+        $form->display('created_at', __('Created At'));
+        $form->display('updated_at', __('Updated At'));
+
+        return $form;
+    }
+}

+ 220 - 0
app/Admin/Controllers/FourActivityController.php

@@ -0,0 +1,220 @@
+<?php
+namespace App\Admin\Controllers;
+use App\Facades\RemoteSsoFacade;
+use App\Models\FourActivity;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Facades\Admin;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+use Illuminate\Database\Eloquent\Builder;
+
+/**
+ * 四进活动相关控制器操作
+ */
+class FourActivityController extends AdminController
+{
+    /**
+     * 访问标题
+     * @var string
+     */
+    protected $title = '四进活动';
+
+    /**
+     * 远程oss首页
+     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+     */
+    public function ssoIndex()
+    {
+        $indexUrl = "/admin/activities";
+        $thirdOpenid = Admin::user()->third_openid;
+        $menuResult = RemoteSsoFacade::getUserMenuWebsiteData($thirdOpenid);
+//        if (isset($menuResult["menu"])){
+//            foreach ($menuResult["menu"] as &$val){
+//                if($val["id"]==1000000000000016){
+//                    $val["menu_url"]=admin_url("activities");
+//                }
+//            }
+//        }
+
+        return view('admin/sso/index', ['menuResult' => $menuResult,"indexUrl"=>$indexUrl]);
+    }
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $user = Admin::user();
+        $grid = new Grid(new FourActivity());
+        //权限
+        $grid->actions(function ($actions) use ($user) {
+            // 没有`delete-image`权限的角色不显示删除按钮
+            if (!$user->can('delete-activite')) {
+                $actions->disableDelete();
+            }
+        });
+        $grid->model()->where(function(Builder $query) use ($user){
+                if ($user->username != "admin"){
+                    $query->where("creator","=",$user->getAuthIdentifier());
+                }
+            }
+        );
+        $grid->filter(function($filter){
+            $filter->disableIdFilter();
+            // $filter->where(function($query){
+            //     $query->where('activity_range_id=' . $_GET['activity_range_id']);
+            // },'hidden');
+            // 在这里添加字段过滤器
+            $filter->like('title', '主题');
+            $filter->equal('type', '活动类型')->select(
+                FourActivity::TYPE_MAP
+            );
+
+            $filter->equal('activities_type', '四进类型')->select(
+                FourActivity::ACTIVITIES_TYPE_MAP
+            );
+            $filter->expand();
+        });
+
+        $grid->column('id', __('ID'));
+        $grid->column('title', __('主题'));
+        $grid->column('type', __('活动类型'))->using(
+            FourActivity::TYPE_MAP
+        );
+        $grid->column('activities_type', __('四进类型'))->using(
+            FourActivity::ACTIVITIES_TYPE_MAP
+        );
+        $grid->column('active_time', __('活动时间'));
+        $grid->column('place', __('活动地点'));
+        // $grid->column('content', __('活动内容'));
+        // $grid->column('ext', __('附件资料'));
+//        $grid->column('creater', __('创建者'));
+//        $grid->column('updater', __('修改者'));
+         $grid->column('created_at', __('创建时间'));
+         $grid->column('updated_at', __('修改时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(FourActivity::findOrFail($id));
+        $show->field('id', __('Id'));
+        $show->field('title', __('主题'));
+        $show->field('type', __('活动类型'))->using(FourActivity::TYPE_MAP);
+        $show->field('activities_type', __('四进类型'))->using(FourActivity::ACTIVITIES_TYPE_MAP);
+        $show->field('active_time', __('活动时间'));
+        $show->field('content', __('活动内容'));
+        $show->field('place', __('活动地点'));
+        $show->field('audience_crowd', __('受众人群'))->using(FourActivity::AUDIENCE_CROWD_MAP);
+        $show->field('mode', __('方式'))->using(FourActivity::MODE_MAP);
+        $show->field('anchor', __('讲者/主持'));
+        $show->field('educational_materials', __('发放宣教材料(份)'));
+        $show->field('publicity_board', __('宣传栏(期)'));
+        $show->field('filling_people', __('填表人'));
+        $show->field('filling_time', __('填表时间'));
+        $show->field('member_num', __('受宣人次数'));
+        $show->field('planned_number', __('计划人数'));
+        $show->field('actual_number', __('实到人数'));
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new FourActivity());
+        $form->radio("type","活动类型")
+            ->options(FourActivity::TYPE_MAP)
+            ->when("in",array(FourActivity::TYPE_SCIENCE_POPULARIZATION_BASE,FourActivity::TYPE_PROMOTION_ACTIVITIES),function (Form $form) {
+                $form->select('activities_type', __('四进类型'))->options(function(){
+                    return FourActivity::ACTIVITIES_TYPE_MAP;
+                });
+                $form->datetime('active_time', __('活动时间'));
+                $form->text('place', __('活动地点'));
+                $form->select('audience_crowd', __('受众人群'))->options(function(){
+                    return FourActivity::AUDIENCE_CROWD_MAP;
+                });
+                $form->text('title', __('主题'));
+                $form->text('anchor', __('讲者/主持'));
+                $form->text('educational_materials', __('发放宣教材料(份)'));
+                $form->text('publicity_board', __('宣传栏(期)'));
+                $form->text('member_num', __('受宣人次数'));
+                $form->text('planned_number', __('计划人数'));
+                $form->text('actual_number', __('实到人数'));
+                $form->text('filling_people', __('填表人'));
+                $form->datetime('filling_time', __('填表时间'));
+                $form->select('mode', __('方式'))->options(function(){
+                    return FourActivity::MODE_MAP;
+                })->when("in",array(
+                    FourActivity::MODE_HEALTH_EDUCATION_LECTURE,
+                    FourActivity::MODE_TRAIN,
+                    FourActivity::MODE_GROUP_DISCUSSION_AND_DISCUSSION
+                ),function (Form $form) {
+                    //开展讲座、培训,需同步提交通知、课件、签到表及现场照片
+                    $form->html("<p style='color: red'>备注:需同步提交通知、课件、签到表及现场照片</p>");
+                })->when("in",array(
+                    FourActivity::MODE_HEALTH_PROMOTION_ACTIVITIES,
+                ),function (Form $form) {
+                    //开展健康宣传活动,需同步提交活动照片、活动总结
+                    $form->html("<p style='color: red'>备注:需同步提交活动照片、活动总结</p>");
+                })->when("in",array_values(array_diff(array_keys(FourActivity::MODE_MAP),array(
+                        FourActivity::MODE_HEALTH_EDUCATION_LECTURE,
+                        FourActivity::MODE_TRAIN,
+                        FourActivity::MODE_GROUP_DISCUSSION_AND_DISCUSSION,
+                        FourActivity::MODE_HEALTH_PROMOTION_ACTIVITIES
+                    )
+                )),function (Form $form) {
+                    //其它形式活动根据实际情况提交影像资料
+                    $form->html("<p style='color: red'>备注:需要根据实际情况提交影像资料</p>");
+                });
+                //多文件
+                $form->multipleFile('ext', __('附件资料'))->removable();
+                $form->textarea('content', __('活动内容'));
+            })
+            ->when("=",FourActivity::TYPE_FEATURED_SERVICES,function (Form $form){
+                $form->text('title', __('项目名称'));
+//                $form->text('place', __('活动地点'));
+                //申报书、任务书、结题报告书和其他
+                $form->file('declaration_form', __('申报书'))->removable();
+                $form->html("<a style='color: red' onclick='window.open(this.href); return false;' href='https://cydsyy-api.qingerai.com/vendor/excel/附件:2024年朝阳区精神卫生特色服务项目申报书.doc'><button  class='btn btn-warning'>下载申报书模版</button></a>");
+                $form->file('task_book', __('任务书'))->removable();
+                $form->html("<a style='color: red' onclick='window.open(this.href); return false;' href='https://cydsyy-api.qingerai.com/vendor/excel/附件2特色项目任务书.doc'><button  class='btn btn-warning'>下载任务书模版</button></a>");
+                $form->file('final_report', __('结题报告书'))->removable();
+                $form->html("<a style='color: red' onclick='window.open(this.href); return false;' href='https://cydsyy-api.qingerai.com/vendor/excel/附件3:朝阳区特色项目结题报告书.doc'><button  class='btn btn-warning'>下载结题报告书模版</button></a>");
+                $form->multipleFile('ext', __('其他'))->removable();
+            })
+            ->when("=",FourActivity::TYPE_FEATURED_REPORT_RECEIPT,function (Form $form){
+                $form->text('title', __('回执名称'));
+//                $form->text('place', __('活动地点'));
+                $form->file('return_receipt', __('回执单'))->removable();
+                $form->html("<a style='color: red' onclick='window.open(this.href); return false;' href='https://cydsyy-api.qingerai.com/vendor/excel/回执单.xlsx'><button  class='btn btn-warning'>下载回执单模版</button></a>");
+                $form->multipleFile('ext', __('其他'))->removable();
+            })
+            ->required();
+        $form->tools(function (Form\Tools $tools) {
+            // 去掉`列表`按钮
+            $tools->disableList();
+
+            // // 去掉`删除`按钮
+            // $tools->disableDelete();
+
+            // // 去掉`查看`按钮
+            // $tools->disableView();
+
+        });
+
+        return $form;
+    }
+}

+ 23 - 0
app/Admin/Controllers/HomeController.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Http\Controllers\Controller;
+use Encore\Admin\Controllers\Dashboard;
+use Encore\Admin\Layout\Column;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Layout\Row;
+use App\Facades\ScaleFacade;
+
+class HomeController extends Controller
+{
+    public function index(Content $content)
+    {
+        //同步量表
+//           return ScaleFacade::createThirdScale(200, 200, '');
+        return $content
+            ->title('欢迎页')
+            ->description('')
+            ;
+    }
+}

+ 96 - 0
app/Admin/Controllers/MentalityDrillExtendController.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\MentalityDrillCategory;
+use App\Models\MentalityDrillExtend;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+use App\Models\MentalityDrill;
+
+class MentalityDrillExtendController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '音视频';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new MentalityDrillExtend());
+        $grid->filter(function(\Encore\Admin\Grid\Filter $filter){
+            // 在这里添加字段过滤器
+            $filter->like('name', '名称');
+            $filter->expand();
+        });
+        $grid->column('id', __('Id'));
+        $grid->column('drill_id', __('训练'))->display(function ($id) {
+            if ($id > 0){
+                $mentalityDrillData = MentalityDrill::find($id);
+                if ($mentalityDrillData){
+                    return $mentalityDrillData->title;
+                }
+            }
+            return  '';
+        });
+        $grid->column('name', __('名称'));
+        $grid->column('time', __('时长'));
+        $grid->column('type', __('类别'))->display(function ($type) {
+            return MentalityDrillExtend::$typeMap[$type];
+        });
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(MentalityDrillExtend::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('drill_id', __('Drill id'));
+        $show->field('name', __('Name'));
+        $show->field('time', __('Time'));
+        $show->field('src', __('Src'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+        $show->field('deleted_at', __('Deleted at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new MentalityDrillExtend());
+
+        $select = MentalityDrill::get(['id','title as name'])->pluck('name','id');
+        $form->select('drill_id', __('训练'))->options($select)->required();
+        $form->select('type', __('类别'))->options(MentalityDrillExtend::$typeMap)->required();
+        $form->text('name', __('名称'))->required();
+        $form->text('time', __('时长'))->required();
+        $form->file('src', __('音视频'))->removable()->uniqueName()->move('videos/'.date('Y').'/'.date('m'));
+        $form->image('pic', __('背景图片'));
+
+        return $form;
+    }
+}

+ 115 - 0
app/Admin/Controllers/MentalityDrillsSubjectController.php

@@ -0,0 +1,115 @@
+<?php
+namespace App\Admin\Controllers;
+use App\Models\MentalityDrill;
+use App\Models\MentalityDrillCategory;
+use App\Models\MentalityDrillsSubject;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\DB;
+
+/**
+ * 课程相关控制
+ */
+class MentalityDrillsSubjectController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '课程';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new MentalityDrillsSubject());
+        $grid->filter(function($filter){
+            $filter->disableIdFilter();
+            // $filter->where(function($query){
+            //     $query->where('activity_range_id=' . $_GET['activity_range_id']);
+            // },'hidden');
+            // 在这里添加字段过滤器
+            $filter->like('name', '课程名称');
+            $tableName = MentalityDrillCategory::query()->getModel()->getTable();
+            $isSubject = MentalityDrillCategory::isSubjectYes;
+            $select = MentalityDrill::query()
+                ->whereRaw(DB::raw("category_id in (select id from {$tableName} where is_subject = {$isSubject} and deleted_at is null)"))
+                ->get(['id','title as name'])
+                ->pluck('name','id');
+            $filter->equal('mentality_drills_id', '训练')->select(
+                $select
+            );
+            $filter->expand();
+        });
+        $grid->column('id', __('Id'));
+        $grid->column('mentality_drills_id', __('训练'))->display(function ($id) {
+            if ($id > 0){
+                $mentalityDrillData = MentalityDrill::find($id);
+                if ($mentalityDrillData){
+                    return $mentalityDrillData->title;
+                }
+            }
+            return  '';
+        });
+        $grid->column('name', __('课程名称'));
+        $grid->column('time', __('时长'));
+//        $grid->column('type', __('类别'))->display(function ($type) {
+//            return MentalityDrillsSubject::$typeMap[$type];
+//        });
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(MentalityDrillsSubject::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('mentality_drills_id', __('Drill id'));
+        $show->field('name', __('Name'));
+        $show->field('time', __('Time'));
+        $show->field('src', __('Src'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+        $show->field('deleted_at', __('Deleted at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new MentalityDrillsSubject());
+        $tableName = MentalityDrillCategory::query()->getModel()->getTable();
+        $isSubject = MentalityDrillCategory::isSubjectYes;
+        $select = MentalityDrill::query()
+            ->whereRaw(DB::raw("category_id in (select id from {$tableName} where is_subject = {$isSubject} and deleted_at is null)"))
+            ->get(['id','title as name'])
+            ->pluck('name','id');
+        $form->select('mentality_drills_id', __('训练'))->options($select)->required();
+//        $form->select('type', __('类别'))->options(MentalityDrillsSubject::$typeMap)->required();
+        $form->hidden("type","类别")->value(MentalityDrillsSubject::TYPE_2);
+        $form->text('name', __('课程名称'))->required();
+        $form->text('time', __('时长'))->required();
+        $form->file('src', __('视频'))->removable()->uniqueName()->move('videos/'.date('Y').'/'.date('m'));
+        $form->image('pic', __('背景图片'));
+        return $form;
+    }
+}

+ 207 - 0
app/Admin/Controllers/OpenWeixinController.php

@@ -0,0 +1,207 @@
+<?php
+
+
+namespace App\Admin\Controllers;
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Redis;
+use Illuminate\Support\Facades\DB;
+use Hanson\LaravelAdminWechat\Models\WechatConfig;
+use EasyWeChat\Factory;
+use EasyWeChat\OpenPlatform\Server\Guard;
+use App\Models\WechatTicket;
+use App\Modelsgbapp\SpecialistInfogbapp;
+
+/**
+ * 微信开发平台第三方平台接入
+ * EasyWeChat 4.0
+ */
+class OpenWeixinController extends Controller
+{
+    protected $account;
+    protected $app;
+    protected $config = [
+        'app_id' => 'wxe81efa7fd6a5fd53',
+        'secret' => '7d22f52938e4c9fbb5f2d07e8f5b83b6',
+        'token' => '6lfq90croi6nsyia63vbhaqnq4lzm66d',
+        'aes_key' => 'uOIvZHtyDKKd7xT4KKgpikGOtgW7ZskeOzVIFgIs2SM'
+    ];
+
+    /**
+     * Display a listing of the resource.
+     *
+     * @return Response
+     */
+    public function index(Request $request)
+    {
+        $this->request = $request;;
+        try {
+
+            $openPlatform = Factory::openPlatform($this->config);
+            // 第三方平台接入处理
+            $server = $openPlatform->server;
+            return $server->serve();
+
+            // 处理授权成功事件
+        if (!empty($request["auth_code"])) {
+//            $server->push(function ($event) use ($openPlatform) {
+//                DB::table("test_content")->insert(array("test"=>json_encode($request["auth_code"])));
+//                //获取(刷新)授权公众号或小程序的接口调用凭据(令牌)
+//                $res = $openPlatform->handleAuthorize($request["auth_code"]);
+//                $appid2 = $res['authorization_info']['authorizer_appid'];
+//                $refresh_token = $res['authorization_info']['authorizer_refresh_token'];
+//
+//                //获取授权方的帐号基本信息
+//                $data = $openPlatform->getAuthorizer($appid2);
+//                $account = WechatConfig::where('app_id', $appid2)->first();
+//                $info2 = $data['authorizer_info'];
+//                $info1 = $data['authorization_info'];
+//                if (is_null($account)) {
+//                    $account = WechatConfig::create([
+//                        'app_id' => $info1['authorizer_appid'],
+//                        'refresh_token' => $refresh_token,
+//                        'name' => $info2['nick_name'],
+//                        'head_img' => $info2['head_img'],
+//                        'original' => $info2['user_name'],
+//                        'com_main_body' => $info2['principal_name'],
+//                        'headimg' => $info2['qrcode_url'], //二维码
+//                        'status' => 1,
+//                        'level' => $this->getLevel($info2),
+//                        'type' => 1,
+////                        'token' => random(32),
+////                        'encodingaeskey' => random(43)
+//                    ]);
+//                } else {
+//                    $account->refresh_token = $refresh_token;
+//                    $account->name = $info2['nick_name'];
+//                    $account->type = 3;
+//                    $account->original = $info2['user_name'];
+//                    $account->level = $this->getLevel($info2);
+//                    $account->head_img = $info2['head_img'];
+//                    $account->save();
+//                }
+//            }, Guard::EVENT_AUTHORIZED);
+
+        }
+
+
+            // 处理授权更新事件
+            $server->push(function ($event) use ($openPlatform) {
+//                DB::table("test_content")->insert(array("test"=>json_encode($event)));
+//
+//                $vl=json_encode($event);
+//                $event=json_decode($vl);
+            }, Guard::EVENT_UPDATE_AUTHORIZED);
+
+            // 处理授权取消事件
+            $server->push(function ($event) {
+//                DB::table("test_content")->insert(array("test"=>json_encode($event)));
+//
+//                $vl=json_encode($event);
+//                $event=json_decode($vl);
+//                $appid = $event->AuthorizerAppid;
+//                $account = WechatConfig::where('appid', $appid)->first();
+//                if (!is_null($account)) {
+//                    $account->refresh_token = '';
+//                    $account->save();
+//                }
+            }, Guard::EVENT_UNAUTHORIZED);
+
+            //VerifyTicket component_verify_ticket协议推送
+            $server->push(function ($event) use ($openPlatform) {
+//                $vl=json_encode($event);
+//                $event=json_decode($vl);
+//                $appid = $event->AppId;
+//                $ticket = $event->ComponentVerifyTicket;
+//                //保存component_verify_ticket协议
+//                Redis::set($appid . '_component_verify_ticket', $ticket);//存储起来方便后续多台服务器并发调用
+////                $wechatTicket = WechatTicket::where('appid', $appid)->orderBy('id')->first();
+//                $wechatTicket = DB::table("wechat_ticket")->where('appid', $appid)->orderBy('id')->first();
+//                if (empty($wechatTicket)) {
+//                    $wechatTicket =  DB::table("wechat_ticket")->insert(array('appid'=>$appid,'ticket'=>$ticket
+//                    ,'create_time'=>time(),'update_time' =>time()));
+//                } else {
+//                    DB::table("wechat_ticket")->where('appid', $appid)->update(array(
+//                        'ticket' => $ticket,
+//                        'update_time' => time()
+//                    ));
+////                    $wechatTicket->ticket = $ticket;
+////                    $wechatTicket->update_time = time();
+////                    $wechatTicket->save();
+//                }
+            }, Guard::EVENT_COMPONENT_VERIFY_TICKET);
+
+            return $server->serve();
+
+        } catch (\Exception $e) {
+            if (env('APP_DEBUG')) {
+                echo $e->getMessage();
+            } else {
+                abort(404);
+            }
+        }
+
+    }
+
+    public function auth(Request $request)
+    {
+        try {
+            $openPlatform = Factory::openPlatform($this->config);
+            // 获取跳转的链接
+            $url = $openPlatform->getPreAuthorizationUrl('http://zyyd-api.qingerai.com/admin/openweixin/index');
+            // 获取跳转的链接
+            echo '<a href="' . $url . '">点击第三方授权</a>';
+        } catch (\Exception $e) {
+            echo $e->getMessage();
+            $url = '';
+        }
+        //return view('admin.auth.note', compact('url'));
+    }
+
+    public function callback(Request $request)
+    {
+//        echo \GuzzleHttp\json_encode($filter);exit;
+//        return redirect()->to(site_path('account/wechat', 'admin'))->with('message', '第三方接入成功!');
+        return redirect()->to('http://zyyd-api.qingerai.com/admin/openweixin/index')->with('message', '第三方接入成功!');
+    }
+
+    public function getThirdToken(Request $request)
+    {
+        $wechatTicket = SpecialistInfogbapp::first()['name'];
+        echo \GuzzleHttp\json_encode($wechatTicket);
+
+//        $openPlatform = Factory::openPlatform($this->config);
+//        // 第三方平台接入处理
+//        $server = $openPlatform->getAuthorizer("wx382b6315fd4f1760");
+
+//       echo \GuzzleHttp\json_encode($server);exit;
+//        return redirect()->to(site_path('account/wechat', 'admin'))->with('message', '第三方接入成功!');
+    }
+
+    // 公众号分组
+    public function getLevel($info = array())
+    {
+        $level = 0;
+        if (!empty($info['MiniProgramInfo'])) {
+            $level = 5;
+        } else if ($info['service_type_info']['id'] == 0 || $info['service_type_info']['id'] == 1) {
+            //订阅号
+            if ($info['verify_type_info']['id'] >= 0) {
+                //已认证
+                $level = 3;
+            } else {
+                $level = 1;
+            }
+        } else if ($info['service_type_info']['id'] == 2) {
+            //服务号
+            if ($info['verify_type_info']['id'] >= 0) {
+                //已认证
+                $level = 4;
+            } else {
+                $level = 2;
+            }
+        }
+        return $level;
+    }
+}

+ 17 - 0
app/Admin/Controllers/RemoteSsoController.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Admin\Controllers;
+use App\Facades\RemoteSsoFacade;
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+use Illuminate\Http\Response;
+
+/**
+ * 远程授权登录
+ */
+class RemoteSsoController extends Controller
+{
+    public function login(Request $request,Response $response)
+    {
+        return RemoteSsoFacade::verifyVisitUrl($request,$response);
+    }
+}

+ 33 - 0
app/Admin/Controllers/RowAction/CustomAction.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Admin\Controllers\RowAction;
+use Encore\Admin\Actions\RowAction;
+
+/**
+ * 自定义按钮选项
+ */
+class CustomAction extends RowAction
+{
+    /**
+     * @var string 跳转网址
+     */
+    private  $href;
+
+    public function __construct(string $name,string $href)
+    {
+        $this->name = $name;
+        $this->href = $href;
+        parent::__construct();
+    }
+
+    public function name()
+    {
+        return $this->name;
+    }
+
+    public function href()
+    {
+        return $this->href;
+    }
+
+}

+ 101 - 0
app/Admin/Controllers/ScaleCategoryController.php

@@ -0,0 +1,101 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Admin\Controllers\RowAction\CustomAction;
+use App\Models\ScaleCategory;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+/**
+ * 量表分类,控制器
+ */
+class ScaleCategoryController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+//    protected $title = '量表分类';
+    protected $title = '心理评估分类';
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new ScaleCategory());
+//        // 禁用创建按钮
+//        $grid->disableCreateButton();
+//        // 禁用编辑功能
+//        $grid->disableActions();
+        // 新增过滤筛选
+        $grid->filter(function ($filter) {
+            $filter->like('name', '分类名称');
+            $filter->like('info', '分类首页简介');
+            $filter->like('list_info', __('分类列表简介'));
+        });
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('分类名称'));
+        $grid->column('info', __('分类首页简介'));
+        $grid->column('list_info', __('分类列表简介'));
+        $grid->column('rank', __('排序 越大越前'));
+        $grid->column('is_index', __('是否首页'))->display(function ($isIndex){
+            return isset(ScaleCategory::isIndexMap[$isIndex])
+                ?
+                ScaleCategory::isIndexMap[$isIndex]
+                :
+                ""
+                ;
+        });
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(ScaleCategory::findOrFail($id));
+        $show->field('id', __('Id'));
+        $show->field('name', __('Name'));
+        $show->field('info', __('Info'));
+        $show->field('list_info', __('List Info'));
+        $show->field('pic', __('Pic'));
+        $show->field('rank', __('Rank'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+        $show->field('deleted_at', __('Deleted at'));
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new ScaleCategory());
+        $form->text('name', __('分类名称'));
+        $form->text('info', __('分类首页简介'));
+        $form->text('list_info', __('分类列表简介'));
+        $form->image('pic', __('首页图片'));
+        $form->image('pic2', __('分类图片'));
+        $form->number('rank', __('排序 越大越前'));
+        $form->radio("is_index","是否首页")
+            ->options(ScaleCategory::isIndexMap)
+            ->default(ScaleCategory::isIndexNo)
+        ;
+        return $form;
+    }
+}

+ 113 - 0
app/Admin/Controllers/ScaleController.php

@@ -0,0 +1,113 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Scale;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+use App\Models\ScaleCategory;
+use App\Models\ThirdScale;
+
+class ScaleController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+//    protected $title = '量表内容';
+    protected $title = '心理评估内容';
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Scale());
+
+        $grid->column('id', __('Id'));
+        $grid->column('category_id', __('分类'))->display(function ($pid) {
+            if ($pid>0){
+                $scaleCategoryData = ScaleCategory::find($pid);
+                if ($scaleCategoryData){
+                    return  $scaleCategoryData->name;
+                }
+            }
+            return '';
+        });
+        $grid->column('title', __('标题'));
+        $grid->column('time', __('测试时间'));
+        $grid->column('suitable_for_the_crowd', __('适合人群'));
+        $grid->column('number_of_questions', __('问题数'));
+        $grid->column('number_of_replay', __('报告数'));
+        $grid->column('number_of_test', __('测试次数'));
+        $grid->column('rank', __('排序 越大越前'));
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Scale::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('category_id', __('Category id'));
+        $show->field('third_id', __('Third id'));
+        $show->field('title', __('Title'));
+        $show->field('subtitle', __('Subtitle'));
+        $show->field('pic', __('Pic'));
+        $show->field('content', __('Content'));
+        $show->field('time', __('Time'));
+        $show->field('suitable_for_the_crowd', __('Suitable for the crowd'));
+        $show->field('number_of_questions', __('Number of questions'));
+        $show->field('number_of_replay', __('Number of replay'));
+        $show->field('number_of_test', __('Number of test'));
+        $show->field('notice', __('Notice'));
+        $show->field('rank', __('Rank'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+        $show->field('deleted_at', __('Deleted at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Scale());
+
+        $thirdScale = ThirdScale::get(['id', 'title as name'])->pluck('name','id');
+        $form->select('third_id', __('远程量表'))->options($thirdScale)->required();
+        $cloumns = ScaleCategory::get(['id','name'])->pluck('name','id');
+        $form->select('category_id', __('分类'))->options($cloumns)->required();
+        $form->text('title', __('标题'))->required();
+        $form->text('subtitle', __('副标题'))->required();
+        $form->image('pic', __('图片'))->required();
+        $form->editor('content', __('内容'))->required();
+        $form->number('time', __('测试时间(分钟)'))->required();
+        $form->text('suitable_for_the_crowd', __('适合人群'))->required();
+        $form->number('number_of_questions', __('问题数'))->default(0);
+        $form->number('number_of_replay', __('报告数'))->default(0);
+        $form->number('number_of_test', __('测试次数'))->default(0);
+        $form->textarea('notice', __('测试须知'))->required();
+        $form->number('rank', __('排序 越大越前'))->default(0);
+        $form->list('comment_tag', __('推荐标签'));
+
+        return $form;
+    }
+}

+ 96 - 0
app/Admin/Controllers/SpecialistColumnController.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+use App\Models\SpecialistCloumn;
+
+class SpecialistColumnController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '健康课堂-一级栏目管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new SpecialistCloumn);
+        // 禁用创建按钮
+        $grid->disableCreateButton();
+        // 禁用编辑功能
+        $grid->disableActions();
+        $grid->column('id', __('ID'))->sortable();
+        $grid->column('name', __('名称'));
+        $grid->column('is_show', __('是否显示'))->display(function ($isShow) {
+            return SpecialistCloumn::$isShowMap[$isShow];
+        });;
+        $grid->column('rank', __('排序(越大越靠前)'))->sortable();
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        $grid->model()->where('pid', SpecialistCloumn::PID_0);
+
+        // 新增过滤
+        $grid->filter(function ($filter) {
+            $filter->like('name', '名称');
+            $filter->equal('is_show', '是否显示')->radio(SpecialistCloumn::$isShowMap);
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed   $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(SpecialistCloumn::findOrFail($id));
+
+        $show->field('id', __('ID'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new SpecialistCloumn);
+
+        $form->display('id', __('ID'))->rules('required');
+        $form->text('name', __('名称'))->rules('required');
+        $form->image('pic', __('图片'))->uniqueName()->move('pics/'.date('Y').'/'.date('m'))->rules('required');
+        $form->text('url', __('链接地址'))->rules('required');
+        $form->table('banner', function ($table) {
+            $table->image('src', '广告图')->uniqueName()->move('pics/'.date('Y').'/'.date('m'))->rules('required');
+            $table->text('url', '链接地址')->rules('required');
+        });
+
+            $states = [
+                'on'  => ['value' => 1, 'text' => '显示', 'color' => 'success'],
+                'off' => ['value' => 0, 'text' => '不显示', 'color' => 'danger'],
+            ];
+        $form->switch('is_show', __('是否显示'))->states($states);
+        $form->number('rank', __('排序(越大越靠前)'))->default(0);
+
+        return $form;
+    }
+}

+ 118 - 0
app/Admin/Controllers/SpecialistColumnSecondController.php

@@ -0,0 +1,118 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+use App\Models\SpecialistCloumn;
+use Illuminate\Http\Request;
+
+class SpecialistColumnSecondController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '健康课堂-二级栏目管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new SpecialistCloumn);
+
+        $grid->column('id', __('ID'))->sortable();
+        $grid->column('pid', __('上级栏目'))->display(function ($pid) {
+            return $pid > 0 ? SpecialistCloumn::find($pid)->name : '';
+        });
+        $grid->column('name', __('名称'));
+        $grid->column('is_show', __('是否显示'))->display(function ($isShow) {
+            return SpecialistCloumn::$isShowMap[$isShow];
+        });
+        $grid->column('rank', __('排序(越大越靠前)'))->sortable();
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        $grid->model()->where('pid', '>', SpecialistCloumn::PID_0);
+
+        //过滤用到的一级栏目
+        $cloumns = SpecialistCloumn::where('pid', 0)->get();
+        $firstCloumns = [];
+        foreach ($cloumns as $cloumn){
+            $firstCloumns[$cloumn->id] = $cloumn->name;
+        }
+
+        // 过滤
+        $grid->filter(function ($filter) use($firstCloumns) {
+            $filter->like('name', '名称');
+            $filter->equal('pid', '类别')->select($firstCloumns);
+            $filter->equal('is_show', '是否显示')->radio(SpecialistCloumn::$isShowMap);
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed   $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(SpecialistCloumn::findOrFail($id));
+
+        $show->field('id', __('ID'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new SpecialistCloumn);
+
+        $form->display('id', __('ID'));
+
+        //只显示一级栏目
+        $cloumns = SpecialistCloumn::where('pid', 0)->get();
+        $firstCloumns = [];
+        foreach ($cloumns as $cloumn){
+            $firstCloumns[$cloumn->id] = $cloumn->name;
+        }
+
+        $form->select('pid', __('上一级'))->options($firstCloumns)->rules('required');;
+        $form->text('name', __('名称'))->rules('required');
+        $form->image('pic', __('图片'))->uniqueName()->move('pics/'.date('Y').'/'.date('m'));
+        $form->text('url', __('链接地址'));
+
+        $states = [
+            'on'  => ['value' => 1, 'text' => '显示', 'color' => 'success'],
+            'off' => ['value' => 0, 'text' => '不显示', 'color' => 'danger'],
+        ];
+        $form->switch('is_show', __('是否显示'))->states($states);
+        $form->number('rank', __('排序(越大越靠前)'))->default(0);
+
+        return $form;
+    }
+
+    protected function secondCloumn(Request $request){
+
+        $pid = $request->get('q');
+        $result = SpecialistCloumn::where('pid', $pid)->get(['id', 'name as text']);
+
+        return count($result) == 0 ? [['id'=>0,'text'=>'无']] : $result;
+    }
+}

+ 97 - 0
app/Admin/Controllers/SpecialistColumnTagController.php

@@ -0,0 +1,97 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+use Illuminate\Http\Request;
+use App\Models\SpecialistCloumnTag;
+use App\Models\SpecialistCloumn;
+
+class SpecialistColumnTagController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '健康课堂-标签管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new SpecialistCloumnTag);
+
+        $grid->column('id', __('ID'))->sortable();
+        $grid->column('specialist_cloumn_id', __('所属栏目'))->display(function ($pid) {
+            if ($pid > 0){
+                $specialistCloumnsData = SpecialistCloumn::query()->find($pid);
+                if ($specialistCloumnsData){
+                    return SpecialistCloumn::find($pid)->name;
+                }
+            }
+            return '';
+        });
+        $grid->column('name', __('名称'));
+        $grid->column('rank', __('排序(越大越靠前)'))->sortable();
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        // 过滤
+        $grid->filter(function ($filter){
+            $filter->like('name', '名称');
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed   $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(SpecialistCloumnTag::findOrFail($id));
+
+        $show->field('id', __('ID'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new SpecialistCloumnTag);
+
+        $form->display('id', __('ID'));
+
+        $cloumns = SpecialistCloumn::where('pid','>',0)->get(['id','name'])->pluck('name','id');
+        $form->select('specialist_cloumn_id', __('所属栏目'))->options($cloumns)->rules('required');
+        $form->text('name', __('名称'))->rules('required');
+        $form->number('rank', __('排序(越大越靠前)'))->default(0);
+
+        return $form;
+    }
+
+    protected function tags(Request $request){
+
+        $pid = $request->get('q');
+        $result = SpecialistCloumnTag::where('specialist_cloumn_id', $pid)->get(['id', 'name as text']);
+
+        return count($result) == 0 ? [['id'=>0,'text'=>'无']] : $result;
+    }
+}

+ 138 - 0
app/Admin/Controllers/SpecialistContentController.php

@@ -0,0 +1,138 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\SpecialistCloumn;
+use App\Models\SpecialistCloumnTag;
+use App\Models\SpecialistInfo;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class SpecialistContentController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '健康课堂-内容管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new SpecialistInfo);
+
+        $grid->column('id', __('ID'))->sortable();
+        $grid->column('firstCloumn.name', __('一级栏目'));
+        $grid->column('secondCloumn.name', __('二级栏目'));
+        $grid->column('name', __('名称'))->limit(40);
+        $grid->column('type', __('类别'))->display(function ($type) {
+            return SpecialistInfo::$typeMap[$type];
+        });
+        $grid->column('rank', __('排序(越大越靠前)'))->sortable();
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        //过滤用到的一级栏目
+        $cloumns = SpecialistCloumn::where('pid', 0)->get();
+        $firstCloumns = [];
+        foreach ($cloumns as $cloumn){
+            $firstCloumns[$cloumn->id] = $cloumn->name;
+        }
+
+        // 过滤
+        $grid->filter(function ($filter) use($firstCloumns){
+            $filter->like('name', '名称');
+            $filter->equal('first_id', '一级栏目')->select($firstCloumns);
+            $filter->equal('type', '类别')->select(SpecialistInfo::$typeMap);
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed   $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(SpecialistInfo::findOrFail($id));
+
+        $show->field('id', __('ID'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new SpecialistInfo);
+
+        $form->display('id', __('ID'))->rules('required');
+        $form->select('first_id', '一级栏目')->options(SpecialistCloumn::where('pid', 0)->get()->pluck('name','id'))->rules("required")->load('second_id', '/admin/second_column');
+
+        $id = 0;
+        if($form->isEditing()){
+            //获取id
+            $parameters = request()->route()->parameters();
+            $id = $parameters['specialist_content'];
+        }
+
+        if ($id > 0) {
+            $info = $form->model()->find($id);
+            $secondCategory = SpecialistCloumn::where('pid', $info->first_id)->get()->pluck('name','id');
+        } else {
+            $secondCategory = [];
+        }
+        $form->select('second_id', '二级栏目')->options($secondCategory)->load('tag_id', '/admin/tags')->default(0);
+        if ($id > 0) {
+            $tags = SpecialistCloumnTag::where('specialist_cloumn_id', $info->second_id)->get()->pluck('name','id');
+        } else {
+            $tags = [];
+        }
+        $form->select('tag_id', '标签')->options($tags)->default(0);
+        $form->text('name', __('名称'))->rules('required');
+        $form->textarea('subtitle', __('描述'))->rules('required');
+        $form->editor('content', __('内容'))->required()->rules('required');;
+        $form->multipleImage('cover', __('封面'))->removable()->uniqueName()->move('pics/'.date('Y').'/'.date('m'));
+        $form->file('video', __('视频'))->removable()->uniqueName()->move('videos/'.date('Y').'/'.date('m'));
+        $form->text('speaker', __('主讲'));
+        $form->text('source', __('来源'));
+        $form->number('rank', __('排序(越大越靠前)'))->default(0);
+        $form->list('comment_tag', __('推荐标签'));
+
+        $form->saved(function(Form $form){
+
+            $id = $form->model()->id;
+
+            $info = SpecialistInfo::find($id);
+
+            $newUpdate = [];
+            if ($info->video){
+                $newUpdate['type'] = SpecialistInfo::TYPE_3;
+            }elseif ($info->cover){
+                $newUpdate['type'] = SpecialistInfo::TYPE_2;
+            }else{
+                $newUpdate['type'] = SpecialistInfo::TYPE_1;
+            }
+
+            SpecialistInfo::where('id', $id)->update($newUpdate);
+        });
+
+        return $form;
+    }
+}

+ 75 - 0
app/Admin/Controllers/SysConfigController.php

@@ -0,0 +1,75 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\SysConfig;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class SysConfigController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '系统基本信息';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new SysConfig());
+
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('系统名'));
+        $grid->column('hotline_number', __('咨询电话'));
+        $grid->column('hotline_number_pic', __('热线图片'))->lightbox([
+            'width' => 100
+        ]);
+        $grid->column('hot_search', __('热搜索关键词'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(SysConfig::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('系统名'));
+        $show->field('hotline_number', __('咨询电话'));
+        $show->field('hotline_number_pic', __('热线对应的图片'));
+        $show->field('hot_search', __('热搜索关键词'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new SysConfig());
+
+        $form->text('name', __('系统名'));
+        $form->text('hotline_number', __('咨询电话'));
+        $form->image('hotline_number_pic', __('热线图片'))->uniqueName()->move('pics/'.date('Y').'/'.date('m'))->rules('required');
+        $form->text('hot_search', __('热搜索关键词'));
+
+        return $form;
+    }
+}

+ 89 - 0
app/Admin/Controllers/SysVersionController.php

@@ -0,0 +1,89 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\SysVersion;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class SysVersionController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = 'APP版本';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new SysVersion());
+
+        $grid->column('id', __('Id'));
+        $grid->column('type', __('类型'))->display(function($type){
+            return SysVersion::$typeMap[$type];
+        });
+        $grid->column('version_number', __('版本号'));
+        $grid->column('description', __('版本更新说明'));
+        $grid->column('web_url', __('版本下载网址'));
+        $grid->column('aos_url', __('安卓下载地址'));
+        $grid->column('ios_url', __('苹果下载地址'));
+        $grid->column('is_must', __('是否强制更新'))->display(function($isMust){
+            return SysVersion::$isMustMap[$isMust];
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(SysVersion::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('type', __('Type'));
+        $show->field('version_number', __('Version number'));
+        $show->field('description', __('Description'));
+        $show->field('web_url', __('Web url'));
+        $show->field('aos_url', __('Aos url'));
+        $show->field('ios_url', __('Ios url'));
+        $show->field('is_must', __('Is must'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+        $show->field('deleted_at', __('Deleted at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new SysVersion());
+
+        $form->select('type', __('类型'))->options(SysVersion::$typeMap);
+        $form->text('version_number', __('版本号'));
+        $form->text('description', __('版本更新说明'));
+        $form->file('web_url', __('版本下载网址'));
+        $form->text('aos_url', __('安卓下载地址'));
+        $form->text('ios_url', __('苹果下载地址'));
+        $form->switch('is_must', __('是否强制更新'));
+
+        return $form;
+    }
+}

+ 164 - 0
app/Admin/Controllers/TrainCategoryController.php

@@ -0,0 +1,164 @@
+<?php
+
+namespace App\Admin\Controllers;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+use App\Models\MentalityDrillCategory;
+use Illuminate\Http\Request;
+
+class TrainCategoryController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '心理训练 类别管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $oneLevelData = MentalityDrillCategory::query()
+            ->where(array("pid"=>0))
+            ->select(array("id","name"))
+            ->get()
+            ->toArray();
+        if (!empty($oneLevelData)){
+            $oneLevelData = array_column($oneLevelData,"name","id");
+            $oneLevelData[0] = "一级分类";
+            ksort($oneLevelData);
+        }
+        $grid = new Grid(new MentalityDrillCategory);
+        $grid->filter(function(\Encore\Admin\Grid\Filter $filter) use ($oneLevelData){
+             // 在这里添加字段过滤器
+             $filter->like('name', '分类名称');
+             $filter->expand();
+        });
+        $grid->column('id', __('ID'))->sortable();
+        $grid->column('name', __('分类名称'));
+        $grid->column('rank', __('排序(越大越前)'));
+        $grid->column('is_index', __('是否首页'))->display(function ($isIndex){
+            return isset(MentalityDrillCategory::isIndexMap[$isIndex])
+                ?
+                MentalityDrillCategory::isIndexMap[$isIndex]
+                :
+                ""
+                ;
+        });
+        $grid->column('pid', __('父级分类'))->display(function ($id) use ($grid,$oneLevelData){
+            if ($id > 0){
+                if (isset($oneLevelData[$id])){
+                    return $oneLevelData[$id];
+                }else {
+                      $data =  MentalityDrillCategory::query()
+                          ->newQuery()
+                          ->where(array("id"=>$id))
+                          ->select(array("id","name"))
+                          ->first();
+                      if (!empty($data)){
+                          return $data->name;
+                      }
+                }
+                return  "";
+            }else{
+                return  $oneLevelData[0];
+            }
+        });
+        $grid->column('is_subject', __('是否开启课程'))->display(function ($isSubject){
+            return isset(MentalityDrillCategory::isSubjectMap[$isSubject])
+                ?
+                MentalityDrillCategory::isSubjectMap[$isSubject]
+                :
+                ""
+                ;
+        });
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+        $grid->actions(function (Grid\Displayers\Actions $actions){
+            // 去掉删除
+            $actions->disableDelete();
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed   $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(MentalityDrillCategory::findOrFail($id));
+        $show->field('id', __('ID'));
+        $show->field('name', __('分类名称'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new MentalityDrillCategory);
+        $oneLevelData = MentalityDrillCategory::query()
+            ->where(array("pid"=>0))
+            ->select(array("id","name"))
+            ->get()
+            ->toArray();
+        if (!empty($oneLevelData)){
+            $oneLevelData = array_column($oneLevelData,"name","id");
+        }
+        $form->display('id', __('ID'));
+        $oneLevelData[0] = "一级分类";
+        ksort($oneLevelData);
+        $form->select('pid', __('父级分类'))->options($oneLevelData)->default(0);
+        $form->text('name', __('分类名称'))->rules('required');
+        $form->text('index_info', __('分类首页简介'));
+        $form->image('index_pic', __('分类首页图片'));
+        $form->text('name', __('分类名称'))->rules('required');
+        $form->image('pic', __('分类图片'))->uniqueName()->move('pics/'.date('Y').'/'.date('m'))->rules('required');
+        $form->text('rank', __('排序(越大越前)'))->default(0);
+        $form->radio("is_index","是否首页")
+            ->options(MentalityDrillCategory::isIndexMap)
+            ->default(MentalityDrillCategory::isIndexNo)
+        ;
+        $form->radio("is_subject","是否开启课程")
+            ->options(MentalityDrillCategory::isSubjectMap)
+            ->default(MentalityDrillCategory::isSubjectNo)
+        ;
+        $form->display('created_at', __('创建时间'));
+        $form->display('updated_at', __('更新时间'));
+        $form->tools(function (Form\Tools $tools){
+            $tools->disableDelete();
+        });
+        return $form;
+    }
+
+    /**
+     * 下级分类
+     * @param Request $request
+     * @return array
+     */
+    public function lowerLevel(Request $request)
+    {
+        $pid = $request->get("q",0);
+        $oneLevelData = MentalityDrillCategory::query()
+            ->where(array("pid"=>$pid))
+            ->select(array("id","name as text"))
+            ->get()
+            ->toArray();
+        return $oneLevelData;
+
+    }
+}

+ 159 - 0
app/Admin/Controllers/TrainDrillController.php

@@ -0,0 +1,159 @@
+<?php
+namespace App\Admin\Controllers;
+use App\Admin\Controllers\RowAction\CustomAction;
+use App\Models\MentalityDrill;
+use App\Models\MentalityDrillCategory;
+use Encore\Admin\Admin;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+use Illuminate\Support\Facades\Log;
+
+class TrainDrillController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '心理训练 内容管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new MentalityDrill());
+
+        $oneLevelData = MentalityDrillCategory::query()
+            ->where(array("pid"=>0))
+            ->select(array("id","name"))
+            ->get()
+            ->toArray();
+        if (!empty($oneLevelData)){
+            $oneLevelData = array_column($oneLevelData,"name","id");
+        }
+        $grid->column('id', __('Id'));
+        $subjectData = MentalityDrillCategory::query()
+            ->where(array("is_subject"=>MentalityDrillCategory::isSubjectYes))
+            ->select(array("id","name"))
+            ->get()
+            ->toArray();
+        if (!empty($subjectData)){
+            $subjectData = array_column($subjectData,"name","id");
+        }
+        $grid->filter(function(\Encore\Admin\Grid\Filter $filter) use ($oneLevelData){
+            // 在这里添加字段过滤器
+            $filter->like('title', '标题');
+            $filter->equal('category_id', '训练')->select(
+                $oneLevelData
+            );
+            $filter->expand();
+        });
+        $grid->column('category_id', __('一级分类'))->display(function ($categoryId)  use ($oneLevelData,$subjectData){
+            if ($categoryId > 0 && isset($oneLevelData[$categoryId])){
+                return isset($subjectData[$categoryId]) ? $oneLevelData[$categoryId]." [课程]" : $oneLevelData[$categoryId];
+            }
+            return '';
+        });
+        $grid->column('two_category_id', __('二级分类'))->display(function ($twoCategoryId)  use ($oneLevelData){
+            if ($twoCategoryId>0){
+                $twoLevelData = MentalityDrillCategory::query()
+                    ->where(array("id"=>$twoCategoryId))
+                    ->select(array("id","name"))
+                    ->first();
+                if ($twoLevelData){
+                    return  $twoLevelData->name;
+                }
+            }
+            return '';
+        });
+        $grid->column('title', __('标题'));
+        $grid->column('number_of_studies', __('学习次数'));
+        $grid->column('rank', __('排序 越大越前'));
+
+        $grid->column('rank', __('排序 越大越前'));
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+        $grid->actions(function (Grid\Displayers\Actions $actions) use ($subjectData) {
+            $categoryId = $actions->row->category_id;
+            if (isset($subjectData[$categoryId])){
+                $actions->add(new CustomAction(
+                    "课程列表",
+                    admin_url("/mentality_drill_subject")."?".
+                    http_build_query(array("mentality_drills_id"=>$actions->row->id))
+                ));
+            }
+           // 去掉删除
+            $actions->disableDelete();
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(MentalityDrill::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('category_id', __('Category id'));
+        $show->field('title', __('Title'));
+        $show->field('subtitle', __('Subtitle'));
+        $show->field('pic', __('Pic'));
+        $show->field('content', __('Content'));
+        $show->field('number_of_studies', __('Number of studies'));
+        $show->field('rank', __('Rank'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+        $show->field('deleted_at', __('Deleted at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new MentalityDrill());
+        Admin::script("
+            $(document).ready(function() {
+                    // 页面加载完毕后执行的代码
+                    console.log('页面已加载完毕');
+                     $('.category_id').trigger('change');
+           });
+        ");
+        $oneLevelData = MentalityDrillCategory::query()
+            ->where(array("pid"=>0))
+            ->select(array("id","name"))
+            ->get()
+            ->toArray();
+        if (!empty($oneLevelData)){
+            $oneLevelData = array_column($oneLevelData,"name","id");
+        }
+        $form->select('category_id', '一级分类')
+            ->options($oneLevelData)
+            ->load('two_category_id', '/admin/lowerLevel')
+            ->required();
+        $form->select('two_category_id', '二级分类')->options([]);
+        $form->text('title', __('标题'))->required();
+        $form->text('subtitle', __('副标题'))->required();
+        $form->image('pic', __('图片'))->removable()->uniqueName()->move('pics/'.date('Y').'/'.date('m'));
+        $form->editor('content', __('内容'))->required();
+        $form->number('number_of_studies', __('学习次数'))->default(0);
+        $form->number('rank', __('排序 越大越前'))->default(0);
+        $form->list('comment_tag', __('推荐标签'));
+        return $form;
+    }
+
+}

+ 49 - 0
app/Admin/Controllers/UploadController.php

@@ -0,0 +1,49 @@
+<?php
+namespace App\Admin\Controllers;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Support\Facades\Storage;
+use Illuminate\Http\Request;
+use App\Repositories\Eloquent\BaseRepository;
+
+/**
+ *
+ * @author lilin
+ *        
+ */
+class UploadController extends Controller
+{
+    public function store(Request $request){
+        $save=array();
+        $all_file=$request->allFiles();
+        foreach ($all_file['wangEditorH5File'] as $key => $value) {
+            if ($value->isValid()) {
+                $result = '/storage/'.Storage::disk("public")->putFile("editor", $value);
+                $save[]=config('app.url').$result;
+            }
+        }
+        echo json_encode(array('errno'=>0,'data'=>$save));
+    }
+    
+    public function imUploadPic(Request $request)
+    {
+        $dst = 'im';
+        
+        $file = $request->file('file');
+        
+        $picInfo = getimagesize($file);
+        if (! $picInfo) {
+            return self::returnCode('sys.notImageFile');
+        }
+        
+        $srcPath = $file->getPathname();
+        $extension = $file->getClientOriginalExtension();
+        //         $fileName = time() . rand(). '.' . $extension;
+        $dstPath = $dst . '/' . date('Ym') ;
+        
+        $path = $request->file('file')->store($dstPath);
+        
+        return ['code'=>1000, 'data'=>['pic'=>$path]];
+    }
+}
+

+ 27 - 0
app/Admin/bootstrap.php

@@ -0,0 +1,27 @@
+<?php
+
+// use Encore\WangEditor\WangEditor;
+
+/**
+ * Laravel-admin - admin builder based on Laravel.
+ * @author z-song <https://github.com/z-song>
+ *
+ * Bootstraper for Admin.
+ *
+ * Here you can remove builtin form field:
+ * Encore\Admin\Form::forget(['map', 'editor']);
+ *
+ * Or extend custom form field:
+ * Encore\Admin\Form::extend('php', PHPEditor::class);
+ *
+ * Or require js and css assets:
+ * Admin::css('/packages/prettydocs/css/styles.css');
+ * Admin::js('/packages/prettydocs/js/main.js');
+ *
+ */
+
+// Encore\Admin\Form::forget(['map', 'editor']);
+
+// Encore\Admin\Form::extend('wangeditor', WangEditor::class);
+// Encore\Admin\Form::extend('largefile', \Encore\LargeFileUpload\LargeFileField::class);
+// Encore\Admin\Form::extend('chunk_file', \Encore\ChunkFileUpload\ChunkFileField::class);

+ 103 - 0
app/Admin/routes.php

@@ -0,0 +1,103 @@
+<?php
+
+use App\Admin\Controllers\OpenWeixinController;
+use App\Admin\Controllers\RemoteSsoController;
+use EasyWeChat\Factory;
+use EasyWeChat\OpenPlatform\Server\Guard;
+use Encore\Admin\Facades\Admin;
+use Illuminate\Routing\Router;
+use Illuminate\Support\Facades\Route;
+
+Admin::routes();
+
+Route::group([
+    'prefix'        => config('admin.route.prefix'),
+    'namespace'     => config('admin.route.namespace'),
+    'middleware'    => config('admin.route.middleware'),
+    'as'            => config('admin.route.prefix') . '.',
+], function (Router $router) {
+
+    $router->get('/', 'HomeController@index')->name('home');
+    //上传图片
+    $router->resource('upload', 'UploadController');
+    //Banner管理
+    $router->resource('banner', 'BannerController');
+    //专家来了-一级栏目管理
+    $router->resource('specialist_column', 'SpecialistColumnController');
+    //专家来了-二级栏目管理
+    $router->resource('specialist_column_second', 'SpecialistColumnSecondController');
+    //只显示对应的二级栏目
+    $router->get('/second_column', 'SpecialistColumnSecondController@secondCloumn')->name('second_column');
+    //专家来了-内容管理
+    $router->resource('specialist_content', 'SpecialistContentController');
+    //专家来了-标签管理
+    $router->resource('specialist_tag', 'SpecialistColumnTagController');
+    //只显示对应的标签列表
+    $router->get('/tags', 'SpecialistColumnTagController@tags')->name('tags');
+
+    //心理大厅-训练-分类
+    $router->resource('train_category', 'TrainCategoryController');
+    //获取下级分类
+    $router->get('/lowerLevel', 'TrainCategoryController@lowerLevel');
+    //心理大厅-训练-内容-课程
+    $router->resource('mentality_drill_subject', 'MentalityDrillsSubjectController');
+    //心理大厅-训练-内容
+    $router->resource('mentality-drills', 'TrainDrillController');
+    //心理大厅-训练-内容-音视频
+    $router->resource('mentality-drill-extends', 'MentalityDrillExtendController');
+    //心情等级
+    $router->resource('diary-mood-levels', 'DiaryMoodLevelController');
+    //心情标签
+    $router->resource('diary-mood-tags', 'DiaryMoodTagController');
+    //睡眠等级
+    $router->resource('diary-sleep-levels', 'DiarySleepLevelController');
+    //量表分类
+    $router->resource('scale-categories', 'ScaleCategoryController');
+    //量表
+    $router->resource('scales', 'ScaleController');
+    //系统配制
+    $router->resource('sys-configs', 'SysConfigController');
+    //APP版本
+    $router->resource('sys-versions', 'SysVersionController');
+    //活动
+    $router->resource('activities', 'FourActivityController');
+    //活动区域
+    $router->resource('activity-ranges', 'ActivityRangeController');
+    //聊天
+    $router->resource('chat', 'ChatController');
+    //远程授权登录
+    $router->get('remoteSso', "RemoteSsoController@login");
+    $router->get('ssoIndex', "FourActivityController@ssoIndex");
+//     $router->post('send_im_message', 'SendImMessageController@sendImMessage')->name('send_im_message');
+//     $router->get('get_im_message_list', 'SendImMessageController@getImMessageList')->name('get_im_message_list');
+//     $router->get('get_im_message_detail', 'SendImMessageController@getImMessageDetail')->name('get_im_message_detail');
+});
+
+//测试
+Route::get('admin/openweixin/index', OpenWeixinController::class.'@index');
+Route::post('admin/openweixin/index', OpenWeixinController::class.'@index');
+Route::get('admin/openweixin/auth', OpenWeixinController::class.'@auth');
+Route::post('admin/openweixin/auth', OpenWeixinController::class.'@auth');
+Route::get('admin/openweixin/callback', OpenWeixinController::class.'@callback');
+Route::post('admin/openweixin/callback', OpenWeixinController::class.'@callback');
+Route::post('admin/openweixin/getThirdToken', OpenWeixinController::class.'@getThirdToken');
+Route::get('admin/openweixin/getThirdToken', OpenWeixinController::class.'@getThirdToken');
+Route::post('admin/openweixin/index/{appId}', function ($appId) {
+    // ...
+     $config = [
+        'app_id' => 'wxe81efa7fd6a5fd53',
+        'secret' => '7d22f52938e4c9fbb5f2d07e8f5b83b6',
+        'token' => '6lfq90croi6nsyia63vbhaqnq4lzm66d',
+        'aes_key' => 'uOIvZHtyDKKd7xT4KKgpikGOtgW7ZskeOzVIFgIs2SM'
+    ];
+    $openPlatform = Factory::openPlatform($config);
+    // 第三方平台接入处理
+    $officialAccount = $openPlatform->officialAccount($appId);
+    $server = $officialAccount->server; // ❗️❗️  这里的 server 为授权方的 server,而不是开放平台的 server,请注意!!!
+
+//    $server->push(function () {
+//        return 'Welcome!';
+//    });
+
+    return $server->serve();
+});

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

+ 64 - 0
app/Exceptions/HOError.php

@@ -0,0 +1,64 @@
+<?php
+namespace App\Exceptions;
+
+use App\Exceptions\Repositories\HOException as HOException;
+
+class HOError
+{
+
+    public function generalErr()
+    {
+        throw new HOException('General Error Occurred', 1001);
+    }
+
+    public function fail($msg = '失败')
+    {
+        throw new HOException($msg, 1002);
+    }
+
+    public function dataDoesNotExist()
+    {
+        throw new HOException('数据不存在', 1003);
+    }
+
+    public function dataDoesExist($msg = '数据已存在')
+    {
+        throw new HOException($msg, 1004);
+    }
+
+    public function authenticationFailed()
+    {
+        throw new HOException('API认证失败', 1005);
+    }
+
+    public function tokenDoesNotExist()
+    {
+        throw new HOException('登陆验证失败,重新登陆', 1006);
+    }
+
+    public function userDoesNotExist()
+    {
+        throw new HOException('用户不存在', 1007);
+    }
+
+    public function wrongPassword()
+    {
+        throw new HOException('密码错误', 1008);
+    }
+
+    public function wrongPayPassword()
+    {
+        throw new HOException('支付密码错误', 1009);
+    }
+
+    public function notImageFile()
+    {
+        throw new HOException('文件不是图片', 1010);
+    }
+
+    public function uploadImageFalse()
+    {
+        throw new HOException('图片上传失败', 1011);
+    }
+    
+}

+ 74 - 0
app/Exceptions/Handler.php

@@ -0,0 +1,74 @@
+<?php
+
+namespace App\Exceptions;
+
+use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
+use Throwable;
+use Illuminate\Support\Facades\Log;
+use App\Exceptions\Repositories\HOException;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+
+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',
+    ];
+
+    /**
+     * Report or log an exception.
+     *
+     * @param  \Throwable  $exception
+     * @return void
+     *
+     * @throws \Exception
+     */
+    public function report(Throwable $exception)
+    {
+        parent::report($exception);
+    }
+
+    /**
+     * Render an exception into an HTTP response.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Throwable  $exception
+     * @return \Symfony\Component\HttpFoundation\Response
+     *
+     * @throws \Throwable
+     */
+    public function render($request, Throwable $exception)
+    {
+        // FIXME LILIN 对详细的错误信息,进行记录,但是不返回给前端
+        if ($exception instanceof HOException) {
+            $msg = $exception->getMessage();
+            $code = $exception->getCode();
+        } elseif ($exception instanceof NotFoundHttpException) {
+            $msg    = 'not found page';
+            $code   = - 404;
+        } else {
+            Log::error(parent::render($request, $exception));
+            
+            $msg    = 'Server Bad';
+            $code   = - 500;
+        }
+        
+        return response()->horesp($code, null, $msg);
+        
+        return parent::render($request, $exception);
+    }
+}

+ 10 - 0
app/Exceptions/Repositories/HOException.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Exceptions\Repositories;
+
+use Exception;
+
+class HOException extends Exception
+{
+    //
+}

+ 16 - 0
app/Facades/AiChatContentFacade.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array sendData(int $userId,string $conversation_id,string $content);
+ * @method static array getChatContentList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ */
+class AiChatContentFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'AiChatContentFacadeRepository';
+    }
+}
+

+ 17 - 0
app/Facades/ApiSignFacade.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array auth($encryptedStr, $random, $timesTamp)
+ *
+ *
+ */
+class ApiSignFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'ApiSignFacadeRepository';
+    }
+}
+

+ 16 - 0
app/Facades/BannerFacade.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ *        
+ */
+class BannerFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'BannerFacadeRepository';
+    }
+}

+ 19 - 0
app/Facades/BrowseRecordFacade.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class BrowseRecordFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'BrowseRecordFacadeRepository';
+    }
+}
+

+ 19 - 0
app/Facades/CollectFacade.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class CollectFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'CollectFacadeRepository';
+    }
+}
+

+ 19 - 0
app/Facades/DiaryLetterFacade.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class DiaryLetterFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'DiaryLetterFacadeRepository';
+    }
+}
+

+ 23 - 0
app/Facades/DiaryMoodFacade.php

@@ -0,0 +1,23 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ * 
+ * @method static array getWeek(int $uid, int $page);
+ * @method static array getWeekDetailByDay(int $uid, string $day);
+ */
+class DiaryMoodFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'DiaryMoodFacadeRepository';
+    }
+}
+

+ 20 - 0
app/Facades/DiaryMoodLevelFacade.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class DiaryMoodLevelFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'DiaryMoodLevelFacadeRepository';
+    }
+}
+

+ 20 - 0
app/Facades/DiaryMoodTagFacade.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class DiaryMoodTagFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'DiaryMoodTagFacadeRepository';
+    }
+}
+

+ 20 - 0
app/Facades/DiarySleepFacade.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class DiarySleepFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'DiarySleepFacadeRepository';
+    }
+}
+

+ 20 - 0
app/Facades/DiarySleepLevelFacade.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class DiarySleepLevelFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'DiarySleepLevelFacadeRepository';
+    }
+}
+

+ 20 - 0
app/Facades/MentalityDrillCategoryFacade.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class MentalityDrillCategoryFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'MentalityDrillCategoryFacadeRepository';
+    }
+}
+

+ 24 - 0
app/Facades/MentalityDrillFacade.php

@@ -0,0 +1,24 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ * @method static array thumbsUpNum(int $id, int $userId);
+ * @method static array loveNum(int $id, int $userId);
+ * @method static array leaveMessage(int $id, int $userId, string $message);
+ * @method static array getDrillExtend(array $conditions, array $fields);
+ */
+class MentalityDrillFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'MentalityDrillFacadeRepository';
+    }
+}
+

+ 20 - 0
app/Facades/PatientCardFacade.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class PatientCardFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'PatientCardFacadeRepository';
+    }
+}
+

+ 19 - 0
app/Facades/RemoteSsoFacade.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Facades;
+use Illuminate\Http\Request;
+use Illuminate\Http\Response;
+use Illuminate\Support\Facades\Facade;
+/**
+ * @des  远程访问操作
+ * @method static mixed  verifyVisitUrl(Request $request,Response $response);
+ * @method static array getUserData(string $openId);
+ * @method static array getUserMenuWebsiteData(string $openId);
+ * @method static string getSign(array  $sendData,string $op="user",string $task="getUserInfo",string $version="1.0.0");
+ */
+class RemoteSsoFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'RemoteSsoFacadeRepository';
+    }
+}
+

+ 19 - 0
app/Facades/ScaleCategoryFacade.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class ScaleCategoryFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'ScaleCategoryFacadeRepository';
+    }
+}
+

+ 21 - 0
app/Facades/ScaleFacade.php

@@ -0,0 +1,21 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ * 
+ * @method static array createThirdScale(int $start, int $count, string $keyword);
+ */
+class ScaleFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'ScaleFacadeRepository';
+    }
+}
+

+ 20 - 0
app/Facades/SpecialistCloumnFacade.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class SpecialistCloumnFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'SpecialistCloumnFacadeRepository';
+    }
+}
+

+ 24 - 0
app/Facades/SpecialistInfoFacade.php

@@ -0,0 +1,24 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ * @method static array thumbsUpNum(int $id,int $userId);
+ * @method static array loveNum(int $id,int $userId);
+ * @method static array leaveMessage(int $id,int $userId,string $message);
+ * @method static array specialistInfosAssociationList(int $userId, int $associationType,int $page, int $limit);
+ */
+class SpecialistInfoFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'SpecialistInfoFacadeRepository';
+    }
+}
+

+ 17 - 0
app/Facades/StatisticsFacade.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array select($showDay = FALSE, $day = 1, $showMonth = FALSE, $month = 1, $showYear = FALSE);
+ * @method static array mood(int $uid, string $typeStr);
+ * @method static array sleep(int $uid, string $typeStr);
+ */
+class StatisticsFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'StatisticsFacadeRepository';
+    }
+}
+

+ 20 - 0
app/Facades/SysConfigFacade.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ * @method static array weather(string $cityid);
+ */
+class SysConfigFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'SysConfigFacadeRepository';
+    }
+}
+

+ 30 - 0
app/Facades/ThirdConsultFacade.php

@@ -0,0 +1,30 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *
+ * @method static array getDepartment();
+ * @method static array getDoctor(array $postArr);
+ * @method static array customerCreate(string $open_id, string $id_card, string $name, int $sex, int $marry_type, int $age, string $contact, int $wechat_uid);
+ * @method static array hospWorkSave(string $day);
+ * @method static array hospWork(string $dockor_open_id, string $work_date_start, string $work_date_end);
+ * @method static array outApply(string $open_id, string $work_open_id, int $time_select);
+ * @method static array outConfirm(string $apply_open_id, string $visit_card_no, string $prepay_id, int $pay_money, string $pay_time);
+ * @method static array outCancel(string $apply_open_id);
+ * @method static array uploadFile(string $open_id, $filename, int $file_type);
+ * @method static array moduleList(int $start, int $count, string $keyword='',string $mid='');
+ * @method static array orderSelect(string $openId, int $payStatus=0, int $orderType=0);
+ * @method static array orderSync(string $order_id, int $status, string $prepay_id, int $pay_money, string $pay_time, string $refund_id, string $refund_datetime, int $refund_money);
+ * @method static array hospMyOutModule(string $open_id);
+ * @method static array appLogin(string $open_id, string $order_id);
+ * @method static array jssdkGetMedia(string $media_id);
+ */
+class ThirdConsultFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'ThirdConsultFacadeRepository';
+    }
+}
+

+ 16 - 0
app/Facades/ThirdH5ChatFacade.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static string getChatUrl($uid, $nickname, $headUrl);
+ *
+ */
+class ThirdH5ChatFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'ThirdH5ChatFacadeRepository';
+    }
+}
+

+ 20 - 0
app/Facades/ThirdScaleFacade.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static string sign(string $op, string $task, string $version, array $parameter);
+ * @method static array getScale(int $start, int $count, string $keyword);
+ * @method static array createPush(string $openid, string $mid);
+ * @method static array customerCreate(string $name, string $openId=null, int $sex=1);
+ * @method static array appLogin(string $thirdOpenId, string $pushId, string $reportId);
+ *
+ */
+class ThirdScaleFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'ThirdScaleFacadeRepository';
+    }
+}
+

+ 16 - 0
app/Facades/ThirdUpFacade.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array login(string $username, string $password);
+ *
+ */
+class ThirdUpFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'ThirdUpFacadeRepository';
+    }
+}
+

+ 17 - 0
app/Facades/ThirdWxFacade.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array authorization();
+ * @method static array getUserInfo(string $weichatUid);
+ *
+ */
+class ThirdWxFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'ThirdWxFacadeRepository';
+    }
+}
+

+ 16 - 0
app/Facades/UploadFacade.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array pic($file, $dst = 'product');
+ *  
+ */
+class UploadFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'UploadFacadeRepository';
+    }
+}
+

+ 20 - 0
app/Facades/UserFacade.php

@@ -0,0 +1,20 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array findLoginBy(int $id)
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array wxWebLoginOrReg(string $code, string $ip, $wxUserInfo);
+ * @method static array appLoginOrReg(string $username, string $password, string $loginIp, int $platform);
+ * @method static array loginOut(string $token);
+ * @method static array updateBy(array $conditions, array $data);
+ */
+class UserFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'UserFacadeRepository';
+    }
+}
+

+ 19 - 0
app/Facades/VersionFacade.php

@@ -0,0 +1,19 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array getList(array $conditions, array $fields, string $sort, int $page, int $limit);
+ * @method static array findBy(array $conditions, array $fields);
+ * @method static array create(array $data);
+ * @method static array updateBy(array $conditions, array $data);
+ * @method static array deleteBy(array $conditions);
+ */
+class VersionFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'VersionFacadeRepository';
+    }
+}
+

+ 22 - 0
app/Facades/WxDecryptFacade.php

@@ -0,0 +1,22 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array xmlToArray($xml);
+ * @method static array arrayToXml(array $config);
+ * @method static array getSHA1($timestamp, $nonce, $encrypt_msg);
+ * @method static array sendWxHttp($url, $content);
+ * @method static array decryptMsg($array, $msgSignature, $timestamp = null, $nonce);
+ * @method static array decrypt($encrypted);
+ * @method static array decode($text);
+ *
+ */
+class WxDecryptFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'WxDecryptFacadeRepository';
+    }
+}
+

+ 15 - 0
app/Facades/WxNotificationFacade.php

@@ -0,0 +1,15 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ *  @method static array getNotification(string $xml, $request);
+ */
+class WxNotificationFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'WxNotificationFacadeRepository';
+    }
+}
+

+ 23 - 0
app/Facades/WxServiceFacade.php

@@ -0,0 +1,23 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array getAccessToken();
+ * @method static array getUserInfo(string $openid);
+ * @method static array checkSignature(string $signature, string $echostr, string $timestamp, string $nonce);
+ * @method static array getJsapiTicket();
+ * @method static array getJsapiSign(string $url);
+ * @method static array sendTplMsg(string $touser, string $templateId, string $jumpUrl, array $data);
+ * @method static array sendMessage(string $toUser, string $msgType, array $msg);
+ * @method static array createMenu(array $menu);
+ *        
+ */
+class WxServiceFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'WxServiceFacadeRepository';
+    }
+}
+

+ 16 - 0
app/Facades/WxServiceKfFacade.php

@@ -0,0 +1,16 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array getAccessToken();
+ *        
+ */
+class WxServiceKfFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'WxServiceKfFacadeRepository';
+    }
+}
+

+ 17 - 0
app/Facades/WxUserFacade.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+/**
+ * @method static array getAccessToken(string $code);
+ * @method static array getUserInfo(string $accessToken, string $openid);
+ *        
+ */
+class WxUserFacade extends Facade
+{
+    protected static function getFacadeAccessor(){
+        return 'WxUserFacadeRepository';
+    }
+}
+

+ 272 - 0
app/Helper.php

@@ -0,0 +1,272 @@
+<?php
+use Illuminate\Support\Facades\Redis;
+
+function statics($file)
+{
+    return config('console.static_url') . $file . '?v=' . config('console.static_v');
+}
+
+/**
+ * 截取REQUEST_URI
+ *
+ * @param string $URL
+ *            REQUEST_URI
+ */
+function REQUEST_URI($URL, $ARR)
+{
+    $U = explode("?", $URL);
+    $B = false;
+    foreach ($ARR as $key => $value) {
+        if ($value === $U[0]) {
+            $B = true;
+        }
+    }
+    return $B;
+}
+
+/**
+ * 加密
+ *
+ * @param string $str
+ * @return string
+ */
+function setSha256(string $str): string
+{
+    return hash('sha256', $str);
+}
+
+if (! function_exists('captchaApiCheck')) {
+
+    /**
+     *
+     * @param
+     *            $value
+     * @return bool
+     */
+    function captchaApiCheck($value, $key)
+    {
+        $ridisKey = config('console.redis_key.captcha_key') . $key;
+        
+        if (! Redis::EXISTS($ridisKey)) {
+            return FALSE;
+        } else {
+            Redis::del($ridisKey);
+            return app('captcha')->check_api($value, $key);
+        }
+    }
+}
+
+function makeSn()
+{
+    $order_id_main = date('YmdHis') . rand(10000000, 99999999);
+    
+    $order_id_len = strlen($order_id_main);
+    
+    $order_id_sum = 0;
+    
+    for ($i = 0; $i < $order_id_len; $i ++) {
+        
+        $order_id_sum += (int) (substr($order_id_main, $i, 1));
+    }
+    return $order_id_main . str_pad((100 - $order_id_sum % 100) % 100, 2, '0', STR_PAD_LEFT);
+}
+
+function stringLength($string)
+{
+    $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";
+    preg_match_all($re['utf-8'], $string, $match);
+    return count($match[0]);
+}
+
+function picPath($path)
+{
+    return asset('storage/' . $path);
+}
+
+/**
+ * 数字转换为中文
+ *
+ * @param integer $num
+ *            目标数字
+ */
+function number2Chinese(int $num)
+{
+    if (is_int($num) && $num < 100) {
+        $char = array(
+            '零',
+            '一',
+            '二',
+            '三',
+            '四',
+            '五',
+            '六',
+            '七',
+            '八',
+            '九'
+        );
+        $unit = [
+            '',
+            '十',
+            '百',
+            '千',
+            '万'
+        ];
+        $return = '';
+        if ($num < 10) {
+            $return = $char[$num];
+        } elseif ($num % 10 == 0) {
+            $firstNum = substr($num, 0, 1);
+            if ($num != 10)
+                $return .= $char[$firstNum];
+            $return .= $unit[strlen($num) - 1];
+        } elseif ($num < 20) {
+            $return = $unit[substr($num, 0, - 1)] . $char[substr($num, - 1)];
+        } else {
+            $numData = str_split($num);
+            $numLength = count($numData) - 1;
+            foreach ($numData as $k => $v) {
+                if ($k == $numLength)
+                    continue;
+                $return .= $char[$v];
+                if ($v != 0)
+                    $return .= $unit[$numLength - $k];
+            }
+            $return .= $char[substr($num, - 1)];
+        }
+        return $return;
+    }
+}
+
+/**
+ * 数字星期转中文
+ *
+ * @param int $num
+ * @return string
+ */
+function week2Chinese(int $num)
+{
+    $weekArray = [
+        "日",
+        "一",
+        "二",
+        "三",
+        "四",
+        "五",
+        "六"
+    ];
+    return $weekArray[$num];
+}
+
+/**
+ * 中文数值转数字
+ *
+ * @param   string $str
+ * @return  string
+ */
+function chinese2Number(string $str)
+{
+    $map = array(
+        '一' => '1',
+        '二' => '2',
+        '三' => '3',
+        '四' => '4',
+        '五' => '5',
+        '六' => '6',
+        '七' => '7',
+        '八' => '8',
+        '九' => '9',
+        '壹' => '1',
+        '贰' => '2',
+        '叁' => '3',
+        '肆' => '4',
+        '伍' => '5',
+        '陆' => '6',
+        '柒' => '7',
+        '捌' => '8',
+        '玖' => '9',
+        '零' => '0',
+        '两' => '2',
+        '仟' => '千',
+        '佰' => '百',
+        '拾' => '十',
+        '万万' => '亿'
+    );
+    
+    $str = str_replace(array_keys($map), array_values($map), $str);
+    $str = checkString($str, '/([\d亿万千百十]+)/u');
+    
+    $func_c2i = function ($str, $plus = false) use(&$func_c2i) {
+        if(false === $plus) {
+            $plus = array('亿' => 100000000,'万' => 10000,'千' => 1000,'百' => 100,'十' => 10,);
+        }
+        
+        $i = 0;
+        if($plus){
+            foreach($plus as $k => $v) {
+                $i++;
+                if(strpos($str, $k) !== false) {
+                    $ex = explode($k, $str, 2);
+                    $new_plus = array_slice($plus, $i, null, true);
+                    $l = $func_c2i($ex[0], $new_plus);
+                    $r = $func_c2i($ex[1], $new_plus);
+                    if($l == 0) $l = 1;
+                    return $l * $v + $r;
+                }
+            }
+            return (int)$str;
+        }
+    };
+    
+    return $func_c2i($str);
+}
+
+/**
+ * 中文数值转数字,检查中文字符串是否满足条件
+ *
+ * @param string    $var
+ * @param string    $check
+ * @param string    $default
+ * @return string
+ */
+function checkString(string $var, $check = '', $default = '')
+{
+    if (! is_string($var)) {
+        if (is_numeric($var)) {
+            $var = (string) $var;
+        } else {
+            return $default;
+        }
+    }
+    if ($check) {
+        return (preg_match($check, $var, $ret) ? $ret[1] : $default);
+    }
+    
+    return $var;
+}
+
+/**
+ * 身份证号获取信息
+ *
+ * @param string $idcard 身份证号
+ * @return array
+ */
+function idCardInfo($idcard)
+{
+    //性别
+    $sex = substr($idcard, (strlen($idcard) == 18 ? - 2 : - 1), 1) % 2 ? '1' : '2';
+    //获得出生年月日的时间戳
+    $birthdays = strtotime(strlen($idcard) == 15 ? ('19' . substr($idcard, 6, 6)) : substr($idcard, 6, 8));
+    
+    // 获得今日的时间戳
+    $today = time();
+    // 得到两个日期相差的大体年数
+    $diff = floor(($today - $birthdays) / 86400 / 365);
+    // strtotime加上这个年数后得到那日的时间戳后与今日的时间戳相比
+    $age = strtotime(substr($idcard, 6, 8) . ' +' . $diff . 'years') > $today ? ($diff + 1) : $diff;
+    
+    return [
+        'sex'       => $sex,
+        'birthday'  => date('Y-m-d', $birthdays),
+        'age'       => $age,
+    ];
+}

+ 72 - 0
app/Http/Controllers/Api/V1/BannerController.php

@@ -0,0 +1,72 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1;
+
+use Illuminate\Http\Request;
+use App\Facades\BannerFacade;
+
+class BannerController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [
+            'local_id' => request('local_id')
+        ];
+        $fields     = ['*'];
+        $sort       = '`rank` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        
+        return BannerFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 19 - 0
app/Http/Controllers/Api/V1/BaseController.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Support\Facades\Auth;
+
+class BaseController extends Controller
+{
+    /**
+     * 登陆用户id
+     *
+     * @return number|NULL
+     */
+    static public function auth()
+    {
+        return Auth::id();
+    }
+}

+ 43 - 0
app/Http/Controllers/Api/V1/Chat/AiChatController.php

@@ -0,0 +1,43 @@
+<?php
+namespace App\Http\Controllers\Api\V1\Chat;
+use App\Facades\AiChatContentFacade;
+use App\Http\Controllers\Api\V1\BaseController;
+use Illuminate\Http\Request;
+
+/**
+ * AI聊天
+ */
+class AiChatController extends BaseController
+{
+    /**
+     * 发送聊天数据
+     * @param Request $request
+     * @return array
+     */
+    public function sendData(Request $request)
+    {
+        return AiChatContentFacade::sendData(
+            (int)$this->auth(),
+            strval($request->get("conversation_id","")),
+            strval($request->get("content",""))
+        );
+    }
+
+    /**
+     * 聊天历史,列表分页
+     * @return array
+     */
+    public function index()
+    {
+        $conditions = [
+            'Robot'  => true,
+            'user_id' => $this->auth(),
+            "conversation_id"=>request('conversation_id', null)
+        ];
+        $fields     = ['*'];
+        $sort       = '`id` asc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        return AiChatContentFacade::getChatContentList($conditions, $fields, $sort, $page, $limit);
+    }
+}

+ 90 - 0
app/Http/Controllers/Api/V1/CommendController.php

@@ -0,0 +1,90 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1;
+
+use Illuminate\Http\Request;
+use App\Facades\MentalityDrillFacade;
+use App\Facades\ScaleFacade;
+use App\Facades\SpecialistInfoFacade;
+
+class CommendController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $commentTag = request('comment_tag');
+        if ($commentTag){
+            $commentTag = explode(',', $commentTag);
+        }
+        $conditions = [
+            'comment_tag' => $commentTag
+        ];
+
+        $fields     = ['*'];
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        switch (request('type')){
+            case 1: //训练
+                $sort       = '`number_of_studies` desc, `id` desc';
+                return MentalityDrillFacade::getList($conditions, $fields, $sort, $page, $limit);
+                break;
+            case 2: //量表
+                $sort       = '`number_of_test` desc, `id` desc';
+                return ScaleFacade::getList($conditions, $fields, $sort, $page, $limit);
+                break;
+            case 3: //文章(专家来了)
+                $sort       = '`number_of_studies` desc, `id` desc';
+                return SpecialistInfoFacade::getList($conditions, $fields, $sort, $page, $limit);
+                break;
+        }
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 65 - 0
app/Http/Controllers/Api/V1/LoginOutController.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1;
+
+use Illuminate\Http\Request;
+use App\Facades\UserFacade;
+
+class LoginOutController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        $token = $request->header('token');
+        return UserFacade::loginOut($token);
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 74 - 0
app/Http/Controllers/Api/V1/Mentality/BrowseRecordController.php

@@ -0,0 +1,74 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\BrowseRecordFacade;
+
+class BrowseRecordController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [
+            'uid'       => $this->auth(),
+            'column'    => request('column')
+        ];
+        $fields     = ['*'];
+        $sort       = '`id` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        
+        return BrowseRecordFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 77 - 0
app/Http/Controllers/Api/V1/Mentality/CollectController.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\CollectFacade;
+
+class CollectController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [
+            'uid' => $this->auth()
+        ];
+        $fields     = ['*'];
+        $sort       = '`id` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+
+        return CollectFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        $data           = $request->only(['column','object_id']);
+        $data['uid']    = $this->auth();
+        $data['repeat'] = 'uid:'.$data['uid'].' column:'.$data['column'].' object_id:'.$data['object_id'];
+
+        return CollectFacade::create($data);
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 76 - 0
app/Http/Controllers/Api/V1/Mentality/DrillCategoryController.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\MentalityDrillCategoryFacade;
+
+class DrillCategoryController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index(Request  $request)
+    {
+        $conditions = [];
+        $fields     = ['*'];
+        $sort       = '`rank` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        $requestUri = $request->getRequestUri();
+        if ($requestUri!=null){
+            if (strstr($requestUri,"mentality/drill_category")){
+                $conditions["isSubject"] = true;
+            }
+        }
+        return MentalityDrillCategoryFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 163 - 0
app/Http/Controllers/Api/V1/Mentality/DrillController.php

@@ -0,0 +1,163 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use App\Models\MentalityDrillsSubject;
+use Illuminate\Http\Request;
+use App\Facades\MentalityDrillFacade;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\BrowseRecordFacade;
+use App\Models\BrowseRecord;
+
+class DrillController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $commentTag = request('comment_tag');
+        if ($commentTag){
+            $commentTag = json_decode($commentTag);
+        }
+
+        $conditions = [
+            'category_id' => request('category_id'),
+            'search'      => request('search'),
+            'comment_tag' => $commentTag
+        ];
+        $fields     = ['*'];
+
+
+        switch (request('sort')) {
+            case 1: // 最新上架
+                $sort = '`id` desc';
+                break;
+            case 2: // 最受欢迎
+                $sort = '`number_of_studies` desc';
+                break;
+            default:
+                $sort = '`rank` desc, `id` desc';
+        }
+
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+
+        return MentalityDrillFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        $conditions = [
+            'id'    => $id
+        ];
+
+        $record = [
+            'uid'       => $this->auth(),
+            'column'    => BrowseRecord::COLUMN_2,
+            'object_id' => $id,
+            'repeat'    => 'uid:'.$this->auth().' column:'.BrowseRecord::COLUMN_2.' object_id:'.$id
+        ];
+        //加入浏览记录
+        try {
+            BrowseRecordFacade::create($record);
+        } catch (\Exception $e) {
+
+        }
+
+        return MentalityDrillFacade::findBy($conditions, ['*']);
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * 播放训练科目
+     * @param int $id
+     * @return mixed
+     */
+    public function playSubject(int $id)
+    {
+        $record = [
+            'uid'       => $this->auth(),
+            'column'    => BrowseRecord::COLUMN_4,
+            'object_id' => $id,
+            'repeat'    => 'uid:'.$this->auth().' column:'.BrowseRecord::COLUMN_4.' object_id:'.$id
+        ];
+        //加入浏览记录
+        try {
+            BrowseRecordFacade::create($record);
+        } catch (\Exception $e) {
+
+        }
+       return response()->horesp(1000, MentalityDrillsSubject::query()->find($id), "成功");
+    }
+    /**
+     * 点赞
+     * @param $id
+     * @return array
+     */
+    public function thumbsUpNum($id)
+    {
+        return MentalityDrillFacade::thumbsUpNum($id,$this->auth());
+    }
+    /**
+     * 喜欢
+     * @param $id
+     * @return array
+     */
+    public function loveNum($id)
+    {
+        return MentalityDrillFacade::loveNum($id,$this->auth());
+    }
+
+    /**
+     * 留言
+     * @param Request $request
+     * @return array
+     */
+    public function leaveMessage(Request $request)
+    {
+        $id = $request->get("id",0);
+        $message = $request->get("message",0);
+        return MentalityDrillFacade::leaveMessage($id,$this->auth(),$message);
+    }
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 104 - 0
app/Http/Controllers/Api/V1/Mentality/LetterController.php

@@ -0,0 +1,104 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\DiaryLetterFacade;
+use Carbon\Carbon;
+
+class LetterController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [
+            'uid'       => $this->auth(),
+            'send_time' => Carbon::now()
+        ];
+        $fields     = ['*'];
+        $sort       = '`send_time` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        
+        return DiaryLetterFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        $data['uid']    = $this->auth();
+        $data['content'] = $request->content;
+        
+        $now = Carbon::now();
+        switch ($request->type){
+            case 1: //半年
+                $sendTime = $now->addMonths(6);
+                break;
+            case 2: //1年
+                $sendTime = $now->addYears(1);
+                break;
+            case 3: //2年
+                $sendTime = $now->addYears(2);
+                break;
+            case 4: //3年
+                $sendTime = $now->addYears(3);
+                break;
+            case 5: //10年
+                $sendTime = $now->addYears(10);
+                break;
+        }
+        $data['send_time'] = $sendTime;
+
+        return DiaryLetterFacade::create($data);
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        $conditions = [
+            'id'    => $id,
+            'uid'   => $this->auth(),
+            'send_time' => Carbon::now()
+        ];
+        $fields = ['*'];
+        return DiaryLetterFacade::findBy($conditions, $fields);
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 87 - 0
app/Http/Controllers/Api/V1/Mentality/MoodController.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\DiaryMoodFacade;
+
+class MoodController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [
+            'uid' => $this->auth()
+        ];
+        $fields     = ['*'];
+        $sort       = '`id` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        
+        return DiaryMoodFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        $data           = $request->all();
+        $data['uid']    = $this->auth();
+        
+        return DiaryMoodFacade::create($data);
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        $conditions = [
+            'id'    => $id,
+            'uid'   => $this->auth()
+        ];
+        $fields = ['*'];
+        return DiaryMoodFacade::findBy($conditions, $fields);
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        $data = $request->all();
+        
+        $conditions = [
+            'id' => $id,
+            'uid' => $this->auth()
+        ];
+        return DiaryMoodFacade::updateBy($conditions, $data);
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 71 - 0
app/Http/Controllers/Api/V1/Mentality/MoodLevelController.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\DiaryMoodLevelFacade;
+
+class MoodLevelController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [];
+        $fields     = ['id','name','pic','color'];
+        $sort       = '`rank` desc, `id` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        
+        return DiaryMoodLevelFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 71 - 0
app/Http/Controllers/Api/V1/Mentality/MoodTagController.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\DiaryMoodTagFacade;
+
+class MoodTagController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [];
+        $fields     = ['id','name','color'];
+        $sort       = '`rank` desc, `id` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        
+        return DiaryMoodTagFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 91 - 0
app/Http/Controllers/Api/V1/Mentality/PatientCardController.php

@@ -0,0 +1,91 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\PatientCardFacade as ThisFacade;
+
+class PatientCardController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [
+            'uid' => $this->auth()
+        ];
+        $fields     = ['*'];
+        $sort       = '`id` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        
+        return ThisFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+    
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        $data = $request->all();
+        $data['uid'] = $this->auth();
+        
+        return ThisFacade::create($data);
+    }
+    
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        $conditions = [
+            'id'    => $id,
+            'uid'   => $this->auth()
+        ];
+        $fields = ['*'];
+        return ThisFacade::findBy($conditions, $fields);
+    }
+    
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        $data = $request->all();
+        
+        $conditions = [
+            'id' => $id,
+            'uid' => $this->auth()
+        ];
+        return ThisFacade::updateBy($conditions, $data);
+    }
+    
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        $conditions = [
+            'id' => $id,
+            'uid' => $this->auth()
+        ];
+        return ThisFacade::deleteBy($conditions);
+    }
+}

+ 69 - 0
app/Http/Controllers/Api/V1/Mentality/PlayController.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+use App\Facades\MentalityDrillFacade;
+
+class PlayController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        $conditions = [
+            'id'    => $id
+        ];
+        
+        return MentalityDrillFacade::getDrillExtend($conditions, ['*']);
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 71 - 0
app/Http/Controllers/Api/V1/Mentality/ScaleCategoryController.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\ScaleCategoryFacade;
+
+class ScaleCategoryController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [];
+        $fields     = ['*'];
+        $sort       = '`rank` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+
+        return ScaleCategoryFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 98 - 0
app/Http/Controllers/Api/V1/Mentality/ScaleController.php

@@ -0,0 +1,98 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\ScaleFacade;
+
+class ScaleController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $commentTag = request('comment_tag');
+        if ($commentTag){
+            $commentTag = json_decode($commentTag);
+        }
+
+        $conditions = [
+            'category_id'   => request('category_id'),
+            'search'        => request('search'),
+            'comment_tag'   => $commentTag
+        ];
+        // var_dump($conditions);exit;
+        $fields     = ['*'];
+        switch (request('sort')) {
+            case 1: // 最新上架
+                $sort = '`id` desc';
+                break;
+            case 2: // 最受欢迎
+                $sort = '`number_of_test` desc';
+                break;
+            default:
+                $sort = '`rank` desc, `id` desc';
+        }
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+
+        return ScaleFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        $conditions = ['id' => $id, 'uid'=>$this->auth()];
+        $fields = ['*'];
+
+        return ScaleFacade::findBy($conditions, $fields);
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+
+    public function startTest(Request $request){
+//           return ScaleFacade::createThirdScale(0, 100, '异性');
+        return ScaleFacade::startTest($this->auth(), intval($request->scale_id));
+    }
+}

+ 78 - 0
app/Http/Controllers/Api/V1/Mentality/SleepController.php

@@ -0,0 +1,78 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Facades\DiarySleepFacade;
+use App\Http\Controllers\Api\V1\BaseController;
+use Carbon\Carbon;
+
+class SleepController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [
+            'uid' => $this->auth()
+        ];
+        $fields     = ['*'];
+        $sort       = '`id` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        
+        return DiarySleepFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        $data           = $request->all();
+        $data['uid']    = $this->auth();
+        $data['day']    = Carbon::today()->toDateString();
+        $data['repeat'] = 'day:'.$data['day'].' uid:'.$data['uid'];
+        return DiarySleepFacade::create($data);
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 71 - 0
app/Http/Controllers/Api/V1/Mentality/SleepLevelController.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\DiarySleepLevelFacade;
+
+class SleepLevelController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [];
+        $fields     = ['id','name','pic','hover_pic','color'];
+        $sort       = '`rank` desc, `id` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        
+        return DiarySleepLevelFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 91 - 0
app/Http/Controllers/Api/V1/Mentality/StatisticsController.php

@@ -0,0 +1,91 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\StatisticsFacade;
+
+class StatisticsController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $type       = request('type');
+        switch (request('column')){
+            case 'mood':
+                return StatisticsFacade::mood($this->auth(), $type);
+                break;
+            case 'sleep':
+                return StatisticsFacade::sleep($this->auth(), $type);
+                break;
+        }
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+    
+    /**
+     * 心情下拉
+     *
+     * @return array
+     */
+    public function getMoodSelect(){
+        return StatisticsFacade::select(TRUE, 7, TRUE, 6, FALSE);
+    }
+    
+    /**
+     * 睡眠下拉
+     *
+     * @return array
+     */
+    public function getSleepSelect(){
+        return StatisticsFacade::select(FALSE, 1, TRUE, 6, FALSE);
+    }
+}

+ 65 - 0
app/Http/Controllers/Api/V1/Mentality/WeekController.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Mentality;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\DiaryMoodFacade;
+
+class WeekController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index(Request $request)
+    {
+        return DiaryMoodFacade::getWeek($this->auth(), $request->page);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($day)
+    {
+        return DiaryMoodFacade::getWeekDetailByDay($this->auth(), $day);
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 65 - 0
app/Http/Controllers/Api/V1/MpService/JsapiSignController.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\MpService;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Controller;
+use App\Facades\WxServiceFacade;
+
+class JsapiSignController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        return WxServiceFacade::getJsapiSign($request->url);
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 65 - 0
app/Http/Controllers/Api/V1/MpUser/AccessTokenController.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\MpUser;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Controller;
+use App\Facades\UserFacade;
+
+class AccessTokenController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        return UserFacade::wxWebLoginOrReg($request->code, $request->ip(),[]);
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 79 - 0
app/Http/Controllers/Api/V1/MpUser/MpUserController.php

@@ -0,0 +1,79 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\MpUser;
+
+use App\Facades\UserFacade;
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+
+class MpUserController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+        $code = request()->input('code');
+        if(!$code) {
+            return $this->error()->fail('code参数不能为空');
+        }
+        return UserFacade::wxMPLogin($code);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+        $code = request()->input('code');
+        if(!$code) {
+            return $this->error()->fail('code参数不能为空');
+        }
+        $wxUserInfo = request()->input('wx_user_info');
+        if(!$wxUserInfo) {
+            return $this->error()->fail('用户数据不能为空');
+        }
+        return UserFacade::wxMPRegister($code, $wxUserInfo);
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 65 - 0
app/Http/Controllers/Api/V1/ScoketConfigController.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+use App\Facades\SysConfigFacade;
+
+class ScoketConfigController extends BaseController
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        return SysConfigFacade::scoketConfig($this->auth());
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 78 - 0
app/Http/Controllers/Api/V1/Specialist/IndexController.php

@@ -0,0 +1,78 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Specialist;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Http\Request;
+use App\Facades\SpecialistCloumnFacade;
+use App\Models\SpecialistCloumn;
+
+class IndexController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        $conditions = [
+            'pid'       => request('pid', SpecialistCloumn::PID_0),
+            'is_show'   => SpecialistCloumn::IS_SHOW_1
+        ];
+        $fields     = ['*'];
+        $sort       = '`rank` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        
+        return SpecialistCloumnFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function show($id)
+    {
+        $conditions = [
+            'id'    => $id
+        ];
+        return SpecialistCloumnFacade::findBy($conditions, ['*']);
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

+ 148 - 0
app/Http/Controllers/Api/V1/Specialist/SpecialistInfoController.php

@@ -0,0 +1,148 @@
+<?php
+
+namespace App\Http\Controllers\Api\V1\Specialist;
+
+use App\Models\SpecialistInfosAssociation;
+use Illuminate\Http\Request;
+use App\Http\Controllers\Api\V1\BaseController;
+use App\Facades\SpecialistInfoFacade;
+use App\Models\SpecialistInfo;
+use App\Models\BrowseRecord;
+use App\Facades\BrowseRecordFacade;
+
+class SpecialistInfoController extends BaseController
+{
+
+    /**
+     * 专家来了,列表分页
+     * @return array
+     */
+    public function index()
+    {
+        $commentTag = request('comment_tag');
+        if ($commentTag){
+            $commentTag = json_decode($commentTag);
+        }
+
+        $conditions = [
+            'first_id'  => request('first_id'),
+            'second_id' => request('second_id') == 0 ? null : request('second_id'),
+            'tag_id'    => request('tag_id'),
+            'comment_tag' => $commentTag,
+            'name'=>request("name","")
+        ];
+        $fields     = ['*'];
+        $sort       = '`rank` desc, `id` desc';
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        return SpecialistInfoFacade::getList($conditions, $fields, $sort, $page, $limit);
+    }
+    /**
+     * 专家来了详情
+     * @param $id
+     * @return array
+     */
+    public function show($id)
+    {
+        $conditions = [
+            'id'=>$id
+        ];
+        $fields = ['*'];
+        $result = SpecialistInfoFacade::findBy($conditions, $fields);
+        //计数加1
+        SpecialistInfo::where('id', $id)->increment('number_of_studies');
+
+        $record = [
+            'uid'       => $this->auth(),
+            'column'    => BrowseRecord::COLUMN_3,
+            'object_id' => $id,
+            'repeat'    => 'uid:'.$this->auth().' column:'.BrowseRecord::COLUMN_3.' object_id:'.$id
+        ];
+        //加入浏览记录
+        try {
+            BrowseRecordFacade::create($record);
+        } catch (\Exception $e) {
+
+        }
+        return $result;
+    }
+
+    /**
+     * 点赞
+     * @param $id
+     * @return array
+     */
+    public function thumbsUpNum($id)
+    {
+        return SpecialistInfoFacade::thumbsUpNum($id,$this->auth());
+    }
+    /**
+     * 喜欢
+     * @param $id
+     * @return array
+     */
+    public function loveNum($id)
+    {
+        return SpecialistInfoFacade::loveNum($id,$this->auth());
+    }
+
+    /**
+     * 留言
+     * @param Request $request
+     * @return array
+     */
+    public function leaveMessage(Request $request)
+    {
+        $id = $request->get("id",0);
+        $message = $request->get("message",0);
+        return SpecialistInfoFacade::leaveMessage($id,$this->auth(),$message);
+    }
+    /**
+     * 得到专家信息关联列表
+     * @param Request $request
+     * @return array
+     */
+    public function specialistInfosAssociationList(Request $request)
+    {
+        $page       = request('page', 1);
+        $limit      = request('limit', 20);
+        $associationType = request('associationType', 20);
+        return SpecialistInfoFacade::specialistInfosAssociationList($this->auth(),$associationType,$page,$limit);
+    }
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+
+
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        //
+    }
+}

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