refactor: java package

JSP refactor-package
          URL PATH reafactor
main
minuk926 2 years ago
parent 621f791801
commit 3e88b14d2a

@ -2,6 +2,7 @@ package kr.xit.framework.biz.mng.menu.web;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -23,6 +24,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.core.JsonProcessingException;
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo; import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
import kr.xit.framework.biz.mng.menu.model.ProgramMngSearchVO; import kr.xit.framework.biz.mng.menu.model.ProgramMngSearchVO;
import kr.xit.framework.biz.mng.menu.model.ProgramMngVO; import kr.xit.framework.biz.mng.menu.model.ProgramMngVO;
@ -38,7 +41,10 @@ import kr.xit.framework.support.mybatis.MybatisUtils;
import kr.xit.framework.support.util.AjaxMessageMapRenderer; import kr.xit.framework.support.util.AjaxMessageMapRenderer;
import kr.xit.framework.support.util.AjaxUtils; import kr.xit.framework.support.util.AjaxUtils;
import kr.xit.framework.support.util.Checks; import kr.xit.framework.support.util.Checks;
import kr.xit.framework.support.util.JsonUtil;
import kr.xit.framework.support.util.ValidationError;
import kr.xit.framework.support.util.constants.MessageKey; import kr.xit.framework.support.util.constants.MessageKey;
import kr.xit.framework.support.util.model.FieldErrorDtl;
/** /**
* *
@ -124,11 +130,10 @@ public class ProgramMngController {
ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW); ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW);
//유효성 확인 //유효성 확인
beanValidator.validate(progrmMngVO, bindingResult); beanValidator.validate("progrmMngVO", progrmMngVO, bindingResult);
// beanValidator.validate("progrmMngVO", vo, bindingResult);
if (bindingResult.hasErrors()) { if (bindingResult.hasErrors()) {
throw BizRuntimeException.create(MessageKey.CMM_INSERT_FAIL); List<FieldErrorDtl> dtls = ValidationError.errorList(bindingResult.getFieldErrors());
throw BizRuntimeException.create("errors.required", new Object[]{dtls.get(0).getMessage()});
} }
programMngService.addProgram(progrmMngVO); programMngService.addProgram(progrmMngVO);

@ -5,6 +5,7 @@ import javax.annotation.Resource;
import org.springframework.context.support.MessageSourceAccessor; import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import kr.xit.framework.support.util.Checks;
import kr.xit.framework.support.util.JBeanRegistry; import kr.xit.framework.support.util.JBeanRegistry;
/** /**
@ -58,7 +59,8 @@ public class BizRuntimeException extends RuntimeException {
BizRuntimeException ex = new BizRuntimeException(); BizRuntimeException ex = new BizRuntimeException();
ex.setCode(errorCode); ex.setCode(errorCode);
ex.setMessage(JBeanRegistry.getMessageSourceAccessor().getMessage(errorCode)); if(Checks.isNotEmpty(arguments)) ex.setMessage(JBeanRegistry.getMessageSourceAccessor().getMessage(errorCode, arguments));
else ex.setMessage(JBeanRegistry.getMessageSourceAccessor().getMessage(errorCode));
ex.setArguments(arguments); ex.setArguments(arguments);
return ex; return ex;
} }

@ -3,8 +3,12 @@ package kr.xit.framework.support.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.context.MessageSource;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError; import org.springframework.validation.FieldError;
@ -13,6 +17,7 @@ import org.springframework.web.servlet.ModelAndView;
import kr.xit.framework.support.exception.BizRuntimeException; import kr.xit.framework.support.exception.BizRuntimeException;
import kr.xit.framework.support.util.constants.MessageGroupKey; import kr.xit.framework.support.util.constants.MessageGroupKey;
import kr.xit.framework.support.util.constants.MessageKey; import kr.xit.framework.support.util.constants.MessageKey;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import kr.xit.framework.support.util.constants.Globals; import kr.xit.framework.support.util.constants.Globals;
@ -281,4 +286,5 @@ public abstract class AjaxMessageMapRenderer {
return message; return message;
} }
} }
} }

@ -0,0 +1,38 @@
package kr.xit.framework.support.util;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.validation.Errors;
import org.springframework.validation.FieldError;
import kr.xit.framework.support.util.model.FieldErrorDtl;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
public class ValidationError {
private List<FieldErrorDtl> errors;
public static ValidationError create(List<FieldError> errors){
List<FieldErrorDtl> dtls = errors.stream()
.map(FieldErrorDtl::create)
.collect(Collectors.toList());
return new ValidationError(dtls);
}
public static List<FieldErrorDtl> errorList(List<FieldError> errors){
return errors.stream()
.map(FieldErrorDtl::create)
.collect(Collectors.toList());
}
public static String errorMessage(List<FieldError> errors){
FieldError error = errors.get(0);
}
}

@ -0,0 +1,37 @@
package kr.xit.framework.support.util.model;
import java.util.Locale;
import org.springframework.context.MessageSource;
import org.springframework.validation.FieldError;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
/**
* Validation format
*/
@Getter
@Setter
@AllArgsConstructor
public class FieldErrorDtl {
private String field;
private String code;
//private Object rejectedValue;
private String message;
public static FieldErrorDtl create(FieldError fieldError) {
return new FieldErrorDtl(
fieldError.getField(),
fieldError.getCode(),
//fieldError.getRejectedValue(),
String.valueOf(fieldError.getArguments()[0])
//fieldError.getDefaultMessage()
);
}
}

