package nlib.col.web; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import nlib.cmm.NlibCommonController; import nlib.cmm.service.CodeService; import nlib.cmm.service.NlibProperty; import nlib.col.service.CollectionService; import nlib.col.service.CollectionVO; import nlib.col.service.RentService; import nlib.restful.service.DataApiReqVO; import nlib.restful.service.DataApiResVO; import nlib.restful.service.DataApiVO; import nlib.util.StringUtil; /** *
 * @Class Name : RentController.java
 * 
 * @Description : 대출 Controller
 * 
 * 
 * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
 *
 * 
* * @ ------------ -------- --------------------------- * @ 수정일 수정자 수정내용 * @ ------------ -------- --------------------------- * @ 2021. 7. 21. JSYOO 최초 생성 * @ 2021.10. 14. KNKIM 대출목록 API방식 변경 및 화면설계서 적용 개발 * * * @author 이씨플라자 * DIGITALSHIP JSYOO * @since 2021. 7. 21. * @version 1.0 * */ @Controller public class RentController extends NlibCommonController { private static final Logger log = LoggerFactory.getLogger(RentController.class); static final String DEFUALT_PAGE_SIZE = NlibProperty.getProperty("list.paging.page.size"); @Resource(name = "rentService") private RentService rentService; @Resource(name = "collectionService") private CollectionService collectionService; @Resource(name = "codeService") private CodeService codeService; /** * 대출 목록 화면을 호출한다. * * @param request * @param searchVO * @param model * @param message * @return * @throws Exception */ @RequestMapping("/rent/listRentItems.do") public String listRentItems(HttpServletRequest request, CollectionVO searchVO, ModelMap model, String message) throws Exception { String mbInfoId = getMbInfoId(request); if(StringUtil.isEmpty(mbInfoId)) { message = "로그인하신 후, 이용바랍니다."; model.addAttribute("message", message); return "nlib/rent/listRentItems"; } // 대출자료 문화원 목록 조회 List> rentMngOrgList = rentService.listRentMngOrg(mbInfoId); model.addAttribute("rentMngOrgList" , rentMngOrgList); model.addAttribute("bookLtRvStatusCd", searchVO.getBookLtRvStatusCd()); model.addAttribute("pageSize" , searchVO.getPageSize()); model.addAttribute("pageSize" , searchVO.getPageSize()); model.addAttribute("pageIndex" , searchVO.getPageIndex()); model.addAttribute("message" , message); return "nlib/rent/listRentItems"; } /** * 대출 목록을 조회한다. * * @param req * @return */ @RequestMapping(value="/rent/listRentItemsAjax.do") public ResponseEntity listRentItemsAjax( HttpServletRequest request, @RequestBody CollectionVO searchVO) { String message = null; String mbInfoId = getMbInfoId(request); if(StringUtil.isEmpty(mbInfoId)) { message = "로그인하신 후, 이용바랍니다."; } //------------------------------- // JSON변환 응답 처리 //------------------------------- // JS-GRID 페이징 처리를 포함한 응답값 처리 // {data: [{...}], // itemsCount: 255 // } HashMap retMap = new HashMap(); if(StringUtil.isNotEmpty(mbInfoId)) { // 로그인 사용자 정보 설정 searchVO.setMbInfoId(mbInfoId); // TO-DO : DDDDDDDDDDDDDDDDDDDddd // 기본값은 전체이나, API 반영전까지 문화원 코드 전송 // if(StringUtil.isEmpty(searchVO.getMngOrgCd())) searchVO.setMngOrgCd(getCurCouncilCd(request)); searchVO.setMngOrgCd("KCCF"); // 조회 // 대출상태구분코드("": 전체, A:신청, B:대출준비완료, C:취소, W:대출중, R0:정상반납, R1:연체반납, P:연체) // TO-DO : api 코드 변경 요청. 변경 처리된 것 확인할 것 DataApiResVO resVO = rentService.listRentItems(searchVO); retMap.put("data" , resVO.getRecordList()); retMap.put("itemsCount", resVO.getRecordTotCount()); retMap.put("pageIndex" , resVO.getPageIndex()); } else { retMap.put("message" , "로그인하신 후, 이용바랍니다."); } return makeResponseEntityJson(retMap); } @RequestMapping(value={"/rent/confirmRentFromCart.do", "/rent/confirmRent.do"}) public String confirmRent(HttpServletRequest request, CollectionVO rentVO, ModelMap model) throws Exception { boolean fromCart = request.getServletPath().contains("Cart.do"); String mbInfoId = getMbInfoId(request); if(StringUtil.isEmpty(mbInfoId)) { model.addAttribute("message", "로그인 후, 이용해 주시기 바랍니다."); return "nlib/rent/confirmRent"; } if(rentVO == null || StringUtil.isEmpty(rentVO.getSelItems())) { model.addAttribute("message", "대출(예약)신청할 정보가 없습니다."); return "nlib/rent/confirmRent"; } String selItems = rentVO.getSelItems(); List list = collectionService.makeInfoListOfCollectionVO(selItems, mbInfoId, NlibProperty.getString("thumbnail.image.url.small")); model.addAttribute("rentVO", rentVO); model.addAttribute("list", list); if(fromCart) model.addAttribute("fromCart", fromCart ? "Y" : "N"); return "nlib/rent/confirmRent"; } @RequestMapping(value={"/rent/insertRentItemsFromCart.do", "/rent/insertRentItems.do"}) public String insertRentItems(HttpServletRequest request, CollectionVO rentVO, ModelMap model) throws Exception { boolean fromCart = request.getServletPath().contains("Cart.do"); String retJsp = "nlib/rent/insertRentItems"; String mbInfoId = getMbInfoId(request); if(StringUtil.isEmpty(mbInfoId)) { model.addAttribute("message", "로그인 후, 이용해 주시기 바랍니다."); return retJsp; } if(rentVO == null || StringUtil.isEmpty(rentVO.getSelItems())) { model.addAttribute("message", "대출(예약)신청할 정보가 없습니다."); return retJsp; } if(StringUtil.isEmpty(rentVO.getMngOrgCd())) { model.addAttribute("message", "관리문화원 정보가 없습니다."); return retJsp; } String selItems = rentVO.getSelItems(); List list = collectionService.makeListOfCollectionVO(selItems); // 임시 막음 DDDDDDDDDDDDDDDDDDDDDDDdd //list = rentService.insertRentItems(list, mbInfoId, rentVO.getMngOrgCd()); list = collectionService.setDetailInfoForList(list, mbInfoId, NlibProperty.getString("thumbnail.image.url.small")); model.addAttribute("rentVO", rentVO); model.addAttribute("list", list); if(fromCart) model.addAttribute("fromCart", fromCart ? "Y" : "N"); return retJsp; } // // // /** 대출 목록 화면을 호출한다. // * @param req // * @return // */ // @RequestMapping("/rent/listCanceledRentItems.do") // public String listCanceledRentItems(HttpServletRequest req, Authentication authentication, @RequestParam Map paramMap, ModelMap model) throws Exception { // String searchKeyword = paramMap.get("searchKeyword"); // String pageIndex = StringUtil.getString(paramMap.get("pageIndex"), "1"); // String pageSize = StringUtil.getString(paramMap.get("pageSize") , DEFUALT_PAGE_SIZE); // // // 페이징 사이즈 코드 목록 조회 (DB방식으로 변경 2021.08.06 KNKIM) // List> pageSizeCodes = codeService.listCodes("PAGE_SIZE_OPTION"); // // // 반환 정보 // model.addAttribute("pageIndex" , pageIndex); // model.addAttribute("pageSize" , pageSize); // model.addAttribute("searchKeyword", searchKeyword); // model.addAttribute("pageSizeCodes", pageSizeCodes); // return "nlib/rent/listCanceledRentItems"; // } // // /** // * 대출 취소 목록을 조회한다. // * // * @param req // * @return // */ // @RequestMapping(value="/rent/listCanceledRentItemsAjax.do") // public ResponseEntity listCanceledRentItemsAjax(HttpServletRequest req, // Authentication authentication, @RequestBody Map paramMap) { // // String searchKeyword = paramMap.get("searchKeyword"); // String pageIndex = StringUtil.getString(paramMap.get("pageIndex"), "1"); // String pageSize = StringUtil.getString(paramMap.get("pageSize") , DEFUALT_PAGE_SIZE); // // //------------------------------- // // REQ VO 구성 // //------------------------------- // DataApiReqVO reqVO = new DataApiReqVO(); // reqVO.setPageIndex(pageIndex); // reqVO.setPageSize(pageSize); // reqVO.putInfoItem("searchKeyword", searchKeyword); // // // 요청 // DataApiResVO resVO = rentService.listCanceledRentItems(reqVO); // // //------------------------------- // // JSON변환 응답 처리 // //------------------------------- // // JS-GRID 페이징 처리를 포함한 응답값 처리 // // {data: [{...}], // // itemsCount: 255 // // } // HashMap retMap = new HashMap(); // retMap.put("data", resVO.getList(DataApiVO.XML_EL_NAME_RECORD)); // retMap.put("itemsCount", resVO.getRecordTotCount()); // // return makeResponseEntityJson(retMap); // } // // /** 반납 연기 화면을 호출한다. // * @param req // * @return // */ // @RequestMapping("/rent/listPostpones.do") // public String listPostpones(HttpServletRequest req, Authentication authentication, @RequestParam Map paramMap, ModelMap model) throws Exception { // String searchKeyword = paramMap.get("searchKeyword"); // String pageIndex = StringUtil.getString(paramMap.get("pageIndex"), "1"); // String pageSize = StringUtil.getString(paramMap.get("pageSize") , DEFUALT_PAGE_SIZE); // // // 페이징 사이즈 코드 목록 조회 (DB방식으로 변경 2021.08.06 KNKIM) // List> pageSizeCodes = codeService.listCodes("PAGE_SIZE_OPTION"); // // // 반환 정보 // model.addAttribute("pageIndex" , pageIndex); // model.addAttribute("pageSize" , pageSize); // model.addAttribute("searchKeyword", searchKeyword); // model.addAttribute("pageSizeCodes", pageSizeCodes); // return "nlib/rent/listPostpones"; // } // // /** // * 반납 연기 목록을 조회한다. // * // * @param req // * @return // */ // @RequestMapping(value="/rent/listPostponesAjax.do") // public ResponseEntity listPostponesAjax(HttpServletRequest req, // Authentication authentication, @RequestBody Map paramMap) { // // String searchKeyword = paramMap.get("searchKeyword"); // String pageIndex = StringUtil.getString(paramMap.get("pageIndex"), "1"); // String pageSize = StringUtil.getString(paramMap.get("pageSize") , DEFUALT_PAGE_SIZE); // // //------------------------------- // // REQ VO 구성 // //------------------------------- // DataApiReqVO reqVO = new DataApiReqVO(); // reqVO.setPageIndex(pageIndex); // reqVO.setPageSize(pageSize); // reqVO.putInfoItem("searchKeyword", searchKeyword); // // // 요청 // DataApiResVO resVO = rentService.listPostpones(reqVO); // // //------------------------------- // // JSON변환 응답 처리 // //------------------------------- // // JS-GRID 페이징 처리를 포함한 응답값 처리 // // {data: [{...}], // // itemsCount: 255 // // } // HashMap retMap = new HashMap(); // retMap.put("data", resVO.getList(DataApiVO.XML_EL_NAME_RECORD)); // retMap.put("itemsCount", resVO.getRecordTotCount()); // // return makeResponseEntityJson(retMap); // } // // public ModelMap listCanceledRentItems(HttpServletRequest req) { // return null; // } // // /** 대출 예약 화면을 호출한다. // * @param req // * @return // */ // @RequestMapping("/rent/listReservations.do") // public String listReservations(HttpServletRequest req, Authentication authentication, @RequestParam Map paramMap, ModelMap model) throws Exception { // String searchKeyword = paramMap.get("searchKeyword"); // String pageIndex = StringUtil.getString(paramMap.get("pageIndex"), "1"); // String pageSize = StringUtil.getString(paramMap.get("pageSize") , DEFUALT_PAGE_SIZE); // // // 페이징 사이즈 코드 목록 조회 (DB방식으로 변경 2021.08.06 KNKIM) // List> pageSizeCodes = codeService.listCodes("PAGE_SIZE_OPTION"); // // // 반환 정보 // model.addAttribute("pageIndex" , pageIndex); // model.addAttribute("pageSize" , pageSize); // model.addAttribute("searchKeyword", searchKeyword); // model.addAttribute("pageSizeCodes", pageSizeCodes); // return "nlib/rent/listReservations"; // } // // /** // * 대출 예약 목록을 조회한다. // * // * @param req // * @return // */ // @RequestMapping(value="/rent/listReservationsAjax.do") // public ResponseEntity listReservationsAjax(HttpServletRequest req, // Authentication authentication, @RequestBody Map paramMap) { // // String searchKeyword = paramMap.get("searchKeyword"); // String pageIndex = StringUtil.getString(paramMap.get("pageIndex"), "1"); // String pageSize = StringUtil.getString(paramMap.get("pageSize") , DEFUALT_PAGE_SIZE); // // //------------------------------- // // REQ VO 구성 // //------------------------------- // DataApiReqVO reqVO = new DataApiReqVO(); // reqVO.setPageIndex(pageIndex); // reqVO.setPageSize(pageSize); // reqVO.putInfoItem("searchKeyword", searchKeyword); // // // 요청 // DataApiResVO resVO = rentService.listReservations(reqVO); // // //------------------------------- // // JSON변환 응답 처리 // //------------------------------- // // JS-GRID 페이징 처리를 포함한 응답값 처리 // // {data: [{...}], // // itemsCount: 255 // // } // HashMap retMap = new HashMap(); // retMap.put("data", resVO.getList(DataApiVO.XML_EL_NAME_RECORD)); // retMap.put("itemsCount", resVO.getRecordTotCount()); // // return makeResponseEntityJson(retMap); // } // // public ModelMap cancelReservations(HttpServletRequest req) { // return null; // } // // /** // * 열람 요청 화면을 호출한다. // * // * @param req // * @return // */ // @RequestMapping("/rent/listRequestsForViewingItem.do") // public String listRequestsForViewingItem(HttpServletRequest req, Authentication authentication, @RequestParam Map paramMap, ModelMap model) throws Exception { // String searchKeyword = paramMap.get("searchKeyword"); // String pageIndex = StringUtil.getString(paramMap.get("pageIndex"), "1"); // String pageSize = StringUtil.getString(paramMap.get("pageSize") , DEFUALT_PAGE_SIZE); // // // 페이징 사이즈 코드 목록 조회 (DB방식으로 변경 2021.08.06 KNKIM) // List> pageSizeCodes = codeService.listCodes("PAGE_SIZE_OPTION"); // // // 반환 정보 // model.addAttribute("pageIndex" , pageIndex); // model.addAttribute("pageSize" , pageSize); // model.addAttribute("searchKeyword", searchKeyword); // model.addAttribute("pageSizeCodes", pageSizeCodes); // return "nlib/rent/listRequestsForViewingItem"; // } // // /** // * 열람 요청 목록을 조회한다. // * // * @param req // * @return // */ // @RequestMapping(value="/rent/listRequestsForViewingItemAjax.do") // public ResponseEntity listRequestsForViewingItemAjax(HttpServletRequest req, // Authentication authentication, @RequestBody Map paramMap) { // // String searchKeyword = paramMap.get("searchKeyword"); // String pageIndex = StringUtil.getString(paramMap.get("pageIndex"), "1"); // String pageSize = StringUtil.getString(paramMap.get("pageSize") , DEFUALT_PAGE_SIZE); // // //------------------------------- // // REQ VO 구성 // //------------------------------- // DataApiReqVO reqVO = new DataApiReqVO(); // reqVO.setPageIndex(pageIndex); // reqVO.setPageSize(pageSize); // reqVO.putInfoItem("searchKeyword", searchKeyword); // // // 요청 // DataApiResVO resVO = rentService.listRequestsForViewingItem(reqVO); // // //------------------------------- // // JSON변환 응답 처리 // //------------------------------- // // JS-GRID 페이징 처리를 포함한 응답값 처리 // // {data: [{...}], // // itemsCount: 255 // // } // HashMap retMap = new HashMap(); // retMap.put("data", resVO.getList(DataApiVO.XML_EL_NAME_RECORD)); // retMap.put("itemsCount", resVO.getRecordTotCount()); // // return makeResponseEntityJson(retMap); // } // // /** // * 묻고답하기 상세 내용 조회한다. // * // * @param req // * @return // */ // @RequestMapping("/rent/selectRequestInfoForViewingItem.do") // public String selectRequestInfoForViewingItem(HttpServletRequest req, Authentication authentication, @RequestParam Map paramMap, ModelMap model) { // // // 목록 이동시 전달할 매개변수 // String searchKeyword = paramMap.get("searchKeyword"); // String pageIndex = paramMap.get("pageIndex"); // String pageSize = paramMap.get("pageSize"); // String message = paramMap.get("message"); // // // 게시물 번호 // String articleNo = paramMap.get("articleNo"); // // log.debug("selectRequestInfoForViewingItem > pageIndex = " + pageIndex); // log.debug("selectRequestInfoForViewingItem > pageSize = " + pageSize); // log.debug("selectRequestInfoForViewingItem > searchKeyword = " + searchKeyword); // log.debug("selectRequestInfoForViewingItem > articleNo = " + articleNo); // log.debug("selectRequestInfoForViewingItem > message = " + message); // // //------------------------------- // // REQ VO 구성 // //------------------------------- // DataApiReqVO reqVO = new DataApiReqVO(); // reqVO.setPageIndex(pageIndex); // reqVO.setPageSize(pageSize); // reqVO.putInfoItem("boardNo", "QNA"); // 게시판ID // reqVO.putInfoItem("articleNo", articleNo); // 게시물번호 // // // 요청 // DataApiResVO resVO = rentService.selectRequestInfoForViewingItem(reqVO); // // // 반환 정보 // model.addAttribute("articleNo" , articleNo); // model.addAttribute("article" , resVO.getInfo()); // 게시물 상세 // model.addAttribute("preArticle" , resVO.getList(DataApiVO.XML_EL_NAME_RECORD).get(0)); // 이전글 정보 // model.addAttribute("nextArticle" , resVO.getList(DataApiVO.XML_EL_NAME_RECORD).get(1)); // 다음글 정보 // model.addAttribute("message" , message); // model.addAttribute("pageIndex" , pageIndex); // model.addAttribute("pageSize" , pageSize); // model.addAttribute("searchKeyword", searchKeyword); // // return "nlib/rent/selectRequestInfoForViewingItem"; // } }