1.增加了查询现场大屏和栏目封装接口
This commit is contained in:
parent
fefc6e54a4
commit
19624d2e73
@ -1,5 +1,6 @@
|
||||
package com.platform.modules.live.controller;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.platform.modules.live.service.LiveChannelTenantService;
|
||||
@ -188,4 +189,16 @@ public class LiveChannelController extends AbstractController{
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询现场大屏和栏目封装
|
||||
* @return 集合
|
||||
*/
|
||||
@PostMapping("/appView")
|
||||
public HashMap<Object, Object> appView() {
|
||||
return liveChannelService.appView();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
12
src/main/java/com/platform/modules/live/dto/ChannelDTO.java
Normal file
12
src/main/java/com/platform/modules/live/dto/ChannelDTO.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.platform.modules.live.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class ChannelDTO {
|
||||
private Integer channelId;
|
||||
private String channelName;
|
||||
private List<LiveSceneDTO> liveScenes;
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package com.platform.modules.live.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LiveSceneDTO {
|
||||
private Integer id;
|
||||
private String title;
|
||||
private String titleImage;
|
||||
|
||||
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.platform.modules.live.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.service.IService;
|
||||
@ -48,4 +49,6 @@ public interface LiveChannelService extends IService<LiveChannelEntity> {
|
||||
JSONArray getAllChannelByTenant(Long tenantId);
|
||||
|
||||
PageUtils pageAll(Map<String, Object> params);
|
||||
|
||||
HashMap<Object, Object> appView();
|
||||
}
|
||||
|
||||
@ -1,11 +1,17 @@
|
||||
package com.platform.modules.live.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.platform.modules.live.constants.SceneConstants;
|
||||
import com.platform.modules.live.dto.ChannelDTO;
|
||||
import com.platform.modules.live.dto.LiveSceneDTO;
|
||||
import com.platform.modules.live.entity.LiveSceneChannelEntity;
|
||||
import com.platform.modules.live.entity.LiveSceneEntity;
|
||||
import com.platform.modules.live.service.LiveSceneService;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -31,8 +37,14 @@ public class LiveChannelServiceImpl extends ServiceImpl<LiveChannelDao, LiveChan
|
||||
|
||||
@Autowired
|
||||
private RedisUtils redisUtils;
|
||||
@Autowired
|
||||
private LiveSceneService liveSceneService;
|
||||
@Autowired
|
||||
private LiveSceneChannelServiceImpl liveSceneChannelService;
|
||||
@Autowired
|
||||
private LiveChannelService liveChannelService;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public PageUtils page(Map<String, Object> params){
|
||||
//检索记录
|
||||
@ -339,4 +351,79 @@ private LiveChannelDao liveChannelDao;
|
||||
page.setRecords(list);
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Object, Object> appView() {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
//1.查询轮播大图
|
||||
List<LiveSceneEntity> sceneEntities = liveSceneService.selectList(new EntityWrapper<LiveSceneEntity>()
|
||||
.eq("delete_flag", 0)
|
||||
.eq("scene_state", SceneConstants.SCENE_PROD)
|
||||
.eq("carousel_image", 1)
|
||||
);
|
||||
// 将 LiveSceneEntity 转换为 LiveSceneDTO
|
||||
List<LiveSceneDTO> liveScenes = sceneEntities.stream()
|
||||
.map(this::convertToDTO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
map.put("carouselScene", liveScenes);
|
||||
|
||||
// 2.按照栏目封装现场
|
||||
List<LiveChannelEntity> channelEntities = liveChannelService.selectList(null);
|
||||
List<ChannelDTO> collect = channelEntities.stream().map(this::convertToB).collect(Collectors.toList());
|
||||
// 为每个 ChannelDTO 获取 liveScenes
|
||||
if(CollectionUtils.isNotEmpty(collect)){
|
||||
|
||||
collect.forEach(channelDTO -> {
|
||||
// 获取当前频道的所有 LiveSceneChannelEntity
|
||||
List<LiveSceneChannelEntity> entityList = liveSceneChannelService.selectList(
|
||||
new EntityWrapper<LiveSceneChannelEntity>().eq("channel_id", channelDTO.getChannelId())
|
||||
);
|
||||
List<LiveSceneEntity> liveSceneEntities= null;
|
||||
if(CollectionUtils.isNotEmpty(entityList)) {
|
||||
// 提取所有的 scene_id 并获取对应的 LiveSceneEntity
|
||||
Set<Integer> sceneIds = entityList.stream()
|
||||
.map(LiveSceneChannelEntity::getSceneId)
|
||||
.collect(Collectors.toSet());
|
||||
liveSceneEntities = liveSceneService.selectList(new EntityWrapper<LiveSceneEntity>()
|
||||
.in("id", sceneIds)
|
||||
.eq("delete_flag", 0)
|
||||
.eq("scene_state", SceneConstants.SCENE_PROD)
|
||||
.orderBy("priority", false)
|
||||
);
|
||||
}
|
||||
|
||||
// 将 LiveSceneEntity 转换为 LiveSceneDTO
|
||||
if(CollectionUtils.isNotEmpty(liveSceneEntities)){
|
||||
|
||||
List<LiveSceneDTO> scenes = liveSceneEntities.stream()
|
||||
.map(this::convertToDTO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 设置 ChannelDTO 的 liveScenes 属性
|
||||
channelDTO.setLiveScenes(scenes);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
map.put("sceneGroupByChannel", collect);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
private LiveSceneDTO convertToDTO(LiveSceneEntity entity) {
|
||||
LiveSceneDTO dto = new LiveSceneDTO();
|
||||
dto.setId(entity.getId());
|
||||
dto.setTitle(entity.getTitle());
|
||||
dto.setTitleImage(entity.getTitleImage());
|
||||
return dto;
|
||||
}
|
||||
|
||||
private ChannelDTO convertToB(LiveChannelEntity a) {
|
||||
ChannelDTO channelDTO = new ChannelDTO();
|
||||
channelDTO.setChannelId(a.getId());
|
||||
channelDTO.setChannelName(a.getName());
|
||||
return channelDTO;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user