|
@@ -1,4 +1,5 @@
|
|
<?php
|
|
<?php
|
|
|
|
+
|
|
namespace App\JsonRpc;
|
|
namespace App\JsonRpc;
|
|
|
|
|
|
use App\Model\Article;
|
|
use App\Model\Article;
|
|
@@ -91,14 +92,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
'website_name' => $data['website_name'],
|
|
'website_name' => $data['website_name'],
|
|
'logo' => $data['logo'] ?? '',
|
|
'logo' => $data['logo'] ?? '',
|
|
'website_url' => $data['website_url'] ?? '',
|
|
'website_url' => $data['website_url'] ?? '',
|
|
-// 'city_id'=>$data['city_id']??0,
|
|
|
|
|
|
+ // 'city_id'=>$data['city_id']??0,
|
|
'website_column_id' => $data['website_column_id'],
|
|
'website_column_id' => $data['website_column_id'],
|
|
'title' => $data['title'] ?? '',
|
|
'title' => $data['title'] ?? '',
|
|
'keywords' => $data['keywords'] ?? '',
|
|
'keywords' => $data['keywords'] ?? '',
|
|
'description' => $data['description'] ?? '',
|
|
'description' => $data['description'] ?? '',
|
|
'status' => $data['status'] ?? 1,
|
|
'status' => $data['status'] ?? 1,
|
|
'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'] ?? "",
|
|
];
|
|
];
|
|
@@ -121,14 +122,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
'website_name' => $data['website_name'],
|
|
'website_name' => $data['website_name'],
|
|
'logo' => $data['logo'] ?? '',
|
|
'logo' => $data['logo'] ?? '',
|
|
'website_url' => $data['website_url'] ?? '',
|
|
'website_url' => $data['website_url'] ?? '',
|
|
-// 'city_id'=>$data['city_id']??0,
|
|
|
|
|
|
+ // 'city_id'=>$data['city_id']??0,
|
|
'website_column_id' => $data['website_column_id'],
|
|
'website_column_id' => $data['website_column_id'],
|
|
'title' => $data['title'] ?? '',
|
|
'title' => $data['title'] ?? '',
|
|
'keywords' => $data['keywords'] ?? '',
|
|
'keywords' => $data['keywords'] ?? '',
|
|
'description' => $data['description'] ?? '',
|
|
'description' => $data['description'] ?? '',
|
|
-// 'status' => $data['status'] ?? 0,
|
|
|
|
|
|
+ // 'status' => $data['status'] ?? 0,
|
|
'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'] ?? "",
|
|
];
|
|
];
|
|
@@ -175,7 +176,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
} else {
|
|
} else {
|
|
return Result::success($result->toArray());
|
|
return Result::success($result->toArray());
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -190,7 +190,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
} else {
|
|
} else {
|
|
return Result::success($result->toArray());
|
|
return Result::success($result->toArray());
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -535,7 +534,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
return Result::error("请选择广告位!", 0);
|
|
return Result::error("请选择广告位!", 0);
|
|
}
|
|
}
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -563,7 +561,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
|
|
|
$result['sele'] = $m;
|
|
$result['sele'] = $m;
|
|
return Result::success($result['sele']);
|
|
return Result::success($result['sele']);
|
|
-
|
|
|
|
}
|
|
}
|
|
$result = $depart;
|
|
$result = $depart;
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
@@ -605,7 +602,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
$pidQuery = WebsiteCategory::where($website_id)
|
|
$pidQuery = WebsiteCategory::where($website_id)
|
|
->where('pid', '!=', 0)
|
|
->where('pid', '!=', 0)
|
|
->orderBy('sort')
|
|
->orderBy('sort')
|
|
- ->select('pid','category_id','alias');
|
|
|
|
|
|
+ ->select('pid', 'category_id', 'alias');
|
|
$pid = $pidQuery->pluck('pid');
|
|
$pid = $pidQuery->pluck('pid');
|
|
$pid = array_values(array_unique($pid->toArray()));
|
|
$pid = array_values(array_unique($pid->toArray()));
|
|
|
|
|
|
@@ -642,7 +639,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
} else {
|
|
} else {
|
|
return Result::error("本网站暂无栏目", 0);
|
|
return Result::error("本网站暂无栏目", 0);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取友情链接
|
|
* 获取友情链接
|
|
@@ -710,7 +707,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
->get();
|
|
->get();
|
|
$res['article'] = $article;
|
|
$res['article'] = $article;
|
|
return Result::success($res);
|
|
return Result::success($res);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return [];
|
|
return [];
|
|
@@ -1072,10 +1068,9 @@ class WebsiteService implements WebsiteServiceInterface
|
|
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);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1158,28 +1153,26 @@ class WebsiteService implements WebsiteServiceInterface
|
|
{
|
|
{
|
|
//处理所有数据
|
|
//处理所有数据
|
|
//获取所有数据
|
|
//获取所有数据
|
|
- // $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);
|
|
|
|
- // }
|
|
|
|
|
|
+ if (isset($data['all']) && $data['all'] == 'all') {
|
|
|
|
+ $result = WebsiteCategory::get();
|
|
|
|
+ $result = $result->toArray();
|
|
|
|
+ var_dump($result, '------------');
|
|
|
|
+ $pinyin = new Pinyin();
|
|
|
|
+ $letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
|
|
+ for ($i = 0; $i < count($result); $i++) {
|
|
|
|
+ $randss = substr(str_shuffle($letters), 0, 4);
|
|
|
|
+ $result[$i]['alias_pinyin'] = $pinyin->permalink($result[$i]['alias'], '') . $randss;
|
|
|
|
+ var_dump($result[$i]['alias_pinyin'], $i . '----------');
|
|
|
|
+ WebsiteCategory::where(['id' => $result[$i]['id']])->update(['alias_pinyin' => $result[$i]['alias_pinyin']]);
|
|
|
|
+ }
|
|
|
|
+ var_dump($result, '--------222----');
|
|
|
|
+ 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'],
|
|
@@ -1190,14 +1183,19 @@ class WebsiteService implements WebsiteServiceInterface
|
|
//从WebsiteCategory取出alis ,并转成拼音存放到alias_pinyin
|
|
//从WebsiteCategory取出alis ,并转成拼音存放到alias_pinyin
|
|
$result = WebsiteCategory::where($where)->first();
|
|
$result = WebsiteCategory::where($where)->first();
|
|
$result = $result->toArray();
|
|
$result = $result->toArray();
|
|
- $data['alias_pinyin'] = $pinyin->permalink($result['alias'], '') . $result['category_id'];
|
|
|
|
|
|
+ //+四位随机字母
|
|
|
|
+ $letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
|
|
+ // 打乱字符串顺序并截取前四位
|
|
|
|
+ $randss = substr(str_shuffle($letters), 0, 4);
|
|
|
|
+ if (!isset($data['alias_pinyin']) || $data['alias_pinyin'] == '') {
|
|
|
|
+ $data['alias_pinyin'] = $alias_pinyin . $randss;
|
|
|
|
+ }
|
|
$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);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1211,7 +1209,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
if (isset($data['website_id']) && !empty($data['website_id'])) {
|
|
if (isset($data['website_id']) && !empty($data['website_id'])) {
|
|
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'] . '%']);
|
|
// array_push($where, ['website_category.name', 'like', '%' . $data['name'] . '%']);
|
|
// }
|
|
// }
|
|
// if (isset($data['alias']) && !empty($data['alias'])) {
|
|
// if (isset($data['alias']) && !empty($data['alias'])) {
|
|
@@ -1226,15 +1224,15 @@ class WebsiteService implements WebsiteServiceInterface
|
|
$result = WebsiteCategory::where($where)
|
|
$result = WebsiteCategory::where($where)
|
|
->leftJoin("category", 'website_category.category_id', 'category.id')
|
|
->leftJoin("category", 'website_category.category_id', 'category.id')
|
|
->select("website_category.*", "category.name as name")
|
|
->select("website_category.*", "category.name as name")
|
|
-// ->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'])
|
|
|
|
|
|
+ // ->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")
|
|
->orderBy("sort", "asc")
|
|
->get();
|
|
->get();
|
|
|
|
|
|
-// $count = WebsiteCategory::where($where)
|
|
|
|
|
|
+ // $count = 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("department", 'category.department_id', 'department.id')
|
|
// ->leftJoin("district", 'category.city_id', 'district.id')
|
|
// ->leftJoin("district", 'category.city_id', 'district.id')
|
|
@@ -1242,7 +1240,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
return Result::error("没有数据", 0);
|
|
return Result::error("没有数据", 0);
|
|
}
|
|
}
|
|
-// $data = [
|
|
|
|
|
|
+ // $data = [
|
|
// 'rows' => $result->toArray(),
|
|
// 'rows' => $result->toArray(),
|
|
// 'count' => $count,
|
|
// 'count' => $count,
|
|
// ];
|
|
// ];
|
|
@@ -1251,7 +1249,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
} else {
|
|
} else {
|
|
return Result::error("查询失败", 0);
|
|
return Result::error("查询失败", 0);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1352,7 +1349,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
'website_head' => $website_head,
|
|
'website_head' => $website_head,
|
|
];
|
|
];
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
-
|
|
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* 获取网站底部导航
|
|
* 获取网站底部导航
|
|
@@ -1546,11 +1542,11 @@ class WebsiteService implements WebsiteServiceInterface
|
|
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();
|
|
|
|
- $parent = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$category['pid'])->select('category_id as parent_id','alias as parent_name','aLIas_pinyin')->first();
|
|
|
|
- $category['parent_id'] = $parent['parent_id']?? '';
|
|
|
|
- $category['parent_pinyin'] = $parent['aLIas_pinyin']?? '';
|
|
|
|
- $category['parent_name'] = $parent['parent_name']?? '';
|
|
|
|
|
|
+ $category['children_count'] = WebsiteCategory::where('website_id', $data['website_id'])->where('pid', $data['category_id'])->count();
|
|
|
|
+ $parent = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $category['pid'])->select('category_id as parent_id', 'alias as parent_name', 'aLIas_pinyin')->first();
|
|
|
|
+ $category['parent_id'] = $parent['parent_id'] ?? '';
|
|
|
|
+ $category['parent_pinyin'] = $parent['aLIas_pinyin'] ?? '';
|
|
|
|
+ $category['parent_name'] = $parent['parent_name'] ?? '';
|
|
return Result::success($category);
|
|
return Result::success($category);
|
|
} else {
|
|
} else {
|
|
return Result::error("参数错误", 0);
|
|
return Result::error("参数错误", 0);
|
|
@@ -1843,7 +1839,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
$query->whereJsonContains('template_img', ['value' => $value]);
|
|
$query->whereJsonContains('template_img', ['value' => $value]);
|
|
}
|
|
}
|
|
})->count();
|
|
})->count();
|
|
-
|
|
|
|
}
|
|
}
|
|
if (empty($rep) || $rep->count() == 0) {
|
|
if (empty($rep) || $rep->count() == 0) {
|
|
return Result::error("没有查找到相关数据!", 0);
|
|
return Result::error("没有查找到相关数据!", 0);
|
|
@@ -1885,7 +1880,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1909,7 +1903,6 @@ class WebsiteService implements WebsiteServiceInterface
|
|
} else {
|
|
} else {
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* 获取网站模板信息
|
|
* 获取网站模板信息
|
|
@@ -1943,7 +1936,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
'template_class.name',
|
|
'template_class.name',
|
|
'template_class.id as class_id',
|
|
'template_class.id as class_id',
|
|
'website_template_info.page_type',
|
|
'website_template_info.page_type',
|
|
- 'website_template_info.website_id')
|
|
|
|
|
|
+ 'website_template_info.website_id'
|
|
|
|
+ )
|
|
->first();
|
|
->first();
|
|
|
|
|
|
if (empty($result)) {
|
|
if (empty($result)) {
|
|
@@ -2061,28 +2055,27 @@ class WebsiteService implements WebsiteServiceInterface
|
|
public function upWebFootInfo(array $data): array
|
|
public function upWebFootInfo(array $data): array
|
|
{
|
|
{
|
|
// return Result::success($data);
|
|
// return Result::success($data);
|
|
- $website = Website::where('id',$data['website_id'])->first();
|
|
|
|
- if(empty($website)){
|
|
|
|
|
|
+ $website = Website::where('id', $data['website_id'])->first();
|
|
|
|
+ if (empty($website)) {
|
|
return Result::error("请输入正确的网站id!", 0);
|
|
return Result::error("请输入正确的网站id!", 0);
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
$web = $data['website_id'];
|
|
$web = $data['website_id'];
|
|
unset($data['website_id']);
|
|
unset($data['website_id']);
|
|
- $where = ['website_id'=>$web];
|
|
|
|
|
|
+ $where = ['website_id' => $web];
|
|
// return Result::success($data);
|
|
// return Result::success($data);
|
|
$result = WebsiteTemplateInfo::where($where)->first();
|
|
$result = WebsiteTemplateInfo::where($where)->first();
|
|
- if(empty($result)){
|
|
|
|
|
|
+ if (empty($result)) {
|
|
$data['website_id'] = $web;
|
|
$data['website_id'] = $web;
|
|
$result = WebsiteTemplateInfo::insertGetId($data);
|
|
$result = WebsiteTemplateInfo::insertGetId($data);
|
|
- // return Result::error("请先添加网站基础信息!",0);
|
|
|
|
- } else{
|
|
|
|
|
|
+ // return Result::error("请先添加网站基础信息!",0);
|
|
|
|
+ } else {
|
|
$result = WebsiteTemplateInfo::where($where)->update($data);
|
|
$result = WebsiteTemplateInfo::where($where)->update($data);
|
|
}
|
|
}
|
|
// $where = ['website_id'=>$data['website_id']];
|
|
// $where = ['website_id'=>$data['website_id']];
|
|
// unset($data['website_id']);
|
|
// unset($data['website_id']);
|
|
// $result = WebsiteTemplateInfo::updateOrInsert($where, $data);
|
|
// $result = WebsiteTemplateInfo::updateOrInsert($where, $data);
|
|
- if(empty($result)){
|
|
|
|
- return Result::error("修改失败!",0);
|
|
|
|
|
|
+ if (empty($result)) {
|
|
|
|
+ return Result::error("修改失败!", 0);
|
|
}
|
|
}
|
|
return Result::success($result);
|
|
return Result::success($result);
|
|
}
|
|
}
|
|
@@ -2111,7 +2104,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
return [
|
|
return [
|
|
'path' => "/{$item->alias_pinyin}/",
|
|
'path' => "/{$item->alias_pinyin}/",
|
|
'name' => $item->alias,
|
|
'name' => $item->alias,
|
|
- 'cid' => $item->category_id
|
|
|
|
|
|
+ 'cid' => $item->category_id,
|
|
];
|
|
];
|
|
})
|
|
})
|
|
->values()
|
|
->values()
|
|
@@ -2133,7 +2126,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
return [
|
|
return [
|
|
'path' => "/{$parentAlias}/{$alias_pinyin}/",
|
|
'path' => "/{$parentAlias}/{$alias_pinyin}/",
|
|
'name' => $alias ? "{$alias}" : null,
|
|
'name' => $alias ? "{$alias}" : null,
|
|
- 'cid' => $category_id ? "{$category_id}" : null
|
|
|
|
|
|
+ 'cid' => $category_id ? "{$category_id}" : null,
|
|
];
|
|
];
|
|
})->values()->all();
|
|
})->values()->all();
|
|
}
|
|
}
|
|
@@ -2369,5 +2362,4 @@ class WebsiteService implements WebsiteServiceInterface
|
|
return Result::error("更新失败", 0);
|
|
return Result::error("更新失败", 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|