Conf.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\App;
  5. use think\facade\Db;
  6. class Conf extends BaseController
  7. {
  8. public function __construct(App $app)
  9. {
  10. parent::__construct($app);
  11. $post =$this->request->post();
  12. $token = isset($post['token']) ? trim($post['token']) : "";
  13. // if($token==""){
  14. // return error_show(101,'token不能为空');
  15. //
  16. // }
  17. // $effetc = VerifyTokens($token);
  18. // if(!empty($effetc) && $effetc['code']!=0){
  19. // return error_show($effetc['code'],$effetc['message']);
  20. //
  21. // }
  22. }
  23. public function list(){
  24. $post = $this->request->post();
  25. $condition = [['is_del'=>0]];
  26. $page = isset($post['page']) &&$post['page']!=='' ?intval($post['page']) :1;
  27. $size = isset($post['size']) &&$post['size']!=='' ?intval($post['size']) :10;
  28. $count = Db::name("config")->where($condition)->count();
  29. $page>=ceil($count/$size) ? $page = ceil($count/$size): '';
  30. $list = Db::name("config")->where($condition)->page($page,$size)->order("addtime desc")->select();
  31. return app_show(0,"获取成功",['list'=>$list,"count"=>$count]);
  32. }
  33. public function info(){
  34. $post = $this->request->post();
  35. $id = isset($post['id']) && $post['id']!==''? intval($post['id']): '';
  36. if($id==''){
  37. return error_show(1004,'参数id 不能为空');
  38. }
  39. $condition = [['is_del'=>0],['id'=>$id]];
  40. $info = Db::name("config")->where($condition)->find();
  41. if(empty($info)){
  42. return error_show(1004,'未找到数据');
  43. }
  44. return app_show(0,"获取成功",$info);
  45. }
  46. public function add(){}
  47. }