作者 王智

1111

@@ -187,12 +187,19 @@ class Config extends Api @@ -187,12 +187,19 @@ class Config extends Api
187 { 187 {
188 $UserId = $this->IsToken($this->request->header()); 188 $UserId = $this->IsToken($this->request->header());
189 $Params = $this->request->param(); 189 $Params = $this->request->param();
190 - $data = [  
191 - 'user_id' => $UserId,  
192 - 'ob_id' => $Params['ob_id'],  
193 - 'createtime' => time()  
194 - ];  
195 - $Res = Db::name('for_ob')->insert($data); 190 + $IsFor = Db::name('for_ob')->where('user_id', $UserId)->where('ob_id', $Params['ob_id'])->find();
  191 + if (empty($IsFor)) {
  192 + $data = [
  193 + 'user_id' => $UserId,
  194 + 'ob_id' => $Params['ob_id'],
  195 + 'createtime' => time()
  196 + ];
  197 + $Res = Db::name('for_ob')->insert($data);
  198 + } else {
  199 + $Res = Db::name('for_ob')->where('id', $IsFor['id'])->update([
  200 + 'createtime' => time()
  201 + ]);
  202 + }
196 $this->Res($Res); 203 $this->Res($Res);
197 } 204 }
198 205