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.util.HashMap;
import java.util.List;
import java.util.Map;
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.servlet.ModelAndView;
import com.fasterxml.jackson.core.JsonProcessingException;
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.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.AjaxUtils;
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.model.FieldErrorDtl;
/**
*
@ -124,11 +130,10 @@ public class ProgramMngController {
ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW);
//유효성 확인
beanValidator.validate(progrmMngVO, bindingResult);
// beanValidator.validate("progrmMngVO", vo, bindingResult);
beanValidator.validate("progrmMngVO", progrmMngVO, bindingResult);
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);

@ -5,6 +5,7 @@ import javax.annotation.Resource;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.validation.BindingResult;
import kr.xit.framework.support.util.Checks;
import kr.xit.framework.support.util.JBeanRegistry;
/**
@ -58,7 +59,8 @@ public class BizRuntimeException extends RuntimeException {
BizRuntimeException ex = new BizRuntimeException();
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);
return ex;
}

@ -3,8 +3,12 @@ package kr.xit.framework.support.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
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.validation.BindingResult;
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.util.constants.MessageGroupKey;
import kr.xit.framework.support.util.constants.MessageKey;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import kr.xit.framework.support.util.constants.Globals;
@ -281,4 +286,5 @@ public abstract class AjaxMessageMapRenderer {
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>
<caption>검색조건</caption>
<colgroup>
<col style="width: 15%;"/>
<col style="width: 20%;"/>
<col style="width: 8%;"/>
<col style="width: ;"/>
<col style="width: 8%;"/>
<col style="width: ;"/>
<col style="width: 7%;"/>
<col style="width: 15%">
<col style="width: 20%;">
<col style="width: 8%;">
<col>
<col style="width: 8%;">
<col>
<col style="width: 7%;">
</colgroup>
<tbody>
<th>프로그램 한글명</th>
<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 colspan="6">
<input type="button" id="btnSearch" class="btn_search" title="검색" value="검색" />

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

Loading…
Cancel
Save