|
@@ -1269,102 +1269,225 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
return Result::success($websiteInfo->toArray());
|
|
|
}
|
|
|
- //20250212 网站标识
|
|
|
- public function addWebsiteGroup(array $data): array
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取网站底部基础信息
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteFootInfo(array $data): array
|
|
|
{
|
|
|
- //添加信息
|
|
|
- $result = WebsiteGroup::insertGetId($data);
|
|
|
- var_dump($result);
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("创建失败", 0);
|
|
|
- } else {
|
|
|
- return Result::success($result);
|
|
|
+ if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
+ $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("找不到网站",0);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
+ }
|
|
|
+ $website_foot = WebsiteTemplateInfo::where('website_id',$data['website_id'])->where('status',2)->first();
|
|
|
+ $website_head = Website::where('id',$data['website_id'])
|
|
|
+ ->select('id','website_name','logo','title','keywords','description')->first();
|
|
|
+ if (empty($website_foot)) {
|
|
|
+ return Result::error("暂无底部基础信息",0);
|
|
|
+ }
|
|
|
+ if (empty($website_head)) {
|
|
|
+ return Result::error("暂无头部基础信息",0);
|
|
|
}
|
|
|
+ $result = [
|
|
|
+ 'website_foot'=>$website_foot,
|
|
|
+ 'website_head'=>$website_head
|
|
|
+ ];
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
- public function getWebsiteGroupList(array $data): array
|
|
|
+ /**
|
|
|
+ * 获取网站底部导航
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteFooterCategory(array $data): array
|
|
|
{
|
|
|
- $where = [];
|
|
|
- if (isset($data['name']) && !empty($data['name'])) {
|
|
|
- array_push($where, ['website_group.name', 'like', '%' . $data['name'] . '%']);
|
|
|
- }
|
|
|
- $result = WebsiteGroup::where($where)
|
|
|
- ->limit($data['pageSize'])->orderBy("id", "desc")->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->get();
|
|
|
-
|
|
|
- foreach ($result as $websiteGroup) {
|
|
|
- $webIds = json_decode($websiteGroup->web_ids, true);
|
|
|
- $websites = Website::whereIn('id', $webIds)->get();
|
|
|
- $websiteNames = $websites->pluck('website_name', 'id')->toArray();
|
|
|
- $websiteGroup->website_names = $websiteNames;
|
|
|
- $websiteGroup->website_names1 = implode(',', array_values($websiteNames));
|
|
|
+ if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
+ $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("找不到网站",0);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
}
|
|
|
- $count = WebsiteGroup::where($where)->count();
|
|
|
+ $result = FooterCategory::where('website_id',$data['website_id'])->get();
|
|
|
if (empty($result)) {
|
|
|
- return Result::error("没有数据", 0);
|
|
|
+ return Result::error("暂无底部导航",0);
|
|
|
}
|
|
|
- return Result::success(['list' => $result->toArray(), 'count' => $count]);
|
|
|
+ return Result::success($result->toArray());
|
|
|
}
|
|
|
- public function getWebsiteGroupInfo(array $data): array
|
|
|
+ /**
|
|
|
+ * 获取网站底部导航列表
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteFooterCategoryList(array $data): array
|
|
|
{
|
|
|
- $websiteInfo = WebsiteGroup::query()->where('id', $data['id'])->first();
|
|
|
- $webIds = json_decode($websiteInfo->web_ids, true);
|
|
|
- $websites = Website::whereIn('id', $webIds)->get();
|
|
|
- $websiteNames = $websites->pluck('website_name', 'id')->toArray();
|
|
|
- $websiteInfo->website_names = $websiteNames;
|
|
|
- $websiteInfo->website_names1 = implode(',', array_values($websiteNames));
|
|
|
- if (empty($websiteInfo)) {
|
|
|
- return Result::error("找不到URL", 0);
|
|
|
+ if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
+ $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("找不到网站",0);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
+ }
|
|
|
+ $footercategory = FooterCategory::where('website_id',$data['website_id'])->where('id',$data['fcat_id'])->first();
|
|
|
+ // '底部导航类型 0:内容型;1:列表型;',
|
|
|
+ if (!isset($footercategory['type']) || $footercategory['type'] == 0) {
|
|
|
+ return Result::error("底部导航id错误",0);
|
|
|
+ }else{
|
|
|
+ $query = FooterContent::where('fcat_id',$data['fcat_id']);
|
|
|
+ if($query->count() == 0){
|
|
|
+ return Result::error("暂无底部导航列表",0);
|
|
|
+ }elseif($query->count() == 1){
|
|
|
+ $result = $query->first();
|
|
|
+ }else{
|
|
|
+ $result = $query->get();
|
|
|
+ }
|
|
|
}
|
|
|
- return Result::success($websiteInfo->toArray());
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
- public function updateWebsiteGroup(array $data): array
|
|
|
+ /**
|
|
|
+ * 获取网站底部导航
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteFooterCategoryInfo(array $data): array
|
|
|
{
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- $insertData = [
|
|
|
- 'name' => $data['name'],
|
|
|
- 'web_ids' => $data['web_ids'],
|
|
|
- ];
|
|
|
- $result = WebsiteGroup::where($where)->update($insertData);
|
|
|
- var_dump($result, '------更新');
|
|
|
+ if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
+ $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("找不到网站",0);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
+ }
|
|
|
+ if (isset($data['type']) && $data['type'] == 0) {
|
|
|
+ $fcatid = FooterCategory::where('website_id',$data['website_id'])->where('id',$data['fcat_id'])->first();
|
|
|
+ if (empty($fcatid)) {
|
|
|
+ return Result::error("底部导航id错误",0);
|
|
|
+ }
|
|
|
+ $result = FooterContent::where('fcat_id',$data['fcat_id'])->first();
|
|
|
+ }else{
|
|
|
+ $result = FooterContent::where('id',$data['fcat_id'])->first();
|
|
|
+ }
|
|
|
if (empty($result)) {
|
|
|
- return Result::error("更新失败", 0);
|
|
|
- } else {
|
|
|
- return Result::success();
|
|
|
+ return Result::error("暂无底部导航内容",0);
|
|
|
}
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
- public function deleteWebsiteGroup(array $data): array
|
|
|
+ /*
|
|
|
+ * 搜索网站二级导航
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function selectWebsiteCategory(array $data): array
|
|
|
{
|
|
|
- $where = [
|
|
|
- 'id' => $data['id'],
|
|
|
- ];
|
|
|
- //看看user表是不是有这个id
|
|
|
- $userGroup = User::query()->where('sszq', $data['id'])->first();
|
|
|
- if (!empty($userGroup)) {
|
|
|
- return Result::error("有用户在使用该网站标识,不能删除", 0);
|
|
|
- }
|
|
|
- $result = WebsiteGroup::where($where)->delete();
|
|
|
- if (empty($result)) {
|
|
|
- return Result::error("删除失败", 0);
|
|
|
- } else {
|
|
|
- return Result::success();
|
|
|
+ if(isset($data['website_id']) &&!empty($data['website_id'])){
|
|
|
+ $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("暂无该网站",0);
|
|
|
+ }
|
|
|
+ $category = WebsiteCategory::where('website_id',$data['website_id'])->where('pid',$data['pid'])->pluck('category_id')->all();
|
|
|
+ // return Result::success($category);
|
|
|
+ if (empty($category)) {
|
|
|
+ return Result::error("暂无二级导航",0);
|
|
|
+ }
|
|
|
+ $query = Category::whereIn('id', $category);
|
|
|
+ if (isset($data['cityid']) && !empty($data['cityid'])) {
|
|
|
+ $cityid = District::where('id', $data['cityid'])->first();
|
|
|
+ if (empty($cityid)) {
|
|
|
+ return Result::error("暂无此城市", 0);
|
|
|
+ } else {
|
|
|
+ $result = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->get();
|
|
|
+ // $where[] = ['JSON_CONTAINS(city_arr_id, ?)', $data['cityid']];
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无此城市下的二级导航", 0);
|
|
|
+ }
|
|
|
+ $city = 1;
|
|
|
+ // var_dump("城市====================",$result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($data['department_id']) && !empty($data['department_id'])) {
|
|
|
+ $departmentid = Department::where('id', $data['department_id'])->first();
|
|
|
+ if (empty($departmentid)) {
|
|
|
+ return Result::error("暂无此部门", 0);
|
|
|
+ } else {
|
|
|
+ $result = $query->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->get();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无此部门下的二级导航", 0);
|
|
|
+ }
|
|
|
+ // var_dump("职能部门*******************",$result);
|
|
|
+ $department = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($city) && !empty($department)){
|
|
|
+ // var_dump("城市和职能部门----------------------",$result);
|
|
|
+ $result = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->get();
|
|
|
+ }else{
|
|
|
+ $result = $query->get();
|
|
|
+ }
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无二级导航",0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // department_id
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
}
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
- public function getWebsiteNavList(array $data): array
|
|
|
+ /**
|
|
|
+ * 获取网站栏目seo
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getWebsiteCategoryHead(array $data): array
|
|
|
{
|
|
|
$where = [];
|
|
|
if (isset($data['website_id']) && !empty($data['website_id'])) {
|
|
|
array_push($where, ['website_id', '=', $data['website_id']]);
|
|
|
}
|
|
|
- if (isset($data['pid']) && !empty($data['pid'])) {
|
|
|
- array_push($where, ['pid', '=', $data['pid']]);
|
|
|
+ if (isset($data['catid']) && !empty($data['catid'])) {
|
|
|
+ $fcatid = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['catid'])->first();
|
|
|
+ if (empty($fcatid)) {
|
|
|
+ return Result::error("导航id错误",0);
|
|
|
+ }
|
|
|
+ $result = Category::where('id',$data['catid'])->first();
|
|
|
}
|
|
|
- $list = WebsiteCategory::query()->where($where)->get();
|
|
|
- if (empty($list)) {
|
|
|
- return Result::error("获取失败", 0);
|
|
|
- } else {
|
|
|
- return Result::success($list);
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无导航",0);
|
|
|
}
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 获取某个导航
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ * */
|
|
|
+ public function getOneWebsiteCategory(array $data): array
|
|
|
+ {
|
|
|
+ if(isset($data['website_id']) &&!empty($data['website_id'])){
|
|
|
+ $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("暂无该网站",0);
|
|
|
+ }
|
|
|
+ $result = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['category_id'])->select('category_id','name')->first();
|
|
|
+ // return Result::success($category);
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无此导航",0);
|
|
|
+ }
|
|
|
+ // department_id
|
|
|
+ }else{
|
|
|
+ return Result::error("参数错误",0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
-}
|
|
|
+}
|