MessageModel.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace app\api\model\message;
  3. use app\api\model\ZskkDefaultModel;
  4. use think\facade\Log;
  5. class MessageModel extends ZskkDefaultModel {
  6. protected $connection = 'db_config_public';
  7. protected $table= 'messages';
  8. protected $logName = "MessageModel";
  9. public function getMessageList($params,$id)
  10. {
  11. $list = $this
  12. ->where('doctor_id', $id)
  13. ->where('status', 0)
  14. ->page($params['page'],$params['num'])
  15. ->order('createdAt desc,is_read asc')
  16. // ->field('doctor_id,status,institution_id,department_id,url,application_id', true)
  17. ->select();
  18. $total = $this
  19. ->where('doctor_id', $id)
  20. ->where('status', 0)
  21. ->count();
  22. return ['total'=>$total, 'list'=>$list];
  23. }
  24. public function readMessage($id)
  25. {
  26. $res = $this
  27. ->where('doctor_id',$id)
  28. ->update(['is_read'=>1]);
  29. return $res;
  30. }
  31. public function unReadMessage($id)
  32. {
  33. $res = $this
  34. ->where('doctor_id',$id)
  35. ->where('is_read',0)
  36. ->where('status',0)
  37. ->count();
  38. return $res;
  39. }
  40. public function getAppUnread($id)
  41. {
  42. $info = $this->where('is_read',0)
  43. ->where('doctor_id', $id)
  44. ->field("count(*) AS count,application_id")
  45. ->group('application_id')
  46. ->select();
  47. return $info;
  48. }
  49. public function delReadMessage($id)
  50. {
  51. $info = $this
  52. ->where('doctor_id', $id)
  53. ->where('is_read', 1)
  54. ->update(['status'=>1]);
  55. return $info;
  56. }
  57. public function delAllMessage($id)
  58. {
  59. $info = $this
  60. ->where('doctor_id', $id)
  61. ->update(['status'=>1]);
  62. return $info;
  63. }
  64. public function read($id)
  65. {
  66. $res = $this
  67. ->where('id',$id)
  68. ->update(['is_read'=>1]);
  69. return $res;
  70. }
  71. public function getInfo($id)
  72. {
  73. $info = $this
  74. ->where('id',$id)
  75. ->field('title,content,application_id,is_read,exam_id,is_remote')
  76. ->find();
  77. $this->where('id',$id)
  78. ->update(['is_read'=>1]);
  79. return $info;
  80. }
  81. public function deleteone($id)
  82. {
  83. $info = $this
  84. ->where('id',$id)
  85. ->update(['status'=>1]);
  86. return $info;
  87. }
  88. public function getSpecialMessage($institution)
  89. {
  90. $message = $this->where('institution_id',$institution)->where('type',10)->where('status',0)->value('content');
  91. return $message;
  92. }
  93. }