Notice.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\Db;
  6. class Notice extends Base
  7. {
  8. // 新增
  9. public function save(){
  10. model('Notice')->add($this->userId,$this->orgId);
  11. HelpHander::success([],'操作成功');
  12. }
  13. // 编辑
  14. public function update(){
  15. model('Notice')->add($this->userId,$this->orgId);
  16. HelpHander::success([],'操作成功');
  17. }
  18. // 详情
  19. public function detail(){
  20. $id = input('id/d',0);
  21. $ret = model('Notice')->info($id);
  22. HelpHander::success($ret);
  23. }
  24. // 列表
  25. public function list(){
  26. $page = input('page/d',1);
  27. $size = input('size/d',10);
  28. $enable = input('enable/d',-1);
  29. $title = input('title','','trim');
  30. $type = input('type/d',0);
  31. $ret = model('Notice')->lists($page,$size,$this->orgId,$title,$enable,$this->userId,$type);
  32. HelpHander::success($ret);
  33. }
  34. // 用户公告列表
  35. public function noticeList(){
  36. $page = input('page/d',1);
  37. $size = input('size/d',10);
  38. $status = input('status/d',-1);
  39. $ret = model('Notice')->userLists($page,$size,$this->userId,$status);
  40. HelpHander::success($ret);
  41. }
  42. public function recentNoticeList(){
  43. $ret = model('Notice')->recentNoticeList($this->userId);
  44. HelpHander::success($ret);
  45. }
  46. // 未读状态改为已读
  47. public function changeStatus(){
  48. $id = input('id/d',0);
  49. model('Notice')->changeStatus($id,$this->userId);
  50. HelpHander::success([],'操作成功');
  51. }
  52. // 删除
  53. public function del(){
  54. $id = input('id/d',0);
  55. model('Notice')->del($id);
  56. HelpHander::success([],'操作成功');
  57. }
  58. // 全部已读
  59. public function setAllNoticeRead(){
  60. model('Notice')->setAllNoticeRead($this->userId,$this->orgId);
  61. HelpHander::success([],'操作成功');
  62. }
  63. //查询公告详情
  64. public function queryAppDetail(){
  65. $id = input('id/d',0);
  66. $ret = model('Notice')->queryAppDetail($id);
  67. HelpHander::success($ret);
  68. }
  69. // 消息列表
  70. public function queryNewsList(){
  71. $ret = model('Message')->queryNewsList($this->userId,$this->orgId);
  72. HelpHander::success($ret);
  73. }
  74. // 置顶/取消置顶
  75. public function top(){
  76. $id = input('id/d',0);
  77. $info = Db::name('notice')->where('id',$id)->find();
  78. if(!$info){
  79. HelpHander::error('数据不存在');
  80. }
  81. $top = $info['top'] == 1?0:1;
  82. $ret = Db::name('notice')->where('id',$id)->setField('top',$top);
  83. if(!$ret){
  84. HelpHander::error('操作失败');
  85. }
  86. HelpHander::success([],'操作成功');
  87. }
  88. }