作者 lyh

gx

<?php
/**
* @remark :
* @name :ExtendController.php
* @author :lyh
* @method :post
* @time :2023/11/9 14:22
*/
namespace App\Http\Controllers\Bside\Product;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Product\ExtendLogic;
use App\Models\Product\Extend;
/**
* @remark :添加扩展字段
* @name :ExtendController
* @author :lyh
* @method :post
* @time :2023/11/9 14:22
*/
class ExtendController extends BaseController
{
/**
* @remark :获取所有扩展字段
* @name :lists
* @author :lyh
* @method :post
* @time :2023/11/9 14:23
*/
public function lists(Extend $extend){
$lists = $extend->list($this->map);
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2023/11/9 14:26
*/
public function save(ExtendLogic $extendLogic){
$this->request->validate([
'title'=>'required',
'type'=>'required',
],[
'title.required' => '字段名称不能为空',
'type.required' => '字段类型不能为空',
]);
$extendLogic->extendSave();
$this->response('success');
}
}
... ...
<?php
/**
* @remark :
* @name :ExtendLogic.php
* @author :lyh
* @method :post
* @time :2023/11/9 14:24
*/
namespace App\Http\Logic\Bside\Product;
use App\Helper\Translate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Product\Extend;
class ExtendLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new Extend();
}
/**
* @remark :保存数据
* @name :extendSave
* @author :lyh
* @method :post
* @time :2023/11/9 14:29
*/
public function extendSave(){
$this->param['key'] = Translate::tran($this->param['title'], 'en');
if(isset($this->param['id']) && !empty($this->param['id'])){
}else{
}
}
}
... ...
... ... @@ -105,7 +105,7 @@ class KeywordLogic extends BaseLogic
* @time :2023/8/28 14:03
*/
public function batchAdd(){
try {
// try {
$idArr = [];
foreach ($this->param['title'] as $v){
$this->model = new Keyword();
... ... @@ -125,9 +125,9 @@ class KeywordLogic extends BaseLogic
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$v['id']]);
}
}catch (\Exception $e){
$this->fail('error');
}
// }catch (\Exception $e){
// $this->fail('error');
// }
return $this->success();
}
... ...
<?php
/**
* @remark :
* @name :Extend.php
* @author :lyh
* @method :post
* @time :2023/11/9 14:18
*/
namespace App\Models\Product;
use App\Models\Base;
class Extend extends Base
{
//设置关联表名
protected $table = 'gl_product_extend';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
<?php
/**
* @remark :
* @name :ExtendInfo.php
* @author :lyh
* @method :post
* @time :2023/11/9 14:19
*/
namespace App\Models\Product;
use App\Models\Base;
class ExtendInfo extends Base
{
//设置关联表名
protected $table = 'gl_product_extend_info';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...