refactor: 简化代码
This commit is contained in:
@@ -51,7 +51,7 @@ public class VisitorServiceImpl implements VisitorService {
|
|||||||
public PageData<VisitorModel> visitorPage(int page, int count, boolean showLocation) {
|
public PageData<VisitorModel> visitorPage(int page, int count, boolean showLocation) {
|
||||||
PageHelper.startPage(page, count);
|
PageHelper.startPage(page, count);
|
||||||
List<Visitor> visitorList = visitorMapper.findAll();
|
List<Visitor> visitorList = visitorMapper.findAll();
|
||||||
return new PageData<VisitorModel>(new PageInfo<Visitor>(visitorList), list2List(visitorList, showLocation));
|
return new PageData<>(new PageInfo<>(visitorList), list2List(visitorList, showLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : xiaohai
|
* @author : xiaohai
|
||||||
@@ -72,7 +73,7 @@ public class WebUpdateInfoServiceImpl implements WebUpdateInfoService {
|
|||||||
public PageData<WebUpdateModel> pages(int count, int page) {
|
public PageData<WebUpdateModel> pages(int count, int page) {
|
||||||
PageHelper.startPage(page, count);
|
PageHelper.startPage(page, count);
|
||||||
List<WebUpdate> updateList = webUpdateInfoMapper.findAll();
|
List<WebUpdate> updateList = webUpdateInfoMapper.findAll();
|
||||||
return new PageData<WebUpdateModel>(new PageInfo<WebUpdate>(updateList), list2List(updateList));
|
return new PageData<>(new PageInfo<>(updateList), list2List(updateList));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -108,8 +109,6 @@ public class WebUpdateInfoServiceImpl implements WebUpdateInfoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<WebUpdateModel> list2List(List<WebUpdate> webUpdates) {
|
private List<WebUpdateModel> list2List(List<WebUpdate> webUpdates) {
|
||||||
List<WebUpdateModel> webUpdateModels = new ArrayList<>();
|
return webUpdates.stream().map(ModalTrans::webUpdate).collect(Collectors.toList());
|
||||||
webUpdates.forEach(update -> webUpdateModels.add(ModalTrans.webUpdate(update)));
|
|
||||||
return webUpdateModels;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user