Template.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\admin\controller\sms;
  3. use app\common\controller\Backend;
  4. /**
  5. * 短信模板管理
  6. *
  7. */
  8. class Template extends Backend
  9. {
  10. /**
  11. * Template模型对象
  12. * @var \app\admin\model\sms\Template
  13. */
  14. protected $model = null;
  15. protected $quickSearchField = ['title', 'code'];
  16. protected $defaultSortField = 'id,desc';
  17. protected $preExcludeFields = ['createtime', 'updatetime'];
  18. public function initialize()
  19. {
  20. parent::initialize();
  21. $this->model = new \app\admin\model\sms\Template;
  22. }
  23. public function add()
  24. {
  25. $this->request->filter('trim,htmlspecialchars');
  26. parent::add();
  27. }
  28. public function edit($id = null)
  29. {
  30. $this->request->filter('trim,htmlspecialchars');
  31. parent::edit($id);
  32. }
  33. /**
  34. * 查看
  35. */
  36. public function index()
  37. {
  38. // 设置过滤方法
  39. $this->request->filter(['strip_tags', 'trim']);
  40. // 如果是select则转发到select方法,若select未重写,其实还是继续执行index
  41. if ($this->request->param('select')) {
  42. $this->select();
  43. }
  44. list($where, $alias, $limit, $order) = $this->queryBuilder();
  45. $res = $this->model
  46. ->alias($alias)
  47. ->where($where)
  48. ->order($order)
  49. ->paginate($limit);
  50. $this->success('', [
  51. 'list' => $res->items(),
  52. 'total' => $res->total(),
  53. 'remark' => get_route_remark(),
  54. ]);
  55. }
  56. }