123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- 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(
- @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;
- }
-
- @RequestMapping( "/new" )
- public ModelAndView newCooperation() {
- ModelAndView mv = setMV( "cooperation/new" );
-
- return mv;
- }
-
- @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);
-
- 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(@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(@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(
- @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) {
-
- boolean result = false;
- if (!cooperativeCode.equals("") && !cooperativeCodeTemp.equals("")) {
- if (cooperativeCode.equals(cooperativeCodeTemp)) {
- return true;
- }
- }
-
- if( cooperativeCode.trim().equals( "" ) ) {
- result = false;
- } else {
- int count = service.duplicateCheck(cooperativeCode);
-
- if( count == 0 ) {
- result = true;
- }
- }
-
- return result;
- }
- }
|