176 lines
4.7 KiB
Java
176 lines
4.7 KiB
Java
package com.mca.cmmn.web;
|
|
|
|
import java.util.List;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import com.mca.cmmn.service.AreaCodeService;
|
|
import com.mca.user.service.UserService;
|
|
import com.mca.user.vo.UserVO;
|
|
|
|
import egovframework.rte.fdl.property.EgovPropertyService;
|
|
|
|
@Controller
|
|
public class CommonController {
|
|
|
|
|
|
/**
|
|
* properties값을 가져오는 인터페이스.
|
|
**/
|
|
@Resource(name="propertiesService")
|
|
private EgovPropertyService propertiesService;
|
|
|
|
@Resource(name="userService")
|
|
private UserService userService;
|
|
|
|
@Resource(name="areaCodeService")
|
|
private AreaCodeService areaCodeService;
|
|
|
|
|
|
/**
|
|
* 로그인 화면을 반환한다.
|
|
*
|
|
* @param error 로그인 실패정보
|
|
* @param fail 사용자 인증정보
|
|
* @return 로그인화면 화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value="/login")
|
|
public String login(String error, String fail, Model model) throws Exception{
|
|
try {
|
|
if(error != null) {
|
|
model.addAttribute("errMsg", "접속자 정보를 찾을 수 없습니다.");
|
|
}
|
|
if(fail != null) {
|
|
model.addAttribute("errMsg", "승인 처리중입니다.");
|
|
}
|
|
return "login";
|
|
} catch (Exception e) {
|
|
// TODO: handle exception
|
|
e.printStackTrace();
|
|
return "error/EgovServerError";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 로그아웃처리를 한다
|
|
*
|
|
* @param session 세션 객체
|
|
* @param model 모델 객체
|
|
* @return 로그인 화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value="/logout")
|
|
public String logout(HttpSession session, Model model) throws Exception {
|
|
try {
|
|
session.removeAttribute("id");
|
|
session.removeAttribute("admin");
|
|
model.addAttribute("url", "/");
|
|
model.addAttribute("resultMsg", "로그아웃 되었습니다.");
|
|
return "/redirect";
|
|
} catch (Exception e) {
|
|
// TODO: handle exception
|
|
e.printStackTrace();
|
|
return "error/EgovServerError";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 회원가입 화면을 반환한다.
|
|
* @return 회원가입 화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value="/join")
|
|
public String join() throws Exception {
|
|
try {
|
|
return "join";
|
|
} catch (Exception e) {
|
|
// TODO: handle exception
|
|
e.printStackTrace();
|
|
return "error/EgovServerError";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 아이디 중복 체크를 한다.
|
|
* @param checkId 입력 아이디값
|
|
* @return 성공, 실패 여부
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value="/userIdCheck")
|
|
@ResponseBody
|
|
public String checkId(@RequestParam("checkId")String checkId) throws Exception {
|
|
try {
|
|
int cnt = userService.selectUserIdCheck(checkId);
|
|
if(cnt > 0) {
|
|
return "duplicate";
|
|
}else {
|
|
return "ok";
|
|
}
|
|
} catch (Exception e) {
|
|
// TODO: handle exception
|
|
e.printStackTrace();
|
|
return "error/EgovServerError";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 사용자 등록 처리를 한다.
|
|
* @param userVO 사용자정보 VO
|
|
* @param model 모델 객체
|
|
* @return 로그인 화면
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value="/insertUser")
|
|
public String userInsert(@ModelAttribute("userVO") UserVO userVO, Model model) throws Exception {
|
|
try {
|
|
int result = userService.insertUser(userVO);
|
|
if(result == 0) {
|
|
model.addAttribute("url", "/");
|
|
model.addAttribute("resultMsg", "회원가입이 완료 되었습니다. 승인을 기다려주세요.");
|
|
return "/redirect";
|
|
}else {
|
|
model.addAttribute("resultMsg", "오류가 발생하였습니다.");
|
|
return "/join";
|
|
}
|
|
} catch (Exception e) {
|
|
// TODO: handle exception
|
|
e.printStackTrace();
|
|
return "error/EgovServerError";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 지역 리스트 가져온다.
|
|
* @param code 법정동 코드
|
|
* @param area 지역이름
|
|
* @return 선택된 지역 리스트
|
|
* @throws Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping(value="/selectAreaList")
|
|
@ResponseBody
|
|
public List<?> selectAreaList(@RequestParam("code")String code, @RequestParam("area")String area) throws Exception {
|
|
List<?> countyList = areaCodeService.selectCounty(code, area);
|
|
return countyList;
|
|
}
|
|
|
|
/**
|
|
* 권한이 없는 사용자가 접근시 권한제한 화면으로 이동한다.
|
|
*
|
|
* @return 권한없음 페이지
|
|
* @exception Exception 기본 예외 처리
|
|
*/
|
|
@RequestMapping("/error/EgovAccessDenied")
|
|
public String accessDenied() throws Exception {
|
|
return "error/EgovAccessDenied";
|
|
}
|
|
}
|