265 lines
8.3 KiB
Java
265 lines
8.3 KiB
Java
package com.mca.cmmn.web;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import com.mca.cmmn.service.AreaCodeService;
|
|
import com.mca.cmmn.service.LayersService;
|
|
import com.mca.cmmn.vo.LayersVO;
|
|
import com.mca.map.service.UseRequestService;
|
|
import com.mca.map.vo.UseRequestSearchVO;
|
|
import com.mca.map.vo.UseRequestVO;
|
|
import com.mca.sec.UserUtil;
|
|
import com.mca.sec.vo.LoginUserVO;
|
|
import com.mca.user.service.UserService;
|
|
import com.mca.user.vo.UserVO;
|
|
|
|
import egovframework.rte.fdl.property.EgovPropertyService;
|
|
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
|
|
|
|
@Controller
|
|
@RequestMapping("/map")
|
|
public class MapController {
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(MapController.class);
|
|
|
|
/**
|
|
* properties값을 가져오는 인터페이스.
|
|
**/
|
|
@Resource(name="propertiesService")
|
|
private EgovPropertyService propertiesService;
|
|
|
|
@Resource(name="useRequestService")
|
|
private UseRequestService useRequestService;
|
|
|
|
@Resource(name="areaCodeService")
|
|
private AreaCodeService areaCodeService;
|
|
|
|
@Resource(name="layersService")
|
|
private LayersService layersService;
|
|
|
|
@Resource(name="userService")
|
|
private UserService userService;
|
|
|
|
|
|
/**
|
|
* 지도 사용요청 목록을 반환한다.
|
|
*
|
|
* @param useRequestSearchVO 지도사용요청 검색, 페이지 정보 객체
|
|
* @param request Request 객체
|
|
* @param model 모델 객체
|
|
* @return 지도사용요청 목록 화면
|
|
* @throws
|
|
*/
|
|
@RequestMapping("/request")
|
|
public String reqList(@ModelAttribute("UseRequestSearchVO") UseRequestSearchVO useRequestSearchVO, HttpServletRequest req, Model model) throws Exception {
|
|
|
|
LoginUserVO user = (LoginUserVO) req.getSession().getAttribute("userVO");
|
|
|
|
useRequestSearchVO.setPageUnit(propertiesService.getInt("pageUnit"));
|
|
useRequestSearchVO.setPageSize(propertiesService.getInt("pageSize"));
|
|
useRequestSearchVO.setUserid(user.getUserid());
|
|
|
|
PaginationInfo paginationInfo = new PaginationInfo();
|
|
paginationInfo.setCurrentPageNo(useRequestSearchVO.getPageIndex());
|
|
paginationInfo.setRecordCountPerPage(useRequestSearchVO.getPageUnit());
|
|
paginationInfo.setPageSize(useRequestSearchVO.getPageSize());
|
|
|
|
useRequestSearchVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
|
|
useRequestSearchVO.setLastIndex(paginationInfo.getLastRecordIndex());
|
|
useRequestSearchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
|
|
|
|
List<?> useRequestList = useRequestService.selectUseRequestList(useRequestSearchVO);
|
|
int count = useRequestService.selectUseRequestCnt(useRequestSearchVO);
|
|
|
|
paginationInfo.setTotalRecordCount(count);
|
|
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
model.addAttribute("useRequestList", useRequestList);
|
|
model.addAttribute("useRequestSearchVO", useRequestSearchVO);
|
|
model.addAttribute("count", count);
|
|
|
|
return "map/request";
|
|
}
|
|
|
|
|
|
/**
|
|
* 지도 사용요청 상세화면을 반환한다.
|
|
*
|
|
* @param idx 지도사용요청 Primary Key
|
|
* @param model 모델 객체
|
|
* @return 지도사용요청 상세 화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping("/request/{idx}")
|
|
public String reqDetail(@PathVariable int idx, Model model) throws Exception {
|
|
try {
|
|
List<?> cityList = areaCodeService.selectCity();
|
|
UseRequestVO useRequestVO = useRequestService.selectUseRequest(idx);
|
|
|
|
if(UserUtil.isEqualMember(useRequestVO.getUserid())) {
|
|
String layers[] = useRequestVO.getLayers().split(",");
|
|
String places[] = useRequestVO.getPlaces().split(",");
|
|
|
|
List<Object> selectArea = new ArrayList<Object>();
|
|
for(int i=0;i<places.length;i++) {
|
|
HashMap<String, String> map = new HashMap<String, String>();
|
|
map.put("name", areaCodeService.selectAreaName(places[i]));
|
|
map.put("code", places[i]);
|
|
selectArea.add(map);
|
|
}
|
|
|
|
List <LayersVO> layersVO = layersService.selectLayers();
|
|
|
|
model.addAttribute("useRequestVO", useRequestVO);
|
|
model.addAttribute("selectArea", selectArea);
|
|
model.addAttribute("cityList", cityList);
|
|
model.addAttribute("layers", layers);
|
|
model.addAttribute("layersVO", layersVO);
|
|
|
|
return "map/requestView";
|
|
}else {
|
|
model.addAttribute("url", "/map/request");
|
|
model.addAttribute("resultMsg", "권한이 없습니다.");
|
|
return "/redirect";
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return "error/EgovServerError";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 지도 사용요청을 등록한다.
|
|
*
|
|
* @param useRequestVO 지도사용요청 VO
|
|
* @param req request 객체
|
|
* @param model 모델 객체
|
|
* @return 목록 화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value="/insertReq")
|
|
public String insertReq(@ModelAttribute("useRequestVO") UseRequestVO useRequestVO, HttpServletRequest req, Model model) throws Exception {
|
|
|
|
LoginUserVO user = (LoginUserVO) req.getSession().getAttribute("userVO");
|
|
useRequestVO.setUserid(user.getUserid());
|
|
useRequestService.insertReq(useRequestVO);
|
|
|
|
model.addAttribute("url", "/map/request");
|
|
model.addAttribute("resultMsg", "지도사용요청 신청이 완료되었습니다. 승인을 기다려주세요.");
|
|
return "/redirect";
|
|
}
|
|
|
|
|
|
/**
|
|
* 지도 사용요청을 수정한다.
|
|
*
|
|
* @param useRequestVO 지도사용요청 VO
|
|
* @param model 모델 객체
|
|
* @return 목록 화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value="/updateReq" )
|
|
public String updateReq(@ModelAttribute("useRequestVO") UseRequestVO useRequestVO, Model model) throws Exception {
|
|
|
|
useRequestService.updateReq(useRequestVO);
|
|
|
|
model.addAttribute("url", "/map/request");
|
|
model.addAttribute("resultMsg", "지도사용요청 수정이 완료되었습니다. 승인을 기다려주세요.");
|
|
return "/redirect";
|
|
}
|
|
|
|
/**
|
|
* 지도 사용요청을 삭제한다.
|
|
*
|
|
* @param useRequestVO 지도사용요청 VO
|
|
* @param model 모델 객체
|
|
* @return 목록 화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value="/deleteReq" )
|
|
public String deleteReq(@ModelAttribute("useRequestVO") UseRequestVO useRequestVO, Model model) throws Exception {
|
|
|
|
useRequestService.deleteReq(useRequestVO.getIdx());
|
|
|
|
model.addAttribute("url", "/map/reqList");
|
|
model.addAttribute("resultMsg", "지도사용요청이 취소되었습니다..");
|
|
return "/redirect";
|
|
}
|
|
|
|
/**
|
|
* 지도 사용요청 등록화면을 반환한다.
|
|
*
|
|
* @param model 모델 객체
|
|
* @return 목록 화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value="/reqWrite")
|
|
public String reqWrite(Model model) throws Exception {
|
|
try {
|
|
List<?> cityList = areaCodeService.selectCity();
|
|
List <LayersVO> layersVO = layersService.selectLayers();
|
|
|
|
model.addAttribute("layersVO", layersVO);
|
|
model.addAttribute("cityList", cityList);
|
|
return "map/requestWrite";
|
|
} catch (Exception e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
return "map/requestWrite";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 사용자 목록화면을 반환한다.
|
|
*
|
|
* @param model 모델 객체
|
|
* @param req Request 객체
|
|
* @return 목록 화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping("/userInfo")
|
|
public String userInfo(HttpServletRequest req, Model model) throws Exception {
|
|
|
|
LoginUserVO loginUserVO = (LoginUserVO) req.getSession().getAttribute("userVO");
|
|
UserVO userVO = userService.selectUserInfo(loginUserVO.getUserid());
|
|
|
|
model.addAttribute("userVO", userVO);
|
|
|
|
return "map/userInfo";
|
|
}
|
|
|
|
/**
|
|
* 사용자정보를 수정한다.
|
|
*
|
|
* @param req Request 객체
|
|
* @param model 모델 객체
|
|
* @param userVO 사용자정보 VO
|
|
* @return 목록 화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping("/userUpdate")
|
|
public String userUpdate(HttpServletRequest req, Model model, UserVO userVO) throws Exception {
|
|
|
|
userService.updateUser(userVO);
|
|
|
|
model.addAttribute("url", "/map/userInfo");
|
|
model.addAttribute("resultMsg", "수정되었습니다.");
|
|
return "/redirect";
|
|
}
|
|
|
|
|
|
}
|