[IT]/java

java.controller.service.paging(pageHelper)

givemebro 2021. 10. 6. 13:02
반응형

package com.example.newsAnalysis.service;

import com.example.newsAnalysis.mapper.CollectionMapper;
import com.example.newsAnalysis.model.CollectionInfoVO;
import com.example.newsAnalysis.model.CollectionStatusVO;
import com.example.newsAnalysis.model.InputVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollectionDataService {
    @Autowired
    CollectionMapper mapper;

    public List<CollectionStatusVO> dataStatus(InputVO inputVO) {
        return mapper.dataStatus(inputVO);
    }

    /***
     * paging 처리를 반영한 dataCollectionInfo List
     * @param inputVO
     * @return
     */
    public Page<CollectionInfoVO> dataInfo(InputVO inputVO) {
        // paging 처리(pagehelper)
        PageHelper.startPage(inputVO.getPageNum(), 10);
        // url mapping
        Page<CollectionInfoVO> list = mapper.dataInfo(inputVO);
        for (CollectionInfoVO vo : list
        ) {
            vo.setUrl("https://news.v.daum.net/v/" + vo.getUrl());
        }
        return list;
    }


}
반응형