123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\controller;
- use think\App;
- use think\facade\Validate;
- use think\facade\Db;
- class System extends Base
- {
- public function __construct(App $app) {
- parent::__construct($app);
- }
- /**
- * 显示资源列表
- *
- * @return \think\Response
- */
- public function list()
- {
- $param =$this->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);
- }
- }
|