openRepairFaultAction.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * 会议相关
  4. * 请求地址如:http://oa.test/api.php?m=openRepairFault&a=test&openkey=fee5efd3a93ca5c6a85b679cde60faa2
  5. * 请求地址如:http://oa.test/api.php?m=openRepairFault&a=test&openkey=d9302364e2a2d9fdcab2707a46fbab5a
  6. */
  7. class openRepairFaultClassAction extends openapiAction
  8. {
  9. public function testAction() {
  10. $str = $this->postdata;
  11. return json_encode($str);
  12. }
  13. public function getListAction()
  14. {
  15. return m("repair_fault")->getall("1=1", "*");
  16. }
  17. public function addAction()
  18. {
  19. $arr = $this->postdata;
  20. if(empty($arr))return returnerror('not data');
  21. $arr = json_decode($this->postdata, true);
  22. if (empty($arr['site']) || empty($arr['reporter']) || empty($arr['mobile'])) {
  23. return returnerror('参数缺失');
  24. }
  25. $ipAddr = $_SERVER['REMOTE_ADDR'];
  26. $haveData = m("repair_fault")->getall("site='{$arr['site']}' and reporter='{$arr['reporter']}' and mobile = '{$arr['mobile']}' and ip_addr = '{$ipAddr}'");
  27. if (!empty($haveData)) {
  28. return returnerror('请勿重复添加');
  29. }
  30. $arr['pic'] = implode(',', $arr['pic']);
  31. $arr['comid'] = 1;
  32. $arr['uid'] = 1;
  33. $arr['optid'] = 1;
  34. $arr['optname'] = "管理员";
  35. $arr['optdt'] = date("Y-m-d H:i:s", time());
  36. $arr['ip_addr']=$ipAddr;
  37. // 插入数据
  38. m("repair_fault")->insert($arr);
  39. // 更新图片信息
  40. m('file')->update(["mknum"=>"repair_fault", "optid"=>1, "optname"=>"管理员"], "id in ({$arr['pic']})");
  41. $this->showreturn([],"success");
  42. }
  43. }