/** * Code 입력 폼 * * @param request * @param modelMap * @return */ @RequestMapping("code/code_form") private String codeForm( // @RequestParam(required=false) String codeMgtNo @RequestParam(required = false) String code, ModelMap modelMap) { if (StringUtils.isNotEmpty(code)) { CmtbCodeId cmtbCodeId = new CmtbCodeId(); // cmtbCodeId.setCodeMgtNo(codeMgtNo); cmtbCodeId.setCode(code); CmtbCode cmtbCode = cmtbCodeRepository.findOne(cmtbCodeId); modelMap.put("cmtbCode", cmtbCode); } return "/code/code_form.tiles"; }
/** * 코드 저장/수정 * * @param cmtbCode * @param bindingResult * @param request * @param modelMap * @return * @throws Exception */ @RequestMapping("code/code_insert") private String saveCode( @Valid CmtbCode cmtbCode, @ModelAttribute CmtbCodeId cmtbCodeId, BindingResult bindingResult, HttpServletRequest request, ModelMap modelMap) throws Exception { if (StringUtils.isEmpty(cmtbCodeId.getCode())) { // 신규 저장 // 상위 코드 값이 있으면 max값 확인 // cmtbCodeId.setCodeMgtNo(UUIDUtils.createUUID()); cmtbCode.setUpperCode(StringUtils.defaultIfEmpty(cmtbCode.getUpperCode(), null)); cmtbCode.setCodeSeq(cmtbCodeService.maxCodeSeq(cmtbCode.getUpperCode())); cmtbCodeId.setCode(cmtbCodeService.lpadMaxCodeValue()); } cmtbCode.setCmtbCodeId(cmtbCodeId); cmtbCodeRepository.save(cmtbCode); return "redirect:/code/code_list"; }