This commit is contained in:
Gitea
2022-01-24 10:43:35 +08:00
commit 15dfc6576b
786 changed files with 219240 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年11月11日
* 单页内容通过分类编码调用接口控制器
*/
namespace app\api\controller;
use core\basic\Controller;
use app\api\model\CmsModel;
use core\basic\Url;
class AboutController extends Controller
{
protected $model;
public function __construct()
{
$this->model = new CmsModel();
}
public function index()
{
if (! ! $scode = request('scode', 'var')) {
// 区域获取
$acode = request('acode', 'var') ?: get_default_lg();
// 读取数据
if (! ! $data = $this->model->getAbout($acode, $scode)) {
if ($data->outlink) {
$data->apilink = $data->outlink;
} else {
$data->apilink = url('/api/content/index/id/' . $data->id, false);
}
$data->likeslink = url('/home/Do/likes/id/' . $data->id, false);
$data->opposelink = url('/home/Do/oppose/id/' . $data->id, false);
$urlname = $data->urlname ?: 'about';
$url_break_char = $this->config('url_break_char') ?: '_';
if ($data->sortfilename) {
$data->contentlink = Url::home($data->sortfilename);
} else {
$data->contentlink = Url::home($urlname . $url_break_char . $data->scode);
}
$data->content = str_replace(STATIC_DIR . '/upload/', get_http_url() . STATIC_DIR . '/upload/', $data->content);
json(1, $data);
} else {
json(0, '分类编码为' . $scode . '的内容已经不存在了!');
}
} else {
json(1, '请求错误传递的内容scode有误');
}
}
}