作者 lyh

gx

@@ -144,12 +144,18 @@ class OnlineController extends BaseController @@ -144,12 +144,18 @@ class OnlineController extends BaseController
144 */ 144 */
145 public function setQuestion(){ 145 public function setQuestion(){
146 $this->request->validate([ 146 $this->request->validate([
147 - 'id'=>'required', 147 + 'project_id'=>'required',
148 ],[ 148 ],[
149 - 'id.required' => 'ID不能为空', 149 + 'project_id.required' => 'ID不能为空',
150 ]); 150 ]);
151 $onlineCheckModel = new OnlineCheck(); 151 $onlineCheckModel = new OnlineCheck();
152 - $rs = $onlineCheckModel->edit($this->param,['id'=>$this->param['id']]); 152 + $info = $onlineCheckModel->read(['project_id'=>$this->param['project_id']]);
  153 + if($info === false){
  154 + $this->param['created_manage_id'] = $this->manager['id'];
  155 + $rs = $this->model->add($this->param);
  156 + }else{
  157 + $rs = $onlineCheckModel->edit($this->param,['id'=>$this->param['id']]);
  158 + }
153 if($rs === false){ 159 if($rs === false){
154 $this->response('error',Code::USER_ERROR); 160 $this->response('error',Code::USER_ERROR);
155 } 161 }