forked from Gitlink/microservices
fix(特色专区专项项目): 定制泛在专区开源项目展示需求
项目根据活跃度排名列表需支持根据项目分类筛选 Signed-off-by: OTTO <731554297@qq.com>
This commit is contained in:
parent
7e424d02b4
commit
bfa8ebd374
|
|
@ -43,15 +43,8 @@ public class RedisService
|
|||
redisTemplate.opsForZSet().remove(key, value);
|
||||
}
|
||||
|
||||
public <T> Set<T> getSortSetBySize(final String key, final Integer offset, final Integer count) {
|
||||
RedisZSetCommands.Limit limit = new RedisZSetCommands.Limit();
|
||||
if (offset != null && count != null) {
|
||||
limit.offset(offset);
|
||||
limit.count(count);
|
||||
} else {
|
||||
limit = RedisZSetCommands.Limit.unlimited();
|
||||
}
|
||||
return redisTemplate.opsForZSet().reverseRangeByLex(key, RedisZSetCommands.Range.unbounded(), limit);
|
||||
public <T> Set<T> getSortSetBySize(final String key) {
|
||||
return redisTemplate.opsForZSet().reverseRangeByLex(key, RedisZSetCommands.Range.unbounded(), RedisZSetCommands.Limit.unlimited());
|
||||
}
|
||||
|
||||
public <T> Long getSortSetRank(final String key, final T value) {
|
||||
|
|
|
|||
|
|
@ -175,7 +175,9 @@ public class OpenController extends BaseController {
|
|||
ZoneProjectOpenSearchVo zoneProjectOpenSearchVo,
|
||||
Integer pageNum, Integer pageSize) {
|
||||
ZoneProjectSearchVo zoneProjectSearchVo = zoneProjectOpenSearchVo.toZoneProjectSearchVo(zoneId);
|
||||
return zoneProjectService.selectZoneProjectByScoreList(zoneProjectSearchVo, true, pageNum, pageSize);
|
||||
return getAllGenericsDataTableToPage(
|
||||
zoneProjectService.selectZoneProjectByScoreList(zoneProjectSearchVo, true, pageNum, pageSize)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -111,5 +111,5 @@ public interface IZoneProjectService {
|
|||
*/
|
||||
Integer selectHomepageCount(Long zoneId);
|
||||
|
||||
GenericsTableDataInfo<JSONObject> selectZoneProjectByScoreList(ZoneProjectSearchVo zoneProjectSearchVo, boolean isOpen, Integer pageNum, Integer pageSize);
|
||||
List<JSONObject> selectZoneProjectByScoreList(ZoneProjectSearchVo zoneProjectSearchVo, boolean isOpen, Integer pageNum, Integer pageSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -620,33 +620,32 @@ public class ZoneProjectServiceImpl implements IZoneProjectService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public GenericsTableDataInfo<JSONObject> selectZoneProjectByScoreList(ZoneProjectSearchVo zoneProjectSearchVo, boolean isOpen, Integer pageNum, Integer pageSize) {
|
||||
public List<JSONObject> selectZoneProjectByScoreList(ZoneProjectSearchVo zoneProjectSearchVo, boolean isOpen, Integer pageNum, Integer pageSize) {
|
||||
if (isOpen && zoneProjectSearchVo.getZoneId() == null) {
|
||||
throw new ServiceException("查询项目列表时,请指定专区Id");
|
||||
}
|
||||
List<ZoneProject> zoneProjectList = new ArrayList<>();
|
||||
List<JSONObject> zoneProjectDataList = new ArrayList<>();
|
||||
zoneDetailService.selectZoneDetailById(zoneProjectSearchVo.getZoneId());
|
||||
zoneProjectSearchVo.setIsOpen(isOpen);
|
||||
|
||||
// 获取专区下活跃度列表
|
||||
Date now = DateUtils.getNowDate();
|
||||
String lastWeekMonday = DateUtils.mondayOfLastWeek(now, 1);
|
||||
String lastWeekKey = CacheConstants.getZoneProjectSortByScore(lastWeekMonday, zoneProjectSearchVo.getZoneId());
|
||||
String secondLastWeekMonday = DateUtils.mondayOfLastWeek(now, 2);
|
||||
String secondLastWeekKey = CacheConstants.getZoneProjectSortByScore(secondLastWeekMonday, zoneProjectSearchVo.getZoneId());
|
||||
Integer offset = null;
|
||||
Integer limit = null;
|
||||
if (pageNum != null && pageSize != null) {
|
||||
offset = (pageNum - 1) * pageSize;
|
||||
limit = pageSize;
|
||||
}
|
||||
Set<Long> gitlinkProjectIdSet = redisService.getSortSetBySize(lastWeekKey, offset, limit);
|
||||
Set<Long> gitlinkProjectIdSet = redisService.getSortSetBySize(lastWeekKey);
|
||||
|
||||
zoneProjectSearchVo.setIsOpen(isOpen);
|
||||
List<ZoneProject> zoneProjectList = zoneProjectMapper.selectZoneProjectList(zoneProjectSearchVo);
|
||||
List<ZoneProject> zoneProjectAndScoreList = new ArrayList<>();
|
||||
|
||||
for (Long gitlinkProjectId : gitlinkProjectIdSet) {
|
||||
ZoneProject zoneProject = zoneProjectMapper.selectZoneProjectByGitLinkProjectIdAndZoneId(gitlinkProjectId, zoneProjectSearchVo.getZoneId());
|
||||
if (zoneProject != null) {
|
||||
zoneProjectList.add(zoneProject);
|
||||
}
|
||||
zoneProjectList.stream().filter(x -> gitlinkProjectId.equals(x.getGitlinkProjectId())).findFirst().ifPresent(zoneProjectAndScoreList::add);
|
||||
}
|
||||
List<ZoneProjectDataVo> zoneProjectDataVoList = toZoneProjectDataVoList(zoneProjectList);
|
||||
|
||||
List<JSONObject> zoneProjectJSONList = new ArrayList<>();
|
||||
|
||||
|
||||
List<ZoneProjectDataVo> zoneProjectDataVoList = toZoneProjectDataVoList(zoneProjectAndScoreList);
|
||||
for (ZoneProjectDataVo zoneProjectDataVo : zoneProjectDataVoList) {
|
||||
Long gitlinkProjectId = zoneProjectDataVo.getGitlinkProjectId();
|
||||
JSONObject jsonObject = JSONObject.from(zoneProjectDataVo);
|
||||
|
|
@ -660,9 +659,8 @@ public class ZoneProjectServiceImpl implements IZoneProjectService {
|
|||
} catch (Exception e) {
|
||||
logger.error("获取项目gitlink信息失败", e);
|
||||
}
|
||||
zoneProjectDataList.add(jsonObject);
|
||||
zoneProjectJSONList.add(jsonObject);
|
||||
}
|
||||
Long count = redisService.getSortSetCount(lastWeekKey);
|
||||
return new GenericsTableDataInfo<>(zoneProjectDataList, count);
|
||||
return zoneProjectJSONList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue