作者 Your Name
<?php
/**
* @remark :
* @name :TemplateLabel.php
* @author :lyh
* @method :post
* @time :2024/6/3 11:33
*/
namespace App\Console\Commands\TemplateLabel;
use Illuminate\Console\Command;
use App\Models\Template\TemplateLabel as TemplateLabelModel;
class TemplateLabel extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'template_label';
/**
* The console command description.
*
* @var string
*/
protected $description = '设置label';
/**
* @remark :执行脚本
* @name :handle
* @author :lyh
* @method :post
* @time :2024/6/3 11:35
*/
public function handle(){
//清除当前所有最新标签
$labelModel = new TemplateLabelModel();
//获取最近5天左侧的记录
$start_time = now()->subDays(7)->startOfDay()->toDateString();
$end_time = now()->startOfDay()->toDateString();
$info = $labelModel->read(['created_at'=>['between',[$start_time,$end_time]]]);
if($info === false){
return false;
}
//清空所有的最近标签
}
}
... ...
... ... @@ -50,7 +50,7 @@ class UpdateProductCategory extends Command
public function handle(){
//获取所有项目
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[621]]],'id',['id']);
$list = $projectModel->list(['id'=>['in',[1077]]],'id',['id']);
echo date('Y-m-d H:i:s') . ' start: ' . json_encode($list) . PHP_EOL;
try {
foreach ($list as $v) {
... ...
... ... @@ -25,17 +25,14 @@ class ATemplateController extends BaseController
* @method :post
* @time :2023/6/28 16:34
*/
public function lists(ATemplateLogic $aTemplateLogic,TemplateLabel $templateLabel){
if(isset($this->map['label_name']) && !empty($this->map['label_name'])){
$id_arr = $templateLabel->formatQuery(['name'=>['like','%'.$this->map['label_name'].'%']])->pluck('template_id')->toArray();
$this->map['id'] = ['in',$id_arr];
unset($this->map['label_name']);
}
public function lists(ATemplateLogic $aTemplateLogic){
$templateLabel = new TemplateLabel();
$this->searchLabelName($templateLabel);
$filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id'];
$lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['label'] = $templateLabel->list(['template_id'=>$v['id']],'id',['id','name'],'desc',5);
$v['label'] = $templateLabel->list(['template_id'=>$v['id'],'type'=>1],'id',['id','name'],'desc',5);
$v['image_link'] = getImageUrl($v['image']);
$lists['list'][$k] = $v;
}
... ... @@ -44,6 +41,22 @@ class ATemplateController extends BaseController
}
/**
* @remark :搜索label
* @name :searchLabelName
* @author :lyh
* @method :post
* @time :2024/6/3 11:11
*/
public function searchLabelName($templateLabel){
if(isset($this->map['label_name']) && !empty($this->map['label_name'])){
$id_arr = $templateLabel->formatQuery(['name'=>['like','%'.$this->map['label_name'].'%'],'type'=>1])->pluck('template_id')->toArray();
$this->map['id'] = ['in',$id_arr];
unset($this->map['label_name']);
}
return true;
}
/**
* @remark :获取选择的模版
* @name :getTemplateInfo
* @author :lyh
... ...
... ... @@ -8,6 +8,8 @@ use App\Http\Logic\Aside\Template\ATemplateLogic;
use App\Http\Logic\Aside\Template\ATemplateModuleLogic;
use App\Http\Requests\Aside\Template\ATemplateModuleRequest;
use App\Models\Project\Project;
use App\Models\Template\TemplateLabel;
use App\Models\Template\TemplateModule;
/**
* @remark :左侧模块管理
... ... @@ -24,12 +26,38 @@ class ATemplateModuleController extends BaseController
* @method :post
* @time :2023/6/28 16:54
*/
public function lists(ATemplateModuleLogic $ATemplateModuleLogic){
$lists = $ATemplateModuleLogic->aTemplateModuleLists($this->map,$this->page,$this->row,$this->order);
public function lists(TemplateModule $templateModule){
$templateLabel = new TemplateLabel();
$this->map['deleted_status'] = 0;
$this->searchLabelName($templateLabel);
$lists = $templateModule->lists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['label'] = $templateLabel->list(['template_id'=>$v['id'],'type'=>2],'id',['id','name'],'desc',5);
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :搜索label
* @name :searchLabelName
* @author :lyh
* @method :post
* @time :2024/6/3 11:11
*/
public function searchLabelName($templateLabel){
if(isset($this->map['label_name']) && !empty($this->map['label_name'])){
$id_arr = $templateLabel->formatQuery(['name'=>['like','%'.$this->map['label_name'].'%'],'type'=>2])->pluck('template_id')->toArray();
$this->map['id'] = ['in',$id_arr];
unset($this->map['label_name']);
}
return true;
}
/**
* @remark :左侧模块保存
* @name :save
* @author :lyh
... ...
... ... @@ -34,8 +34,10 @@ class TemplateLabelController extends BaseController
public function getUserLists(TemplateLabel $templateLabel){
$this->request->validate([
'template_id'=>'required',
'type'=>'required',
],[
'template_id.required' => '模版id不能为空',
'type.required' => '模版类型不能为空不能为空',
]);
$data = $templateLabel->list($this->map);
$this->response('success',Code::SUCCESS,$data);
... ...
<?php
/**
* @remark :
* @name :TemplateLabelController.php
* @author :lyh
* @method :post
* @time :2024/5/16 9:51
*/
namespace App\Http\Controllers\Bside\Template;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\BTemplateLabelLogic;
use App\Models\Template\TemplateLabel;
/**
* @remark :
* @name :TemplateLabelController
* @author :lyh
* @method :post
* @time :2024/5/16 9:51
*/
class BTemplateLabelController extends BaseController
{
/**
* @remark :获取左侧模版的标签
* @name :lists
* @author :lyh
* @method :post
* @time :2024/5/16 10:15
*/
public function getUserLists(TemplateLabel $templateLabel){
$this->request->validate([
'template_id'=>'required',
'type'=>'required',
],[
'template_id.required' => '模版id不能为空',
'type.required' => '模版类型不能为空不能为空',
]);
$data = $templateLabel->list($this->map);
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存标签
* @name :save
* @author :lyh
* @method :post
* @time :2024/5/16 9:53
*/
public function save(BTemplateLabelLogic $labelLogic){
$this->request->validate([
'name'=>'required | max:200',
'type'=>'required',
'template_id'=>'required',
],[
'name.required' => '标签名称不能为空',
'type.required' => '模版类型不能为空不能为空',
'template_id.required' => '模版ID不能为空不能为空',
]);
$data = $labelLogic->saveLabel();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :删除数据
* @name :del
* @author :lyh
* @method :post
* @time :2024/5/16 10:08
*/
public function del(BTemplateLabelLogic $labelLogic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => '主键不能为空',
]);
$data = $labelLogic->delLabel();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -22,19 +22,6 @@ class ATemplateModuleLogic extends BaseLogic
}
/**
* @remark :左侧模块列表
* @name :aTemplateModuleLists
* @author :lyh
* @method :post
* @time :2023/6/28 18:01
*/
public function aTemplateModuleLists($map,$page,$row,$order = 'created_at',$filed = ['*']){
$map['deleted_status'] = 0;
$lists = $this->model->lists($map,$page,$row,$order,$filed);
return $this->success($lists);
}
/**
* @remark :保存左侧模块
* @name :aTemplateModuleSave
* @author :lyh
... ...
<?php
/**
* @remark :
* @name :TemplateLabelLogic.php
* @author :lyh
* @method :post
* @time :2024/5/16 9:54
*/
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Template\TemplateLabel;
/**
* @remark :模版标签
* @name :TemplateLabelLogic
* @author :lyh
* @method :post
* @time :2024/5/16 9:54
*/
class BTemplateLabelLogic extends BaseLogic
{
/**
* 初始化数据
*/
public function __construct()
{
parent::__construct();
$this->model = new TemplateLabel();
$this->param = $this->requestAll;
}
/**
* @remark :保存标签
* @name :saveLabel
* @author :lyh
* @method :post
* @time :2024/5/16 9:55
*/
public function saveLabel(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$info = $this->model->read(['name'=>$this->param['name'],'template_id'=>$this->param['template_id'],'id'=>['!=',$id]],['id']);
if($info === false){
$this->model->edit($this->param,['id'=>$id]);
}
}else{
$info = $this->model->read(['name'=>$this->param['name'],'template_id'=>$this->param['template_id']],['id']);
if($info === false){
$this->param['manager_id'] = $this->manager['id'];
$id = $this->model->addReturnId($this->param);
}else{
$id = $info['id'];
}
}
return $this->success(['id'=>$id]);
}
/**
* @remark :删除标签
* @name :delLabel
* @author :lyh
* @method :post
* @time :2024/5/16 10:03
*/
public function delLabel(){
$rs = $this->model->del($this->param);
if($rs === false){
$this->fail('删除失败,请联系管理员');
}
return $this->success();
}
}
... ...
... ... @@ -14,6 +14,7 @@ class Notify extends Base
const STATUS_FINISH_ROUTE = 1;
const STATUS_FINISH_PAGE = 2;
const STATUS_FINISH_SITEMAP = 3;
const STATUS_ERROR = 9;
/**
* 类型 1:主站, 2:小语种, 3:amp
... ... @@ -78,6 +79,7 @@ class Notify extends Base
self::STATUS_FINISH_ROUTE => '页面生成中',
self::STATUS_FINISH_PAGE => 'sitemap生成中',
self::STATUS_FINISH_SITEMAP => '完成',
self::STATUS_ERROR => 'sitemap生成失败',
];
}
}
... ...