Notice.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2015-2025 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: http://www.niushop.com.cn
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace app\api\controller;
  13. use app\model\web\Notice as NoticeModel;
  14. use app\model\web\NoticeClass as NoticeClassModel;
  15. /**
  16. *
  17. * @author Administrator
  18. *
  19. */
  20. class Notice extends BaseApi
  21. {
  22. /**
  23. * 基础信息
  24. */
  25. public function info()
  26. {
  27. $id = isset($this->params['id']) ? $this->params['id'] : 0;
  28. if (empty($id)) {
  29. return $this->response($this->error('', 'REQUEST_ID'));
  30. }
  31. $notice = new NoticeModel();
  32. $info = $notice->getNoticeInfo([ [ 'id', '=', $id ] ],'id,title,content,show_number,create_time');
  33. $info['data']['create_time']=date('Y-m-d H:i:s', $info['data']['create_time']);
  34. $data['show_number'] = $info['data']['show_number']+1;
  35. $notice->editNotice($data, [ [ 'id', '=', $id ] ]);
  36. return $this->response($info);
  37. }
  38. /**
  39. * @return false|string
  40. * 公告列表
  41. */
  42. public function page()
  43. {
  44. $page = isset($this->params['page']) ? $this->params['page'] : 1;
  45. $page_size = isset($this->params['page_size']) ? $this->params['page_size'] : PAGE_LIST_ROWS;
  46. $n_class = isset($this->params['n_class']) ? $this->params['n_class'] : '';
  47. $notice = new NoticeModel();
  48. $condition = [];
  49. if(!empty($n_class)){
  50. $condition[] =['n_class','=',$n_class];
  51. }
  52. $list = $notice->getNoticePageList($condition, $page, $page_size,'id desc','id,title,content,create_time');
  53. foreach ($list['data']['list'] as $k=>$v){
  54. $list['data']['list'][$k]['create_time']=date('Y-m-d H:i:s', $list['data']['list'][$k]['create_time']);}
  55. return $this->response($list);
  56. }
  57. /**
  58. * @return false|string
  59. * 历史公告菜单
  60. */
  61. public function notice_class(){
  62. $page = isset($this->params['page']) ? $this->params['page'] : 1;
  63. $page_size = isset($this->params['page_size']) ? $this->params['page_size'] : PAGE_LIST_ROWS;
  64. $notice_class = new NoticeClassModel();
  65. $condition = [];
  66. $list = $notice_class->getNoticeClassPageList($condition, $page, $page_size);
  67. return $this->response($list);
  68. }
  69. }