사용자관리 작업중. 페이지네이션 수정.
parent
4248a47916
commit
4d4cb60413
|
|
@ -1,18 +1,55 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
function EgovPaging(props) {
|
function EgovPaging({pagination, moveToPage}) {
|
||||||
console.groupCollapsed("EgovPaging");
|
console.groupCollapsed("EgovPaging");
|
||||||
console.log("EgovPaging [props] : ", props);
|
console.log("EgovPaging [pagination] : ", pagination);
|
||||||
|
|
||||||
let paginationTag = [];
|
let paginationTag = [];
|
||||||
|
|
||||||
if (props.pagination === undefined) {
|
if (pagination === undefined) {
|
||||||
paginationTag = "-";
|
paginationTag = "-";
|
||||||
} else {
|
} else {
|
||||||
const currentPageNo = props.pagination.currentPageNo;
|
if(pagination.startNum>1){
|
||||||
const pageSize = props.pagination.pageSize;
|
// 첫 페이지 이동
|
||||||
const totalRecordCount = props.pagination.totalRecordCount;
|
paginationTag.push(<li key="fp" className="btn">
|
||||||
const recordCountPerPage = props.pagination.recordCountPerPage;
|
<button onClick={e => {moveToPage(1)}} className="first">처음</button>
|
||||||
|
</li>);
|
||||||
|
|
||||||
|
// 이전 페이지 이동
|
||||||
|
const prevPageIndex = pagination.pageIndex-10 < 0?1:(pagination.pageIndex-10)
|
||||||
|
paginationTag.push(<li key="pp" className="btn">
|
||||||
|
<button onClick={e => {moveToPage(prevPageIndex)}} className="prev">이전</button>
|
||||||
|
</li>);
|
||||||
|
}
|
||||||
|
for (let i = pagination.startNum; i <= pagination.endNum; i++) {
|
||||||
|
if (i === pagination.pageIndex) {
|
||||||
|
// 현재 페이지
|
||||||
|
paginationTag.push(<li key={i}>
|
||||||
|
<button className="cur">{i}</button>
|
||||||
|
</li>);
|
||||||
|
} else {
|
||||||
|
// 다른 페이지
|
||||||
|
paginationTag.push(<li key={i}>
|
||||||
|
<button onClick={e => {moveToPage(i)}}>{i}</button>
|
||||||
|
</li>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(pagination.endNum!=pagination.maxNum){
|
||||||
|
// 다음 페이지 이동
|
||||||
|
const nextPageIndex = pagination.pageIndex+10 < pagination.maxNum?pagination.maxNum:(pagination.pageIndex-10)
|
||||||
|
paginationTag.push(<li key="np" className="btn">
|
||||||
|
<button onClick={e => {moveToPage(nextPageIndex)}} className="next">다음</button>
|
||||||
|
</li>);
|
||||||
|
|
||||||
|
// 마지막 페이지 이동
|
||||||
|
paginationTag.push(<li key="lp" className="btn">
|
||||||
|
<button onClick={e => {moveToPage(pagination.maxNum)}} className="last"></button>
|
||||||
|
</li>);
|
||||||
|
}
|
||||||
|
/*const currentPageNo = pagination.currentPageNo;
|
||||||
|
const pageSize = pagination.pageSize;
|
||||||
|
const totalRecordCount = pagination.contentCnt;
|
||||||
|
const recordCountPerPage = pagination.rowCnt;
|
||||||
|
|
||||||
const totalPageCount = Math.ceil(totalRecordCount / recordCountPerPage);
|
const totalPageCount = Math.ceil(totalRecordCount / recordCountPerPage);
|
||||||
const currentFirstPage = Math.floor((currentPageNo - 1) / pageSize) * pageSize + 1;
|
const currentFirstPage = Math.floor((currentPageNo - 1) / pageSize) * pageSize + 1;
|
||||||
|
|
@ -22,13 +59,13 @@ function EgovPaging(props) {
|
||||||
if (totalPageCount > pageSize) {
|
if (totalPageCount > pageSize) {
|
||||||
// 첫 페이지 이동
|
// 첫 페이지 이동
|
||||||
const firstPageTag = <li key="fp" className="btn">
|
const firstPageTag = <li key="fp" className="btn">
|
||||||
<button onClick={e => {props.moveToPage(1)}} className="first">처음</button></li>;
|
<button onClick={e => {moveToPage(1)}} className="first">처음</button></li>;
|
||||||
paginationTag.push(firstPageTag);
|
paginationTag.push(firstPageTag);
|
||||||
|
|
||||||
// 이전 페이지 이동
|
// 이전 페이지 이동
|
||||||
const prevPageIndex = (currentPageNo - 1 > 0) ? currentPageNo - 1 : 1;
|
const prevPageIndex = (currentPageNo - 1 > 0) ? currentPageNo - 1 : 1;
|
||||||
const previousPageTag = <li key="pp" className="btn">
|
const previousPageTag = <li key="pp" className="btn">
|
||||||
<button onClick={e => {props.moveToPage(prevPageIndex)}} className="prev">이전</button></li>;
|
<button onClick={e => {moveToPage(prevPageIndex)}} className="prev">이전</button></li>;
|
||||||
paginationTag.push(previousPageTag);
|
paginationTag.push(previousPageTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,25 +79,26 @@ function EgovPaging(props) {
|
||||||
} else {
|
} else {
|
||||||
// 다른 페이지
|
// 다른 페이지
|
||||||
const otherPage = <li key={i}>
|
const otherPage = <li key={i}>
|
||||||
<button onClick={e => {props.moveToPage(i)}}>{i}</button>
|
<button onClick={e => {moveToPage(i)}}>{i}</button>
|
||||||
</li>;
|
</li>;
|
||||||
console.log("@@@ otherpage : " + otherPage);
|
console.log("@@@ otherpage : " + otherPage);
|
||||||
paginationTag.push(otherPage);
|
paginationTag.push(otherPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalPageCount > pageSize) {
|
if (totalPageCount > pageSize) {
|
||||||
// 다음 페이지 이동
|
// 다음 페이지 이동
|
||||||
const nextPageIndex = (currentLastPage + 1 < totalPageCount) ? currentLastPage + 1 : totalPageCount;
|
const nextPageIndex = (currentLastPage + 1 < totalPageCount) ? currentLastPage + 1 : totalPageCount;
|
||||||
const nextPageTag = <li key="np" className="btn">
|
const nextPageTag = <li key="np" className="btn">
|
||||||
<button onClick={e => {props.moveToPage(nextPageIndex)}} className="next">다음</button>
|
<button onClick={e => {moveToPage(nextPageIndex)}} className="next">다음</button>
|
||||||
</li>;
|
</li>;
|
||||||
paginationTag.push(nextPageTag);
|
paginationTag.push(nextPageTag);
|
||||||
|
|
||||||
// 마지막 페이지 이동
|
// 마지막 페이지 이동
|
||||||
const lastPageTag = <li key="lp" className="btn">
|
const lastPageTag = <li key="lp" className="btn">
|
||||||
<button onClick={e => {props.moveToPage(totalPageCount)}} className="last"></button></li>;
|
<button onClick={e => {moveToPage(totalPageCount)}} className="last"></button></li>;
|
||||||
paginationTag.push(lastPageTag);
|
paginationTag.push(lastPageTag);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
console.log("paginationTag", paginationTag);
|
console.log("paginationTag", paginationTag);
|
||||||
console.groupEnd("EgovPaging");
|
console.groupEnd("EgovPaging");
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,12 @@
|
||||||
import React, {useCallback, useEffect, useRef, useState} from 'react';
|
import React, {useCallback, useEffect, useRef, useState} from 'react';
|
||||||
import {Link, useLocation} from "react-router-dom";
|
import {Link, useLocation} from "react-router-dom";
|
||||||
import URL from "../../../constants/url";
|
import URL from "constants/url";
|
||||||
import Row from "react-bootstrap/Row";
|
|
||||||
import Col from "react-bootstrap/Col";
|
|
||||||
|
|
||||||
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
|
import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin';
|
||||||
import CODE from "../../../constants/code";
|
import EgovPaging from "components/EgovPaging";
|
||||||
import EgovPaging from "../../../components/EgovPaging";
|
import * as EgovNet from "api/egovFetch";
|
||||||
import * as EgovNet from "../../../api/egovFetch";
|
import {itemIdxByPage} from "utils/calc";
|
||||||
import {itemIdxByPage} from "../../../utils/calc";
|
import Button from "react-bootstrap/Button";
|
||||||
import {NOTICE_BBS_ID} from "../../../config";
|
|
||||||
|
|
||||||
|
|
||||||
function List(props) {
|
function List(props) {
|
||||||
|
|
@ -24,33 +21,39 @@ function List(props) {
|
||||||
const wrdRef = useRef();
|
const wrdRef = useRef();
|
||||||
|
|
||||||
const retrieveList = useCallback((searchCondition) => {
|
const retrieveList = useCallback((searchCondition) => {
|
||||||
/*
|
const params = "?";
|
||||||
EgovNet.requestFetch(
|
EgovNet.requestFetch(
|
||||||
'/cop/bbs/selectBoardListAPI.do',
|
'/admin/users/list'+params,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "GET"
|
||||||
headers: {
|
|
||||||
'Content-type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify(searchCondition)
|
|
||||||
},
|
},
|
||||||
(resp) => {
|
(resp) => {
|
||||||
|
|
||||||
setPaginationInfo(resp.result.paginationInfo);
|
setPaginationInfo(resp.result.paginationInfo);
|
||||||
|
|
||||||
let mutListTag = [];
|
let mutListTag = [];
|
||||||
|
|
||||||
const resultCnt = parseInt(resp.result.resultCnt);
|
const resultCnt = parseInt(resp.result.contentCnt);
|
||||||
const currentPageNo = resp.result.paginationInfo.currentPageNo;
|
const currentPageNo = resp.result.paginationInfo.pageIndex;
|
||||||
const pageSize = resp.result.paginationInfo.pageSize;
|
const pageSize = resp.result.paginationInfo.rowCnt;
|
||||||
|
|
||||||
|
setListTag([]);
|
||||||
// 리스트 항목 구성
|
// 리스트 항목 구성
|
||||||
resp.result.resultList.forEach(function (item, index) {
|
resp.result.userList.forEach(function (item, index) {
|
||||||
if (index === 0) mutListTag = []; // 목록 초기화
|
|
||||||
const listIdx = itemIdxByPage(resultCnt , currentPageNo, pageSize, index);
|
const listIdx = itemIdxByPage(resultCnt , currentPageNo, pageSize, index);
|
||||||
|
|
||||||
mutListTag.push(
|
mutListTag.push(
|
||||||
<Link to={{pathname: URL.ADMIN_NOTICE_DETAIL}}
|
<div>
|
||||||
|
<span>{item.userSe}</span>
|
||||||
|
<span>{item.userId}</span>
|
||||||
|
<span>{item.userNm}</span>
|
||||||
|
<span>{item.email}</span>
|
||||||
|
<span>{item.phoneNum}</span>
|
||||||
|
<span>{item.useYn}</span>
|
||||||
|
<span><Button variant={"danger"} size={"sm"}>삭제</Button></span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
/*<Link to={{pathname: URL.ADMIN_NOTICE_DETAIL}}
|
||||||
state={{
|
state={{
|
||||||
nttId: item.nttId,
|
nttId: item.nttId,
|
||||||
searchCondition: searchCondition
|
searchCondition: searchCondition
|
||||||
|
|
@ -68,8 +71,7 @@ function List(props) {
|
||||||
<div>{item.frstRegisterNm}</div>
|
<div>{item.frstRegisterNm}</div>
|
||||||
<div>{item.frstRegisterPnttm}</div>
|
<div>{item.frstRegisterPnttm}</div>
|
||||||
<div>{item.inqireCo}</div>
|
<div>{item.inqireCo}</div>
|
||||||
</Link>
|
</Link>*/
|
||||||
);
|
|
||||||
});
|
});
|
||||||
if(!mutListTag.length) mutListTag.push(<p className="no_data" key="0">검색된 결과가 없습니다.</p>); // 게시판 목록 초기값
|
if(!mutListTag.length) mutListTag.push(<p className="no_data" key="0">검색된 결과가 없습니다.</p>); // 게시판 목록 초기값
|
||||||
setListTag(mutListTag);
|
setListTag(mutListTag);
|
||||||
|
|
@ -78,7 +80,6 @@ function List(props) {
|
||||||
console.log("err response : ", resp);
|
console.log("err response : ", resp);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
*/
|
|
||||||
},[]);
|
},[]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -123,10 +124,10 @@ function List(props) {
|
||||||
<label className="f_select" htmlFor="sel1">
|
<label className="f_select" htmlFor="sel1">
|
||||||
<select id="sel1" title="조건" defaultValue={searchCondition.searchCnd} ref={cndRef}
|
<select id="sel1" title="조건" defaultValue={searchCondition.searchCnd} ref={cndRef}
|
||||||
onChange={e => {cndRef.current.value = e.target.value;}}>
|
onChange={e => {cndRef.current.value = e.target.value;}}>
|
||||||
<option value="0">아이디</option>
|
<option value="id">아이디</option>
|
||||||
<option value="1">이름</option>
|
<option value="name">이름</option>
|
||||||
<option value="2">이메일</option>
|
<option value="email">이메일</option>
|
||||||
<option value="3">전화번호</option>
|
<option value="phoneNum">전화번호</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
|
|
@ -167,8 +168,14 @@ function List(props) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="board_bot">
|
<div className="board_bot">
|
||||||
<EgovPaging pagination={paginationInfo} moveToPage={passedPage => {
|
<EgovPaging pagination={paginationInfo}
|
||||||
retrieveList({ ...searchCondition, pageIndex: passedPage, searchCnd: cndRef.current.value, searchWrd: wrdRef.current.value })
|
moveToPage={passedPage => {
|
||||||
|
retrieveList({
|
||||||
|
...searchCondition,
|
||||||
|
pageIndex: passedPage,
|
||||||
|
searchCnd: cndRef.current.value,
|
||||||
|
searchWrd: wrdRef.current.value
|
||||||
|
})
|
||||||
}} />
|
}} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,21 @@ package com.dbnt.kcscbackend.admin.users;
|
||||||
|
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.users.service.AdminUsersService;
|
import com.dbnt.kcscbackend.admin.users.service.AdminUsersService;
|
||||||
|
import com.dbnt.kcscbackend.auth.entity.UserInfo;
|
||||||
import com.dbnt.kcscbackend.config.common.BaseController;
|
import com.dbnt.kcscbackend.config.common.BaseController;
|
||||||
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/admin/users")
|
@RequestMapping("/admin/users")
|
||||||
|
|
@ -16,4 +25,26 @@ public class AdminUsersController extends BaseController {
|
||||||
|
|
||||||
private final AdminUsersService adminUsersService;
|
private final AdminUsersService adminUsersService;
|
||||||
|
|
||||||
|
@Operation(
|
||||||
|
summary = "사용자 목록 조회",
|
||||||
|
description = "사용자 목록 조회",
|
||||||
|
tags = {"AdminUsersController"}
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "조회 성공"),
|
||||||
|
@ApiResponse(responseCode = "403", description = "인가된 사용자가 아님")
|
||||||
|
})
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = "/list")
|
||||||
|
public ResultVO getUserList(UserInfo params) throws Exception{
|
||||||
|
ResultVO resultVO = new ResultVO();
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
params.setQueryInfo();
|
||||||
|
resultMap.put("userList", adminUsersService.selectUserList(params));
|
||||||
|
params.setContentCnt(adminUsersService.selectUserListCnt(params));
|
||||||
|
params.setPaginationInfo();
|
||||||
|
resultMap.put("paginationInfo", params);
|
||||||
|
resultVO.setResult(resultMap);
|
||||||
|
return resultVO;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
package com.dbnt.kcscbackend.admin.users.mapper;
|
package com.dbnt.kcscbackend.admin.users.mapper;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||||
|
import com.dbnt.kcscbackend.auth.entity.UserInfo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 일반 로그인을 처리하는 비즈니스 구현 클래스
|
* 일반 로그인을 처리하는 비즈니스 구현 클래스
|
||||||
* @author 공통서비스 개발팀 박지욱
|
* @author 공통서비스 개발팀 박지욱
|
||||||
|
|
@ -23,4 +26,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface AdminUsersMapper {
|
public interface AdminUsersMapper {
|
||||||
|
|
||||||
|
List<UserInfo> selectUserList(UserInfo params);
|
||||||
|
|
||||||
|
Integer selectUserListCnt(UserInfo params);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,25 @@
|
||||||
package com.dbnt.kcscbackend.admin.users.service;
|
package com.dbnt.kcscbackend.admin.users.service;
|
||||||
|
|
||||||
|
import com.dbnt.kcscbackend.admin.users.mapper.AdminUsersMapper;
|
||||||
|
import com.dbnt.kcscbackend.auth.entity.UserInfo;
|
||||||
|
import com.dbnt.kcscbackend.auth.repository.UserInfoRepository;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AdminUsersService {
|
public class AdminUsersService {
|
||||||
|
|
||||||
|
private final UserInfoRepository userInfoRepository;
|
||||||
|
private final AdminUsersMapper usersMapper;
|
||||||
|
|
||||||
|
public List<UserInfo> selectUserList(UserInfo params) {
|
||||||
|
return usersMapper.selectUserList(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer selectUserListCnt(UserInfo params) {
|
||||||
|
return usersMapper.selectUserListCnt(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.dbnt.kcscbackend.auth.entity;
|
package com.dbnt.kcscbackend.auth.entity;
|
||||||
|
|
||||||
|
import com.dbnt.kcscbackend.config.common.BoardParams;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
@ -21,7 +23,7 @@ import java.util.Set;
|
||||||
@DynamicInsert
|
@DynamicInsert
|
||||||
@DynamicUpdate
|
@DynamicUpdate
|
||||||
@Table(name = "user_info")
|
@Table(name = "user_info")
|
||||||
public class UserInfo implements UserDetails{
|
public class UserInfo extends BoardParams implements UserDetails{
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "user_seq")
|
@Column(name = "user_seq")
|
||||||
|
|
@ -34,8 +36,17 @@ public class UserInfo implements UserDetails{
|
||||||
private String email;
|
private String email;
|
||||||
@Column(name = "user_se")
|
@Column(name = "user_se")
|
||||||
private String userSe;
|
private String userSe;
|
||||||
|
@Column(name = "user_nm")
|
||||||
|
private String userNm;
|
||||||
|
@Column(name = "phone_num")
|
||||||
|
private String phoneNum;
|
||||||
|
@Column(name = "user_role")
|
||||||
|
private String userRole;
|
||||||
|
@Column(name = "use_yn")
|
||||||
|
private String useYn;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||||
Set<GrantedAuthority> roles = new HashSet<>();
|
Set<GrantedAuthority> roles = new HashSet<>();
|
||||||
for (String role : userSe.split(",")) {
|
for (String role : userSe.split(",")) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.dbnt.kcscbackend.config.common;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class BoardParams implements Serializable {
|
||||||
|
@Transient
|
||||||
|
private String searchCondition;
|
||||||
|
@Transient
|
||||||
|
private String searchKeyword;
|
||||||
|
@Transient
|
||||||
|
private Integer pageIndex=1; //요청페이지
|
||||||
|
@Transient
|
||||||
|
private Integer firstIndex=0; // 쿼리의 시작 row
|
||||||
|
@Transient
|
||||||
|
private Integer rowCnt=10; //한 페이지에 표현되는 row 수
|
||||||
|
@Transient
|
||||||
|
private Integer startNum=1; // pagination 시작값
|
||||||
|
@Transient
|
||||||
|
private Integer endNum=5; // pagination 마지막값
|
||||||
|
@Transient
|
||||||
|
private Integer maxNum; // pagination 최대값
|
||||||
|
@Transient
|
||||||
|
private Integer contentCnt=0;
|
||||||
|
|
||||||
|
public void setQueryInfo(){
|
||||||
|
setFirstIndex((getPageIndex()-1)*getRowCnt());
|
||||||
|
}
|
||||||
|
public void setPaginationInfo(){
|
||||||
|
int contentCnt = getContentCnt();
|
||||||
|
int rowCnt = getRowCnt();
|
||||||
|
int maxNum = (int)Math.ceil(((double)contentCnt)/rowCnt);
|
||||||
|
if (maxNum==0){
|
||||||
|
maxNum = 1;
|
||||||
|
}
|
||||||
|
setMaxNum(maxNum);
|
||||||
|
|
||||||
|
int pageIndex = getPageIndex();
|
||||||
|
int startNum = pageIndex - 4;
|
||||||
|
if(startNum <= 0){
|
||||||
|
startNum = 1;
|
||||||
|
}
|
||||||
|
setStartNum(startNum);
|
||||||
|
|
||||||
|
int endNum = startNum + 9;
|
||||||
|
if(endNum>maxNum){
|
||||||
|
endNum = maxNum;
|
||||||
|
}
|
||||||
|
setEndNum(endNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,4 +3,44 @@
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.dbnt.kcscbackend.admin.users.mapper.AdminUsersMapper">
|
<mapper namespace="com.dbnt.kcscbackend.admin.users.mapper.AdminUsersMapper">
|
||||||
|
|
||||||
|
<select id="selectUserList" parameterType="UserInfo" resultType="UserInfo">
|
||||||
|
select user_seq,
|
||||||
|
user_id,
|
||||||
|
email,
|
||||||
|
user_se,
|
||||||
|
user_nm,
|
||||||
|
phone_num,
|
||||||
|
user_role,
|
||||||
|
use_yn
|
||||||
|
from user_info
|
||||||
|
<include refid="selectUserListWhere"></include>
|
||||||
|
order by user_seq asc
|
||||||
|
limit #{rowCnt} offset #{firstIndex}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectUserListCnt" parameterType="UserInfo" resultType="int">
|
||||||
|
select count(*)
|
||||||
|
from user_info
|
||||||
|
<include refid="selectUserListWhere"></include>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<sql id="selectUserListWhere">
|
||||||
|
<where>
|
||||||
|
<if test='userSe != null and userSe != ""'>
|
||||||
|
and user_se = #{userSe}
|
||||||
|
</if>
|
||||||
|
<if test='searchCondition == "id"'>
|
||||||
|
and user_id like '%'||#{searchKeyword}||'%'
|
||||||
|
</if>
|
||||||
|
<if test='searchCondition == "name"'>
|
||||||
|
and user_nm like '%'||#{searchKeyword}||'%'
|
||||||
|
</if>
|
||||||
|
<if test='searchCondition == "email"'>
|
||||||
|
and email like '%'||#{searchKeyword}||'%'
|
||||||
|
</if>
|
||||||
|
<if test='searchCondition == "phoneNum"'>
|
||||||
|
and phone_num like '%'||#{searchKeyword}||'%'
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue