feat 新闻类型接口
This commit is contained in:
parent
1de69a90a7
commit
b5686e6cf7
71
app/api/controller/News/News.php
Normal file
71
app/api/controller/News/News.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\News;
|
||||||
|
|
||||||
|
use app\BaseController;
|
||||||
|
use app\common\model\News\News as ModelNews;
|
||||||
|
use app\Request;
|
||||||
|
use think\Validate;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
use think\facade\Filesystem;
|
||||||
|
use app\common\arw\adjfut\src\Excel;
|
||||||
|
use app\common\arw\adjfut\src\UploadFile;
|
||||||
|
use think\facade\Db;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
use think\facade\Env;
|
||||||
|
|
||||||
|
|
||||||
|
class News extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取新闻列表
|
||||||
|
*/
|
||||||
|
public function getNewsList(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
$con = [];
|
||||||
|
|
||||||
|
$con = Tool::getOptionalQuery(['news_type', '='], ['news_title', 'LIKE'],);
|
||||||
|
|
||||||
|
$query = ModelNews::where($con)
|
||||||
|
->field([
|
||||||
|
'news_id',
|
||||||
|
'news_type',
|
||||||
|
'news_title',
|
||||||
|
'news_intro',
|
||||||
|
'news_link',
|
||||||
|
'news_issue_date',
|
||||||
|
'news_sort',
|
||||||
|
])
|
||||||
|
->order('news_sort', 'asc');
|
||||||
|
|
||||||
|
return msg("获取新闻列表成功!", $query);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取新闻详情
|
||||||
|
*/
|
||||||
|
public function getNewsInfo(Request $request): array
|
||||||
|
{
|
||||||
|
$params = $request->param();
|
||||||
|
|
||||||
|
$this->validate($params, ['news_id' => 'require']);
|
||||||
|
|
||||||
|
$find = ModelNews::field([
|
||||||
|
'news_id',
|
||||||
|
'news_type',
|
||||||
|
'news_title',
|
||||||
|
'news_intro',
|
||||||
|
'news_source',
|
||||||
|
'news_link',
|
||||||
|
'news_issue_date',
|
||||||
|
'news_views_num',
|
||||||
|
'news_sort',
|
||||||
|
'news_content'
|
||||||
|
])
|
||||||
|
->where('news_id', $params['news_id'])
|
||||||
|
->find();
|
||||||
|
|
||||||
|
return msg(0, '获取新闻详情成功!', ['data' => $find]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user