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']); } $where=['type'=>0]; $page = isset($post['page']) ? intval($post['page']): 1; $size = isset($post['size']) ? intval($post['size']):10; $count =Db::name("exec")->where($where)->count(); $total = ceil($count/$size)>1 ? ceil($count/$size) : 1; $page = $page>=$total?intval($total):$page; $list = Db::name("exec")->where($where)->page($page,$size)->select(); return app_show(0,"获取成功",["list"=>$list,"count"=>$count]); } public function nowlist(){ $post = 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']); } $where=['type'=>1]; $page = isset($post['page']) ? intval($post['page']): 1; $size = isset($post['size']) ? intval($post['size']):10; $count =Db::name("exec")->where($where)->count(); $total = ceil($count/$size)>1 ? ceil($count/$size) : 1; $page = $page>=$total?intval($total):$page; $list = Db::name("exec")->where($where)->page($page,$size)->select(); return app_show(0,"获取成功",["list"=>$list,"count"=>$count]); } public function save(){ $post = 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']); } $userinfo = GetUserInfo($token); if(!isset($userinfo['code'])|| $userinfo['code']!=0){ return error_show(101,'未能获取用户信息'); } $start = isset($post['start']) && $post['start'] != "" ? $post['start']." 00:00:00" : ''; $end = isset($post['end']) && $post['end'] != "" ? $post['end']." 23:59:59" : ''; $id = isset($post['id'])&&$post['id']!=='' ? intval($post['id']) :""; if($id==""){ return error_show(1004,"参数id不能为空"); } $info=Db::name("exec")->where(["id"=>$id])->find(); if(empty($info)){ return error_show(1004,"未找到下载数据"); } if( $info['start'] == $start &&$info['end'] == $end){ return error_show(1004,"数据已提交"); } if($start!=""){ $info['start'] = $start; } if($end!=""){ $info['end'] = $end; } if(is_file(root_path() . 'public'.$info['down_url'])){ @unlink(root_path()."public".$info['down_url']); } $info['status']=1; $info['apply_id']=$userinfo['data']['id']; $info['apply_name']=$userinfo['data']['nickname']; $info['down_url']=''; $info['remark']=''; $info['updatetime'] = date("Y-m-d H:i:s"); $info['addtime'] = date("Y-m-d H:i:s"); $info['expiretime'] = date("Y-m-d H:i:s",time()+7*24*3600); $up = Db::name("exec")->save($info); $redis = Cache::store("redis"); $isPushed = $redis->handler()->lPush($info['type']==1? "nowreport":"execreport", json_encode($info)); return $up? app_show(0,"编辑成功"):error_show(1004,"编辑失败"); } public function down(){ $post = request()->post(); $token = isset($post['token']) ? trim($post['token']) : ""; if($token==""){ return error_show(101,'token不能为空'); } $id = isset($post['id'])&&$post['id']!=='' ? intval($post['id']) :""; if($id==""){ return error_show(1004,"参数id不能为空"); } $info=Db::name("exec")->where(["id"=>$id])->find(); if(empty($info)){ return error_show(1004,"未找到下载数据"); } $effetc = VerifyTokens($token); if(!empty($effetc) && $effetc['code']!=0){ return error_show($effetc['code'],$effetc['message']); } $userinfo = GetUserInfo($token); if(!isset($userinfo['code'])|| $userinfo['code']!=0){ return error_show(101,'未能获取用户信息'); } $info['status']=1; $info['down_url']=''; $info['remark']=''; $info['apply_id']=$userinfo['data']['id']; $info['apply_name']=$userinfo['data']['nickname']; $info['expiretime'] = date("Y-m-d H:i:s",time()+7*24*3600); $info['updatetime'] = date("Y-m-d H:i:s"); $info['addtime'] = date("Y-m-d H:i:s"); $up = Db::name("exec")->save($info); $redis = Cache::store("redis"); $isPushed = $redis->handler()->lPush($info['type']==1? "nowreport":"execreport", json_encode($info)); return $up? app_show(0,"编辑成功"):error_show(1004,"编辑失败"); } }