|
@@ -4,14 +4,12 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.tzld.longarticle.recommend.server.common.response.CommonResponse;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.crawler.GhDetailMapper;
|
|
|
-import com.tzld.longarticle.recommend.server.model.param.GhDetailParam;
|
|
|
import com.tzld.longarticle.recommend.server.repository.model.GhDetail;
|
|
|
import com.tzld.longarticle.recommend.server.repository.model.GhDetailExample;
|
|
|
import com.tzld.longarticle.recommend.server.service.exterior.GhDetailService;
|
|
|
import com.tzld.longarticle.recommend.server.util.page.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.reactive.function.client.WebClient;
|
|
@@ -27,14 +25,23 @@ public class GhDetailServiceImpl implements GhDetailService {
|
|
|
private GhDetailMapper ghDetailMapper;
|
|
|
|
|
|
@Override
|
|
|
- public CommonResponse<Page<GhDetail>> getGhDetailList(GhDetailParam param) {
|
|
|
+ public CommonResponse<Page<GhDetail>> getGhDetailList(Integer pageNum, Integer pageSize) {
|
|
|
+ if (pageNum == null) {
|
|
|
+ pageNum = 1;
|
|
|
+ }
|
|
|
+ if (pageSize == null) {
|
|
|
+ pageSize = 20;
|
|
|
+ }
|
|
|
+ if (pageSize > 100) {
|
|
|
+ pageSize = 100;
|
|
|
+ }
|
|
|
Page<GhDetail> page = new Page<>();
|
|
|
- page.setCurrentPage(param.getPageNum());
|
|
|
- page.setPageSize(param.getPageSize());
|
|
|
+ page.setCurrentPage(pageNum);
|
|
|
+ page.setPageSize(pageSize);
|
|
|
GhDetailExample example = new GhDetailExample();
|
|
|
example.setPage(page);
|
|
|
long total = ghDetailMapper.countByExample(example);
|
|
|
- int totalSize = (int) (total % param.getPageSize() == 0 ? (total / param.getPageSize()) : (total / param.getPageSize() + 1));
|
|
|
+ int totalSize = (int) (total % pageSize == 0 ? (total / pageSize) : (total / pageSize + 1));
|
|
|
page.setTotalSize(totalSize);
|
|
|
List<GhDetail> ghDetails = ghDetailMapper.selectByExample(example);
|
|
|
page.setObjs(ghDetails);
|