|
@@ -787,13 +787,16 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
/**
|
|
|
- * 获取getTemplateClass
|
|
|
+ * 根据风格名称-获取获取所有风格
|
|
|
* @param array $data
|
|
|
* @return array
|
|
|
*/
|
|
|
public function getTemplateClass(array $data): array
|
|
|
{
|
|
|
- $result = TemplateClass::get();
|
|
|
+ $result = TemplateClass::where('name','like','%'.$data['template_name'].'%')->get();
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("暂无风格", 0);
|
|
|
+ }
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
/**
|
|
@@ -911,6 +914,19 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
return Result::success('更新成功');
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 根据皮肤名称-获取所有皮肤
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getAllTemplate(array $data): array
|
|
|
+ {
|
|
|
+ $result = Template::where('template_name','like','%'.$data['template_name'].'%')->get();
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error("暂无皮肤", 0);
|
|
|
+ }
|
|
|
+ return Result::success($result);
|
|
|
+ }
|
|
|
/**
|
|
|
* 获取通栏列表
|
|
|
* @param array $data
|
|
@@ -929,11 +945,11 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
array_push($where, ['sector.sector_name', 'like', '%' . $data['sector_name'] . '%']);
|
|
|
}
|
|
|
if (isset($data['width']) && !empty($data['width']) && isset($data['height']) && !empty($data['height'])){
|
|
|
- $size_id = Size::where('width','like','%' .$data['width'].'%')->where('height','like','%' .$data['height'].'%')->value('id')->all();
|
|
|
+ $size_id = Size::where('width','like','%' .$data['width'].'%')->where('height','like','%' .$data['height'].'%')->pluck('id');
|
|
|
} else if( isset($data['width']) && !empty($data['width'])){
|
|
|
- $size_id = Size::where('width','like','%' .$data['width'].'%')->value('id')->all();
|
|
|
+ $size_id = Size::where('width','like','%' .$data['width'].'%')->pluck('id');
|
|
|
}else if( isset($data['height']) && !empty($data['height'])){
|
|
|
- $size_id = Size::where('height','like','%' .$data['height'].'%')->value('id')->all();
|
|
|
+ $size_id = Size::where('height','like','%' .$data['height'].'%')->pluck('id');
|
|
|
}else{
|
|
|
$size_id = [];
|
|
|
}
|
|
@@ -1052,8 +1068,27 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
public function addSector(array $data): array
|
|
|
{
|
|
|
unset($data['user_id']);
|
|
|
+ // 对传入的 page_type 数组进行去重、转换为整数并重新索引
|
|
|
$data['page_type'] = array_values(array_unique(array_map('intval', $data['page_type'])));
|
|
|
$data['page_type'] = json_encode($data['page_type']);
|
|
|
+ $template = Template::where('template_id', $data['template_id'])
|
|
|
+ ->whereRaw("JSON_CONTAINS(template.page_type, ?)", [$data['page_type']])
|
|
|
+ ->first();
|
|
|
+ if(empty($template)){
|
|
|
+ return Result::error('皮肤不存在!');
|
|
|
+ }
|
|
|
+ // 皮肤相关信息
|
|
|
+ $data['template_name'] = $template['template_name'];
|
|
|
+ $data['template_id'] = $template['template_id'];
|
|
|
+ // 风格相关信息
|
|
|
+ $template_class = TemplateClass::where('class_id',$template['template_class_id'])->first();
|
|
|
+ if(empty($template_class)){
|
|
|
+ return Result::error('所属风格不存在!');
|
|
|
+ }
|
|
|
+ // $data['sector_keyword'] = json_encode($data['sector_keyword']);
|
|
|
+ $data['template_class_id'] = $template_class['class_id'];
|
|
|
+ $data['template_class_name'] = $template_class['name'];
|
|
|
+
|
|
|
$result = Sector::insertGetId($data);
|
|
|
if(empty($result)){
|
|
|
return Result::error('添加失败');
|
|
@@ -1086,8 +1121,30 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
public function updateSector(array $data): array
|
|
|
{
|
|
|
unset($data['user_id']);
|
|
|
+ $sector = Sector::where('id', $data['id'])->first();
|
|
|
+ if(empty($sector)){
|
|
|
+ return Result::error('通栏不存在!');
|
|
|
+ }
|
|
|
+ // 对传入的 page_type 数组进行去重、转换为整数并重新索引
|
|
|
$data['page_type'] = array_values(array_unique(array_map('intval', $data['page_type'])));
|
|
|
$data['page_type'] = json_encode($data['page_type']);
|
|
|
+ $template = Template::where('template_id', $data['template_id'])
|
|
|
+ ->whereRaw("JSON_CONTAINS(template.page_type, ?)", [$data['page_type']])
|
|
|
+ ->first();
|
|
|
+ if(empty($template)){
|
|
|
+ return Result::error('皮肤不存在!');
|
|
|
+ }
|
|
|
+ // 皮肤相关信息
|
|
|
+ $data['template_name'] = $template['template_name'];
|
|
|
+ $data['template_id'] = $template['template_id'];
|
|
|
+ // 风格相关信息
|
|
|
+ $template_class = TemplateClass::where('class_id',$template['template_class_id'])->first();
|
|
|
+ if(empty($template_class)){
|
|
|
+ return Result::error('所属风格不存在!');
|
|
|
+ }
|
|
|
+ // $data['sector_keyword'] = json_encode($data['sector_keyword']);
|
|
|
+ $data['template_class_id'] = $template_class['class_id'];
|
|
|
+ $data['template_class_name'] = $template_class['name'];
|
|
|
$result = Sector::where('id', $data['id'])->update($data);
|
|
|
if ($result == 1) {
|
|
|
return Result::success('修改成功');
|