NoticeService.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: tandunzhao
  5. * Date: 2017/12/2
  6. * Time: 上午11:39
  7. */
  8. namespace App\Modules\Notice\Services;
  9. use App\Modules\Notice\Models\Notice;
  10. use App\Modules\Notice\Models\NoticeType;
  11. class NoticeService
  12. {
  13. /**
  14. * 获取通知列表
  15. * @param string $notice_type_id 可不传
  16. * @param string $status 可不传 0:正常 -1:删除 ;
  17. * @return mixed
  18. */
  19. public static function getAllNoticeList($notice_type_id = '', $status = '') {
  20. return Notice::getList($notice_type_id, $status);
  21. }
  22. /**
  23. * 获取简易通知列表
  24. * @param string $notice_type_id 可不传
  25. * @param string $status 可不传 0:正常 -1:删除 ;
  26. * @return mixed
  27. */
  28. public static function getSimpleNoticeList($notice_type_id = '', $status = '') {
  29. return Notice::getSimpleNoticeList($notice_type_id, $status);
  30. }
  31. /**
  32. * 添加通知
  33. * @param $params
  34. * @return mixed
  35. */
  36. public static function addNotice($params) {
  37. $data = Notice::create($params);
  38. return $data;
  39. }
  40. /**
  41. * 获取一个通知
  42. * @param $noticeId 通知ID
  43. * @return mixed
  44. */
  45. public static function getNotice($noticeId) {
  46. $data = Notice::getItem($noticeId);
  47. return $data;
  48. }
  49. /**
  50. * 更新通知
  51. * @param Notice $notice
  52. * @return Notice
  53. */
  54. public static function updateNotice(Notice $notice) {
  55. $notice->save();
  56. return $notice;
  57. }
  58. /**
  59. * 获取通知类型列表
  60. * @return mixed
  61. */
  62. public static function getAllNoticeTypeList() {
  63. $noticeTypes = NoticeType::all();
  64. return $noticeTypes;
  65. }
  66. /**
  67. * 判断通知类型名称是否存在
  68. * @param $name
  69. * @return bool
  70. */
  71. public static function existNoticeTypeName($name) {
  72. return NoticeType::isNameExist($name);
  73. }
  74. /**
  75. * 保存通知类型列表
  76. * @param $params
  77. * @return mixed
  78. */
  79. public static function addNoticeType($params) {
  80. $noticeTypes = NoticeType::create($params);
  81. return $noticeTypes;
  82. }
  83. /**
  84. * 删除公告类型ID
  85. * @param $id
  86. */
  87. public static function rmNoticeType($id) {
  88. NoticeType::where('id', $id)->delete();
  89. }
  90. }