use of com.dimple.project.system.domain.Link in project DimpleBlog by martin-chips.
the class LinkServiceImpl method handleLinkPass.
@Override
public int handleLinkPass(Long id, Boolean pass) {
Link link = selectLinkById(id);
if (Objects.isNull(link)) {
throw new CustomException("友链不存在");
}
if (!pass) {
// todo 发送email
return linkMapper.deleteLinkById(id, SecurityUtils.getUsername());
}
link.setStatus(true);
return linkMapper.updateLink(link);
}
use of com.dimple.project.system.domain.Link in project DimpleBlog by martin-chips.
the class LinkCheckTask method check.
/**
* 检测友链
*/
public void check() {
// 查询所有Link
List<Link> linkList = linkService.selectLinkList(new Link());
List<Link> unableAccessLinkList = new ArrayList<>();
StringBuffer stringBuffer = new StringBuffer("检查友链结果:");
for (Link link : linkList) {
try {
checkLinkAccessible(link.getUrl());
} catch (Exception e) {
}
}
if (ObjectUtils.isNotEmpty(unableAccessLinkList)) {
// 发送邮件
}
}
use of com.dimple.project.system.domain.Link in project DimpleBlog by martin-chips.
the class DashboardServiceImpl method getAccessData.
@Override
public AccessDataResult getAccessData() {
List<KeyValue> accessDataList = dashBoardMapper.getAccessData();
if (accessDataList.isEmpty()) {
return new AccessDataResult();
}
// handle data
accessDataList = accessDataList.stream().map(e -> new KeyValue(getTopDomain(e.getKey()), e.getValue())).collect(Collectors.toList());
AccessData direct = new AccessData("直达", 0);
AccessData localRedirect = new AccessData("本地跳转", 0);
AccessData searchEngine = new AccessData("搜索引擎", 0);
AccessData link = new AccessData("友链跳转", 0);
AccessData other = new AccessData("其他", 0);
// 搜索引擎
List<AccessDataItem> searchEngineAccessDataItemList = getSearchEngineAccessDataItemList();
// 友链跳转
List<AccessDataItem> linkAccessDataItemList = getLinkAccessDataItemList();
for (KeyValue keyValue : accessDataList) {
String url = keyValue.getKey();
Long count = keyValue.getValue();
Optional<AccessDataItem> searchAny = searchEngineAccessDataItemList.stream().filter(e -> e.getFilter().equals(url)).findAny();
Optional<AccessDataItem> linkAny = linkAccessDataItemList.stream().filter(e -> Objects.equals(e.getFilter(), url)).findAny();
if (StringUtils.isEmpty(url)) {
direct.setValue(direct.getValue() + count);
} else if (url.contains(INTERNAL_KEY)) {
localRedirect.setValue(localRedirect.getValue() + count);
} else if (searchAny.isPresent()) {
AccessDataItem accessDataItem = searchAny.get();
accessDataItem.setValue(accessDataItem.getValue() + count);
} else if (linkAny.isPresent()) {
AccessDataItem accessDataItem = linkAny.get();
accessDataItem.setValue(accessDataItem.getValue() + count);
} else {
other.setValue(other.getValue() + count);
}
}
searchEngine.setValue(searchEngineAccessDataItemList.stream().mapToLong(e -> e.getValue()).sum());
link.setValue(linkAccessDataItemList.stream().mapToLong(e -> e.getValue()).sum());
AccessDataResult accessDataResult = new AccessDataResult();
List<AccessData> innerResult = new ArrayList<>();
innerResult.add(direct);
innerResult.add(searchEngine);
innerResult.add(link);
innerResult.add(localRedirect);
innerResult.add(other);
accessDataResult.setInner(innerResult.stream().filter(e -> e.getValue() != 0).sorted(Comparator.comparing(AccessData::getValue).reversed()).collect(Collectors.toList()));
List<AccessData> outResult = new ArrayList<>();
linkAccessDataItemList.addAll(searchEngineAccessDataItemList);
for (AccessDataItem accessDataItem : linkAccessDataItemList) {
AccessData accessData = new AccessData();
BeanUtils.copyProperties(accessDataItem, accessData);
outResult.add(accessData);
}
accessDataResult.setOut(outResult.stream().filter(e -> e.getValue() != 0).sorted(Comparator.comparing(AccessData::getValue).reversed()).collect(Collectors.toList()));
return accessDataResult.complete();
}
Aggregations