MessageDao.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. namespace app\api\dao\message;
  3. use app\api\actions\ZskkCache;
  4. use app\api\dao\ZskkDefaultDao;
  5. use app\api\model\message\MessageModel;
  6. use think\facade\Log;
  7. use app\api\utils\UUIDUtils;
  8. /**
  9. * 后台控制器基类
  10. * 接口方法权限 必传参数 接口返回 错误抛出 通用参数处理
  11. */
  12. class MessageDao extends ZskkDefaultDao {
  13. protected $flag = true;
  14. protected $logName = "MessageDao";
  15. protected $message = null;
  16. public function __construct(MessageModel $messageModel)
  17. {
  18. parent::__construct();
  19. $this->message = $messageModel;
  20. }
  21. public function getUser($token)
  22. {
  23. $user = $this->getCache($token);
  24. if(!$user){
  25. $this->throwError('登陆信息失效,请重新进行登陆','0099');
  26. }
  27. return $user;
  28. }
  29. public function getMessageList($params,$id)
  30. {
  31. $info = $this->message->getMessageList($params,$id);
  32. return $info;
  33. }
  34. public function readMessage($id,$user)
  35. {
  36. $info = $this->message->readMessage($id);
  37. if($info){
  38. $this->delCache($user['id'].'_unread');
  39. }
  40. return $info;
  41. }
  42. public function unReadMessage($id,$insId)
  43. {
  44. $info = $this->message->unReadMessage($id,$insId);
  45. return $info;
  46. }
  47. public function getUnReadList($id)
  48. {
  49. $info = $this->message->getUnReadList($id);
  50. return $info;
  51. }
  52. public function noticeUnread($id)
  53. {
  54. $info = $this->message->noticeUnread($id);
  55. return $info;
  56. }
  57. public function getAppUnread($id,$insId)
  58. {
  59. $info = $this->message->getAppUnread($id,$insId);
  60. return $info;
  61. }
  62. public function delReadMessage($id)
  63. {
  64. $info = $this->message->delReadMessage($id);
  65. return $info;
  66. }
  67. public function delAllMessage($id,$user)
  68. {
  69. $info = $this->message->delAllMessage($id);
  70. if($info){
  71. $this->delCache($user['id'].'_unread');
  72. }
  73. return $info;
  74. }
  75. public function read($id,$user)
  76. {
  77. $info = $this->message->read($id);
  78. if($info){
  79. $this->delCache($user['id'].'_unread');
  80. }
  81. return $info;
  82. }
  83. public function getInfo($id,$user)
  84. {
  85. $info = $this->message->getInfo($id);
  86. if($info){
  87. $this->delCache($user['id'].'_unread');
  88. }
  89. return $info;
  90. }
  91. public function deleteone($id,$user)
  92. {
  93. $info = $this->message->deleteone($id);
  94. if($info){
  95. $this->delCache($user['id'].'_unread');
  96. }
  97. return $info;
  98. }
  99. public function getSpecialMessage($institution)
  100. {
  101. $info = $this->message->getSpecialMessage($institution);
  102. return $info;
  103. }
  104. }