Feedback.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\controller\base\Permissions;
  4. use think\Db;
  5. class Feedback extends Permissions
  6. {
  7. private function getModel()
  8. {
  9. return new \app\common\model\Feedback();
  10. }
  11. public function index()
  12. {
  13. if ($this->request->isAjax()) {
  14. $post = $this->request->param();
  15. $where = [];
  16. if (isset($post['ids']) and !empty($post['ids'])) {
  17. $where['id'] = ['in', $post['ids']];
  18. }
  19. if (!empty($post["content"])) {
  20. $where["content"] = ['like', '%' . $post["content"] . '%'];
  21. }
  22. if (isset($post["user_id"]) and "" != $post["user_id"]) {
  23. $where["user_id"] = $post["user_id"];
  24. }
  25. if (isset($post["create_time"]) and !empty($post["create_time"])) {
  26. $timerang = explode(' - ', $post["create_time"]);
  27. $min_time = strtotime($timerang[0]);
  28. $max_time = $timerang[0] == $timerang[1] ? $min_time + 24 * 3600 - 1 : strtotime($timerang[1]??'');
  29. $where["create_time"] = [['>=', $min_time], ['<=', $max_time]];
  30. }
  31. $model = $this->getModel();
  32. $count = $model->where($where)->count();
  33. $data = $model->where($where)->page($post['page']??0, $post['limit']??15)->order('id desc')->select();
  34. return array('code' => 0, 'count' => $count, 'data' => $data);
  35. } else {
  36. return $this->fetch();
  37. }
  38. }
  39. public function delete()
  40. {
  41. if ($this->request->isAjax()) {
  42. $id = $this->request->param('id', 0, 'intval');
  43. if (false == $this->getModel()->where('id', $id)->delete()) {
  44. $this->error('删除失败');
  45. } else {
  46. $this->success('删除成功', 'index');
  47. }
  48. }
  49. }
  50. public function deletes()
  51. {
  52. if ($this->request->isAjax()) {
  53. $post = $this->request->param();
  54. $ids = $post['ids'];
  55. if ($this->getModel()->where('id', 'in', $ids)->delete()) {
  56. $this->success('删除成功');
  57. }
  58. }
  59. }
  60. }