فهرست منبع

RedisClusters->Cache

visuddhinanda 2 ماه پیش
والد
کامیت
2b4e536060
41فایلهای تغییر یافته به همراه1093 افزوده شده و 803 حذف شده
  1. 2 2
      api-v12/app/Console/Commands/CacheDictPreference.php
  2. 34 30
      api-v12/app/Console/Commands/CacheWbwPreference.php
  3. 52 49
      api-v12/app/Console/Commands/ExportArticle.php
  4. 111 108
      api-v12/app/Console/Commands/ExportChapter.php
  5. 30 22
      api-v12/app/Console/Commands/ExportChapterIndex.php
  6. 1 2
      api-v12/app/Console/Commands/ExportOffline.php
  7. 4 4
      api-v12/app/Console/Commands/ExportZip.php
  8. 6 6
      api-v12/app/Console/Commands/MqAiTranslate.php
  9. 277 66
      api-v12/app/Console/Commands/StatisticsNissayaCover.php
  10. 68 59
      api-v12/app/Console/Commands/UpgradeChapterDynamicWeekly.php
  11. 66 61
      api-v12/app/Console/Commands/UpgradeDictDefaultMeaning.php
  12. 5 5
      api-v12/app/Http/Api/TaskApi.php
  13. 1 2
      api-v12/app/Http/Api/TemplateRender.php
  14. 22 23
      api-v12/app/Http/Controllers/ApiController.php
  15. 2 3
      api-v12/app/Http/Controllers/CorpusController.php
  16. 5 5
      api-v12/app/Http/Controllers/DhammaTermController.php
  17. 35 15
      api-v12/app/Http/Controllers/DictMeaningController.php
  18. 2 2
      api-v12/app/Http/Controllers/EmailCertificationController.php
  19. 26 27
      api-v12/app/Http/Controllers/ExportController.php
  20. 2 2
      api-v12/app/Http/Controllers/NissayaCoverController.php
  21. 2 3
      api-v12/app/Http/Controllers/OfflineIndexController.php
  22. 2 2
      api-v12/app/Http/Controllers/PaliTextController.php
  23. 2 2
      api-v12/app/Http/Controllers/ProgressChapterController.php
  24. 9 10
      api-v12/app/Http/Controllers/ProgressImgController.php
  25. 78 69
      api-v12/app/Http/Controllers/RelationController.php
  26. 5 6
      api-v12/app/Http/Controllers/SentenceController.php
  27. 2 2
      api-v12/app/Http/Controllers/SentenceInfoController.php
  28. 1 1
      api-v12/app/Http/Controllers/SiteInfoController.php
  29. 3 3
      api-v12/app/Http/Controllers/SysModelController.php
  30. 86 60
      api-v12/app/Http/Controllers/UserStatisticController.php
  31. 13 14
      api-v12/app/Http/Controllers/VocabularyController.php
  32. 2 3
      api-v12/app/Http/Controllers/WbwLookupController.php
  33. 3 7
      api-v12/app/Http/Controllers/WordIndexController.php
  34. 19 21
      api-v12/app/Http/Resources/SearchResource.php
  35. 4 6
      api-v12/app/Http/Resources/VocabularyResource.php
  36. 2 2
      api-v12/app/Jobs/ProcessAITranslateJob.php
  37. 2 2
      api-v12/app/Mail/EmailCertif.php
  38. 2 2
      api-v12/app/Services/AIModelService.php
  39. 6 6
      api-v12/app/Services/AiTranslateService.php
  40. 94 84
      api-v12/app/Tools/ExportDownload.php
  41. 5 5
      api-v12/app/Tools/TurboSplit.php

+ 2 - 2
api-v12/app/Console/Commands/CacheDictPreference.php

