123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace app\api\model\message;
- use app\api\model\ZskkDefaultModel;
- use think\facade\Log;
- class MessageModel extends ZskkDefaultModel {
- protected $connection = 'db_config_public';
- protected $table= 'messages';
- protected $logName = "MessageModel";
- public function getMessageList($params,$id)
- {
- $list = $this
- ->where('doctor_id', $id)
- ->where('status', 0)
- ->page($params['page'],$params['num'])
- ->order('createdAt desc,is_read asc')
- // ->field('doctor_id,status,institution_id,department_id,url,application_id', true)
- ->select();
- $total = $this
- ->where('doctor_id', $id)
- ->where('status', 0)
- ->count();
- return ['total'=>$total, 'list'=>$list];
- }
- public function readMessage($id)
- {
- $res = $this
- ->where('doctor_id',$id)
- ->update(['is_read'=>1]);
- return $res;
- }
- public function unReadMessage($id)
- {
- $res = $this
- ->where('doctor_id',$id)
- ->where('is_read',0)
- ->where('status',0)
- ->count();
- return $res;
- }
- public function getAppUnread($id)
- {
- $info = $this->where('is_read',0)
- ->where('doctor_id', $id)
- ->field("count(*) AS count,application_id")
- ->group('application_id')
- ->select();
- return $info;
- }
- public function delReadMessage($id)
- {
- $info = $this
- ->where('doctor_id', $id)
- ->where('is_read', 1)
- ->update(['status'=>1]);
- return $info;
- }
- public function delAllMessage($id)
- {
- $info = $this
- ->where('doctor_id', $id)
- ->update(['status'=>1]);
- return $info;
- }
- public function read($id)
- {
- $res = $this
- ->where('id',$id)
- ->update(['is_read'=>1]);
- return $res;
- }
- public function getInfo($id)
- {
- $info = $this
- ->where('id',$id)
- ->field('title,content,application_id,is_read,exam_id,is_remote')
- ->find();
- $this->where('id',$id)
- ->update(['is_read'=>1]);
- return $info;
- }
- public function deleteone($id)
- {
- $info = $this
- ->where('id',$id)
- ->update(['status'=>1]);
- return $info;
- }
- public function getSpecialMessage($institution)
- {
- $message = $this->where('institution_id',$institution)->where('type',10)->where('status',0)->value('content');
- return $message;
- }
- }
|