|
|
@@ -40,9 +40,12 @@ use App\Model\ComponentType;
|
|
|
use App\Model\Article;
|
|
|
use App\Model\WebsiteCategory;
|
|
|
use App\Model\AdPlace;
|
|
|
+use App\Model\Company;
|
|
|
use App\Model\WebsiteImg;
|
|
|
use App\Model\SectorComponent;
|
|
|
use App\Model\ComponentImg;
|
|
|
+use App\Model\TemplateRule;
|
|
|
+use App\Model\SectorType;
|
|
|
|
|
|
#[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
|
class PublicRpcService implements PublicRpcServiceInterface
|
|
|
@@ -913,8 +916,12 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
if (!empty($web_template)) {
|
|
|
return Result::error("此皮肤已被绑定网站,不可删除", 0);
|
|
|
}
|
|
|
- if ($template->type == 1) {
|
|
|
- return Result::error("默认皮肤不能删除", 0);
|
|
|
+ // if ($template->type == 1) {
|
|
|
+ // return Result::error("默认皮肤不能删除", 0);
|
|
|
+ // }
|
|
|
+ $component_img = ComponentImg::where('template_id',$template['template_id'])->get();
|
|
|
+ if(!empty($component_img)){
|
|
|
+ return Result::error('此皮肤已绑定组件预览图,不可删除!');
|
|
|
}
|
|
|
$result = Template::where('id', $data['id'])->delete();
|
|
|
var_dump($result, '-------------------delete');
|
|
|
@@ -1191,7 +1198,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
if (empty($template)) {
|
|
|
return Result::error('皮肤不存在!');
|
|
|
}
|
|
|
- $sector_id = Sector::where('sector_id',$data['sector_id'])->first();
|
|
|
+ $sector_id = Sector::where('sector_id',$data['sector_id'])->where('template_id',$data['template_id'])->first();
|
|
|
if(!empty($sector_id)){
|
|
|
return Result::error('通栏编号已存在!');
|
|
|
}
|
|
|
@@ -1200,55 +1207,93 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
return Result::error('位置不存在!');
|
|
|
}
|
|
|
$sort = json_decode($data['component_code'],true);
|
|
|
- $kw = 0;
|
|
|
- $flattened = [];
|
|
|
- $component = [];
|
|
|
+ $sector = 0;
|
|
|
+ // $flattened = [];
|
|
|
+ // $sector = [];
|
|
|
$sector_component = [];
|
|
|
foreach ($sort as $key => $subArray) {
|
|
|
foreach ($subArray as $k => $item) {
|
|
|
- $component[] = $item;
|
|
|
+ // // $component[] = $item;
|
|
|
$sector_component[] = [
|
|
|
'sector_id' => $data['sector_id'],
|
|
|
- 'component_id' => $item,
|
|
|
+ 'component_id' => $subArray[$k],
|
|
|
'sort_id' => $key + 1,
|
|
|
'place_id' => $data['place_type'],
|
|
|
+ // 'sectorid' => $data['id'],
|
|
|
];
|
|
|
+ // // // ---------同步通栏的sort_id到组件之中,目前已废弃,涉及到批量修改------
|
|
|
+ // // $componentTypes[] = $item;
|
|
|
+ // // $components[] = [
|
|
|
+ // // 'sort_id' => $key + 1,
|
|
|
+ // // 'component_type' => $item,
|
|
|
+ // // ];
|
|
|
+ // // $place_ids[] = $data['place_type'];
|
|
|
}
|
|
|
}
|
|
|
- $component_num = count($component);
|
|
|
- $count = count(array_unique($component));
|
|
|
- // return Result::success($sector_component);
|
|
|
- if(count($sort) != $data['component_num'] || $component_num != $count){
|
|
|
+ // $component_num = count($component);
|
|
|
+ // $count = count(array_unique($component));
|
|
|
+
|
|
|
+ // 使用array_map批量替换sector_id
|
|
|
+
|
|
|
+ // return Result::success($sector_component);
|
|
|
+ if(count($sort) != $data['component_num']){
|
|
|
return Result::error('组件关联错误!');
|
|
|
}
|
|
|
// 通栏分类:1:资讯类:2:通栏广告类;3:混合类;4:头条类;5:轮播图类;
|
|
|
$sector_code = [
|
|
|
- 'sectorName' => $data['sector_name'],
|
|
|
- 'sectorId' => $data['sector_id'],
|
|
|
- 'sectorType' => $data['sector_type'],
|
|
|
- 'sectorPlace' => $data['place_type'],
|
|
|
+ $data['sector_id'] => [
|
|
|
+ 'sectorName' => $data['sector_name'],
|
|
|
+ 'sectorHeight' => $data['pic_height'],
|
|
|
+ 'sectorImg' => $data['sector_img'],
|
|
|
+ ]
|
|
|
];
|
|
|
// return Result::success($sector_code);
|
|
|
$data['sector_code'] = json_encode($sector_code);
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
- $com_sector = SectorComponent::insert($sector_component);
|
|
|
+ $sector = Sector::insertGetId($data);
|
|
|
+ if (empty($sector)) {
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error('添加失败');
|
|
|
+ }
|
|
|
+ $sector_com = array_map(function ($item) use ($sector) {
|
|
|
+ // 替换当前记录的sector_id为变量值(保留其他字段不变)
|
|
|
+ $item['sectorid'] = $sector;
|
|
|
+ return $item;
|
|
|
+ }, $sector_component);
|
|
|
+ // Db::rollBack();
|
|
|
+ // return Result::success($sector_com);
|
|
|
+ $com_sector = SectorComponent::insert($sector_com);
|
|
|
if(empty($com_sector)){
|
|
|
Db::rollBack();
|
|
|
return Result::error('通栏关联组件失败!');
|
|
|
}
|
|
|
- // $up_component = Component::whereIn('component_type',$sector_component['component_id'])->update(['status' => 2]);
|
|
|
- // if(empty($up_component)){
|
|
|
+ // ---------同步通栏的sort_id到组件之中,目前已废弃,涉及到批量修改------
|
|
|
+ // 查询数据库中已存在的component_type(只保留存在的记录)
|
|
|
+ // $existingTypes = Component::whereIn('component_type', $componentTypes)
|
|
|
+ // ->pluck('component_type') // 提取存在的component_type
|
|
|
+ // ->toArray();
|
|
|
+ // if(empty($existingTypes)){
|
|
|
// Db::rollBack();
|
|
|
- // return Result::error('通栏关联组件失败!');
|
|
|
+ // return Result::error('组件不存在!');
|
|
|
// }
|
|
|
- $result = Sector::insertGetId($data);
|
|
|
- if (empty($result)) {
|
|
|
- Db::rollBack();
|
|
|
- return Result::error('添加失败');
|
|
|
- }
|
|
|
+ // // var_dump($existingTypes);
|
|
|
+ // // 3. 过滤$components数组,只保留数据库中已存在的记录(核心:避免新增)
|
|
|
+ // $updateData = array_filter($components, function ($item) use ($existingTypes) {
|
|
|
+ // return in_array($item['component_type'], $existingTypes);
|
|
|
+ // });
|
|
|
+
|
|
|
+ // // 4. 执行upsert(此时$updateData中只有已存在的记录,不会新增)
|
|
|
+ // if (!empty($updateData)) {
|
|
|
+ // $component_sort = Component::upsert($updateData,['component_type'],['sort_id']);
|
|
|
+ // }
|
|
|
+ // if(empty($component_sort)){
|
|
|
+ // Db::rollBack();
|
|
|
+ // return Result::error('组件位置关联失败!');
|
|
|
+ // }
|
|
|
+
|
|
|
Db::commit();
|
|
|
- return Result::success($result);
|
|
|
+ return Result::success($sector);
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
|
return Result::error($e->getMessage());
|
|
|
@@ -1267,7 +1312,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
}
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
- $component_id = SectorComponent::where('sector_id', $sector['sector_id'])->delete();
|
|
|
+ $component_id = SectorComponent::where('sectorid', $data['id'])->delete();
|
|
|
if (empty($component_id)) {
|
|
|
Db::rollBack();
|
|
|
return Result::error('解除相关组件关联关系失败!');
|
|
|
@@ -1297,16 +1342,17 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
return Result::error('通栏不存在!');
|
|
|
}
|
|
|
if($sector['sector_id'] != $data['sector_id']){
|
|
|
- $sector_id = Sector::where('sector_id',$data['sector_id'])->first();
|
|
|
+ $sector_id = Sector::where('sector_id',$data['sector_id'])->where('template_id',$data['template_id'])->first();
|
|
|
if(!empty($sector_id)){
|
|
|
return Result::error('通栏编号已存在!');
|
|
|
}
|
|
|
}
|
|
|
$sector_code = [
|
|
|
- 'sectorName' => strval($data['sector_name']),
|
|
|
- 'sectorId' => intval($data['sector_id']),
|
|
|
- 'sectorType' => intval($data['sector_type']),
|
|
|
- 'sectorPlace' => intval($data['place_type']),
|
|
|
+ $data['sector_id'] => [
|
|
|
+ 'sectorName' => $data['sector_name'],
|
|
|
+ 'sectorHeight' => $data['pic_height'],
|
|
|
+ 'sectorImg' => $data['sector_img'],
|
|
|
+ ]
|
|
|
];
|
|
|
// return Result::success($sector_code);
|
|
|
$data['sector_code'] = json_encode($sector_code);
|
|
|
@@ -1320,65 +1366,85 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
return Result::error('皮肤不存在!');
|
|
|
}
|
|
|
$sort = json_decode($data['component_code'],true);
|
|
|
- $kw = 0;
|
|
|
- $flattened = [];
|
|
|
- $component = [];
|
|
|
$sector_component = [];
|
|
|
foreach ($sort as $key => $subArray) {
|
|
|
- foreach ($subArray as $k => $item) {
|
|
|
- $component[] = $item;
|
|
|
- $sector_component[] = [
|
|
|
- 'sector_id' => $data['sector_id'],
|
|
|
- 'component_id' => $item,
|
|
|
- 'sort_id' => $key + 1,
|
|
|
- 'place_id' => $data['place_type'],
|
|
|
- ];
|
|
|
- }
|
|
|
+ foreach ($subArray as $k => $item) {
|
|
|
+ // // $component[] = $item;
|
|
|
+ $sector_component[] = [
|
|
|
+ 'sector_id' => $data['sector_id'],
|
|
|
+ 'component_id' => $subArray[$k],
|
|
|
+ 'sort_id' => $key + 1,
|
|
|
+ 'place_id' => $data['place_type'],
|
|
|
+ 'sectorid' => $data['id'],
|
|
|
+ ];
|
|
|
+ // // // ---------同步通栏的sort_id到组件之中,目前已废弃,涉及到批量修改------
|
|
|
+ // // $componentTypes[] = $item;
|
|
|
+ // // $components[] = [
|
|
|
+ // // 'sort_id' => $key + 1,
|
|
|
+ // // 'component_type' => $item,
|
|
|
+ // // ];
|
|
|
+ // // $place_ids[] = $data['place_type'];
|
|
|
+ }
|
|
|
}
|
|
|
- // // 批量插入数据到 ComponentSector 表
|
|
|
- // \App\Model\ComponentSector::insert($sector_component);
|
|
|
- $component_num = count($component);
|
|
|
- $count = count(array_unique($component));
|
|
|
- // return Result::success($sector_component);
|
|
|
- if(count($sort) != $data['component_num'] || $component_num != $count){
|
|
|
+ if(count($sort) != $data['component_num']){
|
|
|
return Result::error('组件关联错误!');
|
|
|
}
|
|
|
$data['sector_code'] = json_encode($sector_code);
|
|
|
Db::beginTransaction();
|
|
|
try {
|
|
|
- $com_sector = SectorComponent::where('sector_id', $sector['sector_id'])->pluck('component_id');
|
|
|
+ $com_sector = SectorComponent::where('sectorid', $data['id'])->pluck('component_id');
|
|
|
if(empty($com_sector)){
|
|
|
Db::rollBack();
|
|
|
return Result::error('通栏解除组件关联失败!');
|
|
|
}
|
|
|
- // $up_component = Component::whereIn('component_type',$com_sector)->update(['status' => 1]);
|
|
|
- // if(empty($up_component)){
|
|
|
- // Db::rollBack();
|
|
|
- // return Result::error('通栏解除组件关联失败!');
|
|
|
- // }
|
|
|
- $del_SectorComponent = SectorComponent::where('sector_id', $sector['sector_id'])->delete();
|
|
|
+ $del_SectorComponent = SectorComponent::where('sectorid', $data['id'])->delete();
|
|
|
if(empty($del_SectorComponent)){
|
|
|
Db::rollBack();
|
|
|
- return Result::error('通栏解除组件关联失败!');
|
|
|
+ return Result::error('通栏解除组件关联失败!1');
|
|
|
+ }
|
|
|
+ $sector = Sector::where('id', $data['id'])->update($data);
|
|
|
+ if (empty($sector)) {
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error('修改失败');
|
|
|
}
|
|
|
- $com_sector = SectorComponent::insert($sector_component);
|
|
|
+ $sector_com = array_map(function ($item) use ($data) {
|
|
|
+ // 替换当前记录的sector_id为变量值(保留其他字段不变)
|
|
|
+ $item['sectorid'] = $data['id'];
|
|
|
+ return $item;
|
|
|
+ }, $sector_component);
|
|
|
+ // var_dump($sector_com);
|
|
|
+ $com_sector = SectorComponent::insert($sector_com);
|
|
|
if(empty($com_sector)){
|
|
|
Db::rollBack();
|
|
|
return Result::error('通栏关联组件失败!');
|
|
|
}
|
|
|
+ // ---------同步通栏的sort_id到组件之中,目前已废弃,涉及到批量修改------
|
|
|
// $up_component = Component::whereIn('component_id',$sector_component['component_type'])
|
|
|
// ->update(['status' => 2,]);
|
|
|
// if(empty($up_component)){
|
|
|
// Db::rollBack();
|
|
|
// return Result::error('通栏关联组件失败!');
|
|
|
// }
|
|
|
- $result = Sector::where('id', $data['id'])->update($data);
|
|
|
- if (empty($result)) {
|
|
|
- Db::rollBack();
|
|
|
- return Result::error('修改失败');
|
|
|
- }
|
|
|
+ // 2. 查询数据库中已存在的component_type(只保留存在的记录)
|
|
|
+ // $existingTypes = Component::whereIn('component_type', $componentTypes)
|
|
|
+ // ->pluck('component_type') // 提取存在的component_type
|
|
|
+ // ->toArray();
|
|
|
+ // // 3. 过滤$components数组,只保留数据库中已存在的记录(核心:避免新增)
|
|
|
+ // $updateData = array_filter($components, function ($item) use ($existingTypes) {
|
|
|
+ // return in_array($item['component_type'], $existingTypes);
|
|
|
+ // });
|
|
|
+
|
|
|
+ // // 4. 执行upsert(此时$updateData中只有已存在的记录,不会新增)
|
|
|
+ // if (!empty($updateData)) {
|
|
|
+ // $component_sort = Component::upsert($updateData,['component_type'],['sort_id']);
|
|
|
+ // }
|
|
|
+ // if(empty($component_sort)){
|
|
|
+ // Db::rollBack();
|
|
|
+ // return Result::error('组件位置关联失败!');
|
|
|
+ // }
|
|
|
+
|
|
|
Db::commit();
|
|
|
- return Result::success($result);
|
|
|
+ return Result::success($sector);
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
|
return Result::error($e->getMessage());
|
|
|
@@ -1403,8 +1469,14 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$where['component.type_id'] = $data['type_id'];
|
|
|
}
|
|
|
$result = Component::where($where)
|
|
|
- ->leftJoin('component_type','component_type.id','=','component.type_id')
|
|
|
- ->select( 'component.*', 'component_type.com_typename')
|
|
|
+ ->leftJoin('component_type', 'component_type.id', '=', 'component.type_id')
|
|
|
+ ->leftJoin('component_img', 'component.component_type', '=', 'component_img.component_id')
|
|
|
+ ->select(
|
|
|
+ 'component.*',
|
|
|
+ 'component_type.com_typename',
|
|
|
+ DB::raw('COUNT(component_img.id) as img_count')
|
|
|
+ )
|
|
|
+ ->groupBy('component.id') // 按组件ID分组,确保统计每个组件的图片数量
|
|
|
->orderBy('component.updated_at', 'desc')
|
|
|
->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
|
|
|
if(empty($result)){
|
|
|
@@ -1440,8 +1512,8 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
if(empty($component_type)){
|
|
|
return Result::error('组件分类不存在!');
|
|
|
}
|
|
|
- // 组件分类:1:资讯-头条组件;2:资讯-轮播组件;3:资讯-推荐图类组件;4:资讯-最新类组件;5:资讯-推荐类;6:资讯-热点类组件;
|
|
|
- // 7:资讯-栏目类组件;8:列表类组件;9:详情类组件;10:二级导航栏类组件;11:广告类;12:静态资源类;13:底部导航类;
|
|
|
+ // '组件分类:1:资讯-头条组件;2:资讯-轮播组件;3:资讯-推荐图类组件;4:资讯-最新类组件;5:资讯-推荐类;6:资讯-热点类组件;7:资讯-栏目类组件;
|
|
|
+ // 8:列表类组件;9:详情类组件;10:二级导航栏类组件;11:广告类;12:静态资源类;13:底部导航类;14:广告资讯混合类
|
|
|
$data['type_id'] = intval($data['type_id']);
|
|
|
$add_arr = [
|
|
|
// 'template_id' => intval($data['template_id']),
|
|
|
@@ -1454,9 +1526,10 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
'component_keyword' => $data['component_keyword'],
|
|
|
];
|
|
|
$component_head_code = [
|
|
|
- 'component_type' => $add_arr['component_type'],
|
|
|
- 'type_id' => $add_arr['type_id'],
|
|
|
+ 'component_id' => $add_arr['component_type'],
|
|
|
+ 'component_type' => $add_arr['type_id'],
|
|
|
'component_name' => $add_arr['component_name'],
|
|
|
+ 'component_style' => 1,
|
|
|
];
|
|
|
$add_arr['component_code'] = json_encode($component_head_code,true);
|
|
|
switch($data['type_id']){
|
|
|
@@ -1466,12 +1539,15 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
case 4: //4:资讯-最新类组件;
|
|
|
case 5: //5:资讯-推荐类组件;
|
|
|
case 6: //6:资讯-热点类组件;
|
|
|
+ // $component_data['componentData']['name'] = '';
|
|
|
$add_arr['level'] = $data['type_id'];
|
|
|
$add_arr['img_num'] = intval($data['img_num']);
|
|
|
$add_arr['text_num'] = intval($data['text_num']);
|
|
|
$component_data['componentData'] = [
|
|
|
'category_id' => '',
|
|
|
'level' => $add_arr['level'],
|
|
|
+ 'name' => '',
|
|
|
+ 'category_arr' => [],
|
|
|
'imgSize' => $data['img_num'] ?? '',
|
|
|
'textSize' => $data['text_num'] ?? '',
|
|
|
'child' => [
|
|
|
@@ -1480,10 +1556,17 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
'textSize' => ''
|
|
|
]
|
|
|
];
|
|
|
+ if($data['type_id'] == 4){
|
|
|
+ $component_data['componentData']['name'] = '热点精选';
|
|
|
+ }
|
|
|
+ if($data['type_id'] == 5){
|
|
|
+ $component_data['componentData']['name'] = '热点精选';
|
|
|
+ }
|
|
|
$add_arr['component_data'] = json_encode($component_data, true);
|
|
|
$add_arr['component_column'] = $component_type['com_code'] ?? '';
|
|
|
break;
|
|
|
case 7: //7:资讯-栏目类组件;
|
|
|
+ case 15: //15:滚动图文类;
|
|
|
$add_arr['img_num'] = intval($data['img_num']);
|
|
|
$add_arr['text_num'] = intval($data['text_num']);
|
|
|
$add_arr['child_imgnum'] = intval($data['child_imgnum'] ?? null);
|
|
|
@@ -1491,6 +1574,8 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$component_data['componentData'] = [
|
|
|
'category_id' => '',
|
|
|
'level' => '',
|
|
|
+ 'name' => '',
|
|
|
+ 'category_arr' => [],
|
|
|
'imgSize' => $add_arr['img_num'] ?? '',
|
|
|
'textSize' => $add_arr['text_num'] ?? '',
|
|
|
'child' => [
|
|
|
@@ -1538,7 +1623,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$add_arr['component_width'] = intval($data['ad_width']);
|
|
|
$add_arr['component_height'] = intval($data['ad_height']);
|
|
|
$add_arr['ad_type'] = intval($data['ad_type']);
|
|
|
- $add_arr['ad_img'] = $data['ad_img'];
|
|
|
+ // $add_arr['ad_img'] = $data['ad_img'];
|
|
|
$ad = [
|
|
|
'width' => $add_arr['ad_width'],
|
|
|
'height' => $add_arr['ad_height'],
|
|
|
@@ -1546,17 +1631,19 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
'price' => '',
|
|
|
'introduce' => '',
|
|
|
'website_id' => '',
|
|
|
- 'thumb' => $add_arr['ad_img'],
|
|
|
+ // 'thumb' => $add_arr['ad_img'],
|
|
|
'typeid' => $add_arr['ad_type'],
|
|
|
'ad_tag' => '',
|
|
|
];
|
|
|
$add_arr['ad'] = json_encode($ad,true);
|
|
|
$add_arr['component_column'] = $component_type['com_code'] ?? '';
|
|
|
- $add_arr['adimg_info'] = $data['img_info'];
|
|
|
- $ad_imginfo = json_decode($data['img_info'],true);
|
|
|
+ // $add_arr['adimg_info'] = $data['img_info'];
|
|
|
+ // $ad_imginfo = json_decode($data['img_info'],true);
|
|
|
|
|
|
break;
|
|
|
- case 13: //13:底部导航类;
|
|
|
+ // case 13: //13:底部导航类;
|
|
|
+ case 17: //17:单页列表类;
|
|
|
+ case 18: //18:单页详情类;
|
|
|
$component_data['componentData'] = [
|
|
|
'fcat_id' => '',
|
|
|
];
|
|
|
@@ -1577,6 +1664,8 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$component_data['componentData'] = [
|
|
|
'category_id' => '',
|
|
|
'level' => '',
|
|
|
+ 'name' => '',
|
|
|
+ 'category_arr' => [],
|
|
|
'imgSize' => $data['img_num'] ?? '',
|
|
|
'textSize' => $data['text_num'] ?? '',
|
|
|
'child' => [
|
|
|
@@ -1599,22 +1688,23 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$add_arr['ad'] = json_encode($ad,true);
|
|
|
$add_arr['component_data'] = json_encode($component_data,true);
|
|
|
$add_arr['component_column'] = $component_type['com_code'] ?? '';
|
|
|
- $add_arr['adimg_info'] = $data['img_info'];
|
|
|
- $ad_imginfo = json_decode($data['img_info'],true);
|
|
|
+ // $add_arr['adimg_info'] = $data['img_info'];
|
|
|
+ // $ad_imginfo = json_decode($data['img_info'],true);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
if($data['type_id'] == 11 || $data['type_id'] == 14){
|
|
|
Db::beginTransaction();
|
|
|
try{
|
|
|
- $website_img = WebsiteImg::insertGetId($ad_imginfo);
|
|
|
- var_dump($website_img);
|
|
|
- $add_arr['ad_imgid'] = $website_img;
|
|
|
- if(empty($website_img)){
|
|
|
- Db::rollBack();
|
|
|
- return Result::error('广告默认图上传失败!');
|
|
|
- }
|
|
|
+ // $website_img = WebsiteImg::insertGetId($ad_imginfo);
|
|
|
+ // var_dump($website_img);
|
|
|
+ // $add_arr['ad_imgid'] = $website_img;
|
|
|
+ // if(empty($website_img)){
|
|
|
+ // Db::rollBack();
|
|
|
+ // return Result::error('广告默认图上传失败!');
|
|
|
+ // }
|
|
|
$result = Component::insertGetId($add_arr);
|
|
|
if(empty($result)){
|
|
|
Db::rollBack();
|
|
|
@@ -1646,14 +1736,22 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
}
|
|
|
Db::beginTransaction();
|
|
|
try{
|
|
|
- if($component['type_id'] == 11 || $component['type_id'] == 14){
|
|
|
- $ad_img = WebsiteImg::where('id',$component['ad_imgid'])->first();
|
|
|
- if(!empty($ad_img)){
|
|
|
- $ad_img = WebsiteImg::where('id',$component['ad_imgid'])->delete();
|
|
|
- if(empty($ad_img)){
|
|
|
- Db::rollBack();
|
|
|
- return Result::error('删除广告默认图失败!');
|
|
|
- }
|
|
|
+ // if($component['type_id'] == 11 || $component['type_id'] == 14){
|
|
|
+ // $ad_img = WebsiteImg::where('id',$component['ad_imgid'])->first();
|
|
|
+ // if(!empty($ad_img)){
|
|
|
+ // $ad_img = WebsiteImg::where('id',$component['ad_imgid'])->delete();
|
|
|
+ // if(empty($ad_img)){
|
|
|
+ // Db::rollBack();
|
|
|
+ // return Result::error('删除广告默认图失败!');
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ $component_img = ComponentImg::where('component_id',$component['component_type'])->first();
|
|
|
+ if(!empty($component_img)){
|
|
|
+ $del_img = ComponentImg::where('component_id',$component['component_type'])->delete();
|
|
|
+ if(empty($del_img)){
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error('删除组件预览图失败!');
|
|
|
}
|
|
|
}
|
|
|
$result = Component::where('id',$data['id'])->delete();
|
|
|
@@ -1661,6 +1759,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
Db::rollBack();
|
|
|
return Result::error('删除失败!');
|
|
|
}
|
|
|
+
|
|
|
Db::commit();
|
|
|
return Result::success($result);
|
|
|
}catch(\Exception $e){
|
|
|
@@ -1700,9 +1799,10 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
'component_keyword' => $data['component_keyword'],
|
|
|
];
|
|
|
$component_head_code = [
|
|
|
- 'component_type' => $add_arr['component_type'],
|
|
|
- 'type_id' => $add_arr['type_id'],
|
|
|
+ 'component_id' => $add_arr['component_type'],
|
|
|
+ 'component_type' => $add_arr['type_id'],
|
|
|
'component_name' => $add_arr['component_name'],
|
|
|
+ 'component_style' => 1,
|
|
|
];
|
|
|
$add_arr['component_code'] = json_encode($component_head_code,true);
|
|
|
switch($data['type_id']){
|
|
|
@@ -1712,12 +1812,15 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
case 4: //4:资讯-最新类组件;
|
|
|
case 5: //5:资讯-推荐类组件;
|
|
|
case 6: //6:资讯-热点类组件;
|
|
|
+ // $component_data['componentData']['name'] = '';
|
|
|
$add_arr['level'] = $data['type_id'];
|
|
|
$add_arr['img_num'] = intval($data['img_num']);
|
|
|
$add_arr['text_num'] = intval($data['text_num']);
|
|
|
$component_data['componentData'] = [
|
|
|
'category_id' => '',
|
|
|
'level' => $add_arr['level'],
|
|
|
+ 'category_arr' => [],
|
|
|
+ 'name' => '',
|
|
|
'imgSize' => $data['img_num'] ?? '',
|
|
|
'textSize' => $data['text_num'] ?? '',
|
|
|
'child' => [
|
|
|
@@ -1726,10 +1829,17 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
'textSize' => ''
|
|
|
]
|
|
|
];
|
|
|
+ if($data['type_id'] == 4){
|
|
|
+ $component_data['componentData']['name'] = '最新资讯';
|
|
|
+ }
|
|
|
+ if($data['type_id'] == 5){
|
|
|
+ $component_data['componentData']['name'] = '热点精选';
|
|
|
+ }
|
|
|
$add_arr['component_data'] = json_encode($component_data, true);
|
|
|
$add_arr['component_column'] = $component_type['com_code'] ?? '';
|
|
|
break;
|
|
|
case 7: //7:资讯-栏目类组件;
|
|
|
+ case 15: //15:滚动图文类;
|
|
|
$add_arr['img_num'] = intval($data['img_num']);
|
|
|
$add_arr['text_num'] = intval($data['text_num']);
|
|
|
$add_arr['child_imgnum'] = intval($data['child_imgnum'] ?? null);
|
|
|
@@ -1737,6 +1847,8 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$component_data['componentData'] = [
|
|
|
'category_id' => '',
|
|
|
'level' => '',
|
|
|
+ 'name' => '',
|
|
|
+ 'category_arr' => [],
|
|
|
'imgSize' => $add_arr['img_num'] ?? '',
|
|
|
'textSize' => $add_arr['text_num'] ?? '',
|
|
|
'child' => [
|
|
|
@@ -1784,7 +1896,7 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$add_arr['component_width'] = intval($data['ad_width']);
|
|
|
$add_arr['component_height'] = intval($data['ad_height']);
|
|
|
$add_arr['ad_type'] = intval($data['ad_type']);
|
|
|
- $add_arr['ad_img'] = $data['ad_img'];
|
|
|
+ // $add_arr['ad_img'] = $data['ad_img'];
|
|
|
$ad = [
|
|
|
'width' => $add_arr['ad_width'],
|
|
|
'height' => $add_arr['ad_height'],
|
|
|
@@ -1793,15 +1905,17 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
'introduce' => '',
|
|
|
'website_id' => '',
|
|
|
'thumb' => $add_arr['ad_img'],
|
|
|
- 'typeid' => $add_arr['ad_type'],
|
|
|
+ // 'typeid' => $add_arr['ad_type'],
|
|
|
'ad_tag' => '',
|
|
|
];
|
|
|
$add_arr['ad'] = json_encode($ad,true);
|
|
|
$add_arr['component_column'] = $component_type['com_code'] ?? '';
|
|
|
- $add_arr['adimg_info'] = $data['img_info'];
|
|
|
- $ad_imginfo = json_decode($data['img_info'],true);
|
|
|
+ // $add_arr['adimg_info'] = $data['img_info'];
|
|
|
+ // $ad_imginfo = json_decode($data['img_info'],true);
|
|
|
break;
|
|
|
- case 13: //13:底部导航类;
|
|
|
+ // case 13: //13:底部导航类;
|
|
|
+ case 17: //17:单页列表类;
|
|
|
+ case 18: //18:单页详情类;
|
|
|
$component_data['componentData'] = [
|
|
|
'fcat_id' => '',
|
|
|
];
|
|
|
@@ -1822,6 +1936,8 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$component_data['componentData'] = [
|
|
|
'category_id' => '',
|
|
|
'level' => '',
|
|
|
+ 'name' => '',
|
|
|
+ 'category_arr' => [],
|
|
|
'imgSize' => $data['img_num'] ?? '',
|
|
|
'textSize' => $data['text_num'] ?? '',
|
|
|
'child' => [
|
|
|
@@ -1844,8 +1960,8 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$add_arr['ad'] = json_encode($ad,true);
|
|
|
$add_arr['component_data'] = json_encode($component_data,true);
|
|
|
$add_arr['component_column'] = $component_type['com_code'] ?? '';
|
|
|
- $add_arr['adimg_info'] = $data['img_info'];
|
|
|
- $ad_imginfo = json_decode($data['img_info'],true);
|
|
|
+ // $add_arr['adimg_info'] = $data['img_info'];
|
|
|
+ // $ad_imginfo = json_decode($data['img_info'],true);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -1865,52 +1981,52 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
'article_id' => null,
|
|
|
'cate_place' => null,
|
|
|
'pageSize' => null,
|
|
|
- 'ad_img' => null,
|
|
|
+ // 'ad_img' => null,
|
|
|
'ad_width' => null,
|
|
|
'ad_height' => null,
|
|
|
'ad' => '',
|
|
|
'ad_type' => null,
|
|
|
- 'ad_imgid' => null,
|
|
|
+ // 'ad_imgid' => null,
|
|
|
'adimg_info' => '[]',
|
|
|
];
|
|
|
Db::beginTransaction();
|
|
|
try{
|
|
|
- // return Result::success($add_arr);
|
|
|
- if(($component['type_id'] == 11 || $component['type_id'] == 14) && ($data['type_id'] != 11 && $data['type_id'] != 14)){
|
|
|
- $website_img = WebsiteImg::where('id',$component['ad_imgid'])->delete();
|
|
|
+ // return Result::success($add_arr);
|
|
|
+ // if(($component['type_id'] == 11 || $component['type_id'] == 14) && ($data['type_id'] != 11 && $data['type_id'] != 14)){
|
|
|
+ // // $website_img = WebsiteImg::where('id',$component['ad_imgid'])->delete();
|
|
|
|
|
|
- if(empty($website_img)){
|
|
|
- Db::rollBack();
|
|
|
- return Result::error('广告默认图删除失败!');
|
|
|
- }
|
|
|
- var_dump("删除",$website_img);
|
|
|
+ // if(empty($website_img)){
|
|
|
+ // Db::rollBack();
|
|
|
+ // return Result::error('广告默认图删除失败!');
|
|
|
+ // }
|
|
|
+ // var_dump("删除",$website_img);
|
|
|
|
|
|
- }
|
|
|
- if(($data['type_id'] == 11 || $data['type_id'] == 14) && ($component['type_id'] != 11 && $component['type_id'] != 14)){
|
|
|
- $website_img = WebsiteImg::insertGetId($ad_imginfo);
|
|
|
- $add_arr['ad_imgid'] = $website_img;
|
|
|
- if(empty($website_img)){
|
|
|
- Db::rollBack();
|
|
|
- return Result::error('广告默认图上传失败!');
|
|
|
- }
|
|
|
- var_dump("上传",$website_img);
|
|
|
+ // }
|
|
|
+ // if(($data['type_id'] == 11 || $data['type_id'] == 14) && ($component['type_id'] != 11 && $component['type_id'] != 14)){
|
|
|
+ // $website_img = WebsiteImg::insertGetId($ad_imginfo);
|
|
|
+ // $add_arr['ad_imgid'] = $website_img;
|
|
|
+ // if(empty($website_img)){
|
|
|
+ // Db::rollBack();
|
|
|
+ // return Result::error('广告默认图上传失败!');
|
|
|
+ // }
|
|
|
+ // var_dump("上传",$website_img);
|
|
|
|
|
|
- }
|
|
|
- if(($component['type_id'] == 11 || $component['type_id'] == 14) && ($data['type_id'] == 11 || $data['type_id'] == 14)){
|
|
|
- $website_img = WebsiteImg::where('id',$component['ad_imgid'])->first();
|
|
|
- if(empty($website_img)){
|
|
|
- $website_img = WebsiteImg::insertGetId($ad_imginfo);
|
|
|
- $add_arr['ad_imgid'] = $website_img;
|
|
|
- }else{
|
|
|
- $website_img = WebsiteImg::where('id',$component['ad_imgid'])->update($ad_imginfo);
|
|
|
- $add_arr['ad_imgid'] = $component['ad_imgid'];
|
|
|
- }
|
|
|
- if(empty($website_img)){
|
|
|
- Db::rollBack();
|
|
|
- return Result::error('广告默认图修改失败!');
|
|
|
- }
|
|
|
+ // }
|
|
|
+ // if(($component['type_id'] == 11 || $component['type_id'] == 14) && ($data['type_id'] == 11 || $data['type_id'] == 14)){
|
|
|
+ // $website_img = WebsiteImg::where('id',$component['ad_imgid'])->first();
|
|
|
+ // if(empty($website_img)){
|
|
|
+ // $website_img = WebsiteImg::insertGetId($ad_imginfo);
|
|
|
+ // $add_arr['ad_imgid'] = $website_img;
|
|
|
+ // }else{
|
|
|
+ // $website_img = WebsiteImg::where('id',$component['ad_imgid'])->update($ad_imginfo);
|
|
|
+ // $add_arr['ad_imgid'] = $component['ad_imgid'];
|
|
|
+ // }
|
|
|
+ // if(empty($website_img)){
|
|
|
+ // Db::rollBack();
|
|
|
+ // return Result::error('广告默认图修改失败!');
|
|
|
+ // }
|
|
|
|
|
|
- }
|
|
|
+ // }
|
|
|
$add_arr = array_merge($cll_column,$add_arr);
|
|
|
$result = Component::where('id',$id)->update($add_arr);
|
|
|
if(empty($result)){
|
|
|
@@ -2517,16 +2633,27 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
return Result::success($component_type);
|
|
|
}
|
|
|
/**
|
|
|
- * 组件管理-获取所有组件
|
|
|
+ * 组件管理-获取所有组件样式
|
|
|
*/
|
|
|
public function getAllComponent(array $data): array
|
|
|
{
|
|
|
$where = [];
|
|
|
if((isset($data['sector_id']) && !empty($data['sector_id'])) || (isset($data['sort_id']) && !empty($data['sort_id']))){
|
|
|
- $sector['sector_component.sector_id'] = $data['sector_id'];
|
|
|
+ $sector_id['sector.sector_id'] = $data['sector_id'];
|
|
|
$sector['sector_component.sort_id'] = $data['sort_id'];
|
|
|
- $where = SectorComponent::where($sector)->pluck('component_id')->toArray();
|
|
|
- $component = Component::whereIn('component_type',$where)->get()->all();
|
|
|
+ $sectors = Sector::where($sector_id)
|
|
|
+ ->where('sector.template_id',$data['template_id'])
|
|
|
+ ->leftJoin('sector_component','sector.id','sector_component.sectorid')
|
|
|
+ ->where($sector)
|
|
|
+ ->select('sector.template_id','sector_component.component_id')
|
|
|
+ ->get()->all();
|
|
|
+ // return Result::success($sectors);
|
|
|
+ $component_id = array_column($sectors,'component_id');
|
|
|
+ $template = ['template_id' => $sectors[0]['template_id']];
|
|
|
+ $component = ComponentImg::whereIn('component_id',$component_id)
|
|
|
+ ->where($template)
|
|
|
+ ->select('img_id','img_name','img_url','template_id')
|
|
|
+ ->get()->all();
|
|
|
}else{
|
|
|
if(isset($data['type_id']) && !empty($data['type_id'])){
|
|
|
$where['component.type_id'] = $data['type_id'];
|
|
|
@@ -2538,8 +2665,8 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
$where['component.component_height'] = $data['height'];
|
|
|
}
|
|
|
$component = Component::where($where)
|
|
|
- // ->leftJoin('size','component.size_id','=','size.id')
|
|
|
- // ->select('component.*','size.width','size.height')
|
|
|
+ ->leftJoin('component_img','component.component_id','=','component_img.component_id')
|
|
|
+ ->select('component.*','component_img.img_id','component_img.img_url','img_name')
|
|
|
->get()->all();
|
|
|
}
|
|
|
|
|
|
@@ -2555,19 +2682,139 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
{
|
|
|
$where = [];
|
|
|
if(isset($data['template_id']) && !empty($data['template_id'])){
|
|
|
- $where['template_id'] = $data['template_id'];
|
|
|
+ $where['sector.template_id'] = $data['template_id'];
|
|
|
}
|
|
|
if(isset($data['page_type']) && !empty($data['page_type'])){
|
|
|
- array_push($where,['page_type', 'like', '%'.$data['page_type'].'%']);
|
|
|
+ array_push($where,['sector.page_type', 'like', '%'.$data['page_type'].'%']);
|
|
|
}
|
|
|
$sector = Sector::where($where)
|
|
|
- // ->leftJoin('size','sector.size_id','=','size.id')
|
|
|
- ->select('sector.*')
|
|
|
+ ->leftJoin('sector_component', 'sector.id', '=', 'sector_component.sectorid')
|
|
|
+ ->leftJoin('component', 'sector_component.component_id', '=', 'component.component_type')
|
|
|
+ ->when(isset($data['template_id']), function ($query) use ($data) {
|
|
|
+ // 当 type_id 等于 11 时,关联查询 component_img 表并添加 img_url 字段
|
|
|
+ return $query->leftJoin('component_img', function ($join) use ($data) {
|
|
|
+ $join->on('component.component_type', '=', 'component_img.component_id')
|
|
|
+ ->where('component_img.template_id', $data['template_id'])
|
|
|
+ ->where('component.type_id', 11);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->select('sector.sector_name', 'sector.sector_id', 'component.*', 'component_img.img_url'
|
|
|
+ ,'sector.pic_height','sector.sector_img','sector_component.sort_id')
|
|
|
+ ->orderBy('sector_component.sort_id')
|
|
|
+ ->orderBy('sector_component.sector_id')
|
|
|
->get()->all();
|
|
|
if(empty($sector)){
|
|
|
return Result::error('通栏不存在!');
|
|
|
}
|
|
|
- return Result::success($sector);
|
|
|
+ $com_num = array_count_values(array_column($sector,'sector_id'));
|
|
|
+ // 使用 array_keys 和 array_diff 函数,不使用循环将值不为 1 的字段键提取到 $sectors_key 中
|
|
|
+ $sectors_key = array_keys(array_diff($com_num, [1]));
|
|
|
+ // return Result::success($sector);
|
|
|
+ $num = 0;
|
|
|
+ $array_key = 0;
|
|
|
+ foreach($sector as $key => $value){
|
|
|
+ $sector_id = $value['sector_id'];
|
|
|
+ $sectors[$key] = $value['sector_id'];
|
|
|
+ // if(isset($comlist_key) && !empty($comlist_key)){
|
|
|
+ // $sector_arr_key[$key] = array_keys($comlist_key);
|
|
|
+ // }
|
|
|
+ if(in_array($sector_id,$sectors_key) && in_array($sector_id,$sectors)){
|
|
|
+ $array_key = array_search($sector_id,$sectors);
|
|
|
+ if(isset($sectors) && !in_array($sector_id,$sectors)){
|
|
|
+ $array_key++;
|
|
|
+ }
|
|
|
+ $num++;
|
|
|
+ $array_key++;
|
|
|
+ }else{
|
|
|
+ $array_key++;
|
|
|
+ }
|
|
|
+ // var_dump($array_key);
|
|
|
+ // var_dump(in_array($sector_id,$sectors_key));
|
|
|
+ $comlist_key[$array_key][$sector_id]['sectorName'] = $value['sector_name'];
|
|
|
+ $comlist_key[$array_key][$sector_id]['sectorHeight'] = $value['pic_height'];
|
|
|
+ $comlist_key[$array_key][$sector_id]['sectorImg'] = $value['sector_img'];
|
|
|
+ $componentList['component_style'] = 1;
|
|
|
+ $componentList['sort'] = $value['sort_id'];
|
|
|
+ // 1:资讯;2:广告;3:静态;
|
|
|
+ $component_data = empty($value['component_data']) ? null : (json_decode($value['component_data']) ?? []);
|
|
|
+ // 检查 $value['component_column'] 是否为非空字符串,避免传递 null 给 json_decode
|
|
|
+ $listType = empty($value['component_column']) ? null : (json_decode($value['component_column']) ?? []);;
|
|
|
+ // $page[$key][$setor_id]['componentList'] =
|
|
|
+ // 组件分类:1:资讯-头条组件;2:资讯-轮播组件;3:资讯-推荐图类组件;4:资讯-最新类组件;5:资讯-推荐类;6:资讯-热点类组件;7:资讯-栏目类组件;8:列表类组件;9:详情类组件;
|
|
|
+ // 10:二级导航栏类组件;11:广告类;12:静态资源类;13:单页导航类;14:广告资讯混合类;15:滚动图文;16:搜索框类;17:单页列表类;18:单页详情类;
|
|
|
+ if(in_array($value['type_id'],[1,2,3,4,5,6,7,8,9,15,17,18])){
|
|
|
+ $type = 1;
|
|
|
+ $componentList['component_type'] = $type;
|
|
|
+ if(in_array($value['type_id'],[7,15]) && $data['page_type'] == 1){
|
|
|
+ $component_data->componentData->name = '请选择导航..';
|
|
|
+ }else if(in_array($value['type_id'],[7,15]) && $data['page_type'] == 2){
|
|
|
+ $component_data->componentData->name = '自动生成';
|
|
|
+ }else if($data['page_type'] == 3){
|
|
|
+ if($value['type_id'] == 4){
|
|
|
+ $component_data->componentData->name = '最新资讯';
|
|
|
+ }
|
|
|
+ if($value['type_id'] == 6){
|
|
|
+ $component_data->componentData->name = '热点精选';
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ unset($component_data->componentData->name);
|
|
|
+ }
|
|
|
+ $componentData = $component_data->componentData;
|
|
|
+ $componentList['componentData'] = is_object($componentData) ? (array)$componentData ?? [] : $componentData ?? [];
|
|
|
+
|
|
|
+ // $page_listType = is_object($listType) ? (array)$listType->listType ?? [] : $listType['listType'] ?? [];
|
|
|
+ $componentList['componentData']['listType'] = $listType->listType;
|
|
|
+ }else if(in_array($value['type_id'],[10,12,13,16])){
|
|
|
+ $type = 3;
|
|
|
+ $componentList['component_type'] = $type;
|
|
|
+ $componentList['componentData']=(object)[];
|
|
|
+ }else if($value['type_id']== 11){
|
|
|
+ $type = 2;
|
|
|
+ $componentList['component_type'] = $type;
|
|
|
+ $componentList['componentData']=(object)[];
|
|
|
+ $ad = json_decode($value['ad']) ?? [];
|
|
|
+ if(is_object($ad)){
|
|
|
+ $ad->thumb = $value['img_url'];
|
|
|
+ }else{
|
|
|
+ $ad['thumb'] = $value['img_url'];
|
|
|
+ }
|
|
|
+ $comlist_key[$array_key][$sector_id]['ad'] =is_object($ad) ? (array)$ad ?? [] : $ad ?? [];
|
|
|
+ // 在 $page[$key][$setor_id] 中增加一个键值为 ad 的数组
|
|
|
+ // $page[$key][$setor_id]['ad'] = is_object($ad) ? (array)$ad->ad ?? [] : $ad['ad'] ?? [];
|
|
|
+
|
|
|
+ }else if($value['type_id'] == 14){
|
|
|
+ $type = 1;
|
|
|
+ $componentList['component_type'] = $type;
|
|
|
+ if($data['page_type'] == 1){
|
|
|
+ $component_data->componentData->name = '请选择导航..';
|
|
|
+ }
|
|
|
+ $componentData = $component_data->componentData;
|
|
|
+ $componentList['componentData'] = is_object($componentData) ? (array)$componentData ?? [] : $componentData ?? [];
|
|
|
+ $componentList['componentData']['listType'] = $listType->listType;
|
|
|
+ $ad = json_decode($value['ad']) ?? [];
|
|
|
+ $comlist_key[$array_key][$sector_id]['ad'] =is_object($ad) ? (array)$ad ?? [] : $ad ?? [];
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
+ if( in_array($sector_id,$sectors_key)){
|
|
|
+ $comlist_key[$array_key][$sector_id]['componentList'][$num-1] = $componentList;
|
|
|
+ $comlist_key[$array_key][$sector_id]['componentList'] = array_values($comlist_key[$array_key][$sector_id]['componentList']);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $comlist_key[$array_key][$sector_id]['componentList'] = $componentList;
|
|
|
+ }
|
|
|
+ $keys[$key] = $key;
|
|
|
+ }
|
|
|
+ // return Result::success($sector_arr_key);
|
|
|
+ // $page[$keys] = array_column($page,$sectors_key[0]);
|
|
|
+ $comlist_key = array_values($comlist_key);
|
|
|
+ // $sector_page = json_encode($comlist_key);
|
|
|
+ if(empty($comlist_key)){
|
|
|
+ return Result::error('通栏不存在!');
|
|
|
+ }
|
|
|
+ return Result::success($comlist_key);
|
|
|
+ // return Result::success(gettype($listType));
|
|
|
}
|
|
|
/**
|
|
|
* 自助建站-组件管理-获取组件预览图列表
|
|
|
@@ -2584,9 +2831,13 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
->leftJoin('component','component_img.component_id','=','component.component_type')
|
|
|
->select('component_img.*','template.template_name','component.component_name')
|
|
|
->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
|
- if(empty($component_img)){
|
|
|
+ if($component_img->isEmpty()){
|
|
|
return Result::error('组件预览图不存在!');
|
|
|
}
|
|
|
+ $component_img = [
|
|
|
+ 'data' => $component_img->items(),
|
|
|
+ 'total' => $component_img->total(),
|
|
|
+ ];
|
|
|
return Result::success($component_img);
|
|
|
}
|
|
|
/**
|
|
|
@@ -2595,9 +2846,19 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
public function addComponentImg(array $data): array
|
|
|
{
|
|
|
unset($data['user_id']);
|
|
|
- $img = ComponentImg::where('component_id',$data['component_id'])->where('template_id',$data['template_id'])->get()->all();
|
|
|
- if(!empty($img)){
|
|
|
- return Result::error('该组件已存在此皮肤的预览图!');
|
|
|
+ $component = Component::where('component_type',$data['component_id'])->first();
|
|
|
+ if(empty($component)){
|
|
|
+ return Result::error('组件不存在!');
|
|
|
+ }
|
|
|
+ if($component['type_id'] == 11){
|
|
|
+ $img = ComponentImg::where('component_id',$data['component_id'])->where('template_id',$data['template_id'])->get()->all();
|
|
|
+ if(!empty($img)){
|
|
|
+ return Result::error('该组件已存在此皮肤的预览图!');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $component = ComponentImg::where('template_id',$data['template_id'])->where('component_id',$data['component_id'])->where('img_id',$data['img_id'])->first();
|
|
|
+ if(!empty($component)){
|
|
|
+ return Result::error('组件预览图编号已存在!');
|
|
|
}
|
|
|
$component_img = ComponentImg::insertGetId($data);
|
|
|
if(empty($component_img)){
|
|
|
@@ -2621,10 +2882,21 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
*/
|
|
|
public function updateComponentImg(array $data): array
|
|
|
{
|
|
|
- $img = ComponentImg::where('id','!=',$data['id'])->where('component_id',$data['component_id'])->where('template_id',$data['template_id'])->get()->all();
|
|
|
- if(!empty($img)){
|
|
|
- return Result::error('该组件已存在此皮肤的预览图!');
|
|
|
+ $component = Component::where('component_type',$data['component_id'])->first();
|
|
|
+ if(empty($component)){
|
|
|
+ return Result::error('组件不存在!');
|
|
|
+ }
|
|
|
+ if($component['type_id'] == 11){
|
|
|
+ $img = ComponentImg::where('id','!=',$data['id'])->where('component_id',$data['component_id'])->where('template_id',$data['template_id'])->get()->all();
|
|
|
+ if(!empty($img)){
|
|
|
+ return Result::error('该组件已存在此皮肤的预览图!');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $component = ComponentImg::where('id','!=',$data['id'])->where('component_id',$data['component_id'])->where('template_id',$data['template_id'])->where('img_id',$data['img_id'])->first();
|
|
|
+ if(!empty($component)){
|
|
|
+ return Result::error('组件预览图编号已存在!');
|
|
|
}
|
|
|
+ // return Result::success($component);
|
|
|
unset($data['user_id']);
|
|
|
// unset($data['updated_at']);
|
|
|
$id = $data['id'];
|
|
|
@@ -2637,7 +2909,17 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
}
|
|
|
return Result::success($component_img);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 自助建站-获取通栏类型
|
|
|
+ */
|
|
|
+ public function getSectorType(array $data): array
|
|
|
+ {
|
|
|
+ $sector = SectorType::get()->all();
|
|
|
+ if(empty($sector)){
|
|
|
+ return Result::error('通栏类型不存在!');
|
|
|
+ }
|
|
|
+ return Result::success($sector);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
}
|