News.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\api\controller;
  10. use app\common\exception\BaseException;
  11. use think\facade\Request;
  12. use app\api\service\News as NewsService;
  13. class News extends Base {
  14. /**
  15. * 新闻列表
  16. * @return \think\response\Json
  17. */
  18. public function index(){
  19. try{
  20. return $this->returnAjax("ok",1,NewsService::getList(Request::param()));
  21. }catch (BaseException $ex){
  22. return $this->returnAjax($ex->getMessage(),$ex->getCode(),$ex->getRaw());
  23. }
  24. }
  25. /**
  26. * 新闻详情
  27. * @return \think\response\Json
  28. */
  29. public function view(){
  30. try {
  31. return $this->returnAjax("ok",1,NewsService::detail(Request::param("id","0","intval")));
  32. }catch (\Exception $ex){
  33. return $this->returnAjax($ex->getMessage(),0);
  34. }
  35. }
  36. }