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. * @param \think\Request $request
  44. * @return \think\Response
  45. */
  46. public function save(Request $request)
  47. {
  48. //
  49. }
  50. /**
  51. * 显示指定的资源
  52. *
  53. * @param int $id
  54. * @return \think\Response
  55. */
  56. public function read()
  57. {
  58. $id = isset($this->post['id'])&&$this->post['id']!=="" ? intval($this->post['id']) :"";
  59. if($id===""){
  60. return error_show(1004,"参数 id 不能为空");
  61. }
  62. $info = Db::name("action_log")->where(["id"=>$id])->find();
  63. if(empty($info)){
  64. return error_show(1004,"未找到数据");
  65. }
  66. return app_show(0,"获取成功",$info);
  67. }
  68. /**
  69. * 显示编辑资源表单页.
  70. *
  71. * @param int $id
  72. * @return \think\Response
  73. */
  74. public function edit($id)
  75. {
  76. //
  77. }
  78. /**
  79. * 保存更新的资源
  80. *
  81. * @param \think\Request $request
  82. * @param int $id
  83. * @return \think\Response
  84. */
  85. public function update(Request $request, $id)
  86. {
  87. //
  88. }
  89. /**
  90. * 删除指定资源
  91. *
  92. * @param int $id
  93. * @return \think\Response
  94. */
  95. public function delete($id)
  96. {
  97. //
  98. }
  99. }