|
@@ -1,18 +1,81 @@
|
|
|
package com.lemon.lifecenter.controller;
|
|
|
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
+import com.lemon.lifecenter.common.LifeCenterConfigVO;
|
|
|
import com.lemon.lifecenter.common.LifeCenterController;
|
|
|
+import com.lemon.lifecenter.common.LifeCenterFunction;
|
|
|
+import com.lemon.lifecenter.common.LifeCenterPaging;
|
|
|
+import com.lemon.lifecenter.common.LifeCenterSessionController;
|
|
|
+import com.lemon.lifecenter.dto.CooperationDTO;
|
|
|
+import com.lemon.lifecenter.service.CooperationService;
|
|
|
|
|
|
@Controller
|
|
|
@RequestMapping("/cooperation")
|
|
|
public class CooperationController extends LifeCenterController {
|
|
|
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CooperationService service;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LifeCenterConfigVO config;
|
|
|
+ private LifeCenterPaging paging;
|
|
|
|
|
|
@RequestMapping( "/list" )
|
|
|
- public ModelAndView list() {
|
|
|
+ public ModelAndView list(
|
|
|
+ @ModelAttribute("dto") final CooperationDTO dto,
|
|
|
+ @RequestParam(value="page", required=false, defaultValue="1") int page,
|
|
|
+ @RequestParam(value="useYn", required=false, defaultValue="") String useYn,
|
|
|
+ @RequestParam(value="sData", required=false, defaultValue="") String sData,
|
|
|
+ @RequestParam(value="selectState", required=false, defaultValue="") String selectState) {
|
|
|
+
|
|
|
+ dto.setLimit( ( Integer.valueOf( page ) - 1 ) * config.pageDataSize );
|
|
|
+ dto.setLimitMax( config.pageDataSize );
|
|
|
+
|
|
|
+ dto.setUseYn(useYn);
|
|
|
+ if (selectState.equals("sCode")) {
|
|
|
+ dto.setCooperativeCode(sData);
|
|
|
+ } else if (selectState.equals("sName")) {
|
|
|
+ dto.setCooperativeName(sData);
|
|
|
+ }
|
|
|
+
|
|
|
+ int total = service.selectCooperationTotal(dto);
|
|
|
+ List<CooperationDTO> list = new ArrayList<CooperationDTO>();
|
|
|
+ if (total > 0) {
|
|
|
+ list = service.selectCooperationList(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ String param = "selectState="+selectState+"&sData="+sData+"&useYn="+useYn;
|
|
|
+ paging = LifeCenterPaging.getInstance();
|
|
|
+ paging.paging(config, total, page, param);
|
|
|
+
|
|
|
+
|
|
|
ModelAndView mv = setMV( "cooperation/list" );
|
|
|
+ mv.addObject("total", total);
|
|
|
+ mv.addObject("list", list);
|
|
|
+ mv.addObject("paging", paging);
|
|
|
+ mv.addObject("page", page);
|
|
|
+ mv.addObject("pageSize", dto.getLimitMax());
|
|
|
+ mv.addObject("selectState", selectState);
|
|
|
+ mv.addObject("sData", sData);
|
|
|
+ mv.addObject("useYn", useYn);
|
|
|
|
|
|
return mv;
|
|
|
}
|
|
@@ -24,30 +87,93 @@ public class CooperationController extends LifeCenterController {
|
|
|
return mv;
|
|
|
}
|
|
|
|
|
|
- @RequestMapping( "/new/insert" )
|
|
|
- public String insertCooperation() {
|
|
|
+ @RequestMapping( value = "/new/insert", method = RequestMethod.POST)
|
|
|
+ public String insertCooperation(
|
|
|
+ @ModelAttribute("dto") final CooperationDTO dto,
|
|
|
+ HttpServletRequest request,HttpServletResponse response) {
|
|
|
+ String sesId = LifeCenterSessionController.getSession( request, "sesId" );
|
|
|
+ dto.setCreateBy(sesId);
|
|
|
+
|
|
|
+ service.insertCooperation(dto);
|
|
|
|
|
|
- return "redirect:/cooperation/list";
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '협력병원이 등록되었습니다.', callBack : function(){ location.href='/cooperation/info?cooperativeCode="+dto.getCooperativeCode()+"'; } });" );
|
|
|
+ return "/common/blank";
|
|
|
+
|
|
|
+ //return "redirect:/cooperation/info?cooperativeCode="+dto.getCooperativeCode();
|
|
|
}
|
|
|
|
|
|
@RequestMapping( "/info" )
|
|
|
- public ModelAndView info() {
|
|
|
- ModelAndView mv = setMV( "cooperation/info" );
|
|
|
+ public ModelAndView info(@RequestParam(value="cooperativeCode", required=false, defaultValue="" ) String cooperativeCode) {
|
|
|
+
|
|
|
+ int cnt = service.selectCooperationInfoOneCount(cooperativeCode);
|
|
|
|
|
|
+ if (cnt == 0) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ CooperationDTO dto = new CooperationDTO();
|
|
|
+ dto = service.selectCooperationInfoOne(cooperativeCode);
|
|
|
+ ModelAndView mv = setMV( "cooperation/info" );
|
|
|
+ mv.addObject("info", dto);
|
|
|
return mv;
|
|
|
}
|
|
|
|
|
|
|
|
|
@RequestMapping( "/edit" )
|
|
|
- public ModelAndView edit() {
|
|
|
- ModelAndView mv = setMV( "cooperation/edit" );
|
|
|
+ public ModelAndView edit(@RequestParam(value="cooperativeCode", required=false, defaultValue="" ) String cooperativeCode) {
|
|
|
+ int cnt = service.selectCooperationInfoOneCount(cooperativeCode);
|
|
|
|
|
|
+ if (cnt == 0) {
|
|
|
+
|
|
|
+ }
|
|
|
+ CooperationDTO dto = new CooperationDTO();
|
|
|
+ dto = service.selectCooperationInfoOne(cooperativeCode);
|
|
|
+ ModelAndView mv = setMV( "cooperation/edit" );
|
|
|
+ mv.addObject("info", dto);
|
|
|
return mv;
|
|
|
}
|
|
|
|
|
|
@RequestMapping( "/edit/update" )
|
|
|
- public String updateCooperation() {
|
|
|
+ public String updateCooperation(
|
|
|
+ @ModelAttribute("dto") final CooperationDTO dto,
|
|
|
+ HttpServletRequest request,HttpServletResponse response) {
|
|
|
+ String sesId = LifeCenterSessionController.getSession( request, "sesId" );
|
|
|
+ dto.setUpdateBy(sesId);
|
|
|
+
|
|
|
+ service.updateCooperationInfo(dto);
|
|
|
+ LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '협력병원 정보가 수정되었습니다.', callBack : function(){ location.href='/cooperation/info?cooperativeCode="+dto.getCooperativeCode()+"'; } });" );
|
|
|
+ return "/common/blank";
|
|
|
+ //return "redirect:/cooperation/info?cooperativeCode="+dto.getCooperativeCode();
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping( value="/duplicateCheck", method = RequestMethod.POST )
|
|
|
+ @ResponseBody
|
|
|
+ public boolean duplicateCheck(
|
|
|
+ @RequestParam(value="cooperativeCode", required=false, defaultValue="" ) String cooperativeCode,
|
|
|
+ @RequestParam(value="cooperativeCodeTemp", required=false, defaultValue="" ) String cooperativeCodeTemp) {
|
|
|
+
|
|
|
+ logger.error("cooperationCode -- > " + cooperativeCode);
|
|
|
+ logger.error("cooperationCodeTemp -- > " + cooperativeCodeTemp);
|
|
|
+
|
|
|
+ boolean result = false;
|
|
|
+ if (!cooperativeCode.equals("") && !cooperativeCodeTemp.equals("")) {
|
|
|
+ if (cooperativeCode.equals(cooperativeCodeTemp)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- return "redirect:/cooperation/edit";
|
|
|
+ if( cooperativeCode.trim().equals( "" ) ) {
|
|
|
+ result = false;
|
|
|
+ } else {
|
|
|
+
|
|
|
+ int count = service.duplicateCheck(cooperativeCode);
|
|
|
+
|
|
|
+ if( count == 0 ) {
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
}
|