作者 lyh

gx

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtendController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/9 14:22
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Product;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\Product\ExtendLogic;
  15 +use App\Models\Product\Extend;
  16 +
  17 +/**
  18 + * @remark :添加扩展字段
  19 + * @name :ExtendController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2023/11/9 14:22
  23 + */
  24 +class ExtendController extends BaseController
  25 +{
  26 + /**
  27 + * @remark :获取所有扩展字段
  28 + * @name :lists
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2023/11/9 14:23
  32 + */
  33 + public function lists(Extend $extend){
  34 + $lists = $extend->list($this->map);
  35 + $this->response('success',Code::SUCCESS,$lists);
  36 + }
  37 +
  38 + /**
  39 + * @remark :保存数据
  40 + * @name :save
  41 + * @author :lyh
  42 + * @method :post
  43 + * @time :2023/11/9 14:26
  44 + */
  45 + public function save(ExtendLogic $extendLogic){
  46 + $this->request->validate([
  47 + 'title'=>'required',
  48 + 'type'=>'required',
  49 + ],[
  50 + 'title.required' => '字段名称不能为空',
  51 + 'type.required' => '字段类型不能为空',
  52 + ]);
  53 + $extendLogic->extendSave();
  54 + $this->response('success');
  55 + }
  56 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtendLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/9 14:24
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\Product;
  11 +
  12 +use App\Helper\Translate;
  13 +use App\Http\Logic\Bside\BaseLogic;
  14 +use App\Models\Product\Extend;
  15 +
  16 +class ExtendLogic extends BaseLogic
  17 +{
  18 + public function __construct()
  19 + {
  20 + parent::__construct();
  21 + $this->param = $this->requestAll;
  22 + $this->model = new Extend();
  23 + }
  24 +
  25 + /**
  26 + * @remark :保存数据
  27 + * @name :extendSave
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2023/11/9 14:29
  31 + */
  32 + public function extendSave(){
  33 + $this->param['key'] = Translate::tran($this->param['title'], 'en');
  34 + if(isset($this->param['id']) && !empty($this->param['id'])){
  35 +
  36 + }else{
  37 +
  38 + }
  39 +
  40 + }
  41 +}
@@ -105,7 +105,7 @@ class KeywordLogic extends BaseLogic @@ -105,7 +105,7 @@ class KeywordLogic extends BaseLogic
105 * @time :2023/8/28 14:03 105 * @time :2023/8/28 14:03
106 */ 106 */
107 public function batchAdd(){ 107 public function batchAdd(){
108 - try { 108 +// try {
109 $idArr = []; 109 $idArr = [];
110 foreach ($this->param['title'] as $v){ 110 foreach ($this->param['title'] as $v){
111 $this->model = new Keyword(); 111 $this->model = new Keyword();
@@ -125,9 +125,9 @@ class KeywordLogic extends BaseLogic @@ -125,9 +125,9 @@ class KeywordLogic extends BaseLogic
125 $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']); 125 $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']);
126 $this->model->edit(['route'=>$route],['id'=>$v['id']]); 126 $this->model->edit(['route'=>$route],['id'=>$v['id']]);
127 } 127 }
128 - }catch (\Exception $e){  
129 - $this->fail('error');  
130 - } 128 +// }catch (\Exception $e){
  129 +// $this->fail('error');
  130 +// }
131 return $this->success(); 131 return $this->success();
132 } 132 }
133 133
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Extend.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/9 14:18
  8 + */
  9 +
  10 +namespace App\Models\Product;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class Extend extends Base
  15 +{
  16 + //设置关联表名
  17 + protected $table = 'gl_product_extend';
  18 + //连接数据库
  19 + protected $connection = 'custom_mysql';
  20 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtendInfo.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/9 14:19
  8 + */
  9 +
  10 +namespace App\Models\Product;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class ExtendInfo extends Base
  15 +{
  16 + //设置关联表名
  17 + protected $table = 'gl_product_extend_info';
  18 + //连接数据库
  19 + protected $connection = 'custom_mysql';
  20 +}