|
@@ -13,24 +13,34 @@ class NewsService implements NewsServiceInterface
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
+ * 获取导航池列表
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
public function getCategoryList(array $data): array
|
|
|
{
|
|
|
- $where = [
|
|
|
- ['name','like','%'.$data['keyWord'].'%'],
|
|
|
- ['website_id','=',$data['website_id']],
|
|
|
- ['pid','=',$data['pid']??0]
|
|
|
- ];
|
|
|
- $rep = Category::where($where)->limit($data['pageSize'])->orderBy("sort","asc")->offset(($data['page']-1)*$data['pageSize'])->get();
|
|
|
+ $where = [];
|
|
|
+ if(isset($data['name']) && $data['name']){
|
|
|
+ array_push($where, ['category.name','like','%'.$data['name'].'%']);
|
|
|
+ }
|
|
|
+ if(isset($data['department_id']) && $data['department_id']){
|
|
|
+ array_push($where, ['category.department_id','=',$data['department_id']]);
|
|
|
+ }
|
|
|
+ if(isset($data['city_id']) && $data['city_id']){
|
|
|
+ array_push($where, ['category.city_id','=',$data['city_id']]);
|
|
|
+ }
|
|
|
+ $rep = Category::where($where)
|
|
|
+ ->leftJoin('district','category.city_id','district.id')
|
|
|
+ ->leftJoin('department','category.department_id','department.id')
|
|
|
+ ->select("category.*","district.name as city_name","department.name as department_name")
|
|
|
+ ->limit($data['pageSize'])->orderBy("category.sort","desc")->offset(($data['page']-1)*$data['pageSize'])->get();
|
|
|
$count = Category::where($where)->count();
|
|
|
$data = [
|
|
|
'rows'=>$rep->toArray(),
|
|
|
'count'=>$count
|
|
|
];
|
|
|
if(empty($rep->toArray())){
|
|
|
- return Result::error("没有栏目数据");
|
|
|
+ return Result::error("没有导航池数据");
|
|
|
}
|
|
|
return Result::success($data);
|
|
|
}
|
|
@@ -41,7 +51,14 @@ class NewsService implements NewsServiceInterface
|
|
|
*/
|
|
|
public function categoryList(array $data): array
|
|
|
{
|
|
|
- $result = Category::where($data)->get();
|
|
|
+ $where[] = [
|
|
|
+ 'pid','=',$data['pid']
|
|
|
+ ];
|
|
|
+ if(isset($data['name'])){
|
|
|
+ array_push($where, ['category.name','like','%'.$data['name'].'%']);
|
|
|
+ }
|
|
|
+ var_dump($where);
|
|
|
+ $result = Category::where($where)->get();
|
|
|
if(empty($result)){
|
|
|
return Result::error("没有栏目数据");
|
|
|
}
|
|
@@ -100,6 +117,23 @@ class NewsService implements NewsServiceInterface
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取导航池信息
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getCategoryInfo(array $data): array
|
|
|
+ {
|
|
|
+ $where = [
|
|
|
+ 'id'=>$data['id']
|
|
|
+ ];
|
|
|
+ $result = Category::where($where)->first();
|
|
|
+ if($result){
|
|
|
+ return Result::success($result);
|
|
|
+ }else{
|
|
|
+ return Result::error("更新失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* @param array $data
|
|
|
* @return array
|
|
@@ -107,14 +141,25 @@ class NewsService implements NewsServiceInterface
|
|
|
public function getArticleList(array $data): array
|
|
|
{
|
|
|
$where= [];
|
|
|
- if(isset($data['keyWord'])){
|
|
|
- $where[] = ['article.title','like','%'.$data['keyWord'].'%'];
|
|
|
- $where[] = ['article.status','!=','5'];
|
|
|
+ if(isset($data['title']) && $data['title']){
|
|
|
+ array_push($where,['article.title','like','%'.$data['title'].'%']);
|
|
|
+ }
|
|
|
+ if(isset($data['category_name']) && $data['category_name']){
|
|
|
+ array_push($where,['category.name','=',$data['category_name']]);
|
|
|
+ }
|
|
|
+ if(isset($data['author']) && $data['author']){
|
|
|
+ array_push($where,['article.author','=',$data['author']]);
|
|
|
+ }
|
|
|
+ if(isset($data['islink']) && $data['islink']){
|
|
|
+ array_push($where,['article.islink','=',$data['islink']]);
|
|
|
+ }
|
|
|
+ if(isset($data['status']) && $data['status']){
|
|
|
+ array_push($where,['article.status','=',$data['status']]);
|
|
|
}
|
|
|
$rep = Article::where($where)
|
|
|
+ ->whereNotIn('status',[404])
|
|
|
->leftJoin('category','article.catid','category.id')
|
|
|
- ->leftJoin("article_data","article.id","article_data.article_id")
|
|
|
- ->select("article.*","category.name","article_data.content")
|
|
|
+ ->select("article.*","category.name as category_name")
|
|
|
->orderBy("article.id","desc")
|
|
|
->limit($data['pageSize'])
|
|
|
->offset(($data['page']-1)*$data['pageSize'])->get();
|
|
@@ -138,8 +183,6 @@ class NewsService implements NewsServiceInterface
|
|
|
Db::beginTransaction();
|
|
|
try{
|
|
|
|
|
|
- $data['cat_arr_id'] = isset($data['cat_arr_id'])?json_encode($data['cat_arr_id']):'';
|
|
|
- $data['tag'] = isset($data['tag'])?json_encode($data['tag']):'';
|
|
|
$articleData = $data;
|
|
|
unset($articleData['content']);
|
|
|
$id = Article::insertGetId($articleData);
|
|
@@ -164,7 +207,7 @@ class NewsService implements NewsServiceInterface
|
|
|
*/
|
|
|
public function delArticle(array $data): array
|
|
|
{
|
|
|
- $result = Article::where($data)->update(['status'=>5]);
|
|
|
+ $result = Article::where($data)->update(['status'=>404]);
|
|
|
if(!$result){
|
|
|
return Result::error("删除失败");
|
|
|
}
|
|
@@ -202,6 +245,20 @@ class NewsService implements NewsServiceInterface
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新资讯状态
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function upArticleStatus(array $data):array
|
|
|
+ {
|
|
|
+ $result = Article::where(['id'=>$data['id']])->update($data);
|
|
|
+ if($result){
|
|
|
+ return Result::success();
|
|
|
+ }else{
|
|
|
+ return Result::error("更新状态失败",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* @param array $data
|
|
|
* @return array
|