visuddhinanda 2 лет назад
Родитель
Сommit
a572462dce

+ 1 - 1
app/Console/Commands/MqDiscussion.php

@@ -68,7 +68,7 @@ class MqDiscussion extends Command
                     $msgParam = array();
                     $msgParam['anchor-content'] = $contentTxt;
                     $msgParam['nickname'] = $message->editor->nickName;
-                    $link = env('APP_URL')."/pcd/discussion/topic/";
+                    $link = config('app.url')."/pcd/discussion/topic/";
                     if($message->parent){
                         $msgParam['topic-title'] = Discussion::where('id',$message->parent)->value('title');
                         $id = $message->id;

+ 1 - 1
app/Console/Commands/MqPr.php

@@ -57,7 +57,7 @@ class MqPr extends Command
                                 ->value('text');
             $prtext = mb_substr($message->content,0,140,"UTF-8");
             $sent_num = "{$message->book}-{$message->paragraph}-{$message->word_start}-{$message->word_end}";
-            $link = env('APP_URL')."/pcd/article/para/{$message->book}-{$message->paragraph}";
+            $link = config('app.url')."/pcd/article/para/{$message->book}-{$message->paragraph}";
             $link .= "?book={$message->book}&par={$message->paragraph}&channel={$message->channel->id}";
 
             $msgContent = "{$username} 就文句`{$palitext}`提出了修改建议:\n";

+ 5 - 5
app/Console/Commands/TestMqWorker.php

@@ -43,11 +43,11 @@ class TestMqWorker extends Command
         $queue = 'hello';
         $consumerTag = 'consumer';
 
-        $connection = new AMQPStreamConnection(env("RABBITMQ_HOST"),
-                                               env("RABBITMQ_PORT"),
-                                               env("RABBITMQ_USER"),
-                                               env("RABBITMQ_PASSWORD"),
-                                               env("RABBITMQ_VIRTUAL_HOST"));
+        $connection = new AMQPStreamConnection(config("rabbitmq.host"),
+                                            config("rabbitmq.port"),
+                                            config("rabbitmq.user"),
+                                            config("rabbitmq.password"),
+                                            config("rabbitmq.virtual.host"));
         $channel = $connection->channel();
 
         /*

+ 27 - 4
app/Console/Commands/TestRedis.php

@@ -5,6 +5,7 @@ namespace App\Console\Commands;
 use Illuminate\Console\Command;
 use Illuminate\Support\Facades\Redis;
 use Illuminate\Support\Facades\Cache;
+use App\Tools\RedisClusters;
 
 class TestRedis extends Command
 {
@@ -45,10 +46,21 @@ class TestRedis extends Command
             return 'remember ok';
         });
         $this->info("test store remember value=".$remember);
-		Redis::set("test-redis",$value);
-		if(Redis::get("test-redis",function(){
-            return 'aa';
-        })==$value){
+
+        $key = "test-redis";
+		Redis::set($key,$value);
+        if(Redis::exists($key)){
+            $this->info("has key ".$key);
+        }else{
+            $this->error("no key ".$key);
+        }
+        $expire = Redis::expire($key,10);
+        $this->info("key expire ".$expire);
+        $this->info('del key '.Redis::del($key));
+        $getValue = Redis::get($key,function(){
+            return 'this is a test';
+        });
+		if($getValue === $value){
 			$this->info("redis set ok ");
 		}else{
 			$this->error("redis set fail ");
@@ -103,6 +115,17 @@ class TestRedis extends Command
 		}else{
 			$this->error("cache::remember() fail.");
 		}
+
+        $key = 'cache-key-clusters';
+		$this->info("testing RedisClusters remember()");
+		$value = RedisClusters::remember($key,600,function(){
+			return 'cache-key-clusters';
+		});
+		if(RedisClusters::has($key)){
+			$this->info("{$key} exist value=".RedisClusters::get($key));
+		}else{
+			$this->error("cache::remember() fail.");
+		}
         return 0;
     }
 }

+ 1 - 1
app/Console/Commands/UpgradeDict.php

@@ -129,7 +129,7 @@ class UpgradeDict extends Command
 														if(isset($newPart[$part])){
 															$newPart[$part][0]++;
 														}else{
-															$partExists = Cache::remember('dict/part/'.$part,env('CACHE_EXPIRE',1000),function() use($part){
+															$partExists = Cache::remember('dict/part/'.$part,config('cache.expire',1000),function() use($part){
 																return UserDict::where('word',$part)->exists();
 															});
 															if(!$partExists){

+ 11 - 11
app/Console/Commands/WebHookArticleNew.php

@@ -39,7 +39,7 @@ class WebHookArticleNew extends Command
     public function handle()
     {
 		# 获取最新文章数据
-		$url = env('APP_URL',"http://127.0.0.1:8000")."/api/v2/progress?view=chapter&channel_type=translation";
+		$url = config('app.url',"http://127.0.0.1:8000")."/api/v2/progress?view=chapter&channel_type=translation";
 
 		$response = Http::get($url);
 		if($response->successful()){
@@ -47,7 +47,7 @@ class WebHookArticleNew extends Command
 			$data = $response['data']['rows'];
 			$title = "2022-7-3更新";
 			$message = "# wikipali:最新更新\n\n";
-			for ($i=0; $i < 4; $i++) { 
+			for ($i=0; $i < 4; $i++) {
 				# code...
 				$row = $data[$i];
 				$book = $row['book'];
@@ -58,11 +58,11 @@ class WebHookArticleNew extends Command
 				}else{
 					$title = $row['toc'];
 				}
-                
-				$link = env('APP_URL',"http://127.0.0.1:8000")."/app/article/index.php?view=chapter&book={$book}&par={$para}&channel={$channel_id}";
-				$message .= "1. [{$title}]({$link})\n";				
+
+				$link = config('app.url',"http://127.0.0.1:8000")."/app/article/index.php?view=chapter&book={$book}&par={$para}&channel={$channel_id}";
+				$message .= "1. [{$title}]({$link})\n";
 			}
-			$link = env('APP_URL',"http://127.0.0.1:8000")."/app/palicanon";
+			$link = config('app.url',"http://127.0.0.1:8000")."/app/palicanon";
 			$message .= "\n [更多]({$link})";
 			$this->info($message);
 			$url = $this->argument('host');
@@ -70,9 +70,9 @@ class WebHookArticleNew extends Command
 				case "dingtalk":
 					$param = [
 						"markdown"=> [
-							"title"=> $title, 
-							"text"=> $message, 
-						], 
+							"title"=> $title,
+							"text"=> $message,
+						],
 						"msgtype"=>"markdown"
 						];
 					break;
@@ -80,8 +80,8 @@ class WebHookArticleNew extends Command
 					$param = [
 						"msgtype"=>"markdown",
 						"markdown"=> [
-							"content"=> $message, 
-						], 
+							"content"=> $message,
+						],
 						];
 					break;
 			}

+ 1 - 1
app/Http/Api/AuthApi.php

@@ -15,7 +15,7 @@ class AuthApi{
                 if($token === "null"){
                     return false;
                 }
-                $jwt = JWT::decode($token,new Key(env('APP_KEY'),'HS512'));
+                $jwt = JWT::decode($token,new Key(config('app.key'),'HS512'));
                 if($jwt->exp < time()){
                     //过期
                     return false;

+ 10 - 10
app/Http/Api/Mq.php

@@ -10,11 +10,11 @@ class Mq{
                 //一对一
 
         try{
-            $host = env("RABBITMQ_HOST");
-            $port = env("RABBITMQ_PORT");
-            $user = env("RABBITMQ_USER");
-            $password = env("RABBITMQ_PASSWORD");
-            $vhost = env("RABBITMQ_VIRTUAL_HOST");
+            $host = config("rabbitmq.host");
+            $port = config("rabbitmq.port");
+            $user = config("rabbitmq.user");
+            $password = config("rabbitmq.password");
+            $vhost = config("rabbitmq.virtual.host");
             if(empty($host) || empty($port) || empty($user) || empty($password) || empty($vhost)){
                 return;
             }
@@ -43,11 +43,11 @@ class Mq{
 
         $consumerTag = 'consumer';
 
-        $connection = new AMQPStreamConnection(env("RABBITMQ_HOST"),
-                                               env("RABBITMQ_PORT"),
-                                               env("RABBITMQ_USER"),
-                                               env("RABBITMQ_PASSWORD"),
-                                               env("RABBITMQ_VIRTUAL_HOST"));
+        $connection = new AMQPStreamConnection(config("rabbitmq.host"),
+                                        config("rabbitmq.port"),
+                                        config("rabbitmq.user"),
+                                        config("rabbitmq.password"),
+                                        config("rabbitmq.virtual.host"));
         $channel = $connection->channel();
 
  /*

+ 1 - 1
app/Http/Api/TemplateRender.php

@@ -402,7 +402,7 @@ class TemplateRender{
         $paraId = $this->get_param($this->param,"para",1);
         $channelId = $this->channel_id[0];
         $props = Cache::remember("/quote/{$channelId}/{$paraId}",
-              env('CACHE_EXPIRE',3600*24),
+              config('cache.expire',3600*24),
               function() use($paraId,$channelId){
                 $para = \explode('-',$paraId);
                 $output = [

+ 1 - 1
app/Http/Controllers/AuthController.php

@@ -79,7 +79,7 @@ class AuthController extends Controller
         $user = $query->first();
         if($user){
             $ExpTime = time() + 60 * 60 * 24 * 365;
-            $key = env('APP_KEY');
+            $key = config('app.key');
             $payload = [
                 'nbf' => time(),
                 'exp' => $ExpTime,

+ 4 - 4
app/Http/Controllers/CorpusController.php

@@ -664,7 +664,7 @@ class CorpusController extends Controller
                             break;
                         case 'nissaya':
                             $newSent['html'] = Cache::remember("/sent/{$channelId}/{$currSentId}",
-                                                env('CACHE_EXPIRE',3600*24),
+                                                config('cache.expire',3600*24),
                                                 function() use($row,$mode){
                                                     return MdRender::render($row->content,[$row->channel_uid],null,$mode,"nissaya",$row->content_type);
                                                 });
@@ -676,7 +676,7 @@ class CorpusController extends Controller
                          */
                             if(strpos($row->content,'[[')===false){
                                 $newSent['html'] = Cache::remember("/sent/{$channelId}/{$currSentId}",
-                                                env('CACHE_EXPIRE',3600*24),
+                                                    config('cache.expire',3600*24),
                                                 function() use($row){
                                                     return MdRender::render($row->content,[$row->channel_uid]);
                                                 });
@@ -913,7 +913,7 @@ class CorpusController extends Controller
         }else{
             $key .= 'guest';
         }
-		$channelCount = Cache::remember($key,env('CACHE_EXPIRE',3600*24),
+		$channelCount = Cache::remember($key,config('cache.expire',3600*24),
                           function() use($book,$para,$start,$end,$userUuid){
                             $keyCanRead="/channel/can-read/";
                             if($userUuid){
@@ -922,7 +922,7 @@ class CorpusController extends Controller
                                 $keyCanRead .= 'guest';
                             }
                             $channelCanRead = Cache::remember($keyCanRead,
-                                                            env('CACHE_EXPIRE',3600*24),
+                                                config('cache.expire',3600*24),
                                                 function() use($userUuid){
                                                     return ChannelApi::getCanReadByUser($userUuid);
                                                 });

+ 1 - 1
app/Http/Controllers/DhammaTermController.php

@@ -160,7 +160,7 @@ class DhammaTermController extends Controller
                     }
                     Cache::put($key, $hotMeaning, 3600);
                     return $hotMeaning;
-                }, env('CACHE_EXPIRE',3600*24));
+                }, config('cache.expire',3600*24));
                 return $this->ok(["rows"=>$value,"count"=>count($value)]);
                 break;
 			default:

