|
@@ -1008,6 +1008,9 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
} else {
|
|
|
$size_id = [];
|
|
|
}
|
|
|
+ if(isset($data['page_type']) && !empty($data['page_type'])){
|
|
|
+ array_push($where, ['sector.page_type', 'like', '%' . $data['page_type'] . '%']);
|
|
|
+ }
|
|
|
$result = Sector::when(!empty($size_id), function ($query) use ($size_id) {
|
|
|
$query->whereIn('sector.size_id', $size_id);
|
|
|
})
|
|
@@ -1016,9 +1019,9 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
->leftJoin('template_class', 'template_class.class_id', '=', 'template.template_class_id')
|
|
|
->leftJoin('sector_place', 'sector_place.sector_type', '=', 'sector.place_type')
|
|
|
->where($where)
|
|
|
- ->where('sector_place.type_id',1)
|
|
|
- ->select('sector.*', 'size.width','size.height','template_class.name as class_name','template.template_name'
|
|
|
- ,'sector_place.name as place_name','sector_place.sector_img as place_img')
|
|
|
+ ->where('sector_place.type_id', 1)
|
|
|
+ ->select('sector.*', 'size.width', 'size.height', 'template_class.name as class_name', 'template_class.class_id', 'template.template_name',
|
|
|
+ 'sector_place.name as place_name', 'sector_place.sector_img as place_img')
|
|
|
->orderBy('sector.id', 'desc')
|
|
|
->paginate($data['page_size'], ['*'], 'page', $data['page']);
|
|
|
if(empty($result)){
|
|
@@ -1237,27 +1240,48 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
}
|
|
|
public function getComponentList(array $data): array
|
|
|
{
|
|
|
- var_dump($data, '---------');
|
|
|
$where = [];
|
|
|
- // $where[] = ['sector.id', '=', $data['id']];
|
|
|
- if (!empty($data['template_class_id'])) {
|
|
|
- $where['template_class.id'] = $data['template_class_id'];
|
|
|
+ if (isset($data['template_class_id']) && !empty($data['template_class_id'])) {
|
|
|
+ $where['template_class.class_id'] = $data['template_class_id'];
|
|
|
}
|
|
|
- if (!empty($data['component_name'])) {
|
|
|
- $where['component.component_name'] = $data['component_name'];
|
|
|
+ if (isset($data['component_name']) && !empty($data['component_name'])) {
|
|
|
+ array_push($where, ['component.component_name', 'like', '%' . $data['component_name'] . '%']);
|
|
|
}
|
|
|
- if (!empty($data['sector_id'])) {
|
|
|
- $where['sector.id'] = $data['sector_id'];
|
|
|
+ if (isset($data['sector_id']) && !empty($data['sector_id'])) {
|
|
|
+ $where['component.sector_id'] = $data['sector_id'];
|
|
|
};
|
|
|
-
|
|
|
- $result = Component::where($where)
|
|
|
- ->leftJoin('template', 'template.id', '=', 'component.template_id')
|
|
|
- ->leftJoin('template_class', 'template_class.id', '=', 'template.template_class_id') // 添加这一行
|
|
|
- ->leftJoin('sector', 'sector.id', '=', 'component.sector_id')
|
|
|
- ->select('template_class.name as template_class_name', 'template.template_name as template_name', 'template_class.id as template_class_id', 'sector.sector_name as sector_name', 'component.*', 'sector.id as sector_id') // 修改这一行)
|
|
|
+ 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'] . '%')->pluck('id');
|
|
|
+ } else if (isset($data['width']) && !empty($data['width'])) {
|
|
|
+ $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'] . '%')->pluck('id');
|
|
|
+ } else {
|
|
|
+ $size_id = [];
|
|
|
+ }
|
|
|
+ if(isset($data['page_type']) && !empty($data['page_type'])){
|
|
|
+ array_push($where, ['component.page_type', 'like', '%' . $data['page_type'] . '%']);
|
|
|
+ }
|
|
|
+ if(isset($data['type_id']) && !empty($data['type_id'])){
|
|
|
+ $where['component.type_id'] = $data['type_id'];
|
|
|
+ }
|
|
|
+ $result = Component::when(!empty($size_id), function ($query) use ($size_id) {
|
|
|
+ $query->whereIn('component.size_id', $size_id);
|
|
|
+ })
|
|
|
+ ->where($where)
|
|
|
+ ->leftJoin('template', 'template.template_id', '=', 'component.template_id')
|
|
|
+ ->leftJoin('template_class', 'template.template_class_id', '=', 'template_class.class_id') // 添加与 template_class 的关联
|
|
|
+ ->leftJoin('sector', 'sector.sector_id', '=', 'component.sector_id')
|
|
|
+ ->leftJoin('size','size.id','=','component.size_id')
|
|
|
+ ->leftJoin('component_type','component_type.id','=','component.type_id')
|
|
|
+ ->select( 'component.*', 'sector.sector_id','sector.sector_name','template.template_id',
|
|
|
+ 'template.template_name','template_class.class_id', 'template_class.name as class_name',
|
|
|
+ 'size.width','size.height','component_type.com_typename')
|
|
|
->orderBy('sector.updated_at', 'desc')
|
|
|
- ->orderBy('sector.created_at', 'desc')
|
|
|
->paginate($data['page_size'], ['*'], 'mypage_name', $data['page']);
|
|
|
+ if(empty($result)){
|
|
|
+ return Result::error('暂无数据');
|
|
|
+ }
|
|
|
return Result::success($result);
|
|
|
}
|
|
|
public function getComponentInfo(array $data): array
|
|
@@ -1274,7 +1298,68 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
public function addComponent(array $data): array
|
|
|
{
|
|
|
unset($data['user_id']);
|
|
|
- $result = Component::insertGetId($data);
|
|
|
+ $sector = Sector::where('sector_id',$data['sector_id'])->first();
|
|
|
+ if(empty($sector)){
|
|
|
+ return Result::error('通栏不存在!');
|
|
|
+ }
|
|
|
+ $component_id = Component::where('component_type',$data['component_type'])->first();
|
|
|
+ if(!empty($component_id)){
|
|
|
+ return Result::error('组件编号已存在!');
|
|
|
+
|
|
|
+ }
|
|
|
+ $component_place = SectorPlace::where('sector_type',$sector['place_type'])->where('type_id',2)->where('sort_id',$data['sort_id'])->first();
|
|
|
+ // return Result::success($component_place);
|
|
|
+ // 组件分类:2:资讯-轮播组件;3:资讯-推荐类组件;4:资讯-热点类组件;5:广告类组件;
|
|
|
+ // 6:列表类组件;7:详情类组件;8:底部导航类组件;9:栏目资讯类组件;10:最新资讯类;11:导航栏类;',
|
|
|
+ if(is_array($data['page_type']) && !empty($data['page_type'])){
|
|
|
+ $page_type = array_values(array_map('intval',$data['page_type']));
|
|
|
+ $data['page_type'] = json_encode($page_type,true);
|
|
|
+
|
|
|
+ }
|
|
|
+ $data['type_id'] = intval($data['type_id']);
|
|
|
+ $add_arr = [
|
|
|
+ 'template_id' => $data['template_id'],
|
|
|
+ 'sector_id' => $data['sector_id'],
|
|
|
+ 'page_type' => $data['page_type'],
|
|
|
+ 'component_type' => $data['component_type'],
|
|
|
+ 'component_name' => $data['component_name'],
|
|
|
+ 'component_img' => $data['component_img'],
|
|
|
+ 'place_type' => $component_place['component_type'],
|
|
|
+ 'size_id' => $component_place['size_id'],
|
|
|
+ 'type_id' => $data['type_id'],
|
|
|
+ 'sort_id' => $data['sort_id'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ switch($data['type_id']){
|
|
|
+ case 1: //1:资讯-头条组件;
|
|
|
+ case 2: //2:资讯-轮播组件;
|
|
|
+ case 3: //3:资讯-推荐类组件;
|
|
|
+ case 4: //4:资讯-热点类组件;
|
|
|
+ case 10: //10:最新资讯类;
|
|
|
+ $add_arr['level'] = $data['level'];
|
|
|
+ $add_arr['img_num'] = $data['img_num'];
|
|
|
+ $add_arr['text_num'] = $data['text_num'];
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ $add_arr['img_num'] = $data['img_num'];
|
|
|
+ $add_arr['text_num'] = $data['text_num'];
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 7: //7:列表类组件;
|
|
|
+ $add_arr['pageSize'] = $data['pageSize'];
|
|
|
+ break;
|
|
|
+ case 11: //11:导航栏类;
|
|
|
+ $add_arr['cate_place'] = 0;
|
|
|
+ $add_arr['pageSize'] = $data['pageSize'];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return Result::success($add_arr);
|
|
|
+ // $result = Component::insertGetId($data);
|
|
|
if ($result) {
|
|
|
return Result::success($result);
|
|
|
} else {
|