-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- notice 패키지 . c,r,u 기능 추가 . 리스트 및 디테일 뷰 추가 - banner 패키지 . c기능 추가 . 리스트 추가 - 기타 . 쿼리문 수정으로 인한 mapper추가 및 변경
- Loading branch information
1 parent
05b2fd0
commit 7378865
Showing
40 changed files
with
1,265 additions
and
73 deletions.
There are no files selected for viewing
Binary file added
BIN
+710 Bytes
bin/src/main/java/com/kh/tripply/banner/controller/BannerController.class
Binary file not shown.
91 changes: 91 additions & 0 deletions
91
src/main/java/com/kh/tripply/banner/controller/BannerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Banner> 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; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 + "]"; | ||
} | ||
|
||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/kh/tripply/banner/service/BannerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Banner> printAllBanner(); | ||
} |
33 changes: 32 additions & 1 deletion
33
src/main/java/com/kh/tripply/banner/service/logic/BannerServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Banner> printAllBanner() { | ||
List<Banner> bList = bStore.selectAllBanner(session); | ||
return bList; | ||
} | ||
|
||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/kh/tripply/banner/store/BannerStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Banner> selectAllBanner(SqlSession session); | ||
|
||
} |
23 changes: 22 additions & 1 deletion
23
src/main/java/com/kh/tripply/banner/store/logic/BannerStoreLogic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Banner> selectAllBanner(SqlSession session) { | ||
List<Banner> bList = session.selectList("bannerMapper.selectAllBanner"); | ||
return bList; | ||
} | ||
|
||
} |
Oops, something went wrong.