GGWEB/src/main/java/com/mca/cmmn/web/CommonController.java

176 lines
4.7 KiB
Java
Raw Normal View History

2022-02-15 07:38:58 +00:00
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";
}
}