openRepairFaultAction.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. $data = m("repair_fault")->getall("1=1", "*");
  16. $this->showreturn($data);
  17. }
  18. public function getTypeListAction() {
  19. $data = m("repair_type")->getall("1=1", "id, name, dept");
  20. $this->showreturn($data);
  21. }
  22. public function addAction()
  23. {
  24. $arr = $this->postdata;
  25. if(empty($arr))return returnerror('not data');
  26. $arr = json_decode($this->postdata, true);
  27. if (empty($arr['site']) || empty($arr['reporter']) || empty($arr['mobile']) || empty($arr['type']) || empty($arr['type_id']) ) {
  28. return returnerror('参数缺失');
  29. }
  30. $ipAddr = $_SERVER['REMOTE_ADDR'];
  31. $where = " site='{$arr['site']}' and ";
  32. $where .= " reporter='{$arr['reporter']}' and ";
  33. $where .= " mobile='{$arr['mobile']}' and ";
  34. $where .= " ip_addr='{$ipAddr}' and ";
  35. $where .= " type_id='{$arr['type_id']}' ";
  36. $haveData = m("repair_fault")->getall($where);
  37. if (!empty($haveData)) {
  38. return returnerror('请勿重复添加');
  39. }
  40. $arr['pic'] = implode(',', $arr['pic']);
  41. $arr['comid'] = 1;
  42. $arr['uid'] = 1;
  43. $arr['optid'] = 1;
  44. $arr['optname'] = "管理员";
  45. $arr['optdt'] = date("Y-m-d H:i:s", time());
  46. $arr['ip_addr']=$ipAddr;
  47. // 插入数据
  48. m("repair_fault")->insert($arr);
  49. // 更新图片信息
  50. m('file')->update(["mknum"=>"repair_fault", "optid"=>1, "optname"=>"管理员"], "id in ({$arr['pic']})");
  51. $this->showreturn([],"success");
  52. }
  53. }