作者 lyh

gx

@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 9
10 namespace App\Console\Commands\TemplateLabel; 10 namespace App\Console\Commands\TemplateLabel;
11 11
  12 +use App\Models\Template\Template;
12 use App\Models\Template\TemplateModule; 13 use App\Models\Template\TemplateModule;
13 use Illuminate\Console\Command; 14 use Illuminate\Console\Command;
14 use App\Models\Template\TemplateLabel as TemplateLabelModel; 15 use App\Models\Template\TemplateLabel as TemplateLabelModel;
@@ -37,24 +38,77 @@ class TemplateLabel extends Command @@ -37,24 +38,77 @@ class TemplateLabel extends Command
37 * @time :2024/6/3 11:35 38 * @time :2024/6/3 11:35
38 */ 39 */
39 public function handle(){ 40 public function handle(){
40 - //清除当前所有最新标签  
41 - $labelModel = new TemplateLabelModel();  
42 - //获取最近5天左侧的记录 41 + //获取最近7天模版的记录
43 $start_time = now()->subDays(7)->startOfDay()->toDateString(); 42 $start_time = now()->subDays(7)->startOfDay()->toDateString();
44 $end_time = now()->startOfDay()->toDateString(); 43 $end_time = now()->startOfDay()->toDateString();
45 - $templateModuleModel = new TemplateModule();  
46 - $moduleInfo = $templateModuleModel->list(['created_at'=>['between',[$start_time,$end_time]],'type'=>1]);  
47 - if($moduleInfo === false){  
48 - return false; 44 + $this->setTemplateModule($start_time,$end_time);
  45 + $this->setTemplate($start_time,$end_time);
  46 + return true;
  47 + }
  48 +
  49 + /**
  50 + * @remark :公共模块
  51 + * @name :setTemplate
  52 + * @author :lyh
  53 + * @method :post
  54 + * @time :2024/6/3 15:56
  55 + */
  56 + public function setTemplate($start_time,$end_time){
  57 + $templateModel = new Template();
  58 + $info = $templateModel->list(['created_at'=>['between',[$start_time,$end_time]],'test_model'=>0],'id',['id']);
  59 + if(empty($info)){
  60 + return true;
49 }else{ 61 }else{
  62 + //清除当前所有最新标签
  63 + $labelModel = new TemplateLabelModel();
  64 + $labelModel->del(['name'=>'最新','type'=>1]);
50 $data = []; 65 $data = [];
51 - foreach ($moduleInfo as $k => $v){ 66 + foreach ($info as $k => $v){
52 $data[] = [ 67 $data[] = [
53 'name'=>'最新', 68 'name'=>'最新',
  69 + 'type'=>1,
  70 + 'template_id'=>$v['id'],
  71 + 'manager_id'=>0,
  72 + 'created_at'=>date('Y-m-d H:i:s'),
  73 + 'updated_at'=>date('Y-m-d H:i:s')
  74 + ];
  75 + }
  76 + //设置为最新
  77 + $labelModel->insert($data);
  78 + }
  79 + return true;
  80 + }
  81 +
  82 + /**
  83 + * @remark :左侧模块
  84 + * @name :templateModule
  85 + * @author :lyh
  86 + * @method :post
  87 + * @time :2024/6/3 15:54
  88 + */
  89 + public function setTemplateModule($start_time,$end_time){
  90 + $templateModuleModel = new TemplateModule();
  91 + $moduleInfo = $templateModuleModel->list(['created_at'=>['between',[$start_time,$end_time]],'test_model'=>0],'id',['id']);
  92 + if(empty($moduleInfo)){
  93 + return true;
  94 + }else{
  95 + //清除当前所有最新标签
  96 + $labelModel = new TemplateLabelModel();
  97 + $labelModel->del(['name'=>'最新','type'=>2]);
  98 + $moduleData = [];
  99 + foreach ($moduleInfo as $k => $v){
  100 + $moduleData[] = [
  101 + 'name'=>'最新',
  102 + 'type'=>2,
  103 + 'template_id'=>$v['id'],
  104 + 'manager_id'=>0,
  105 + 'created_at'=>date('Y-m-d H:i:s'),
  106 + 'updated_at'=>date('Y-m-d H:i:s')
54 ]; 107 ];
55 } 108 }
56 //设置为最新 109 //设置为最新
  110 + $labelModel->insert($moduleData);
57 } 111 }
58 - //清空所有的最近标签 112 + return true;
59 } 113 }
60 } 114 }
@@ -15,6 +15,8 @@ class Kernel extends ConsoleKernel @@ -15,6 +15,8 @@ class Kernel extends ConsoleKernel
15 */ 15 */
16 protected function schedule(Schedule $schedule) 16 protected function schedule(Schedule $schedule)
17 { 17 {
  18 + // 每日更新最新模块
  19 + $schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块
18 // $schedule->command('inspire')->hourly(); 20 // $schedule->command('inspire')->hourly();
19 $schedule->command('remain_day')->dailyAt('09:00')->withoutOverlapping(1); // 项目剩余服务时长 21 $schedule->command('remain_day')->dailyAt('09:00')->withoutOverlapping(1); // 项目剩余服务时长
20 $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务 22 $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务
@@ -24,7 +24,7 @@ use App\Models\Template\TemplateLabel; @@ -24,7 +24,7 @@ use App\Models\Template\TemplateLabel;
24 class BTemplateLabelController extends BaseController 24 class BTemplateLabelController extends BaseController
25 { 25 {
26 /** 26 /**
27 - * @remark :获取左侧模版的标签 27 + * @remark :获取模版的标签
28 * @name :lists 28 * @name :lists
29 * @author :lyh 29 * @author :lyh
30 * @method :post 30 * @method :post
@@ -537,6 +537,11 @@ Route::middleware(['bloginauth'])->group(function () { @@ -537,6 +537,11 @@ Route::middleware(['bloginauth'])->group(function () {
537 Route::prefix('tutorial')->group(function () { 537 Route::prefix('tutorial')->group(function () {
538 Route::any('/', [\App\Http\Controllers\Bside\BCom\TutorialController::class, 'lists'])->name('tutorial_lists'); 538 Route::any('/', [\App\Http\Controllers\Bside\BCom\TutorialController::class, 'lists'])->name('tutorial_lists');
539 }); 539 });
  540 + //oa教程
  541 + Route::prefix('template_label')->group(function () {
  542 + Route::any('/save', [\App\Http\Controllers\Bside\Template\BTemplateLabelController::class, 'save'])->name('template_label_save');
  543 + Route::any('/del', [\App\Http\Controllers\Bside\Template\BTemplateLabelController::class, 'del'])->name('template_label_del');
  544 + });
540 }); 545 });
541 //无需登录验证的路由组 546 //无需登录验证的路由组
542 Route::group([], function () { 547 Route::group([], function () {