|
@@ -9,7 +9,6 @@ use App\Model\Web;
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
use App\Tools\Result;
|
|
use App\Tools\Result;
|
|
use Hyperf\DbConnection\Db;
|
|
use Hyperf\DbConnection\Db;
|
|
-use PhpParser\Node\Expr\Clone_;
|
|
|
|
|
|
|
|
#[RpcService(name: "FooterService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
#[RpcService(name: "FooterService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
class FooterService implements FooterServiceInterface
|
|
class FooterService implements FooterServiceInterface
|
|
@@ -28,24 +27,25 @@ class FooterService implements FooterServiceInterface
|
|
if(isset($data['name'])){
|
|
if(isset($data['name'])){
|
|
array_push($where, ['footer_category.name','like','%'.$data['name'].'%']);
|
|
array_push($where, ['footer_category.name','like','%'.$data['name'].'%']);
|
|
}
|
|
}
|
|
- $query = FooterCategory::when(!empty($where), function ($query) use ($where) {
|
|
|
|
- $query->where($where)
|
|
|
|
- ->leftJoin("website","website.id","footer_category.website_id")
|
|
|
|
- ->select("footer_category.*","website.website_name","website.id as website_id");
|
|
|
|
- });
|
|
|
|
|
|
+ $query = FooterCategory::query();
|
|
|
|
+ if (!empty($where)) {
|
|
|
|
+ $query->where($where);
|
|
|
|
+ }
|
|
$count = $query->count();
|
|
$count = $query->count();
|
|
- $query = clone $query;
|
|
|
|
- $rep = $query
|
|
|
|
- ->limit($data['pageSize'])->offset(($data['page']-1)*$data['pageSize'])->orderBy("updated_at","desc")
|
|
|
|
- ->get();
|
|
|
|
- // $count = $query->count();
|
|
|
|
|
|
+ $rep = $query->leftJoin("website", "website.id", "footer_category.website_id")
|
|
|
|
+ ->select("footer_category.*", "website.website_name", "website.id as website_id")
|
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
|
+ ->limit($data['pageSize'])
|
|
|
|
+ ->orderByDesc("updated_at")
|
|
|
|
+ ->get();
|
|
|
|
+
|
|
// var_dump($where);
|
|
// var_dump($where);
|
|
$result = [];
|
|
$result = [];
|
|
$result = [
|
|
$result = [
|
|
'rows'=>$rep,
|
|
'rows'=>$rep,
|
|
'count'=>$count
|
|
'count'=>$count
|
|
];
|
|
];
|
|
- if($count == 0){
|
|
|
|
|
|
+ if(empty($result)){
|
|
return Result::error("没有查到相关数据!");
|
|
return Result::error("没有查到相关数据!");
|
|
}
|
|
}
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
@@ -103,7 +103,7 @@ class FooterService implements FooterServiceInterface
|
|
'web'=>$web
|
|
'web'=>$web
|
|
];
|
|
];
|
|
}else{
|
|
}else{
|
|
- $all_categories = FooterCategory::where('website_id',$data['website_id'])->pluck('name')->toArray();
|
|
|
|
|
|
+ $all_categories = FooterCategory::where('website_id',$data['website_id'])->where('id','!=',$data['id'])->pluck('name')->toArray();
|
|
// 检查修改后的数据是否与已有数据重复
|
|
// 检查修改后的数据是否与已有数据重复
|
|
if (in_array($data['name'], $all_categories)) {
|
|
if (in_array($data['name'], $all_categories)) {
|
|
return Result::error("修改后的底部导航名称已存在!");
|
|
return Result::error("修改后的底部导航名称已存在!");
|
|
@@ -207,6 +207,7 @@ class FooterService implements FooterServiceInterface
|
|
array_push($where, ['con_title','like','%'.$data['con_title'].'%']);
|
|
array_push($where, ['con_title','like','%'.$data['con_title'].'%']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ $count = FooterContent::where($where)->count();
|
|
$rep = FooterContent::where($where)
|
|
$rep = FooterContent::where($where)
|
|
->leftJoin('footer_category','footer_category.id','fcat_id')
|
|
->leftJoin('footer_category','footer_category.id','fcat_id')
|
|
->select('footer_content.*','footer_category.type')
|
|
->select('footer_content.*','footer_category.type')
|
|
@@ -214,8 +215,8 @@ class FooterService implements FooterServiceInterface
|
|
->offset(($data['page']-1)*$data['pageSize'])
|
|
->offset(($data['page']-1)*$data['pageSize'])
|
|
->orderBy("updated_at","desc")
|
|
->orderBy("updated_at","desc")
|
|
->get();
|
|
->get();
|
|
- $count = FooterContent::where($where)->count();
|
|
|
|
- if($count == 0){
|
|
|
|
|
|
+
|
|
|
|
+ if(empty($rep)){
|
|
return Result::error("没有查到相关数据!");
|
|
return Result::error("没有查到相关数据!");
|
|
}else{
|
|
}else{
|
|
$result = [
|
|
$result = [
|