페이징 유틸 추가

This commit is contained in:
ckx6954 2024-12-12 15:55:39 +09:00
parent 6437f0e721
commit 75257e241e
4 changed files with 16 additions and 14 deletions

View File

@ -1,11 +1,12 @@
package io.company.localhost.mapper; package io.company.localhost.mapper;
import java.util.List; import io.company.localhost.common.dto.MapDto;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper @Mapper
public interface TestMapper { public interface TestMapper {
List<Long> getCong(); List<MapDto> getCong();
} }

View File

@ -1,11 +1,12 @@
package io.company.localhost.service; package io.company.localhost.service;
import java.util.List; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service; import io.company.localhost.common.dto.MapDto;
import io.company.localhost.mapper.TestMapper; import io.company.localhost.mapper.TestMapper;
import io.company.localhost.utils.PageUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@ -13,7 +14,8 @@ public class TestService {
private final TestMapper testMapper; private final TestMapper testMapper;
public List<Long> getCong(){ public PageInfo<MapDto> getCong(){
return testMapper.getCong(); PageHelper.startPage( 1 , 10);
return PageUtil.redefineNavigation(new PageInfo<>(testMapper.getCong(),10));
} }
} }

View File

@ -1,13 +1,12 @@
package io.company.localhost.utils; package io.company.localhost.utils;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.company.localhost.common.dto.MapDto;
import java.util.Map;
public class PageUtil { public class PageUtil {
public static PageInfo<Map<String , Object>> redefineNavigation(PageInfo<Map<String , Object>> list){ public static PageInfo<MapDto> redefineNavigation(PageInfo<MapDto> list){
// 페이지 배열 // 페이지 배열
int[] nav = list.getNavigatepageNums(); int[] nav = list.getNavigatepageNums();

View File

@ -2,11 +2,11 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.company.localhost.mapper.TestMapper"> <mapper namespace="io.company.localhost.mapper.TestMapper">
<select id="getCong" resultType="Long"> <select id="getCong" resultType="Map">
SELECT SELECT
* *
FROM FROM
test.cong cong
</select> </select>
</mapper> </mapper>