作者 lyh

gx

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :BTemplateLabelController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/16 9:51
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Template;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\BTemplate\BTemplateLabelLogic;
  15 +use App\Http\Logic\Bside\BTemplate\BTemplateLogic;
  16 +use App\Models\Template\BTemplate;
  17 +use App\Models\Template\Template;
  18 +use App\Models\Template\TemplateLabel;
  19 +
  20 +/**
  21 + * @remark :
  22 + * @name :BTemplateLabelController
  23 + * @author :lyh
  24 + * @method :post
  25 + * @time :2024/5/16 9:51
  26 + */
  27 +class BTemplateLabelController extends BaseController
  28 +{
  29 + /**
  30 + * @remark :根据用户获取模版
  31 + * @name :lists
  32 + * @author :lyh
  33 + * @method :post
  34 + * @time :2024/5/16 10:15
  35 + */
  36 + public function getUserLists(TemplateLabel $templateLabel,Template $template){
  37 + $data = [];
  38 + $this->map['user_id'] = $this->param['id'];
  39 + $template_id_arr = $templateLabel->formatQuery($this->map)->pluck('template_id')->toArray();
  40 + if(!empty($template_id_arr)){
  41 + $filed = ['id','name','image','url','created_at','status','deleted_status'];
  42 + $map = ['id'=>['in',$template_id_arr],'deleted_status'=>BTemplate::STATUS,'status'=>BTemplate::STATUS];
  43 + $data = $template->list($map,'id',$filed);
  44 + foreach ($data as $k => $v){
  45 + $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
  46 + $data[$k] = $v;
  47 + }
  48 + }
  49 + $this->response('success',Code::SUCCESS,$data);
  50 + }
  51 +
  52 + /**
  53 + * @remark :保存标签
  54 + * @name :save
  55 + * @author :lyh
  56 + * @method :post
  57 + * @time :2024/5/16 9:53
  58 + */
  59 + public function save(BTemplateLabelLogic $labelLogic){
  60 + $this->request->validate([
  61 + 'name'=>'required | max:200',
  62 + 'type'=>'required',
  63 + 'template_id'=>'required',
  64 + ],[
  65 + 'name.required' => '标签名称不能为空',
  66 + 'type.required' => '模版类型不能为空不能为空',
  67 + 'template_id.required' => '模版ID不能为空不能为空',
  68 + ]);
  69 + $data = $labelLogic->saveLabel();
  70 + $this->response('success',Code::SUCCESS,$data);
  71 + }
  72 +
  73 + /**
  74 + * @remark :删除数据
  75 + * @name :del
  76 + * @author :lyh
  77 + * @method :post
  78 + * @time :2024/5/16 10:08
  79 + */
  80 + public function del(BTemplateLabelLogic $labelLogic){
  81 + $this->request->validate([
  82 + 'id'=>'required',
  83 + ],[
  84 + 'id.required' => '主键不能为空',
  85 + ]);
  86 + $data = $labelLogic->delLabel();
  87 + $this->response('success',Code::SUCCESS,$data);
  88 + }
  89 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :BTemplateLabelLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/16 9:54
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\BTemplate;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\Template\TemplateLabel;
  14 +
  15 +/**
  16 + * @remark :模版标签
  17 + * @name :BTemplateLabelLogic
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2024/5/16 9:54
  21 + */
  22 +class BTemplateLabelLogic extends BaseLogic
  23 +{
  24 + /**
  25 + * 初始化数据
  26 + */
  27 + public function __construct()
  28 + {
  29 + parent::__construct();
  30 + $this->model = new TemplateLabel();
  31 + $this->param = $this->requestAll;
  32 + }
  33 +
  34 +
  35 + /**
  36 + * @remark :保存标签
  37 + * @name :saveLabel
  38 + * @author :lyh
  39 + * @method :post
  40 + * @time :2024/5/16 9:55
  41 + */
  42 + public function saveLabel(){
  43 + try {
  44 + if(isset($this->param['id']) && !empty($this->param['id'])){
  45 + $id = $this->param['id'];
  46 + $this->model->edit($this->param,['id'=>$id]);
  47 + }else{
  48 + $this->param['user_id'] = $this->user['id'];
  49 + $id = $this->model->addReturnId($this->param);
  50 + }
  51 + }catch (\Exception $e){
  52 + $this->fail('保存失败,请联系管理员');
  53 + }
  54 + return $this->success(['id'=>$id]);
  55 + }
  56 +
  57 + /**
  58 + * @remark :删除标签
  59 + * @name :delLabel
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2024/5/16 10:03
  63 + */
  64 + public function delLabel(){
  65 + $rs = $this->model->del($this->param);
  66 + if($rs === false){
  67 + $this->fail('删除失败,请联系管理员');
  68 + }
  69 + return $this->success();
  70 + }
  71 +}
@@ -103,6 +103,7 @@ class RankDataLogic extends BaseLogic @@ -103,6 +103,7 @@ class RankDataLogic extends BaseLogic
103 'home_cnt' => $lang_data[$lang['lang']]['home_cnt'] ?? 0, 103 'home_cnt' => $lang_data[$lang['lang']]['home_cnt'] ?? 0,
104 'remain_day' => ($lang['type']??0) == 1 ? $data['project']['remain_day'] : $lang['service_day'] - $remain_day, 104 'remain_day' => ($lang['type']??0) == 1 ? $data['project']['remain_day'] : $lang['service_day'] - $remain_day,
105 'type' => $lang['type'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数 105 'type' => $lang['type'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数
  106 + 'dabiao_day'=>$remain_day,
106 'service_day' => $lang['service_day'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数 107 'service_day' => $lang['service_day'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数
107 ]; 108 ];
108 } 109 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TemplateLabel.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/16 9:49
  8 + */
  9 +
  10 +namespace App\Models\Template;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :模版标签
  16 + * @name :TemplateLabel
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2024/5/16 9:49
  20 + */
  21 +class TemplateLabel extends Base
  22 +{
  23 + protected $table = 'gl_public_template_label';
  24 +}