+ 1 - 1
app/Http/Controllers/DictController.php

@@ -45,7 +45,7 @@ class DictController extends Controller
         }else{
             $inMyHanGroup = false;
         }
-        if(env('APP_ENV')==='local'){
+        if(config('app.env')==='local'){
             $inMyHanGroup = true;
         }
         $resultCount=0;

+ 3 - 3
app/Http/Controllers/NissayaCardController.php

@@ -93,7 +93,7 @@ class NissayaCardController extends Controller
                     $localCase  =[];
                     foreach ($cases as $case) {
                         $localCase[] = ['label'=>__("grammar.".$case),
-                                        'link'=>env('DASHBOARD_URL').'/term/list/'.$case
+                                        'link'=>config('dashboard.url').'/term/list/'.$case
                                         ];
                     }
                     # 格位
@@ -108,7 +108,7 @@ class NissayaCardController extends Controller
                     $localTo  =[];
                     foreach ($linkTos->case as $to) {
                         $localTo[] = ['label'=>__("grammar.".$to),
-                                        'link'=>env('DASHBOARD_URL').'/term/list/'.$to
+                                        'link'=>config('dashboard.url').'/term/list/'.$to
                                         ];
                     }
 
@@ -157,7 +157,7 @@ class NissayaCardController extends Controller
                 }
                 //关系名称
                 $newLine['relation'] =  $relation['name'];
