123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace app\api\controller\v1;
- use app\api\controller\Base;
- use app\hander\HelpHander;
- use think\Db;
- class Notice extends Base
- {
- // 新增
- public function save(){
- model('Notice')->add($this->userId,$this->orgId);
- HelpHander::success([],'操作成功');
- }
- // 编辑
- public function update(){
- model('Notice')->add($this->userId,$this->orgId);
- HelpHander::success([],'操作成功');
- }
- // 详情
- public function detail(){
- $id = input('id/d',0);
- $ret = model('Notice')->info($id);
- HelpHander::success($ret);
- }
- // 列表
- public function list(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $enable = input('enable/d',-1);
- $title = input('title','','trim');
- $type = input('type/d',0);
- $ret = model('Notice')->lists($page,$size,$this->orgId,$title,$enable,$this->userId,$type);
- HelpHander::success($ret);
- }
- // 用户公告列表
- public function noticeList(){
- $page = input('page/d',1);
- $size = input('size/d',10);
- $status = input('status/d',-1);
- $ret = model('Notice')->userLists($page,$size,$this->userId,$status);
- HelpHander::success($ret);
- }
- public function recentNoticeList(){
- $ret = model('Notice')->recentNoticeList($this->userId);
- HelpHander::success($ret);
- }
- // 未读状态改为已读
- public function changeStatus(){
- $id = input('id/d',0);
- model('Notice')->changeStatus($id,$this->userId);
- HelpHander::success([],'操作成功');
- }
- // 删除
- public function del(){
- $id = input('id/d',0);
- model('Notice')->del($id);
- HelpHander::success([],'操作成功');
- }
- // 全部已读
- public function setAllNoticeRead(){
- model('Notice')->setAllNoticeRead($this->userId,$this->orgId);
- HelpHander::success([],'操作成功');
- }
- //查询公告详情
- public function queryAppDetail(){
- $id = input('id/d',0);
- $ret = model('Notice')->queryAppDetail($id);
- HelpHander::success($ret);
- }
- // 消息列表
- public function queryNewsList(){
- $ret = model('Message')->queryNewsList($this->userId,$this->orgId);
- HelpHander::success($ret);
- }
- // 置顶/取消置顶
- public function top(){
- $id = input('id/d',0);
- $info = Db::name('notice')->where('id',$id)->find();
- if(!$info){
- HelpHander::error('数据不存在');
- }
- $top = $info['top'] == 1?0:1;
- $ret = Db::name('notice')->where('id',$id)->setField('top',$top);
- if(!$ret){
- HelpHander::error('操作失败');
- }
- HelpHander::success([],'操作成功');
- }
- }
|