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.
 
 
 
 
 
 

93 lines
2.2 KiB

  1. <?php
  2. namespace admin\controllers\prod;
  3. use common\Controller\AdminController;
  4. use admin\service\prod\NewsService;
  5. class NewsController extends AdminController
  6. {
  7. /**
  8. * Des:获取
  9. * Name: service
  10. * @author 倪宗峰
  11. */
  12. public function service()
  13. {
  14. if ($this->service == '') {
  15. $this->service = new NewsService();
  16. }
  17. return $this->service;
  18. }
  19. /**
  20. * Function Description:获取新闻列表
  21. * Function Name: actionNewsList
  22. *
  23. * @return string
  24. *
  25. * @author 娄梦宁
  26. */
  27. public function actionNewsList(){
  28. $param=[
  29. 'news_title'=>$this->_post('news_title_search',''),
  30. 'current_page' => $this->_post('current_page', 1),
  31. 'page_size' => $this->_post('page_size', 10)
  32. ];
  33. $result=$this->service()->getNewsList($param);
  34. return json_encode($result);
  35. }
  36. /**
  37. * Function Description:删除新闻
  38. * Function Name: actionDesNews
  39. *
  40. * @return string
  41. *
  42. * @author 娄梦宁
  43. */
  44. public function actionDelNews()
  45. {
  46. $news_id=$this->_post('news_id','');
  47. $result=$this->service()->DelNews($news_id);
  48. return json_encode($result);
  49. }
  50. /**
  51. * Function Description:新闻修改时获取数据
  52. * Function Name: actionGetNewsInfo
  53. *
  54. * @return string
  55. *
  56. * @author 娄梦宁
  57. */
  58. public function actionGetNewsInfo()
  59. {
  60. $news_id=$this->_post('news_id','');
  61. $result=$this->service()->GetNewsInfo($news_id);
  62. return json_encode($result);
  63. }
  64. /**
  65. * Function Description:添加或保存新闻
  66. * Function Name: actionSaveNews
  67. *
  68. * @return string
  69. *
  70. * @author 娄梦宁
  71. */
  72. public function actionSaveNews()
  73. {
  74. $params = [
  75. 'id' => $this->_post('news_id', ''),
  76. 'class_id' => $this->_post('class_id', ''),
  77. 'content' => $this->_post('content', ''),
  78. 'navi_content' => $this->_post('navi_content', ''),
  79. 'news_title' => $this->_post('news_title', ''),
  80. ];
  81. $result=$this->service()->SaveNews($params);
  82. return json_encode($result);
  83. }
  84. }