|
@@ -1086,7 +1086,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function getWebsiteTemplateinfo(array $data): array
|
|
|
+ public function getWebsiteTemplateintel(array $data): array
|
|
|
{
|
|
|
$where = []; // 初始化 $where 数组
|
|
|
//若存在条件;则在$rep的基础上进行筛选
|
|
@@ -1147,16 +1147,16 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if($rep->count()==0){
|
|
|
return Result::error("没有查找到相关数据",0);
|
|
|
} else {
|
|
|
- return Result::success($result); // 返回结果应该是 $result,而不是 $where
|
|
|
+ return Result::success($result);
|
|
|
}
|
|
|
// return Result::success($result);
|
|
|
}
|
|
|
/**
|
|
|
- * 添加网站模板信息
|
|
|
+ * 添加网站基础信息
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function addWebsiteTemplateinfo(array $data): array
|
|
|
+ public function addWebsiteTemplateintel(array $data): array
|
|
|
{
|
|
|
$website = Website::where('website.id',$data['website_id'])->first();
|
|
|
if(empty($website)){
|
|
@@ -1165,10 +1165,11 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if(empty($website['website_column_id'])){
|
|
|
$message = "请先关联导航池!";
|
|
|
}
|
|
|
+ // $data['page_type'] = WebsiteTemplateInfo::where('website_id',$data['website_id'])->select('page_type')->first();
|
|
|
if(isset($data['page_type'])){
|
|
|
if (in_array(1, $data['page_type']) && in_array(7, $data['page_type'])) {
|
|
|
// 数组中同时包含值为 1(首页) 和值为 7 (底部导航详情页)的元素
|
|
|
- $result = 'yes';
|
|
|
+ // $result = 'yes';
|
|
|
$data['page_type'] = json_encode($data['page_type'])??''; // 将数组转换为 JSON 字符串
|
|
|
$result = WebsiteTemplateInfo::insertGetId($data);
|
|
|
} else {
|
|
@@ -1198,88 +1199,100 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
- * 添加网站模板信息
|
|
|
+ * 获取所有网站风格信息
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getAllTemplateClass(array $data): array
|
|
|
+ {
|
|
|
+ $result = TemplateClass::all();
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("没有查找到相关数据!",0);
|
|
|
+ }else{
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取网站模板信息
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
- public function addWebsiteTemplate(array $data): array
|
|
|
+ public function getWebsiteTemplateList(array $data): array
|
|
|
{
|
|
|
$website = Website::where('website.id',$data['website_id'])->first();
|
|
|
if(empty($website)){
|
|
|
$message = "请输入正确的网站id!";
|
|
|
}else{
|
|
|
- //若存在模板id 则直接添加
|
|
|
- if(isset($data['template_id'])){
|
|
|
- $template = Template::where('id',$data['template_id'])->first();
|
|
|
- if(empty($template)){
|
|
|
- $message = "请输入正确的模板id!";
|
|
|
+ $where = $data["page_type"];
|
|
|
+ if(isset($data['template_class_id'])){
|
|
|
+ $template_class = TemplateClass::where('id',$data['template_class_id'])->first();
|
|
|
+ if(empty($template_class)){
|
|
|
+ $message = "请输入正确的模板风格id!";
|
|
|
}else{
|
|
|
- $result = WebsiteTemplateInfo::where('website_id',$data['website_id'])
|
|
|
- ->update(['template_id'=>$data['template_id']]);
|
|
|
- return Result::success($result);
|
|
|
- }
|
|
|
- }else{
|
|
|
- $where = $data["page_type"];
|
|
|
- if(isset($data['template_class_id'])){
|
|
|
- $template_class = TemplateClass::where('id',$data['template_class_id'])->first();
|
|
|
- if(empty($template_class)){
|
|
|
- $message = "请输入正确的模板风格id!";
|
|
|
- }else{
|
|
|
- // 获取指定风格下的模板
|
|
|
- $rep = Template::where('template_class_id', $data['template_class_id'])
|
|
|
- ->where(function ($query) use ($where) {
|
|
|
- foreach ($where as $value) {
|
|
|
- $query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
- }
|
|
|
- })
|
|
|
- ->leftJoin('template_class','template_class.id','template.template_class_id')
|
|
|
- ->select('template.*','template_class.name')
|
|
|
- ->limit($data['pageSize'])
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
- ->orderBy("template.updated_at", "desc")
|
|
|
- ->get();
|
|
|
- }
|
|
|
- }else{
|
|
|
- //获取所有模板
|
|
|
- $rep = Template::where(function ($query) use ($where) {
|
|
|
+ // 获取指定风格下的模板
|
|
|
+ $rep = Template::where('template_class_id', $data['template_class_id'])
|
|
|
+ ->where(function ($query) use ($where) {
|
|
|
foreach ($where as $value) {
|
|
|
$query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
}
|
|
|
})
|
|
|
- ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
+ ->leftJoin('template_class','template_class.id','template.template_class_id')
|
|
|
+ ->select('template.*','template_class.name')
|
|
|
->limit($data['pageSize'])
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
->orderBy("template.updated_at", "desc")
|
|
|
->get();
|
|
|
}
|
|
|
- if(empty($rep->toArray())){
|
|
|
- $message = "没有查找到相关数据!";
|
|
|
- }else{
|
|
|
- $result = [
|
|
|
- "rows" => $rep->toArray(),
|
|
|
- "count" => $rep->count()
|
|
|
- ];
|
|
|
- }
|
|
|
+ }else{
|
|
|
+ //获取所有模板
|
|
|
+ $rep = Template::where(function ($query) use ($where) {
|
|
|
+ foreach ($where as $value) {
|
|
|
+ $query->whereJsonContains('template_img', ['value' => $value]);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ->offset(($data['page'] - 1) * $data['pageSize'])
|
|
|
+ ->limit($data['pageSize'])
|
|
|
+ ->orderBy("template.updated_at", "desc")
|
|
|
+ ->get();
|
|
|
}
|
|
|
+ if(empty($rep)){
|
|
|
+ $message = "没有查找到相关数据!";
|
|
|
+ }else{
|
|
|
+ $result = [
|
|
|
+ "rows" => $rep->toArray(),
|
|
|
+ "count" => $rep->count()
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- if(empty($rep->toArray())){
|
|
|
+ if(empty($rep)){
|
|
|
return Result::error($message,0);
|
|
|
}else{
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
}
|
|
|
- /**
|
|
|
- * 获取所有网站模板信息
|
|
|
- *
|
|
|
- * @return array
|
|
|
+ /**
|
|
|
+ * 添加网站模板
|
|
|
+ * @param array $data
|
|
|
*/
|
|
|
- public function getAllTemplateClass(array $data): array
|
|
|
+ public function addWebsiteTemplateclassintel(array $data): array
|
|
|
{
|
|
|
- $result = TemplateClass::all();
|
|
|
+ $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);
|
|
|
+ }
|
|
|
+ $result = WebsiteTemplateInfo::where('website_id',$data['website_id'])->update(['template_id' => $data['template_id']]);
|
|
|
if(empty($result)){
|
|
|
- return Result::error("没有查找到相关数据!",0);
|
|
|
+ return Result::error("添加失败",0);
|
|
|
}else{
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|