|
@@ -1339,32 +1339,32 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
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);
|
|
|
- }
|
|
|
+ // 获取此网站的底部导航 类型 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']);
|
|
@@ -1377,12 +1377,12 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$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 {
|
|
|
// 处理其他类型的数据库错误
|
|
@@ -1392,7 +1392,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
} else {
|
|
|
return Result::error("该网站已经构建过了!", 0);
|
|
|
- }
|
|
|
+ }
|
|
|
} else {
|
|
|
return Result::error("请先选择首页和底部导航详情页!", 0);
|
|
|
}
|
|
@@ -1410,17 +1410,17 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
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();
|
|
|
+ ->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);
|
|
|
}
|
|
@@ -1435,7 +1435,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
* 修改网站基础信息
|
|
|
*
|
|
|
* @return array
|
|
|
- */
|
|
|
+ */
|
|
|
public function upWebsiteTemplateintel(array $data): array
|
|
|
{
|
|
|
$web = Website::where('website.id', $data['website_id'])->first();
|
|
@@ -1455,12 +1455,12 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
// 数组中同时包含值为 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 {
|
|
|
// 处理其他类型的数据库错误
|
|
@@ -1492,7 +1492,22 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 获取模板内容
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function getWebsiteTemplateInfo(array $data): array //丢了
|
|
|
+ {
|
|
|
+ $wehre = [
|
|
|
+ "website_id" =>$data['website_id']
|
|
|
+ ];
|
|
|
+ $result = WebsiteTemplate::where($wehre)->first();
|
|
|
+ if($result){
|
|
|
+ return Result::success($result);
|
|
|
+ }else{
|
|
|
+ return Result::error("没有数据",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 搜索并获取网站模板信息
|
|
|
* @param array $data
|
|
@@ -1510,7 +1525,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
return Result::error("此网站还未添加基础信息!",0);
|
|
|
} else{
|
|
|
$where = json_decode($page_type['page_type'], true);
|
|
|
- // $where = $data["page_type"];
|
|
|
+ // $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)){
|
|
@@ -1538,21 +1553,21 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
|
|
|
//获取所有模板
|
|
|
$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);
|
|
@@ -1564,8 +1579,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 = [
|
|
@@ -1585,7 +1600,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
$item->template_img = []; // 如果无法解码为数组,则设置为空数组
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
$result = [
|
|
|
"rows" => $rep->toArray(),
|
|
|
"count" => $count,
|
|
@@ -1593,8 +1608,8 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return Result::success($result);
|
|
|
-
|
|
|
+ return Result::success($result);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1636,23 +1651,23 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
['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();
|
|
|
+ ->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();
|
|
|
// return Result::success($result);
|
|
|
// 过滤 template_img 字段 只获取 基础信息中 包含的模板图片
|
|
|
$template_img = $result['template_img'] !== null ? json_decode($result['template_img'], true) : [];
|
|
@@ -1695,8 +1710,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
*/
|
|
|
public function addWebsiteTemplate(array $data): array
|
|
|
{
|
|
|
-// var_dump("接收参数:",$data['template_data']);
|
|
|
- $result = WebsiteTemplate::updateOrInsert(['website_id'=>$data['website_id']],['template_data'=>json_encode($data['template_data'])]);
|
|
|
+ $result = WebsiteTemplate::updateOrInsert(['website_id'=>$data['webSiteData']['base']['websiteId']],['template_data'=>json_encode($data['webSiteData']),'updated_at'=>date("Y-m-d H:i:s",time())]);
|
|
|
if($result){
|
|
|
return Result::success($result);
|
|
|
}else{
|