Message.php 1.7 KB

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