|
...
|
...
|
@@ -25,10 +25,12 @@ class NewsController extends BaseController |
|
|
|
* @author :liyuhang
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
public function lists(NewsModel $news,NewsCategoryLogic $newsCategoryLogic){
|
|
|
|
$this->map = $this->searchParam();
|
|
|
|
$lists = $news->lists($this->map,$this->page,$this->row,$this->order = 'sort',
|
|
|
|
['id','category_id','operator_id','status','created_at','updated_at','image','name','sort','url']);
|
|
|
|
public function lists(NewsModel $news){
|
|
|
|
$filed = ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url'];
|
|
|
|
$this->order = 'sort';
|
|
|
|
$query = $news->orderBy($this->order ,'desc');
|
|
|
|
$query = $this->searchParam($query);
|
|
|
|
$lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page);
|
|
|
|
if(!empty($lists) && !empty($lists['list'])){
|
|
|
|
//获取当前项目的所有分类
|
|
|
|
$data = $this->getCategoryList();
|
|
...
|
...
|
@@ -51,12 +53,18 @@ class NewsController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/14 10:01
|
|
|
|
*/
|
|
|
|
public function searchParam(){
|
|
|
|
$this->map['project_id'] = $this->user['project_id'];
|
|
|
|
if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
|
|
|
|
$this->map['category_id'] = ['like','%,'.$this->map['category_id'].',%'];
|
|
|
|
}
|
|
|
|
return $this->map;
|
|
|
|
public function searchParam(&$query){
|
|
|
|
$query = $query->where('project_id',$this->user['project_id']);
|
|
|
|
if (isset($this->map['category_id']) && !empty($this->map['category_id'])) {
|
|
|
|
$str = [];
|
|
|
|
$this->getLastLevelIds($this->map['category_id'],$str);
|
|
|
|
$query->where(function ($subQuery) use ($str) {
|
|
|
|
foreach ($str as $v) {
|
|
|
|
$subQuery->orWhereRaw("FIND_IN_SET(?, category_id) > 0", [$v]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|