| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- /**
- * 会议相关
- * 请求地址如:http://oa.test/api.php?m=openRepairFault&a=test&openkey=fee5efd3a93ca5c6a85b679cde60faa2
- * 请求地址如:http://oa.test/api.php?m=openRepairFault&a=test&openkey=d9302364e2a2d9fdcab2707a46fbab5a
- */
- class openRepairFaultClassAction extends openapiAction
- {
- public function testAction() {
- $str = $this->postdata;
- return json_encode($str);
- }
- public function getListAction()
- {
- return m("repair_fault")->getall("1=1", "*");
- }
- public function addAction()
- {
- $arr = $this->postdata;
- if(empty($arr))return returnerror('not data');
- $arr = json_decode($this->postdata, true);
- if (empty($arr['site']) || empty($arr['reporter']) || empty($arr['mobile'])) {
- return returnerror('参数缺失');
- }
- $ipAddr = $_SERVER['REMOTE_ADDR'];
- $haveData = m("repair_fault")->getall("site='{$arr['site']}' and reporter='{$arr['reporter']}' and mobile = '{$arr['mobile']}' and ip_addr = '{$ipAddr}'");
- if (!empty($haveData)) {
- return returnerror('请勿重复添加');
- }
- $arr['pic'] = implode(',', $arr['pic']);
- $arr['comid'] = 1;
- $arr['uid'] = 1;
- $arr['optid'] = 1;
- $arr['optname'] = "管理员";
- $arr['optdt'] = date("Y-m-d H:i:s", time());
- $arr['ip_addr']=$ipAddr;
- // 插入数据
- m("repair_fault")->insert($arr);
- // 更新图片信息
- m('file')->update(["mknum"=>"repair_fault", "optid"=>1, "optname"=>"管理员"], "id in ({$arr['pic']})");
- $this->showreturn([],"success");
- }
- }
|