|
...
|
...
|
@@ -108,34 +108,38 @@ class Extension3915ModuleController extends BaseController |
|
|
|
$this->fail('当前项目不能调用当前方法');
|
|
|
|
}
|
|
|
|
$moduleFieldModel = new ExtensionModuleField();
|
|
|
|
$filedList = $moduleFieldModel->where(['module_id' => $this->param['module_id']])->pluck('field_name', 'id')->toArray();
|
|
|
|
$filedList = $moduleFieldModel->where(['module_id' => $this->param['module_id']])->pluck( 'id','field_name')->toArray();
|
|
|
|
if(empty($filedList)){
|
|
|
|
$this->response('请先设置字段,再添加数据',Code::SUCCESS);
|
|
|
|
$this->fail('请先设置字段,再添加数据');
|
|
|
|
}
|
|
|
|
$data = $this->param['data'];
|
|
|
|
$moduleValueModel = new ExtensionModuleValue();
|
|
|
|
$key_filedId = [];
|
|
|
|
$resultData = [];
|
|
|
|
foreach ($data as $k => $v){
|
|
|
|
foreach ($v as $k1 => $v1){
|
|
|
|
if($k == 0){
|
|
|
|
if(isset($filedList[$v1])){
|
|
|
|
$key_filedId[$k1] = $filedList[$v1];
|
|
|
|
try {
|
|
|
|
foreach ($data as $k => $v){
|
|
|
|
foreach ($v as $k1 => $v1){
|
|
|
|
if($k == 0){
|
|
|
|
if(isset($filedList[$v1])){
|
|
|
|
$key_filedId[$k1] = $filedList[$v1];
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
$resultData[] = [
|
|
|
|
'uuid'=>$k + 1,
|
|
|
|
'module_id'=>$this->param['module_id'],
|
|
|
|
'field_id'=>$key_filedId[$k1],
|
|
|
|
'value'=>$v1 ?? '',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
$resultData[] = [
|
|
|
|
'uuid'=>$k + 1,
|
|
|
|
'module_id'=>$this->param['module_id'],
|
|
|
|
'field_id'=>$key_filedId[$k1],
|
|
|
|
'value'=>$v1 ?? '',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!empty($resultData)){
|
|
|
|
//todo::优先截断表
|
|
|
|
$moduleValueModel->truncate();
|
|
|
|
$moduleValueModel->insertAll($resultData);
|
|
|
|
if(!empty($resultData)){
|
|
|
|
//todo::优先截断表
|
|
|
|
$moduleValueModel->truncate();
|
|
|
|
$moduleValueModel->insertAll($resultData);
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('当前文件不能导入,请修改后再导入');
|
|
|
|
}
|
|
|
|
$this->response('success',Code::SUCCESS,$resultData);
|
|
|
|
}
|
...
|
...
|
|