作者 lyh

gx

<?php
/**
* @remark :
* @name :BTemplateLabelController.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\Http\Logic\Bside\BTemplate\BTemplateLogic;
use App\Models\Template\BTemplate;
use App\Models\Template\Template;
use App\Models\Template\TemplateLabel;
/**
* @remark :
* @name :BTemplateLabelController
* @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,Template $template){
$data = [];
$this->map['user_id'] = $this->param['id'];
$template_id_arr = $templateLabel->formatQuery($this->map)->pluck('template_id')->toArray();
if(!empty($template_id_arr)){
$filed = ['id','name','image','url','created_at','status','deleted_status'];
$map = ['id'=>['in',$template_id_arr],'deleted_status'=>BTemplate::STATUS,'status'=>BTemplate::STATUS];
$data = $template->list($map,'id',$filed);
foreach ($data as $k => $v){
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$data[$k] = $v;
}
}
$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);
}
}
... ...
<?php
/**
* @remark :
* @name :BTemplateLabelLogic.php
* @author :lyh
* @method :post
* @time :2024/5/16 9:54
*/
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Template\TemplateLabel;
/**
* @remark :模版标签
* @name :BTemplateLabelLogic
* @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(){
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->model->edit($this->param,['id'=>$id]);
}else{
$this->param['user_id'] = $this->user['id'];
$id = $this->model->addReturnId($this->param);
}
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
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();
}
}
... ...
... ... @@ -103,6 +103,7 @@ class RankDataLogic extends BaseLogic
'home_cnt' => $lang_data[$lang['lang']]['home_cnt'] ?? 0,
'remain_day' => ($lang['type']??0) == 1 ? $data['project']['remain_day'] : $lang['service_day'] - $remain_day,
'type' => $lang['type'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数
'dabiao_day'=>$remain_day,
'service_day' => $lang['service_day'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数
];
}
... ...
<?php
/**
* @remark :
* @name :TemplateLabel.php
* @author :lyh
* @method :post
* @time :2024/5/16 9:49
*/
namespace App\Models\Template;
use App\Models\Base;
/**
* @remark :模版标签
* @name :TemplateLabel
* @author :lyh
* @method :post
* @time :2024/5/16 9:49
*/
class TemplateLabel extends Base
{
protected $table = 'gl_public_template_label';
}
... ...