first commit

This commit is contained in:
Your Name
2026-01-19 14:19:22 +08:00
commit fe2d9c1868
4777 changed files with 665503 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\api\lists\article;
use app\api\lists\BaseApiDataLists;
use app\common\enum\YesNoEnum;
use app\common\lists\ListsSearchInterface;
use app\common\model\article\Article;
use app\common\service\{FileService,UtilsService};
/**
* 文章列表
* Class ArticleLists
* @package app\api\lists\article
*/
class ArticleLists extends BaseApiDataLists implements ListsSearchInterface
{
/**
* @notes 搜索条件
* @return \string[][]
* @author 段誉
* @date 2022/9/16 18:54
*/
public function setSearch(): array
{
return [
'=' => ['cid']
];
}
/**
* @notes 自定查询条件
* @return array
* @author 段誉
* @date 2022/10/25 16:53
*/
public function queryWhere()
{
$where[] = ['is_show', '=', 1];
return $where;
}
/**
* @notes 获取文章列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/9/16 18:55
*/
public function lists(): array
{
$lang = $this->params['lang'];
$field = 'id,title,image,langs';
$result = Article::field($field)
->where($this->queryWhere())
->where($this->searchWhere)
->order(['sort' => 'desc', 'id' => 'desc'])
->limit($this->limitOffset, $this->limitLength)
->select()->toArray();
foreach ($result as &$article) {
//多语言替换
$data = UtilsService::get_langs_data($article['langs'],$lang);
$data_title = '';
if(count($data) > 0){
$data_title = $data['title'];
}
$article['title'] = $data_title;
unset($article['langs']);
}
return $result;
}
/**
* @notes 获取文章数量
* @return int
* @author 段誉
* @date 2022/9/16 18:55
*/
public function count(): int
{
return Article::where($this->searchWhere)
->where($this->queryWhere())
->count();
}
}