-                $newLine['relation_link'] =  env('DASHBOARD_URL').'/term/list/'.$relation['name'];
+                $newLine['relation_link'] =  config('dashboard.url').'/term/list/'.$relation['name'];
                 $cardData['row'][] = $newLine;
             }
         }

+ 3 - 3
app/Http/Controllers/NissayaEndingController.php

@@ -166,7 +166,7 @@ class NissayaEndingController extends Controller
                     $localCase  =[];
                     foreach ($cases as $case) {
                         $localCase[] = ['label'=>__("grammar.".$case),
-                                        'link'=>env('DASHBOARD_URL').'/term/list/'.$case
+                                        'link'=>config('dashboard.url').'/term/list/'.$case
                                         ];
                     }
                     # 格位
@@ -181,7 +181,7 @@ class NissayaEndingController extends Controller
                     $localTo  =[];
                     foreach ($linkTos as $to) {
                         $localTo[] = ['label'=>__("grammar.".$to),
-                                        'link'=>env('DASHBOARD_URL').'/term/list/'.$case
+                                        'link'=>config('dashboard.url').'/term/list/'.$case
                                         ];
                     }
                     # 格位
@@ -219,7 +219,7 @@ class NissayaEndingController extends Controller
                 }
                 //关系名称
                 $newLine['relation'] =  $relation['name'];
