request->only(["module"=>"","system"=>"","sys_type"=>"","version"=>"","page"=>1,"size"=>15], "post","trim"); $where=[]; if($param['module']!='') $where[]=["module","like","%{$param['module']}%"]; if($param['system']!='') $where[]=["system","like","%{$param['system']}%"]; if($param['sys_type']!='') $where[]=["sys_type","=",$param['sys_type']]; if($param['version']!='') $where[]=["version","like","%{$param['version']}%"]; $count= Db::name("system_version")->where($where)->count(); $total=ceil($count/$param['size']); $page = $total>=$param['page']? intval($param['page']): intval($total); $list = Db::name("system_version")->where($where)->page($page,intval($param['size']))->order("id desc") ->select(); return app_show(0,"获取成功",["list"=>$list,'count'=>$count]); } /** * 显示创建资源表单页. * * @return \think\Response */ public function create() { $param =$this->request->only(["module"=>"","system"=>"","sys_type"=>"","version"=>"",'addtime'],"post","trim"); $valid= Validate::rule([ "module|标题"=>"require|max:255|min:4", "system|内容"=>"require|min:4", "sys_type|数据类型"=>"require|in:VER,MSG", "version|版本号"=>"require|max:255|min:4", "addtime|时间"=>"require|date", ]); if($valid->check($param)==false) return error_show(1004,$valid->getError()); $data=[ "module"=>$param['module'], "system"=>$param['system'], "sys_type"=>$param['sys_type'], "version"=>$param['version'], "addtime"=>$param['addtime'], ]; $ip= Db::name("system_version")->insert($data,true); return $ip?app_show(0,"新建成功",["id"=>$ip]):error_show(1004,"新建失败"); } /** * 保存新建的资源 * * @param \think\Request $request * @return \think\Response */ public function save() { $param =$this->request->only(["id"=>'',"module"=>"","system"=>"","sys_type"=>"","version"=>"",'addtime'],"post","trim"); $valid= Validate::rule([ "module|标题"=>"require|max:255|min:4", "system|内容"=>"require|min:4", "sys_type|数据类型"=>"require|in:VER,MSG", "version|版本号"=>"require|max:255|min:4", "addtime|时间"=>"require|date", "id|数据ID"=>"require|number|gt:0", ]); if($valid->check($param)==false) return error_show(1004,$valid->getError()); $info= Db::name("system_version")->where(["id"=>$param['id']])->findOrEmpty(); if(empty($info)) return error_show(1004,'未获取到信息'); $data=[ "module"=>$param['module'], "system"=>$param['system'], "sys_type"=>$param['sys_type'], "version"=>$param['version'], "addtime"=>$param['addtime'], ]; $ip= Db::name("system_version")->where($info)->update($data); return $ip?app_show(0,"编辑成功"):error_show(1004,"编辑失败"); } /** * 显示指定的资源 * * @param int $id * @return \think\Response */ public function GetLast() { $param =$this->request->only(["sys_type"=>"VER"],"post","trim"); $info= Db::name("system_version")->where(["sys_type"=>$param['sys_type']])->order("addtime desc,id desc") ->findOrEmpty(); return app_show(0,"获取成功",$info); } public function GetRate() { $info= Db::name("order_rate")->where(["status"=>1])->select()->toArray(); return app_show(0,"获取成功",$info); } }