System.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\Admin\controller;
  4. use app\BaseController;
  5. use think\facade\Db;
  6. use think\Request;
  7. class System extends BaseController
  8. {
  9. /**
  10. * 显示资源列表
  11. *
  12. * @return \think\Response
  13. */
  14. public function index()
  15. {
  16. $post =$this->request->post();
  17. $token = isset($post['token']) ? trim($post['token']) : "";
  18. if($token==""){
  19. return error_show(101,'token不能为空');
  20. }
  21. $effetc =VerifyTokens($token);
  22. if(!empty($effetc) && $effetc['code']!=0){
  23. return error_show($effetc['code'],$effetc['message']);
  24. }
  25. $condition = [];
  26. isset($post['startTime'])&& $post['startTime']!="" ? $condition[] = ["addtime",">=",$post["startTime"]]:"";
  27. isset($post['endTime'])&& $post['endTime']!="" ? $condition[] = ["addtime","<=",$post["endTime"]]:"";
  28. isset($post['event'])&& $post['event']!="" ? $condition[] = ["url","like","%".$post['event']."%"]:"";
  29. isset($post['name'])&& $post['name']!="" ? $condition[] = ["name","like","%".$post['name']."%"]:"";
  30. isset($post['action'])&& $post['action']!="" ? $condition[] = ["info","=",$post["action"]]:"";
  31. isset($post['role'])&& $post['role']!="" ? $condition[] = ["rolename","like","%".$post['role']."%"]:"";
  32. $page = isset($post['page'])&&$post['page']!="" ? intval($post['page']) :0;
  33. $size = isset($post['size'])&&$post['size']!="" ? intval($post['size']) :10;
  34. $count = Db::name("system_log")->where($condition)->count();
  35. $total = ceil($count/$size)>1 ? ceil($count/$size) : 1;
  36. $page = $page>=$total?intval($total):$page;
  37. $list = Db::name("system_log")->where($condition)->page($page,$size)->order("addtime desc")->field("id,info,url,param,rolename,name,addtime")->select();
  38. return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
  39. }
  40. /**
  41. * 显示创建资源表单页.
  42. *
  43. * @return \think\Response
  44. */
  45. public function version()
  46. {
  47. $post =$this->request->post();
  48. $token = isset($post['token']) ? trim($post['token']) : "";
  49. if($token==""){
  50. return error_show(101,'token不能为空');
  51. }
  52. $effetc =VerifyTokens($token);
  53. if(!empty($effetc) && $effetc['code']!=0){
  54. return error_show($effetc['code'],$effetc['message']);
  55. }
  56. $condition = " 1=1 ";
  57. $page = isset($post['page'])&&$post['page']!="" ? intval($post['page']) :0;
  58. $size = isset($post['size'])&&$post['size']!="" ? intval($post['size']) :10;
  59. $count = Db::name("system_version")->where($condition)->count();
  60. $total = ceil($count/$size)>1 ? ceil($count/$size) : 1;
  61. $page = $page>=$total?intval($total):$page;
  62. $list = Db::name("system_version")->where($condition)->page($page,$size)->order("addtime desc")->select();
  63. return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
  64. }
  65. /**
  66. * 保存新建的资源
  67. *
  68. * @param \think\Request $request
  69. * @return \think\Response
  70. */
  71. public function LastVersion()
  72. {
  73. $post =$this->request->post();
  74. $type = isset($post['type'])&& $post['type']!="" ? $post['type'] : "";
  75. if($type=="" || !in_array($type,["VER","MSG"])){
  76. $where="1=1";
  77. }else{
  78. $where="sys_type='{$type}'";
  79. }
  80. $version=Db::name("system_version")->where($where)->order("addtime desc")->find();
  81. if(!$version){
  82. return error_show(1004,'未找到数据');
  83. }
  84. return app_show(0,"获取成功",$version);
  85. }
  86. /**
  87. * 显示指定的资源
  88. *
  89. * @param int $id
  90. * @return \think\Response
  91. */
  92. public function read($id)
  93. {
  94. //
  95. }
  96. /**
  97. * 显示编辑资源表单页.
  98. *
  99. * @param int $id
  100. * @return \think\Response
  101. */
  102. public function edit($id)
  103. {
  104. //
  105. }
  106. /**
  107. * 保存更新的资源
  108. *
  109. * @param \think\Request $request
  110. * @param int $id
  111. * @return \think\Response
  112. */
  113. public function update(Request $request, $id)
  114. {
  115. //
  116. }
  117. /**
  118. * 删除指定资源
  119. *
  120. * @param int $id
  121. * @return \think\Response
  122. */
  123. public function delete($id)
  124. {
  125. //
  126. }
  127. }