Log.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\controller;
  4. use app\BaseController;
  5. use think\Request;
  6. use think\app;
  7. use think\Facade\Db;
  8. class Log extends BaseController
  9. {
  10. public $post = "";
  11. public function __construct(App $app)
  12. {
  13. parent::__construct($app);
  14. $this->post = $this->request->post();
  15. }
  16. /**
  17. * 显示资源列表
  18. *
  19. * @return \think\Response
  20. */
  21. public function index()
  22. {
  23. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
  24. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
  25. $condition = [['type',"=",1]];
  26. $count = Db::name("action_log")->where($condition)->count();
  27. $total = ceil($count/$size);
  28. $page = $page >= $total ? $total : $page;
  29. $list =Db::name("action_log")->where($condition)->page($page,$size)->select();
  30. return app_show(0,"获取成功",['list'=>$list,"count"=>$count]);
  31. }
  32. /**
  33. * 显示创建资源表单页.
  34. *
  35. * @return \think\Response
  36. */
  37. public function create()
  38. {
  39. //
  40. }
  41. /**
  42. * 保存新建的资源
  43. *
  44. * @param \think\Request $request
  45. * @return \think\Response
  46. */
  47. public function save(Request $request)
  48. {
  49. //
  50. }
  51. /**
  52. * 显示指定的资源
  53. *
  54. * @param int $id
  55. * @return \think\Response
  56. */
  57. public function read()
  58. {
  59. $id = isset($this->post['id'])&&$this->post['id']!=="" ? intval($this->post['id']) :"";
  60. if($id===""){
  61. return error_show(1004,"参数 id 不能为空");
  62. }
  63. $info = Db::name("action_log")->where(["id"=>$id])->find();
  64. if(empty($info)){
  65. return error_show(1004,"未找到数据");
  66. }
  67. return app_show(0,"获取成功",$info);
  68. }
  69. /**
  70. * 显示编辑资源表单页.
  71. *
  72. * @param int $id
  73. * @return \think\Response
  74. */
  75. public function edit($id)
  76. {
  77. //
  78. }
  79. /**
  80. * 保存更新的资源
  81. *
  82. * @param \think\Request $request
  83. * @param int $id
  84. * @return \think\Response
  85. */
  86. public function update(Request $request, $id)
  87. {
  88. //
  89. }
  90. /**
  91. * 删除指定资源
  92. *
  93. * @param int $id
  94. * @return \think\Response
  95. */
  96. public function delete($id)
  97. {
  98. //
  99. }
  100. }