@RequestMapping(value = "/view/BBS_ID/{bbsId}/ATC_NO/{atcNo}", method = RequestMethod.GET)
public String view(@RequestParam(value = "single", required = false, defaultValue = "") String single, String page, @PathVariable String bbsId, @PathVariable String atcNo, HttpServletRequest request, Model model) {
// 게시판 관리 정보
Bbs objBbsInfo = boardBO.getBbsInfo(bbsId);
// 게시판 권한 정보
String strRoleRead = "";
String strRoleWrite = "";
User objUserInfo = RoleUtil.getUserInfo();
if (objUserInfo == null) {
strRoleRead = RoleUtil.getRoleByBoardRead(objBbsInfo.getBbsRole(), "R", "G0");
strRoleWrite = RoleUtil.getRoleByBoardRead(objBbsInfo.getBbsRole(), "W", "G0");
} else {
strRoleRead = RoleUtil.getRoleByBoardRead(objBbsInfo.getBbsRole(), "R", objUserInfo.getRoleGrpId());
strRoleWrite = RoleUtil.getRoleByBoardRead(objBbsInfo.getBbsRole(), "W", objUserInfo.getRoleGrpId());
}
// 내용 조회시 [읽기권한]이 없는 경우 로그인 페이지로 이동시킨다.
if (strRoleRead == "") throw new UsernameNotFoundException("내용 조회시 접근한 게시판에 Read 권한이 존재하지않습니다.");
// 게시판 정보
Article article = new Article();
article.setBbsId(bbsId);
// Page 정보
if (page == null) page = "1";
if (page.equals("")) page = "1";
int totalRows = boardBO.getListArticleCount(article);
int rowRange = m_intRowRange;
int pageRange = m_intPageRange;
int pageNum = Integer.parseInt(page);
String pageURL = "/board/list/BBS_ID/" + bbsId;
PagingHelper pHelper = PagingHelper.instance;
pHelper.init(totalRows, rowRange, pageRange, pageNum);
String pageHTML = pHelper.getPagingHTML(single, pageURL);
int startNum = pHelper.getStartRownum();
int endNum = pHelper.getEndRownum();
Article objViewArticle = null;
Article objNextArticle = null;
Article objPrevArticle = null;
article.setStartBbsThread(startNum);
article.setEndBbsThread(endNum);
List<Article> objArticleList = boardBO.listArticle(article);
for (int i = 0; i < objArticleList.size(); i++) {
if (objArticleList.get(i).getAtcNo() == new Integer(atcNo)) {
objViewArticle = objArticleList.get(i);
boardBO.hitArticle(new Integer(atcNo));
if (i > 0)
objNextArticle = objArticleList.get(i - 1);
if (i < (objArticleList.size() - 1))
objPrevArticle = objArticleList.get(i + 1);
}
}
// 사용자 정보
String strId = "";
if (objUserInfo != null) strId = objUserInfo.getId();
// 권한정보
String strAuth = "";
if (objUserInfo != null) {
strAuth = objUserInfo.getRoleGrpId();
}
model.addAttribute("userRole", strAuth);
model.addAttribute("boardRoleRead", strRoleRead);
model.addAttribute("boardRoleWrite", strRoleWrite);
model.addAttribute("single", single);
model.addAttribute("objBbsInfo", objBbsInfo);
model.addAttribute("objArticleList", objArticleList);
model.addAttribute("pageHTML", pageHTML);
model.addAttribute("page", page);
model.addAttribute("objViewArticle", objViewArticle);
model.addAttribute("objNextArticle", objNextArticle);
model.addAttribute("objPrevArticle", objPrevArticle);
model.addAttribute("userId", strId);
if (!objBbsInfo.getCdCatId().equals("")) {
// 게시판 카테고리 정보가 존재할 경우 카테고리 정보를 보여준다.
model.addAttribute("boardCatgList", codeCategoryBO.listCodeCategoryForCombo(objBbsInfo.getCdCatId()));
}
return "board/view";
}