request->post(); $token = isset($post['token']) ? trim($post['token']) : ""; // if($token==""){ // return error_show(101,'token不能为空'); // // } // $effetc = VerifyTokens($token); // if(!empty($effetc) && $effetc['code']!=0){ // return error_show($effetc['code'],$effetc['message']); // // } } public function list(){ $post = $this->request->post(); $condition = [['is_del'=>0]]; $page = isset($post['page']) &&$post['page']!=='' ?intval($post['page']) :1; $size = isset($post['size']) &&$post['size']!=='' ?intval($post['size']) :10; $count = Db::name("config")->where($condition)->count(); $page>=ceil($count/$size) ? $page = ceil($count/$size): ''; $list = Db::name("config")->where($condition)->page($page,$size)->order("addtime desc")->select(); return app_show(0,"获取成功",['list'=>$list,"count"=>$count]); } public function info(){ $post = $this->request->post(); $id = isset($post['id']) && $post['id']!==''? intval($post['id']): ''; if($id==''){ return error_show(1004,'参数id 不能为空'); } $condition = [['is_del'=>0],['id'=>$id]]; $info = Db::name("config")->where($condition)->find(); if(empty($info)){ return error_show(1004,'未找到数据'); } return app_show(0,"获取成功",$info); } public function add(){ $post = $this->request->post(); $name = isset($post['name'])&& $post['name']!='' ? trim($post['name']) :""; if($name==""){ return error_show(1004,"参数name 不能为空"); } $ist = Db::name("config")->where(["name"=>$name,"is_del"=>0])->find(); if(!empty($ist)){ return error_show(1004,"配置名称已存在"); } $setv = isset($post['setv'])&& $post['setv']!='' ? trim($post['setv']) :""; if($setv==""){ return error_show(1004,"参数setv 不能为空"); } $start= isset($post['start'])&& $post['start']!='' ? $post['start'] :date("Y-m-d H:i:s"); $end= isset($post['end'])&& $post['end']!='' ? $post['end'] :null; $status= isset($post['status'])&& $post['status']!='' ? intval($post['satus']) :"1"; $data= [ "name"=>$name, "setv"=>$setv, 'status'=>$status, "starttime"=>$start, "endtime"=>$end, "addtime"=>date("Y-m-d H:i:s"), "updatetime"=>date("Y-m-d H:i:s") ]; $iser=Db::name("config")->insert($data); return $iser ? app_show(0,"新建成功"):error_show(1008,"新建失败"); } public function edit(){ $post = $this->request->post(); $id = isset($post['id'])&& $post['id']!='' ? intval($post['id']) :""; if($id==""){ return error_show(1004,"参数id 不能为空"); } $data = Db::name("config")->where(['id'=>$id,"is_del"=>0])->find(); if(empty($data)){ return error_show(1005,"未找到数据"); } $name = isset($post['name'])&& $post['name']!='' ? trim($post['name']) :""; if($name==""){ return error_show(1004,"参数name 不能为空"); } $ist = Db::name("config")->where(["name"=>$name,"is_del"=>0])->find(); if(!empty($ist)&&$ist['id']!=$id){ return error_show(1004,"配置名称已存在"); } $setv = isset($post['setv'])&& $post['setv']!='' ? trim($post['setv']) :""; if($setv==""){ return error_show(1004,"参数setv 不能为空"); } $start= isset($post['start'])&& $post['start']!='' ? $post['start'] :date("Y-m-d H:i:s"); $end= isset($post['end'])&& $post['end']!='' ? $post['end'] :null; $status= isset($post['status'])&& $post['status']!='' ? intval($post['satus']) :"1"; $data= [ "id"=>$id, "name"=>$name, "setv"=>$setv, 'status'=>$status, "starttime"=>$start, "endtime"=>$end, "updatetime"=>date("Y-m-d H:i:s") ]; $iser=Db::name("config")->save($data); return $iser ? app_show(0,"新建成功"):error_show(1008,"新建失败"); } public function delete(){ $post = $this->request->post(); $id = isset($post['id'])&& $post['id']!='' ? intval($post['id']) :""; if($id==""){ return error_show(1004,"参数id 不能为空"); } $data = Db::name("config")->where(['id'=>$id,"is_del"=>0])->find(); if(empty($data)){ return error_show(1005,"未找到数据"); } $data['is_del']=1; $data['updatetime']=date("Y-m-d H:i:s"); $iser=Db::name("config")->save($data); return $iser ? app_show(0,"删除成功"):error_show(1008,"删除失败"); } }