diff --git a/bin/src/main/java/com/kh/tripply/banner/controller/BannerController.class b/bin/src/main/java/com/kh/tripply/banner/controller/BannerController.class new file mode 100644 index 0000000..f1ec295 Binary files /dev/null and b/bin/src/main/java/com/kh/tripply/banner/controller/BannerController.class differ diff --git a/src/main/java/com/kh/tripply/banner/controller/BannerController.java b/src/main/java/com/kh/tripply/banner/controller/BannerController.java index dd74062..3250e60 100644 --- a/src/main/java/com/kh/tripply/banner/controller/BannerController.java +++ b/src/main/java/com/kh/tripply/banner/controller/BannerController.java @@ -1,5 +1,96 @@ package com.kh.tripply.banner.controller; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +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.multipart.MultipartFile; +import org.springframework.web.servlet.ModelAndView; + +import com.kh.tripply.banner.domain.Banner; +import com.kh.tripply.banner.service.BannerService; +import com.kh.tripply.notice.domain.Notice; + +@Controller public class BannerController { + @Autowired + private BannerService bService; + + // 배너 리스트 및 등록 뷰 + @RequestMapping(value="/banner/listView.kh", method=RequestMethod.GET) + public ModelAndView showBannerWriteAndList(ModelAndView mv) { + + List bList = bService.printAllBanner(); + if(!bList.isEmpty()) { + mv.addObject("bList", bList); + mv.setViewName("banner/bannerRegisterAndList"); + }else { + mv.addObject("msg", "실패"); + mv.setViewName("common/errorPage"); + } + + return mv; + } + + // 배너 등록 + @RequestMapping(value="/banner/register.kh", method=RequestMethod.POST) + public ModelAndView registerBanner(ModelAndView mv + ,@ModelAttribute Banner banner + ,@RequestParam(value = "uploadFile", required = false) + MultipartFile uploadFile + , HttpServletRequest request) { // resources 경로 가져오려고 + + try { + + String bannerFileName = uploadFile.getOriginalFilename(); + + if(!bannerFileName.equals("")) { + String root = request.getSession().getServletContext().getRealPath("resources"); + String savePath = root + "\\buploadFiles"; // 저장경로 지정 + File file = new File(savePath); + + // 파일 이름이 같다고 안들어가는 경우 방지 --> 파일명을 날짜+시간으로 바꿈 + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String bannerFileRename = sdf.format(new Date(System.currentTimeMillis()))+"." + +bannerFileName.substring(bannerFileName.lastIndexOf(".")+1);// .다음부터 끝까지 잘라서 반환 + if(!file.exists()) { + file.mkdir(); // 경로 폴더가 없으면 폴더 생성 + } + uploadFile.transferTo(new File(savePath + "\\" + bannerFileRename));//파일을 buploadFile경로에 저장하는 메소드 + + banner.setBannerFileName(bannerFileName); + banner.setBannerFileRename(bannerFileRename); + + String boardFilepath = savePath + "\\" +bannerFileRename;// 절대경로 + + banner.setBannerFilePath(boardFilepath); + + } + + int result = bService.registerBanner(banner); + mv.setViewName("redirect:/banner/listView.kh"); + + }catch (Exception e) { + e.printStackTrace(); + mv.addObject("msg", e.getMessage()); + mv.setViewName("common/errorPage"); + } + return mv; + } + + + + + } + diff --git a/src/main/java/com/kh/tripply/banner/domain/Banner.java b/src/main/java/com/kh/tripply/banner/domain/Banner.java index e52afb3..620a22f 100644 --- a/src/main/java/com/kh/tripply/banner/domain/Banner.java +++ b/src/main/java/com/kh/tripply/banner/domain/Banner.java @@ -1,5 +1,47 @@ package com.kh.tripply.banner.domain; + public class Banner { + private int bannerNo; + private String bannerWriter; + private String bannerFileName; + private String bannerFileRename; + private String bannerFilePath; + public int getBannerNo() { + return bannerNo; + } + public void setBannerNo(int bannerNo) { + this.bannerNo = bannerNo; + } + public String getBannerWriter() { + return bannerWriter; + } + public void setBannerWriter(String bannerWriter) { + this.bannerWriter = bannerWriter; + } + public String getBannerFileName() { + return bannerFileName; + } + public void setBannerFileName(String bannerFileName) { + this.bannerFileName = bannerFileName; + } + public String getBannerFileRename() { + return bannerFileRename; + } + public void setBannerFileRename(String bannerFileRename) { + this.bannerFileRename = bannerFileRename; + } + public String getBannerFilePath() { + return bannerFilePath; + } + public void setBannerFilePath(String bannerFilePath) { + this.bannerFilePath = bannerFilePath; + } + @Override + public String toString() { + return "Banner [bannerNo=" + bannerNo + ", bannerWriter=" + bannerWriter + ", bannerFileName=" + bannerFileName + + ", bannerFileRename=" + bannerFileRename + ", bannerFilePath=" + bannerFilePath + "]"; + } + } diff --git a/src/main/java/com/kh/tripply/banner/service/BannerService.java b/src/main/java/com/kh/tripply/banner/service/BannerService.java index 5e467cb..c79b632 100644 --- a/src/main/java/com/kh/tripply/banner/service/BannerService.java +++ b/src/main/java/com/kh/tripply/banner/service/BannerService.java @@ -1,5 +1,12 @@ package com.kh.tripply.banner.service; +import java.util.List; + +import com.kh.tripply.banner.domain.Banner; + public interface BannerService { + + public int registerBanner(Banner banner); + public List printAllBanner(); } diff --git a/src/main/java/com/kh/tripply/banner/service/logic/BannerServiceImpl.java b/src/main/java/com/kh/tripply/banner/service/logic/BannerServiceImpl.java index fb8ad53..fe6cb1f 100644 --- a/src/main/java/com/kh/tripply/banner/service/logic/BannerServiceImpl.java +++ b/src/main/java/com/kh/tripply/banner/service/logic/BannerServiceImpl.java @@ -1,5 +1,36 @@ package com.kh.tripply.banner.service.logic; -public class BannerServiceImpl { +import java.util.List; +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.kh.tripply.banner.domain.Banner; +import com.kh.tripply.banner.service.BannerService; +import com.kh.tripply.banner.store.BannerStore; + +@Service +public class BannerServiceImpl implements BannerService{ + + @Autowired + private BannerStore bStore; + @Autowired + private SqlSessionTemplate session; + + // 배너 등록 + @Override + public int registerBanner(Banner banner) { + int result = bStore.insertBanner(session, banner); + return result; + } + + // 배너 리스트 + @Override + public List printAllBanner() { + List bList = bStore.selectAllBanner(session); + return bList; + } + + } diff --git a/src/main/java/com/kh/tripply/banner/store/BannerStore.java b/src/main/java/com/kh/tripply/banner/store/BannerStore.java index 0746fa5..4ac4e48 100644 --- a/src/main/java/com/kh/tripply/banner/store/BannerStore.java +++ b/src/main/java/com/kh/tripply/banner/store/BannerStore.java @@ -1,5 +1,17 @@ package com.kh.tripply.banner.store; +import java.util.List; + +import org.apache.ibatis.session.SqlSession; + +import com.kh.tripply.banner.domain.Banner; + public interface BannerStore { + + //등록 쿼리 + public int insertBanner(SqlSession session, Banner banner); + + //리스트 쿼리 + public List selectAllBanner(SqlSession session); } diff --git a/src/main/java/com/kh/tripply/banner/store/logic/BannerStoreLogic.java b/src/main/java/com/kh/tripply/banner/store/logic/BannerStoreLogic.java index 3cdb356..7f017c7 100644 --- a/src/main/java/com/kh/tripply/banner/store/logic/BannerStoreLogic.java +++ b/src/main/java/com/kh/tripply/banner/store/logic/BannerStoreLogic.java @@ -1,5 +1,26 @@ package com.kh.tripply.banner.store.logic; -public class BannerStoreLogic { +import java.util.List; + +import org.apache.ibatis.session.SqlSession; +import org.springframework.stereotype.Repository; + +import com.kh.tripply.banner.domain.Banner; +import com.kh.tripply.banner.store.BannerStore; + +@Repository +public class BannerStoreLogic implements BannerStore { + + @Override + public int insertBanner(SqlSession session, Banner banner) { + int result = session.insert("bannerMapper.insertBanner", banner); + return result; + } + + @Override + public List selectAllBanner(SqlSession session) { + List bList = session.selectList("bannerMapper.selectAllBanner"); + return bList; + } } diff --git a/src/main/java/com/kh/tripply/notice/controller/NoticeController.java b/src/main/java/com/kh/tripply/notice/controller/NoticeController.java index bb9c3b2..394f347 100644 --- a/src/main/java/com/kh/tripply/notice/controller/NoticeController.java +++ b/src/main/java/com/kh/tripply/notice/controller/NoticeController.java @@ -1,5 +1,172 @@ package com.kh.tripply.notice.controller; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.springframework.beans.factory.annotation.Autowired; +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.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.ModelAndView; + +import com.kh.tripply.notice.domain.Notice; +import com.kh.tripply.notice.service.NoticeService; + +@Controller public class NoticeController { + @Autowired + private NoticeService nService; + + // 공지사항 등록 화면 + @RequestMapping(value = "/notice/writeView.kh", method = RequestMethod.GET) + public String showBoardWrite() { + return "notice/noticeWriteForm"; + } + + // 공지사항 등록 + @RequestMapping(value = "/notice/register.kh", method = RequestMethod.POST) + public ModelAndView registerBoard(ModelAndView mv, @ModelAttribute Notice notice) { + + try { + int result = nService.registerNotice(notice); + mv.setViewName("redirect:/notice/list.kh"); + } catch (Exception e) { + e.printStackTrace(); + mv.addObject("msg", e.getMessage()); + mv.setViewName("common/errorPage"); + } + return mv; + } + + // 공지사항 리스트 + @RequestMapping(value = "/notice/list.kh", method = RequestMethod.GET) + public ModelAndView noticeListView(ModelAndView mv + , @RequestParam(value = "page", required = false) Integer page, + HttpServletRequest request) { + + try { + // 페이징 + int currentPage = (page != null) ? page : 1; + int totalCount = nService.getTotalCount("", ""); + int boardLimit = 10; + int naviLimit = 5; + int maxPage; + int startNavi; + int endNavi; + maxPage = (int) ((double) totalCount / boardLimit + 0.9); + startNavi = ((int) ((double) currentPage / naviLimit + 0.9) - 1) * naviLimit + 1; + endNavi = startNavi + naviLimit - 1; + if (maxPage < endNavi) { + endNavi = maxPage; + } + mv.addObject("currentPage", currentPage); + mv.addObject("maxPage", maxPage); + mv.addObject("startNavi", startNavi); + mv.addObject("endNavi", endNavi); + mv.addObject("urlVal", "list"); + // 페이징 + + List nList = nService.printAllNotice(currentPage, boardLimit); + mv.addObject("nList", nList); + mv.setViewName("notice/noticeListView"); + } catch (Exception e) { + e.printStackTrace(); + mv.addObject("msg", e.getMessage()); + mv.setViewName("common/errorPage"); + } + return mv; + } + + // 공지사항 상세 뷰 + @RequestMapping(value = "/notice/detail.kh", method = RequestMethod.GET) + public ModelAndView noticeDetailView(ModelAndView mv, @RequestParam("noticeNo") int noticeNo, + @RequestParam("page") Integer page, HttpSession session) { + + try { + Notice notice = nService.printOneNotice(noticeNo); + mv.addObject("notice", notice); + mv.addObject("page", page); + + mv.setViewName("notice/noticeDetailView"); + } catch (Exception e) { + mv.addObject("msg", e.getMessage()); + + mv.setViewName("common/errorPage"); + } + + return mv; + + } + +// // 공지사항 삭제 수정중 +// @RequestMapping(value="notice/remove.kh", method = RequestMethod.GET) +// public String noticeRemove(HttpSession session +// , Model model +// , @RequestParam("page") Integer page) { +// +// try { +// int noticeNo = (int) session.getAttribute("noticeNo"); +// System.out.println(noticeNo); +// int result = nService.removeOneByNo(noticeNo); +// if(result > 0) { +// session.removeAttribute("noticeNo"); +// +// }else { +// System.out.println("실패"); +// } +// +// return "redirect:/notice/list.kh?page=" + page; +// } catch (Exception e) { +// model.addAttribute("msg", e.getMessage()); +// return "common/errorPage"; +// } +// } + + // 공지사항 수정 뷰 + @RequestMapping(value="notice/modifyView.kh", method = RequestMethod.GET) + public ModelAndView noticeModifyView( + ModelAndView mv + , @RequestParam("page") Integer page + , @RequestParam("noticeNo") Integer noticeNo) { + + try { + Notice notice = nService.printOneNotice(noticeNo); + mv.addObject("notice", notice); + mv.addObject("page", page); + mv.setViewName("notice/noticeModifyForm"); + } catch (Exception e) { + mv.addObject("msg", e.getMessage()); + mv.setViewName("common/errorPage"); + } + return mv; + + } + + // 공지사항 수정 + @RequestMapping(value="notice/modify.kh", method = RequestMethod.POST) + public ModelAndView noticeModify( + ModelAndView mv + , @ModelAttribute Notice notice + , @RequestParam("page") Integer page + , HttpServletRequest request) { // 파일경로는 request로 알아옴 + + try { + int result = nService.modifyNotice(notice); + if(result > 0) { + mv.setViewName("redirect:/notice/list.kh?page=" + page); + } + } catch (Exception e) { + mv.addObject("msg", e.getMessage()); + mv.setViewName("common/errorPage"); + } + + return mv; + + } } diff --git a/src/main/java/com/kh/tripply/notice/domain/Notice.java b/src/main/java/com/kh/tripply/notice/domain/Notice.java index b000a79..0eabfe7 100644 --- a/src/main/java/com/kh/tripply/notice/domain/Notice.java +++ b/src/main/java/com/kh/tripply/notice/domain/Notice.java @@ -1,5 +1,87 @@ package com.kh.tripply.notice.domain; +import java.sql.Date; + public class Notice { + private int noticeNo; + private String noticeTitle; + private String noticeContents; + private String noticeWriter; + private int noticeCount; + private Date nCreateDate; + private Date nUpdateDate; + private String nStatus; + + public int getNoticeNo() { + return noticeNo; + } + + public void setNoticeNo(int noticeNo) { + this.noticeNo = noticeNo; + } + + public String getNoticeTitle() { + return noticeTitle; + } + + public void setNoticeTitle(String noticeTitle) { + this.noticeTitle = noticeTitle; + } + + public String getNoticeContents() { + return noticeContents; + } + + public void setNoticeContents(String noticeContents) { + this.noticeContents = noticeContents; + } + + public String getNoticeWriter() { + return noticeWriter; + } + + public void setNoticeWriter(String noticeWriter) { + this.noticeWriter = noticeWriter; + } + + public Date getnCreateDate() { + return nCreateDate; + } + + public void setnCreateDate(Date nCreateDate) { + this.nCreateDate = nCreateDate; + } + + public Date getnUpdateDate() { + return nUpdateDate; + } + + public void setnUpdateDate(Date nUpdateDate) { + this.nUpdateDate = nUpdateDate; + } + + public String getnStatus() { + return nStatus; + } + + public void setnStatus(String nStatus) { + this.nStatus = nStatus; + } + + public int getNoticeCount() { + return noticeCount; + } + + public void setNoticeCount(int noticeCount) { + this.noticeCount = noticeCount; + } + + @Override + public String toString() { + return "Notice [noticeNo=" + noticeNo + ", noticeTitle=" + noticeTitle + ", noticeContents=" + noticeContents + + ", noticeWriter=" + noticeWriter + ", nCreateDate=" + nCreateDate + ", nUpdateDate=" + nUpdateDate + + ", nStatus=" + nStatus + ", noticeCount=" + noticeCount + "]"; + } + } diff --git a/src/main/java/com/kh/tripply/notice/service/NoticeService.java b/src/main/java/com/kh/tripply/notice/service/NoticeService.java index be81126..a2a34e5 100644 --- a/src/main/java/com/kh/tripply/notice/service/NoticeService.java +++ b/src/main/java/com/kh/tripply/notice/service/NoticeService.java @@ -1,5 +1,22 @@ package com.kh.tripply.notice.service; +import java.util.List; + +import com.kh.tripply.notice.domain.Notice; + public interface NoticeService { + + public int registerNotice(Notice notice); + + public List printAllNotice(int currentPage, int boardLimit); + + public int getTotalCount(String searchCondition, String searchValue); + + public Notice printOneNotice(int noticeNo); + + public int removeOneByNo(int noticeNo); + + public int modifyNotice(Notice notice); } + \ No newline at end of file diff --git a/src/main/java/com/kh/tripply/notice/service/logic/NoticeServiceImpl.java b/src/main/java/com/kh/tripply/notice/service/logic/NoticeServiceImpl.java index 4789640..3ff5a9e 100644 --- a/src/main/java/com/kh/tripply/notice/service/logic/NoticeServiceImpl.java +++ b/src/main/java/com/kh/tripply/notice/service/logic/NoticeServiceImpl.java @@ -1,5 +1,61 @@ package com.kh.tripply.notice.service.logic; -public class NoticeServiceImpl { +import java.util.List; +import org.apache.ibatis.type.NStringTypeHandler; +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.kh.tripply.notice.domain.Notice; +import com.kh.tripply.notice.service.NoticeService; +import com.kh.tripply.notice.store.NoticeStore; + +@Service +public class NoticeServiceImpl implements NoticeService{ + + @Autowired + private NoticeStore nStore; + @Autowired + private SqlSessionTemplate session; + + @Override + public int registerNotice(Notice notice) { + int result = nStore.insertNotice(session, notice); + return result; + } + + @Override + public List printAllNotice(int currentPage, int boardLimit) { + List nList = nStore.selectAllNotice(session, currentPage, boardLimit); + return nList; + } + + @Override + public int getTotalCount(String searchCondition, String searchValue) { + int totalCount = nStore.selectTotalCount(session, searchCondition, searchValue); + return totalCount; + } + + @Override + public Notice printOneNotice(int noticeNo) { + Notice notice = nStore.selectOneNotice(session, noticeNo); + if(notice != null) { + nStore.updateBoardCount(session, noticeNo); + } + return notice; + } + + @Override + public int removeOneByNo(int noticeNo) { + int result = nStore.deleteNotice(session, noticeNo); + return result; + } + + @Override + public int modifyNotice(Notice notice) { + int result = nStore.updateNotice(session, notice); + return result; + } + } diff --git a/src/main/java/com/kh/tripply/notice/store/NoticeStore.java b/src/main/java/com/kh/tripply/notice/store/NoticeStore.java index dc34662..efba022 100644 --- a/src/main/java/com/kh/tripply/notice/store/NoticeStore.java +++ b/src/main/java/com/kh/tripply/notice/store/NoticeStore.java @@ -1,5 +1,25 @@ package com.kh.tripply.notice.store; +import java.util.List; + +import org.apache.ibatis.session.SqlSession; + +import com.kh.tripply.notice.domain.Notice; + public interface NoticeStore { + + public int insertNotice(SqlSession session, Notice notice); + + public List selectAllNotice(SqlSession session, int currentPage, int boardLimit); + + public int selectTotalCount(SqlSession session, String searchCondition, String searchValue); + + public Notice selectOneNotice(SqlSession session, int noticeNo); + + public int deleteNotice(SqlSession session, int noticeNo); + + public int updateNotice(SqlSession session, Notice notice); + + public int updateBoardCount(SqlSession session, int noticeNo); } diff --git a/src/main/java/com/kh/tripply/notice/store/logic/NoticeStoreLogic.java b/src/main/java/com/kh/tripply/notice/store/logic/NoticeStoreLogic.java index 657cbb5..25d4489 100644 --- a/src/main/java/com/kh/tripply/notice/store/logic/NoticeStoreLogic.java +++ b/src/main/java/com/kh/tripply/notice/store/logic/NoticeStoreLogic.java @@ -1,5 +1,67 @@ package com.kh.tripply.notice.store.logic; -public class NoticeStoreLogic { +import java.util.HashMap; +import java.util.List; + +import org.apache.ibatis.session.RowBounds; +import org.apache.ibatis.session.SqlSession; +import org.springframework.stereotype.Repository; + +import com.kh.tripply.notice.domain.Notice; +import com.kh.tripply.notice.store.NoticeStore; + +@Repository +public class NoticeStoreLogic implements NoticeStore { + + @Override + public int insertNotice(SqlSession session, Notice notice) { + int result = session.insert("noticeMapper.insertNotice", notice); + return result; + } + + @Override + public List selectAllNotice(SqlSession session, int currentPage, int boardLimit) { + int offset = (currentPage - 1)*boardLimit; + RowBounds rowBounds = new RowBounds(offset, boardLimit); + List nList = session.selectList("noticeMapper.selectAllNotice", null, rowBounds); + return nList; + } + + @Override + public int selectTotalCount(SqlSession session, String searchCondition, String searchValue) { + HashMap paramMap = new HashMap(); + paramMap.put("searchCondition", searchCondition); + paramMap.put("searchValue", searchValue); + int totalCount = session.selectOne("noticeMapper.selectTotalCount",paramMap); + return totalCount; + } + + @Override + public Notice selectOneNotice(SqlSession session, int noticeNo) { + Notice notice = session.selectOne("noticeMapper.selectOneNotice", noticeNo); + return notice; + } + + @Override + public int deleteNotice(SqlSession session, int noticeNo) { + int result = session.update("noticeMapper.deleteNotice", noticeNo); + return result; + } + + @Override + public int updateNotice(SqlSession session, Notice notice) { + int result = session.update("noticeMapper.updateNotice", notice); + return result; + } + + @Override + public int updateBoardCount(SqlSession session, int noticeNo) { + int result = session.update("noticeMapper.updateNoticeCount", noticeNo); + return result; + } + + + + } diff --git a/src/main/java/com/kh/tripply/party/controller/PartyController.java b/src/main/java/com/kh/tripply/party/controller/PartyController.java index 4db5f3c..8464fc2 100644 --- a/src/main/java/com/kh/tripply/party/controller/PartyController.java +++ b/src/main/java/com/kh/tripply/party/controller/PartyController.java @@ -3,6 +3,7 @@ import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -22,54 +23,101 @@ public class PartyController { @Autowired private PartyService pService; - -@RequestMapping(value="/party/writeView.kh", method=RequestMethod.GET) + + // 동행자 게시판 등록view + @RequestMapping(value = "/party/writeView.kh", method = RequestMethod.GET) public String showBoardWrite() { return "party/partyWriteForm"; } -@RequestMapping(value="/party/register.kh", method=RequestMethod.POST) -public ModelAndView registerBoard(ModelAndView mv - ,@ModelAttribute Party party -// ,@RequestParam(value = "uploadFile", required = false) -// MultipartFile uploadFile -// , HttpServletRequest request - ) { // resources 경로 가져오려고 + // 동행자 게시판 게시글 등록 + @RequestMapping(value = "/party/register.kh", method = RequestMethod.POST) + public ModelAndView registerBoard(ModelAndView mv, @ModelAttribute Party party, + @RequestParam(value = "uploadFile", required = false) MultipartFile uploadFile, + HttpServletRequest request) { // resources 경로 가져오려고 + + try { + + String boardFilename = uploadFile.getOriginalFilename(); + + if (!boardFilename.equals("")) { + String root = request.getSession().getServletContext().getRealPath("resources"); + String savePath = root + "\\partyuploadFiles"; // 저장경로 지정 + File file = new File(savePath); + + // 파일 이름이 같다고 안들어가는 경우 방지 --> 파일명을 날짜+시간으로 바꿈 + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + String boardFileRename = sdf.format(new Date(System.currentTimeMillis())) + "." + + boardFilename.substring(boardFilename.lastIndexOf(".") + 1);// .다음부터 끝까지 잘라서 반환 + if (!file.exists()) { + file.mkdir(); // 경로 폴더가 없으면 폴더 생성 + } + uploadFile.transferTo(new File(savePath + "\\" + boardFileRename));// 파일을 buploadFile경로에 저장하는 메소드 + party.setPartyFileName(boardFilename); + party.setPartyFileRename(boardFileRename); // 모든 파일이 고유한 값을 갖게 해야함 + + String boardFilepath = savePath + "\\" + boardFileRename;// 절대경로 + + party.setPartyFilePath(boardFilepath); + + } + + int result = pService.registerParty(party); + mv.setViewName("redirect:/party/writeView.kh"); + + } catch (Exception e) { + e.printStackTrace(); + mv.addObject("msg", e.getMessage()); + mv.setViewName("common/errorPage"); + } + return mv; + } - try { - -// String boardFilename = uploadFile.getOriginalFilename(); +// // 동행자 게시판 리스트 수정중!!! +// @RequestMapping(value="/party/list.kh", method=RequestMethod.GET) +// public ModelAndView partyListView( +// ModelAndView mv +// ,@RequestParam(value = "page", required=false) Integer page +// ,HttpServletRequest request) { // -// if(!boardFilename.equals("")) { -// String root = request.getSession().getServletContext().getRealPath("resources"); -// String savePath = root + "\\buploadFiles"; // 저장경로 지정 -// File file = new File(savePath); +// try { +// +// int currentPage = (page != null) ? page : 1; +// int totalCount = pService.getTotalCount("",""); +// int boardLimit = 9; +// int naviLimit = 5; +// int maxPage; +// int startNavi; +// int endNavi; // -// // 파일 이름이 같다고 안들어가는 경우 방지 --> 파일명을 날짜+시간으로 바꿈 -// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); -// String boardFileRename = sdf.format(new Date(System.currentTimeMillis()))+"." -// +boardFilename.substring(boardFilename.lastIndexOf(".")+1);// .다음부터 끝까지 잘라서 반환 -// if(!file.exists()) { -// file.mkdir(); // 경로 폴더가 없으면 폴더 생성 +// maxPage = (int)((double)totalCount/boardLimit + 0.9); +// startNavi = ((int)((double)currentPage/naviLimit + 0.9)-1)*naviLimit+1; +// endNavi = startNavi + naviLimit - 1; +// if(maxPage < endNavi) { +// endNavi = maxPage; // } -// uploadFile.transferTo(new File(savePath + "\\" + boardFileRename));//파일을 buploadFile경로에 저장하는 메소드 -// party.setPartyFileName(boardFilename); -// party.setPartyFileRename(boardFileRename); //모든 파일이 고유한 값을 갖게 해야함 // -// String boardFilepath = savePath + "\\" +boardFileRename;// 절대경로 // -// party.setPartyFilePath(boardFilepath); +// List pList = pService.printAllBoard(currentPage, boardLimit); +// +// +// if(!pList.isEmpty()) { +// mv.addObject("currentPage", currentPage); +// mv.addObject("maxPage", maxPage); +// mv.addObject("startNavi", startNavi); +// mv.addObject("endNavi", endNavi); +// mv.addObject("pList", pList); +// mv.addObject("urlVal", "list"); +// mv.setViewName("party/partyListView"); +// }else { +// mv.addObject("msg", "실패").setViewName("common/errorPage"); +// } // +// }catch (Exception e) { +// mv.addObject("msg", e.getMessage()).setViewName("common/errorPage"); // } - - int result = pService.registerParty(party); - mv.setViewName("redirect:/board/list.kh"); - - }catch (Exception e) { - e.printStackTrace(); - mv.addObject("msg", e.getMessage()); - mv.setViewName("common/errorPage"); - } - return mv; -} +// return mv; +// +// +// } } diff --git a/src/main/java/com/kh/tripply/party/domain/Party.java b/src/main/java/com/kh/tripply/party/domain/Party.java index 18e6a33..6239736 100644 --- a/src/main/java/com/kh/tripply/party/domain/Party.java +++ b/src/main/java/com/kh/tripply/party/domain/Party.java @@ -103,6 +103,15 @@ public String getpStatus() { public void setpStatus(String pStatus) { this.pStatus = pStatus; } + @Override + public String toString() { + return "Party [partyNo=" + partyNo + ", partyTitle=" + partyTitle + ", partyContents=" + partyContents + + ", partyWriter=" + partyWriter + ", partyFirstDate=" + partyFirstDate + ", partyLastDate=" + + partyLastDate + ", partyLocation=" + partyLocation + ", partyFileName=" + partyFileName + + ", partyFileRename=" + partyFileRename + ", partyFilePath=" + partyFilePath + ", partyCount=" + + partyCount + ", pCreateDate=" + pCreateDate + ", pUpdateDate=" + pUpdateDate + ", pStatus=" + pStatus + + "]"; + } diff --git a/src/main/java/com/kh/tripply/party/service/PartyService.java b/src/main/java/com/kh/tripply/party/service/PartyService.java index 8946047..bc01220 100644 --- a/src/main/java/com/kh/tripply/party/service/PartyService.java +++ b/src/main/java/com/kh/tripply/party/service/PartyService.java @@ -1,9 +1,14 @@ package com.kh.tripply.party.service; +import java.util.List; + import com.kh.tripply.party.domain.Party; public interface PartyService { public int registerParty(Party party); + + public List printAllBoard(int currentPage, int boardLimit); + public int getTotalCount(String searchCondition, String searchValue); } diff --git a/src/main/java/com/kh/tripply/party/service/logic/PartyServiceImple.java b/src/main/java/com/kh/tripply/party/service/logic/PartyServiceImple.java index 7d4c7af..f5cb3fe 100644 --- a/src/main/java/com/kh/tripply/party/service/logic/PartyServiceImple.java +++ b/src/main/java/com/kh/tripply/party/service/logic/PartyServiceImple.java @@ -1,5 +1,7 @@ package com.kh.tripply.party.service.logic; +import java.util.List; + import org.mybatis.spring.SqlSessionTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -22,5 +24,14 @@ public int registerParty(Party party) { return result; } + @Override + public List printAllBoard(int currentPage, int boardLimit) { + List pList = pStore.selectAllParty(boardLimit, currentPage, session); + return pList; + } + + public int getTotalCount(String searchCondition, String searchValue) { + int result = pStore.selectTotalCount(searchCondition, searchValue, session); + return result; + } } - diff --git a/src/main/java/com/kh/tripply/party/store/PartyStore.java b/src/main/java/com/kh/tripply/party/store/PartyStore.java index f7772e4..20406d2 100644 --- a/src/main/java/com/kh/tripply/party/store/PartyStore.java +++ b/src/main/java/com/kh/tripply/party/store/PartyStore.java @@ -1,6 +1,8 @@ package com.kh.tripply.party.store; +import java.util.List; + import org.apache.ibatis.session.SqlSession; import com.kh.tripply.party.domain.Party; @@ -8,7 +10,9 @@ public interface PartyStore { public int insertParty(Party party, SqlSession session); + + public List selectAllParty(int currentPage, int boardLimit, SqlSession session); - + public int selectTotalCount(String searchCondition,String searchValue,SqlSession session); } diff --git a/src/main/java/com/kh/tripply/party/store/logic/PartyStoreLogic.java b/src/main/java/com/kh/tripply/party/store/logic/PartyStoreLogic.java index 44deee7..b75709e 100644 --- a/src/main/java/com/kh/tripply/party/store/logic/PartyStoreLogic.java +++ b/src/main/java/com/kh/tripply/party/store/logic/PartyStoreLogic.java @@ -1,5 +1,9 @@ package com.kh.tripply.party.store.logic; +import java.util.HashMap; +import java.util.List; + +import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.SqlSession; import org.springframework.stereotype.Repository; @@ -15,4 +19,21 @@ public int insertParty(Party party, SqlSession session) { return result; } + @Override + public List selectAllParty(int currentPage, int boardLimit, SqlSession session) { + int offset = (currentPage - 1)*boardLimit; + RowBounds rowBounds = new RowBounds(offset, boardLimit); + List pList = session.selectList("PartyMapper.selectAllParty", null, rowBounds); + return pList; + } + + @Override + public int selectTotalCount(String searchCondition, String searchValue, SqlSession session) { + HashMap paramMap = new HashMap(); + paramMap.put("searchCondition", searchCondition); + paramMap.put("searchValue", searchValue); + int result = session.selectOne("PartyMapper.selectTotalCount", paramMap); + return result; + } + } \ No newline at end of file diff --git a/src/main/resources/mappers/banner-mapper.xml b/src/main/resources/mappers/banner-mapper.xml new file mode 100644 index 0000000..2604b8a --- /dev/null +++ b/src/main/resources/mappers/banner-mapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + INSERT INTO BANNER_TBL + VALUES(#{bannerNo}, #{bannerWriter}, #{bannerFileName}, #{bannerFileRename}, #{bannerFilePath}) + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mappers/notice-mapper.xml b/src/main/resources/mappers/notice-mapper.xml new file mode 100644 index 0000000..8ff26b0 --- /dev/null +++ b/src/main/resources/mappers/notice-mapper.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + INSERT INTO NOTICE_TBL + VALUES(SEQ_NOTICENO.NEXTVAL, #{noticeTitle}, #{noticeContents}, #{noticeWriter}, + DEFAULT,DEFAULT,DEFAULT,DEFAULT) + + + + + UPDATE NOTICE_TBL + SET NOTICE_TITLE = #{noticeTitle}, + NOTICE_CONTENTS = #{noticeContents}, + N_UPDATE_DATE = DEFAULT + WHERE NOTICE_NO = #{noticeNo} + + + + + + + + + + + + + UPDATE NOTICE_TBL + SET N_STATUS = 'N' + WHERE NOTICE_NO = #{noticeNo} + + + + UPDATE NOTICE_TBL + SET NOTICE_COUNT = NOTICE_COUNT + 1 + WHERE NOTICE_NO = #{noticeNo} + + \ No newline at end of file diff --git a/src/main/resources/mappers/party-mapper.xml b/src/main/resources/mappers/party-mapper.xml index b523abe..3d31de5 100644 --- a/src/main/resources/mappers/party-mapper.xml +++ b/src/main/resources/mappers/party-mapper.xml @@ -4,6 +4,24 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + + + + + + + + + + + + + + + + + INSERT INTO PARTY_TBL VALUES( @@ -13,4 +31,35 @@ VALUES( DEFAULT, DEFAULT, DEFAULT, DEFAULT ) + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis-config.xml b/src/main/resources/mybatis-config.xml index 49e23ec..c4669fa 100644 --- a/src/main/resources/mybatis-config.xml +++ b/src/main/resources/mybatis-config.xml @@ -10,7 +10,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/banner/bannerRegisterAndList.jsp b/src/main/webapp/WEB-INF/views/banner/bannerRegisterAndList.jsp new file mode 100644 index 0000000..a2d8357 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/banner/bannerRegisterAndList.jsp @@ -0,0 +1,50 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + + + +게시글작성 + + +
+ +
+ +

배너 등록 및 리스트 페이지

+

+ +
+ + + + + + + + + + + + + + + + + + + + +
배너 순서배너 이미지작성자등록삭제
${i.count } + 본문이미지 + +
+ +
+ + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/notice/noticeDetailView.jsp b/src/main/webapp/WEB-INF/views/notice/noticeDetailView.jsp new file mode 100644 index 0000000..96bf573 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/notice/noticeDetailView.jsp @@ -0,0 +1,62 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%-- <%@ page session="false" %> 이거 있으면 세션스코프 동작 안함--%> +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + +게시글 상세 정보 + + + + + +

${notice.noticeNo }번 공지

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
제목${notice.noticeTitle }
작성자${notice.noticeWriter }
작성날짜${notice.nUpdateDate }
조회수${notice.noticeCount }
내용${notice.noticeContents } +
+ + + +
+ + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/notice/noticeListView.jsp b/src/main/webapp/WEB-INF/views/notice/noticeListView.jsp new file mode 100644 index 0000000..2f48cb1 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/notice/noticeListView.jsp @@ -0,0 +1,95 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + + + +동행자 게시판 + + + + + + +

게시글 목록

+ + + + + + + + + + + + + + + + + + + + + + + + + + +<%-- --%> + + + + + + + + + + + + + + + +
번호제목작성자날짜조회수
${i.count }${notice.noticeTitle }${notice.noticeWriter }${notice.nUpdateDate }${notice.noticeCount }
+ + + [이전] + + + + + ${p } + + + ${p } + + + + + [다음] + + +
검색 결과가 없습니다. +
+
+ + + +
+
+ +
+


+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/notice/noticeModifyForm.jsp b/src/main/webapp/WEB-INF/views/notice/noticeModifyForm.jsp new file mode 100644 index 0000000..1f5137c --- /dev/null +++ b/src/main/webapp/WEB-INF/views/notice/noticeModifyForm.jsp @@ -0,0 +1,65 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + + + + + + + + + + + +수정 페이지 + + + + +

${notice.noticeNo }번 게시글 수정 페이지

+

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
제목
작성자
내용
+ + + + +
+
+ + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/notice/noticeWriteForm.jsp b/src/main/webapp/WEB-INF/views/notice/noticeWriteForm.jsp new file mode 100644 index 0000000..8b7e3eb --- /dev/null +++ b/src/main/webapp/WEB-INF/views/notice/noticeWriteForm.jsp @@ -0,0 +1,67 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + + + + + + + + + + + + + +게시글작성 + + +
+ +
+ +

공지사항 등록 페이지

+

+ + +
+ + + + + + + + + + + + + + + + + + +
제목
작성자
내용
+ + + + +
+
+ + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/party/partyListView.jsp b/src/main/webapp/WEB-INF/views/party/partyListView.jsp index 8e7eaa3..a6cc913 100644 --- a/src/main/webapp/WEB-INF/views/party/partyListView.jsp +++ b/src/main/webapp/WEB-INF/views/party/partyListView.jsp @@ -6,7 +6,7 @@ -자유게시판 +동행자 게시판 @@ -15,39 +15,25 @@

게시글 목록

- +
- - - + - - - - - - - - - - +<%-- --%> + + + + @@ -55,7 +41,7 @@ - +<%-- --%> - + @@ -85,7 +71,7 @@ diff --git a/src/main/webapp/WEB-INF/views/party/partyWriteForm.jsp b/src/main/webapp/WEB-INF/views/party/partyWriteForm.jsp index bb003ff..3604d5c 100644 --- a/src/main/webapp/WEB-INF/views/party/partyWriteForm.jsp +++ b/src/main/webapp/WEB-INF/views/party/partyWriteForm.jsp @@ -31,6 +31,10 @@
번호 제목 작성자 날짜 조회수첨부파일
${i.count }${board.boardTitle }${board.boardTitle }${board.boardWriter }${board.bCreateDate }${board.boardCount } - - O - - - X - - ${party.partyTitle }${party.partyWriter }${party.pCreateDate }${party.partyCount }
- [이전] + [이전] @@ -63,20 +49,20 @@ ${p } - ${p } + ${p } - [다음] + [다음]
검색 결과가 없습니다.
-
+
- +
+ + + + diff --git a/src/main/webapp/resources/buploadFiles/20220918135151.png b/src/main/webapp/resources/buploadFiles/20220918135151.png new file mode 100644 index 0000000..67cce22 Binary files /dev/null and b/src/main/webapp/resources/buploadFiles/20220918135151.png differ diff --git a/src/main/webapp/resources/buploadFiles/20220918135556.png b/src/main/webapp/resources/buploadFiles/20220918135556.png new file mode 100644 index 0000000..67cce22 Binary files /dev/null and b/src/main/webapp/resources/buploadFiles/20220918135556.png differ diff --git a/src/main/webapp/resources/buploadFiles/20220918135724.png b/src/main/webapp/resources/buploadFiles/20220918135724.png new file mode 100644 index 0000000..7febff9 Binary files /dev/null and b/src/main/webapp/resources/buploadFiles/20220918135724.png differ diff --git a/src/main/webapp/resources/partyuploadFiles/20220916161551.png b/src/main/webapp/resources/partyuploadFiles/20220916161551.png new file mode 100644 index 0000000..67cce22 Binary files /dev/null and b/src/main/webapp/resources/partyuploadFiles/20220916161551.png differ diff --git a/src/main/webapp/resources/partyuploadFiles/20220916172802.png b/src/main/webapp/resources/partyuploadFiles/20220916172802.png new file mode 100644 index 0000000..67cce22 Binary files /dev/null and b/src/main/webapp/resources/partyuploadFiles/20220916172802.png differ diff --git a/src/main/webapp/resources/partyuploadFiles/20220916172803.png b/src/main/webapp/resources/partyuploadFiles/20220916172803.png new file mode 100644 index 0000000..67cce22 Binary files /dev/null and b/src/main/webapp/resources/partyuploadFiles/20220916172803.png differ diff --git a/src/main/webapp/resources/partyuploadFiles/20220916173855.png b/src/main/webapp/resources/partyuploadFiles/20220916173855.png new file mode 100644 index 0000000..67cce22 Binary files /dev/null and b/src/main/webapp/resources/partyuploadFiles/20220916173855.png differ diff --git a/src/main/webapp/resources/partyuploadFiles/20220916174124.png b/src/main/webapp/resources/partyuploadFiles/20220916174124.png new file mode 100644 index 0000000..7febff9 Binary files /dev/null and b/src/main/webapp/resources/partyuploadFiles/20220916174124.png differ diff --git a/src/main/webapp/resources/partyuploadFiles/20220919095555.png b/src/main/webapp/resources/partyuploadFiles/20220919095555.png new file mode 100644 index 0000000..67cce22 Binary files /dev/null and b/src/main/webapp/resources/partyuploadFiles/20220919095555.png differ diff --git a/src/main/webapp/resources/partyuploadFiles/20220919123551.png b/src/main/webapp/resources/partyuploadFiles/20220919123551.png new file mode 100644 index 0000000..67cce22 Binary files /dev/null and b/src/main/webapp/resources/partyuploadFiles/20220919123551.png differ
썸네일 등록
제목