@@ -5,7 +5,7 @@ namespace App\Console\Commands;
 use Illuminate\Console\Command;
 use App\Models\UserDict;
 use Illuminate\Support\Facades\DB;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 
 class CacheDictPreference extends Command
 {
@@ -60,7 +60,7 @@ class CacheDictPreference extends Command
             $meaning = trim($meaning, " $");
             if (!empty($meaning)) {
                 $m = explode('$', $meaning);
-                RedisClusters::put("{$prefix}/{$word->word}/{$word->language}", $m[0]);
+                Cache::put("{$prefix}/{$word->word}/{$word->language}", $m[0]);
             }
             $bar->advance();
             $count++;

+ 34 - 30
api-v12/app/Console/Commands/CacheWbwPreference.php

@@ -7,7 +7,6 @@ use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Cache;
 use App\Models\WbwAnalysis;
 use Illuminate\Support\Facades\DB;
-use App\Tools\RedisClusters;
 
 class CacheWbwPreference extends Command
 {
@@ -42,40 +41,44 @@ class CacheWbwPreference extends Command
      */
     public function handle()
     {
-        if(\App\Tools\Tools::isStop()){
+        if (\App\Tools\Tools::isStop()) {
             return 0;
         }
         $prefix = 'wbw-preference';
-        if($this->option('view')==='all' ||
-           $this->option('view')==='my'){
+        if (
+            $this->option('view') === 'all' ||
+            $this->option('view') === 'my'
+        ) {
             $this->info('个人数据');
             /**
              * 个人数据算法
              * 最新优先
              */
-            $wbw = WbwAnalysis::select(['wbw_word','type','editor_id']);
+            $wbw = WbwAnalysis::select(['wbw_word', 'type', 'editor_id']);
             $wbwCount = DB::select('SELECT count(*) from (
                 SELECT wbw_word,type,editor_id from wbw_analyses group by wbw_word,type,editor_id) T');
-            if($this->option('editor')){
-                $wbw = $wbw->where('editor_id',$this->option('editor'));
-                $wbwCount = DB::select('SELECT count(*) from (
+            if ($this->option('editor')) {
+                $wbw = $wbw->where('editor_id', $this->option('editor'));
+                $wbwCount = DB::select(
+                    'SELECT count(*) from (
                     SELECT wbw_word,type,editor_id from wbw_analyses where editor_id=? group by wbw_word,type,editor_id) T',
-                    [$this->option('editor')]);
+                    [$this->option('editor')]
+                );
             }
-            $wbw = $wbw->groupBy(['wbw_word','type','editor_id'])->cursor();
+            $wbw = $wbw->groupBy(['wbw_word', 'type', 'editor_id'])->cursor();
             $bar = $this->output->createProgressBar($wbwCount[0]->count);
             $count = 0;
             foreach ($wbw as $key => $value) {
-                $data = WbwAnalysis::where('wbw_word',$value->wbw_word)
-                                    ->where('type',$value->type)
-                                    ->where('editor_id',$value->editor_id)
-                                    ->orderBy('updated_at','desc')
-                                    ->value('data');
-                RedisClusters::put("{$prefix}/{$value->wbw_word}/{$value->type}/{$value->editor_id}",$data);
+                $data = WbwAnalysis::where('wbw_word', $value->wbw_word)
+                    ->where('type', $value->type)
+                    ->where('editor_id', $value->editor_id)
+                    ->orderBy('updated_at', 'desc')
+                    ->value('data');
+                Cache::put("{$prefix}/{$value->wbw_word}/{$value->type}/{$value->editor_id}", $data);
                 $bar->advance();
                 $count++;
-                if($count%1000 === 0){
-                    if(\App\Tools\Tools::isStop()){
+                if ($count % 1000 === 0) {
+                    if (\App\Tools\Tools::isStop()) {
                         return 0;
                     }
                 }
@@ -83,29 +86,30 @@ class CacheWbwPreference extends Command
             $bar->finish();
         }
 
-        if($this->option('view')==='all' ||
-           $this->option('view')==='community'
-           ){
+        if (
+            $this->option('view') === 'all' ||
+            $this->option('view') === 'community'
+        ) {
             $this->info('社区通用');
             /**
              * 社区数据算法
              * 多的优先
              */
-            $wbw = WbwAnalysis::select(['wbw_word','type']);
+            $wbw = WbwAnalysis::select(['wbw_word', 'type']);
             $count = DB::select('SELECT count(*) from (
                 SELECT wbw_word,type from wbw_analyses group by wbw_word,type) T');
-            $wbw = $wbw->groupBy(['wbw_word','type'])->cursor();
+            $wbw = $wbw->groupBy(['wbw_word', 'type'])->cursor();
 
             $bar = $this->output->createProgressBar($count[0]->count);
             foreach ($wbw as $key => $value) {
-                $data = WbwAnalysis::where('wbw_word',$value->wbw_word)
-                                    ->where('type',$value->type)
-                                    ->selectRaw('data,count(*)')
-                                    ->groupBy("data")
-                                    ->orderBy("count", "desc")
-                                    ->first();
+                $data = WbwAnalysis::where('wbw_word', $value->wbw_word)
+                    ->where('type', $value->type)
+                    ->selectRaw('data,count(*)')
+                    ->groupBy("data")
+                    ->orderBy("count", "desc")
+                    ->first();
 
-                Cache::put("{$prefix}/{$value->wbw_word}/{$value->type}/0",$data->data);
+                Cache::put("{$prefix}/{$value->wbw_word}/{$value->type}/0", $data->data);
                 $bar->advance();
             }
             $bar->finish();

+ 52 - 49
api-v12/app/Console/Commands/ExportArticle.php

@@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Str;
 use Illuminate\Support\Facades\Storage;
 
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use App\Tools\ExportDownload;
 use App\Http\Api\MdRender;
 
@@ -49,30 +49,32 @@ class ExportArticle extends Command
     {
         $this->info('task export chapter start');
         Log::debug('task export chapter start');
-        if(\App\Tools\Tools::isStop()){
+        if (\App\Tools\Tools::isStop()) {
             return 0;
         }
         $options = [
-            'queryId'=>$this->argument('query_id'),
-            'format'=>$this->option('format'),
-            'debug'=>$this->option('debug'),
-            'filename'=>'article',
+            'queryId' => $this->argument('query_id'),
+            'format' => $this->option('format'),
+            'debug' => $this->option('debug'),
+            'filename' => 'article',
         ];
         $upload = new ExportDownload($options);
 
         MdRender::init();
-        $m = new \Mustache_Engine(array('entity_flags'=>ENT_QUOTES,
-                                        'delimiters' => '[[ ]]',
-                                        'escape'=>function ($value){
-                                            return $value;
-                                        }));
+        $m = new \Mustache_Engine(array(
+            'entity_flags' => ENT_QUOTES,
+            'delimiters' => '[[ ]]',
+            'escape' => function ($value) {
+                return $value;
+            }
+        ));
 
         $sections = array();
         $articles = array();
 
 
         $article = $this->fetch($this->argument('id'));
-        if(!$article){
+        if (!$article) {
             return 1;
         }
 
@@ -81,79 +83,80 @@ class ExportArticle extends Command
         $bookMeta['book_title'] = $article['title_text'];
 
         $articles[] = [
-            'level'=>1,
-            'title'=>$article['title_text'],
-            'content'=>isset($article['html'])?$article['html']:'',
+            'level' => 1,
+            'title' => $article['title_text'],
+            'content' => isset($article['html']) ? $article['html'] : '',
         ];
         $progress = 0.1;
-        $this->info($upload->setStatus($progress,'export article content title='.$article['title_text']));
+        $this->info($upload->setStatus($progress, 'export article content title=' . $article['title_text']));
 
-        if(isset($article['toc']) && count($article['toc'])>0){
-            $this->info('has sub article '. count($article['toc']));
+        if (isset($article['toc']) && count($article['toc']) > 0) {
+            $this->info('has sub article ' . count($article['toc']));
             $step = 0.8 / count($article['toc']);
             $baseLevel = 0;
             foreach ($article['toc'] as $key => $value) {
-                if($baseLevel === 0){
+                if ($baseLevel === 0) {
                     $baseLevel = $value['level'] - 2;
                 }
                 $progress += $step;
-                $this->info($upload->setStatus($progress,'exporting article title='.$value['title']));
+                $this->info($upload->setStatus($progress, 'exporting article title=' . $value['title']));
                 $article = $this->fetch($value['key']);
-                if(!$article){
-                    $this->info($upload->setStatus($progress,'exporting article fail title='.$value['title']));
+                if (!$article) {
+                    $this->info($upload->setStatus($progress, 'exporting article fail title=' . $value['title']));
                     continue;
                 }
-                $this->info($upload->setStatus($progress,'exporting article success title='.$article['title_text']));
+                $this->info($upload->setStatus($progress, 'exporting article success title=' . $article['title_text']));
                 $articles[] = [
-                    'level'=>$value['level']-$baseLevel,
-                    'title'=>$article['title_text'],
-                    'content'=>isset($article['html'])?$article['html']:'',
+                    'level' => $value['level'] - $baseLevel,
+                    'title' => $article['title_text'],
+                    'content' => isset($article['html']) ? $article['html'] : '',
                 ];
             }
         }
 
         $sections[] = [
-            'name'=>'articles',
-            'body'=>['articles'=>$articles],
+            'name' => 'articles',
+            'body' => ['articles' => $articles],
         ];
-        $this->info($upload->setStatus(0.9,'export article content done'));
+        $this->info($upload->setStatus(0.9, 'export article content done'));
         Log::debug('导出结束');
 
 
-        $upload->upload('article',$sections,$bookMeta);
-        $this->info($upload->setStatus(1,'export article done'));
+        $upload->upload('article', $sections, $bookMeta);
+        $this->info($upload->setStatus(1, 'export article done'));
         return 0;
     }
 
-    private function fetch($articleId){
+    private function fetch($articleId)
+    {
         $api = config('mint.server.api.bamboo');
         $basicUrl = $api . '/v2/article/';
         $url =  $basicUrl . $articleId;;
-        $this->info('http request url='.$url);
+        $this->info('http request url=' . $url);
 
         $urlParam = [
-                'mode' => 'read',
-                'format' => 'markdown',
-                'anthology'=> $this->option('anthology'),
-                'channel' => $this->option('channel'),
-                'origin' => 'true' /*$this->option('origin')*/,
-                'paragraph' => true,
+            'mode' => 'read',
+            'format' => 'markdown',
+            'anthology' => $this->option('anthology'),
+            'channel' => $this->option('channel'),
+            'origin' => 'true' /*$this->option('origin')*/,
+            'paragraph' => true,
         ];
 
-        Log::debug('export article http request',['url'=>$url,'param'=>$urlParam]);
-        if($this->option('token')){
-            $response = Http::withToken($this->option('token'))->get($url,$urlParam);
-        }else{
-            $response = Http::get($url,$urlParam);
+        Log::debug('export article http request', ['url' => $url, 'param' => $urlParam]);
+        if ($this->option('token')) {
+            $response = Http::withToken($this->option('token'))->get($url, $urlParam);
+        } else {
+            $response = Http::get($url, $urlParam);
         }
 
-        if($response->failed()){
-            $this->error('http request error'.$response->json('message'));
-            Log::error('http request error',['error'=>$response->json('message')]);
+        if ($response->failed()) {
+            $this->error('http request error' . $response->json('message'));
+            Log::error('http request error', ['error' => $response->json('message')]);
             return false;
         }
-        if(!$response->json('ok')){
-            $this->error('http request error'.$response->json('message'));
+        if (!$response->json('ok')) {
+            $this->error('http request error' . $response->json('message'));
             return false;
         }
         $article = $response->json('data');

+ 111 - 108
api-v12/app/Console/Commands/ExportChapter.php

@@ -15,7 +15,7 @@ use App\Models\Sentence;
 use App\Http\Api\ChannelApi;
 use App\Http\Api\MdRender;
 use App\Tools\Export;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use App\Tools\ExportDownload;
 
 
@@ -56,37 +56,39 @@ class ExportChapter extends Command
     {
         $this->info('task export chapter start');
         Log::debug('task export chapter start');
-        if(\App\Tools\Tools::isStop()){
+        if (\App\Tools\Tools::isStop()) {
             return 0;
         }
         $book = $this->argument('book');
         $para = $this->argument('para');
 
         $upload = new ExportDownload([
-            'queryId'=>$this->argument('query_id'),
-            'format'=>$this->option('format'),
-            'debug'=>$this->option('debug'),
-            'filename'=>$book.'-'.$para,
+            'queryId' => $this->argument('query_id'),
+            'format' => $this->option('format'),
+            'debug' => $this->option('debug'),
+            'filename' => $book . '-' . $para,
         ]);
 
-        $m = new \Mustache_Engine(array('entity_flags'=>ENT_QUOTES,
-                                        'delimiters' => '[[ ]]',
-                                        'escape'=>function ($value){
-                                            return $value;
-                                        }));
+        $m = new \Mustache_Engine(array(
+            'entity_flags' => ENT_QUOTES,
+            'delimiters' => '[[ ]]',
+            'escape' => function ($value) {
+                return $value;
+            }
+        ));
         $tplFile = resource_path("mustache/chapter/md/paragraph.md");
         $tplParagraph = file_get_contents($tplFile);
 
         MdRender::init();
 
-        $renderFormat='markdown';
+        $renderFormat = 'markdown';
 
         //获取原文channel
         $orgChannelId = ChannelApi::getSysChannel('_System_Pali_VRI_');
 
-        $tranChannelsId = explode('_',$this->argument('channel'));
+        $tranChannelsId = explode('_', $this->argument('channel'));
 
-        $channelsId = array_merge([$orgChannelId],$tranChannelsId);
+        $channelsId = array_merge([$orgChannelId], $tranChannelsId);
 
         $channels = array();
         $channelsIndex = array();
@@ -101,88 +103,89 @@ class ExportChapter extends Command
             $bookMeta['book_author'] .= $channel['name'] . ' ';
         }
 
-        $chapter = PaliText::where('book',$book)
-                           ->where('paragraph',$para)->first();
-        if(!$chapter){
+        $chapter = PaliText::where('book', $book)
+            ->where('paragraph', $para)->first();
+        if (!$chapter) {
             return $this->error("no data");
         }
 
         $currProgress = 0;
-        $this->info($upload->setStatus($currProgress,'start'));
+        $this->info($upload->setStatus($currProgress, 'start'));
 
 
-        if(empty($chapter->toc)){
+        if (empty($chapter->toc)) {
             $bookMeta['title'] = "unknown";
-        }else{
+        } else {
             $bookMeta['book_title'] = '';
             foreach ($channelsId as $key => $id) {
-                $title = ProgressChapter::where('book',$book)->where('para',$para)
-                        ->where('channel_id',$id)
-                        ->value('title');
+                $title = ProgressChapter::where('book', $book)->where('para', $para)
+                    ->where('channel_id', $id)
+                    ->value('title');
                 $bookMeta['book_title'] .= $title;
             }
             $bookMeta['sub_title'] = $chapter->toc;
         }
 
-        $subChapter = PaliText::where('book',$book)->where('parent',$para)
-                              ->where('level','<',8)
-                              ->orderBy('paragraph')
-                              ->get();
-        if(count($subChapter) === 0){
+        $subChapter = PaliText::where('book', $book)->where('parent', $para)
+            ->where('level', '<', 8)
+            ->orderBy('paragraph')
+            ->get();
+        if (count($subChapter) === 0) {
             //没有子章节
-            $subChapter = PaliText::where('book',$book)->where('paragraph',$para)
-                              ->where('level','<',8)
-                              ->orderBy('paragraph')
-                              ->get();
+            $subChapter = PaliText::where('book', $book)->where('paragraph', $para)
+                ->where('level', '<', 8)
+                ->orderBy('paragraph')
+                ->get();
         }
 
-        $chapterParagraph = PaliText::where('book',$book)->where('paragraph',$para)->value('chapter_len');
-        if($chapterParagraph >0 ){
+        $chapterParagraph = PaliText::where('book', $book)->where('paragraph', $para)->value('chapter_len');
+        if ($chapterParagraph > 0) {
             $step = 0.9 / $chapterParagraph;
-        }else{
+        } else {
             $step = 0.9;
-            Log::error('段落长度不能为0',['book'=>$book,'para'=>$para]);
+            Log::error('段落长度不能为0', ['book' => $book, 'para' => $para]);
         }
 
         $outputChannelsId = [];
-        if($this->option('origin') === 'true'){
+        if ($this->option('origin') === 'true') {
             $outputChannelsId[] = $orgChannelId;
         }
-        if($this->option('translation') === 'true'){
-            $outputChannelsId = array_merge($outputChannelsId,$tranChannelsId);
+        if ($this->option('translation') === 'true') {
+            $outputChannelsId = array_merge($outputChannelsId, $tranChannelsId);
         }
 
         $sections = array();
         foreach ($subChapter as $key => $sub) {
             # 看这个章节是否存在译文
             $hasChapter = false;
-            if($this->option('origin') === 'true'){
+            if ($this->option('origin') === 'true') {
                 $hasChapter = true;
             }
-            if($this->option('translation') === 'true'){
+            if ($this->option('translation') === 'true') {
                 foreach ($tranChannelsId as $id) {
-                    if(ProgressChapter::where('book',$book)->where('para',$sub->paragraph)
-                        ->where('channel_id',$id)
-                        ->exists()){
-                            $hasChapter = true;
+                    if (ProgressChapter::where('book', $book)->where('para', $sub->paragraph)
+                        ->where('channel_id', $id)
+                        ->exists()
+                    ) {
+                        $hasChapter = true;
                     }
                 }
             }
-            if(!$hasChapter){
+            if (!$hasChapter) {
                 //不存在需要导出的数据
                 continue;
             }
-            $filename = "{$sub->paragraph}.".$this->option('format');
-            $bookMeta['sections'][] = ['filename'=>$filename];
-            $paliTitle = PaliText::where('book',$book)
-                                 ->where('paragraph',$sub->paragraph)
-                                 ->value('toc');
+            $filename = "{$sub->paragraph}." . $this->option('format');
+            $bookMeta['sections'][] = ['filename' => $filename];
+            $paliTitle = PaliText::where('book', $book)
+                ->where('paragraph', $sub->paragraph)
+                ->value('toc');
             $sectionTitle = $paliTitle;
-            if($this->option('translation') === 'true'){
-                $chapter = ProgressChapter::where('book',$book)->where('para',$sub->paragraph)
-                                        ->where('channel_id',$tranChannelsId[0])
-                                        ->first();
-                if($chapter && !empty($chapter->title)){
+            if ($this->option('translation') === 'true') {
+                $chapter = ProgressChapter::where('book', $book)->where('para', $sub->paragraph)
+                    ->where('channel_id', $tranChannelsId[0])
+                    ->first();
+                if ($chapter && !empty($chapter->title)) {
                     $sectionTitle = $chapter->title;
                 }
             }
@@ -190,80 +193,80 @@ class ExportChapter extends Command
 
             $content = array();
 
-            $chapterStart = $sub->paragraph+1;
+            $chapterStart = $sub->paragraph + 1;
             $chapterEnd = $sub->paragraph + $sub->chapter_len;
-            $chapterBody = PaliText::where('book',$book)
-                                    ->whereBetween('paragraph',[$chapterStart,$chapterEnd])
-                                    ->orderBy('paragraph')->get();
+            $chapterBody = PaliText::where('book', $book)
+                ->whereBetween('paragraph', [$chapterStart, $chapterEnd])
+                ->orderBy('paragraph')->get();
 
 
 
             foreach ($chapterBody as $body) {
                 $currProgress += $step;
-                $this->info($upload->setStatus($currProgress,'export chapter '.$body->paragraph));
+                $this->info($upload->setStatus($currProgress, 'export chapter ' . $body->paragraph));
                 $paraData = array();
                 $paraData['translations'] = array();
                 foreach ($outputChannelsId as $key => $channelId) {
-                    $translationData = Sentence::where('book_id',$book)
-                                        ->where('paragraph',$body->paragraph)
-                                        ->where('channel_uid',$channelId)
-                                        ->orderBy('word_start')->get();
+                    $translationData = Sentence::where('book_id', $book)
+                        ->where('paragraph', $body->paragraph)
+                        ->where('channel_uid', $channelId)
+                        ->orderBy('word_start')->get();
                     $sentContent = array();
                     foreach ($translationData as $sent) {
-                        $texText = MdRender::render($sent->content,
-                                                    [$sent->channel_uid],
-                                                    null,
-                                                    'read',
-                                                    $channelsIndex[$channelId]['type'],
-                                                    $sent->content_type,
-                                                    $renderFormat
-                                                    );
+                        $texText = MdRender::render(
+                            $sent->content,
+                            [$sent->channel_uid],
+                            null,
+                            'read',
+                            $channelsIndex[$channelId]['type'],
+                            $sent->content_type,
+                            $renderFormat
+                        );
                         $sentContent[] = trim($texText);
                     }
-                    $paraContent = implode(' ',$sentContent);
-                    if($channelsIndex[$channelId]['type'] === 'original'){
+                    $paraContent = implode(' ', $sentContent);
+                    if ($channelsIndex[$channelId]['type'] === 'original') {
                         $paraData['origin'] = $paraContent;
-                    }else{
-                        $paraData['translations'][] = ['content'=>$paraContent];
+                    } else {
+                        $paraData['translations'][] = ['content' => $paraContent];
                     }
                 }
-                if($body->level > 7){
-                    $content[] = $m->render($tplParagraph,$paraData);
-                }else{
+                if ($body->level > 7) {
+                    $content[] = $m->render($tplParagraph, $paraData);
+                } else {
                     $currLevel = $body->level - $sub->level;
-                    if($currLevel<=0){
+                    if ($currLevel <= 0) {
                         $currLevel = 1;
                     }
 
-                    if(count($paraData['translations'])===0){
-                        $subSessionTitle = PaliText::where('book',$book)
-                                            ->where('paragraph',$body->paragraph)
-                                            ->value('toc');
-                    }else{
+                    if (count($paraData['translations']) === 0) {
+                        $subSessionTitle = PaliText::where('book', $book)
+                            ->where('paragraph', $body->paragraph)
+                            ->value('toc');
+                    } else {
                         $subSessionTitle = $paraData['translations'][0]['content'];
                     }
 
                     //标题
-                    $subStr = array_fill(0,$currLevel,'#');
-                    $content[] = implode('',$subStr) . " ".$subSessionTitle;
-
+                    $subStr = array_fill(0, $currLevel, '#');
+                    $content[] = implode('', $subStr) . " " . $subSessionTitle;
                 }
                 $content[] = "\n\n";
             }
 
             $sections[] = [
-                    'name'=>$filename,
-                    'body'=>[
-                        'title'=>$sectionTitle,
-                        'content'=>implode('',$content)
-                    ]
-                ];
+                'name' => $filename,
+                'body' => [
+                    'title' => $sectionTitle,
+                    'content' => implode('', $content)
+                ]
+            ];
         }
 
         //导出术语表
         $keyPali = array();
         $keyMeaning = array();
-        if(isset($GLOBALS['glossary'])){
+        if (isset($GLOBALS['glossary'])) {
             $glossary = $GLOBALS['glossary'];
             foreach ($glossary as $word => $meaning) {
                 $keyMeaning[$meaning] = $word;
@@ -277,34 +280,34 @@ class ExportChapter extends Command
         $glossaryData['pali'] = [];
         $glossaryData['meaning'] = [];
         foreach ($keyPali as $word => $meaning) {
-            $glossaryData['pali'][] = ['pali'=>$word,'meaning'=>$meaning];
+            $glossaryData['pali'][] = ['pali' => $word, 'meaning' => $meaning];
         }
         foreach ($keyMeaning as $meaning => $word) {
-            $glossaryData['meaning'][] = ['pali' => $word,'meaning'=>$meaning];
+            $glossaryData['meaning'][] = ['pali' => $word, 'meaning' => $meaning];
         }
 
-        Log::debug('glossary',['data' => $glossaryData]);
+        Log::debug('glossary', ['data' => $glossaryData]);
 
-        $tplFile = resource_path("mustache/chapter/".$this->option('format')."/glossary.".$this->option('format'));
+        $tplFile = resource_path("mustache/chapter/" . $this->option('format') . "/glossary." . $this->option('format'));
         $tplGlossary = file_get_contents($tplFile);
 
-        $glossaryContent = $m->render($tplGlossary,$glossaryData);
+        $glossaryContent = $m->render($tplGlossary, $glossaryData);
 
         $sections[] = [
-            'name'=>'glossary.'.$this->option('format'),
-            'body'=>[
+            'name' => 'glossary.' . $this->option('format'),
+            'body' => [
                 'title' => 'glossary',
                 'content' => $glossaryContent
             ]
         ];
-        $this->info($upload->setStatus($currProgress,'export glossary '. count($keyPali)));
+        $this->info($upload->setStatus($currProgress, 'export glossary ' . count($keyPali)));
 
-        $this->info($upload->setStatus(0.9,'export content done sections='.count($sections)));
+        $this->info($upload->setStatus(0.9, 'export content done sections=' . count($sections)));
 
-        Log::debug('导出结束',['sections'=>count($sections)]);
+        Log::debug('导出结束', ['sections' => count($sections)]);
 
-        $upload->upload('chapter',$sections,$bookMeta);
-        $this->info($upload->setStatus(1,'export chapter done'));
+        $upload->upload('chapter', $sections, $bookMeta);
+        $this->info($upload->setStatus(1, 'export chapter done'));
 
         return 0;
     }

+ 30 - 22
api-v12/app/Console/Commands/ExportChapterIndex.php

@@ -8,7 +8,6 @@ use App\Models\ProgressChapter;
 use App\Models\Channel;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Log;
-use App\Tools\RedisClusters;
 
 class ExportChapterIndex extends Command
 {
@@ -44,43 +43,52 @@ class ExportChapterIndex extends Command
     public function handle()
     {
         Log::debug('task export offline chapter-index-table start');
-        if(\App\Tools\Tools::isStop()){
+        if (\App\Tools\Tools::isStop()) {
             return 0;
         }
 
-        $exportFile = storage_path('app/public/export/offline/'.$this->argument('db').'-'.date("Y-m-d").'.db3');
-        $dbh = new \PDO('sqlite:'.$exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));
+        $exportFile = storage_path('app/public/export/offline/' . $this->argument('db') . '-' . date("Y-m-d") . '.db3');
+        $dbh = new \PDO('sqlite:' . $exportFile, "", "", array(\PDO::ATTR_PERSISTENT => true));
         $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
         $dbh->beginTransaction();
 
         $query = "INSERT INTO chapter ( id , book , paragraph,
                                     language , title , channel_id , progress,updated_at  )
                                     VALUES ( ? , ? , ? , ? , ? , ? , ? , ?  )";
-        try{
+        try {
             $stmt = $dbh->prepare($query);
-        }catch(PDOException $e){
+        } catch (\PDOException $e) {
             Log::info($e);
             return 1;
         }
 
-        $publicChannels = Channel::where('status',30)->select('uid')->get();
-        $rows = ProgressChapter::whereIn('channel_id',$publicChannels)->count();
-        RedisClusters::put("/export/chapter/count",$rows,3600*10);
+        $publicChannels = Channel::where('status', 30)->select('uid')->get();
+        $rows = ProgressChapter::whereIn('channel_id', $publicChannels)->count();
+        Cache::put("/export/chapter/count", $rows, 3600 * 10);
         $bar = $this->output->createProgressBar($rows);
-        foreach (ProgressChapter::whereIn('channel_id',$publicChannels)
-                                ->select(['uid','book','para',
-                                'lang','title','channel_id',
-                                'progress','updated_at'])->cursor() as $row) {
+        foreach (
+            ProgressChapter::whereIn('channel_id', $publicChannels)
+                ->select([
+                    'uid',
+                    'book',
+                    'para',
+                    'lang',
+                    'title',
+                    'channel_id',
+                    'progress',
+                    'updated_at'
+                ])->cursor() as $row
+        ) {
             $currData = array(
-                            $row->uid,
-                            $row->book,
-                            $row->para,
-                            $row->lang,
-                            $row->title,
-                            $row->channel_id,
-                            $row->progress,
-                            $row->updated_at,
-                            );
+                $row->uid,
+                $row->book,
+                $row->para,
+                $row->lang,
+                $row->title,
+                $row->channel_id,
+                $row->progress,
+                $row->updated_at,
+            );
             $stmt->execute($currData);
             $bar->advance();
         }

+ 1 - 2
api-v12/app/Console/Commands/ExportOffline.php

@@ -6,7 +6,6 @@ use Illuminate\Console\Command;
 use Illuminate\Support\Facades\Storage;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Log;
-use App\Tools\RedisClusters;
 use Illuminate\Support\Facades\Redis;
 
 class ExportOffline extends Command
@@ -55,7 +54,7 @@ class ExportOffline extends Command
         }
 
         //清空redis
-        RedisClusters::put('/offline/index', []);
+        Cache::put('/offline/index', []);
 
         //删除全部的旧文件
         foreach (scandir($exportDir) as $key => $file) {

+ 4 - 4
api-v12/app/Console/Commands/ExportZip.php

@@ -5,7 +5,7 @@ namespace App\Console\Commands;
 use Illuminate\Console\Command;
 use Illuminate\Support\Facades\Storage;
 use Illuminate\Support\Facades\Log;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\App;
 
 use Symfony\Component\Process\Process;
@@ -170,7 +170,7 @@ class ExportZip extends Command
             'link' => $link,
             'hostname' => 'Amazon cloud storage(Hongkong)',
         ];
-        $info = RedisClusters::get('/offline/index');
+        $info = Cache::get('/offline/index');
         if (!is_array($info)) {
             $info = array();
         }
@@ -180,11 +180,11 @@ class ExportZip extends Command
             'filename' => $zipFile,
             'url' => $url,
             'create_at' => date("Y-m-d H:i:s"),
-            'chapter' => RedisClusters::get("/export/chapter/count"),
+            'chapter' => Cache::get("/export/chapter/count"),
             'filesize' => filesize($zipFullFileName),
             'min_app_ver' => '1.3',
         ];
-        RedisClusters::put('/offline/index', $info);
+        Cache::put('/offline/index', $info);
         sleep(5);
         try {
             unlink($exportFullFileName);

+ 6 - 6
api-v12/app/Console/Commands/MqAiTranslate.php

@@ -7,7 +7,7 @@ use App\Http\Api\Mq;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Http;
 use Illuminate\Http\Client\RequestException;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 
 class MqAiTranslate extends Command
 {
@@ -60,12 +60,12 @@ class MqAiTranslate extends Command
             //获取model token
             $first = $messages[0];
             $taskId = $first->task->info->id;
-            RedisClusters::put("/task/{$taskId}/message_id", $messageId);
+            Cache::put("/task/{$taskId}/message_id", $messageId);
             $pointerKey = "/message/{$messageId}/pointer";
             $pointer = 0;
-            if (RedisClusters::has($pointerKey)) {
+            if (Cache::has($pointerKey)) {
                 //回到上次中断的点
-                $pointer = RedisClusters::get($pointerKey);
+                $pointer = Cache::get($pointerKey);
             }
 
             Log::debug($queue . ' ai assistant token', ['user' => $first->model->uid]);
@@ -94,7 +94,7 @@ class MqAiTranslate extends Command
             }
 
             for ($i = $pointer; $i < count($messages); $i++) {
-                RedisClusters::put($pointerKey, $i);
+                Cache::put($pointerKey, $i);
                 $message = $messages[$i];
                 $taskDiscussionContent = [];
                 $param = [
@@ -324,7 +324,7 @@ class MqAiTranslate extends Command
                     $this->setTaskStatus($message->task->info->id, 'done', $modelToken);
                 }
             }
-            RedisClusters::forget($pointerKey);
+            Cache::forget($pointerKey);
             $this->info('ai translate task complete');
             return 0;
         });

+ 277 - 66
api-v12/app/Console/Commands/StatisticsNissayaCover.php

@@ -6,7 +6,7 @@ use Illuminate\Console\Command;
 use App\Models\Channel;
 use App\Models\Sentence;
 use App\Models\PaliSentence;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 
 class StatisticsNissayaCover extends Command
 {
@@ -17,58 +17,271 @@ class StatisticsNissayaCover extends Command
      */
     protected $signature = 'statistics:nissaya.cover';
     protected $types = [
-        'mula'=>[
-            69,70,71,72,73,74,
-            75,76,77,78,79,80,
-            81,82,83,84,85,86,
-            87,88,89,90,91,92,
-            93,94,95,143,144,145,
-            146,147,148,149,150,151,
-            152,153,154,155,156,157,
-            158,159,160,161,162,163,
-            164,165,166,167,168,169,
-            170,171,213,214,215,216,217,
+        'mula' => [
+            69,
+            70,
+            71,
+            72,
+            73,
+            74,
+            75,
+            76,
+            77,
+            78,
+            79,
+            80,
+            81,
+            82,
+            83,
+            84,
+            85,
+            86,
+            87,
+            88,
+            89,
+            90,
+            91,
+            92,
+            93,
+            94,
+            95,
+            143,
+            144,
+            145,
+            146,
+            147,
+            148,
+            149,
+            150,
+            151,
+            152,
+            153,
+            154,
+            155,
+            156,
+            157,
+            158,
+            159,
+            160,
+            161,
+            162,
+            163,
+            164,
+            165,
+            166,
+            167,
+            168,
+            169,
+            170,
+            171,
+            213,
+            214,
+            215,
+            216,
+            217,
         ],
         'atthakatha' => [
-            64,65,96,97,98,99,
-            100,101,102,103,104,105,
-            106,107,108,109,110,111,
-            112,113,114,115,116,117,
-            118,119,120,121,122,123,
-            124,125,126,127,128,129,
-            130,131,132,133,134,135,
-            136,137,138,139,140,141,142,
+            64,
+            65,
+            96,
+            97,
+            98,
+            99,
+            100,
+            101,
+            102,
+            103,
+            104,
+            105,
+            106,
+            107,
+            108,
+            109,
+            110,
+            111,
+            112,
+            113,
+            114,
+            115,
+            116,
+            117,
+            118,
+            119,
+            120,
+            121,
+            122,
+            123,
+            124,
+            125,
+            126,
+            127,
+            128,
+            129,
+            130,
+            131,
+            132,
+            133,
+            134,
+            135,
+            136,
+            137,
+            138,
+            139,
+            140,
+            141,
+            142,
         ],
         'tika' => [
-            66,67,68,172,173,174,
-            175,176,177,178,179,180,
-            181,182,183,184,185,186,
-            187,188,189,190,191,192,
-            193,194,195,196,197,198,
-            199,200,201,202,203,204,
-            205,206,207,208,209,210,211,212,
+            66,
+            67,
+            68,
+            172,
+            173,
+            174,
+            175,
+            176,
+            177,
+            178,
+            179,
+            180,
+            181,
+            182,
+            183,
+            184,
+            185,
+            186,
+            187,
+            188,
+            189,
+            190,
+            191,
+            192,
+            193,
+            194,
+            195,
+            196,
+            197,
+            198,
+            199,
+            200,
+            201,
+            202,
+            203,
+            204,
+            205,
+            206,
+            207,
+            208,
+            209,
+            210,
+            211,
+            212,
         ],
-        'vinaya' => [138,139,140,141,142,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,],
+        'vinaya' => [138, 139, 140, 141, 142, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,],
         'sutta' => [
-            82,83,84,85,86,
-            87,88,89,90,91,92,93,
-            94,95,99,100,101,102,
-            103,104,105,106,107,108,
-            109,110,111,112,113,114,
-            115,116,117,118,119,120,
-            121,122,123,124,125,126,
-            127,128,129,130,131,132,
-            133,134,135,136,137,143,
-            144,145,146,147,148,149,
-            150,151,152,153,154,155,
-            156,157,158,159,160,161,
-            162,163,164,165,166,167,
-            168,169,170,171,181,182,
-            183,184,185,186,187,188,
-            189,190,191,192,193,194,
-            195,196,197,198,199,
+            82,
+            83,
+            84,
+            85,
+            86,
+            87,
+            88,
+            89,
+            90,
+            91,
+            92,
+            93,
+            94,
+            95,
+            99,
+            100,
+            101,
+            102,
+            103,
+            104,
+            105,
+            106,
+            107,
+            108,
+            109,
+            110,
+            111,
+            112,
+            113,
+            114,
+            115,
+            116,
+            117,
+            118,
+            119,
+            120,
+            121,
+            122,
+            123,
+            124,
+            125,
+            126,
+            127,
+            128,
+            129,
+            130,
+            131,
+            132,
+            133,
+            134,
+            135,
+            136,
+            137,
+            143,
+            144,
+            145,
+            146,
+            147,
+            148,
+            149,
+            150,
+            151,
+            152,
+            153,
+            154,
+            155,
+            156,
+            157,
+            158,
+            159,
+            160,
+            161,
+            162,
+            163,
+            164,
+            165,
+            166,
+            167,
+            168,
+            169,
+            170,
+            171,
+            181,
+            182,
+            183,
+            184,
+            185,
+            186,
+            187,
+            188,
+            189,
+            190,
+            191,
+            192,
+            193,
+            194,
+            195,
+            196,
+            197,
+            198,
+            199,
         ],
-        'abhidhamma' => [69,70,71,72,73,74,75,76,77,78,79,80,81,96,97,98,172,173,174,175,176,177,178,179,180,],
+        'abhidhamma' => [69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 96, 97, 98, 172, 173, 174, 175, 176, 177, 178, 179, 180,],
     ];
     /**
      * The console command description.
@@ -94,26 +307,26 @@ class StatisticsNissayaCover extends Command
      */
     public function handle()
     {
-        if(\App\Tools\Tools::isStop()){
+        if (\App\Tools\Tools::isStop()) {
             return 0;
         }
-        $nissaya_channels = Channel::where('type','nissaya')
-                                ->where('lang','my')
-                                ->select('uid')->get();
-        $this->info('channel:'.count($nissaya_channels));
+        $nissaya_channels = Channel::where('type', 'nissaya')
+            ->where('lang', 'my')
+            ->select('uid')->get();
+        $this->info('channel:' . count($nissaya_channels));
         $output = [];
         foreach ($this->types as $type => $books) {
             # code...
-            $pali = PaliSentence::whereIn('book',$books)->sum('length');
-            $nissayaSentences = Sentence::whereIn('channel_uid',$nissaya_channels)
-                                ->whereIn('book_id',$books)
-                                ->groupBy(['book_id','paragraph','word_start','word_end'])
-                                ->select(['book_id','paragraph','word_start','word_end'])
-                                ->get();
+            $pali = PaliSentence::whereIn('book', $books)->sum('length');
+            $nissayaSentences = Sentence::whereIn('channel_uid', $nissaya_channels)
+                ->whereIn('book_id', $books)
+                ->groupBy(['book_id', 'paragraph', 'word_start', 'word_end'])
+                ->select(['book_id', 'paragraph', 'word_start', 'word_end'])
+                ->get();
             $sentences = [];
             $final = 0;
-            $this->info($type . count($nissayaSentences). " sentences");
-            if(count($nissayaSentences)>0){
+            $this->info($type . count($nissayaSentences) . " sentences");
+            if (count($nissayaSentences) > 0) {
                 $count = 0;
                 foreach ($nissayaSentences as  $value) {
                     $sentences[] = [
@@ -122,23 +335,21 @@ class StatisticsNissayaCover extends Command
                         $value->word_start,
                         $value->word_end,
                     ];
-                    if($count % 100 === 0 ){
-                        $final += PaliSentence::whereIns(['book','paragraph','word_begin','word_end'],$sentences)
-                                        ->sum('length');
+                    if ($count % 100 === 0) {
+                        $final += PaliSentence::whereIns(['book', 'paragraph', 'word_begin', 'word_end'], $sentences)
+                            ->sum('length');
                         $sentences = [];
                         $percent = intval($count * 100 / count($nissayaSentences));
                         $this->info("[{$percent}] {$final}");
                     }
                     $count++;
                 }
-
             }
 
             $this->info($type . '=' . $pali . '=' . $final);
-            $output[] = ['type'=>$type,'total'=>$pali,'final'=>$final];
-
+            $output[] = ['type' => $type, 'total' => $pali, 'final' => $final];
         }
-        RedisClusters::put('/statistics/nissaya/cover',$output,48*3600);
+        Cache::put('/statistics/nissaya/cover', $output, 48 * 3600);
         return 0;
     }
 }

+ 68 - 59
api-v12/app/Console/Commands/UpgradeChapterDynamicWeekly.php

@@ -1,6 +1,7 @@
 <?php
 
 namespace App\Console\Commands;
+
 use Illuminate\Support\Facades\Storage;
 use Illuminate\Console\Command;
 use Illuminate\Support\Carbon;
@@ -8,7 +9,7 @@ use App\Models\SentHistory;
 use App\Models\Sentence;
 use App\Models\ProgressChapter;
 use App\Models\PaliText;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Log;
 
 class UpgradeChapterDynamicWeekly extends Command
@@ -44,115 +45,123 @@ class UpgradeChapterDynamicWeekly extends Command
      */
     public function handle()
     {
-        if(\App\Tools\Tools::isStop()){
+        if (\App\Tools\Tools::isStop()) {
             return 0;
         }
-		Log::debug('upgrade:chapter.dynamic.weekly start.');
-		$this->info('upgrade:chapter.dynamic.weekly start.');
+        Log::debug('upgrade:chapter.dynamic.weekly start.');
+        $this->info('upgrade:chapter.dynamic.weekly start.');
 
         $startAt = time();
         $weeks = 60; //统计多少周
 
-//更新总动态
-		$this->info("更新总动态");
-		Log::debug("task:更新总动态开始");
-        $table = ProgressChapter::select('book','para')
-                                    ->groupBy('book','para')
-                                    ->orderBy('book');
-        if($this->option('book')){
-            $table = $table->where('book',$this->option('book'));
+        //更新总动态
+        $this->info("更新总动态");
+        Log::debug("task:更新总动态开始");
+        $table = ProgressChapter::select('book', 'para')
+            ->groupBy('book', 'para')
+            ->orderBy('book');
+        if ($this->option('book')) {
+            $table = $table->where('book', $this->option('book'));
         }
         $chapters = $table->get();
         $bar = $this->output->createProgressBar(count($chapters));
-        Log::debug('chapter {count} ',['count',count($chapters)]);
+        Log::debug('chapter {count} ', ['count', count($chapters)]);
         foreach ($chapters as $key => $chapter) {
             #章节长度
-            $paraEnd = PaliText::where('book',$chapter->book)
-                            ->where('paragraph',$chapter->para)
-                            ->value('chapter_len')+$chapter->para-1;
+            $paraEnd = PaliText::where('book', $chapter->book)
+                ->where('paragraph', $chapter->para)
+                ->value('chapter_len') + $chapter->para - 1;
 
             $progress = [];
-            for ($i=$weeks; $i > 0 ; $i--) {
+            for ($i = $weeks; $i > 0; $i--) {
                 #这一周有多少次更新
-                $currDay = $i*7+$this->option('offset',0);
-                $count = SentHistory::whereBetween('sent_histories.created_at',
-                                                  [Carbon::today()->subDays($currDay)->startOfWeek(),
-                                                  Carbon::today()->subDays($currDay)->endOfWeek()])
-                           ->leftJoin('sentences', 'sent_histories.sent_uid', '=', 'sentences.uid')
-                             ->where('book_id',$chapter->book)
-                             ->whereBetween('paragraph',[$chapter->para,$paraEnd])
-                             ->count();
+                $currDay = $i * 7 + $this->option('offset', 0);
+                $count = SentHistory::whereBetween(
+                    'sent_histories.created_at',
+                    [
+                        Carbon::today()->subDays($currDay)->startOfWeek(),
+                        Carbon::today()->subDays($currDay)->endOfWeek()
+                    ]
+                )
+                    ->leftJoin('sentences', 'sent_histories.sent_uid', '=', 'sentences.uid')
+                    ->where('book_id', $chapter->book)
+                    ->whereBetween('paragraph', [$chapter->para, $paraEnd])
+                    ->count();
                 $progress[] = $count;
             }
-            $key="/chapter_dynamic/{$chapter->book}/{$chapter->para}/global";
-            RedisClusters::put($key,$progress,3600*24*7);
+            $key = "/chapter_dynamic/{$chapter->book}/{$chapter->para}/global";
+            Cache::put($key, $progress, 3600 * 24 * 7);
 
             $bar->advance();
 
-            if($this->option('test')){
+            if ($this->option('test')) {
                 $this->info("key:{$key}");
-                if(RedisClusters::has($key)){
-                    $this->info('has key '.$key);
+                if (Cache::has($key)) {
+                    $this->info('has key ' . $key);
                 }
                 break; //调试代码
             }
         }
         $bar->finish();
-		Log::debug("task:更新总动态结束");
+        Log::debug("task:更新总动态结束");
 
-		$time = time()- $startAt;
+        $time = time() - $startAt;
         $this->info("用时 {$time}");
 
         $startAt = time();
 
-		$startAt = time();
+        $startAt = time();
         //更新chennel动态
         $this->info('更新channel动态');
-		Log::debug("task:更新channel动态开始");
+        Log::debug("task:更新channel动态开始");
 
-        $table = ProgressChapter::select('book','para','channel_id');
-        if($this->option('book')){
-            $table = $table->where('book',$this->option('book'));
+        $table = ProgressChapter::select('book', 'para', 'channel_id');
+        if ($this->option('book')) {
+            $table = $table->where('book', $this->option('book'));
         }
         $bar = $this->output->createProgressBar($table->count());
-		Log::debug("更新channel动态 {count}",['count'=>$table->count()]);
+        Log::debug("更新channel动态 {count}", ['count' => $table->count()]);
         foreach ($table->cursor() as $chapter) {
             # code...
-            $max=0;
+            $max = 0;
             #章节长度
-            $paraEnd = PaliText::where('book',$chapter->book)
-                            ->where('paragraph',$chapter->para)
-                            ->value('chapter_len')+$chapter->para-1;
+            $paraEnd = PaliText::where('book', $chapter->book)
+                ->where('paragraph', $chapter->para)
+                ->value('chapter_len') + $chapter->para - 1;
             $progress = [];
-            for ($i=$weeks; $i > 0 ; $i--) {
+            for ($i = $weeks; $i > 0; $i--) {
                 #这一周有多少次更新
-                $currDay = $i*7+$this->option('offset',0);
-                $count = SentHistory::whereBetween('sent_histories.created_at',
-                                                [Carbon::today()->subDays($currDay)->startOfWeek(),
-                                                Carbon::today()->subDays($currDay)->endOfWeek()])
-                           ->leftJoin('sentences', 'sent_histories.sent_uid', '=', 'sentences.uid')
-                             ->where('book_id',$chapter->book)
-                             ->whereBetween('paragraph',[$chapter->para,$paraEnd])
-                             ->where('sentences.channel_uid',$chapter->channel_id)
-                             ->count();
+                $currDay = $i * 7 + $this->option('offset', 0);
+                $count = SentHistory::whereBetween(
+                    'sent_histories.created_at',
+                    [
+                        Carbon::today()->subDays($currDay)->startOfWeek(),
+                        Carbon::today()->subDays($currDay)->endOfWeek()
+                    ]
+                )
+                    ->leftJoin('sentences', 'sent_histories.sent_uid', '=', 'sentences.uid')
+                    ->where('book_id', $chapter->book)
+                    ->whereBetween('paragraph', [$chapter->para, $paraEnd])
+                    ->where('sentences.channel_uid', $chapter->channel_id)
+                    ->count();
                 $progress[] = $count;
             }
-            $key="/chapter_dynamic/{$chapter->book}/{$chapter->para}/ch_{$chapter->channel_id}";
-            RedisClusters::put($key,$progress,3600*24*7);
+            $key = "/chapter_dynamic/{$chapter->book}/{$chapter->para}/ch_{$chapter->channel_id}";
+            Cache::put($key, $progress, 3600 * 24 * 7);
             $bar->advance();
 
-            if($this->option('test')){
+            if ($this->option('test')) {
                 $this->info("key:{$key}");
-                if(RedisClusters::has($key)){
-                    $this->info('has key '.$key);
+                if (Cache::has($key)) {
+                    $this->info('has key ' . $key);
                 }
                 break; //调试代码
             }
         }
         $bar->finish();
-		Log::debug("task:更新channel动态结束");
+        Log::debug("task:更新channel动态结束");
 
-		$time = time()- $startAt;
+        $time = time() - $startAt;
         $this->info("用时 {$time}");
 
         $this->info("upgrade:chapter.dynamic done");

+ 66 - 61
api-v12/app/Console/Commands/UpgradeDictDefaultMeaning.php

@@ -1,4 +1,5 @@
 <?php
+
 /**
  * 刷新字典单词的默认意思
  * 目标:
@@ -7,13 +8,13 @@
  * 1. 某种语言会有多个字典。按照字典重要程度人工排序
  * 2. 按照顺序搜索这些字典。找到第一个意思就停止。
  */
+
 namespace App\Console\Commands;
 
 use Illuminate\Console\Command;
 use App\Models\UserDict;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Log;
-use App\Tools\RedisClusters;
 
 class UpgradeDictDefaultMeaning extends Command
 {
@@ -24,45 +25,45 @@ class UpgradeDictDefaultMeaning extends Command
      */
     protected $signature = 'upgrade:dict.default.meaning {word?}';
     protected $dict = [
-        "zh-Hans"=>[
-            "8833de18-0978-434c-b281-a2e7387f69be",	/*巴汉字典明法尊者修订版*/
-            "f364d3dc-b611-471b-9a4f-531286b8c2c3",	/*《巴汉词典》Mahāñāṇo Bhikkhu编著*/
-            "0e4dc5c8-a228-4693-92ba-7d42918d8a91",	/*汉译パーリ语辞典-黃秉榮*/
-            "6aa9ec8b-bba4-4bcd-abd2-9eae015bad2b",	/*汉译パーリ语辞典-李瑩*/
-            "eb99f8b4-c3e5-43af-9102-6a93fcb97db6",	/*パーリ语辞典--勘误表*/
-            "0d79e8e8-1430-4c99-a0f1-b74f2b4b26d8",	/*《巴汉词典》增订*/
+        "zh-Hans" => [
+            "8833de18-0978-434c-b281-a2e7387f69be",    /*巴汉字典明法尊者修订版*/
+            "f364d3dc-b611-471b-9a4f-531286b8c2c3",    /*《巴汉词典》Mahāñāṇo Bhikkhu编著*/
+            "0e4dc5c8-a228-4693-92ba-7d42918d8a91",    /*汉译パーリ语辞典-黃秉榮*/
+            "6aa9ec8b-bba4-4bcd-abd2-9eae015bad2b",    /*汉译パーリ语辞典-李瑩*/
+            "eb99f8b4-c3e5-43af-9102-6a93fcb97db6",    /*パーリ语辞典--勘误表*/
+            "0d79e8e8-1430-4c99-a0f1-b74f2b4b26d8",    /*《巴汉词典》增订*/
         ],
-        "zh-Hant"=>[
-            "3acf0c0f-59a7-4d25-a3d9-bf394a266ebd",	/*汉译パーリ语辞典-黃秉榮*/
-            "5293ffb9-887e-4cf2-af78-48bf52a85304",	/*巴利詞根*/
+        "zh-Hant" => [
+            "3acf0c0f-59a7-4d25-a3d9-bf394a266ebd",    /*汉译パーリ语辞典-黃秉榮*/
+            "5293ffb9-887e-4cf2-af78-48bf52a85304",    /*巴利詞根*/
         ],
-        "jp"=>[
-            "91d3ec93-3811-4973-8d84-ced99179a0aa",	/*パーリ语辞典*/
-            "6d6c6812-75e7-457d-874f-5b049ad4b6de",	/*パーリ语辞典-增补*/
+        "jp" => [
+            "91d3ec93-3811-4973-8d84-ced99179a0aa",    /*パーリ语辞典*/
+            "6d6c6812-75e7-457d-874f-5b049ad4b6de",    /*パーリ语辞典-增补*/
         ],
-        "en"=>[
-            "c6e70507-4a14-4687-8b70-2d0c7eb0cf21",	/*	Concise P-E Dict*/
-            "eae9fd6f-7bac-4940-b80d-ad6cd6f433bf",	/*	Concise P-E Dict*/
-            "2f93d0fe-3d68-46ee-a80b-11fa445a29c6",	/*	unity*/
-            "b9163baf-2bca-41a5-a936-5a0834af3945",	/*	Pali-Dict Vri*/
-            "b089de57-f146-4095-b886-057863728c43",	/*	Buddhist Dictionary*/
-            "6afb8c05-5cbe-422e-b691-0d4507450cb7",	/*	PTS P-E dictionary*/
-            "0bfd87ec-f3ac-49a2-985e-28388779078d",	/*	Pali Proper Names Dict*/
-            "1cdc29e0-6783-4241-8784-5430b465b79c",	/*	Pāḷi Root In Saddanīti*/
-            "5718cbcf-684c-44d4-bbf2-4fa12f2588a4",	/*	Critical Pāli Dictionary*/
+        "en" => [
+            "c6e70507-4a14-4687-8b70-2d0c7eb0cf21",    /*	Concise P-E Dict*/
+            "eae9fd6f-7bac-4940-b80d-ad6cd6f433bf",    /*	Concise P-E Dict*/
+            "2f93d0fe-3d68-46ee-a80b-11fa445a29c6",    /*	unity*/
+            "b9163baf-2bca-41a5-a936-5a0834af3945",    /*	Pali-Dict Vri*/
+            "b089de57-f146-4095-b886-057863728c43",    /*	Buddhist Dictionary*/
+            "6afb8c05-5cbe-422e-b691-0d4507450cb7",    /*	PTS P-E dictionary*/
+            "0bfd87ec-f3ac-49a2-985e-28388779078d",    /*	Pali Proper Names Dict*/
+            "1cdc29e0-6783-4241-8784-5430b465b79c",    /*	Pāḷi Root In Saddanīti*/
+            "5718cbcf-684c-44d4-bbf2-4fa12f2588a4",    /*	Critical Pāli Dictionary*/
         ],
-        "my"=>[
-            "e740ef40-26d7-416e-96c2-925d6650ac6b",	/*	Tipiṭaka Pāḷi-Myanmar*/
-            "beb45062-7c20-4047-bcd4-1f636ba443d1",	/*	U Hau Sein’s Pāḷi-Myanmar Dictionary*/
-            "1e299ccb-4fc4-487d-8d72-08f63d84c809",	/*	Pali Roots Dictionary*/
-            "6f9caea1-17fa-41f1-92e5-bd8e6e70e1d7",	/*	U Hau Sein’s Pāḷi-Myanmar*/
+        "my" => [
+            "e740ef40-26d7-416e-96c2-925d6650ac6b",    /*	Tipiṭaka Pāḷi-Myanmar*/
+            "beb45062-7c20-4047-bcd4-1f636ba443d1",    /*	U Hau Sein’s Pāḷi-Myanmar Dictionary*/
+            "1e299ccb-4fc4-487d-8d72-08f63d84c809",    /*	Pali Roots Dictionary*/
+            "6f9caea1-17fa-41f1-92e5-bd8e6e70e1d7",    /*	U Hau Sein’s Pāḷi-Myanmar*/
         ],
-        "vi"=>[
-            "23f67523-fa03-48d9-9dda-ede80d578dd2",	/*	Pali Viet Dictionary*/
-            "4ac8a0d5-9c6f-4b9f-983d-84288d47f993",	/*	Pali Viet Abhi-Terms*/
-            "7c7ee287-35ba-4cf3-b87b-30f1fa6e57c9",	/*	Pali Viet Vinaya Terms*/
+        "vi" => [
+            "23f67523-fa03-48d9-9dda-ede80d578dd2",    /*	Pali Viet Dictionary*/
+            "4ac8a0d5-9c6f-4b9f-983d-84288d47f993",    /*	Pali Viet Abhi-Terms*/
+            "7c7ee287-35ba-4cf3-b87b-30f1fa6e57c9",    /*	Pali Viet Vinaya Terms*/
         ],
-        "cm"=>[],
+        "cm" => [],
     ];
     /**
      * The console command description.
@@ -88,7 +89,7 @@ class UpgradeDictDefaultMeaning extends Command
      */
     public function handle()
     {
-        if(\App\Tools\Tools::isStop()){
+        if (\App\Tools\Tools::isStop()) {
             return 0;
         }
         $_word = $this->argument('word');
@@ -96,48 +97,52 @@ class UpgradeDictDefaultMeaning extends Command
         $langInDict = UserDict::select('language')->groupBy('language')->get();
         $languages = [];
         foreach ($langInDict as $lang) {
-            if(!empty($lang["language"])){
+            if (!empty($lang["language"])) {
                 $languages[] = $lang["language"];
             }
         }
-		//print_r($languages);
-        foreach ($this->dict as $thisLang=>$dictId) {
+        //print_r($languages);
+        foreach ($this->dict as $thisLang => $dictId) {
             $this->info("running $thisLang");
 
-            $bar = $this->output->createProgressBar(UserDict::where('source','_PAPER_')
-                                                        ->where('language',$thisLang)->count());
-            foreach (UserDict::where('source','_PAPER_')
-                                ->where('language',$thisLang)
-                                ->select('word','note')
-                                ->cursor() as $word) {
-                if(!empty($word['note'])){
-                    RedisClusters::put("dict_first_mean/{$thisLang}/{$word['word']}", mb_substr($word['note'],0,50,"UTF-8"));
+            $bar = $this->output->createProgressBar(UserDict::where('source', '_PAPER_')
+                ->where('language', $thisLang)->count());
+            foreach (
+                UserDict::where('source', '_PAPER_')
+                    ->where('language', $thisLang)
+                    ->select('word', 'note')
+                    ->cursor() as $word
+            ) {
+                if (!empty($word['note'])) {
+                    Cache::put("dict_first_mean/{$thisLang}/{$word['word']}", mb_substr($word['note'], 0, 50, "UTF-8"));
                 }
                 $bar->advance();
             }
             $bar->finish();
 
-            for ($i=count($dictId)-1; $i >=0 ; $i--) {
+            for ($i = count($dictId) - 1; $i >= 0; $i--) {
                 # code...
                 $this->info("running $thisLang - {$dictId[$i]}");
                 $count = 0;
-                foreach (UserDict::where('dict_id',$dictId[$i])
-                    ->select('word','note')
-                    ->cursor() as $word) {
-                        $cacheKey = "dict_first_mean/{$thisLang}/{$word['word']}";
-                        if(!empty($word['note'])){
-                            $cacheValue = mb_substr($word['note'],0,50,"UTF-8");
-                            if(!empty($_word) && $word['word'] === $_word ){
-                                Log::info($cacheKey.':'.$cacheValue);
-                            }
-                            RedisClusters::put($cacheKey, $cacheValue);
+                foreach (
+                    UserDict::where('dict_id', $dictId[$i])
+                        ->select('word', 'note')
+                        ->cursor() as $word
+                ) {
+                    $cacheKey = "dict_first_mean/{$thisLang}/{$word['word']}";
+                    if (!empty($word['note'])) {
+                        $cacheValue = mb_substr($word['note'], 0, 50, "UTF-8");
+                        if (!empty($_word) && $word['word'] === $_word) {
+                            Log::info($cacheKey . ':' . $cacheValue);
                         }
+                        Cache::put($cacheKey, $cacheValue);
+                    }
 
-                        if($count % 1000 === 0){
-                            $this->info("{$count}");
-                        }
-                        $count++;
+                    if ($count % 1000 === 0) {
+                        $this->info("{$count}");
                     }
+                    $count++;
+                }
             }
         }
 

+ 5 - 5
api-v12/app/Http/Api/TaskApi.php

@@ -6,7 +6,7 @@ use App\Models\Task;
 use App\Models\TaskRelation;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\App;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Str;
 
 class TaskApi
@@ -84,8 +84,8 @@ class TaskApi
     public static function getRelationTasks($taskId, $relation = 'pre')
     {
         $key = TaskApi::taskRelationRedisKey($taskId, $relation);
-        //Log::debug('task redis key=' . $key . ' has=' . RedisClusters::has($key));
-        $data = RedisClusters::remember($key,  24 * 3600, function () use ($taskId, $relation) {
+        //Log::debug('task redis key=' . $key . ' has=' . Cache::has($key));
+        $data = Cache::remember($key,  24 * 3600, function () use ($taskId, $relation) {
             Log::debug('getRelationTasks task=' . $taskId . ' relation=' . $relation);
             if ($relation === 'pre') {
                 $where = 'next_task_id';
@@ -127,9 +127,9 @@ class TaskApi
         }
         foreach ($relationsId as $taskId => $value) {
             $key = TaskApi::taskRelationRedisKey($taskId, 'pre');
-            RedisClusters::forget($key);
+            Cache::forget($key);
             $key = TaskApi::taskRelationRedisKey($taskId, 'next');
-            RedisClusters::forget($key);
+            Cache::forget($key);
         }
     }
     public static function taskRelationRedisKey($taskId, $relation = 'pre')

+ 1 - 2
api-v12/app/Http/Api/TemplateRender.php

@@ -16,7 +16,6 @@ use App\Models\BookTitle as BookSeries;
 
 use App\Http\Controllers\CorpusController;
 
-use App\Tools\RedisClusters;
 use App\Http\Api\ChannelApi;
 use App\Http\Api\MdRender;
 use App\Http\Api\PaliTextApi;
@@ -675,7 +674,7 @@ class TemplateRender
     {
         $paraId = $this->get_param($this->param, "para", 1);
         $channelId = $this->channel_id[0];
-        $props = RedisClusters::remember(
+        $props = Cache::remember(
             "/quote/{$channelId}/{$paraId}",
             config('mint.cache.expire'),
             function () use ($paraId, $channelId) {

+ 22 - 23
api-v12/app/Http/Controllers/ApiController.php

@@ -4,7 +4,6 @@ namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Cache;
-use App\Tools\RedisClusters;
 use Illuminate\Support\Facades\Redis;
 use Illuminate\Support\Facades\Log;
 
@@ -37,25 +36,25 @@ class ApiController extends Controller
      * @param  int  $id
      * @return \Illuminate\Http\Response
      */
-    public function show(Request $request,$id)
+    public function show(Request $request, $id)
     {
         //
         $times = $id;
         $currTime = time();
-        $key= "pref-s/";
+        $key = "pref-s/";
         $begin = $currTime - $times - 1;
         $value = 0;
-        for ($i=$begin; $i <= $currTime; $i++) {
-            $keyApi = $key.$request->get('api','all')."/".$i;
-            if(!empty(Redis::get($keyApi.'/delay'))){
-                if($request->get('item') === 'average'){
-                    $value += intval(Redis::get($keyApi.'/delay') / Redis::get($keyApi.'/count'));
-                }else{
-                    $value += (int)Redis::get($keyApi.'/'.$request->get('item'));
+        for ($i = $begin; $i <= $currTime; $i++) {
+            $keyApi = $key . $request->get('api', 'all') . "/" . $i;
+            if (!empty(Redis::get($keyApi . '/delay'))) {
+                if ($request->get('item') === 'average') {
+                    $value += intval(Redis::get($keyApi . '/delay') / Redis::get($keyApi . '/count'));
+                } else {
+                    $value += (int)Redis::get($keyApi . '/' . $request->get('item'));
                 }
             }
         }
-        $value = $value/$times;
+        $value = $value / $times;
         return $this->ok($value);
     }
 
@@ -69,24 +68,24 @@ class ApiController extends Controller
     public function update(Request $request, $id)
     {
         //
-        $currMinute = intval(time()/60);
-        $key= "pref-m/";
+        $currMinute = intval(time() / 60);
+        $key = "pref-m/";
         $begin = $currMinute - 60;
         $output = [];
-        for ($i=$begin; $i <= $currMinute; $i++) {
+        for ($i = $begin; $i <= $currMinute; $i++) {
             $value = 0;
-            $keyApi = $key.$request->get('api','all')."/".$i;
-            if(!empty(Redis::get($keyApi.'/delay'))){
-                if($request->get('item') === 'average'){
-                    $value += intval(Redis::get($keyApi.'/delay') / Redis::get($keyApi.'/count'));
-                }else{
-                    $value += (int)Redis::get($keyApi.'/'.$request->get('item'));
+            $keyApi = $key . $request->get('api', 'all') . "/" . $i;
+            if (!empty(Redis::get($keyApi . '/delay'))) {
+                if ($request->get('item') === 'average') {
+                    $value += intval(Redis::get($keyApi . '/delay') / Redis::get($keyApi . '/count'));
+                } else {
+                    $value += (int)Redis::get($keyApi . '/' . $request->get('item'));
                 }
-            }else{
+            } else {
                 $value = 0;
             }
-            $time = date("H:i:s",$i);
-            $output[] = ['date'=>$time,'value'=>$value];
+            $time = date("H:i:s", $i);
+            $output[] = ['date' => $time, 'value' => $value];
         }
         return $this->ok($output);
     }

+ 2 - 3
api-v12/app/Http/Controllers/CorpusController.php

@@ -19,7 +19,6 @@ use App\Models\CustomBook;
 use Illuminate\Support\Str;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Cache;
-use App\Tools\RedisClusters;
 use App\Http\Api\MdRender;
 use App\Http\Api\SuggestionApi;
 use App\Http\Api\ChannelApi;
@@ -744,7 +743,7 @@ class CorpusController extends Controller
 
                             break;
                         case 'nissaya':
-                            $newSent['html'] = RedisClusters::remember(
+                            $newSent['html'] = Cache::remember(
                                 "/sent/{$channelId}/{$currSentId}/{$format}",
                                 config('mint.cache.expire'),
                                 function () use ($row, $mode, $format) {
@@ -1022,7 +1021,7 @@ class CorpusController extends Controller
         } else {
             $keyCanRead .= 'guest';
         }
-        $channelCanRead = RedisClusters::remember(
+        $channelCanRead = Cache::remember(
             $keyCanRead,
             config('mint.cache.expire'),
             function () use ($userUuid) {

+ 5 - 5
api-v12/app/Http/Controllers/DhammaTermController.php

@@ -17,7 +17,7 @@ use App\Http\Api\StudioApi;
 use App\Http\Api\ChannelApi;
 use App\Http\Api\ShareApi;
 use App\Tools\Tools;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 
 use PhpOffice\PhpSpreadsheet\Spreadsheet;
 use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
@@ -154,7 +154,7 @@ class DhammaTermController extends Controller
                 break;
             case 'hot-meaning':
                 $key = 'term/hot_meaning';
-                $value = RedisClusters::get($key, function () use ($request) {
+                $value = Cache::get($key, function () use ($request) {
                     $hotMeaning = [];
                     $words = DhammaTerm::select('word')
                         ->where('language', $request->get("language"))
@@ -178,7 +178,7 @@ class DhammaTermController extends Controller
                             ];
                         }
                     }
-                    RedisClusters::put($key, $hotMeaning, 3600);
+                    Cache::put($key, $hotMeaning, 3600);
                     return $hotMeaning;
                 }, config('mint.cache.expire'));
                 return $this->ok(["rows" => $value, "count" => count($value)]);
@@ -294,10 +294,10 @@ class DhammaTermController extends Controller
             //通用 查询studio所有channel
             $channels = Channel::where('owner_uid', $term->owner)->select('uid')->get();
             foreach ($channels as $channel) {
-                RedisClusters::forget("/term/{$channel}/{$term->word}");
+                Cache::forget("/term/{$channel}/{$term->word}");
             }
         } else {
-            RedisClusters::forget("/term/{$term->channal}/{$term->word}");
+            Cache::forget("/term/{$term->channal}/{$term->word}");
         }
     }
 

+ 35 - 15
api-v12/app/Http/Controllers/DictMeaningController.php

@@ -5,22 +5,41 @@ namespace App\Http\Controllers;
 use App\Models\UserDict;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Cache;
-use App\Tools\RedisClusters;
 
 class DictMeaningController extends Controller
 {
     protected $langOrder = [
-        "zh-Hans"=>[
-            "zh-Hans","zh-Hant","jp","en","my","vi"
+        "zh-Hans" => [
+            "zh-Hans",
+            "zh-Hant",
+            "jp",
+            "en",
+            "my",
+            "vi"
         ],
-        "zh-Hant"=>[
-            "zh-Hant","zh-Hans","jp","en","my","vi"
+        "zh-Hant" => [
+            "zh-Hant",
+            "zh-Hans",
+            "jp",
+            "en",
+            "my",
+            "vi"
         ],
-        "en"=>[
-            "en","my","zh-Hant","zh-Hans","jp","vi"
+        "en" => [
+            "en",
+            "my",
+            "zh-Hant",
+            "zh-Hans",
+            "jp",
+            "vi"
         ],
-        "jp"=>[
-            "jp","en","my","zh-Hant","zh-Hans","vi"
+        "jp" => [
+            "jp",
+            "en",
+            "my",
+            "zh-Hant",
+            "zh-Hans",
+            "vi"
         ],
     ];
 
@@ -32,26 +51,27 @@ class DictMeaningController extends Controller
     public function index(Request $request)
     {
         //
-        $words = explode("-",$request->get('word'));
+        $words = explode("-", $request->get('word'));
         $lang = $request->get('lang');
         $key = "dict_first_mean/";
         $meaning = [];
         foreach ($words as $key => $word) {
             # code...
-            $meaning[] = ['word'=>$word,'meaning'=>$this->get($word,$lang)];
+            $meaning[] = ['word' => $word, 'meaning' => $this->get($word, $lang)];
         }
 
         return $this->ok($meaning);
     }
 
-    public function get(string $word,string $lang){
+    public function get(string $word, string $lang)
+    {
         $currMeaning = "";
-        if(isset($this->langOrder[$lang])){
+        if (isset($this->langOrder[$lang])) {
             foreach ($this->langOrder[$lang] as $key => $value) {
                 # 遍历每种语言。找到返回
                 $cacheKey = "dict_first_mean/{$value}/{$word}";
-                $meaning = RedisClusters::get($cacheKey);
-                if(!empty($meaning)){
+                $meaning = Cache::get($cacheKey);
+                if (!empty($meaning)) {
                     $currMeaning = $meaning;
                     break;
                 }

+ 2 - 2
api-v12/app/Http/Controllers/EmailCertificationController.php

@@ -8,7 +8,7 @@ use App\Http\Resources\InviteResource;
 use Illuminate\Support\Str;
 use App\Mail\EmailCertif;
 use Illuminate\Support\Facades\Mail;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use App\Models\UserInfo;
 
 class EmailCertificationController extends Controller
@@ -68,7 +68,7 @@ class EmailCertificationController extends Controller
     public function show(string $id)
     {
         //
-        $code = RedisClusters::get("/email/certification/" . $id);
+        $code = Cache::get("/email/certification/" . $id);
         if (empty($code)) {
             return $this->error('Certification is avalide', 200, 200);
         }

+ 26 - 27
api-v12/app/Http/Controllers/ExportController.php

@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Storage;
 
 use App\Http\Api\AuthApi;
 use App\Http\Api\Mq;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use App\Tools\ExportDownload;
 
 class ExportController extends Controller
@@ -24,40 +24,40 @@ class ExportController extends Controller
     {
         $queryId = Str::uuid();
         $token = AuthApi::getToken($request);
-        switch ($request->get('type','chapter')) {
+        switch ($request->get('type', 'chapter')) {
             case 'chapter':
                 $data = [
-                    'book'=>$request->get('book'),
-                    'para'=>$request->get('par'),
-                    'channel'=>$request->get('channel'),
-                    'format'=>$request->get('format'),
-                    'origin'=>$request->get('origin'),
-                    'translation'=>$request->get('translation'),
-                    'queryId'=>$queryId,
+                    'book' => $request->get('book'),
+                    'para' => $request->get('par'),
+                    'channel' => $request->get('channel'),
+                    'format' => $request->get('format'),
+                    'origin' => $request->get('origin'),
+                    'translation' => $request->get('translation'),
+                    'queryId' => $queryId,
                 ];
-                if($token){
+                if ($token) {
                     $data['token'] = $token;
                 }
-                Mq::publish('export_pali_chapter',$data);
+                Mq::publish('export_pali_chapter', $data);
                 break;
             case 'article':
                 $data = [
-                    'id'=>$request->get('id'),
-                    'channel'=>$request->get('channel'),
-                    'format'=>$request->get('format'),
-                    'origin'=>$request->get('origin'),
-                    'translation'=>$request->get('translation'),
-                    'queryId'=>$queryId,
-                    'anthology'=>$request->get('anthology'),
-                    'channel'=>$request->get('channel'),
+                    'id' => $request->get('id'),
+                    'channel' => $request->get('channel'),
+                    'format' => $request->get('format'),
+                    'origin' => $request->get('origin'),
+                    'translation' => $request->get('translation'),
+                    'queryId' => $queryId,
+                    'anthology' => $request->get('anthology'),
+                    'channel' => $request->get('channel'),
                 ];
-                if($token){
+                if ($token) {
                     $data['token'] = $token;
                 }
-                Mq::publish('export_article',$data);
+                Mq::publish('export_article', $data);
                 break;
             default:
-                return $this->error('unknown type '.$request->get('type'),400,400);
+                return $this->error('unknown type ' . $request->get('type'), 400, 400);
                 break;
         }
 
@@ -84,19 +84,18 @@ class ExportController extends Controller
     public function show($filename)
     {
         //
-        $exportChapter = new ExportDownload(['queryId'=>$filename]);
+        $exportChapter = new ExportDownload(['queryId' => $filename]);
         $exportStatus = $exportChapter->getStatus();
-        if(empty($exportStatus)){
-            return $this->error('no file',200,200);
+        if (empty($exportStatus)) {
+            return $this->error('no file', 200, 200);
         };
 
         $output = array();
         $output['status'] = $exportStatus;
-        if($exportStatus['progress']===1){
+        if ($exportStatus['progress'] === 1) {
             $output['url'] = $exportStatus['url'];
         }
         return $this->ok($output);
-
     }
 
     /**

+ 2 - 2
api-v12/app/Http/Controllers/NissayaCoverController.php

@@ -3,7 +3,7 @@
 namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 
 class NissayaCoverController extends Controller
 {
@@ -15,7 +15,7 @@ class NissayaCoverController extends Controller
     public function index()
     {
         //
-        $cover = RedisClusters::get('/statistics/nissaya/cover');
+        $cover = Cache::get('/statistics/nissaya/cover');
         return $this->ok($cover);
     }
 

+ 2 - 3
api-v12/app/Http/Controllers/OfflineIndexController.php

@@ -4,7 +4,6 @@ namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Cache;
-use App\Tools\RedisClusters;
 use Illuminate\Support\Facades\Redis;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Storage;
@@ -22,10 +21,10 @@ class OfflineIndexController extends Controller
         //
         $key = '/offline/index';
 
-        if (!RedisClusters::has($key)) {
+        if (!Cache::has($key)) {
             return [];
         }
-        $fileInfo = RedisClusters::get($key);
+        $fileInfo = Cache::get($key);
         $output = [];
         foreach ($fileInfo as $key => $file) {
             if ($request->has('file')) {

+ 2 - 2
api-v12/app/Http/Controllers/PaliTextController.php

@@ -8,7 +8,7 @@ use App\Models\BookTitle;
 use App\Models\Tag;
 use App\Models\TagMap;
 use Illuminate\Http\Request;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use App\Http\Resources\PaliTextResource;
 
 class PaliTextController extends Controller
@@ -253,7 +253,7 @@ class PaliTextController extends Controller
                 if (is_object($value)) {
                     //TODO $value->book 可能不存在
                     $progress_key = "/chapter_dynamic/{$value->book}/{$value->paragraph}/global";
-                    $chapters[$key]->progress_line = RedisClusters::get($progress_key);
+                    $chapters[$key]->progress_line = Cache::get($progress_key);
                 }
             }
         }

+ 2 - 2
api-v12/app/Http/Controllers/ProgressChapterController.php

@@ -13,7 +13,7 @@ use App\Models\View;
 use App\Models\Like;
 use Illuminate\Http\Request;
 use App\Http\Api\StudioApi;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 
 class ProgressChapterController extends Controller
 {
@@ -234,7 +234,7 @@ class ProgressChapterController extends Controller
                     $chapters[$key]->studio = StudioApi::getById($value->owner_uid);
                     $chapters[$key]->channel = ['uid' => $value->channel_id, 'name' => $value->name, 'type' => $value->type];
                     $progress_key = "/chapter_dynamic/{$value->book}/{$value->para}/ch_{$value->channel_id}";
-                    $chapters[$key]->progress_line = RedisClusters::get($progress_key);
+                    $chapters[$key]->progress_line = Cache::get($progress_key);
                 }
 
                 $all_count = count($chapters);

+ 9 - 10
api-v12/app/Http/Controllers/ProgressImgController.php

@@ -4,7 +4,6 @@ namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Cache;
-use App\Tools\RedisClusters;
 use Illuminate\Support\Facades\Log;
 
 class ProgressImgController extends Controller
@@ -40,26 +39,26 @@ class ProgressImgController extends Controller
     {
         //
         return response()->stream(function () use ($id) {
-            $key = str_replace('-','/',$id);
-            $svg = RedisClusters::get('svg/'.$key, function () use ($key) {
+            $key = str_replace('-', '/', $id);
+            $svg = Cache::get('svg/' . $key, function () use ($key) {
                 $viewHeight = 60;
                 $svg = "<svg xmlns='http://www.w3.org/2000/svg'  fill='currentColor' viewBox='0 0 300 60'>";
-                $data = RedisClusters::get($key);
-                if(is_array($data)){
+                $data = Cache::get($key);
+                if (is_array($data)) {
                     $point = [];
                     foreach ($data as $key => $value) {
-                        $point[] = ($key*10) . ',' . $viewHeight-($value/20)-3;
+                        $point[] = ($key * 10) . ',' . $viewHeight - ($value / 20) - 3;
                     }
-                    $svg .= '<polyline points="'. implode(' ',$point) . '"';
+                    $svg .= '<polyline points="' . implode(' ', $point) . '"';
                     $svg .= ' style="fill:none;stroke:green;stroke-width:3" /></svg>';
-                }else{
+                } else {
                     $svg .= '<polyline points="0,0 1,0" /></svg>';
                 }
                 return $svg;
-            } , config('mint.cache.expire') );
+            }, config('mint.cache.expire'));
             echo $svg;
         }, 200, ['Content-Type' => 'image/svg+xml']);
-    /*
+        /*
     ————————————————
     原文作者:Summer
     转自链接:https://learnku.com/laravel/wikis/25600

+ 78 - 69
api-v12/app/Http/Controllers/RelationController.php

@@ -10,7 +10,6 @@ use Illuminate\Support\Facades\App;
 use PhpOffice\PhpSpreadsheet\Spreadsheet;
 use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
 use Illuminate\Support\Facades\Cache;
-use App\Tools\RedisClusters;
 
 class RelationController extends Controller
 {
@@ -23,47 +22,56 @@ class RelationController extends Controller
     {
         //
         $key = 'relation-vocabulary';
-        if($request->has('vocabulary')){
-            if(RedisClusters::has($key)){
-                return $this->ok(RedisClusters::get($key));
+        if ($request->has('vocabulary')) {
+            if (Cache::has($key)) {
+                return $this->ok(Cache::get($key));
             }
         }
-        $table = Relation::select(['id','name','case','from','to',
-                                    'category','editor_id','match',
-                                    'updated_at','created_at']);
-        if(($request->has('case'))){
-            $table = $table->whereIn('case', explode(",",$request->get('case')) );
+        $table = Relation::select([
+            'id',
+            'name',
+            'case',
+            'from',
+            'to',
+            'category',
+            'editor_id',
+            'match',
+            'updated_at',
+            'created_at'
+        ]);
+        if (($request->has('case'))) {
+            $table = $table->whereIn('case', explode(",", $request->get('case')));
         }
-        if(($request->has('search'))){
-            $table = $table->where('name', 'like', $request->get('search')."%");
+        if (($request->has('search'))) {
+            $table = $table->where('name', 'like', $request->get('search') . "%");
         }
-        if(($request->has('name'))){
-            $table = $table->where('name',$request->get('name'));
+        if (($request->has('name'))) {
+            $table = $table->where('name', $request->get('name'));
         }
-        if(($request->has('from'))){
-            $table = $table->whereJsonContains('from->case',$request->get('from'));
+        if (($request->has('from'))) {
+            $table = $table->whereJsonContains('from->case', $request->get('from'));
         }
-        if(($request->has('to'))){
-            $table = $table->whereJsonContains('to',$request->get('to'));
+        if (($request->has('to'))) {
+            $table = $table->whereJsonContains('to', $request->get('to'));
         }
-        if(($request->has('match'))){
-            $table = $table->whereJsonContains('match',$request->get('match'));
+        if (($request->has('match'))) {
+            $table = $table->whereJsonContains('match', $request->get('match'));
         }
-        if(($request->has('category'))){
-            $table = $table->where('category',$request->get('category'));
+        if (($request->has('category'))) {
+            $table = $table->where('category', $request->get('category'));
         }
-        $table = $table->orderBy($request->get('order','updated_at'),$request->get('dir','desc'));
+        $table = $table->orderBy($request->get('order', 'updated_at'), $request->get('dir', 'desc'));
         $count = $table->count();
 
-        $table = $table->skip($request->get("offset",0))
-                       ->take($request->get('limit',1000));
+        $table = $table->skip($request->get("offset", 0))
+            ->take($request->get('limit', 1000));
         $result = $table->get();
 
-        $output = ["rows"=>RelationResource::collection($result),"count"=>$count];
+        $output = ["rows" => RelationResource::collection($result), "count" => $count];
 
-        if($request->has('vocabulary')){
-            if(!RedisClusters::has($key)){
-                RedisClusters::put($key,$output,config('mint.cache.expire'));
+        if ($request->has('vocabulary')) {
+            if (!Cache::has($key)) {
+                Cache::put($key, $output, config('mint.cache.expire'));
             }
         }
         return $this->ok($output);
@@ -80,39 +88,38 @@ class RelationController extends Controller
     {
         //
         $user = AuthApi::current($request);
-        if(!$user){
-            return $this->error(__('auth.failed'),[],401);
+        if (!$user) {
+            return $this->error(__('auth.failed'), [], 401);
         }
         //TODO 判断权限
         $validated = $request->validate([
             'name' => 'required',
         ]);
-        $case = $request->get('case','');
+        $case = $request->get('case', '');
         $new = new Relation;
         $new->name = $validated['name'];
 
         $new->case = $request->get('case');
         $new->category = $request->get('category');
 
-        if($request->has('from')){
-            $new->from = json_encode($request->get('from'),JSON_UNESCAPED_UNICODE);
-        }else{
+        if ($request->has('from')) {
+            $new->from = json_encode($request->get('from'), JSON_UNESCAPED_UNICODE);
+        } else {
             $new->from = null;
         }
-        if($request->has('to')){
-            $new->to = json_encode($request->get('to'),JSON_UNESCAPED_UNICODE);
-        }else{
+        if ($request->has('to')) {
+            $new->to = json_encode($request->get('to'), JSON_UNESCAPED_UNICODE);
+        } else {
             $new->to = null;
         }
-        if($request->has('match')){
-            $new->match = json_encode($request->get('match'),JSON_UNESCAPED_UNICODE);
-        }else{
+        if ($request->has('match')) {
+            $new->match = json_encode($request->get('match'), JSON_UNESCAPED_UNICODE);
+        } else {
             $new->match = null;
         }
         $new->editor_id = $user['user_uid'];
         $new->save();
         return $this->ok(new RelationResource($new));
-
     }
 
     /**
@@ -139,7 +146,7 @@ class RelationController extends Controller
     {
         //
         $user = AuthApi::current($request);
-        if(!$user){
+        if (!$user) {
             return $this->error(__('auth.failed'));
         }
 
@@ -147,19 +154,19 @@ class RelationController extends Controller
         $relation->case = $request->get('case');
         $relation->category = $request->get('category');
 
-        if($request->has('from')){
-            $relation->from = json_encode($request->get('from'),JSON_UNESCAPED_UNICODE);
-        }else{
+        if ($request->has('from')) {
+            $relation->from = json_encode($request->get('from'), JSON_UNESCAPED_UNICODE);
+        } else {
             $relation->from = null;
         }
-        if($request->has('to')){
-            $relation->to = json_encode($request->get('to'),JSON_UNESCAPED_UNICODE);
-        }else{
+        if ($request->has('to')) {
+            $relation->to = json_encode($request->get('to'), JSON_UNESCAPED_UNICODE);
+        } else {
             $relation->to = null;
         }
-        if($request->has('match')){
-            $relation->match = json_encode($request->get('match'),JSON_UNESCAPED_UNICODE);
-        }else{
+        if ($request->has('match')) {
+            $relation->match = json_encode($request->get('match'), JSON_UNESCAPED_UNICODE);
+        } else {
             $relation->match = null;
         }
         $relation->editor_id = $user['user_uid'];
@@ -174,11 +181,11 @@ class RelationController extends Controller
      * @param  \App\Models\Relation  $relation
      * @return \Illuminate\Http\Response
      */
-    public function destroy(Request $request,Relation $relation)
+    public function destroy(Request $request, Relation $relation)
     {
         //
         $user = AuthApi::current($request);
-        if(!$user){
+        if (!$user) {
             return $this->error(__('auth.failed'));
         }
         //TODO 判断当前用户是否有权限
@@ -188,7 +195,8 @@ class RelationController extends Controller
         return $this->ok($delete);
     }
 
-    public function export(){
+    public function export()
+    {
         $spreadsheet = new Spreadsheet();
         $activeWorksheet = $spreadsheet->getActiveSheet();
         $activeWorksheet->setCellValue('A1', 'id');
@@ -216,9 +224,10 @@ class RelationController extends Controller
         $writer->save("php://output");
     }
 
-    public function import(Request $request){
+    public function import(Request $request)
+    {
         $user = AuthApi::current($request);
-        if(!$user){
+        if (!$user) {
             return $this->error(__('auth.failed'));
         }
 
@@ -238,10 +247,10 @@ class RelationController extends Controller
             $to = $activeWorksheet->getCell("D{$currLine}")->getValue();
             $match = $activeWorksheet->getCell("E{$currLine}")->getValue();
             $category = $activeWorksheet->getCell("F{$currLine}")->getValue();
-            if(!empty($name)){
-                                //查询是否有冲突数据
+            if (!empty($name)) {
+                //查询是否有冲突数据
                 //查询此id是否有旧数据
-                if(!empty($id)){
+                if (!empty($id)) {
                     $oldRow = Relation::find($id);
                 }
                 //查询是否跟已有数据重复
@@ -254,28 +263,28 @@ class RelationController extends Controller
                                         ])->first();
                 */
                 $row = false;
-                if(!$row){
+                if (!$row) {
                     //不重复
-                    if(isset($oldRow) && $oldRow){
+                    if (isset($oldRow) && $oldRow) {
                         //有旧的记录-修改旧数据
                         $row = $oldRow;
-                    }else{
+                    } else {
                         //没找到旧的记录-新建
                         $row = new Relation();
                     }
-                }else{
+                } else {
                     //重复-如果与旧的id不同旧报错
-                    if(isset($oldRow) && $oldRow && $row->id !== $id){
-                        $error .= "重复的数据:{$id} - {$word}\n";
+                    if (isset($oldRow) && $oldRow && $row->id !== $id) {
+                        $error .= "重复的数据:id={$id} -\n";
                         $currLine++;
                         $countFail++;
                         continue;
                     }
                 }
                 $row->name = $name;
-                if(empty($from)){
+                if (empty($from)) {
                     $row->from = null;
-                }else{
+                } else {
                     $row->from = $from;
                 }
                 $row->to = $to;
@@ -283,11 +292,11 @@ class RelationController extends Controller
                 $row->category = $category;
                 $row->editor_id = $user['user_uid'];
                 $row->save();
-            }else{
+            } else {
                 break;
             }
             $currLine++;
         } while (true);
-        return $this->ok(["success"=>$currLine-2-$countFail,'fail'=>($countFail)],$error);
+        return $this->ok(["success" => $currLine - 2 - $countFail, 'fail' => ($countFail)], $error);
     }
 }

+ 5 - 6
api-v12/app/Http/Controllers/SentenceController.php

@@ -20,7 +20,6 @@ use App\Http\Api\ChannelApi;
 use App\Http\Api\PaliTextApi;
 use App\Http\Api\Mq;
 use App\Models\AccessToken;
-use App\Tools\RedisClusters;
 use App\Tools\OpsLog;
 
 use Firebase\JWT\JWT;
@@ -537,7 +536,7 @@ class SentenceController extends Controller
         //清除cache
         $channelId = $param[4];
         $currSentId = "{$param[0]}-{$param[1]}-{$param[2]}-{$param[3]}";
-        RedisClusters::forget("/sent/{$channelId}/{$currSentId}");
+        Cache::forget("/sent/{$channelId}/{$currSentId}");
         //保存历史记录
         if ($request->has('prEditor')) {
             $this->saveHistory(
@@ -606,8 +605,8 @@ class SentenceController extends Controller
             if (!empty($word->meaning->value)) {
                 $newData['data'] = $word->meaning->value;
                 WbwAnalysis::insert($newData);
-                RedisClusters::put("{$prefix}/{$word->real->value}/3/{$editorId}", $word->meaning->value);
-                RedisClusters::put("{$prefix}/{$word->real->value}/3/0", $word->meaning->value);
+                Cache::put("{$prefix}/{$word->real->value}/3/{$editorId}", $word->meaning->value);
+                Cache::put("{$prefix}/{$word->real->value}/3/0", $word->meaning->value);
             }
             if (isset($word->factors) && isset($word->factorMeaning)) {
                 $factors = explode('+', str_replace('-', '+', $word->factors->value));
@@ -619,8 +618,8 @@ class SentenceController extends Controller
                             $newData['data'] = $factorMeaning[$key];
                             $newData['type'] = 5;
                             WbwAnalysis::insert($newData);
-                            RedisClusters::put("{$prefix}/{$factor}/5/{$editorId}", $factorMeaning[$key]);
-                            RedisClusters::put("{$prefix}/{$factor}/5/0", $factorMeaning[$key]);
+                            Cache::put("{$prefix}/{$factor}/5/{$editorId}", $factorMeaning[$key]);
+                            Cache::put("{$prefix}/{$factor}/5/0", $factorMeaning[$key]);
                         }
                     }
                 }

+ 2 - 2
api-v12/app/Http/Controllers/SentenceInfoController.php

@@ -8,7 +8,7 @@ use App\Models\PaliText;
 
 use Illuminate\Http\Request;
 use App\Http\Resources\SentResource;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 
 class SentenceInfoController extends Controller
 {
@@ -115,7 +115,7 @@ class SentenceInfoController extends Controller
             foreach ($sentFinished as $sent) {
                 # code...
                 $key_sent_id = $sent->book_id . '-' . $sent->paragraph . '-' . $sent->word_start . '-' . $sent->word_end;
-                $para_strlen += RedisClusters::remember(
+                $para_strlen += Cache::remember(
                     'pali-sent/strlen/' . $key_sent_id,
                     config('mint.cache.expire'),
                     function () use ($sent) {

+ 1 - 1
api-v12/app/Http/Controllers/SiteInfoController.php

@@ -4,7 +4,7 @@ namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\App;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use App\Services\AIModelService;
 
 

+ 3 - 3
api-v12/app/Http/Controllers/SysModelController.php

@@ -6,7 +6,7 @@ use App\Models\AiModel;
 use Illuminate\Http\Request;
 use App\Http\Api\AuthApi;
 use Illuminate\Support\Facades\Log;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use App\Http\Resources\AiModelResource;
 
 class SysModelController extends Controller
@@ -25,7 +25,7 @@ class SysModelController extends Controller
             Log::error('notification auth failed {request}', ['request' => $request]);
             return $this->error(__('auth.failed'), 401, 401);
         }
-        $modelsId = RedisClusters::get($this->key . $request->get('view', 'wbw'));
+        $modelsId = Cache::get($this->key . $request->get('view', 'wbw'));
         if (!is_array($modelsId)) {
             $modelsId = [];
         }
@@ -53,7 +53,7 @@ class SysModelController extends Controller
             Log::error('notification auth failed {request}', ['request' => $request]);
             return $this->error(__('auth.failed'), 401, 401);
         }
-        RedisClusters::put(
+        Cache::put(
             $this->key . $request->get('view', 'wbw'),
             $request->get('models')
         );

+ 86 - 60
api-v12/app/Http/Controllers/UserStatisticController.php

@@ -9,10 +9,8 @@ use App\Models\Sentence;
 use App\Models\DhammaTerm;
 use App\Models\UserDict;
 use Illuminate\Http\Request;
-use App\Http\Api\AuthApi;
 use App\Http\Api\UserApi;
 use Illuminate\Support\Facades\Cache;
-use App\Tools\RedisClusters;
 
 class UserStatisticController extends Controller
 {
@@ -53,7 +51,7 @@ class UserStatisticController extends Controller
      * @param  \App\Models\UserOperationDaily  $userOperationDaily
      * @return \Illuminate\Http\Response
      */
-    public function show(Request $request,string $userName)
+    public function show(Request $request, string $userName)
     {
         //
         $queryUserId = UserApi::getIntIdByName($userName);
@@ -69,78 +67,106 @@ class UserStatisticController extends Controller
         $termCountWithNote = 0;
         $myDictCount = 0;
         //总经验值
-        if(!$request->has('view') || $request->get('view') === 'exp-sum'){
-            $expSum = RedisClusters::remember("user/{$userName}/exp/sum",$cacheExpiry,
-                    function() use($queryUserId){
-                        return UserOperationDaily::where('user_id',$queryUserId)
-                                ->sum('duration');
-            });
+        if (!$request->has('view') || $request->get('view') === 'exp-sum') {
+            $expSum = Cache::remember(
+                "user/{$userName}/exp/sum",
+                $cacheExpiry,
+                function () use ($queryUserId) {
+                    return UserOperationDaily::where('user_id', $queryUserId)
+                        ->sum('duration');
+                }
+            );
         }
 
         //逐词解析
-        if(!$request->has('view') || $request->get('view') === 'wbw-count'){
-            $wbwCount = RedisClusters::remember("user/{$userName}/wbw/count",$cacheExpiry,
-                        function() use($queryUserId){
-                            return Wbw::where('editor_id',$queryUserId)
-                                ->count();
-                            });
+        if (!$request->has('view') || $request->get('view') === 'wbw-count') {
+            $wbwCount = Cache::remember(
+                "user/{$userName}/wbw/count",
+                $cacheExpiry,
+                function () use ($queryUserId) {
+                    return Wbw::where('editor_id', $queryUserId)
+                        ->count();
+                }
+            );
         }
 
         //查字典次数
-        if(!$request->has('view') || $request->get('view') === 'lookup-count'){
-            $lookupCount = RedisClusters::remember("user/{$userName}/lookup/count",$cacheExpiry,
-                            function() use($queryUserId){
-                                return UserOperationLog::where('user_id',$queryUserId)
-                                                        ->where('op_type','dict_lookup')
-                                                        ->count();
-                                    });
+        if (!$request->has('view') || $request->get('view') === 'lookup-count') {
+            $lookupCount = Cache::remember(
+                "user/{$userName}/lookup/count",
+                $cacheExpiry,
+                function () use ($queryUserId) {
+                    return UserOperationLog::where('user_id', $queryUserId)
+                        ->where('op_type', 'dict_lookup')
+                        ->count();
+                }
+            );
         }
         //译文
         //TODO 判断是否是译文channel
-        if(!$request->has('view') || $request->get('view') === 'translation-count'){
-            $translationCount = RedisClusters::remember("user/{$userName}/translation/count",$cacheExpiry,
-                                function() use($queryUserUuid){
-                                return Sentence::where('editor_uid',$queryUserUuid)
-                                            ->count();
-                                });
-            $translationCountPub = RedisClusters::remember("user/{$userName}/translation/count-pub",$cacheExpiry,
-                                    function() use($queryUserUuid){
-                                        return Sentence::where('editor_uid',$queryUserUuid)
-                                        ->where('status',30)
-                                        ->count();
-                                    });
+        if (!$request->has('view') || $request->get('view') === 'translation-count') {
+            $translationCount = Cache::remember(
+                "user/{$userName}/translation/count",
+                $cacheExpiry,
+                function () use ($queryUserUuid) {
+                    return Sentence::where('editor_uid', $queryUserUuid)
+                        ->count();
+                }
+            );
+            $translationCountPub = Cache::remember(
+                "user/{$userName}/translation/count-pub",
+                $cacheExpiry,
+                function () use ($queryUserUuid) {
+                    return Sentence::where('editor_uid', $queryUserUuid)
+                        ->where('status', 30)
+                        ->count();
+                }
+            );
         }
         //术语
-        if(!$request->has('view') || $request->get('view') === 'term-count'){
-            $termCount = RedisClusters::remember("user/{$userName}/term/count",$cacheExpiry,
-                        function() use($queryUserId){
-                            return DhammaTerm::where('editor_id',$queryUserId)
-                                        ->count();
-                        });
-            $termCountWithNote = RedisClusters::remember("user/{$userName}/term/count-note",$cacheExpiry,
-                                function() use($queryUserId){
-                                    return DhammaTerm::where('editor_id',$queryUserId)
-                                                        ->where('note',"<>","")
-                                                        ->count();
-                                    });
+        if (!$request->has('view') || $request->get('view') === 'term-count') {
+            $termCount = Cache::remember(
+                "user/{$userName}/term/count",
+                $cacheExpiry,
+                function () use ($queryUserId) {
+                    return DhammaTerm::where('editor_id', $queryUserId)
+                        ->count();
+                }
+            );
+            $termCountWithNote = Cache::remember(
+                "user/{$userName}/term/count-note",
+                $cacheExpiry,
+                function () use ($queryUserId) {
+                    return DhammaTerm::where('editor_id', $queryUserId)
+                        ->where('note', "<>", "")
+                        ->count();
+                }
+            );
         }
         //单词本
-        if(!$request->has('view') || $request->get('view') === 'my-dict-count'){
-            $myDictCount = RedisClusters::remember("user/{$userName}/dict/count",$cacheExpiry,
-                            function() use($queryUserId){
-                                return UserDict::where('creator_id',$queryUserId)
-                                            ->count();
-                            });
+        if (!$request->has('view') || $request->get('view') === 'my-dict-count') {
+            $myDictCount = Cache::remember(
+                "user/{$userName}/dict/count",
+                $cacheExpiry,
+                function () use ($queryUserId) {
+                    return UserDict::where('creator_id', $queryUserId)
+                        ->count();
+                }
+            );
         }
         return $this->ok([
-            "exp" => ["sum"=>(int)$expSum],
-            "wbw" => ["count"=>(int)$wbwCount],
-            "lookup" => ["count"=>(int)$lookupCount],
-            "translation" =>["count"=>(int)$translationCount,
-                             "count_pub"=>(int)$translationCountPub],
-            "term" => ["count"=>(int)$termCount,
-                      "count_with_note"=>(int)$termCountWithNote],
-            "dict" => ["count"=>(int)$myDictCount],
+            "exp" => ["sum" => (int)$expSum],
+            "wbw" => ["count" => (int)$wbwCount],
+            "lookup" => ["count" => (int)$lookupCount],
+            "translation" => [
+                "count" => (int)$translationCount,
+                "count_pub" => (int)$translationCountPub
+            ],
+            "term" => [
+                "count" => (int)$termCount,
+                "count_with_note" => (int)$termCountWithNote
+            ],
+            "dict" => ["count" => (int)$myDictCount],
         ]);
     }
 

+ 13 - 14
api-v12/app/Http/Controllers/VocabularyController.php

@@ -4,11 +4,8 @@ namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Cache;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Log;
 use App\Models\Vocabulary;
 use App\Http\Resources\VocabularyResource;
-use App\Tools\RedisClusters;
 
 class VocabularyController extends Controller
 {
@@ -23,17 +20,19 @@ class VocabularyController extends Controller
         switch ($request->get("view")) {
             case 'key':
                 $key = $request->get("key");
-                $result = RedisClusters::remember("/dict_vocabulary/{$key}",
-                        config('mint.cache.expire'),
-                        function() use($key){
-                            $query = Vocabulary::where('word', 'like',$key."%")
-                                            ->orWhere('word_en','like',$key."%")
-                                            ->orderBy('strlen')
-                                            ->orderBy('word')
-                                            ->take(50);
-                            return $query->get();
-                });
-                return $this->ok(['rows'=>VocabularyResource::collection($result),'count'=>count($result)]);
+                $result = Cache::remember(
+                    "/dict_vocabulary/{$key}",
+                    config('mint.cache.expire'),
+                    function () use ($key) {
+                        $query = Vocabulary::where('word', 'like', $key . "%")
+                            ->orWhere('word_en', 'like', $key . "%")
+                            ->orderBy('strlen')
+                            ->orderBy('word')
+                            ->take(50);
+                        return $query->get();
+                    }
+                );
+                return $this->ok(['rows' => VocabularyResource::collection($result), 'count' => count($result)]);
                 break;
         }
     }

+ 2 - 3
api-v12/app/Http/Controllers/WbwLookupController.php

@@ -10,7 +10,6 @@ use Illuminate\Http\Request;
 use App\Tools\CaseMan;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Cache;
-use App\Tools\RedisClusters;
 use App\Http\Api\DictApi;
 use App\Http\Api\AuthApi;
 
@@ -172,12 +171,12 @@ class WbwLookupController extends Controller
             'case' => 8,
         ];
         $fieldId = $fieldMap[$field];
-        $myPreference = RedisClusters::get("{$prefix}/{$word}/{$fieldId}/{$userId}");
+        $myPreference = Cache::get("{$prefix}/{$word}/{$fieldId}/{$userId}");
         if (!empty($myPreference)) {
             Log::debug($word . '命中我的wbw-' . $field, ['data' => $myPreference]);
             return ['value' => $myPreference, 'status' => 5];
         } else {
-            $myPreference = RedisClusters::get("{$prefix}/{$word}/3/0");
+            $myPreference = Cache::get("{$prefix}/{$word}/3/0");
             if (!empty($myPreference)) {
                 Log::debug($word . '命中社区wbw-' . $field, ['data' => $myPreference]);
                 return ['value' => $myPreference, 'status' => 5];

+ 3 - 7
api-v12/app/Http/Controllers/WordIndexController.php

@@ -4,10 +4,6 @@ namespace App\Http\Controllers;
 
 use App\Models\WordIndex;
 use Illuminate\Http\Request;
-use App\Http\Resources\WordIndexResource;
-use Illuminate\Support\Facades\Cache;
-use App\Tools\RedisClusters;
-use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\DB;
 
 class WordIndexController extends Controller
@@ -24,7 +20,7 @@ class WordIndexController extends Controller
             case 'key':
                 $key = $request->get("key");
                 /*
-                $result = RedisClusters::remember("/word_index/{$key}",10,function() use($key){
+                $result = Cache::remember("/word_index/{$key}",10,function() use($key){
                     return WordIndex::where('word','like',$key."%")
                                     ->whereOr('word_en','like',$key."%")
                                     ->orderBy('word_en')
@@ -38,9 +34,9 @@ class WordIndexController extends Controller
                 Log::info($table->toSql());
                 $result = $table->get();
 */
-                $result = DB::select("SELECT * from  word_indices where word like ? or word_en like ? order by len, word_en limit 10",[$key."%",$key."%"]);
+                $result = DB::select("SELECT * from  word_indices where word like ? or word_en like ? order by len, word_en limit 10", [$key . "%", $key . "%"]);
 
-                return $this->ok(['rows'=>$result,'count'=>count($result)]);
+                return $this->ok(['rows' => $result, 'count' => count($result)]);
                 break;
             default:
                 return $this->error('view error');

+ 19 - 21
api-v12/app/Http/Resources/SearchResource.php

@@ -7,7 +7,6 @@ use App\Models\PaliText;
 use App\Models\Sentence;
 use App\Http\Api\ChannelApi;
 use Illuminate\Support\Facades\Cache;
-use App\Tools\RedisClusters;
 
 
 class SearchResource extends JsonResource
@@ -21,27 +20,27 @@ class SearchResource extends JsonResource
     public function toArray($request)
     {
         $data = [
-            "book"=>$this->book,
-            "paragraph"=> $this->paragraph,
+            "book" => $this->book,
+            "paragraph" => $this->paragraph,
         ];
-        if(isset($this->rank)){
+        if (isset($this->rank)) {
             $data["rank"] = $this->rank;
         }
-        $paliText = PaliText::where('book',$this->book)
-                            ->where('paragraph',$this->paragraph)
-                            ->first();
-        if(isset($this->highlight)){
+        $paliText = PaliText::where('book', $this->book)
+            ->where('paragraph', $this->paragraph)
+            ->first();
+        if (isset($this->highlight)) {
             $data["highlight"] = $this->highlight;
-        }else if(isset($this->content)){
+        } else if (isset($this->content)) {
             $data["content"] = $this->content;
-        }else{
-            $channelId = RedisClusters::remember('_System_Pali_VRI_',config('mint.cache.expire'),function(){
+        } else {
+            $channelId = Cache::remember('_System_Pali_VRI_', config('mint.cache.expire'), function () {
                 return ChannelApi::getSysChannel('_System_Pali_VRI_');
             });
 
-            $paraContent = Sentence::where('book_id',$this->book)
-                ->where('paragraph',$this->paragraph)
-                ->where('channel_uid',$channelId)
+            $paraContent = Sentence::where('book_id', $this->book)
+                ->where('paragraph', $this->paragraph)
+                ->where('channel_uid', $channelId)
                 ->orderBy('word_start')
                 ->select('content')
                 ->get();
@@ -52,16 +51,15 @@ class SearchResource extends JsonResource
             $data["content"] = $html;
         }
 
-        if($paliText){
+        if ($paliText) {
             $data['path'] = json_decode($paliText->path);
-            if($paliText->level<100){
+            if ($paliText->level < 100) {
                 $data["paliTitle"] = $paliText->toc;
-            }else{
-                $data["paliTitle"] = PaliText::where('book',$this->book)
-                                            ->where('paragraph',$paliText->parent)
-                                            ->value('toc');
+            } else {
+                $data["paliTitle"] = PaliText::where('book', $this->book)
+                    ->where('paragraph', $paliText->parent)
+                    ->value('toc');
             }
-
         }
         return $data;
     }

+ 4 - 6
api-v12/app/Http/Resources/VocabularyResource.php

@@ -3,8 +3,6 @@
 namespace App\Http\Resources;
 
 use Illuminate\Http\Resources\Json\JsonResource;
-use Illuminate\Support\Facades\Cache;
-use App\Tools\RedisClusters;
 use App\Http\Controllers\DictMeaningController;
 
 class VocabularyResource extends JsonResource
@@ -19,10 +17,10 @@ class VocabularyResource extends JsonResource
     {
         $dictMeaning = new DictMeaningController();
         return [
-            "word"=>$this['word'],
-            "count"=> $this['count'],
-            "strlen"=> $this['strlen'],
-            "meaning"=> $dictMeaning->get($this['word'],$request->get("lang","zh-Hans")),
+            "word" => $this['word'],
+            "count" => $this['count'],
+            "strlen" => $this['strlen'],
+            "meaning" => $dictMeaning->get($this['word'], $request->get("lang", "zh-Hans")),
         ];
     }
 }

+ 2 - 2
api-v12/app/Jobs/ProcessAITranslateJob.php

@@ -6,7 +6,7 @@ use App\Services\AiTranslateService;
 use App\Services\RabbitMQService;
 use Illuminate\Support\Facades\Log;
 use App\Exceptions\TaskFailException;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 
 class ProcessAITranslateJob extends BaseRabbitMQJob
 {
@@ -50,7 +50,7 @@ class ProcessAITranslateJob extends BaseRabbitMQJob
         $mq = app(RabbitMQService::class);
         $queue = 'ai_translate_v2';
         $msgId = $mq->publishMessage($queue, []);
-        RedisClusters::put("/mq/message/{$msgId}/data", $data);
+        Cache::put("/mq/message/{$msgId}/data", $data);
         return $msgId;
     }
 }

+ 2 - 2
api-v12/app/Mail/EmailCertif.php

@@ -5,7 +5,7 @@ namespace App\Mail;
 use Illuminate\Bus\Queueable;
 use Illuminate\Mail\Mailable;
 use Illuminate\Queue\SerializesModels;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Log;
 
 class EmailCertif extends Mailable
@@ -37,7 +37,7 @@ class EmailCertif extends Mailable
         $randomNumber = random_int(1000, 9999);
         $key = "/email/certification/" . $this->uuid;
         Log::debug('email certification', ['key' => $key, 'value' => $randomNumber]);
-        RedisClusters::put($key, $randomNumber,  30 * 60);
+        Cache::put($key, $randomNumber,  30 * 60);
         return $this->view('emails.certification.' . $this->lang)
             ->with([
                 'code' => $randomNumber,

+ 2 - 2
api-v12/app/Services/AIModelService.php

@@ -4,7 +4,7 @@ namespace App\Services;
 
 use App\Models\AiModel;
 use App\Http\Resources\AiModelResource;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 
 class AIModelService
 {
@@ -32,7 +32,7 @@ class AIModelService
 
         $sysModels = [];
         foreach ($types as $key => $type) {
-            $sysModels[$type] =  $this->getModelsById(RedisClusters::get('/ai/model/system/' . $type) ?? []);
+            $sysModels[$type] =  $this->getModelsById(Cache::get('/ai/model/system/' . $type) ?? []);
         }
         if (!empty($type)) {
             return $sysModels[$type];

+ 6 - 6
api-v12/app/Services/AiTranslateService.php

@@ -5,7 +5,7 @@ namespace App\Services;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Http;
 use Illuminate\Http\Client\RequestException;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 
 use App\Models\Task;
 use App\Models\PaliText;
@@ -61,12 +61,12 @@ class AiTranslateService
         $first = $messages[0];
         $this->task = $first->task->info;
         $taskId = $this->task->id;
-        RedisClusters::put("/task/{$taskId}/message_id", $messageId);
+        Cache::put("/task/{$taskId}/message_id", $messageId);
         $pointerKey = "/task/{$taskId}/pointer";
         $pointer = 0;
-        if (RedisClusters::has($pointerKey)) {
+        if (Cache::has($pointerKey)) {
             //回到上次中断的点
-            $pointer = RedisClusters::get($pointerKey);
+            $pointer = Cache::get($pointerKey);
             Log::info("last break point {$pointer}");
         }
 
@@ -101,7 +101,7 @@ class AiTranslateService
                 return false;
             }
 
-            RedisClusters::put($pointerKey, $i);
+            Cache::put($pointerKey, $i);
             $message = $messages[$i];
             $taskDiscussionContent = [];
 
@@ -198,7 +198,7 @@ class AiTranslateService
         //任务完成 修改任务状态为 done
         if ($i === count($messages)) {
             $this->setTaskStatus($this->task->id, 'done');
-            RedisClusters::forget($pointerKey);
+            Cache::forget($pointerKey);
             Log::info('ai translate task complete');
         }
 

+ 94 - 84
api-v12/app/Tools/ExportDownload.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace App\Tools;
 
 use Illuminate\Support\Str;
@@ -9,7 +10,7 @@ use Illuminate\Support\Facades\App;
 use Symfony\Component\Process\Process;
 use Symfony\Component\Process\Exception\ProcessFailedException;
 
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 use App\Tools\Export;
 
 class ExportDownload
@@ -19,7 +20,7 @@ class ExportDownload
     protected $currStatusKey = '';
 
     protected $queryId = 'id';
-    protected $realFilename = 'index';//压缩包里的文件名
+    protected $realFilename = 'index'; //压缩包里的文件名
     protected $zipFilename = 'file.zip';
     protected $downloadUrl = null;
 
@@ -33,19 +34,19 @@ class ExportDownload
      *
      * @return void
      */
-    public function __construct($options=[])
+    public function __construct($options = [])
     {
-        if(isset($options['format'])){
+        if (isset($options['format'])) {
             $this->format = $options['format'];
         }
-        if(isset($options['debug'])){
+        if (isset($options['debug'])) {
             $this->debug = $options['debug'];
         }
-        if(isset($options['filename'])){
+        if (isset($options['filename'])) {
             $this->realFilename = $options['filename'];
         }
         $this->queryId = $options['queryId'];
-        $this->zipFilename = $this->queryId.'.zip';
+        $this->zipFilename = $this->queryId . '.zip';
 
         $this->currStatusKey = $this->statusKey . '/' . $this->queryId;
     }
@@ -54,87 +55,96 @@ class ExportDownload
      * progress: 0-1, error -1
      * message: string
      */
-    public function setStatus($progress,$message=''){
+    public function setStatus($progress, $message = '')
+    {
         $this->logs[] = $message;
         $data = [
-                    'progress'=>$progress,
-                    'message'=>$message,
-                    'log'=>$this->logs,
-                    'content-type'=>'application/zip',
-                ];
-        if($this->downloadUrl){
+            'progress' => $progress,
+            'message' => $message,
+            'log' => $this->logs,
+            'content-type' => 'application/zip',
+        ];
+        if ($this->downloadUrl) {
             $data['url'] = $this->downloadUrl;
         }
-        RedisClusters::put($this->currStatusKey,
-                           $data,
-                           $this->statusExpiry);
+        Cache::put(
+            $this->currStatusKey,
+            $data,
+            $this->statusExpiry
+        );
         $percent = (int)($progress * 100);
-        return "[{$percent}%]".$message;
+        return "[{$percent}%]" . $message;
     }
 
 
-    public function getStatus(){
-        return RedisClusters::get($this->currStatusKey);
+    public function getStatus()
+    {
+        return Cache::get($this->currStatusKey);
     }
 
-    public function upload(string $type,$sections,$bookMeta){
+    public function upload(string $type, $sections, $bookMeta)
+    {
         $outputFilename = Str::uuid();
 
-        $m = new \Mustache_Engine(array('entity_flags'=>ENT_QUOTES,
-                    'delimiters' => '[[ ]]',
-                    'escape'=>function ($value){
-                        return $value;
-                    }));
+        $m = new \Mustache_Engine(array(
+            'entity_flags' => ENT_QUOTES,
+            'delimiters' => '[[ ]]',
+            'escape' => function ($value) {
+                return $value;
+            }
+        ));
 
         $tex = array();
 
         $_format = 'md';
-        $tplFile = resource_path("mustache/".$type.'/'.$_format."/main.".$_format);
+        $tplFile = resource_path("mustache/" . $type . '/' . $_format . "/main." . $_format);
         $tpl = file_get_contents($tplFile);
-        $texContent = $m->render($tpl,$bookMeta);
+        $texContent = $m->render($tpl, $bookMeta);
         $tex[] = [
-            'name' => 'main.'.$_format,
+            'name' => 'main.' . $_format,
             'content' => $texContent
-            ];
+        ];
         foreach ($sections as $key => $section) {
-            $tplFile = resource_path("mustache/".$type.'/'.$_format."/section.".$_format);
+            $tplFile = resource_path("mustache/" . $type . '/' . $_format . "/section." . $_format);
             $tpl = file_get_contents($tplFile);
-            $texContent = $m->render($tpl,$section['body']);
+            $texContent = $m->render($tpl, $section['body']);
             $tex[] = [
-                'name'=>$section['name'],
-                'content'=>$texContent
-                ];
+                'name' => $section['name'],
+                'content' => $texContent
+            ];
         }
 
         Log::debug('footnote start');
         //footnote
-        $tplFile = resource_path("mustache/".$_format."/footnote.".$_format);
-        if(isset($GLOBALS['note']) &&
+        $tplFile = resource_path("mustache/" . $_format . "/footnote." . $_format);
+        if (
+            isset($GLOBALS['note']) &&
             is_array($GLOBALS['note']) &&
-            count($GLOBALS['note'])>0 &&
-            file_exists($tplFile)){
+            count($GLOBALS['note']) > 0 &&
+            file_exists($tplFile)
+        ) {
             $tpl = file_get_contents($tplFile);
-            $texContent = $m->render($tpl,['footnote'=>$GLOBALS['note']]);
+            $texContent = $m->render($tpl, ['footnote' => $GLOBALS['note']]);
             $tex[] = [
-                'name'=>'footnote.'.$_format,
-                'content'=>$texContent
-                ];
+                'name' => 'footnote.' . $_format,
+                'content' => $texContent
+            ];
         }
         Log::debug('footnote finished');
 
-        $this->setStatus(0.95,'export content done. tex count='.count($tex));
-        Log::debug('export content done.',['tex_count'=>count($tex)]);
+        $this->setStatus(0.95, 'export content done. tex count=' . count($tex));
+        Log::debug('export content done.', ['tex_count' => count($tex)]);
 
         //upload
         $fileDate = '';
         switch ($this->format) {
             case 'tex':
                 $data = Export::ToPdf($tex);
-                if($data['ok']){
+                if ($data['ok']) {
                     $this->info($data['content-type']);
                     $fileDate = $data['data'];
-                }else{
-                    $this->error($data['code'].'-'.$data['message']);
+                } else {
+                    $this->error($data['code'] . '-' . $data['message']);
                 }
                 break;
             default:
@@ -142,31 +152,31 @@ class ExportDownload
                 foreach ($tex as $key => $section) {
                     $file[] = $section['content'];
                 }
-                $fileDate = implode('',$file);
+                $fileDate = implode('', $file);
                 break;
         }
 
 
-        $dir = "tmp/export/{$type}/".$this->format."/";
-        $mdFilename = $dir.$outputFilename.'.md';
+        $dir = "tmp/export/{$type}/" . $this->format . "/";
+        $mdFilename = $dir . $outputFilename . '.md';
         Storage::disk('local')->put($mdFilename, $fileDate);
-        Log::debug('markdown saved',['filename'=>$mdFilename]);
-        if($this->format === 'markdown'){
+        Log::debug('markdown saved', ['filename' => $mdFilename]);
+        if ($this->format === 'markdown') {
             $filename = $mdFilename;
-        }else{
-            $filename = $dir.$outputFilename.'.'.$this->format;
+        } else {
+            $filename = $dir . $outputFilename . '.' . $this->format;
 
-            Log::debug('tmp saved',['filename'=>$filename]);
+            Log::debug('tmp saved', ['filename' => $filename]);
             $absoluteMdPath = Storage::disk('local')->path($mdFilename);
             $absoluteOutputPath = Storage::disk('local')->path($filename);
             //$command = "pandoc pandoc1.md --reference-doc tpl.docx -o pandoc1.docx";
             $command = ['pandoc', $absoluteMdPath, '-o', $absoluteOutputPath];
-            if($this->format === 'docx'){
-                 $tplFile = resource_path("template/docx/paper.docx");
-                 array_push($command,'--reference-doc');
-                 array_push($command,$tplFile);
+            if ($this->format === 'docx') {
+                $tplFile = resource_path("template/docx/paper.docx");
+                array_push($command, '--reference-doc');
+                array_push($command, $tplFile);
             }
-            Log::debug('pandoc start',['command'=>$command,'format'=>$this->format]);
+            Log::debug('pandoc start', ['command' => $command, 'format' => $this->format]);
             $process = new Process($command);
             $process->run();
 
@@ -175,54 +185,54 @@ class ExportDownload
             }
 
             echo $process->getOutput();
-            Log::debug('pandoc end',['command'=>$command]);
+            Log::debug('pandoc end', ['command' => $command]);
         }
 
         $zipDir = storage_path('app/export/zip');
-        if(!is_dir($zipDir)){
-            $res = mkdir($zipDir,0755,true);
-            if(!$res){
-                Log::error('mkdir fail path='.$zipDir);
+        if (!is_dir($zipDir)) {
+            $res = mkdir($zipDir, 0755, true);
+            if (!$res) {
+                Log::error('mkdir fail path=' . $zipDir);
                 return 1;
             }
         }
 
-        $zipFile = $zipDir.'/'. $outputFilename .'.zip';
+        $zipFile = $zipDir . '/' . $outputFilename . '.zip';
 
-        Log::debug('export chapter start zip  file='.$zipFile);
+        Log::debug('export chapter start zip  file=' . $zipFile);
         //zip压缩包里面的文件名
-        $realFilename = $this->realFilename.".".$this->format;
+        $realFilename = $this->realFilename . "." . $this->format;
         $fileContent = Storage::disk('local')->get($filename);
-        $zipOk = \App\Tools\Tools::zip($zipFile,[$realFilename=>$fileContent]);
-        if(!$zipOk){
-            Log::error('export chapter zip fail zip file='.$zipFile);
-            $this->setStatus(0.99,'export chapter zip fail');
-            $this->error('export chapter zip fail zip file='.$zipFile);
+        $zipOk = \App\Tools\Tools::zip($zipFile, [$realFilename => $fileContent]);
+        if (!$zipOk) {
+            Log::error('export chapter zip fail zip file=' . $zipFile);
+            $this->setStatus(0.99, 'export chapter zip fail');
+            $this->error('export chapter zip fail zip file=' . $zipFile);
             //TODO 给客户端返回错误状态
             return 1;
         }
-        $this->setStatus(0.96,'export chapter zip success');
+        $this->setStatus(0.96, 'export chapter zip success');
 
         $bucket = config('mint.attachments.bucket_name.temporary');
-        $tmpFile =  $bucket.'/'. $this->zipFilename ;
-        Log::debug('upload start filename='.$tmpFile);
-        $this->setStatus(0.97,'upload start ');
+        $tmpFile =  $bucket . '/' . $this->zipFilename;
+        Log::debug('upload start filename=' . $tmpFile);
+        $this->setStatus(0.97, 'upload start ');
         $zipData = file_get_contents($zipFile);
         Storage::put($tmpFile, $zipData);
 
         if (App::environment('local')) {
             $s3Link = Storage::url($tmpFile);
-        }else{
-            try{
+        } else {
+            try {
                 $s3Link = Storage::temporaryUrl($tmpFile, now()->addDays(7));
-            }catch(\Exception $e){
-                Log::error('export {Exception}',['exception'=>$e]);
+            } catch (\Exception $e) {
+                Log::error('export {Exception}', ['exception' => $e]);
                 return false;
             }
         }
         $this->downloadUrl = $s3Link;
-        $this->setStatus(1,'export chapter done');
-        Log::debug('export chapter done, upload',['filename'=>$tmpFile,'url'=>$s3Link] );
+        $this->setStatus(1, 'export chapter done');
+        Log::debug('export chapter done, upload', ['filename' => $tmpFile, 'url' => $s3Link]);
         unlink($zipFile);
         return true;
     }

+ 5 - 5
api-v12/app/Tools/TurboSplit.php

@@ -7,7 +7,7 @@ require_once __DIR__ . '/../../public/app/public/casesuf.inc';
 use Illuminate\Support\Facades\Log;
 use App\Models\WordPart;
 use App\Models\UserDict;
-use App\Tools\RedisClusters;
+use Illuminate\Support\Facades\Cache;
 
 class TurboSplit
 {
@@ -184,7 +184,7 @@ class TurboSplit
         $search = $word;
 
         //获取单词权重
-        $weight = RedisClusters::remember(
+        $weight = Cache::remember(
             'palicanon/wordpart/weight/' . $search,
             config('mint.cache.expire'),
             function () use ($search) {
@@ -216,7 +216,7 @@ class TurboSplit
             $base_weight = 0;
             $len = 0;
             foreach ($newWord as $x => $x_len) {
-                $weight = RedisClusters::remember(
+                $weight = Cache::remember(
                     'palicanon/wordpart/weight/' . $x,
                     config('mint.cache.expire'),
                     function () use ($x) {
@@ -249,7 +249,7 @@ class TurboSplit
 
         $isFound = false;
         $count = 0;
-        $wordPart  = RedisClusters::remember(
+        $wordPart  = Cache::remember(
             "turbosplit/part/{$word}",
             config('mint.cache.expire'),
             function () use ($word) {
@@ -273,7 +273,7 @@ class TurboSplit
 
         //fomular of confidence value 信心值计算公式
         if ($isFound) {
-            $cf  = RedisClusters::remember(
+            $cf  = Cache::remember(
                 "turbosplit/confidence/" . $word,
                 config('mint.cache.expire'),
                 function () use ($word, $count, $case_len) {