|
@@ -29,6 +29,7 @@ use Carbon\Carbon;
|
|
use App\Model\WebsiteCategory;
|
|
use App\Model\WebsiteCategory;
|
|
use App\Model\WebsiteGroup;
|
|
use App\Model\WebsiteGroup;
|
|
use function PHPUnit\Framework\isNull;
|
|
use function PHPUnit\Framework\isNull;
|
|
|
|
+use Overtrue\Pinyin\Pinyin;
|
|
|
|
|
|
#[RpcService(name: "WebsiteService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
#[RpcService(name: "WebsiteService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
class WebsiteService implements WebsiteServiceInterface
|
|
class WebsiteService implements WebsiteServiceInterface
|
|
@@ -95,7 +96,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
'website_column_arr_id' => $data['website_column_arr_id'],
|
|
'website_column_arr_id' => $data['website_column_arr_id'],
|
|
// 'city_arr_id'=>$data['city_arr_id']??[0],
|
|
// 'city_arr_id'=>$data['city_arr_id']??[0],
|
|
'template_id' => $data['template_id'] ?? 0,
|
|
'template_id' => $data['template_id'] ?? 0,
|
|
- 'suffix' => $data['suffix'] ??"",
|
|
|
|
|
|
+ 'suffix' => $data['suffix'] ?? "",
|
|
];
|
|
];
|
|
$result = Website::insertGetId($insertData);
|
|
$result = Website::insertGetId($insertData);
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
@@ -125,9 +126,9 @@ class WebsiteService implements WebsiteServiceInterface
|
|
'website_column_arr_id' => $data['website_column_arr_id'],
|
|
'website_column_arr_id' => $data['website_column_arr_id'],
|
|
// 'city_arr_id'=>$data['city_arr_id']??[0],
|
|
// 'city_arr_id'=>$data['city_arr_id']??[0],
|
|
'template_id' => $data['template_id'] ?? 0,
|
|
'template_id' => $data['template_id'] ?? 0,
|
|
- 'suffix' => $data['suffix'] ??"",
|
|
|
|
|
|
+ 'suffix' => $data['suffix'] ?? "",
|
|
];
|
|
];
|
|
- var_dump("=========:",$insertData);
|
|
|
|
|
|
+ var_dump("=========:", $insertData);
|
|
$result = Website::where('id', $id)->update($insertData);
|
|
$result = Website::where('id', $id)->update($insertData);
|
|
var_dump("更新站点", $result);
|
|
var_dump("更新站点", $result);
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
@@ -543,64 +544,64 @@ class WebsiteService implements WebsiteServiceInterface
|
|
public function selectWebsiteDepartment(array $data): array
|
|
public function selectWebsiteDepartment(array $data): array
|
|
{
|
|
{
|
|
|
|
|
|
- $depart = Department::where('pid',0)->orderBy('id','asc')->get();
|
|
|
|
- if(isset($data['keyword']) && !empty($data['keyword'])){
|
|
|
|
- $departments= Department::where('name', 'like', '%' . $data['keyword'] . '%')->get();
|
|
|
|
- if(empty($departments)){
|
|
|
|
- $result['message']="未查询到与此相关职能部门";
|
|
|
|
- }else{
|
|
|
|
- $count = Department::where('name','like',"%{$data['keyword']}%")->count();
|
|
|
|
|
|
+ $depart = Department::where('pid', 0)->orderBy('id', 'asc')->get();
|
|
|
|
+ if (isset($data['keyword']) && !empty($data['keyword'])) {
|
|
|
|
+ $departments = Department::where('name', 'like', '%' . $data['keyword'] . '%')->get();
|
|
|
|
+ if (empty($departments)) {
|
|
|
|
+ $result['message'] = "未查询到与此相关职能部门";
|
|
|
|
+ } else {
|
|
|
|
+ $count = Department::where('name', 'like', "%{$data['keyword']}%")->count();
|
|
$m = [
|
|
$m = [
|
|
- 'department'=>$depart,
|
|
|
|
- 'type'=>$departments,
|
|
|
|
- 'count'=>$count
|
|
|
|
- ];
|
|
|
|
|
|
+ 'department' => $depart,
|
|
|
|
+ 'type' => $departments,
|
|
|
|
+ 'count' => $count,
|
|
|
|
+ ];
|
|
}
|
|
}
|
|
-
|
|
|
|
- $result['sele'] = $m;
|
|
|
|
- return Result::success($result['sele']);
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ $result['sele'] = $m;
|
|
|
|
+ return Result::success($result['sele']);
|
|
|
|
+
|
|
}
|
|
}
|
|
- $result=$depart;
|
|
|
|
- return Result::success($result);
|
|
|
|
|
|
+ $result = $depart;
|
|
|
|
+ return Result::success($result);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 搜索地区
|
|
* 搜索地区
|
|
- * @param array $data
|
|
|
|
- * @return array
|
|
|
|
- */
|
|
|
|
- public function selectWebsiteArea(array $data): array
|
|
|
|
- {
|
|
|
|
- $provinces=District::where('pid',0)->where('status',1)->orderBy('code')->get();
|
|
|
|
-
|
|
|
|
- if(isset($data['province'])){
|
|
|
|
- $province=District::where('pid',0)->where('status',1)->where('id',$data['province'])->orderBy('code')->get();
|
|
|
|
- $province=$province->toArray();
|
|
|
|
- if(!empty($province)){
|
|
|
|
- $citys=District::where('pid',$data['province'])->where('status',1)->orderBy('code')->get();
|
|
|
|
- if(!empty($citys) && isset($data['city']) && !empty($data['city'])){
|
|
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function selectWebsiteArea(array $data): array
|
|
|
|
+ {
|
|
|
|
+ $provinces = District::where('pid', 0)->where('status', 1)->orderBy('code')->get();
|
|
|
|
+
|
|
|
|
+ if (isset($data['province'])) {
|
|
|
|
+ $province = District::where('pid', 0)->where('status', 1)->where('id', $data['province'])->orderBy('code')->get();
|
|
|
|
+ $province = $province->toArray();
|
|
|
|
+ if (!empty($province)) {
|
|
|
|
+ $citys = District::where('pid', $data['province'])->where('status', 1)->orderBy('code')->get();
|
|
|
|
+ if (!empty($citys) && isset($data['city']) && !empty($data['city'])) {
|
|
// $province = $province->toArray();
|
|
// $province = $province->toArray();
|
|
$province_id = [];
|
|
$province_id = [];
|
|
foreach ($province as $val) {
|
|
foreach ($province as $val) {
|
|
array_push($province_id, $val['id']);
|
|
array_push($province_id, $val['id']);
|
|
}
|
|
}
|
|
// var_dump($province_id);
|
|
// var_dump($province_id);
|
|
- $city=District::whereIn('pid',$province_id)->where('status',1)->where('id',$data['city'])->orderBy('code')->get();
|
|
|
|
- if(!empty($city)){
|
|
|
|
- $city_id=[];
|
|
|
|
- foreach($city as $val){
|
|
|
|
- array_push($city_id,$val['id']);
|
|
|
|
|
|
+ $city = District::whereIn('pid', $province_id)->where('status', 1)->where('id', $data['city'])->orderBy('code')->get();
|
|
|
|
+ if (!empty($city)) {
|
|
|
|
+ $city_id = [];
|
|
|
|
+ foreach ($city as $val) {
|
|
|
|
+ array_push($city_id, $val['id']);
|
|
}
|
|
}
|
|
- $regions=District::whereIn('pid',$city_id)->where('status',1)->orderBy('code')->get();
|
|
|
|
-
|
|
|
|
- $result=[
|
|
|
|
- 'province' => $province,
|
|
|
|
- 'city' => $city,
|
|
|
|
- 'region' => $regions
|
|
|
|
- ];
|
|
|
|
- }else{
|
|
|
|
- return Result::error("未查询到此城市",0);
|
|
|
|
|
|
+ $regions = District::whereIn('pid', $city_id)->where('status', 1)->orderBy('code')->get();
|
|
|
|
+
|
|
|
|
+ $result = [
|
|
|
|
+ 'province' => $province,
|
|
|
|
+ 'city' => $city,
|
|
|
|
+ 'region' => $regions,
|
|
|
|
+ ];
|
|
|
|
+ } else {
|
|
|
|
+ return Result::error("未查询到此城市", 0);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
$result = [
|
|
$result = [
|
|
@@ -628,8 +629,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
public function getWebsiteModelCategory(array $data): array
|
|
public function getWebsiteModelCategory(array $data): array
|
|
{
|
|
{
|
|
// return Result::success($data);
|
|
// return Result::success($data);
|
|
- $website_id=[
|
|
|
|
- 'website_id' => $data['website_id']
|
|
|
|
|
|
+ $website_id = [
|
|
|
|
+ 'website_id' => $data['website_id'],
|
|
];
|
|
];
|
|
// 初始化 $pid 数组
|
|
// 初始化 $pid 数组
|
|
// $pid = [];
|
|
// $pid = [];
|
|
@@ -657,12 +658,12 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
|
|
|
// 执行查询
|
|
// 执行查询
|
|
$result = $query->get();
|
|
$result = $query->get();
|
|
- if(!empty($result)){
|
|
|
|
- return Result::success($result);
|
|
|
|
- }else{
|
|
|
|
- return Result::error("本网站暂无栏目",0);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (!empty($result)) {
|
|
|
|
+ return Result::success($result);
|
|
|
|
+ } else {
|
|
|
|
+ return Result::error("本网站暂无栏目", 0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取友情链接
|
|
* 获取友情链接
|
|
@@ -989,7 +990,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
];
|
|
];
|
|
$result = WebsiteCategory::where($where)->orderBy('sort', 'asc')->get();
|
|
$result = WebsiteCategory::where($where)->orderBy('sort', 'asc')->get();
|
|
$list = [];
|
|
$list = [];
|
|
- if($result){
|
|
|
|
|
|
+ if ($result) {
|
|
foreach ($result->toArray() as $val) {
|
|
foreach ($result->toArray() as $val) {
|
|
array_push($list, json_decode($val['category_arr_id']));
|
|
array_push($list, json_decode($val['category_arr_id']));
|
|
}
|
|
}
|
|
@@ -1010,82 +1011,81 @@ class WebsiteService implements WebsiteServiceInterface
|
|
{
|
|
{
|
|
Db::beginTransaction();
|
|
Db::beginTransaction();
|
|
try {
|
|
try {
|
|
- if($data['category_arr_id']){
|
|
|
|
- $oldCategoryList = WebsiteCategory::where(['website_id' => $data['website_id']])->get();
|
|
|
|
- if($oldCategoryList){
|
|
|
|
- $oldCategoryList = $oldCategoryList->toArray();
|
|
|
|
- $oldCategoryListIds = [];
|
|
|
|
- foreach ($oldCategoryList as $val) {
|
|
|
|
- array_push($oldCategoryListIds, $val['category_id']);
|
|
|
|
- }
|
|
|
|
- $newCategoryListIds = [];
|
|
|
|
- foreach ($data['category_arr_id'] as $v){
|
|
|
|
- array_push($newCategoryListIds, end($v));
|
|
|
|
- }
|
|
|
|
- $differenceIDS = array_merge(array_diff($oldCategoryListIds, $newCategoryListIds), array_diff($newCategoryListIds, $oldCategoryListIds));
|
|
|
|
- if($differenceIDS){
|
|
|
|
- foreach ($differenceIDS as $v){
|
|
|
|
- WebsiteCategory::where(['website_id' => $data['website_id'], 'category_id' => $v])->delete();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- foreach ($data['category_arr_id'] as $key => $value){
|
|
|
|
- $info = Category::where(['id' => end($value)])->first();
|
|
|
|
- $info = $info->toArray();
|
|
|
|
- // 假设 $data、$value 和 $info 是已经定义好的变量
|
|
|
|
- $attributes = [
|
|
|
|
- 'website_id' => $data['website_id'],
|
|
|
|
- 'category_id' => end($value)
|
|
|
|
- ];
|
|
|
|
|
|
+ if ($data['category_arr_id']) {
|
|
|
|
+ $oldCategoryList = WebsiteCategory::where(['website_id' => $data['website_id']])->get();
|
|
|
|
+ if ($oldCategoryList) {
|
|
|
|
+ $oldCategoryList = $oldCategoryList->toArray();
|
|
|
|
+ $oldCategoryListIds = [];
|
|
|
|
+ foreach ($oldCategoryList as $val) {
|
|
|
|
+ array_push($oldCategoryListIds, $val['category_id']);
|
|
|
|
+ }
|
|
|
|
+ $newCategoryListIds = [];
|
|
|
|
+ foreach ($data['category_arr_id'] as $v) {
|
|
|
|
+ array_push($newCategoryListIds, end($v));
|
|
|
|
+ }
|
|
|
|
+ $differenceIDS = array_merge(array_diff($oldCategoryListIds, $newCategoryListIds), array_diff($newCategoryListIds, $oldCategoryListIds));
|
|
|
|
+ if ($differenceIDS) {
|
|
|
|
+ foreach ($differenceIDS as $v) {
|
|
|
|
+ WebsiteCategory::where(['website_id' => $data['website_id'], 'category_id' => $v])->delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ foreach ($data['category_arr_id'] as $key => $value) {
|
|
|
|
+ $info = Category::where(['id' => end($value)])->first();
|
|
|
|
+ $info = $info->toArray();
|
|
|
|
+ // 假设 $data、$value 和 $info 是已经定义好的变量
|
|
|
|
+ $attributes = [
|
|
|
|
+ 'website_id' => $data['website_id'],
|
|
|
|
+ 'category_id' => end($value),
|
|
|
|
+ ];
|
|
// 先复制一份要更新或创建的数据
|
|
// 先复制一份要更新或创建的数据
|
|
- $values = [
|
|
|
|
- 'website_id' => $data['website_id'],
|
|
|
|
- 'name' => $info['name']?? '',
|
|
|
|
- 'alias' => $info['name']?? '',
|
|
|
|
- 'sort' => $info['sort']?? 0,
|
|
|
|
- 'pid' => $info['pid']?? 0,
|
|
|
|
- 'pid_arr' => $info['pid_arr']?? json_encode([]),
|
|
|
|
- 'seo_title' => $info['seo_title']?? "",
|
|
|
|
- 'seo_keywords' => $info['seo_keywords']?? "",
|
|
|
|
- 'seo_description' => $info['seo_description']?? "",
|
|
|
|
- 'is_url' => $info['is_url']?? 0,
|
|
|
|
- 'web_url' => $info['web_url']?? '',
|
|
|
|
- 'category_id' => end($value),
|
|
|
|
- 'category_arr_id' => $value? json_encode($value) : json_encode([])
|
|
|
|
- ];
|
|
|
|
|
|
+ $values = [
|
|
|
|
+ 'website_id' => $data['website_id'],
|
|
|
|
+ 'name' => $info['name'] ?? '',
|
|
|
|
+ 'alias' => $info['name'] ?? '',
|
|
|
|
+ 'sort' => $info['sort'] ?? 0,
|
|
|
|
+ 'pid' => $info['pid'] ?? 0,
|
|
|
|
+ 'pid_arr' => $info['pid_arr'] ?? json_encode([]),
|
|
|
|
+ 'seo_title' => $info['seo_title'] ?? "",
|
|
|
|
+ 'seo_keywords' => $info['seo_keywords'] ?? "",
|
|
|
|
+ 'seo_description' => $info['seo_description'] ?? "",
|
|
|
|
+ 'is_url' => $info['is_url'] ?? 0,
|
|
|
|
+ 'web_url' => $info['web_url'] ?? '',
|
|
|
|
+ 'category_id' => end($value),
|
|
|
|
+ 'category_arr_id' => $value ? json_encode($value) : json_encode([])
|
|
|
|
+ ];
|
|
// 检查数据库中是否已有该记录
|
|
// 检查数据库中是否已有该记录
|
|
- $existingRecord = WebsiteCategory::where($attributes)->first();
|
|
|
|
- if ($existingRecord && $existingRecord->name) {
|
|
|
|
- unset($values['name']);
|
|
|
|
- }
|
|
|
|
- if ($existingRecord && $existingRecord->sort>=0) {
|
|
|
|
- unset($values['sort']);
|
|
|
|
- }
|
|
|
|
- if ($existingRecord && $existingRecord->seo_title) {
|
|
|
|
- unset($values['seo_title']);
|
|
|
|
- }
|
|
|
|
- if ($existingRecord && $existingRecord->seo_keywords) {
|
|
|
|
- unset($values['seo_keywords']);
|
|
|
|
- }
|
|
|
|
- if ($existingRecord && $existingRecord->seo_description) {
|
|
|
|
- unset($values['seo_description']);
|
|
|
|
- }
|
|
|
|
- if ($existingRecord && $existingRecord->alias) {
|
|
|
|
- unset($values['alias']);
|
|
|
|
- }
|
|
|
|
|
|
+ $existingRecord = WebsiteCategory::where($attributes)->first();
|
|
|
|
+ if ($existingRecord && $existingRecord->name) {
|
|
|
|
+ unset($values['name']);
|
|
|
|
+ }
|
|
|
|
+ if ($existingRecord && $existingRecord->sort >= 0) {
|
|
|
|
+ unset($values['sort']);
|
|
|
|
+ }
|
|
|
|
+ if ($existingRecord && $existingRecord->seo_title) {
|
|
|
|
+ unset($values['seo_title']);
|
|
|
|
+ }
|
|
|
|
+ if ($existingRecord && $existingRecord->seo_keywords) {
|
|
|
|
+ unset($values['seo_keywords']);
|
|
|
|
+ }
|
|
|
|
+ if ($existingRecord && $existingRecord->seo_description) {
|
|
|
|
+ unset($values['seo_description']);
|
|
|
|
+ }
|
|
|
|
+ if ($existingRecord && $existingRecord->alias) {
|
|
|
|
+ unset($values['alias']);
|
|
|
|
+ }
|
|
// 执行 updateOrCreate 操作
|
|
// 执行 updateOrCreate 操作
|
|
- WebsiteCategory::updateOrCreate($attributes, $values);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ WebsiteCategory::updateOrCreate($attributes, $values);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
Db::commit();
|
|
Db::commit();
|
|
return Result::success();
|
|
return Result::success();
|
|
} catch (\Throwable $ex) {
|
|
} catch (\Throwable $ex) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
// var_dump($ex->getMessage());
|
|
// var_dump($ex->getMessage());
|
|
- return Result::error("修改失败".$ex->getMessage(), 0);
|
|
|
|
|
|
+ return Result::error("修改失败" . $ex->getMessage(), 0);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1166,16 +1166,48 @@ class WebsiteService implements WebsiteServiceInterface
|
|
*/
|
|
*/
|
|
public function upWebsiteCategoryones(array $data): array
|
|
public function upWebsiteCategoryones(array $data): array
|
|
{
|
|
{
|
|
|
|
+ //处理所有数据
|
|
|
|
+ //获取所有数据
|
|
|
|
+ // $result = WebsiteCategory::get();
|
|
|
|
+ // $result = $result->toArray();
|
|
|
|
+ // var_dump($result, '------------');
|
|
|
|
+ // $pinyin = new Pinyin();
|
|
|
|
+ // for ($i = 0; $i < count($result); $i++) {
|
|
|
|
+ // $result[$i]['alias_pinyin'] = $pinyin->permalink($result[$i]['alias'], '') . $result[$i]['category_id'];
|
|
|
|
+ // var_dump($result[$i]['alias_pinyin'], $i . '----------');
|
|
|
|
+ // //更新数据
|
|
|
|
+ // WebsiteCategory::where(['id' => $result[$i]['id']])->update(['alias_pinyin' => $result[$i]['alias_pinyin']]);
|
|
|
|
+ // //判断是否更新成功
|
|
|
|
+ // }
|
|
|
|
+ // var_dump($result, '--------222----');
|
|
|
|
+ // //更新数据
|
|
|
|
+ // // $result = WebsiteCategory::update($result);
|
|
|
|
+ // //判断是否更新成功
|
|
|
|
+ // if ($result) {
|
|
|
|
+ // return Result::success($result);
|
|
|
|
+ // } else {
|
|
|
|
+ // return Result::error("更新失败", 0);
|
|
|
|
+ // }
|
|
|
|
+ //处理所有数据
|
|
|
|
+
|
|
$where = [
|
|
$where = [
|
|
'website_id' => $data['website_id'],
|
|
'website_id' => $data['website_id'],
|
|
'category_id' => $data['category_id'],
|
|
'category_id' => $data['category_id'],
|
|
];
|
|
];
|
|
|
|
+ $alias = $data['alias'];
|
|
|
|
+ $pinyin = new Pinyin();
|
|
|
|
+ $alias_pinyin = $pinyin->permalink($alias, '');
|
|
|
|
+ //从WebsiteCategory取出alis ,并转成拼音存放到alias_pinyin
|
|
|
|
+ $result = WebsiteCategory::where($where)->first();
|
|
|
|
+ $result = $result->toArray();
|
|
|
|
+ $data['alias_pinyin'] = $pinyin->permalink($result['alias'], '') . $result['category_id'];
|
|
$result = WebsiteCategory::where($where)->update($data);
|
|
$result = WebsiteCategory::where($where)->update($data);
|
|
if ($result) {
|
|
if ($result) {
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
} else {
|
|
} else {
|
|
return Result::error("更新失败", 0);
|
|
return Result::error("更新失败", 0);
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1190,40 +1222,40 @@ class WebsiteService implements WebsiteServiceInterface
|
|
array_push($where, ['website_category.website_id', '=', $data['website_id']]);
|
|
array_push($where, ['website_category.website_id', '=', $data['website_id']]);
|
|
}
|
|
}
|
|
// if (isset($data['name']) && !empty($data['name'])) {
|
|
// if (isset($data['name']) && !empty($data['name'])) {
|
|
-// array_push($where, ['website_category.name', 'like', '%' . $data['name'] . '%']);
|
|
|
|
-// }
|
|
|
|
-// if (isset($data['alias']) && !empty($data['alias'])) {
|
|
|
|
-// array_push($where, ['website_category.alias', 'like', '%' . $data['alias'] . '%']);
|
|
|
|
-// }
|
|
|
|
-// if (isset($data['department_id']) && !empty($data['department_id'])) {
|
|
|
|
-// array_push($where, ['category.department_id', '=', $data['department_id']]);
|
|
|
|
-// }
|
|
|
|
-// if (isset($data['city_id']) && !empty($data['city_id'])) {
|
|
|
|
-// array_push($where, ['category.city_id', '=', $data['city_id']]);
|
|
|
|
-// }
|
|
|
|
|
|
+ // array_push($where, ['website_category.name', 'like', '%' . $data['name'] . '%']);
|
|
|
|
+ // }
|
|
|
|
+ // if (isset($data['alias']) && !empty($data['alias'])) {
|
|
|
|
+ // array_push($where, ['website_category.alias', 'like', '%' . $data['alias'] . '%']);
|
|
|
|
+ // }
|
|
|
|
+ // if (isset($data['department_id']) && !empty($data['department_id'])) {
|
|
|
|
+ // array_push($where, ['category.department_id', '=', $data['department_id']]);
|
|
|
|
+ // }
|
|
|
|
+ // if (isset($data['city_id']) && !empty($data['city_id'])) {
|
|
|
|
+ // array_push($where, ['category.city_id', '=', $data['city_id']]);
|
|
|
|
+ // }
|
|
$result = WebsiteCategory::where($where)
|
|
$result = WebsiteCategory::where($where)
|
|
// ->leftJoin("category", 'website_category.category_id', 'category.id')
|
|
// ->leftJoin("category", 'website_category.category_id', 'category.id')
|
|
-// ->leftJoin("department", 'category.department_id', 'department.id')
|
|
|
|
-// ->leftJoin("district", 'category.city_id', 'district.id')
|
|
|
|
-// ->select("website_category.*", "department.name as department_name", "district.name as city_name")
|
|
|
|
-// ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
|
- ->orderBy("sort","asc")
|
|
|
|
|
|
+ // ->leftJoin("department", 'category.department_id', 'department.id')
|
|
|
|
+ // ->leftJoin("district", 'category.city_id', 'district.id')
|
|
|
|
+ // ->select("website_category.*", "department.name as department_name", "district.name as city_name")
|
|
|
|
+ // ->limit($data['pageSize'])->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
|
+ ->orderBy("sort", "asc")
|
|
->get();
|
|
->get();
|
|
|
|
|
|
// $count = WebsiteCategory::where($where)
|
|
// $count = WebsiteCategory::where($where)
|
|
-// ->leftJoin("category", 'website_category.category_id', 'category.id')
|
|
|
|
-// ->leftJoin("department", 'category.department_id', 'department.id')
|
|
|
|
-// ->leftJoin("district", 'category.city_id', 'district.id')
|
|
|
|
-// ->count();
|
|
|
|
|
|
+ // ->leftJoin("category", 'website_category.category_id', 'category.id')
|
|
|
|
+ // ->leftJoin("department", 'category.department_id', 'department.id')
|
|
|
|
+ // ->leftJoin("district", 'category.city_id', 'district.id')
|
|
|
|
+ // ->count();
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
return Result::error("没有数据", 0);
|
|
return Result::error("没有数据", 0);
|
|
}
|
|
}
|
|
// $data = [
|
|
// $data = [
|
|
-// 'rows' => $result->toArray(),
|
|
|
|
-// 'count' => $count,
|
|
|
|
-// ];
|
|
|
|
|
|
+ // 'rows' => $result->toArray(),
|
|
|
|
+ // 'count' => $count,
|
|
|
|
+ // ];
|
|
if ($result) {
|
|
if ($result) {
|
|
- return Result::success( $result->toArray());
|
|
|
|
|
|
+ return Result::success($result->toArray());
|
|
} else {
|
|
} else {
|
|
return Result::error("查询失败", 0);
|
|
return Result::error("查询失败", 0);
|
|
}
|
|
}
|
|
@@ -1314,14 +1346,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
}
|
|
}
|
|
$website_foot = WebsiteTemplateInfo::where('website_id', $data['website_id'])->where('status', 2)->first();
|
|
$website_foot = WebsiteTemplateInfo::where('website_id', $data['website_id'])->where('status', 2)->first();
|
|
$website_head = Website::where('id', $data['website_id'])
|
|
$website_head = Website::where('id', $data['website_id'])
|
|
- ->select('id', 'website_name', 'logo', 'title', 'keywords', 'description','suffix','website_url')->first();
|
|
|
|
|
|
+ ->select('id', 'website_name', 'logo', 'title', 'keywords', 'description', 'suffix', 'website_url')->first();
|
|
if (empty($website_foot)) {
|
|
if (empty($website_foot)) {
|
|
return Result::error("暂无底部基础信息", 0);
|
|
return Result::error("暂无底部基础信息", 0);
|
|
}
|
|
}
|
|
if (empty($website_head)) {
|
|
if (empty($website_head)) {
|
|
return Result::error("暂无头部基础信息", 0);
|
|
return Result::error("暂无头部基础信息", 0);
|
|
}
|
|
}
|
|
- $website_head['website_url'] = $website_head['website_url']?json_decode($website_head['website_url']):[];
|
|
|
|
|
|
+ $website_head['website_url'] = $website_head['website_url'] ? json_decode($website_head['website_url']) : [];
|
|
$result = [
|
|
$result = [
|
|
'website_foot' => $website_foot,
|
|
'website_foot' => $website_foot,
|
|
'website_head' => $website_head,
|
|
'website_head' => $website_head,
|
|
@@ -1495,8 +1527,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
return Result::error("导航id错误", 0);
|
|
return Result::error("导航id错误", 0);
|
|
}
|
|
}
|
|
$result = Category::where('id', $data['catid'])->first();
|
|
$result = Category::where('id', $data['catid'])->first();
|
|
- $result['website_name'] = $website['website_name']??'';
|
|
|
|
- $result['suffix'] = $website['suffix']??'';
|
|
|
|
|
|
+ $result['website_name'] = $website['website_name'] ?? '';
|
|
|
|
+ $result['suffix'] = $website['suffix'] ?? '';
|
|
}
|
|
}
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
return Result::error("暂无导航", 0);
|
|
return Result::error("暂无导航", 0);
|
|
@@ -1515,14 +1547,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
if (empty($website)) {
|
|
if (empty($website)) {
|
|
return Result::error("暂无该网站", 0);
|
|
return Result::error("暂无该网站", 0);
|
|
}
|
|
}
|
|
- $category = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['category_id'])->first();
|
|
|
|
|
|
+ $category = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['category_id'])->first();
|
|
if (empty($category)) {
|
|
if (empty($category)) {
|
|
- return Result::error("暂无此导航",0);
|
|
|
|
|
|
+ return Result::error("暂无此导航", 0);
|
|
}
|
|
}
|
|
- $category['children_count'] = WebsiteCategory::where('website_id',$data['website_id'])->where('pid',$data['category_id'])->count();
|
|
|
|
|
|
+ $category['children_count'] = WebsiteCategory::where('website_id', $data['website_id'])->where('pid', $data['category_id'])->count();
|
|
return Result::success($category);
|
|
return Result::success($category);
|
|
- }else{
|
|
|
|
- return Result::error("参数错误",0);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ return Result::error("参数错误", 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|