作者 lyh

变更数据

@@ -89,24 +89,27 @@ class TicketUploadDataController extends BaseController @@ -89,24 +89,27 @@ class TicketUploadDataController extends BaseController
89 'type.required' => '上传类型不能为空', 89 'type.required' => '上传类型不能为空',
90 'text' => '数据详情不为空' 90 'text' => '数据详情不为空'
91 ]); 91 ]);
  92 + //验证当前数据是否已提交
  93 + $this->param['text'] = json_encode($this->param['text'], true);
92 if(isset($this->param['id']) && !empty($this->param['id'])){ 94 if(isset($this->param['id']) && !empty($this->param['id'])){
93 //执行编辑 95 //执行编辑
94 $info = $this->model->read(['id'=>$this->param['id']]); 96 $info = $this->model->read(['id'=>$this->param['id']]);
95 - if($this->param['status'] == 0){  
96 - $this->model->edit($this->param,['id'=>$id]); 97 + if($info['status'] == 0){
  98 + $this->model->edit($this->param,['id'=>$this->param['id']]);
  99 + }else{
  100 + $this->response('当前状态不允许编辑', Code::SYSTEM_ERROR);
97 } 101 }
  102 + $this->response('success');
  103 + }else{
  104 + $info = $this->model->read(['project_id' => $this->param['project_id'], 'type' => $this->param['type'], 'text' => $this->param['text'], 'status' => 0]);
  105 + if ($info === false) {
  106 + $id = $this->model->addReturnId($this->param);
  107 + } else {
  108 + $id = $info['id'];
  109 + }
  110 + $data = ['id' => $id];
98 $this->response('success', Code::SUCCESS, $data); 111 $this->response('success', Code::SUCCESS, $data);
99 } 112 }
100 - //验证当前数据是否已提交  
101 - $this->param['text'] = json_encode($this->param['text'], true);  
102 - $info = $this->model->read(['project_id' => $this->param['project_id'], 'type' => $this->param['type'], 'text' => $this->param['text'], 'status' => 0]);  
103 - if ($info === false) {  
104 - $id = $this->model->addReturnId($this->param);  
105 - } else {  
106 - $id = $info['id'];  
107 - }  
108 - $data = ['id' => $id];  
109 - $this->response('success', Code::SUCCESS, $data);  
110 } 113 }
111 114
112 /** 115 /**