이지우 - 기존 뉴스레터 게시판 이전 작업 중
This commit is contained in:
parent
59b9eb2904
commit
4156f96ab1
6
pom.xml
6
pom.xml
@ -623,6 +623,12 @@
|
|||||||
<version>2.5.0</version>
|
<version>2.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>joda-time</groupId>
|
||||||
|
<artifactId>joda-time</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@ -81,6 +81,10 @@ public class Criteria implements Serializable {
|
|||||||
/** 메뉴번호 */
|
/** 메뉴번호 */
|
||||||
private Integer menuNo;
|
private Integer menuNo;
|
||||||
|
|
||||||
|
/** 분쟁조정 as-is */
|
||||||
|
private int page;
|
||||||
|
private int perPageNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 기본생성자
|
* 기본생성자
|
||||||
*/
|
*/
|
||||||
@ -372,4 +376,33 @@ public class Criteria implements Serializable {
|
|||||||
return ToStringBuilder.reflectionToString(this);
|
return ToStringBuilder.reflectionToString(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPage(int page){
|
||||||
|
if(page <= 0){
|
||||||
|
this.page = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPerPageNum(int perPageNum){
|
||||||
|
if(perPageNum <= 0 || perPageNum > 100){
|
||||||
|
this.perPageNum = 10;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.perPageNum = perPageNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPage(){
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPageStart(){
|
||||||
|
return (this.page - 1) * perPageNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPerPageNum(){
|
||||||
|
return this.perPageNum;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
164
src/main/java/seed/com/gtm/board/CaseBoardController.java
Normal file
164
src/main/java/seed/com/gtm/board/CaseBoardController.java
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
package seed.com.gtm.board;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
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.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import kcc.com.cmm.util.Criteria;
|
||||||
|
import seed.com.gtm.seedfile.SeedFileService;
|
||||||
|
import seed.com.gtm.util.PageMaker;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/gtm/case")
|
||||||
|
public class CaseBoardController {
|
||||||
|
@Autowired
|
||||||
|
private CaseBoardService service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SeedFileService fileService;
|
||||||
|
|
||||||
|
public void setSessionMessageRemove(HttpSession session){
|
||||||
|
session.removeAttribute("url");
|
||||||
|
session.removeAttribute("message");
|
||||||
|
session.removeAttribute("opener");
|
||||||
|
session.removeAttribute("append");
|
||||||
|
session.removeAttribute("self");
|
||||||
|
}
|
||||||
|
|
||||||
|
// /gtm/case/board/form/write.do
|
||||||
|
@RequestMapping(value="/board/{boardIdx}/write.do", method=RequestMethod.GET)
|
||||||
|
public String formWrite(ModelMap model, @RequestParam Map<String,Object> paramMap, @PathVariable(value="boardIdx") String boardIdx){
|
||||||
|
paramMap.put("boardIdx", boardIdx);
|
||||||
|
return "/_extra/gtm/board/write";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/board/{boardIdx}/write.do", method=RequestMethod.POST)
|
||||||
|
public String formWrite(HttpServletRequest request ,HttpSession session, @RequestParam Map<String,Object> paramMap, Map<String, Object> map, @PathVariable(value="boardIdx") String boardIdx){
|
||||||
|
|
||||||
|
paramMap.put("memberName", session.getAttribute("memberName"));
|
||||||
|
paramMap.put("memberId", session.getAttribute("memberId"));
|
||||||
|
paramMap.put("boardIdx", boardIdx);
|
||||||
|
service.boardInsert(paramMap);
|
||||||
|
|
||||||
|
//현제 등록된 게시글의 시퀀스 불러와 맵에 저장
|
||||||
|
paramMap.put("dataIdx", paramMap.get("seq"));
|
||||||
|
fileService.fileInsert(paramMap, request, session);
|
||||||
|
|
||||||
|
map.put("message", "common.message.reg");
|
||||||
|
map.put("url", "/gtm/case/board/"+boardIdx+"/list.do");
|
||||||
|
|
||||||
|
return "/_common/jsp/message";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// /gtm/case/board/form/list.do
|
||||||
|
@RequestMapping("/board/{boardIdx}/list.do")
|
||||||
|
public String boardList(ModelMap model, HttpSession session, Criteria cri,@RequestParam Map<String,Object> paramMap, @PathVariable(value="boardIdx") String boardIdx){
|
||||||
|
|
||||||
|
//로그인페이지로 튕겨나가지 않게 우선은 임시방편
|
||||||
|
session.setAttribute("siteIdx", "case");
|
||||||
|
|
||||||
|
String menuName = "";
|
||||||
|
if(boardIdx.equals("form")){
|
||||||
|
menuName = "분쟁조정 관련 서식";
|
||||||
|
}else if(boardIdx.equals("law")){
|
||||||
|
menuName = "법령자료실";
|
||||||
|
}else if(boardIdx.equals("news")){
|
||||||
|
menuName = "뉴스레터 자료";
|
||||||
|
}else{
|
||||||
|
menuName = "공지사항";
|
||||||
|
}
|
||||||
|
session.setAttribute("menuName", menuName);
|
||||||
|
|
||||||
|
//페이징 관련
|
||||||
|
paramMap.put("pageStart", cri.getPageStart());
|
||||||
|
paramMap.put("perPageNum", cri.getPerPageNum());
|
||||||
|
paramMap.put("boardIdx", boardIdx);
|
||||||
|
|
||||||
|
List<Map<String,Object>> bbsList = service.boardList(paramMap);
|
||||||
|
List<Map<String,Object>> selectNotice = service.selectNotice(paramMap);
|
||||||
|
|
||||||
|
PageMaker pageMaker = new PageMaker();
|
||||||
|
pageMaker.setCri(cri);
|
||||||
|
pageMaker.setTotalCount(service.boardListCnt(paramMap));
|
||||||
|
|
||||||
|
model.addAttribute("boardIdx", boardIdx);
|
||||||
|
model.addAttribute("bbsList", bbsList);
|
||||||
|
model.addAttribute("selectNotice", selectNotice);
|
||||||
|
model.addAttribute("pageMaker", pageMaker);
|
||||||
|
|
||||||
|
return "/_extra/gtm/board/list";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/board/{boardIdx}/view.do")
|
||||||
|
public String boardView(ModelMap model, @RequestParam Map<String,Object> paramMap, @PathVariable(value="boardIdx") String boardIdx){
|
||||||
|
|
||||||
|
paramMap.put("dataIdx", paramMap.get("bbsNo"));
|
||||||
|
System.out.println(paramMap.get("bbsNo"));
|
||||||
|
model.addAttribute("bbsView", service.boardView(paramMap));
|
||||||
|
model.addAttribute("boardIdx", boardIdx);
|
||||||
|
model.addAttribute("fileList", fileService.fileList(paramMap));
|
||||||
|
|
||||||
|
return "/_extra/gtm/board/view";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/board/{boardIdx}/bbsDel.do")
|
||||||
|
public String boardDel(HttpSession session, @RequestParam Map<String,Object> paramMap, @PathVariable(value="boardIdx") String boardIdx, Map<String, Object> map){
|
||||||
|
paramMap.put("dataIdx", paramMap.get("bbsNo"));
|
||||||
|
service.boardDel(paramMap);
|
||||||
|
fileService.fileDelAll(paramMap);
|
||||||
|
this.setSessionMessageRemove(session);
|
||||||
|
|
||||||
|
map.put("message", "common.message.del");
|
||||||
|
map.put("url", "/gtm/case/board/"+boardIdx+"/list.do?searchType=" + paramMap.get("searchType") +
|
||||||
|
"&searchTilte=" + paramMap.get("searchTilte") + "&page=" + paramMap.get("page")
|
||||||
|
);
|
||||||
|
|
||||||
|
return "/_common/jsp/message";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/board/{boardIdx}/edit.do", method=RequestMethod.GET)
|
||||||
|
public String boardEdit(ModelMap model, @RequestParam Map<String,Object> paramMap, @PathVariable(value="boardIdx") String boardIdx){
|
||||||
|
|
||||||
|
|
||||||
|
paramMap.put("dataIdx", paramMap.get("bbsNo"));
|
||||||
|
List<Map<String, Object>> fileList = fileService.fileList(paramMap);
|
||||||
|
|
||||||
|
model.addAttribute("boardIdx", boardIdx);
|
||||||
|
model.addAttribute("bbsView", service.boardView(paramMap));
|
||||||
|
model.addAttribute("fileList", fileList);
|
||||||
|
model.addAttribute("fileListSize", fileList.size());
|
||||||
|
|
||||||
|
return "/_extra/gtm/board/edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/board/{boardIdx}/edit.do", method=RequestMethod.POST)
|
||||||
|
public String boardEdit(HttpSession session, HttpServletRequest request, @RequestParam Map<String,Object> paramMap, @PathVariable(value="boardIdx") String boardIdx, Map<String, Object> map){
|
||||||
|
paramMap.put("memberId", session.getAttribute("memberId"));
|
||||||
|
paramMap.put("dataIdx", paramMap.get("bbsNo"));//fileInsert에서 필요
|
||||||
|
|
||||||
|
service.boardUpdate(paramMap);
|
||||||
|
fileService.fileInsert(paramMap, request, session);
|
||||||
|
fileService.fileDel(paramMap);
|
||||||
|
|
||||||
|
|
||||||
|
this.setSessionMessageRemove(session);
|
||||||
|
map.put("message", "common.message.mod");
|
||||||
|
map.put("url", "/gtm/case/board/"+boardIdx+"/view.do?bbsNo=" + paramMap.get("bbsNo") +
|
||||||
|
"&searchType=" + paramMap.get("searchType") + "&searchTilte=" + paramMap.get("searchTilte") + "&page=" + paramMap.get("page")+
|
||||||
|
"&fileFuncType=" + paramMap.get("fileFuncType")
|
||||||
|
);
|
||||||
|
|
||||||
|
return "/_common/jsp/message";
|
||||||
|
}
|
||||||
|
}
|
||||||
50
src/main/java/seed/com/gtm/board/CaseBoardService.java
Normal file
50
src/main/java/seed/com/gtm/board/CaseBoardService.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package seed.com.gtm.board;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import seed.com.gtm.dao.BoardDaoImpl;
|
||||||
|
@Service
|
||||||
|
public class CaseBoardService {
|
||||||
|
@Autowired
|
||||||
|
private BoardDaoImpl dao;
|
||||||
|
|
||||||
|
public void boardInsert(Map<String, Object> paramMap){
|
||||||
|
dao.boardInsert(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int boardNo(Map<String, Object> paramMap){
|
||||||
|
return dao.boardNo(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, Object>> boardList(Map<String, Object> paramMap){
|
||||||
|
return dao.boardList(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int boardListCnt(Map<String, Object> paramMap){
|
||||||
|
return dao.boardListCnt(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, Object>> selectNotice(Map<String, Object> paramMap){
|
||||||
|
return dao.selectNotice(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> boardView(Map<String, Object> paramMap){
|
||||||
|
return dao.boardView(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void boardDel(Map<String, Object> paramMap){
|
||||||
|
dao.boardDel(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void boardUpdate(Map<String, Object> paramMap){
|
||||||
|
dao.boardUpdate(paramMap);
|
||||||
|
}
|
||||||
|
public void cntUpdate(Map<String, Object> paramMap){
|
||||||
|
dao.cntUpdate(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
15
src/main/java/seed/com/gtm/code/CodeDao.java
Normal file
15
src/main/java/seed/com/gtm/code/CodeDao.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package seed.com.gtm.code;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
|
|
||||||
|
public interface CodeDao {
|
||||||
|
List<?> list(EgovMap params);
|
||||||
|
Object select(EgovMap params);
|
||||||
|
void insert(EgovMap params);
|
||||||
|
int update(EgovMap params);
|
||||||
|
int delete(EgovMap params);
|
||||||
|
int updown(EgovMap params);
|
||||||
|
}
|
||||||
69
src/main/java/seed/com/gtm/code/CodeDaoImpl.java
Normal file
69
src/main/java/seed/com/gtm/code/CodeDaoImpl.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package seed.com.gtm.code;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class CodeDaoImpl implements CodeDao {
|
||||||
|
protected Log log = LogFactory.getLog(this.getClass());
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SqlSession sqlSession;
|
||||||
|
|
||||||
|
/*@Override
|
||||||
|
public void boardInsert(Map<String, Object> paramMap) {
|
||||||
|
sqlSession.insert("faqbbs.insert", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> boardList(Map<String, Object> paramMap) {
|
||||||
|
List<Map<String, Object>> boardList = sqlSession.selectList("faqbbs.select", paramMap);
|
||||||
|
return boardList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> boardView(Map<String, Object> paramMap) {
|
||||||
|
Map<String, Object> boardView = sqlSession.selectOne("faqbbs.selectOne", paramMap);
|
||||||
|
return boardView;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List list(EgovMap params) {
|
||||||
|
return sqlSession.selectList("code.selectList", params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object select(EgovMap params) {
|
||||||
|
return sqlSession.selectOne("code.selectOne", params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insert(EgovMap params) {
|
||||||
|
sqlSession.insert("code.insertCode", params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(EgovMap params) {
|
||||||
|
return sqlSession.update("code.updateCode", params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int delete(EgovMap params) {
|
||||||
|
return sqlSession.delete("code.deleteCode", params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updown(EgovMap params) {
|
||||||
|
return sqlSession.update("code.updownCode", params);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
85
src/main/java/seed/com/gtm/code/CodeService.java
Normal file
85
src/main/java/seed/com/gtm/code/CodeService.java
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package seed.com.gtm.code;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CodeService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CodeDaoImpl dao;
|
||||||
|
|
||||||
|
/*public void boardInsert(Map<String, Object> paramMap){
|
||||||
|
dao.boardInsert(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String,Object>> boardList(Map<String, Object> paramMap){
|
||||||
|
List<Map<String,Object>> boardList = dao.boardList(paramMap);
|
||||||
|
return boardList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String,Object> boardView(Map<String, Object> paramMap){
|
||||||
|
Map<String,Object> boardView = dao.boardView(paramMap);
|
||||||
|
System.out.println(paramMap.get(""));
|
||||||
|
System.out.println(boardView);
|
||||||
|
return boardView;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 코드리스트
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<?> CodeList(EgovMap params){
|
||||||
|
return dao.list(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 코드단일출력
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object selectCode(EgovMap params){
|
||||||
|
return dao.select(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 코드입력
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
void inserCode(EgovMap params){
|
||||||
|
dao.insert(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 코드업데이트
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int updateCode(EgovMap params){
|
||||||
|
return dao.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 코드삭제
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int deleteCode(EgovMap params){
|
||||||
|
return dao.delete(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 코드 순서변경
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int updownCode(EgovMap params){
|
||||||
|
return dao.updown(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/main/java/seed/com/gtm/dao/BoardDao.java
Normal file
16
src/main/java/seed/com/gtm/dao/BoardDao.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package seed.com.gtm.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface BoardDao {
|
||||||
|
public void boardInsert(Map<String,Object> paramMap);
|
||||||
|
public int boardNo(Map<String,Object> paramMap);
|
||||||
|
public List<Map<String,Object>> boardList(Map<String,Object> paramMap);
|
||||||
|
public int boardListCnt(Map<String,Object> paramMap);
|
||||||
|
public List<Map<String,Object>> selectNotice(Map<String,Object> paramMap);
|
||||||
|
public Map<String,Object> boardView(Map<String,Object> paramMap);
|
||||||
|
public void boardDel(Map<String,Object> paramMap);
|
||||||
|
public void boardUpdate(Map<String,Object> paramMap);
|
||||||
|
public void cntUpdate(Map<String,Object> paramMap);
|
||||||
|
}
|
||||||
60
src/main/java/seed/com/gtm/dao/BoardDaoImpl.java
Normal file
60
src/main/java/seed/com/gtm/dao/BoardDaoImpl.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package seed.com.gtm.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class BoardDaoImpl implements BoardDao {
|
||||||
|
@Autowired
|
||||||
|
private SqlSession sqlSession;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void boardInsert(Map<String, Object> paramMap) {
|
||||||
|
sqlSession.insert("form.board.insert", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int boardNo(Map<String, Object> paramMap) {
|
||||||
|
return sqlSession.selectOne("form.board.selectNo", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> boardList(Map<String, Object> paramMap) {
|
||||||
|
return sqlSession.selectList("form.board.select", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int boardListCnt(Map<String, Object> paramMap) {
|
||||||
|
return sqlSession.selectOne("form.board.selectCnt", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> selectNotice(Map<String, Object> paramMap){
|
||||||
|
return sqlSession.selectList("form.board.selectNotice", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> boardView(Map<String, Object> paramMap) {
|
||||||
|
return sqlSession.selectOne("form.board.selectOne", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void boardDel(Map<String, Object> paramMap) {
|
||||||
|
sqlSession.delete("form.board.delete", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void boardUpdate(Map<String, Object> paramMap) {
|
||||||
|
sqlSession.update("form.board.update", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cntUpdate(Map<String, Object> paramMap) {
|
||||||
|
sqlSession.update("form.board.cntUpdate", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
20
src/main/java/seed/com/gtm/dao/SeedFileDao.java
Normal file
20
src/main/java/seed/com/gtm/dao/SeedFileDao.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package seed.com.gtm.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
|
|
||||||
|
public interface SeedFileDao {
|
||||||
|
public void fileInsert(Map<String, Object> paramMap);
|
||||||
|
public List<Map<String, Object>> fileList(Map<String, Object> paramMap);
|
||||||
|
public Map<String, Object> fileOne(Map<String, Object> paramMap);
|
||||||
|
public void fileDel(Map<String, Object> paramMap);
|
||||||
|
public void fileDelAll(Map<String, Object> paramMap);
|
||||||
|
public void caseInsert(Map<String, Object> paramMap);
|
||||||
|
public List<Map<String, Object>> caseFileList(Map<String, Object> paramMap);
|
||||||
|
public List<EgovMap> caseFileListEgov(EgovMap paramMap);
|
||||||
|
public Map<String, Object> caseFileOne(Map<String, Object> paramMap);
|
||||||
|
public void caseDelete(Map<String, Object> paramMap);
|
||||||
|
public void hisInsert(Map<String, Object> paramMap);
|
||||||
|
}
|
||||||
73
src/main/java/seed/com/gtm/dao/SeedFileDaoImpl.java
Normal file
73
src/main/java/seed/com/gtm/dao/SeedFileDaoImpl.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package seed.com.gtm.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class SeedFileDaoImpl implements SeedFileDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SqlSession sqlSession;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fileInsert(Map<String, Object> paramMap) {
|
||||||
|
sqlSession.insert("com.seed.file.insert", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> fileList(Map<String, Object> paramMap) {
|
||||||
|
return sqlSession.selectList("com.seed.file.select", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> fileOne(Map<String, Object> paramMap) {
|
||||||
|
return sqlSession.selectOne("com.seed.file.selectOne", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fileDel(Map<String, Object> paramMap) {
|
||||||
|
sqlSession.update("com.seed.file.delete", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fileDelAll(Map<String, Object> paramMap) {
|
||||||
|
sqlSession.update("com.seed.file.deleteAll", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void caseInsert(Map<String, Object> paramMap) {
|
||||||
|
sqlSession.insert("com.seed.file.caseInsert", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> caseFileList(Map<String, Object> paramMap) {
|
||||||
|
return sqlSession.selectList("com.seed.file.selectCase", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EgovMap> caseFileListEgov(EgovMap paramMap) {
|
||||||
|
return sqlSession.selectList("com.seed.file.selectCaseEgov", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> caseFileOne(Map<String, Object> paramMap) {
|
||||||
|
return sqlSession.selectOne("com.seed.file.caseFileOne", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void caseDelete(Map<String, Object> paramMap) {
|
||||||
|
sqlSession.update("com.seed.file.caseDelete", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hisInsert(Map<String, Object> paramMap) {
|
||||||
|
sqlSession.insert("com.seed.file.hisInsert", paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
265
src/main/java/seed/com/gtm/seedfile/SeedFileService.java
Normal file
265
src/main/java/seed/com/gtm/seedfile/SeedFileService.java
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
package seed.com.gtm.seedfile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
|
import seed.com.gtm.dao.SeedFileDao;
|
||||||
|
import seed.com.gtm.service.BaseService;
|
||||||
|
import seed.utils.SeedDateUtil;
|
||||||
|
import seed.utils.SeedProperties;
|
||||||
|
import seed.utils.SeedUtils;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SeedFileService {
|
||||||
|
@Autowired
|
||||||
|
private SeedFileDao dao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BaseService bservice;
|
||||||
|
|
||||||
|
public void fileInsert(Map<String, Object> paramMap, HttpServletRequest request, HttpSession session){
|
||||||
|
|
||||||
|
String siteIdx = SeedUtils.setReplaceNull(session.getAttribute("siteIdx"));
|
||||||
|
if(siteIdx.equals("")){
|
||||||
|
siteIdx = SeedUtils.setReplaceNull(request.getParameter("siteIdx"));
|
||||||
|
}
|
||||||
|
String fileFuncType = (String)paramMap.get("fileFuncType");
|
||||||
|
|
||||||
|
SeedProperties seedProperties = new SeedProperties();
|
||||||
|
|
||||||
|
String rootPath = null;
|
||||||
|
String tempPath = seedProperties.getConfigValue("file.temp.path");
|
||||||
|
if(fileFuncType.equals("trublchargermng")){
|
||||||
|
rootPath = seedProperties.getConfigValue("root.path");
|
||||||
|
}else{
|
||||||
|
rootPath = seedProperties.getConfigValue("file.real.path");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SeedDateUtil seedDateUtil = new SeedDateUtil();
|
||||||
|
String toDate = seedDateUtil.getSimpleDateFormat(new Date(), "yyyyMMdd");
|
||||||
|
String renameDate = seedDateUtil.getSimpleDateFormat(new Date(), "yyyyMMddHHmmss");
|
||||||
|
|
||||||
|
SeedUtils.setSeedMkDirs(rootPath + "/"+siteIdx+ "/" +fileFuncType);
|
||||||
|
|
||||||
|
int fileCnt = 0;
|
||||||
|
|
||||||
|
String[] uploadFileName = request.getParameterValues("uploadFileName");
|
||||||
|
String[] uploadFileReName = request.getParameterValues("uploadFileReName");
|
||||||
|
String[] copyContractYnList = request.getParameterValues("copyContractYn");
|
||||||
|
if(uploadFileName!=null && uploadFileName.length > 0){
|
||||||
|
|
||||||
|
for(int i=0; i<uploadFileName.length; i++){
|
||||||
|
|
||||||
|
String uploadFileNameData = uploadFileName[i];
|
||||||
|
String uploadFileReNameData = uploadFileReName[i];
|
||||||
|
String copyContractYn = "";
|
||||||
|
if(copyContractYnList != null){
|
||||||
|
copyContractYn = copyContractYnList[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
String fileType = uploadFileNameData.substring(uploadFileNameData.lastIndexOf(".")+1, uploadFileNameData.length());
|
||||||
|
String reFileName = renameDate + "_" + SeedUtils.getSeedMD5Code(String.valueOf(SeedUtils.getRandom(999,1)));
|
||||||
|
|
||||||
|
File oldFile = null;
|
||||||
|
if(fileFuncType.equals("trublchargermng")){
|
||||||
|
oldFile = new File(rootPath + "/"+siteIdx+"/upload/tempFiles/"+fileFuncType+ "/" + uploadFileReNameData);
|
||||||
|
}else{
|
||||||
|
oldFile = new File(tempPath + "/"+siteIdx+"/"+fileFuncType+ "/" + uploadFileReNameData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(oldFile.exists()){
|
||||||
|
Long fileSize = oldFile.length();
|
||||||
|
String filePath ="";
|
||||||
|
if(fileFuncType.equals("trublchargermng")){
|
||||||
|
SeedUtils.setSeedFileCopy(rootPath + "/"+siteIdx+"/upload/tempFiles/"+fileFuncType+ "/" + uploadFileReNameData,
|
||||||
|
rootPath + "/"+siteIdx+"/upload/uploadFiles/"+fileFuncType+"/"+reFileName+"."+fileType);
|
||||||
|
|
||||||
|
filePath = rootPath + "/"+siteIdx+"/upload/uploadFiles/"+fileFuncType+"/"+reFileName+"."+fileType;
|
||||||
|
}else{
|
||||||
|
SeedUtils.setSeedFileCopy(tempPath + "/"+siteIdx+"/"+fileFuncType + "/" + uploadFileReNameData,
|
||||||
|
rootPath + "/"+siteIdx+"/"+fileFuncType+"/"+reFileName+"."+fileType);
|
||||||
|
|
||||||
|
filePath = rootPath + "/"+siteIdx+"/"+fileFuncType+"/"+reFileName+"."+fileType;
|
||||||
|
}
|
||||||
|
|
||||||
|
paramMap.put("uploadFileNameData", uploadFileNameData);
|
||||||
|
paramMap.put("reFileName", reFileName+"."+fileType);
|
||||||
|
paramMap.put("fileSize", fileSize);
|
||||||
|
paramMap.put("fileType", fileType);
|
||||||
|
paramMap.put("filePath", filePath);
|
||||||
|
paramMap.put("copyContractYn", copyContractYn);
|
||||||
|
//파일타입에 따라서 sql분기
|
||||||
|
if(fileFuncType.equals("mediation")){
|
||||||
|
dao.caseInsert(paramMap);
|
||||||
|
}else{
|
||||||
|
dao.fileInsert(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
oldFile.delete();
|
||||||
|
fileCnt = fileCnt+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fileInsertEgov(EgovMap paramMap, HttpServletRequest request, HttpSession session)throws Exception {
|
||||||
|
System.out.println(">>>>>>>fileInsertEgov<<<<<<<<<");
|
||||||
|
try {
|
||||||
|
|
||||||
|
String siteIdx = SeedUtils.setReplaceNull(session.getAttribute("siteIdx"));
|
||||||
|
if(siteIdx.equals("")){
|
||||||
|
siteIdx = SeedUtils.setReplaceNull(request.getParameter("siteIdx"));
|
||||||
|
}
|
||||||
|
String fileFuncType = (String)paramMap.get("fileFuncType");
|
||||||
|
|
||||||
|
SeedProperties seedProperties = new SeedProperties();
|
||||||
|
|
||||||
|
String rootPath = seedProperties.getConfigValue("file.real.path");
|
||||||
|
String tempPath = seedProperties.getConfigValue("file.temp.path");
|
||||||
|
|
||||||
|
SeedDateUtil seedDateUtil = new SeedDateUtil();
|
||||||
|
String toDate = seedDateUtil.getSimpleDateFormat(new Date(), "yyyyMMdd");
|
||||||
|
String renameDate = seedDateUtil.getSimpleDateFormat(new Date(), "yyyyMMddHHmmss");
|
||||||
|
|
||||||
|
SeedUtils.setSeedMkDirs(rootPath + "/"+siteIdx+ "/" +fileFuncType);
|
||||||
|
|
||||||
|
int fileCnt = 0;
|
||||||
|
|
||||||
|
String[] uploadFileName = request.getParameterValues("uploadFileName");
|
||||||
|
String[] uploadFileReName = request.getParameterValues("uploadFileReName");
|
||||||
|
String[] copyContractYnList = request.getParameterValues("copyContractYn");
|
||||||
|
String[] fileGubun = request.getParameterValues("fileGubun");
|
||||||
|
String[] fileMemo = request.getParameterValues("fileMemo");
|
||||||
|
|
||||||
|
if(uploadFileName!=null && uploadFileName.length > 0){
|
||||||
|
|
||||||
|
for(int i=0; i<uploadFileName.length; i++){
|
||||||
|
|
||||||
|
String uploadFileNameData = uploadFileName[i];
|
||||||
|
String uploadFileReNameData = uploadFileReName[i];
|
||||||
|
String fileGubunData = fileGubun[i];
|
||||||
|
String fileMemoData = "";
|
||||||
|
|
||||||
|
if(fileMemo !=null && fileMemo.length > 0){
|
||||||
|
if(uploadFileName.length == fileMemo.length){
|
||||||
|
fileMemoData = fileMemo[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String copyContractYn = "";
|
||||||
|
if(copyContractYnList != null){
|
||||||
|
copyContractYn = copyContractYnList[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
String fileType = uploadFileNameData.substring(uploadFileNameData.lastIndexOf(".")+1, uploadFileNameData.length());
|
||||||
|
String reFileName = renameDate + "_" + SeedUtils.getSeedMD5Code(String.valueOf(SeedUtils.getRandom(999,1)));
|
||||||
|
|
||||||
|
File oldFile = new File(tempPath + "/"+siteIdx+"/"+fileFuncType+ "/" + uploadFileReNameData);
|
||||||
|
System.out.println(">>>>>>>fileInsertEgov0<<<<<<<<<"+tempPath + "/"+siteIdx+"/"+fileFuncType+ "/" + uploadFileReNameData);
|
||||||
|
if(oldFile.exists()){
|
||||||
|
|
||||||
|
Long fileSize = oldFile.length();
|
||||||
|
|
||||||
|
SeedUtils.setSeedFileCopy(tempPath + "/"+siteIdx+"/"+fileFuncType + "/" + uploadFileReNameData,
|
||||||
|
rootPath + "/"+siteIdx+"/"+fileFuncType+"/"+reFileName+"."+fileType);
|
||||||
|
|
||||||
|
|
||||||
|
paramMap.put("uploadFileNameData", uploadFileNameData);
|
||||||
|
paramMap.put("reFileName", reFileName+"."+fileType);
|
||||||
|
paramMap.put("fileSize", fileSize);
|
||||||
|
paramMap.put("fileType", fileType);
|
||||||
|
paramMap.put("filePath", rootPath + "/"+siteIdx+"/"+fileFuncType+"/");
|
||||||
|
paramMap.put("copyContractYn", copyContractYn);
|
||||||
|
paramMap.put("fileGubun", fileGubunData);
|
||||||
|
paramMap.put("fileMemo", fileMemoData);
|
||||||
|
//파일타입에 따라서 sql분기
|
||||||
|
/*if(fileFuncType.equals("mediation")){
|
||||||
|
dao.caseInsert(paramMap);
|
||||||
|
}else{
|
||||||
|
dao.fileInsert(paramMap);
|
||||||
|
}*/
|
||||||
|
System.out.println(">>>>>>>fileInsertEgov1<<<<<<<<<");
|
||||||
|
bservice.insert(paramMap);
|
||||||
|
System.out.println(">>>>>>>fileInsertEgov2<<<<<<<<<");
|
||||||
|
|
||||||
|
oldFile.delete();
|
||||||
|
fileCnt = fileCnt+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, Object>> fileList(Map<String,Object> paramMap){
|
||||||
|
return dao.fileList(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> fileOne(Map<String,Object> paramMap){
|
||||||
|
return dao.fileOne(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*일반 게시판 파일 (T_EXTRA_FILE)*/
|
||||||
|
public void fileDel(Map<String,Object> paramMap){
|
||||||
|
if(paramMap.get("deleteFileData") != "" && paramMap.get("deleteFileData") != null){
|
||||||
|
|
||||||
|
String delIdx = (String)paramMap.get("deleteFileData");
|
||||||
|
String[] delList = delIdx.split(",");
|
||||||
|
|
||||||
|
for(int i = 0; i < delList.length; i++){
|
||||||
|
paramMap.put("dataIdx", delList[i]);
|
||||||
|
dao.fileDel(paramMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*사건관련 파일 (C_CASEFILE)*/
|
||||||
|
public void caseFileDel(Map<String,Object> paramMap){
|
||||||
|
if(paramMap.get("deleteFileData") != "" && paramMap.get("deleteFileData") != null){
|
||||||
|
|
||||||
|
String delIdx = (String)paramMap.get("deleteFileData");
|
||||||
|
String[] delList = delIdx.split(",");
|
||||||
|
for(int i = 0; i < delList.length; i++){
|
||||||
|
paramMap.put("dataIdx", delList[i]);
|
||||||
|
dao.caseDelete(paramMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fileDelAll(Map<String,Object> paramMap){
|
||||||
|
dao.fileDelAll(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, Object>> caseFileList(Map<String,Object> paramMap){
|
||||||
|
return dao.caseFileList(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EgovMap> caseFileListEgov(EgovMap paramMap){
|
||||||
|
return dao.caseFileListEgov(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> caseFileOne(Map<String,Object> paramMap){
|
||||||
|
return dao.caseFileOne(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hisInsert(Map<String,Object> paramMap){
|
||||||
|
dao.hisInsert(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
15
src/main/java/seed/com/gtm/service/BaseDao.java
Normal file
15
src/main/java/seed/com/gtm/service/BaseDao.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package seed.com.gtm.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
|
|
||||||
|
public interface BaseDao {
|
||||||
|
List<?> list(EgovMap params);
|
||||||
|
Object select(EgovMap params);
|
||||||
|
Object insert(EgovMap params);
|
||||||
|
Object update(EgovMap params);
|
||||||
|
Object delete(EgovMap params);
|
||||||
|
Object updown(EgovMap params);
|
||||||
|
}
|
||||||
56
src/main/java/seed/com/gtm/service/BaseDaoImpl.java
Normal file
56
src/main/java/seed/com/gtm/service/BaseDaoImpl.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package seed.com.gtm.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class BaseDaoImpl implements BaseDao {
|
||||||
|
protected Log log = LogFactory.getLog(this.getClass());
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SqlSession sqlSession;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List list(EgovMap params) {
|
||||||
|
return sqlSession.selectList(params.get("sql").toString(), params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object select(EgovMap params) {
|
||||||
|
return sqlSession.selectOne(params.get("sql").toString(), params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object insert(EgovMap params) {
|
||||||
|
return sqlSession.insert(params.get("sql").toString(), params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object update(EgovMap params) {
|
||||||
|
System.out.println(">>>>>>>>>>BaseDaoImpl<<<<<<< update");
|
||||||
|
System.out.println("sql:"+params.get("sql").toString());
|
||||||
|
System.out.println("caseNo:"+params.get("caseNo"));
|
||||||
|
return sqlSession.update(params.get("sql").toString(), params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object delete(EgovMap params) {
|
||||||
|
return sqlSession.delete(params.get("sql").toString(), params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object updown(EgovMap params) {
|
||||||
|
return sqlSession.update(params.get("sql").toString(), params);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
68
src/main/java/seed/com/gtm/service/BaseService.java
Normal file
68
src/main/java/seed/com/gtm/service/BaseService.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package seed.com.gtm.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import seed.com.gtm.code.CodeDaoImpl;
|
||||||
|
|
||||||
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class BaseService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BaseDaoImpl dao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 리스트
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<?> list(EgovMap params){
|
||||||
|
System.out.println("list sql = " + params.get("sql"));
|
||||||
|
return dao.list(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 단일출력
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object select(EgovMap params){
|
||||||
|
System.out.println("select sql = " + params.get("sql"));
|
||||||
|
return dao.select(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 입력
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
public Object insert(EgovMap params){
|
||||||
|
System.out.println("insert sql = " + params.get("sql"));
|
||||||
|
return dao.insert(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 업데이트
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object update(EgovMap params){
|
||||||
|
System.out.println("update sql = " + params.get("sql"));
|
||||||
|
return dao.update(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 삭제
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object delete(EgovMap params){
|
||||||
|
System.out.println("delete sql = " + params.get("sql"));
|
||||||
|
return dao.delete(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
68
src/main/java/seed/com/gtm/util/PageMaker.java
Normal file
68
src/main/java/seed/com/gtm/util/PageMaker.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package seed.com.gtm.util;
|
||||||
|
|
||||||
|
import kcc.com.cmm.util.Criteria;
|
||||||
|
|
||||||
|
public class PageMaker {
|
||||||
|
private int totalCount;
|
||||||
|
private int startPage;
|
||||||
|
private int endPage;
|
||||||
|
private boolean prev;
|
||||||
|
private boolean next;
|
||||||
|
|
||||||
|
private int displayPageNum = 10;
|
||||||
|
private Criteria cri;
|
||||||
|
|
||||||
|
public void setCri(Criteria cri){
|
||||||
|
this.cri = cri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalCount(int totalCount){
|
||||||
|
this.totalCount = totalCount;
|
||||||
|
|
||||||
|
calcData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calcData(){
|
||||||
|
|
||||||
|
endPage = (int)(Math.ceil(cri.getPage() / (double)displayPageNum) * displayPageNum);
|
||||||
|
|
||||||
|
startPage = (endPage - displayPageNum) + 1;
|
||||||
|
|
||||||
|
int tempEndPage = (int)(Math.ceil(totalCount / (double)cri.getPerPageNum()));
|
||||||
|
|
||||||
|
if(endPage > tempEndPage){
|
||||||
|
endPage = tempEndPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
prev = (cri.getPage() == 1) ? false : true;
|
||||||
|
next = (cri.getPage() * cri.getPerPageNum() >= totalCount) ? false : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalCount() {
|
||||||
|
return totalCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStartPage() {
|
||||||
|
return startPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEndPage() {
|
||||||
|
return endPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPrev() {
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNext() {
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDisplayPageNum() {
|
||||||
|
return displayPageNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria getCri(){
|
||||||
|
return cri;
|
||||||
|
}
|
||||||
|
}
|
||||||
263
src/main/java/seed/utils/SeedDateUtil.java
Normal file
263
src/main/java/seed/utils/SeedDateUtil.java
Normal file
@ -0,0 +1,263 @@
|
|||||||
|
package seed.utils;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
import org.joda.time.Days;
|
||||||
|
import org.joda.time.format.DateTimeFormat;
|
||||||
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
public class SeedDateUtil {
|
||||||
|
private DateTime dateTime;
|
||||||
|
|
||||||
|
|
||||||
|
public SeedDateUtil(){}
|
||||||
|
|
||||||
|
public SeedDateUtil(Date date){
|
||||||
|
dateTime = new DateTime(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void defaultDateSetting(Date date){
|
||||||
|
dateTime = new DateTime(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* year, month 정보를 전달 받아서 DateTime을 초기화 하는 메소드
|
||||||
|
* 일/시/분 은 1일/12시/0분으로 기본 설정 합니다.
|
||||||
|
* @param int year 년
|
||||||
|
* @param int month 월
|
||||||
|
* */
|
||||||
|
public void defaultDateSetting(int year, int month){
|
||||||
|
dateTime = new DateTime(year, month, 1, 12, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getYear(){
|
||||||
|
return dateTime.getYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMonth(){
|
||||||
|
return dateTime.getMonthOfYear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDay(){
|
||||||
|
return dateTime.getDayOfMonth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBeginningDayOfWeek(){
|
||||||
|
return dateTime.dayOfMonth().withMinimumValue().getDayOfWeek();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLastDayOfMonth(){
|
||||||
|
return dateTime.dayOfMonth().withMaximumValue().getDayOfMonth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastDayOfMonthToString(){
|
||||||
|
int curData= dateTime.dayOfMonth().withMaximumValue().getDayOfMonth();
|
||||||
|
if(curData<10){
|
||||||
|
return "0"+curData;
|
||||||
|
}else{
|
||||||
|
return String.valueOf(curData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHour(){
|
||||||
|
return dateTime.getHourOfDay();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinute(){
|
||||||
|
return dateTime.getMinuteOfHour();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getYearToString(){
|
||||||
|
int curYear = dateTime.getYear();
|
||||||
|
return String.valueOf(curYear);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 10이하의 값은 앞에 0을 붙이게 됩니다.
|
||||||
|
* */
|
||||||
|
public String getMonthToString(){
|
||||||
|
int curMonth = dateTime.getMonthOfYear();
|
||||||
|
if(curMonth<10){
|
||||||
|
return "0"+curMonth;
|
||||||
|
}else{
|
||||||
|
return String.valueOf(curMonth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMonthToStringDefault(){
|
||||||
|
int curMonth = dateTime.getMonthOfYear();
|
||||||
|
return String.valueOf(curMonth);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 10이하의 값은 앞에 0을 붙이게 됩니다.
|
||||||
|
* */
|
||||||
|
public String getDayToString(){
|
||||||
|
int curDay = dateTime.getDayOfMonth();
|
||||||
|
if(curDay<10){
|
||||||
|
return "0"+curDay;
|
||||||
|
}else{
|
||||||
|
return String.valueOf(curDay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDayToStringDefault(){
|
||||||
|
int curDay = dateTime.getDayOfMonth();
|
||||||
|
return String.valueOf(curDay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSimpleDateFormat(String dateFormat){
|
||||||
|
DateTimeFormatter dateTimeFormat = DateTimeFormat.forPattern(dateFormat);
|
||||||
|
return dateTime.toString(dateTimeFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSimpleDateFormat(Date date, String dateFormat){
|
||||||
|
DateTimeFormatter dateTimeFormat = DateTimeFormat.forPattern(dateFormat);
|
||||||
|
return new DateTime(date).toString(dateTimeFormat);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 전달 받은 Date의 year,month,day에 해당하는 margin만큰 지난 날짜를 반환하는
|
||||||
|
* 메소드
|
||||||
|
* */
|
||||||
|
public Date dayCalForStr(Date date, int margin, String mode){
|
||||||
|
DateTime calDateTime = new DateTime(date);
|
||||||
|
if(mode.endsWith("year")){
|
||||||
|
calDateTime.plusYears(margin);
|
||||||
|
}else if(mode.endsWith("month")){
|
||||||
|
calDateTime.plusMonths(margin);
|
||||||
|
}else{
|
||||||
|
calDateTime.plusDays(margin);
|
||||||
|
}
|
||||||
|
return calDateTime.toDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 전달 받은 year, month, day의 year,month,day에 해당하는 margin만큰 지난 날짜를 반환하는
|
||||||
|
* 시/분 은 12시0분으로 자동 셋팅
|
||||||
|
* 메소드
|
||||||
|
* */
|
||||||
|
public Date dayCalForStr(int year, int month, int day, int margin, String mode){
|
||||||
|
DateTime calDateTime = new DateTime(year, month, day, 12, 0);
|
||||||
|
if(mode.endsWith("year")){
|
||||||
|
calDateTime = calDateTime.plusYears(margin);
|
||||||
|
}else if(mode.endsWith("month")){
|
||||||
|
calDateTime = calDateTime.plusMonths(margin);
|
||||||
|
}else{
|
||||||
|
calDateTime = calDateTime.plusDays(margin);
|
||||||
|
}
|
||||||
|
return calDateTime.toDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 생성시 설정된 date의 year,month,day에 해당하는 margin만큰 지난 날짜를 반환하는
|
||||||
|
* 메소드
|
||||||
|
* */
|
||||||
|
public Date dayCalForStr(int margin, String mode){
|
||||||
|
DateTime calDateTime = dateTime;
|
||||||
|
if(mode.endsWith("year")){
|
||||||
|
calDateTime = calDateTime.plusYears(margin);
|
||||||
|
}else if(mode.endsWith("month")){
|
||||||
|
calDateTime = calDateTime.plusMonths(margin);
|
||||||
|
}else{
|
||||||
|
calDateTime = calDateTime.plusDays(margin);
|
||||||
|
}
|
||||||
|
return calDateTime.toDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 전달 받은 날짜(targetDate-yyyy-mm-dd)가 현재 날짜 기준으로 checkNum(날짜) 기준안의 글인지 체크 하는 메소드
|
||||||
|
* checkNum 날짜 보다 더 전의 글은 false 안의 글이면 true
|
||||||
|
* */
|
||||||
|
public boolean marginCheck(String dateStr, int checkNum){
|
||||||
|
DateTime checkDateTime = new DateTime(dateStr);
|
||||||
|
Days checkDays = Days.daysBetween(checkDateTime, dateTime);
|
||||||
|
int checkCnt = checkDays.getDays();
|
||||||
|
if(checkCnt>checkNum){
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 전달 받은 날짜(targetDate-yyyy-mm-dd)가 (checkDate-yyyy-mm-dd)기준으로 checkNum(날짜) 기준안의 날짜인지 체크 하는 메소드
|
||||||
|
* checkNum 날짜 보다 더 전의 날짜는 true 안의 날짜면 false
|
||||||
|
* */
|
||||||
|
public boolean marginCheck(String checkDate, String targetDate, int checkNum){
|
||||||
|
DateTime checkDateTime = new DateTime(checkDate);
|
||||||
|
DateTime targetDateTime = new DateTime(targetDate);
|
||||||
|
Days checkDays = Days.daysBetween(checkDateTime, targetDateTime);
|
||||||
|
int checkCnt = checkDays.getDays();
|
||||||
|
if(checkCnt>checkNum){
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 전달 받은 날짜(targetDate yyyy-mm-dd, hour, minute)가 현재 날짜 기준으로 이전인지 이후 인지 체크하는 메소드
|
||||||
|
* 현재 날짜 보다 이전일 경우 false 이후 이면 true
|
||||||
|
* */
|
||||||
|
public boolean atferDateCheck(String targetDate, String hour, String minute){
|
||||||
|
String[] tDate = targetDate.split("-");
|
||||||
|
if("".equals(hour)){hour = "0";}
|
||||||
|
if("".equals(minute)){minute = "0";}
|
||||||
|
|
||||||
|
DateTime targetDateTime = new DateTime(Integer.parseInt(tDate[0]), Integer.parseInt(tDate[1]), Integer.parseInt(tDate[2]), Integer.parseInt(hour), Integer.parseInt(minute));
|
||||||
|
if(dateTime.isAfter(targetDateTime)){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 시작 날짜(startDate yyyy-mm-dd, hour, minute)와
|
||||||
|
* 종료 날짜(endDate yyyy-mm-dd, hour, minute) 기준으로
|
||||||
|
* 오늘 날짜가 속해 있을경우 true
|
||||||
|
* 오늘 날짜가 속해 있지 않을 경우 false
|
||||||
|
* */
|
||||||
|
public boolean innerDateCheck(String startDate, String startHour, String startMinute, String endDate, String endHour, String endMinute){
|
||||||
|
String[] sDate = startDate.split("-");
|
||||||
|
String[] eDate = endDate.split("-");
|
||||||
|
if("".equals(startHour)){startHour = "00";}
|
||||||
|
if("".equals(startMinute)){startMinute = "00";}
|
||||||
|
if("".equals(endHour)){endHour = "23";}
|
||||||
|
if("".equals(endMinute)){endMinute = "59";}
|
||||||
|
|
||||||
|
DateTime startDateTime = new DateTime(Integer.parseInt(sDate[0]), Integer.parseInt(sDate[1]), Integer.parseInt(sDate[2]), Integer.parseInt(startHour), Integer.parseInt(startMinute));
|
||||||
|
DateTime endDateTime = new DateTime(Integer.parseInt(eDate[0]), Integer.parseInt(eDate[1]), Integer.parseInt(eDate[2]), Integer.parseInt(endHour), Integer.parseInt(endMinute));
|
||||||
|
|
||||||
|
if(dateTime.isAfter(startDateTime) && dateTime.isBefore(endDateTime)){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 넘겨준 year,month,day,time,minute값으로 디비에 저장할 Date함수를 넘겨주는 메소드
|
||||||
|
* @param int year 년도
|
||||||
|
* @param int month 월
|
||||||
|
* @param int day 일
|
||||||
|
* @param int time 시간
|
||||||
|
* @param int minute 분
|
||||||
|
* @return Date
|
||||||
|
* */
|
||||||
|
public Date dateInString(int year, int month, int day, int time, int minute){
|
||||||
|
DateTime createDateTime = new DateTime(year, month, day, time, minute);
|
||||||
|
return createDateTime.toDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dateStr 을 format형식으로 받아서 Date로 반환하는 메소드
|
||||||
|
* DateTimeFormatter 에 맞는 포멧을 넘겨 주면 자동 변환
|
||||||
|
* */
|
||||||
|
public Date dateInSimpleDateFormat(String dateStr, String format){
|
||||||
|
DateTimeFormatter dateTimeFormat = DateTimeFormat.forPattern(format);
|
||||||
|
DateTime createDateTime = dateTimeFormat.parseDateTime(dateStr);
|
||||||
|
return createDateTime.toDate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
185
src/main/java/seed/utils/SeedProperties.java
Normal file
185
src/main/java/seed/utils/SeedProperties.java
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
package seed.utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
public class SeedProperties {
|
||||||
|
|
||||||
|
private Logger log = Logger.getLogger(this.getClass());
|
||||||
|
|
||||||
|
private static Properties configProperties = null;
|
||||||
|
private static String configPath = null;
|
||||||
|
private static File configFile = null;
|
||||||
|
private static long propertiesLastModifyTime = 0l;
|
||||||
|
|
||||||
|
public SeedProperties(){}
|
||||||
|
|
||||||
|
public String configPropertiesInit(){
|
||||||
|
|
||||||
|
if(configProperties == null || propertiesLastModifyTime < configFile.lastModified()){
|
||||||
|
|
||||||
|
System.out.println("configProperties load");
|
||||||
|
|
||||||
|
String getPath = SeedUtils.setReplaceNull(SeedSqlCon.class.getProtectionDomain().getCodeSource().getLocation().getPath());
|
||||||
|
|
||||||
|
if(!getPath.equals("")){
|
||||||
|
|
||||||
|
configPath = SeedUtils.setReplaceNull(SeedSqlCon.class.getProtectionDomain().getCodeSource().getLocation().getPath());
|
||||||
|
int index = configPath.indexOf("WEB-INF");
|
||||||
|
if(index > 0) configPath = configPath.substring(0, index+7);
|
||||||
|
|
||||||
|
configPath = configPath + "/classes/config/seed/config.properties";
|
||||||
|
configFile = new File(configPath);
|
||||||
|
|
||||||
|
if(configFile == null || !configFile.isFile()){
|
||||||
|
log.error("Error configFile not file");
|
||||||
|
}
|
||||||
|
|
||||||
|
FileInputStream fileInputStream=null;
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
fileInputStream = new FileInputStream(configFile);
|
||||||
|
configProperties = new Properties();
|
||||||
|
configProperties.load(fileInputStream);
|
||||||
|
propertiesLastModifyTime = configFile.lastModified();
|
||||||
|
}catch(FileNotFoundException fe){
|
||||||
|
log.error("SeedUtils configPropertiesInit FileNotFoundException");
|
||||||
|
}catch(IOException ie){
|
||||||
|
log.error("SeedUtils configPropertiesInit IOException");
|
||||||
|
}catch(Exception ie){
|
||||||
|
log.error("SeedUtils configPropertiesInit IOException");
|
||||||
|
}finally{
|
||||||
|
if (fileInputStream!=null) try{fileInputStream.close();}catch(IOException ie){log.error("SeedUtils configPropertiesInit IOException");}
|
||||||
|
fileInputStream = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return configPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfigValue(String keyName){
|
||||||
|
this.configPropertiesInit();
|
||||||
|
return this.getConfigProperties().getProperty(keyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfigRootContextpath() {
|
||||||
|
return getConfigValue("root.contextpath");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Properties getConfigProperties() {
|
||||||
|
return configProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Properties getStaticConfigProperties() {
|
||||||
|
return configProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
//메모리상 처리
|
||||||
|
/*
|
||||||
|
public void setProperties(String keyName, String sValue){
|
||||||
|
getConfigProperties().setProperty(keyName, sValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
//파일 내부 처리
|
||||||
|
public String setReplaceConfFile(String keyName, String sValue){
|
||||||
|
|
||||||
|
String sTarget = keyName+"="+getConfigProperties().getProperty(keyName);
|
||||||
|
String sReplacement = keyName+"="+sValue;
|
||||||
|
|
||||||
|
StringReplace sr = new StringReplace(configPath, sTarget, sReplacement);
|
||||||
|
sr.processStringReplace();
|
||||||
|
|
||||||
|
return sr.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StringReplace {
|
||||||
|
private static final Logger LOG = Logger.getLogger(StringReplace.class.getName());
|
||||||
|
|
||||||
|
private String sFilename = null;
|
||||||
|
private String sTarget = null;
|
||||||
|
private String sReplacement = null;
|
||||||
|
|
||||||
|
private String sMessage = null;
|
||||||
|
|
||||||
|
public StringReplace(){}
|
||||||
|
|
||||||
|
public StringReplace(String sFilename, String sTarget, String sReplacement){
|
||||||
|
this.sFilename = sFilename;
|
||||||
|
this.sTarget = sTarget;
|
||||||
|
this.sReplacement = sReplacement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return sMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setMessage(String message) {
|
||||||
|
sMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processStringReplace(){
|
||||||
|
if(sFilename==null || sFilename.equals("")) {
|
||||||
|
setMessage("#1 파일이 선택되지 않았습니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(sTarget==null || sTarget.equals("")){
|
||||||
|
setMessage("#2 대상 문자열이 선택되지 않았습니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(sReplacement==null){
|
||||||
|
setMessage("#3 치환할 문자가 선택되지 않았습니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.setStringReplace() == 1){
|
||||||
|
setMessage("#4 정상적으로 치환되지 않았습니다.");
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
setMessage("#5 정상적으로 처리되었습니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int setStringReplace(){
|
||||||
|
BufferedReader brReader = null;
|
||||||
|
BufferedWriter bwWriter = null;
|
||||||
|
int iReturnValue = 0;
|
||||||
|
|
||||||
|
sFilename= SeedUtils.setFilePathReplaceAll(sFilename);
|
||||||
|
|
||||||
|
try{
|
||||||
|
brReader = new BufferedReader(new InputStreamReader(new FileInputStream(sFilename),"UTF-8"));
|
||||||
|
String sTmp = null;
|
||||||
|
ArrayList al = new ArrayList();
|
||||||
|
|
||||||
|
while((sTmp = brReader.readLine()) != null) {
|
||||||
|
al.add(sTmp.replaceAll(sTarget, sReplacement));
|
||||||
|
}
|
||||||
|
|
||||||
|
bwWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(sFilename ),"UTF-8"));
|
||||||
|
|
||||||
|
for(int i = 0 ; i < al.size(); i++){
|
||||||
|
bwWriter.write((String)al.get(i));
|
||||||
|
bwWriter.newLine();
|
||||||
|
}
|
||||||
|
}catch(IOException e){
|
||||||
|
LOG.error("IGNORE:",e);
|
||||||
|
iReturnValue = 1;
|
||||||
|
}finally{
|
||||||
|
if(bwWriter != null) try { bwWriter.flush(); } catch (IOException e) {LOG.error("IGNORE:",e);}
|
||||||
|
if(bwWriter != null) try { bwWriter.close(); } catch (IOException e) {LOG.error("IGNORE:",e);}
|
||||||
|
if(brReader != null) try { brReader.close(); } catch (IOException e) {LOG.error("IGNORE:",e);}
|
||||||
|
}
|
||||||
|
|
||||||
|
return iReturnValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
265
src/main/java/seed/utils/SeedSqlCon.java
Normal file
265
src/main/java/seed/utils/SeedSqlCon.java
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
package seed.utils;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import javax.naming.Context;
|
||||||
|
import javax.naming.InitialContext;
|
||||||
|
import javax.naming.NamingException;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
public class SeedSqlCon {
|
||||||
|
|
||||||
|
private Logger log = Logger.getLogger(this.getClass());
|
||||||
|
|
||||||
|
private Connection connection = null;
|
||||||
|
|
||||||
|
private String dbType = "";
|
||||||
|
private String dbVersion = "";
|
||||||
|
|
||||||
|
public SeedSqlCon(String jndiName){
|
||||||
|
|
||||||
|
SeedProperties seedProperties = new SeedProperties();
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
seedProperties.configPropertiesInit();
|
||||||
|
|
||||||
|
setDbType(seedProperties.getConfigProperties().getProperty("database").toUpperCase());
|
||||||
|
setDbVersion(seedProperties.getConfigProperties().getProperty("database.version").toUpperCase());
|
||||||
|
|
||||||
|
String jndi = "jndi/seedDB";
|
||||||
|
|
||||||
|
if ((jndiName != null) && (!("".equals(jndiName)))) {
|
||||||
|
jndi = jndiName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seedProperties.getConfigProperties().getProperty("was").equals("tomcat")) {
|
||||||
|
|
||||||
|
Context ctx = new InitialContext();
|
||||||
|
Context envCtx = (Context)ctx.lookup("java:comp/env");
|
||||||
|
|
||||||
|
if (envCtx != null) {
|
||||||
|
DataSource ds = (DataSource)envCtx.lookup(jndi);
|
||||||
|
if (ds != null){
|
||||||
|
this.connection = ds.getConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(seedProperties.getConfigProperties().getProperty("was").equalsIgnoreCase("jeus")){
|
||||||
|
|
||||||
|
InitialContext ctx = new InitialContext();
|
||||||
|
|
||||||
|
if(ctx != null){
|
||||||
|
DataSource ds = (DataSource)ctx.lookup(jndi);
|
||||||
|
if(ds != null){
|
||||||
|
this.connection = ds.getConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(seedProperties.getConfigProperties().getProperty("was").equals("weblogic")){
|
||||||
|
|
||||||
|
Context envCtx = new InitialContext();
|
||||||
|
|
||||||
|
if(envCtx != null){
|
||||||
|
DataSource ds = (DataSource)envCtx.lookup(jndi);
|
||||||
|
if(ds != null){
|
||||||
|
connection = ds.getConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(seedProperties.getConfigProperties().getProperty("was").equals("jboss")){
|
||||||
|
|
||||||
|
InitialContext ctxt = new InitialContext();
|
||||||
|
|
||||||
|
if (ctxt != null) {
|
||||||
|
DataSource ds = (DataSource) ctxt.lookup("java:jboss/"+jndi);
|
||||||
|
if (ds != null){
|
||||||
|
connection = ds.getConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (NamingException e){
|
||||||
|
log.error("CHECK ERROR:",e);
|
||||||
|
}catch(SQLException e){
|
||||||
|
log.error("CHECK ERROR:",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SeedSqlCon(String jndiName,String dbType, String dbVersion){
|
||||||
|
|
||||||
|
SeedProperties seedProperties = new SeedProperties();
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
seedProperties.configPropertiesInit();
|
||||||
|
|
||||||
|
setDbType(dbType);
|
||||||
|
setDbVersion(dbVersion);
|
||||||
|
|
||||||
|
String jndi = "jndi/seedDB";
|
||||||
|
|
||||||
|
if ((jndiName != null) && (!("".equals(jndiName)))) {
|
||||||
|
jndi = jndiName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seedProperties.getConfigProperties().getProperty("was").equalsIgnoreCase("tomcat")) {
|
||||||
|
|
||||||
|
Context ctx = new InitialContext();
|
||||||
|
Context envCtx = (Context)ctx.lookup("java:comp/env");
|
||||||
|
|
||||||
|
if (envCtx != null) {
|
||||||
|
DataSource dataSource = (DataSource)envCtx.lookup(jndi);
|
||||||
|
if (dataSource != null){
|
||||||
|
this.connection = dataSource.getConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(seedProperties.getConfigProperties().getProperty("was").equalsIgnoreCase("jeus")){
|
||||||
|
|
||||||
|
InitialContext ctx = new InitialContext();
|
||||||
|
|
||||||
|
if(ctx != null){
|
||||||
|
DataSource ds = (DataSource)ctx.lookup(jndi);
|
||||||
|
if(ds != null){
|
||||||
|
this.connection = ds.getConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(seedProperties.getConfigProperties().getProperty("was").equalsIgnoreCase("weblogic")){
|
||||||
|
|
||||||
|
Context envCtx = new InitialContext();
|
||||||
|
|
||||||
|
if(envCtx != null){
|
||||||
|
DataSource ds = (DataSource)envCtx.lookup(jndi);
|
||||||
|
if(ds != null){
|
||||||
|
this.connection = ds.getConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(seedProperties.getConfigProperties().getProperty("was").equals("jboss")){
|
||||||
|
|
||||||
|
InitialContext ctxt = new InitialContext();
|
||||||
|
|
||||||
|
if (ctxt != null) {
|
||||||
|
DataSource ds = (DataSource) ctxt.lookup("java:jboss/"+jndi);
|
||||||
|
if (ds != null){
|
||||||
|
connection = ds.getConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (NamingException e){
|
||||||
|
log.error("CHECK ERROR:",e);
|
||||||
|
}catch(SQLException e){
|
||||||
|
log.error("CHECK ERROR:",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SeedSqlCon(String dbType, String dbVersion, String dbIp, String dbPort, String dbName, String dbUser, String dbPw){
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
setDbType(dbType);
|
||||||
|
setDbVersion(dbVersion);
|
||||||
|
|
||||||
|
if(dbType.equals("MSSQL")){
|
||||||
|
|
||||||
|
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
|
||||||
|
|
||||||
|
setConnection(DriverManager.getConnection("jdbc:sqlserver://"+dbIp+":"+dbPort+";DatabaseName="+dbName+"", ""+dbUser+"", ""+dbPw+""));
|
||||||
|
|
||||||
|
}else if(dbType.equals("MYSQL")){
|
||||||
|
|
||||||
|
Class.forName("com.mysql.jdbc.Driver");
|
||||||
|
|
||||||
|
setConnection(DriverManager.getConnection("jdbc:mysql://"+dbIp+":"+dbPort+"/"+dbName+"", ""+dbUser+"", ""+dbPw+""));
|
||||||
|
|
||||||
|
}else if(dbType.equals("ORACLE")){
|
||||||
|
|
||||||
|
Class.forName("oracle.jdbc.driver.OracleDriver");
|
||||||
|
|
||||||
|
if(dbName.indexOf("SERVICE:") > -1){
|
||||||
|
setConnection(DriverManager.getConnection("jdbc:oracle:thin:@"+dbIp+":"+dbPort+"/"+dbName.split(":")[1]+"", ""+dbUser+"", ""+dbPw+""));
|
||||||
|
}else{
|
||||||
|
setConnection(DriverManager.getConnection("jdbc:oracle:thin:@"+dbIp+":"+dbPort+":"+dbName+"", ""+dbUser+"", ""+dbPw+""));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}else if(dbType.equals("TIBERO")){
|
||||||
|
|
||||||
|
Class.forName("com.tmax.tibero.jdbc.TbDriver");
|
||||||
|
|
||||||
|
setConnection(DriverManager.getConnection("jdbc:tibero:thin:@"+dbIp+":"+dbPort+":"+dbName+"", ""+dbUser+"", ""+dbPw+""));
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (ClassNotFoundException e){
|
||||||
|
log.error("CHECK ERROR:",e);
|
||||||
|
}catch(SQLException e){
|
||||||
|
log.error("CHECK ERROR:",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeedSqlDispose() {
|
||||||
|
|
||||||
|
if (connection != null){
|
||||||
|
|
||||||
|
try{
|
||||||
|
connection.close();
|
||||||
|
connection = null;
|
||||||
|
}catch(SQLException e){
|
||||||
|
log.error("CHECK ERROR:",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PreparedStatement seedPrepareStatement(String strSql) throws SQLException {
|
||||||
|
|
||||||
|
return connection.prepareStatement(strSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Connection getConnection() {
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConnection(Connection connection) {
|
||||||
|
this.connection = connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutoCommit(boolean autoCommit) throws SQLException {
|
||||||
|
connection.setAutoCommit(autoCommit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAutoCommit() throws SQLException {
|
||||||
|
return connection.getAutoCommit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void commit() throws SQLException {
|
||||||
|
connection.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rollback() throws SQLException {
|
||||||
|
connection.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDbType() {
|
||||||
|
return SeedUtils.setReplaceNull(dbType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDbType(String dbType) {
|
||||||
|
this.dbType = dbType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDbVersion() {
|
||||||
|
return dbVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDbVersion(String dbVersion) {
|
||||||
|
this.dbVersion = SeedUtils.setReplaceNull(dbVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user