@ -21,18 +21,18 @@
<table> <table>
<caption>검색조건</caption> <caption>검색조건</caption>
<colgroup> <colgroup>
<col style="width: 15%;"/> <col style="width: 15%">
<col style="width: 20%;"/> <col style="width: 20%;">
<col style="width: 8%;"/> <col style="width: 8%;">
<col style="width: ;"/> <col>
<col style="width: 8%;"/> <col style="width: 8%;">
<col style="width: ;"/> <col>
<col style="width: 7%;"/> <col style="width: 7%;">
</colgroup> </colgroup>
<tbody> <tbody>
<th>프로그램 한글명</th> <th>프로그램 한글명</th>
<td> <td>
<input name="searchKeyword" id="searchKeyword" type="text" size="60" value="<c:out value='${searchVO.searchKeyword}'/>" maxlength="60" title="검색조건"> <input name="searchKeyword" id="searchKeyword" type="text" size="60" value="<c:out value='${searchKeyword}'/>" maxlength="60" title="검색조건">
</td> </td>
<td colspan="6"> <td colspan="6">
<input type="button" id="btnSearch" class="btn_search" title="검색" value="검색" /> <input type="button" id="btnSearch" class="btn_search" title="검색" value="검색" />

@ -18,9 +18,14 @@
<p class="pop_title"> 프로그램 상세조회 /수정</p> <p class="pop_title"> 프로그램 상세조회 /수정</p>
<table class="tbl03"> <table class="tbl03">
<caption>프로그램 상세조회 /수정</caption> <caption>프로그램 상세조회 /수정</caption>
<colgroup>
<col style="width: 20%; height: 23px;">
<col style="width: 80%; height: 23px;">
</colgroup>
<tbody>
<tr> <tr>
<th width="20%" height="23" class="required" scope="row"><label for="progrmFileNm">프로그램파일명</label> <th scope="row" class="required"><label for="progrmFileNm">프로그램파일명</label>
<td width="80%" nowrap="nowrap"> <td nowrap="nowrap">
<c:choose> <c:choose>
<c:when test="${!empty progrmMngVO.progrmFileNm and fn:length(progrmMngVO.progrmFileNm) > 0}"> <c:when test="${!empty progrmMngVO.progrmFileNm and fn:length(progrmMngVO.progrmFileNm) > 0}">
<input type="text" id='progrmFileNm' name='progrmFileNm' disabled="disabled" value="<c:out value='${progrmMngVO.progrmFileNm}'/>"> <input type="text" id='progrmFileNm' name='progrmFileNm' disabled="disabled" value="<c:out value='${progrmMngVO.progrmFileNm}'/>">
@ -29,40 +34,39 @@
<input type="text" id='progrmFileNm' name='progrmFileNm' value="<c:out value='${progrmMngVO.progrmFileNm}'/>"> <input type="text" id='progrmFileNm' name='progrmFileNm' value="<c:out value='${progrmMngVO.progrmFileNm}'/>">
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
<form:input path="progrmFileNm" size="50" maxlength="50" title="프로그램파일명" cssStyle="display:none" /> <form:input path="progrmFileNm" size="50" maxlength="50" title="프로그램파일명" cssStyle="display:none" />
<form:errors path="progrmFileNm"/> <form:errors path="progrmFileNm"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th width="20%" height="23" class="required" scope="row"><label for="progrmStrePath">저장경로</label> <th class="required" scope="row"><label for="progrmStrePath">저장경로</label>
<td width="80%" nowrap="nowrap"> <td nowrap="nowrap">
<form:input path="progrmStrePath" size="50" maxlength="50" title="저장경로" disabled="disabled"/> <form:input path="progrmStrePath" size="50" maxlength="50" title="저장경로" disabled="disabled"/>
<form:errors path="progrmStrePath"/> <form:errors path="progrmStrePath"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th width="20%" height="23" class="required" scope="row"><label for="progrmKoreanNm">프로그램 한글명</label> <th class="required" scope="row"><label for="progrmKoreanNm">프로그램 한글명</label>
<td width="80%" nowrap="nowrap"> <td nowrap="nowrap">
<form:input path="progrmKoreanNm" size="60" maxlength="50" title="프로그램 한글명"/> <form:input path="progrmKoreanNm" size="60" maxlength="50" title="프로그램 한글명"/>
<form:errors path="progrmKoreanNm" /> <form:errors path="progrmKoreanNm" />
</td> </td>
</tr> </tr>
<tr> <tr>
<th width="20%" height="23" class="required" scope="row"><label for="URL">URL</label> <th class="required" scope="row"><label for="URL">URL</label>
<td width="80%" nowrap="nowrap"> <td nowrap="nowrap">
<form:input path="URL" size="100" maxlength="100" title="URL" /> <form:input path="URL" size="100" maxlength="100" title="URL" />
<form:errors path="URL" /> <form:errors path="URL" />
</td> </td>
</tr> </tr>
<tr> <tr>
<th height="23" class="required" scope="row"><label for="progrmDc">프로그램설명</label></th> <th class="required" scope="row"><label for="progrmDc">프로그램설명</label></th>
<td> <td>
<form:textarea path="progrmDc" rows="14" cols="75" title="프로그램설명"/> <form:textarea path="progrmDc" rows="14" cols="75" title="프로그램설명"/>
<form:errors path="progrmDc"/> <form:errors path="progrmDc"/>
</td> </td>
</tr> </tr>
</tbody>
</table> </table>
<div class="popup_btn"> <div class="popup_btn">
<span class="flr" colspan="4"> <span class="flr" colspan="4">
@ -79,15 +83,12 @@
</span> </span>
</div> </div>
<!-- //등록버튼 --> <!-- //등록버튼 -->
</div> </div>
</div> </div>
<!-- //popup --> <!-- //popup -->
</form:form> </form:form>
<script type="text/javaScript" language="javascript"> <script type="text/javaScript" language="javascript">
/* ******************************* /* *******************************
* 프로그램 목록관리 수정화면 Functions * 프로그램 목록관리 수정화면 Functions
******************************* */ ******************************* */
@ -107,8 +108,8 @@
======================== */ ======================== */
addProgram : function(){ addProgram : function(){
if(!validateProgrmMngVO(document.getElementById("progrmMngVO"))) if(!validateProgrmMngVO(document.getElementById("progrmMngVO")))
return; //return;
;
var varFrom = document.getElementById("progrmMngVO"); var varFrom = document.getElementById("progrmMngVO");
if(confirm("저장 하시겠습니까?")){ if(confirm("저장 하시겠습니까?")){
var param = $(varFrom).serialize(); var param = $(varFrom).serialize();

Loading…
Cancel
Save