-                $newLine['relation_link'] =  env('DASHBOARD_URL').'/term/list/'.$relation['name'];
+                $newLine['relation_link'] =  config('dashboard.url').'/term/list/'.$relation['name'];
                 $cardData['row'][] = $newLine;
             }
         }

+ 1 - 1
app/Http/Controllers/ProgressImgController.php

@@ -55,7 +55,7 @@ class ProgressImgController extends Controller
                     $svg .= '<polyline points="0,0 1,0" /></svg>';
                 }
                 return $svg;
-            } , env('CACHE_EXPIRE',3600*24) );
+            } , config('cache.expire',3600*24) );
             echo $svg;
         }, 200, ['Content-Type' => 'image/svg+xml']);
     /*

+ 1 - 1
app/Http/Controllers/RelationController.php

@@ -62,7 +62,7 @@ class RelationController extends Controller
 
         if($request->has('vocabulary')){
             if(!Cache::has($key)){
-                Cache::put($key,$output,env('CACHE_EXPIRE',3600*24));
+                Cache::put($key,$output,config('cache.expire',3600*24));
             }
         }
         return $this->ok($output);

+ 1 - 1
app/Http/Controllers/SentenceInfoController.php

@@ -129,7 +129,7 @@ class SentenceInfoController extends Controller
                 # code...
 				$key_sent_id = $sent->book_id.'-'.$sent->paragraph.'-'.$sent->word_start.'-'.$sent->word_end;
 				$para_strlen += Cache::remember('pali-sent/strlen/'.$key_sent_id,
-                                    env('CACHE_EXPIRE',3600*24*30) ,
+                                    config('cache.expire',3600*24*30) ,
                                     function() use($sent) {
                                         return PaliSentence::where('book',$sent->book_id)
                                                 ->where('paragraph',$sent->paragraph)

+ 1 - 1
app/Http/Controllers/UserStatisticController.php

@@ -57,7 +57,7 @@ class UserStatisticController extends Controller
         //
         $queryUserId = UserApi::getIntIdByName($userName);
         $queryUserUuid = UserApi::getIdByName($userName);
-        $cacheExpiry = env('CACHE_EXPIRE',3600*24);
+        $cacheExpiry = config('cache.expire',3600*24);
         //总经验值
         $expSum = Cache::remember("user/{$userName}/exp/sum",$cacheExpiry,function() use($queryUserId){
 			return UserOperationDaily::where('user_id',$queryUserId)

+ 1 - 1
app/Http/Controllers/VocabularyController.php

@@ -22,7 +22,7 @@ class VocabularyController extends Controller
             case 'key':
                 $key = $request->get("key");
                 $result = Cache::remember("/dict_vocabulary/{$key}",
-                        env('CACHE_EXPIRE',3600*24),
+                        config('cache.expire',3600*24),
                         function() use($key){
                         return Vocabulary::whereRaw('word like ? or word_en like ?',[$key."%",$key."%"])
                                     ->whereOr('word_en','like',$key."%")

+ 1 - 1
app/Http/Resources/SearchResource.php

@@ -34,7 +34,7 @@ class SearchResource extends JsonResource
         }else if(isset($this->content)){
             $data["content"] = $this->content;
         }else{
-            $channelId = Cache::remember('_System_Pali_VRI_',env('CACHE_EXPIRE',3600*24),function(){
+            $channelId = Cache::remember('_System_Pali_VRI_',config('cache.expire',3600*24),function(){
                 return ChannelApi::getSysChannel('_System_Pali_VRI_');
             });
 

+ 1 - 1
app/Mail/InviteMail.php

@@ -35,7 +35,7 @@ class InviteMail extends Mailable
     {
         return $this->view('emails.invite.'.$this->lang)
                     ->with([
-                        'url' => env('DASHBOARD_URL').'/anonymous/users/sign-up/'.$this->uuid,
+                        'url' => config('dashboard.url').'/anonymous/users/sign-up/'.$this->uuid,
                     ]);
     }
 }

+ 1 - 1
app/Providers/AppServiceProvider.php

@@ -22,7 +22,7 @@ class AppServiceProvider extends ServiceProvider
         //雪花算法
 
 		$this->app->singleton('snowflake', function () {
-            return (new Snowflake(env('SNOWFLAKE_DATA_CENTER_ID'),env('SNOWFLAKE_WORKER_ID')))
+            return (new Snowflake(config('snowflake.data.center.id'),config('snowflake.worker.id')))
                 ->setStartTimeStamp(strtotime(config('database.snowflake.start'))*1000)
                 ->setSequenceResolver(
                     new LaravelSequenceResolver($this->app->get('cache')->store()

+ 1 - 1
app/Tools/Export.php

@@ -17,7 +17,7 @@ class Export
             //Log::info($value['name']);
             //Log::info($value['content']);
         }
-        $host = env('LILY_RPC_SERVER');
+        $host = config('lily.rpc.server');
         $client = new \Palm\Lily\V1\TexClient($host, [
             'credentials' => \Grpc\ChannelCredentials::createInsecure(),
         ]);

+ 1 - 1
app/Tools/Markdown.php

@@ -10,7 +10,7 @@ class Markdown
     }
 
     public static function morus($text){
-        $host = env('MORUS_RPC_SERVER');
+        $host = config('morus.rpc.server');
         $client = new \Mint\Morus\V1\MarkdownClient($host, [
             'credentials' => \Grpc\ChannelCredentials::createInsecure(),
         ]);

+ 4 - 4
app/Tools/TurboSplit.php

@@ -179,7 +179,7 @@ class TurboSplit
 
 		//获取单词权重
 		$row = Cache::remember('palicanon/wordpart/weight/'.$search,
-                env('CACHE_EXPIRE',3600*24) ,
+                config('cache.expire',3600*24) ,
                 function() use($search) {
                     return WordPart::where('word',$search)->value('weight');
                 });
@@ -208,7 +208,7 @@ class TurboSplit
 			$len = 0;
 			foreach ($newWord as $x => $x_value) {
 				$row = Cache::remember('palicanon/wordpart/weight/'.$search,
-                        env('CACHE_EXPIRE',3600*24) ,
+                        config('cache.expire',3600*24) ,
                         function() use($x) {
                             return WordPart::where('word',$x)->value('weight');
                         });
@@ -238,7 +238,7 @@ class TurboSplit
 		$isFound = false;
 		$count = 0;
 		$wordPart  = Cache::remember("turbosplit/part/{$word}",
-                        env('CACHE_EXPIRE',3600*24),
+                        config('cache.expire',3600*24),
                         function() use($word){
                             return implode(',',$this->dict_lookup($word));
                         });
@@ -254,7 +254,7 @@ class TurboSplit
 		//fomular of confidence value 信心值计算公式
 		if ($isFound) {
 			$cf  = Cache::remember("turbosplit/confidence/".$word,
-                    env('CACHE_EXPIRE',1000),
+                    config('cache.expire',1000),
                     function() use($word,$count,$case_len){
                         $len = mb_strlen($word, "UTF-8") - $case_len;
                         $len_correct = 1.2;