|
@@ -1,24 +1,36 @@
|
|
|
package com.fs.app.facade.impl;
|
|
package com.fs.app.facade.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fs.app.facade.LiveFacadeService;
|
|
import com.fs.app.facade.LiveFacadeService;
|
|
|
import com.fs.common.constant.LiveKeysConstant;
|
|
import com.fs.common.constant.LiveKeysConstant;
|
|
|
|
|
+import com.fs.common.core.controller.BaseController;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.PageRequest;
|
|
import com.fs.common.core.page.PageRequest;
|
|
|
|
|
+import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.core.redis.RedisUtil;
|
|
import com.fs.common.core.redis.RedisUtil;
|
|
|
import com.fs.live.domain.Live;
|
|
import com.fs.live.domain.Live;
|
|
|
|
|
+import com.fs.live.domain.LiveWatchUser;
|
|
|
import com.fs.live.service.ILiveService;
|
|
import com.fs.live.service.ILiveService;
|
|
|
|
|
+import com.fs.live.service.ILiveWatchUserService;
|
|
|
|
|
+import com.fs.live.vo.LiveWatchUserVO;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Objects;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
-public class LiveFacadeServiceImpl implements LiveFacadeService {
|
|
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+public class LiveFacadeServiceImpl extends BaseController implements LiveFacadeService {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
private RedisUtil redisUtil;
|
|
@@ -26,6 +38,9 @@ public class LiveFacadeServiceImpl implements LiveFacadeService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ILiveService liveService;
|
|
private ILiveService liveService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ILiveWatchUserService liveWatchUserService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public R liveList(PageRequest pageRequest) {
|
|
public R liveList(PageRequest pageRequest) {
|
|
|
int start = (pageRequest.getCurrentPage() - 1) * pageRequest.getPageSize();
|
|
int start = (pageRequest.getCurrentPage() - 1) * pageRequest.getPageSize();
|
|
@@ -60,4 +75,27 @@ public class LiveFacadeServiceImpl implements LiveFacadeService {
|
|
|
return R.ok().put("data", result);
|
|
return R.ok().put("data", result);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public TableDataInfo watchUserList(LiveWatchUser param) {
|
|
|
|
|
+ List<LiveWatchUserVO> liveWatchUserVOS ;
|
|
|
|
|
+ String setKey = String.format(LiveKeysConstant.LIVE_WATCH_USERS, param.getLiveId());
|
|
|
|
|
+ Map<Object, Object> hashEntries = redisUtil.hashEntries(setKey);
|
|
|
|
|
+ if (CollUtil.isEmpty(hashEntries)){
|
|
|
|
|
+ liveWatchUserVOS = liveWatchUserService.asyncToCache(param.getLiveId());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ liveWatchUserVOS = hashEntries.values().stream()
|
|
|
|
|
+ .map(value -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return JSONUtil.toBean(JSONUtil.parseObj(value), LiveWatchUserVO.class);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("反序列化LiveWatchUserVO失败: {}", value, e);
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+ return getDataTable(liveWatchUserVOS);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|