心理咨询网
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.

AboutController.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @copyright (C)2016-2099 Hnaoyun Inc.
  4. * @author XingMeng
  5. * @email hnxsh@foxmail.com
  6. * @date 2018年11月11日
  7. * 单页内容通过分类编码调用接口控制器
  8. */
  9. namespace app\api\controller;
  10. use core\basic\Controller;
  11. use app\api\model\CmsModel;
  12. use core\basic\Url;
  13. use app\home\controller\ParserController;
  14. class AboutController extends Controller
  15. {
  16. protected $model;
  17. public function __construct()
  18. {
  19. $this->model = new CmsModel();
  20. }
  21. public function index()
  22. {
  23. if (! ! $scode = request('scode', 'var')) {
  24. // 区域获取
  25. $acode = request('acode', 'var') ?: get_default_lg();
  26. // 读取数据
  27. if (! ! $data = $this->model->getAbout($acode, $scode)) {
  28. if ($data->outlink) {
  29. $data->apilink = $data->outlink;
  30. } else {
  31. $data->apilink = url('/api/content/index/id/' . $data->id, false);
  32. }
  33. $data->likeslink = url('/home/Do/likes/id/' . $data->id, false);
  34. $data->opposelink = url('/home/Do/oppose/id/' . $data->id, false);
  35. $Parser = new ParserController();
  36. $data->contentlink = $Parser->parserLink(1, $data->urlname, 'about', $data->scode, $data->sortfilename);
  37. $data->content = str_replace(STATIC_DIR . '/upload/', get_http_url() . STATIC_DIR . '/upload/', $data->content);
  38. json(1, $data);
  39. } else {
  40. json(0, '分类编码为' . $scode . '的内容已经不存在了!');
  41. }
  42. } else {
  43. json(1, '请求错误,传递的内容scode有误!');
  44. }
  45. }
  46. }