|
@@ -27,6 +27,15 @@ class Wind extends CatchController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 列表
|
|
|
+ * @time 2022年04月27日 10:49
|
|
|
+ * @param Request $request
|
|
|
+ */
|
|
|
+ public function getWindList(Request $request) : \think\Response
|
|
|
+ {
|
|
|
+ return CatchResponse::success($this->windModel->getWindList());
|
|
|
+ }
|
|
|
+ /**
|
|
|
* 保存信息
|
|
|
* @time 2022年04月27日 10:49
|
|
|
* @param Request $request
|
|
@@ -77,28 +86,19 @@ class Wind extends CatchController
|
|
|
{
|
|
|
$post = $request->post();
|
|
|
|
|
|
- if (!isset($post['name']) || !$post['name']) {
|
|
|
- return CatchResponse::fail('风场名称不能为空');
|
|
|
- }
|
|
|
- if (!isset($post['wind_shape']) || !$post['wind_shape']) {
|
|
|
- return CatchResponse::fail('获取风场类型失败');
|
|
|
- }
|
|
|
- if (!isset($post['wind_info']) || !is_array($post['wind_info'])) {
|
|
|
- return CatchResponse::fail('获取风场坐标数据失败');
|
|
|
- }
|
|
|
- if (!isset($post['department_id']) || !$post['department_id']) {
|
|
|
- return CatchResponse::fail('获取风场所属部门失败');
|
|
|
- }
|
|
|
- // 检测名称重复
|
|
|
- $n_id = $this->windModel->where('name',$post['name'])->value('id');
|
|
|
- if($n_id && $n_id != $id){
|
|
|
- return CatchResponse::fail('风场名称已存在');
|
|
|
- }
|
|
|
- $post['wind_info'] = json_encode($post['wind_info']);
|
|
|
- if(isset($post['department_id']) && is_array($post['department_id'])){
|
|
|
+ if(isset($post['name'])){
|
|
|
+ // 检测名称重复
|
|
|
+ $n_id = $this->windModel->where('name',$post['name'])->value('id');
|
|
|
+ if($n_id && ($n_id != $id)){
|
|
|
+ return CatchResponse::fail('风场名称已存在');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(isset($post['department_id']) && is_array($post['department_id'])){
|
|
|
$post['department_id'] = array_pop($post['department_id']);
|
|
|
}
|
|
|
- return CatchResponse::success($this->windModel->updateBy($id, $post));
|
|
|
+ $post['wind_info'] = json_encode($post['wind_info']);
|
|
|
+
|
|
|
+ return CatchResponse::success($this->windModel->updateBy($id, $post));
|
|
|
}
|
|
|
|
|
|
/**
|