NoticeService.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Http\Services\V1;
  3. use App\Generated\V1\Messages\Notice\UpdateNoticeByKeyMessage;
  4. use App\Generated\V1\Messages\Notice\GetNoticeByKeyToIntMessage;
  5. use App\Generated\V1\Messages\Notice\UpdateNoticeByGroupMessage;
  6. use App\Generated\V1\Messages\Notice\GetNoticeProfileListMessage;
  7. use App\Services\Notice\ManageService;
  8. use App\Http\Controllers\Core\Auth;
  9. class NoticeService
  10. {
  11. /**
  12. * 获取通知开关配置
  13. * @param GetNoticeProfileListMessage $message
  14. * @throws \App\Exceptions\ApiException
  15. */
  16. public function getNoticeProfileList(GetNoticeProfileListMessage $message)
  17. {
  18. $uid = Auth::auth();
  19. $ms = new ManageService();
  20. $data = $ms->getNoticeByUser($uid);
  21. $message->setResponse($data);
  22. }
  23. /**
  24. * 设置通知的开关
  25. * @param UpdateNoticeByKeyMessage $message
  26. * @throws \App\Exceptions\AlertException
  27. * @throws \App\Exceptions\ApiException
  28. */
  29. public function updateNoticeByKey(UpdateNoticeByKeyMessage $message)
  30. {
  31. $key = $message->getKey();
  32. $open = $message->getIsOpen();
  33. $uid = Auth::auth();
  34. $manageService = new ManageService();
  35. $manageService->updateNoticeByKey($uid, $key, $open);
  36. }
  37. /**
  38. * 设置群组通知的开关
  39. * @param UpdateNoticeByGroupMessage $message
  40. * @throws \App\Exceptions\AlertException
  41. * @throws \App\Exceptions\ApiException
  42. */
  43. public function updateNoticeByGroup(UpdateNoticeByGroupMessage $message)
  44. {
  45. $uid = Auth::auth();
  46. $group = $message->getGroup();
  47. $open = $message->getIsOpen();
  48. $manageService = new ManageService();
  49. $manageService->updateNoticeByGroup($uid, $group, $open);
  50. }
  51. /**
  52. * 获取通知开关
  53. * @param GetNoticeByKeyToIntMessage $message
  54. * @throws \App\Exceptions\AlertException
  55. * @throws \App\Exceptions\ApiException
  56. */
  57. public function getNoticeByKeyToInt(GetNoticeByKeyToIntMessage $message)
  58. {
  59. $key = $message->getKey();
  60. $uid = Auth::auth();
  61. $manageService = new ManageService();
  62. $open = $manageService->getNoticeByKey2Int($uid, $key);
  63. $message->setResponse([
  64. 'isopen' => $open
  65. ]);
  66. }
  67. }