p2 project
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.

55 lines
1.7 KiB

<?php
namespace app\home\service;
use app\model\InformationArticleModel;
class DocumentService extends BaseHomeService
{
// 获取股票资讯文章
public function informationArticleList($param)
{
try {
if (empty($param['page']) || empty($param['limit'])) {
return $this->toData('400', lang('parameter_error'));
}
$where = ['state'=>1];
if (isset($param['type'])) {
$where['type'] = $param['type'];
}
$list = InformationArticleModel::where($where)->order('id', 'desc')->paginate([
'list_rows' => $param['limit'],
'page' => $param['page'],
]);
return $this->toData('0', 'Successful', [
'list' => $list->items(),
'total' => $list->total(),
'page' => $list->currentPage(),
'last_page' => $list->lastPage(),
]);
} catch (\Exception $d) {
return $this->toData('500', 'The system is busy');
}
}
// 获取一条资讯详情
public function informationArticleDetails($param)
{
try {
if (empty($param['id'])) {
return $this->toData('400', lang('parameter_error'));
}
$info = InformationArticleModel::where(['id'=>$param['id']])->find();
if (empty($info)) {
return $this->toData('400', lang('data_empty'));
}
$res = $info->toArray();
return $this->toData('0', 'Successful', $res);
} catch (\Exception $d) {
return $this->toData('500', 'The system is busy');
}
}
}