Message.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | framework
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://framework.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/framework
  12. // +----------------------------------------------------------------------
  13. namespace app\admin\controller\api;
  14. use library\Controller;
  15. /**
  16. * Class Message
  17. * @package app\admin\controller\api
  18. */
  19. class Message extends Controller
  20. {
  21. /**
  22. * Message constructor.
  23. * @throws \think\Exception
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. if (!\app\admin\service\AuthService::isLogin()) {
  29. $this->error('访问授权失败,请重新登录授权再试!');
  30. }
  31. }
  32. /**
  33. * 获取系统消息列表
  34. * @throws \think\db\exception\DataNotFoundException
  35. * @throws \think\db\exception\ModelNotFoundException
  36. * @throws \think\exception\DbException
  37. */
  38. public function gets()
  39. {
  40. $list = \app\admin\service\MessageService::gets();
  41. $this->success('获取系统消息成功!', $list);
  42. }
  43. /**
  44. * 系统消息状态更新
  45. * @throws \think\Exception
  46. * @throws \think\exception\PDOException
  47. */
  48. public function set()
  49. {
  50. $code = $this->request->post('code');
  51. if (\app\admin\service\MessageService::set($code)) {
  52. $this->success('系统消息状态更新成功!');
  53. } else {
  54. $this->error('系统消息状态更新失败,请稍候再试!');
  55. }
  56. }
  57. }