| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?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()
- {
- $data = m("repair_fault")->getall("1=1", "*");
- $this->showreturn($data);
- }
- public function getTypeListAction() {
- $data = m("repair_type")->getall("1=1", "id, name, dept");
- $this->showreturn($data);
- }
- 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']) || empty($arr['type']) || empty($arr['type_id']) ) {
- return returnerror('参数缺失');
- }
- $ipAddr = $_SERVER['REMOTE_ADDR'];
- $where = " site='{$arr['site']}' and ";
- $where .= " reporter='{$arr['reporter']}' and ";
- $where .= " mobile='{$arr['mobile']}' and ";
- $where .= " ip_addr='{$ipAddr}' and ";
- $where .= " type_id='{$arr['type_id']}' ";
- $haveData = m("repair_fault")->getall($where);
- 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");
- }
- }
|