|
@@ -29,7 +29,7 @@ use App\Tools\Result;
|
|
|
use Carbon\Carbon;
|
|
|
use App\Model\WebsiteCategory;
|
|
|
use App\Model\WebsiteGroup;
|
|
|
-use App\Model\WebsiteTemplate;
|
|
|
+use App\Model\WebsiteTemplate;
|
|
|
use App\Model\Sector;
|
|
|
use PhpParser\Node\Stmt\Return_;
|
|
|
use function PHPUnit\Framework\isNull;
|
|
@@ -517,22 +517,22 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
];
|
|
|
if (isset($data['ad_tag']) && !empty($data['ad_tag'])) {
|
|
|
$now = Carbon::now()->format('Y-m-d H:i:s'); // 获取当前时间
|
|
|
- $where[] = ['ad_place.ad_tag','like','%'.$data['ad_tag'].'%'];
|
|
|
+ $where[] = ['ad_place.ad_tag', 'like', '%' . $data['ad_tag'] . '%'];
|
|
|
// return Result::success($where);
|
|
|
- $result = AdPlace::where($where)
|
|
|
- ->leftJoin("ad", function ($join) use ($now) {
|
|
|
- $join->on("ad.pid", "=", "ad_place.id")
|
|
|
- ->where('ad.status', 1)
|
|
|
- ->where('ad.fromtime', '<=', $now)
|
|
|
- ->where('ad.totime', '>=', $now);
|
|
|
- })
|
|
|
- ->select("ad_place.*",'ad.*',"ad_place.id as ad_place_id","ad.name as ad_name")
|
|
|
- ->get()->all();
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("此广告位不存在!",0);
|
|
|
- }
|
|
|
- }else{
|
|
|
- return Result::error("请选择广告位!",0);
|
|
|
+ $result = AdPlace::where($where)
|
|
|
+ ->leftJoin("ad", function ($join) use ($now) {
|
|
|
+ $join->on("ad.pid", "=", "ad_place.id")
|
|
|
+ ->where('ad.status', 1)
|
|
|
+ ->where('ad.fromtime', '<=', $now)
|
|
|
+ ->where('ad.totime', '>=', $now);
|
|
|
+ })
|
|
|
+ ->select("ad_place.*", 'ad.*', "ad_place.id as ad_place_id", "ad.name as ad_name")
|
|
|
+ ->get()->all();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("此广告位不存在!", 0);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return Result::error("请选择广告位!", 0);
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
|
|
@@ -571,18 +571,18 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
|
|
|
/**
|
|
|
* 搜索地区
|
|
|
- * @param array $data
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public function selectWebsiteArea(array $data): array
|
|
|
- {
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function selectWebsiteArea(array $data): array
|
|
|
+ {
|
|
|
|
|
|
// return Result::success($data);
|
|
|
$pid = $data['pid'] ?? 0;
|
|
|
- $result = District::where('pid',$pid)->where('status',1)->orderBy('code')->get();
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("未查询到此地区",0);
|
|
|
- }else{
|
|
|
+ $result = District::where('pid', $pid)->where('status', 1)->orderBy('code')->get();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("未查询到此地区", 0);
|
|
|
+ } else {
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
@@ -623,14 +623,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
|
|
|
// 执行查询
|
|
|
- $placeid = $data['placeid']-1;
|
|
|
+ $placeid = $data['placeid'] - 1;
|
|
|
$result = $query->offset($placeid)->limit($data['num'])->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);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 获取友情链接
|
|
@@ -1201,6 +1201,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
// array_push($where, ['category.city_id', '=', $data['city_id']]);
|
|
|
// }
|
|
|
$result = WebsiteCategory::where($where)
|
|
|
+ ->leftJoin("category", 'website_category.category_id', 'category.id')
|
|
|
+ ->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')
|
|
@@ -1304,13 +1306,13 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function getWebsiteFootInfo(array $data): array
|
|
|
{
|
|
|
|
|
|
- if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
- $website_head = Website::where('id',$data['website_id'])
|
|
|
- ->where('status',1)
|
|
|
+ if (isset($data['website_id']) && !empty($data['website_id'])) {
|
|
|
+ $website_head = Website::where('id', $data['website_id'])
|
|
|
+ ->where('status', 1)
|
|
|
->select('id', 'website_name', 'logo', 'title', 'keywords', 'description', 'suffix', 'website_url')
|
|
|
->first();
|
|
|
if (empty($website_head)) {
|
|
|
- return Result::error("找不到网站",0);
|
|
|
+ return Result::error("找不到网站", 0);
|
|
|
}
|
|
|
} else {
|
|
|
return Result::error("参数错误", 0);
|
|
@@ -1327,7 +1329,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
'website_head' => $website_head,
|
|
|
];
|
|
|
return Result::success($result);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
/**
|
|
|
* 获取网站底部导航
|
|
@@ -1515,25 +1517,25 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$website = Website::where('id', $data['website_id'])->where('status', 1)->first();
|
|
|
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();
|
|
|
if (empty($category)) {
|
|
|
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')->first();
|
|
|
- $category['parent_id'] = $parent['parent_id']?? '';
|
|
|
- $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')->first();
|
|
|
+ $category['parent_id'] = $parent['parent_id'] ?? '';
|
|
|
+ $category['parent_name'] = $parent['parent_name'] ?? '';
|
|
|
return Result::success($category);
|
|
|
} else {
|
|
|
return Result::error("参数错误", 0);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 自助建站--fr-------------------
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 获取并搜索 网站模板信息
|
|
|
* @param array $data
|
|
|
* @return array
|
|
@@ -1554,24 +1556,24 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
"website_template_info.action_id",
|
|
|
"website_template_info.created_at",
|
|
|
"website_template_info.updated_at",
|
|
|
- "website_template_info.page_type",
|
|
|
+ "website_template_info.page_type",
|
|
|
DB::raw("COALESCE(website_template_info.status, 0) as template_status"),
|
|
|
"template.template_name"
|
|
|
);
|
|
|
//若存在条件;则在$query的基础上进行筛选
|
|
|
- if(isset($data['website_name']) && !empty($data['website_name'])){
|
|
|
+ if (isset($data['website_name']) && !empty($data['website_name'])) {
|
|
|
$query->where('website.website_name', 'like', '%' . $data['website_name'] . '%');
|
|
|
}
|
|
|
- if(isset($data['status']) && !empty($data['status'])){
|
|
|
+ if (isset($data['status']) && !empty($data['status'])) {
|
|
|
$query->where('website_template_info.status', $data['status']);
|
|
|
}
|
|
|
$count = $query->count();
|
|
|
$query->limit($data['pageSize'])
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->orderBy("website_template_info.updated_at", "desc");
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
+ ->orderBy("website_template_info.updated_at", "desc");
|
|
|
$rep = $query->get();
|
|
|
- if($rep->count()==0){
|
|
|
- return Result::error("没有查找到相关数据",0);
|
|
|
+ if ($rep->count() == 0) {
|
|
|
+ return Result::error("没有查找到相关数据", 0);
|
|
|
} else {
|
|
|
$rep->each(function ($item) {
|
|
|
if (!empty($item->page_type)) {
|
|
@@ -1581,12 +1583,12 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
$result = [
|
|
|
"rows" => $rep->toArray(),
|
|
|
- "count" => $count
|
|
|
+ "count" => $count,
|
|
|
];
|
|
|
- return Result::success($result);
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
// return Result::success($result);
|
|
|
}
|
|
@@ -1598,40 +1600,40 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function addWebsiteTemplateintel(array $data): array
|
|
|
{
|
|
|
- $website = Website::where('website.id',$data['website_id'])->first();
|
|
|
- if(empty($website)){
|
|
|
+ $website = Website::where('website.id', $data['website_id'])->first();
|
|
|
+ if (empty($website)) {
|
|
|
return Result::error("请输入正确的网站id!", 0);
|
|
|
}
|
|
|
- if(empty($website['website_column_id'])){
|
|
|
+ if (empty($website['website_column_id'])) {
|
|
|
return Result::error("请先关联导航池!", 0);
|
|
|
}
|
|
|
- // 获取此网站的底部导航 类型 type: 0:内容型底部导航(只有一条详情内容);1:列表型底部导航(可以有多条详情内容)
|
|
|
- $foot_type = FooterCategory::where('website_id',$data['website_id'])->pluck('type')->toArray();
|
|
|
- if (empty($foot_type)) {
|
|
|
- return Result::error("请先关联底部导航池!", 0);
|
|
|
- } elseif (in_array(1, $foot_type)) {
|
|
|
- $foot_type = 1;
|
|
|
- } else {
|
|
|
- $foot_type = 0;
|
|
|
- }
|
|
|
- $result['foot_type'] = $foot_type;
|
|
|
- // 友情链接类型'1:图片 2:文字 3:底部';
|
|
|
- $types = Link::where('website_id', $data['website_id'])->pluck('type')->toArray();
|
|
|
- $missingTypes = [];
|
|
|
- if (!in_array(1, $types)) {
|
|
|
- $missingTypes[] = "文字链接";
|
|
|
- }
|
|
|
- if (!in_array(2, $types)) {
|
|
|
- $missingTypes[] = "图片链接";
|
|
|
- }
|
|
|
- if (!in_array(3, $types)) {
|
|
|
- $missingTypes[] = "底部链接";
|
|
|
- }
|
|
|
- if (!empty($missingTypes)) {
|
|
|
- $errorMessage = "请先添加 " . implode(" 和 ", $missingTypes) . "!";
|
|
|
- return Result::error($errorMessage, 0);
|
|
|
- }
|
|
|
- if(isset($data['page_type'])){
|
|
|
+ // 获取此网站的底部导航 类型 type: 0:内容型底部导航(只有一条详情内容);1:列表型底部导航(可以有多条详情内容)
|
|
|
+ $foot_type = FooterCategory::where('website_id', $data['website_id'])->pluck('type')->toArray();
|
|
|
+ if (empty($foot_type)) {
|
|
|
+ return Result::error("请先关联底部导航池!", 0);
|
|
|
+ } elseif (in_array(1, $foot_type)) {
|
|
|
+ $foot_type = 1;
|
|
|
+ } else {
|
|
|
+ $foot_type = 0;
|
|
|
+ }
|
|
|
+ $result['foot_type'] = $foot_type;
|
|
|
+ // 友情链接类型'1:图片 2:文字 3:底部';
|
|
|
+ $types = Link::where('website_id', $data['website_id'])->pluck('type')->toArray();
|
|
|
+ $missingTypes = [];
|
|
|
+ if (!in_array(1, $types)) {
|
|
|
+ $missingTypes[] = "文字链接";
|
|
|
+ }
|
|
|
+ if (!in_array(2, $types)) {
|
|
|
+ $missingTypes[] = "图片链接";
|
|
|
+ }
|
|
|
+ if (!in_array(3, $types)) {
|
|
|
+ $missingTypes[] = "底部链接";
|
|
|
+ }
|
|
|
+ if (!empty($missingTypes)) {
|
|
|
+ $errorMessage = "请先添加 " . implode(" 和 ", $missingTypes) . "!";
|
|
|
+ return Result::error($errorMessage, 0);
|
|
|
+ }
|
|
|
+ if (isset($data['page_type'])) {
|
|
|
// 删除重复元素并重新索引数组
|
|
|
$data['page_type'] = array_unique($data['page_type']);
|
|
|
$data['page_type'] = array_values($data['page_type']);
|
|
@@ -1640,15 +1642,15 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
|
if (empty($info)) {
|
|
|
// 将数组转换为 JSON 字符串
|
|
|
- $data['page_type'] = json_encode($data['page_type'])??'';
|
|
|
+ $data['page_type'] = json_encode($data['page_type']) ?? '';
|
|
|
// 操作状态:1:填写完成基础信息;2:选择完成模板;0:未构建
|
|
|
$data['action_id'] = 1;
|
|
|
-
|
|
|
+
|
|
|
try {
|
|
|
$result = WebsiteTemplateInfo::insertGetId($data);
|
|
|
} catch (\Exception $e) {
|
|
|
if ($e->getCode() == 22001) {
|
|
|
- $errorMessage = $e->getMessage();
|
|
|
+ $errorMessage = $e->getMessage();
|
|
|
return Result::error("请检查表单,某个字段超出了长度限制!");
|
|
|
} else {
|
|
|
// 处理其他类型的数据库错误
|
|
@@ -1658,75 +1660,75 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
} else {
|
|
|
return Result::error("该网站已经构建过了!", 0);
|
|
|
- }
|
|
|
+ }
|
|
|
} else {
|
|
|
return Result::error("请先选择首页和底部导航详情页!", 0);
|
|
|
}
|
|
|
}
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("添加失败!",0);
|
|
|
- }else{
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("添加失败!", 0);
|
|
|
+ } else {
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 获取网站基础信息
|
|
|
*
|
|
|
* @return array
|
|
|
*/
|
|
|
public function getWebsiteTemplateintel(array $data): array
|
|
|
{
|
|
|
-
|
|
|
- $result = WebsiteTemplateInfo::where('website_template_info.website_id',$data['website_id'])
|
|
|
- ->leftJoin('footer_category','footer_category.website_id','website_template_info.website_id')
|
|
|
- ->leftJoin('website','website.id','website_template_info.website_id')
|
|
|
- ->select(
|
|
|
- "website_template_info.*",
|
|
|
- "footer_category.type",
|
|
|
- "website.website_name",
|
|
|
- "website.id as website_id"
|
|
|
- )
|
|
|
- ->first();
|
|
|
- if(empty($result['website_name'])){
|
|
|
+
|
|
|
+ $result = WebsiteTemplateInfo::where('website_template_info.website_id', $data['website_id'])
|
|
|
+ ->leftJoin('footer_category', 'footer_category.website_id', 'website_template_info.website_id')
|
|
|
+ ->leftJoin('website', 'website.id', 'website_template_info.website_id')
|
|
|
+ ->select(
|
|
|
+ "website_template_info.*",
|
|
|
+ "footer_category.type",
|
|
|
+ "website.website_name",
|
|
|
+ "website.id as website_id"
|
|
|
+ )
|
|
|
+ ->first();
|
|
|
+ if (empty($result['website_name'])) {
|
|
|
return Result::error("请输入正确的网站id!", 0);
|
|
|
}
|
|
|
- if($result){
|
|
|
- $result['page_type'] = json_decode($result['page_type'],true);
|
|
|
+ if ($result) {
|
|
|
+ $result['page_type'] = json_decode($result['page_type'], true);
|
|
|
return Result::success($result);
|
|
|
- }else{
|
|
|
- return Result::error("请先添加网站基础信息!",0);
|
|
|
+ } else {
|
|
|
+ return Result::error("请先添加网站基础信息!", 0);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 修改网站基础信息
|
|
|
*
|
|
|
* @return array
|
|
|
- */
|
|
|
+ */
|
|
|
public function upWebsiteTemplateintel(array $data): array
|
|
|
{
|
|
|
- $web = Website::where('website.id',$data['website_id'])->first();
|
|
|
- if(empty($web)){
|
|
|
+ $web = Website::where('website.id', $data['website_id'])->first();
|
|
|
+ if (empty($web)) {
|
|
|
return Result::error("请输入正确的网站id!", 0);
|
|
|
}
|
|
|
- $where = ['website_id'=>$data['website_id']];
|
|
|
+ $where = ['website_id' => $data['website_id']];
|
|
|
$result = WebsiteTemplateInfo::where($where)->first();
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("请先添加网站基础信息!",0);
|
|
|
- }else{
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("请先添加网站基础信息!", 0);
|
|
|
+ } else {
|
|
|
unset($data['website_id']);
|
|
|
// 删除重复元素
|
|
|
- $data['page_type'] = array_unique($data['page_type']);
|
|
|
+ $data['page_type'] = array_unique($data['page_type']);
|
|
|
// 重新索引数组
|
|
|
$data['page_type'] = array_values($data['page_type']);
|
|
|
// 数组中同时包含值为 1(首页) 和值为 7 (底部导航详情页)的元素
|
|
|
if (in_array(1, $data['page_type']) && in_array(7, $data['page_type'])) {
|
|
|
// 将数组转换为 JSON 字符串
|
|
|
- $data['page_type'] = json_encode($data['page_type'])??'';
|
|
|
+ $data['page_type'] = json_encode($data['page_type']) ?? '';
|
|
|
try {
|
|
|
$result = WebsiteTemplateInfo::where($where)->update($data);
|
|
|
} catch (\Exception $e) {
|
|
|
if ($e->getCode() == 22001) {
|
|
|
- $errorMessage = $e->getMessage();
|
|
|
+ $errorMessage = $e->getMessage();
|
|
|
return Result::error("请检查表单,某个字段超出了长度限制!");
|
|
|
} else {
|
|
|
// 处理其他类型的数据库错误
|
|
@@ -1734,17 +1736,17 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
return Result::error("修改失败!", 0);
|
|
|
}
|
|
|
- }else{
|
|
|
- return Result::error("请先选择首页和底部导航详情页!",0);
|
|
|
+ } else {
|
|
|
+ return Result::error("请先选择首页和底部导航详情页!", 0);
|
|
|
}
|
|
|
}
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("修改失败!",0);
|
|
|
- }else{
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("修改失败!", 0);
|
|
|
+ } else {
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 获取所有网站风格信息
|
|
|
*
|
|
|
* @return array
|
|
@@ -1752,14 +1754,14 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function getAllTemplateClass(array $data): array
|
|
|
{
|
|
|
$result = TemplateClass::all();
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("没有查找到相关数据!",0);
|
|
|
- }else{
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("没有查找到相关数据!", 0);
|
|
|
+ } else {
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 搜索并获取网站模板信息
|
|
|
* @param array $data
|
|
|
* @return array
|
|
@@ -1767,21 +1769,21 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function getWebsiteTemplateList(array $data): array
|
|
|
{
|
|
|
|
|
|
- $website = Website::where('website.id',$data['website_id'])->first();
|
|
|
- if(empty($website)){
|
|
|
- return Result::error("请输入正确的网站id!",0);
|
|
|
- }else{
|
|
|
- $page_type = WebsiteTemplateInfo::where('website_id',$data['website_id'])->select('page_type')->first();
|
|
|
- if(empty($page_type)){
|
|
|
- return Result::error("此网站还未添加基础信息!",0);
|
|
|
- } else{
|
|
|
+ $website = Website::where('website.id', $data['website_id'])->first();
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("请输入正确的网站id!", 0);
|
|
|
+ } else {
|
|
|
+ $page_type = WebsiteTemplateInfo::where('website_id', $data['website_id'])->select('page_type')->first();
|
|
|
+ if (empty($page_type)) {
|
|
|
+ return Result::error("此网站还未添加基础信息!", 0);
|
|
|
+ } else {
|
|
|
$where = json_decode($page_type['page_type'], true);
|
|
|
- // $where = $data["page_type"];
|
|
|
- if(isset($data['template_class_id']) && !empty($data['template_class_id'])){
|
|
|
- $template_class = TemplateClass::where('id',$data['template_class_id'])->first();
|
|
|
- if(empty($template_class)){
|
|
|
- return Result::error("请输入正确的模板风格id!",0);
|
|
|
- }else{
|
|
|
+ // $where = $data["page_type"];
|
|
|
+ if (isset($data['template_class_id']) && !empty($data['template_class_id'])) {
|
|
|
+ $template_class = TemplateClass::where('id', $data['template_class_id'])->first();
|
|
|
+ if (empty($template_class)) {
|
|
|
+ return Result::error("请输入正确的模板风格id!", 0);
|
|
|
+ } else {
|
|
|
// 获取指定风格下的模板
|
|
|
$rep = Template::where('template_class_id', $data['template_class_id'])
|
|
|
->where(function ($query) use ($where) {
|
|
@@ -1800,29 +1802,28 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
})->count();
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
|
|
|
//获取所有模板
|
|
|
$rep = Template::where(function ($query) use ($where) {
|
|
|
- foreach ($where as $value) {
|
|
|
- $query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
- }
|
|
|
- })
|
|
|
- ->limit($data['pageSize'])
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->orderBy("template.updated_at", "desc")
|
|
|
- ->get();
|
|
|
+ foreach ($where as $value) {
|
|
|
+ $query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
+ ->orderBy("template.updated_at", "desc")
|
|
|
+ ->get();
|
|
|
$count = Template::where(function ($query) use ($where) {
|
|
|
foreach ($where as $value) {
|
|
|
$query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
}
|
|
|
})->count();
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- if(empty($rep) || $rep->count()==0){
|
|
|
- return Result::error("没有查找到相关数据!",0);
|
|
|
- }else{
|
|
|
+ if (empty($rep) || $rep->count() == 0) {
|
|
|
+ return Result::error("没有查找到相关数据!", 0);
|
|
|
+ } else {
|
|
|
// 过滤 template_img 字段 只获取 基础信息中 包含的模板图片
|
|
|
// $rep->each(function ($item) use ($where) {
|
|
|
// $template_img = json_decode($item->template_img, true);
|
|
@@ -1830,8 +1831,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
// $filtered_img = array_filter($template_img, function ($img) use ($where) {
|
|
|
// return isset($img['value']) && in_array($img['value'], $where);
|
|
|
// });
|
|
|
- // }
|
|
|
-
|
|
|
+ // }
|
|
|
+
|
|
|
// $item->template_img = $filtered_img;
|
|
|
// });
|
|
|
// $result = [
|
|
@@ -1851,16 +1852,16 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$item->template_img = []; // 如果无法解码为数组,则设置为空数组
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
$result = [
|
|
|
"rows" => $rep->toArray(),
|
|
|
- "count" => $count
|
|
|
+ "count" => $count,
|
|
|
];
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
- return Result::success($result);
|
|
|
-
|
|
|
+ return Result::success($result);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1869,22 +1870,22 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function addWebsiteTemplateclassintel(array $data): array
|
|
|
{
|
|
|
- $template = Template::where('id',$data['template_id'])->first();
|
|
|
- $web = Website::where('id',$data['website_id'])->first();
|
|
|
- if(empty($template)){
|
|
|
- return Result::error("请输入正确的模板id",0);
|
|
|
+ $template = Template::where('id', $data['template_id'])->first();
|
|
|
+ $web = Website::where('id', $data['website_id'])->first();
|
|
|
+ if (empty($template)) {
|
|
|
+ return Result::error("请输入正确的模板id", 0);
|
|
|
}
|
|
|
- if(empty($web)){
|
|
|
- return Result::error("请输入正确的网站id",0);
|
|
|
+ if (empty($web)) {
|
|
|
+ return Result::error("请输入正确的网站id", 0);
|
|
|
}
|
|
|
|
|
|
- $result = WebsiteTemplateInfo::where('website_id',$data['website_id'])->update(['template_id'=>$data['template_id'],'action_id'=>2]);
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("添加失败",0);
|
|
|
- }else{
|
|
|
+ $result = WebsiteTemplateInfo::where('website_id', $data['website_id'])->update(['template_id' => $data['template_id'], 'action_id' => 2]);
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("添加失败", 0);
|
|
|
+ } else {
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
/**
|
|
|
* 获取网站模板信息
|
|
@@ -1893,38 +1894,38 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function getWebsiteTemplateclassintel(array $data): array
|
|
|
{
|
|
|
// return Result::success($data);
|
|
|
- $template = WebsiteTemplateInfo::where('website_id',$data['website_id'])->first();
|
|
|
- if(empty($template)){
|
|
|
- return Result::error("请输入正确的搭建网站id",0);
|
|
|
+ $template = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
|
+ if (empty($template)) {
|
|
|
+ return Result::error("请输入正确的搭建网站id", 0);
|
|
|
}
|
|
|
- $page_type = json_decode($template['page_type'], true);
|
|
|
+ $page_type = json_decode($template['page_type'], true);
|
|
|
// 获取指定网站下的基础信息和模板及风格信息
|
|
|
$result = WebsiteTemplateInfo::where([
|
|
|
- ['website_template_info.website_id',$data['website_id']],
|
|
|
- ['template_id','!=',null]
|
|
|
+ ['website_template_info.website_id', $data['website_id']],
|
|
|
+ ['template_id', '!=', null],
|
|
|
])
|
|
|
- ->leftJoin('template','template.id','website_template_info.template_id')
|
|
|
- ->leftJoin('template_class','template_class.id','template.template_class_id')
|
|
|
- ->where(function ($query) use ($page_type) {
|
|
|
- // 假设 $data['page_type'] 是一个数组,包含需要匹配的 page_type 值
|
|
|
- foreach ($page_type as $pageType) {
|
|
|
- $query->orWhereJsonContains('template.template_img', ['value' => $pageType]);
|
|
|
- }
|
|
|
- })
|
|
|
- ->select(
|
|
|
- 'template.template_name',
|
|
|
- 'template.template_img',
|
|
|
- 'template.id as tid',
|
|
|
- 'template_class.name',
|
|
|
- 'template_class.id as class_id',
|
|
|
- 'website_template_info.page_type',
|
|
|
- 'website_template_info.website_id')
|
|
|
- ->first();
|
|
|
-
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("没有查找到相关数据",0);
|
|
|
- }
|
|
|
-
|
|
|
+ ->leftJoin('template', 'template.id', 'website_template_info.template_id')
|
|
|
+ ->leftJoin('template_class', 'template_class.id', 'template.template_class_id')
|
|
|
+ ->where(function ($query) use ($page_type) {
|
|
|
+ // 假设 $data['page_type'] 是一个数组,包含需要匹配的 page_type 值
|
|
|
+ foreach ($page_type as $pageType) {
|
|
|
+ $query->orWhereJsonContains('template.template_img', ['value' => $pageType]);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->select(
|
|
|
+ 'template.template_name',
|
|
|
+ 'template.template_img',
|
|
|
+ 'template.id as tid',
|
|
|
+ 'template_class.name',
|
|
|
+ 'template_class.id as class_id',
|
|
|
+ 'website_template_info.page_type',
|
|
|
+ 'website_template_info.website_id')
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("没有查找到相关数据", 0);
|
|
|
+ }
|
|
|
+
|
|
|
// return Result::success($result);
|
|
|
// 过滤 template_img 字段 只获取 基础信息中 包含的模板图片
|
|
|
$template_img = $result['template_img'] !== null ? json_decode($result['template_img'], true) : [];
|
|
@@ -1962,20 +1963,20 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function getWebsiteSectorList(array $data): array
|
|
|
{
|
|
|
- $website = Website::where('id',$data['website_id'])->first();
|
|
|
- if(empty($website)){
|
|
|
- return Result::error("请输入正确的网站id",0);
|
|
|
+ $website = Website::where('id', $data['website_id'])->first();
|
|
|
+ if (empty($website)) {
|
|
|
+ return Result::error("请输入正确的网站id", 0);
|
|
|
}
|
|
|
- $template = WebsiteTemplateInfo::where('website_id',$data['website_id'])->first();
|
|
|
- if(empty($template['template_id'])){
|
|
|
- return Result::error("请先添加网站模板",0);
|
|
|
+ $template = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
|
+ if (empty($template['template_id'])) {
|
|
|
+ return Result::error("请先添加网站模板", 0);
|
|
|
}
|
|
|
- $query = Sector::where('template_id',$template['template_id']);
|
|
|
- if($query->count() == 0){
|
|
|
- return Result::error("没有查找到相关板块数据",0);
|
|
|
- }elseif($query->count() == 1){
|
|
|
+ $query = Sector::where('template_id', $template['template_id']);
|
|
|
+ if ($query->count() == 0) {
|
|
|
+ return Result::error("没有查找到相关板块数据", 0);
|
|
|
+ } elseif ($query->count() == 1) {
|
|
|
$sector = $query->first();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$sector = $query->get();
|
|
|
}
|
|
|
$result['page_type'] = $template['page_type'];
|
|
@@ -1983,15 +1984,13 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$result = [
|
|
|
"tid" => $template['template_id'],
|
|
|
"page_type" => $template['page_type'],
|
|
|
- "sector" => $sector
|
|
|
+ "sector" => $sector,
|
|
|
];
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 自助建站---------------fr---------------
|
|
|
|
|
|
-
|
|
|
// 网站底基础信息--fr-------------------
|
|
|
|
|
|
/**
|
|
@@ -2000,34 +1999,34 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function addWebFootInfo(array $data): array
|
|
|
{
|
|
|
- $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);
|
|
|
}
|
|
|
- $info = WebsiteTemplateInfo::where('website_id',$data['website_id'])->first();
|
|
|
- if(!empty($info)){
|
|
|
+ $info = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
|
+ if (!empty($info)) {
|
|
|
return Result::error("该网站已经添加过了!", 0);
|
|
|
}
|
|
|
- $result = WebsiteTemplateInfo::where('website_id',$data['website_id'])->insertGetId($data);
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("请先添加网站基础信息!",0);
|
|
|
- }else{
|
|
|
+ $result = WebsiteTemplateInfo::where('website_id', $data['website_id'])->insertGetId($data);
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("请先添加网站基础信息!", 0);
|
|
|
+ } else {
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 获取网站底基础信息
|
|
|
* @param array $data
|
|
|
- */
|
|
|
+ */
|
|
|
public function getWebFootInfo(array $data): array
|
|
|
{
|
|
|
- $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);
|
|
|
}
|
|
|
- $result = WebsiteTemplateInfo::where('website_id',$data['website_id'])->first();
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("请先添加网站基础信息!",0);
|
|
|
+ $result = WebsiteTemplateInfo::where('website_id', $data['website_id'])->first();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("请先添加网站基础信息!", 0);
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
@@ -2038,60 +2037,60 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
public function upWebFootInfo(array $data): array
|
|
|
{
|
|
|
// return Result::success($data['website_id']);
|
|
|
- $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);
|
|
|
-
|
|
|
- }
|
|
|
- $where = ['website_id'=>$data['website_id']];
|
|
|
+
|
|
|
+ }
|
|
|
+ $where = ['website_id' => $data['website_id']];
|
|
|
unset($data['website_id']);
|
|
|
$result = WebsiteTemplateInfo::where($where)->first();
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("请先添加网站基础信息!",0);
|
|
|
- }
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("请先添加网站基础信息!", 0);
|
|
|
+ }
|
|
|
// $where = ['website_id'=>$data['website_id']];
|
|
|
// unset($data['website_id']);
|
|
|
$result = WebsiteTemplateInfo::where($where)->update($data);
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("修改失败!",0);
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("修改失败!", 0);
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
+ /*
|
|
|
* 获取父级/子级栏目
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
* */
|
|
|
public function getWebsiteParentCategory(array $data): array
|
|
|
{
|
|
|
- if(isset($data['website_id']) &&!empty($data['website_id'])){
|
|
|
- $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
- }
|
|
|
+ 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);
|
|
|
+ return Result::error("暂无该网站", 0);
|
|
|
}
|
|
|
- if($data['id']==0){
|
|
|
+ if ($data['id'] == 0) {
|
|
|
$category = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
- ->where('pid', 0)
|
|
|
- ->pluck('aLIas_pinyin')
|
|
|
- ->map(function ($alias) {
|
|
|
- return "/{$alias}/:id";
|
|
|
- })
|
|
|
- ->values()
|
|
|
- ->all();
|
|
|
- }else{
|
|
|
+ ->where('pid', 0)
|
|
|
+ ->pluck('aLIas_pinyin')
|
|
|
+ ->map(function ($alias) {
|
|
|
+ return "/{$alias}/:id";
|
|
|
+ })
|
|
|
+ ->values()
|
|
|
+ ->all();
|
|
|
+ } else {
|
|
|
$category = WebsiteCategory::where('website_id', $data['website_id'])
|
|
|
- ->where('pid','!=', 0)
|
|
|
- ->pluck('aLIas_pinyin')
|
|
|
- ->map(function ($alias) {
|
|
|
- return "/{$alias}/:id";
|
|
|
- })
|
|
|
- ->values()
|
|
|
- ->all();
|
|
|
+ ->where('pid', '!=', 0)
|
|
|
+ ->pluck('aLIas_pinyin')
|
|
|
+ ->map(function ($alias) {
|
|
|
+ return "/{$alias}/:id";
|
|
|
+ })
|
|
|
+ ->values()
|
|
|
+ ->all();
|
|
|
}
|
|
|
if (empty($category)) {
|
|
|
- return Result::error("暂无此导航",0);
|
|
|
+ return Result::error("暂无此导航", 0);
|
|
|
}
|
|
|
// $result = [];
|
|
|
return Result::success($category);
|
|
@@ -2102,18 +2101,18 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function getWebsiteFootAll(array $data): array
|
|
|
{
|
|
|
- $website = Website::where('id',$data['website_id'])->where('status',1)->first();
|
|
|
+ $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
|
|
|
if (empty($website)) {
|
|
|
- return Result::error("暂无该网站",0);
|
|
|
+ return Result::error("暂无该网站", 0);
|
|
|
}
|
|
|
// 1:图片 2:文字 3:底部
|
|
|
- $result['foot_cate'] = FooterCategory::where('website_id',$data['website_id'])->get()->all();
|
|
|
- $result['link_img'] = Link::where('website_id',$data['website_id'])->where('type',1)->where('status',1)->limit($data['link_imgnum'])->orderBy('sort')->get()->all();
|
|
|
- $result['link_text'] = Link::where('website_id',$data['website_id'])->where('type',2)->where('status',1)->limit($data['link_textnum'])->orderBy('sort')->get()->all();
|
|
|
- $result['link_foot'] = Link::where('website_id',$data['website_id'])->where('type',3)->where('status',1)->limit($data['link_footnum'])->orderBy('sort')->get()->all();
|
|
|
- $result['foot_info'] = WebsiteTemplateInfo::where('website_id',$data['website_id'])->where('status',2)->first();
|
|
|
- if(empty($result)){
|
|
|
- return Result::error("暂无此网站信息",0);
|
|
|
+ $result['foot_cate'] = FooterCategory::where('website_id', $data['website_id'])->get()->all();
|
|
|
+ $result['link_img'] = Link::where('website_id', $data['website_id'])->where('type', 1)->where('status', 1)->limit($data['link_imgnum'])->orderBy('sort')->get()->all();
|
|
|
+ $result['link_text'] = Link::where('website_id', $data['website_id'])->where('type', 2)->where('status', 1)->limit($data['link_textnum'])->orderBy('sort')->get()->all();
|
|
|
+ $result['link_foot'] = Link::where('website_id', $data['website_id'])->where('type', 3)->where('status', 1)->limit($data['link_footnum'])->orderBy('sort')->get()->all();
|
|
|
+ $result['foot_info'] = WebsiteTemplateInfo::where('website_id', $data['website_id'])->where('status', 2)->first();
|
|
|
+ if (empty($result)) {
|
|
|
+ return Result::error("暂无此网站信息", 0);
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
@@ -2123,15 +2122,13 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function getWebsiteHead(array $data): array
|
|
|
{
|
|
|
- $result = Website::where('id',$data['website_id'])->where('status',1)->select('website_name','logo')->first();
|
|
|
+ $result = Website::where('id', $data['website_id'])->where('status', 1)->select('website_name', 'logo')->first();
|
|
|
if (empty($result)) {
|
|
|
- return Result::error("暂无该网站",0);
|
|
|
+ return Result::error("暂无该网站", 0);
|
|
|
}
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//20250212 网站标识
|
|
|
public function addWebsiteGroup(array $data): array
|
|
|
{
|