Log.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. }
  65. /**
  66. * 显示编辑资源表单页.
  67. *
  68. * @param int $id
  69. * @return \think\Response
  70. */
  71. public function edit($id)
  72. {
  73. //
  74. }
  75. /**
  76. * 保存更新的资源
  77. *
  78. * @param \think\Request $request
  79. * @param int $id
  80. * @return \think\Response
  81. */
  82. public function update(Request $request, $id)
  83. {
  84. //
  85. }
  86. /**
  87. * 删除指定资源
  88. *
  89. * @param int $id
  90. * @return \think\Response
  91. */
  92. public function delete($id)
  93. {
  94. //
  95. }
  96. }