|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :ExtensionModuleController.php
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/8/7 16:15
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Bside\ExtensionModule;
|
|
|
|
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Http\Controllers\Bside\BaseController;
|
|
|
|
use App\Http\Logic\Bside\ExtensionModule\ExtensionModuleFieldLogic;
|
|
|
|
use App\Models\ExtentModule\ExtensionModule;
|
|
|
|
use App\Models\ExtentModule\ExtensionModuleField;
|
|
|
|
use App\Models\ExtentModule\ExtensionModuleValue;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
class ExtensionModuleController extends BaseController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @remark :获取扩展数据模块
|
|
|
|
* @name :getModuleList
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/8/7 16:16
|
|
|
|
*/
|
|
|
|
public function getModuleList(){
|
|
|
|
$moduleModel = new ExtensionModule();
|
|
|
|
$this->map['status'] = 0;
|
|
|
|
$list = $moduleModel->list($this->map);
|
|
|
|
$this->response('success',Code::SUCCESS,$list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取数据类型
|
|
|
|
* @name :getDataType
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/8/7 17:31
|
|
|
|
*/
|
|
|
|
public function getDataType(){
|
|
|
|
$data = [
|
|
|
|
'1'=>'文本框',
|
|
|
|
'2'=>'多文本输入框',
|
|
|
|
'3'=>'图片框',
|
|
|
|
'4'=>'文件框',
|
|
|
|
'5'=>'下拉框',
|
|
|
|
'6'=>'自动生成订单框'
|
|
|
|
];
|
|
|
|
$this->response('success',Code::SUCCESS,$data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取当前模块字段
|
|
|
|
* @name :getModuleFiledInfo
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/8/7 16:20
|
|
|
|
*/
|
|
|
|
public function getModuleFiledInfo(){
|
|
|
|
$this->request->validate([
|
|
|
|
'module_id'=>'required',
|
|
|
|
],[
|
|
|
|
'module_id.required' => '模块id不能为空',
|
|
|
|
]);
|
|
|
|
$moduleFieldModel = new ExtensionModuleField();
|
|
|
|
$list = $moduleFieldModel->list(['module_id'=>$this->param['module_id']]);
|
|
|
|
$this->response('success',Code::SUCCESS,$list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :添加字段
|
|
|
|
* @name :saveModuleField
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/8/7 16:27
|
|
|
|
*/
|
|
|
|
public function saveModuleField(ExtensionModuleFieldLogic $logic){
|
|
|
|
$this->request->validate([
|
|
|
|
'module_id'=>'required',
|
|
|
|
'field_name'=>'required',
|
|
|
|
'data_type'=>'required',
|
|
|
|
'is_required'=>'required',
|
|
|
|
],[
|
|
|
|
'module_id.required' => '模块id不能为空',
|
|
|
|
'field_name.required' => '字段名称不能为空',
|
|
|
|
'data_type.required' => '数据类型不能为空',
|
|
|
|
'is_required.required' => '是否必填不能为空',
|
|
|
|
]);
|
|
|
|
$data = $logic->saveModuleField();
|
|
|
|
$this->response('success',Code::SUCCESS,$data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :删除字段
|
|
|
|
* @name :delModuleField
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/8/7 17:10
|
|
|
|
*/
|
|
|
|
public function delModuleField(ExtensionModuleFieldLogic $logic){
|
|
|
|
$this->request->validate([
|
|
|
|
'field_id'=>'required',
|
|
|
|
],[
|
|
|
|
'field_id.required' => '字段id不能为空',
|
|
|
|
]);
|
|
|
|
$logic->delModuleField();
|
|
|
|
$this->response('success');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取当前模块的所有数据
|
|
|
|
* @name :getModuleValueList
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/8/7 17:37
|
|
|
|
*/
|
|
|
|
public function getModuleValueList(){
|
|
|
|
$this->request->validate([
|
|
|
|
'module_id'=>'required',
|
|
|
|
],[
|
|
|
|
'module_id.required' => '模块id不能为空',
|
|
|
|
]);
|
|
|
|
$data = [];
|
|
|
|
$moduleValueModel = new ExtensionModuleValue();
|
|
|
|
$lists = $moduleValueModel->list(['module_id'=>$this->param['module_id']]);
|
|
|
|
if(!empty($lists)){
|
|
|
|
foreach ($lists as $k => $v){
|
|
|
|
$data[$v['uuid']][$v['field_id']] = $v['value'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->response('success',Code::SUCCESS,$data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存数据
|
|
|
|
* @name :saveModuleValue
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/8/7 17:59
|
|
|
|
*/
|
|
|
|
public function editModuleValue(){
|
|
|
|
$this->request->validate([
|
|
|
|
'module_id'=>'required',
|
|
|
|
],[
|
|
|
|
'module_id.required' => '模块id不能为空',
|
|
|
|
]);
|
|
|
|
$data = $this->param['data'];
|
|
|
|
$moduleValueModel = new ExtensionModuleValue();
|
|
|
|
foreach ($data as $k => $v){
|
|
|
|
$info = $moduleValueModel->read(['uuid'=>$this->param['uuid'],'field_id'=>$v['field_id'],'module_id'=>$this->param['module_id']]);
|
|
|
|
if($info === false){
|
|
|
|
$data = [
|
|
|
|
'uuid'=>$this->param['uuid'],
|
|
|
|
'module_id'=>$this->param['module_id'],
|
|
|
|
'field_id'=>$v['field_id'],
|
|
|
|
'value'=>$v['value']
|
|
|
|
];
|
|
|
|
$moduleValueModel->addReturnId($data);
|
|
|
|
}else{
|
|
|
|
$moduleValueModel->edit(['value'=>$v['value']],['id'=>$info['id']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->response('success',Code::SUCCESS,['uuid'=>$this->param['uuid']]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :新增數據
|
|
|
|
* @name :addModuleValue
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/8/8 10:00
|
|
|
|
*/
|
|
|
|
public function addModuleValue(){
|
|
|
|
$this->request->validate([
|
|
|
|
'module_id'=>'required',
|
|
|
|
],[
|
|
|
|
'module_id.required' => '模块id不能为空',
|
|
|
|
]);
|
|
|
|
$moduleValueModel = new ExtensionModuleValue();
|
|
|
|
$info = $moduleValueModel->where('module_id',$this->param['module_id'])->orderBy('uuid','desc')->first()->toArray();
|
|
|
|
if(empty($info)){
|
|
|
|
$uuid = 1;
|
|
|
|
}else{
|
|
|
|
$uuid = $info['uuid'] + 1;
|
|
|
|
}
|
|
|
|
$data = $this->param['data'];
|
|
|
|
$moduleValueModel = new ExtensionModuleValue();
|
|
|
|
foreach ($data as $k => $v){
|
|
|
|
$data = [
|
|
|
|
'uuid'=>$uuid,
|
|
|
|
'module_id'=>$this->param['module_id'],
|
|
|
|
'field_id'=>$v['field_id'],
|
|
|
|
'value'=>$v['value']
|
|
|
|
];
|
|
|
|
$moduleValueModel->addReturnId($data);
|
|
|
|
}
|
|
|
|
$this->response('success',Code::SUCCESS,['uuid'=>$this->param['uuid']]);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|