苗总组局小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
jol/application/api/controller/Systemmessage.php

52 lines
1.4 KiB

<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\library\Sms as Smslib;
use app\common\model\User;
use think\Hook;
use think\Db;
class Systemmessage extends Api{
protected $model = null;
protected $noNeedRight = '*';
protected $noNeedLogin = [];
use \app\api\library\buiapi\traits\Api;
public function _initialize(){
parent::_initialize();
$this->model = new \app\admin\model\system\Message;
}
public function getmessagelist(){
$uid = $this->auth->id;
$offset = $this->request->post('offset');
$limit = $this->request->post('limit');
$data = $this->model->getlist($offset, $limit,$uid);
//查询未读消息数量
$data['unread'] = $this->model->where("uid",$uid)->where("is_read",0)->where("is_del",0)->count();
return $this->success('获取成功',$data);
}
public function delmessage(){
$data = $this->request->post();
if($this->request->isPost()){
$id = $data['id'];
//查询消息信息
$message = $this->model->get($id);
if(!$message->save(['is_del'=>1])) return $this->error('已删除或者消息不存在');
return $this->success('已删除');
}
}
public function readmessage(){
$data = $this->request->post();
if($this->request->isPost()){
$uid = $this->auth->id;
$sql = "update fa_system_message set is_read=1 where uid in (".$uid.")";
Db::execute($sql);
}
}
}