Message.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace app\data\controller\base;
  3. use app\data\model\BaseUserMessage;
  4. use think\admin\Controller;
  5. use think\admin\helper\QueryHelper;
  6. /**
  7. * 系统通知管理
  8. * Class Notify
  9. * @package app\data\controller\base
  10. */
  11. class Message extends Controller
  12. {
  13. /**
  14. * 系统通知管理
  15. * @auth true
  16. * @menu true
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. */
  21. public function index()
  22. {
  23. BaseUserMessage::mQuery()->layTable(function () {
  24. $this->title = '系统通知管理';
  25. }, function (QueryHelper $query) {
  26. $query->where(['deleted' => 0]);
  27. $query->like('name')->equal('status')->dateBetween('create_at');
  28. });
  29. }
  30. /**
  31. * 添加系统通知
  32. * @auth true
  33. */
  34. public function add()
  35. {
  36. $this->title = '添加系统通知';
  37. BaseUserMessage::mForm('form');
  38. }
  39. /**
  40. * 编辑系统通知
  41. * @auth true
  42. */
  43. public function edit()
  44. {
  45. $this->title = '编辑系统通知';
  46. BaseUserMessage::mForm('form');
  47. }
  48. /**
  49. * 表单结果处理
  50. * @param boolean $state
  51. */
  52. protected function _form_result(bool $state)
  53. {
  54. if ($state) {
  55. $this->success('内容保存成功!', 'javascript:history.back()');
  56. }
  57. }
  58. /**
  59. * 修改通知状态
  60. * @auth true
  61. */
  62. public function state()
  63. {
  64. BaseUserMessage::mSave($this->_vali([
  65. 'status.in:0,1' => '状态值范围异常!',
  66. 'status.require' => '状态值不能为空!',
  67. ]));
  68. }
  69. /**
  70. * 删除系统通知
  71. * @auth true
  72. */
  73. public function remove()
  74. {
  75. BaseUserMessage::mDelete();
  76. }
  77. }