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"); } }