조사원 관리
parent
70898974d9
commit
2cb0d328a7
@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="go.kr.project.exmnr.mapper.ExmnrMapper">
|
||||
|
||||
<!-- 조사원 목록 조회 -->
|
||||
<select id="selectList" parameterType="go.kr.project.exmnr.model.ExmnrVO" resultType="go.kr.project.exmnr.model.ExmnrVO">
|
||||
/* ExmnrMapper.selectList : 조사원 목록 조회 */
|
||||
SELECT
|
||||
e.EXMNR_ID,
|
||||
e.SGG_CD,
|
||||
sgg.CD_NM AS SGG_CD_NM,
|
||||
e.REG_DT,
|
||||
e.RGTR,
|
||||
e.DEL_YN,
|
||||
e.DEL_DT,
|
||||
e.DLTR,
|
||||
e.EXMNR,
|
||||
u.USER_ACNT AS RGTR_ACNT,
|
||||
u.USER_NM AS RGTR_NM
|
||||
FROM tb_exmnr e
|
||||
LEFT JOIN tb_cd_detail sgg ON sgg.CD_GROUP_ID = 'ORG_CD' AND sgg.CD_ID = e.SGG_CD AND sgg.USE_YN = 'Y'
|
||||
LEFT JOIN tb_user u ON u.USER_ID = e.RGTR AND u.USE_YN = 'Y'
|
||||
WHERE e.DEL_YN = 'N'
|
||||
<if test='schExmnrId != null and schExmnrId != ""'>
|
||||
AND e.EXMNR_ID = #{schExmnrId}
|
||||
</if>
|
||||
<if test='schExmnr != null and schExmnr != ""'>
|
||||
AND e.EXMNR LIKE CONCAT('%', #{schExmnr}, '%')
|
||||
</if>
|
||||
ORDER BY e.EXMNR_ID ASC
|
||||
<if test='pagingYn != null and pagingYn == "Y"'>
|
||||
limit #{startIndex}, #{perPage} /* 서버사이드 페이징 처리 */
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 조사원 목록 총 개수 조회 -->
|
||||
<select id="selectListTotalCount" parameterType="go.kr.project.exmnr.model.ExmnrVO" resultType="int">
|
||||
/* ExmnrMapper.selectListTotalCount : 조사원 목록 총 개수 조회 */
|
||||
SELECT COUNT(*)
|
||||
FROM tb_exmnr e
|
||||
WHERE e.DEL_YN = 'N'
|
||||
<if test='schExmnrId != null and schExmnrId != ""'>
|
||||
AND e.EXMNR_ID = #{schExmnrId}
|
||||
</if>
|
||||
<if test='schExmnr != null and schExmnr != ""'>
|
||||
AND e.EXMNR LIKE CONCAT('%', #{schExmnr}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 조사원 단건 조회 -->
|
||||
<select id="selectOne" parameterType="go.kr.project.exmnr.model.ExmnrVO" resultType="go.kr.project.exmnr.model.ExmnrVO">
|
||||
/* ExmnrMapper.selectOne : 조사원 단건 조회 */
|
||||
SELECT
|
||||
e.EXMNR_ID,
|
||||
e.SGG_CD,
|
||||
sgg.CD_NM AS SGG_CD_NM,
|
||||
e.REG_DT,
|
||||
e.RGTR,
|
||||
e.DEL_YN,
|
||||
e.DEL_DT,
|
||||
e.DLTR,
|
||||
e.EXMNR,
|
||||
u.USER_ACNT AS RGTR_ACNT,
|
||||
u.USER_NM AS RGTR_NM
|
||||
FROM tb_exmnr e
|
||||
LEFT JOIN tb_cd_detail sgg ON sgg.CD_GROUP_ID = 'ORG_CD' AND sgg.CD_ID = e.SGG_CD AND sgg.USE_YN = 'Y'
|
||||
LEFT JOIN tb_user u ON u.USER_ID = e.RGTR AND u.USE_YN = 'Y'
|
||||
WHERE e.DEL_YN = 'N'
|
||||
AND e.EXMNR_ID = #{exmnrId}
|
||||
</select>
|
||||
|
||||
<!-- 조사원 등록 -->
|
||||
<insert id="insert" parameterType="go.kr.project.exmnr.model.ExmnrVO">
|
||||
/* ExmnrMapper.insert : 조사원 등록 */
|
||||
INSERT INTO tb_exmnr (
|
||||
EXMNR_ID,
|
||||
SGG_CD,
|
||||
REG_DT,
|
||||
RGTR,
|
||||
DEL_YN,
|
||||
EXMNR
|
||||
) VALUES (
|
||||
LPAD(NEXTVAL(seq_exmnr_id), 10, '0'),
|
||||
#{sggCd},
|
||||
NOW(),
|
||||
#{rgtr},
|
||||
'N',
|
||||
#{exmnr}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 조사원 수정 -->
|
||||
<update id="update" parameterType="go.kr.project.exmnr.model.ExmnrVO">
|
||||
/* ExmnrMapper.update : 조사원 수정 */
|
||||
UPDATE tb_exmnr
|
||||
SET EXMNR = #{exmnr}
|
||||
WHERE EXMNR_ID = #{exmnrId}
|
||||
AND DEL_YN = 'N'
|
||||
</update>
|
||||
|
||||
<!-- 조사원 삭제 -->
|
||||
<update id="delete" parameterType="go.kr.project.exmnr.model.ExmnrVO">
|
||||
/* ExmnrMapper.delete : 조사원 삭제 */
|
||||
UPDATE tb_exmnr
|
||||
SET DEL_YN = 'Y',
|
||||
DEL_DT = NOW(),
|
||||
DLTR = #{dltr}
|
||||
WHERE EXMNR_ID = #{exmnrId}
|
||||
AND DEL_YN = 'N'
|
||||
</update>
|
||||
|
||||
<!-- 조사원번호 중복 체크 -->
|
||||
<select id="selectDuplicateCheck" parameterType="go.kr.project.exmnr.model.ExmnrVO" resultType="int">
|
||||
/* ExmnrMapper.selectDuplicateCheck : 조사원번호 중복 체크 */
|
||||
SELECT COUNT(*)
|
||||
FROM tb_exmnr
|
||||
WHERE EXMNR_ID = #{exmnrId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,213 @@
|
||||
package go.kr.project.exmnr.controller;
|
||||
|
||||
import egovframework.constant.MessageConstants;
|
||||
import egovframework.constant.TilesConstants;
|
||||
import egovframework.exception.MessageException;
|
||||
import egovframework.util.ApiResponseUtil;
|
||||
import egovframework.util.SessionUtil;
|
||||
import go.kr.project.exmnr.model.ExmnrVO;
|
||||
import go.kr.project.exmnr.service.ExmnrService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* packageName : go.kr.project.exmnr.controller
|
||||
* fileName : ExmnrController
|
||||
* author :
|
||||
* date : 2025-08-27
|
||||
* description : 조사원 관리 관련 요청을 처리하는 컨트롤러
|
||||
* 중요한 로직 주석: 조사원 관련 화면 제공 및 CRUD API를 처리하는 컨트롤러
|
||||
* ===========================================================
|
||||
* DATE AUTHOR NOTE
|
||||
* -----------------------------------------------------------
|
||||
* 2025-08-27 최초 생성
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/exmnr")
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@Tag(name = "조사원 관리", description = "조사원 관리 관련 API")
|
||||
public class ExmnrController {
|
||||
|
||||
/** 조사원 서비스 */
|
||||
private final ExmnrService service;
|
||||
|
||||
@GetMapping("/list.do")
|
||||
@Operation(summary = "조사원 관리 화면", description = "조사원 목록을 조회합니다.")
|
||||
public String mainPage(Model model, HttpServletRequest request) {
|
||||
return "exmnr/list"+ TilesConstants.BASE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 조사원 목록을 조회하는 AJAX 메소드
|
||||
* 공통 응답 형식(ApiResponse)을 사용하여 응답합니다.
|
||||
*
|
||||
* @param paramVO 검색 조건을 담은 VO 객체
|
||||
* @return 조사원 목록과 성공 상태를 담은 ResponseEntity 객체
|
||||
* @throws Exception 조회 중 발생할 수 있는 예외
|
||||
*/
|
||||
@Operation(summary = "조사원 목록 조회 (AJAX)", description = "조사원 목록을 조회하고 JSON 형식으로 반환합니다.")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조사원 목록 조회 성공"),
|
||||
@ApiResponse(responseCode = "400", description = "조사원 목록 조회 실패"),
|
||||
@ApiResponse(description = "오류로 인한 실패")
|
||||
})
|
||||
@PostMapping("/list.ajax")
|
||||
public ResponseEntity<?> listAjax(@ModelAttribute ExmnrVO paramVO) {
|
||||
|
||||
// 총 조사원 수 조회
|
||||
int totalCount = service.selectListTotalCount(paramVO);
|
||||
paramVO.setTotalCount(totalCount);
|
||||
|
||||
// 페이징 처리를 위한 설정
|
||||
paramVO.setPagingYn("Y");
|
||||
|
||||
// 페이징 처리된 조사원 목록 조회
|
||||
List<ExmnrVO> list = service.selectList(paramVO);
|
||||
return ApiResponseUtil.successWithGrid(list, paramVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 조사원 등록/수정 팝업 화면을 제공한다.
|
||||
* @param exmnrId 조사원 ID (수정 시)
|
||||
* @param mode 화면 모드 (C: 등록, U: 수정, V: 보기)
|
||||
* @param model 모델 객체
|
||||
* @return 조사원 등록/수정 팝업 화면
|
||||
*/
|
||||
@GetMapping("/popup.do")
|
||||
@Operation(summary = "조사원 등록/수정 팝업", description = "조사원 등록/수정/조회 팝업 화면을 제공합니다.")
|
||||
public ModelAndView popup(
|
||||
@Parameter(description = "조사원 ID") @RequestParam(required = false) String exmnrId,
|
||||
@Parameter(description = "화면 모드 (C:등록, U:수정, V:보기)") @RequestParam String mode,
|
||||
Model model) {
|
||||
|
||||
try {
|
||||
log.debug("조사원 팝업 화면 요청 - 모드: {}, 조사원ID: {}", mode, exmnrId);
|
||||
|
||||
ModelAndView mav = new ModelAndView("exmnr/popup" + TilesConstants.POPUP);
|
||||
mav.addObject("mode", mode);
|
||||
|
||||
// 수정/조회 모드인 경우 기존 데이터 조회
|
||||
if (("U".equals(mode) || "V".equals(mode)) && exmnrId != null) {
|
||||
ExmnrVO paramVO = new ExmnrVO();
|
||||
paramVO.setExmnrId(exmnrId);
|
||||
|
||||
ExmnrVO data = service.selectOne(paramVO);
|
||||
if (data != null) {
|
||||
mav.addObject("data", data);
|
||||
} else {
|
||||
throw new MessageException("해당 조사원 정보를 찾을 수 없습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
return mav;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("조사원 팝업 화면 제공 중 오류 발생", e);
|
||||
throw new MessageException("팝업 화면을 불러오는 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 조사원 정보를 등록합니다.
|
||||
*
|
||||
* @param paramVO 등록할 조사원 정보를 담은 VO 객체
|
||||
* @return 등록 결과와 성공 상태를 담은 ResponseEntity 객체
|
||||
* @throws Exception 등록 중 발생할 수 있는 예외
|
||||
*/
|
||||
@Operation(summary = "조사원 등록", description = "새로운 조사원 정보를 등록합니다.")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조사원 등록 성공"),
|
||||
@ApiResponse(responseCode = "400", description = "조사원 등록 실패"),
|
||||
@ApiResponse(description = "오류로 인한 실패")
|
||||
})
|
||||
@PostMapping("/insert.ajax")
|
||||
public ResponseEntity<?> insert(@ModelAttribute ExmnrVO paramVO) throws Exception {
|
||||
// 등록자 정보 설정
|
||||
paramVO.setRgtr(SessionUtil.getUserId());
|
||||
|
||||
// 시군구 코드 설정 (세션의 조직 코드 사용)
|
||||
paramVO.setSggCd(SessionUtil.getSessionVO().getUser().getOrgCd());
|
||||
|
||||
int result = service.insert(paramVO);
|
||||
|
||||
if (result > 0) {
|
||||
return ApiResponseUtil.success(MessageConstants.Common.SAVE_SUCCESS);
|
||||
} else {
|
||||
return ApiResponseUtil.error(MessageConstants.Common.SAVE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 조사원 정보를 수정합니다.
|
||||
*
|
||||
* @param paramVO 수정할 조사원 정보를 담은 VO 객체
|
||||
* @return 수정 결과와 성공 상태를 담은 ResponseEntity 객체
|
||||
* @throws Exception 수정 중 발생할 수 있는 예외
|
||||
*/
|
||||
@Operation(summary = "조사원 수정", description = "기존 조사원 정보를 수정합니다.")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조사원 수정 성공"),
|
||||
@ApiResponse(responseCode = "400", description = "조사원 수정 실패"),
|
||||
@ApiResponse(description = "오류로 인한 실패")
|
||||
})
|
||||
@PostMapping("/update.ajax")
|
||||
public ResponseEntity<?> update(@ModelAttribute ExmnrVO paramVO) throws Exception {
|
||||
int result = service.update(paramVO);
|
||||
|
||||
if (result > 0) {
|
||||
return ApiResponseUtil.success(MessageConstants.Common.UPDATE_SUCCESS);
|
||||
} else {
|
||||
return ApiResponseUtil.error(MessageConstants.Common.UPDATE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 조사원 정보를 삭제합니다. (논리 삭제)
|
||||
*
|
||||
* @param exmnrId 조사원 ID
|
||||
* @return 삭제 결과와 성공 상태를 담은 ResponseEntity 객체
|
||||
* @throws Exception 삭제 중 발생할 수 있는 예외
|
||||
*/
|
||||
@Operation(summary = "조사원 삭제", description = "조사원 정보를 삭제(논리삭제)합니다.")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "조사원 삭제 성공"),
|
||||
@ApiResponse(responseCode = "400", description = "조사원 삭제 실패"),
|
||||
@ApiResponse(description = "오류로 인한 실패")
|
||||
})
|
||||
@PostMapping("/delete.ajax")
|
||||
public ResponseEntity<?> delete(@RequestParam String exmnrId) throws Exception {
|
||||
ExmnrVO paramVO = new ExmnrVO();
|
||||
paramVO.setExmnrId(exmnrId);
|
||||
|
||||
int result = service.delete(paramVO);
|
||||
|
||||
if (result > 0) {
|
||||
return ApiResponseUtil.success(MessageConstants.Common.DELETE_SUCCESS);
|
||||
} else {
|
||||
return ApiResponseUtil.error(MessageConstants.Common.DELETE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
package go.kr.project.exmnr.mapper;
|
||||
|
||||
import go.kr.project.exmnr.model.ExmnrVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* packageName : go.kr.project.exmnr.mapper
|
||||
* fileName : ExmnrMapper
|
||||
* author :
|
||||
* date : 2025-08-28
|
||||
* description : 조사원 관련 데이터베이스 접근을 위한 MyBatis 매퍼 인터페이스
|
||||
* 중요한 로직 주석: 조사원 테이블(tb_exmnr)에 대한 CRUD 작업을 수행하는 매퍼 인터페이스
|
||||
* ===========================================================
|
||||
* DATE AUTHOR NOTE
|
||||
* -----------------------------------------------------------
|
||||
* 2025-08-28 최초 생성
|
||||
*/
|
||||
@Mapper
|
||||
public interface ExmnrMapper {
|
||||
|
||||
/**
|
||||
* 조사원 목록을 조회한다.
|
||||
* @param vo 검색 조건과 페이징 정보를 담은 VO 객체
|
||||
* @return 조사원 목록
|
||||
*/
|
||||
List<ExmnrVO> selectList(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* 조사원 목록의 총 개수를 조회한다.
|
||||
* @param vo 검색 조건을 담은 VO 객체
|
||||
* @return 조회된 목록의 총 개수
|
||||
*/
|
||||
int selectListTotalCount(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* 특정 조사원 ID에 해당하는 조사원 정보를 조회한다.
|
||||
* @param vo 조회할 PK 정보(exmnrId)를 담은 VO 객체
|
||||
* @return 조회된 조사원 정보
|
||||
*/
|
||||
ExmnrVO selectOne(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* 새로운 조사원 정보를 등록한다.
|
||||
* 조사원 ID는 연도별 시컨스를 통해 자동 생성된다.
|
||||
* @param vo 등록할 조사원 정보를 담은 VO 객체
|
||||
* @return 등록된 행의 수
|
||||
*/
|
||||
int insert(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* 기존 조사원 정보를 수정한다.
|
||||
* @param vo 수정할 조사원 정보를 담은 VO 객체
|
||||
* @return 수정된 행의 수
|
||||
*/
|
||||
int update(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* 조사원 정보를 삭제한다. (논리 삭제)
|
||||
* @param vo 삭제할 PK 정보(exmnrId)를 담은 VO 객체
|
||||
* @return 삭제된 행의 수
|
||||
*/
|
||||
int delete(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* PK(조사원 ID) 중복 체크를 수행한다.
|
||||
* @param vo 중복 체크할 PK 정보(exmnrId)를 담은 VO 객체
|
||||
* @return 중복 건수 (0이면 중복 없음, 1이상이면 중복 존재)
|
||||
*/
|
||||
int selectDuplicateCheck(ExmnrVO vo);
|
||||
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package go.kr.project.exmnr.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import go.kr.project.common.model.PagingVO;
|
||||
import lombok.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* packageName : go.kr.project.exmnr.model
|
||||
* fileName : ExmnrVO
|
||||
* author :
|
||||
* date : 2025-08-28
|
||||
* description : 조사원 관련 데이터를 담는 Value Object 클래스
|
||||
* 중요한 로직 주석: 조사원 테이블(tb_exmnr)과 매핑되는 VO 클래스로 페이징 기능을 포함한다.
|
||||
* ===========================================================
|
||||
* DATE AUTHOR NOTE
|
||||
* -----------------------------------------------------------
|
||||
* 2025-08-28 최초 생성
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper=true)
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class ExmnrVO extends PagingVO {
|
||||
|
||||
// ==================== 기본 테이블 컬럼 ====================
|
||||
|
||||
/** 조사원 ID */
|
||||
private String exmnrId;
|
||||
|
||||
/** 시군구 코드(그룹코드:ORG_CD, 로그인한 사용자정보에서 ORG_CD 가져온다.) */
|
||||
private String sggCd;
|
||||
|
||||
/** 등록 일시 */
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul")
|
||||
private LocalDateTime regDt;
|
||||
|
||||
/** 등록자 */
|
||||
private String rgtr;
|
||||
|
||||
/** 삭제 여부 */
|
||||
private String delYn;
|
||||
|
||||
/** 삭제 일시 */
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul")
|
||||
private LocalDateTime delDt;
|
||||
|
||||
/** 삭제자 */
|
||||
private String dltr;
|
||||
|
||||
/** 조사원 */
|
||||
private String exmnr;
|
||||
|
||||
// ==================== 조인 컬럼 (코드명) ====================
|
||||
|
||||
/** 시군구 코드명 */
|
||||
private String sggCdNm;
|
||||
|
||||
/** 등록자*/
|
||||
private String rgtrNm;
|
||||
|
||||
/** 역순 행 번호 (그리드 표시용) */
|
||||
private Integer rowNum;
|
||||
|
||||
// ==================== 검색 조건 ====================
|
||||
|
||||
/** 검색 조건 - 조사원 ID */
|
||||
private String schExmnrId;
|
||||
|
||||
/** 검색 조건 - 조사원 */
|
||||
private String schExmnr;
|
||||
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package go.kr.project.exmnr.service;
|
||||
|
||||
import go.kr.project.exmnr.model.ExmnrVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* packageName : go.kr.project.exmnr.service
|
||||
* fileName : ExmnrService
|
||||
* author :
|
||||
* date : 2025-08-28
|
||||
* description : 조사원 관련 비즈니스 로직을 처리하는 서비스 인터페이스
|
||||
* ===========================================================
|
||||
* DATE AUTHOR NOTE
|
||||
* -----------------------------------------------------------
|
||||
* 2025-08-28 최초 생성
|
||||
*/
|
||||
public interface ExmnrService {
|
||||
|
||||
/**
|
||||
* 조사원 목록을 조회합니다.
|
||||
*
|
||||
* @param vo 검색 조건과 페이징 정보를 담은 VO 객체
|
||||
* @return 조사원 목록
|
||||
*/
|
||||
List<ExmnrVO> selectList(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* 조사원 목록의 총 개수를 조회합니다.
|
||||
*
|
||||
* @param vo 검색 조건을 담은 VO 객체
|
||||
* @return 조회된 목록의 총 개수
|
||||
*/
|
||||
int selectListTotalCount(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* 조사원 정보를 조회합니다.
|
||||
*
|
||||
* @param vo 조회할 PK 정보(exmnrId)를 담은 VO 객체
|
||||
* @return 조회된 조사원 정보
|
||||
*/
|
||||
ExmnrVO selectOne(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* 조사원 정보를 등록합니다.
|
||||
*
|
||||
* @param vo 등록할 조사원 정보를 담은 VO 객체
|
||||
* @return 등록된 행의 수
|
||||
*/
|
||||
int insert(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* 조사원 정보를 수정합니다.
|
||||
*
|
||||
* @param vo 수정할 조사원 정보를 담은 VO 객체
|
||||
* @return 수정된 행의 수
|
||||
*/
|
||||
int update(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* 조사원 정보를 삭제합니다. (논리 삭제)
|
||||
*
|
||||
* @param vo 삭제할 PK 정보(exmnrId)를 담은 VO 객체
|
||||
* @return 삭제된 행의 수
|
||||
*/
|
||||
int delete(ExmnrVO vo);
|
||||
|
||||
/**
|
||||
* PK(조사원 ID) 중복 체크를 수행합니다.
|
||||
*
|
||||
* @param vo 중복 체크할 PK 정보(exmnrId)를 담은 VO 객체
|
||||
* @return 중복 건수 (0이면 중복 없음, 1이상이면 중복 존재)
|
||||
*/
|
||||
int selectDuplicateCheck(ExmnrVO vo);
|
||||
|
||||
}
|
||||
@ -0,0 +1,183 @@
|
||||
package go.kr.project.exmnr.service.impl;
|
||||
|
||||
import egovframework.exception.MessageException;
|
||||
import egovframework.util.SessionUtil;
|
||||
import egovframework.util.StringUtil;
|
||||
import go.kr.project.crdn.crndRegistAndView.model.CrdnRegistAndViewVO;
|
||||
import go.kr.project.exmnr.mapper.ExmnrMapper;
|
||||
import go.kr.project.exmnr.model.ExmnrVO;
|
||||
import go.kr.project.exmnr.service.ExmnrService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import static egovframework.constant.SEQConstants.SEQ_CRDN;
|
||||
|
||||
/**
|
||||
* packageName : go.kr.project.exmnr.service.impl
|
||||
* fileName : ExmnrServiceImpl
|
||||
* author :
|
||||
* date : 2025-08-28
|
||||
* description : 조사원 관련 비즈니스 로직을 처리하는 서비스 구현체
|
||||
* ===========================================================
|
||||
* DATE AUTHOR NOTE
|
||||
* -----------------------------------------------------------
|
||||
* 2025-08-28 최초 생성
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ExmnrServiceImpl extends EgovAbstractServiceImpl implements ExmnrService {
|
||||
|
||||
private final ExmnrMapper mapper;
|
||||
|
||||
/**
|
||||
* 조사원 목록을 조회합니다.
|
||||
*
|
||||
* @param vo 검색 조건과 페이징 정보를 담은 VO 객체
|
||||
* @return 조사원 목록
|
||||
*/
|
||||
@Override
|
||||
public List<ExmnrVO> selectList(ExmnrVO vo) {
|
||||
return mapper.selectList(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 조사원 목록의 총 개수를 조회합니다.
|
||||
*
|
||||
* @param vo 검색 조건을 담은 VO 객체
|
||||
* @return 조회된 목록의 총 개수
|
||||
*/
|
||||
@Override
|
||||
public int selectListTotalCount(ExmnrVO vo) {
|
||||
return mapper.selectListTotalCount(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 조사원 정보를 조회합니다.
|
||||
*
|
||||
* @param vo 조회할 PK 정보(exmnrId)를 담은 VO 객체
|
||||
* @return 조회된 조사원 정보
|
||||
*/
|
||||
@Override
|
||||
public ExmnrVO selectOne(ExmnrVO vo) {
|
||||
return mapper.selectOne(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 조사원 정보를 등록합니다.
|
||||
*
|
||||
* @param vo 등록할 조사원 정보를 담은 VO 객체
|
||||
* @return 등록된 행의 수
|
||||
*/
|
||||
@Override
|
||||
public int insert(ExmnrVO vo) {
|
||||
log.debug("조사원 등록 - 조사원: {}", vo.getExmnr());
|
||||
|
||||
// 필수값 검증
|
||||
validateRequiredFields(vo);
|
||||
|
||||
// 조사원 바이트 길이 검증 (한글 3바이트 기준 최대 100바이트)
|
||||
if (vo.getExmnr() != null && !vo.getExmnr().trim().isEmpty()) {
|
||||
int byteLength = StringUtil.calculateUtf8ByteLength(vo.getExmnr());
|
||||
if (byteLength > 100) {
|
||||
log.warn("조사원 등록 실패 - 조사원 바이트 길이 초과: {}바이트", byteLength);
|
||||
throw new MessageException("조사원명은 최대 100바이트까지 입력 가능합니다. (현재: " + byteLength + "바이트)");
|
||||
}
|
||||
}
|
||||
|
||||
// 등록자 정보 설정 및 등록 수행
|
||||
vo.setRgtr(SessionUtil.getUserId());
|
||||
int result = mapper.insert(vo);
|
||||
log.debug("조사원 등록 완료 - 등록 건수: {}", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 조사원 정보를 수정합니다.
|
||||
*
|
||||
* @param vo 수정할 조사원 정보를 담은 VO 객체
|
||||
* @return 수정된 행의 수
|
||||
*/
|
||||
@Override
|
||||
public int update(ExmnrVO vo) {
|
||||
log.debug("조사원 수정 - 조사원 ID: {}", vo.getExmnrId());
|
||||
|
||||
// PK(조사원 ID) 필수값 검증
|
||||
validatePrimaryKey(vo);
|
||||
|
||||
// 필수값 검증
|
||||
validateRequiredFields(vo);
|
||||
|
||||
// 조사원 바이트 길이 검증 (한글 3바이트 기준 최대 100바이트)
|
||||
if (vo.getExmnr() != null && !vo.getExmnr().trim().isEmpty()) {
|
||||
int byteLength = StringUtil.calculateUtf8ByteLength(vo.getExmnr());
|
||||
if (byteLength > 100) {
|
||||
log.warn("조사원 수정 실패 - 조사원 바이트 길이 초과: {}바이트", byteLength);
|
||||
throw new MessageException("조사원명은 최대 100바이트까지 입력 가능합니다. (현재: " + byteLength + "바이트)");
|
||||
}
|
||||
}
|
||||
|
||||
// 수정 수행
|
||||
int result = mapper.update(vo);
|
||||
log.debug("조사원 수정 완료 - 수정 건수: {}", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 조사원 정보를 삭제합니다. (논리 삭제)
|
||||
*
|
||||
* @param vo 삭제할 PK 정보(exmnrId)를 담은 VO 객체
|
||||
* @return 삭제된 행의 수
|
||||
*/
|
||||
@Override
|
||||
public int delete(ExmnrVO vo) {
|
||||
// PK(조사원 ID) 필수값 검증
|
||||
validatePrimaryKey(vo);
|
||||
|
||||
// 삭제자 정보 설정 및 삭제 수행
|
||||
vo.setDltr(SessionUtil.getUserId());
|
||||
return mapper.delete(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* PK(조사원 ID) 중복 체크를 수행합니다.
|
||||
*
|
||||
* @param vo 중복 체크할 PK 정보(exmnrId)를 담은 VO 객체
|
||||
* @return 중복 건수 (0이면 중복 없음, 1이상이면 중복 존재)
|
||||
*/
|
||||
@Override
|
||||
public int selectDuplicateCheck(ExmnrVO vo) {
|
||||
return mapper.selectDuplicateCheck(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* PK(조사원 ID) 필수값 검증을 수행한다.
|
||||
* @param vo 검증할 VO 객체
|
||||
* @throws MessageException PK 필수값 누락 시 발생
|
||||
*/
|
||||
private void validatePrimaryKey(ExmnrVO vo) {
|
||||
if (vo.getExmnrId() == null || vo.getExmnrId().trim().isEmpty()) {
|
||||
log.warn("조사원 작업 실패 - 조사원 ID 누락");
|
||||
//throw new MessageException("는 필수값입니다.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 필수값 검증을 수행한다.
|
||||
* @param vo 검증할 VO 객체
|
||||
* @throws MessageException 필수값 누락 시 발생
|
||||
*/
|
||||
private void validateRequiredFields(ExmnrVO vo) {
|
||||
if (vo.getExmnr() == null || vo.getExmnr().trim().isEmpty()) {
|
||||
log.warn("조사원 작업 실패 - 조사원명 미입력");
|
||||
throw new MessageException("조사원명은 필수값입니다.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="go.kr.project.exmnr.mapper.ExmnrMapper">
|
||||
|
||||
<!-- 조사원 목록 조회 -->
|
||||
<select id="selectList" parameterType="go.kr.project.exmnr.model.ExmnrVO" resultType="go.kr.project.exmnr.model.ExmnrVO">
|
||||
/* ExmnrMapper.selectList : 조사원 목록 조회 */
|
||||
SELECT
|
||||
e.EXMNR_ID,
|
||||
e.SGG_CD,
|
||||
sgg.CD_NM AS SGG_CD_NM,
|
||||
e.REG_DT,
|
||||
e.RGTR,
|
||||
e.DEL_YN,
|
||||
e.DEL_DT,
|
||||
e.DLTR,
|
||||
e.EXMNR,
|
||||
u.USER_ACNT AS RGTR_ACNT,
|
||||
u.USER_NM AS RGTR_NM
|
||||
FROM tb_exmnr e
|
||||
LEFT JOIN tb_cd_detail sgg ON sgg.CD_GROUP_ID = 'ORG_CD' AND sgg.CD_ID = e.SGG_CD AND sgg.USE_YN = 'Y'
|
||||
LEFT JOIN tb_user u ON u.USER_ID = e.RGTR AND u.USE_YN = 'Y'
|
||||
WHERE e.DEL_YN = 'N'
|
||||
<if test='schExmnrId != null and schExmnrId != ""'>
|
||||
AND e.EXMNR_ID = #{schExmnrId}
|
||||
</if>
|
||||
<if test='schExmnr != null and schExmnr != ""'>
|
||||
AND e.EXMNR LIKE CONCAT('%', #{schExmnr}, '%')
|
||||
</if>
|
||||
ORDER BY e.EXMNR_ID ASC
|
||||
<if test='pagingYn != null and pagingYn == "Y"'>
|
||||
limit #{startIndex}, #{perPage} /* 서버사이드 페이징 처리 */
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 조사원 목록 총 개수 조회 -->
|
||||
<select id="selectListTotalCount" parameterType="go.kr.project.exmnr.model.ExmnrVO" resultType="int">
|
||||
/* ExmnrMapper.selectListTotalCount : 조사원 목록 총 개수 조회 */
|
||||
SELECT COUNT(*)
|
||||
FROM tb_exmnr e
|
||||
WHERE e.DEL_YN = 'N'
|
||||
<if test='schExmnrId != null and schExmnrId != ""'>
|
||||
AND e.EXMNR_ID = #{schExmnrId}
|
||||
</if>
|
||||
<if test='schExmnr != null and schExmnr != ""'>
|
||||
AND e.EXMNR LIKE CONCAT('%', #{schExmnr}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 조사원 단건 조회 -->
|
||||
<select id="selectOne" parameterType="go.kr.project.exmnr.model.ExmnrVO" resultType="go.kr.project.exmnr.model.ExmnrVO">
|
||||
/* ExmnrMapper.selectOne : 조사원 단건 조회 */
|
||||
SELECT
|
||||
e.EXMNR_ID,
|
||||
e.SGG_CD,
|
||||
sgg.CD_NM AS SGG_CD_NM,
|
||||
e.REG_DT,
|
||||
e.RGTR,
|
||||
e.DEL_YN,
|
||||
e.DEL_DT,
|
||||
e.DLTR,
|
||||
e.EXMNR,
|
||||
u.USER_ACNT AS RGTR_ACNT,
|
||||
u.USER_NM AS RGTR_NM
|
||||
FROM tb_exmnr e
|
||||
LEFT JOIN tb_cd_detail sgg ON sgg.CD_GROUP_ID = 'ORG_CD' AND sgg.CD_ID = e.SGG_CD AND sgg.USE_YN = 'Y'
|
||||
LEFT JOIN tb_user u ON u.USER_ID = e.RGTR AND u.USE_YN = 'Y'
|
||||
WHERE e.DEL_YN = 'N'
|
||||
AND e.EXMNR_ID = #{exmnrId}
|
||||
</select>
|
||||
|
||||
<!-- 조사원 등록 -->
|
||||
<insert id="insert" parameterType="go.kr.project.exmnr.model.ExmnrVO">
|
||||
/* ExmnrMapper.insert : 조사원 등록 */
|
||||
INSERT INTO tb_exmnr (
|
||||
EXMNR_ID,
|
||||
SGG_CD,
|
||||
REG_DT,
|
||||
RGTR,
|
||||
DEL_YN,
|
||||
EXMNR
|
||||
) VALUES (
|
||||
LPAD(NEXTVAL(seq_exmnr_id), 10, '0'),
|
||||
#{sggCd},
|
||||
NOW(),
|
||||
#{rgtr},
|
||||
'N',
|
||||
#{exmnr}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 조사원 수정 -->
|
||||
<update id="update" parameterType="go.kr.project.exmnr.model.ExmnrVO">
|
||||
/* ExmnrMapper.update : 조사원 수정 */
|
||||
UPDATE tb_exmnr
|
||||
SET EXMNR = #{exmnr}
|
||||
WHERE EXMNR_ID = #{exmnrId}
|
||||
AND DEL_YN = 'N'
|
||||
</update>
|
||||
|
||||
<!-- 조사원 삭제 -->
|
||||
<update id="delete" parameterType="go.kr.project.exmnr.model.ExmnrVO">
|
||||
/* ExmnrMapper.delete : 조사원 삭제 */
|
||||
UPDATE tb_exmnr
|
||||
SET DEL_YN = 'Y',
|
||||
DEL_DT = NOW(),
|
||||
DLTR = #{dltr}
|
||||
WHERE EXMNR_ID = #{exmnrId}
|
||||
AND DEL_YN = 'N'
|
||||
</update>
|
||||
|
||||
<!-- 조사원번호 중복 체크 -->
|
||||
<select id="selectDuplicateCheck" parameterType="go.kr.project.exmnr.model.ExmnrVO" resultType="int">
|
||||
/* ExmnrMapper.selectDuplicateCheck : 조사원번호 중복 체크 */
|
||||
SELECT COUNT(*)
|
||||
FROM tb_exmnr
|
||||
WHERE EXMNR_ID = #{exmnrId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,423 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="dateUtil" uri="http://egovframework.go.kr/functions/date-util" %>
|
||||
|
||||
<!-- Main body -->
|
||||
<div class="main_body">
|
||||
<section id="section8" class="main_bars">
|
||||
<div class="bgs-main">
|
||||
<section id="section5">
|
||||
<div class="sub_title"></div>
|
||||
<button type="button" id="registerBtn" class="newbtn bg1">등록</button>
|
||||
<button type="button" id="updaterBtn" class="newbtn bg4">수정</button>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
<div class="contants_body">
|
||||
<div class="gs_b_top">
|
||||
<ul class="lef">
|
||||
<li class="th">조사원 ID</li>
|
||||
<li>
|
||||
<input type="text" id="schExmnrId" name="schExmnrId" maxlength="6" class="input" style="width: 100px;" autocomplete="off"/>
|
||||
</li>
|
||||
<li class="th">조사원</li>
|
||||
<li>
|
||||
<input type="text" id="schExmnr" name="schExmnr" maxlength="50" class="input" style="width: 150px;" autocomplete="off"/>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="rig2">
|
||||
<li><button type="button" id="search_btn" class="newbtnss bg1">검색</button></li>
|
||||
<li><button type="button" id="reset_btn" class="newbtnss bg5" style="margin-left: 5px;">초기화</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="gs_booking">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="box_column">
|
||||
<ul class="box_title" style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<li class="tit">조사원 목록</li>
|
||||
<li class="rig">
|
||||
<span id="totalCount" class="total-count" style="padding-left: 25px;padding-right: 25px;">총 0건</span>
|
||||
<select id="perPageSelect" class="input" style="width: 112px; ">
|
||||
<option value="15">페이지당 15</option>
|
||||
<option value="50">페이지당 50</option>
|
||||
<option value="100">페이지당 100</option>
|
||||
</select>
|
||||
<span class="page_number"><span id="currentPage"></span><span class="bar">/</span><span id="totalPages"></span> Pages</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="containers">
|
||||
<div id="grid"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Main body -->
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
/**
|
||||
* 조사원 등록/조회 목록 관리 모듈
|
||||
* 조사원 목록을 조회하고 관리하는 기능을 제공합니다.
|
||||
*/
|
||||
(function(window, $) {
|
||||
'use strict';
|
||||
|
||||
var SEARCH_COND = {};
|
||||
|
||||
// 페이징 정보를 저장할 전역 변수
|
||||
var GRID_PAGINATION_INFO = {
|
||||
totalCount: 0,
|
||||
page: 0,
|
||||
perPage: 0
|
||||
};
|
||||
|
||||
// 검색정보 설정
|
||||
var setSearchCond = function() {
|
||||
var schExmnrId = $.trim(nvl($("#schExmnrId").val(), ""));
|
||||
var schExmnr = $.trim(nvl($("#schExmnr").val(), ""));
|
||||
|
||||
SEARCH_COND.schExmnrId = schExmnrId;
|
||||
SEARCH_COND.schExmnr = schExmnr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 조사원 목록 관리 네임스페이스
|
||||
*/
|
||||
var ExmnrList = {
|
||||
/**
|
||||
* 선택된 행 정보
|
||||
*/
|
||||
selectedRow: null,
|
||||
|
||||
/**
|
||||
* 그리드 관련 객체
|
||||
*/
|
||||
grid: {
|
||||
/**
|
||||
* 그리드 인스턴스
|
||||
*/
|
||||
instance: null,
|
||||
|
||||
/**
|
||||
* 그리드 설정 초기화
|
||||
* @returns {Object} 그리드 설정 객체
|
||||
*/
|
||||
initConfig: function() {
|
||||
// 데이터 소스 설정
|
||||
var dataSource = this.createDataSource();
|
||||
|
||||
// 현재 선택된 perPage 값 가져오기
|
||||
var perPage = parseInt($('#perPageSelect').val() || 15, 10);
|
||||
|
||||
// 그리드 설정 객체 생성
|
||||
var gridConfig = new XitTuiGridConfig();
|
||||
|
||||
// 기본 설정
|
||||
gridConfig.setOptDataSource(dataSource); // 데이터소스 연결
|
||||
gridConfig.setOptGridId('grid'); // 그리드를 출력할 Element ID
|
||||
gridConfig.setOptGridHeight(470); // 그리드 높이(단위: px)
|
||||
gridConfig.setOptRowHeight(30); // 그리드 행 높이(단위: px)
|
||||
gridConfig.setOptRowHeaderType(''); // 행 첫번째 셀 타입 비활성화 (라디오 버튼을 컬럼으로 구현)
|
||||
gridConfig.setOptUseClientSort(false); // 서버사이드 정렬 false
|
||||
|
||||
// 페이징 옵션 설정
|
||||
gridConfig.setOptPageOptions({
|
||||
useClient: false, // 클라이언트 페이징 여부(false: 서버 페이징)
|
||||
perPage: perPage // 페이지당 표시 건수
|
||||
});
|
||||
gridConfig.setOptColumns(this.getGridColumns());
|
||||
|
||||
return gridConfig;
|
||||
},
|
||||
|
||||
/**
|
||||
* 그리드 컬럼 정의
|
||||
* @returns {Array} 그리드 컬럼 배열
|
||||
*/
|
||||
getGridColumns: function() {
|
||||
var self = this;
|
||||
return [
|
||||
{
|
||||
header: '선택',
|
||||
name: '_radio',
|
||||
align: 'center',
|
||||
width: 50,
|
||||
sortable: false,
|
||||
renderer: {
|
||||
type: XitRadioRenderer,
|
||||
options: {
|
||||
radioName: 'gridRowRadio',
|
||||
targetObject: 'ExmnrList',
|
||||
selectedRowProperty: 'selectedRow'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
header: '번호',
|
||||
name: '_rowNum',
|
||||
align: 'center',
|
||||
width: 60,
|
||||
sortable: false,
|
||||
formatter: function(e) {
|
||||
// 서버사이드 페이징에서 역순 번호 계산
|
||||
// totalCount - (현재페이지-1) * 페이지당항목수 - 현재행인덱스
|
||||
var totalCount = GRID_PAGINATION_INFO.totalCount;
|
||||
var page = GRID_PAGINATION_INFO.page;
|
||||
var perPage = GRID_PAGINATION_INFO.perPage;
|
||||
var rowIndex = e.row.rowKey;
|
||||
return (page - 1) * perPage + rowIndex + 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
header: '조사원ID',
|
||||
name: 'exmnrId',
|
||||
align: 'center',
|
||||
width: 90,
|
||||
//sortable: true
|
||||
},
|
||||
{
|
||||
header: '조사원',
|
||||
name: 'exmnr',
|
||||
align: 'center',
|
||||
width: 120
|
||||
//sortable: true
|
||||
},
|
||||
{
|
||||
header: '등록일시',
|
||||
name: 'regDt',
|
||||
align: 'center',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
header: '등록자',
|
||||
name: 'rgtrNm',
|
||||
align: 'center',
|
||||
width: 100
|
||||
}
|
||||
];
|
||||
},
|
||||
|
||||
/**
|
||||
* 데이터 소스 생성
|
||||
* @returns {Object} 데이터 소스 설정 객체
|
||||
*/
|
||||
createDataSource: function() {
|
||||
return {
|
||||
api: {
|
||||
readData: {
|
||||
url: '<c:url value="/exmnr/list.ajax"/>',
|
||||
method: 'POST',
|
||||
contentType: 'application/x-www-form-urlencoded',
|
||||
processData: true
|
||||
}
|
||||
},
|
||||
initialRequest: false, // 초기 데이터 요청 여부
|
||||
serializer: function(params) {
|
||||
setSearchCond();
|
||||
SEARCH_COND.perPage = params.perPage;
|
||||
SEARCH_COND.page = params.page;
|
||||
return $.param(SEARCH_COND);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* 그리드 인스턴스 생성
|
||||
*/
|
||||
create: function() {
|
||||
var gridConfig = this.initConfig();
|
||||
var Grid = tui.Grid;
|
||||
this.instance = gridConfig.instance(Grid);
|
||||
|
||||
// 그리드 테마 설정
|
||||
Grid.applyTheme('striped');
|
||||
|
||||
this.gridBindEvents();
|
||||
},
|
||||
|
||||
/**
|
||||
* 그리드 이벤트 바인딩
|
||||
*/
|
||||
gridBindEvents: function() {
|
||||
var self = this;
|
||||
|
||||
// 데이터 로딩 완료 이벤트 - 라디오 버튼 초기화
|
||||
this.instance.on('successResponse', function(ev) {
|
||||
var responseObj = JSON.parse(ev.xhr.response);
|
||||
if( responseObj ){
|
||||
$("#currentPage").text(responseObj.data.pagination.page);
|
||||
$("#totalPages").text(responseObj.data.pagination.totalPages);
|
||||
var totalCount = responseObj.data.pagination.totalCount;
|
||||
$("#totalCount").text('총 ' + totalCount.toLocaleString() + '건');
|
||||
|
||||
// 페이징 정보를 전역 변수에 저장 (formatter에서 사용하기 위해)
|
||||
GRID_PAGINATION_INFO.totalCount = responseObj.data.pagination.totalCount;
|
||||
GRID_PAGINATION_INFO.page = responseObj.data.pagination.page;
|
||||
GRID_PAGINATION_INFO.perPage = responseObj.data.pagination.perPage;
|
||||
}
|
||||
|
||||
// 라디오 버튼 모두 해제
|
||||
document.querySelectorAll('input[name="gridRowRadio"]').forEach(function(radio) {
|
||||
radio.checked = false;
|
||||
});
|
||||
// 선택된 행 초기화
|
||||
ExmnrList.selectedRow = null;
|
||||
});
|
||||
|
||||
// 행 선택 이벤트
|
||||
this.instance.on('selection', function(ev) {
|
||||
if (ev.range && ev.range.row && ev.range.row.length > 0) {
|
||||
var rowKey = ev.range.row[0];
|
||||
ExmnrList.selectedRow = self.instance.getRow(rowKey);
|
||||
|
||||
// XitRadioRenderer 동기화 함수 사용
|
||||
XitRadioRenderer.syncRadioSelection(rowKey, 'gridRowRadio');
|
||||
}
|
||||
});
|
||||
|
||||
// 행 클릭 이벤트 - 라디오 버튼 즉시 체크를 위해 추가
|
||||
this.instance.on('click', function(ev) {
|
||||
if (ev.rowKey !== undefined && ev.rowKey !== null) {
|
||||
ExmnrList.selectedRow = self.instance.getRow(ev.rowKey);
|
||||
|
||||
// XitRadioRenderer 동기화 함수 사용
|
||||
XitRadioRenderer.syncRadioSelection(ev.rowKey, 'gridRowRadio');
|
||||
}
|
||||
});
|
||||
|
||||
// 행 더블클릭 이벤트 - detailView 페이지를 새 탭으로 열기
|
||||
this.instance.on('dblclick', function(ev) {
|
||||
var rowKey = ev.rowKey;
|
||||
var rowData = self.instance.getRow(rowKey);
|
||||
if (rowData) {
|
||||
ExmnrList.openViewPopup(rowData.exmnrId);
|
||||
// var paramCond = Object.assign({}, SEARCH_COND);
|
||||
// paramCond.crdnYr = rowData.crdnYr;
|
||||
// paramCond.crdnNo = rowData.crdnNo;
|
||||
|
||||
// 새 탭으로 열기 - 컨트롤러가 요구하는 파라미터명으로 전달 (crdnYr, crdnNo)
|
||||
// var detailUrl = buildUrlWithParamCondAndMultipleKeys(null, {"crdnYr": rowData.crdnYr, "crdnNo": rowData.crdnNo}, "<c:url value="/crdn/crndRegistAndView/detailView.do"/>");
|
||||
// window.open(detailUrl, 'crdnDetailView');
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 팝업 관련 기능
|
||||
*/
|
||||
openRegisterPopup: function() {
|
||||
window.open('<c:url value="/exmnr/popup.do"/>?mode=C', 'exmnrReg', 'width=450,height=280');
|
||||
},
|
||||
|
||||
openViewPopup: function(exmnrId) {
|
||||
var url = '<c:url value="/exmnr/popup.do"/>?mode=V&exmnrId=' + encodeURIComponent(exmnrId);
|
||||
window.open(url, 'exmnr', 'width=450,height=280');
|
||||
},
|
||||
|
||||
/**
|
||||
* 목록 새로고침
|
||||
*/
|
||||
refreshList: function() {
|
||||
if (this.grid.instance) {
|
||||
this.grid.instance.readData(GRID_PAGINATION_INFO.page);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 이벤트 핸들러 설정
|
||||
*/
|
||||
eventBindEvents: function() {
|
||||
var self = this;
|
||||
|
||||
// 검색 버튼 클릭 이벤트
|
||||
$("#search_btn").on('click', function() {
|
||||
self.grid.instance.readData(1);
|
||||
});
|
||||
|
||||
// 초기화 버튼 클릭 이벤트
|
||||
$("#reset_btn").on('click', function() {
|
||||
// 모든 검색 조건 초기화
|
||||
$("#schExmnrId").val("");
|
||||
$("#schExmnr").val("");
|
||||
|
||||
// 그리드 데이터 새로고침
|
||||
self.grid.instance.readData(1);
|
||||
});
|
||||
|
||||
// 등록 버튼 클릭 이벤트
|
||||
$("#registerBtn").on('click', function() {
|
||||
self.openRegisterPopup();
|
||||
});
|
||||
|
||||
// 수정 버튼 클릭 이벤트
|
||||
$("#updaterBtn").on('click', function() {
|
||||
// 선택된 행 확인
|
||||
if (!self.selectedRow) {
|
||||
alert('수정할 조사원을 선택해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
// 선택된 행의 데이터로 팝업 열기
|
||||
self.openViewPopup(self.selectedRow.exmnrId);
|
||||
});
|
||||
|
||||
// 엔터키 검색
|
||||
$(".gs_b_top input").on('keypress', function(e) {
|
||||
if (e.which === 13) {
|
||||
e.preventDefault();
|
||||
$("#search_btn").trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
// perPage 변경 이벤트 추가
|
||||
$('#perPageSelect').on('change', function() {
|
||||
var perPage = parseInt($(this).val(), 10);
|
||||
self.grid.instance.setPerPage(perPage);
|
||||
|
||||
// 라디오 버튼 모두 해제
|
||||
document.querySelectorAll('input[name="gridRowRadio"]').forEach(function(radio) {
|
||||
radio.checked = false;
|
||||
});
|
||||
// 선택된 행 초기화
|
||||
self.selectedRow = null;
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 모듈 초기화
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
// 그리드 생성
|
||||
this.grid.create();
|
||||
|
||||
// 이벤트 핸들러 설정
|
||||
this.eventBindEvents();
|
||||
|
||||
this.grid.instance.readData(${param.page eq null or param.page eq 0 ? 1 : param.page});
|
||||
}
|
||||
};
|
||||
|
||||
// 팝업 콜백 함수 (팝업에서 호출)
|
||||
window.refreshCrdnList = function() {
|
||||
ExmnrList.refreshList();
|
||||
};
|
||||
|
||||
// DOM 준비 완료 시 초기화
|
||||
$(document).ready(function() {
|
||||
ExmnrList.init();
|
||||
});
|
||||
|
||||
})(window, jQuery);
|
||||
</script>
|
||||
@ -0,0 +1,159 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="dateUtil" uri="http://egovframework.go.kr/functions/date-util" %>
|
||||
|
||||
<div class="popup_wrap">
|
||||
<div class="popup_inner">
|
||||
<div class="popup_tit">
|
||||
<h2 class="tit">조사원 관리</h2>
|
||||
<a href="#" class="pop-x-btn modalclose"></a>
|
||||
</div>
|
||||
<div class="popup_con">
|
||||
<div class="forms_table_non">
|
||||
<form id="crdnForm" name="crdnForm">
|
||||
<input type="hidden" id="mode" name="mode" value="${param.mode}" />
|
||||
<table>
|
||||
<colgroup>
|
||||
<col style="width: 20%;" />
|
||||
<col style="width: 30%;" />
|
||||
<col style="width: 20%;" />
|
||||
<col style="width: 30%;"/>
|
||||
</colgroup>
|
||||
<tr>
|
||||
<th class="th">조사원 ID</th>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${param.mode eq 'C'}">
|
||||
자동채번
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<input type="text" id="exmnrId" name="exmnrId" class="input"
|
||||
value="${data.exmnrId}" readonly/>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="th">조사원</th>
|
||||
<td colspan="3">
|
||||
<input type="text" id="exmnr" name="exmnr" class="input"
|
||||
value="${data.exmnr}" maxlength="100" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="popup_foot">
|
||||
<c:choose>
|
||||
<c:when test="${param.mode eq 'V'}">
|
||||
<a href="#" id="btnDelete" class="newbtns bg2">삭제</a>
|
||||
<a href="#" id="btnSave" class="newbtns bg4">수정</a>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<a href="#" id="btnSave" class="newbtns bg4">저장</a>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
<a href="#" class="newbtns bg1 modalclose">닫기</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
var CrdnPopup = {
|
||||
// 자식 팝업창 참조 저장 배열
|
||||
childPopups: [],
|
||||
|
||||
init: function() {
|
||||
this.bindEvents();
|
||||
},
|
||||
|
||||
bindEvents: function() {
|
||||
var self = this;
|
||||
|
||||
$("#btnSave").on('click', function() {
|
||||
self.save();
|
||||
});
|
||||
|
||||
$("#btnDelete").on('click', function() {
|
||||
self.delete();
|
||||
});
|
||||
|
||||
// 닫기 버튼
|
||||
$('.modalclose').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
self.cancel();
|
||||
});
|
||||
|
||||
//$("#dsclYmd").datepicker({
|
||||
// container: '.popup_inner',
|
||||
// language: "kr"
|
||||
//});
|
||||
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
// 공통 함수를 사용하여 자식 팝업창들을 닫고 현재 창 닫기
|
||||
this.childPopups = closeChildPopupsAndSelf(this.childPopups);
|
||||
},
|
||||
|
||||
save: function() {
|
||||
|
||||
var mode = $("#mode").val();
|
||||
var url = mode === 'C' ? '/exmnr/insert.ajax' : '/exmnr/update.ajax';
|
||||
var data = $("#crdnForm").serialize();
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
alert(response.message || '처리되었습니다.');
|
||||
if (window.opener && window.opener.refreshCrdnList) {
|
||||
window.opener.refreshCrdnList();
|
||||
}
|
||||
window.close();
|
||||
} else {
|
||||
alert(response.message || '처리 중 오류가 발생했습니다.');
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
delete: function() {
|
||||
if (!confirm('정말 삭제하시겠습니까?')) return;
|
||||
|
||||
var exmnrId = $("#exmnrId").val();
|
||||
|
||||
$.ajax({
|
||||
url: '/exmnr/delete.ajax',
|
||||
type: 'POST',
|
||||
data: { exmnrId: exmnrId },
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
alert(response.message || '삭제되었습니다.');
|
||||
if (window.opener && window.opener.refreshCrdnList) {
|
||||
window.opener.refreshCrdnList();
|
||||
}
|
||||
window.close();
|
||||
} else {
|
||||
alert(response.message || '삭제 중 오류가 발생했습니다.');
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
CrdnPopup.init();
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
Loading…
Reference in New Issue