svn에서 이사

oracle
강석 최 2022-03-17 11:42:45 +09:00
parent e7a65c2b3a
commit 0a3c4dfb82
846 changed files with 98742 additions and 0 deletions

7
.checkstyle Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<fileset name="all" enabled="true" check-config-name="KGI_Checks" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>

1258
.pmd Normal file

File diff suppressed because it is too large Load Diff

432
pom.xml Normal file
View File

@ -0,0 +1,432 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kcg</groupId>
<artifactId>faics</artifactId>
<packaging>war</packaging>
<version>1.0.0</version>
<url>http://maven.apache.org</url>
<properties>
<spring.maven.artifact.version>4.0.9.RELEASE</spring.maven.artifact.version>
<egovframework.rte.version>3.5.0</egovframework.rte.version>
<org.apache.tiles.version>3.0.5</org.apache.tiles.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<repositories>
<repository>
<id>mvn2</id>
<url>http://repo1.maven.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>egovframe</id>
<url>http://www.egovframe.go.kr/maven/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<!-- egovframework.rte -->
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.psl.dataaccess</artifactId>
<version>${egovframework.rte.version}</version>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.ptl.mvc</artifactId>
<version>${egovframework.rte.version}</version>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.fdl.property</artifactId>
<version>${egovframework.rte.version}</version>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.fdl.excel</artifactId>
<version>${egovframework.rte.version}</version>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.fdl.crypto</artifactId>
<version>${egovframework.rte.version}</version>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.fdl.string</artifactId>
<version>${egovframework.rte.version}</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.fdl.security</artifactId>
<version>${egovframework.rte.version}</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- 기능사용하는 곳 없음. 최종 결과물이 나올 때 까지 해당기능을 사용하지 않으면 삭제 <dependency> <groupId>egovframework.rte</groupId>
<artifactId>egovframework.rte.fdl.idgnr</artifactId> <version>${egovframework.rte.version}</version>
</dependency> -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<dependency>
<groupId>net.sf</groupId>
<artifactId>log4jdbc3</artifactId>
<version>1.1</version>
</dependency>
<!-- validation -->
<dependency>
<groupId>org.springmodules</groupId>
<artifactId>spring-modules-validation</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr</artifactId>
<version>3.0.1</version>
</dependency>
<!-- /validation -->
<!-- database driver -->
<dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/ojdbc-14.jar</systemPath>
</dependency>
<!-- /database driver -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- tiles -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>${org.apache.tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>${org.apache.tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>${org.apache.tiles.version}</version>
</dependency>
<!-- /tiles -->
<!-- json -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.3</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<!-- /json -->
<!-- ckeditor -->
<dependency>
<groupId>com.ckeditor</groupId>
<artifactId>ckeditor-java-core</artifactId>
<version>3.5.3</version>
</dependency>
<!-- file upload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.maven.artifact.version}</version>
<scope>test</scope>
</dependency>
<!-- Lucy xss servlet filter -->
<dependency>
<groupId>com.navercorp.lucy</groupId>
<artifactId>lucy-xss-servlet</artifactId>
<version>2.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<directory>${basedir}/target</directory>
<finalName>faics</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
</component>
</components>
</configuration>
<dependencies>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
</dependency>
</dependencies>
</plugin>
<!-- EMMA -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
</plugin>
<!-- PMD manven plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.4</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<versionRange>
[2.5.1,)
</versionRange>
<goals>
<goal>testCompile</goal>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- EMMA -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>false</skipTests>
<testFailureIgnore>true</testFailureIgnore>
<forkMode>once</forkMode>
<reportFormat>xml</reportFormat>
<excludes>
<exclude>**/Abstract*.java</exclude>
<exclude>**/*Suite.java</exclude>
</excludes>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<inherited>true</inherited>
</plugin>
<!-- CheckStyle 리포트 생성 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<configuration>
<configLocation>${basedir}\src\main\resources\config\KGI_Checks.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>${basedir}/target/site</outputDirectory>
<plugins>
<!-- FindBugs 리포트 생성 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
</plugin>
<!-- javadoc 생성 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<minmemory>128m</minmemory>
<maxmemory>512m</maxmemory>
<encoding>${encoding}</encoding>
<docencoding>${encoding}</docencoding>
<charset>${encoding}</charset>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
<!-- Generating Java Source in HTML -->
<plugin>
<artifactId>maven-jxr-plugin</artifactId>
<configuration>
<inputEncoding>${encoding}</inputEncoding>
<outputEncoding>${encoding}</outputEncoding>
<linkJavadoc>true</linkJavadoc>
<javadocDir>apidocs</javadocDir>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -0,0 +1,100 @@
package kcg.faics.admin.vo;
import kcg.faics.cmmn.bbs.BaseSearchVO;
/**
* LogVO.java
* @author
* @since 2016. 11. 10.
*
*
* ------------- -------- ---------------------------
* 2016. 11. 10.
*
*/
public class LogSearchVO extends BaseSearchVO {
public LogSearchVO() {
super();
}
private int type = 0;
private String sdate;
private String edate;
private String place1;
private String name;
private String order;
/**
* @return the type
*/
public int getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(int type) {
this.type = type;
}
/**
* @return the sdate
*/
public String getSdate() {
return sdate;
}
/**
* @param sdate the sdate to set
*/
public void setSdate(String sdate) {
this.sdate = sdate;
}
/**
* @return the edate
*/
public String getEdate() {
return edate;
}
/**
* @param edate the edate to set
*/
public void setEdate(String edate) {
this.edate = edate;
}
/**
* @return the place1
*/
public String getPlace1() {
return place1;
}
/**
* @param place1 the place1 to set
*/
public void setPlace1(String place1) {
this.place1 = place1;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the order
*/
public String getOrder() {
return order;
}
/**
* @param order the order to set
*/
public void setOrder(String order) {
this.order = order;
}
}

View File

@ -0,0 +1,147 @@
package kcg.faics.admin.vo;
/**
* LogVO.java
* @author
* @since 2016. 11. 10.
*
*
* ------------- -------- ---------------------------
* 2016. 11. 10.
*
*/
public class LogVO {
private int rnum;
private String userid;
private int type;
private String regdate;
private String position;
private String name;
private String location1;
private String location2;
private String location3;
private String ip;
/**
* @return the seq
*/
public int getRnum() {
return rnum;
}
/**
* @param seq the seq to set
*/
public void setRnum(int rnum) {
this.rnum = rnum;
}
/**
* @return the userid
*/
public String getUserid() {
return userid;
}
/**
* @param userid the userid to set
*/
public void setUserid(String userid) {
this.userid = userid;
}
/**
* @return the type
*/
public int getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(int type) {
this.type = type;
}
/**
* @return the regdate
*/
public String getRegdate() {
return regdate;
}
/**
* @param regdate the regdate to set
*/
public void setRegdate(String regdate) {
this.regdate = regdate;
}
/**
* @return the position
*/
public String getPosition() {
return position;
}
/**
* @param position the position to set
*/
public void setPosition(String position) {
this.position = position;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the location1
*/
public String getLocation1() {
return location1;
}
/**
* @param location1 the location1 to set
*/
public void setLocation1(String location1) {
this.location1 = location1;
}
/**
* @return the location2
*/
public String getLocation2() {
return location2;
}
/**
* @param location2 the location2 to set
*/
public void setLocation2(String location2) {
this.location2 = location2;
}
/**
* @return the location3
*/
public String getLocation3() {
return location3;
}
/**
* @param location3 the location3 to set
*/
public void setLocation3(String location3) {
this.location3 = location3;
}
/**
* @return the ip
*/
public String getIp() {
return ip;
}
/**
* @param ip the ip to set
*/
public void setIp(String ip) {
this.ip = ip;
}
}

View File

@ -0,0 +1,940 @@
/**
* AdminController.java
* @author
* @since 2016. 10. 27.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 27.
*
*/
package kcg.faics.admin.web;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import kcg.faics.admin.vo.LogSearchVO;
import kcg.faics.cmmn.excel.ExcelExporter;
import kcg.faics.cmmn.service.CodeService;
import kcg.faics.cmmn.service.LogService;
import kcg.faics.cmmn.vo.CodeVO;
import kcg.faics.member.UserType;
import kcg.faics.member.service.MemberAuthService;
import kcg.faics.member.service.MemberService;
import kcg.faics.member.vo.MemberSearchVO;
import kcg.faics.member.vo.MemberVO;
import kcg.faics.sec.LoginUserVO;
import kcg.faics.sec.UserUtil;
import kcg.faics.sec.service.impl.SecurityMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.session.SessionInformation;
import org.springframework.security.core.session.SessionRegistry;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
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.ResponseBody;
import org.springframework.web.bind.support.SessionStatus;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import egovframework.rte.fdl.property.EgovPropertyService;
import egovframework.rte.fdl.security.userdetails.EgovUserDetails;
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
/**
* AdminController.java
* @author
* @since 2016. 10. 27.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 27.
*
*/
@Controller
@RequestMapping("/admin")
public class AdminController {
@Resource(name = "propertiesService")
private EgovPropertyService propertiesService;
@Resource(name = "codeService")
CodeService codeService;
@Resource(name = "memberService")
MemberService memberService;
@Resource(name = "memberAuthService")
MemberAuthService memberAuthService;
@Resource(name = "logService")
LogService logService;
/**
* .
*
* @param memberVO modelAttribute
* @param model
* @return
* @throws Exception
*/
@RequestMapping(value = "/faMemberAdd.do", method=RequestMethod.GET)
public String faMemberAddView(@ModelAttribute("memberVO") final MemberVO memberVO, Model model) throws Exception {
/* 외사경찰 */
memberVO.setUsertype(UserType.FA);
model.addAttribute("memberVO", new MemberVO());
model.addAttribute("place1List", codeService.getPlace1List(false));
model.addAttribute("positionList", codeService.getPositionList());
model.addAttribute("dutiesList", codeService.getDutiesList());
model.addAttribute("jobTypeList", codeService.getJobTypeList());
model.addAttribute("scholarshipList", codeService.getScholarshipList());
/* create or modify 플래그 */
model.addAttribute("registerFlag", "create");
return "admin/faMemberAdd.tiles";
}
/**
* .
*
* @param multiRequest multpart
* @param memberVO
* @param bindingResult
* @param model
* @param status
* @return
* @throws Exception
*/
@RequestMapping(value = "/faMemberAdd.do", method=RequestMethod.POST)
public String faMemberAdd(final MultipartHttpServletRequest multiRequest, @ModelAttribute("memberVO") final MemberVO memberVO,
final BindingResult bindingResult, final Model model, final SessionStatus status) throws Exception {
/* 외사경찰 */
memberVO.setUsertype(UserType.FA);
HashMap<String, Object> result = new HashMap<String, Object>();
try {
/* 유효성 검사 */
MemberVO vo = memberService.select(memberVO);
if (vo != null || bindingResult.hasErrors()) {
if (vo != null) {
bindingResult.rejectValue("userid", "member.msg.duplicate");
}
model.addAttribute("memberVO", memberVO);
model.addAttribute("place1List", codeService.getPlace1List(false));
model.addAttribute("positionList", codeService.getPositionList());
model.addAttribute("dutiesList", codeService.getDutiesList());
model.addAttribute("jobTypeList", codeService.getJobTypeList());
model.addAttribute("scholarshipList", codeService.getScholarshipList());
/* create or modify 플래그 */
model.addAttribute("registerFlag", "create");
return "admin/faMemberAdd.tiles";
}
result = memberService.insert(memberVO, multiRequest.getFileMap());
} catch (Exception e) {
e.printStackTrace();
}
if ((Integer) result.get("result") != 1) {
return "redirect:/admin/faMemberAdd.do";
}
String newUserId = (String) result.get("userid");
newUserId = URLEncoder.encode(newUserId, "UTF-8");
return "redirect:/admin/faMemberInfo.do?userid=" + newUserId;
}
/**
* .
*
* @param memberVO
* @param model
* @return
* @throws Exception
*/
@RequestMapping("/faMemberInfo.do")
public String faMemberInfo(final MemberVO memberVO, final Model model) throws Exception {
try {
/* 외사경찰 */
memberVO.setUsertype(UserType.FA);
model.addAttribute("memberVO", memberService.select(memberVO));
model.addAttribute("isAdmin", UserUtil.isAdmin());
model.addAttribute("isSysAdmin", UserUtil.isSysAdmin());
} catch (Exception e) {
e.printStackTrace();
}
return "admin/faMemberInfo.tiles";
}
/**
* .
*
* @param searchVO ,
* @param model
* @return
* @throws Exception
*/
@RequestMapping("/faMemberList.do")
public String faMemberList(@ModelAttribute("memberSearchVO") final MemberSearchVO searchVO, final Model model) throws Exception {
try {
/* 페이징 처리 정보 */
searchVO.setPageUnit(propertiesService.getInt("pageUnit"));
searchVO.setPageSize(propertiesService.getInt("pageSize"));
/* 페이징 처리 */
PaginationInfo paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(searchVO.getPageIndex());
paginationInfo.setRecordCountPerPage(searchVO.getPageUnit());
paginationInfo.setPageSize(searchVO.getPageSize());
searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
searchVO.setLastIndex(paginationInfo.getLastRecordIndex());
searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
int totSearchCnt = memberService.selectListCnt(searchVO);
paginationInfo.setTotalRecordCount(totSearchCnt);
model.addAttribute("paginationInfo", paginationInfo);
/* 게시판 상단 페이지 및 게시물 정보 표현을 위한 데이터 */
int totCnt = memberService.selectTotalCnt(searchVO);
model.addAttribute("totalCnt", totCnt);
model.addAttribute("resultList", memberService.selectList(searchVO));
model.addAttribute("place1List", codeService.getPlace1List(false));
} catch (Exception e) {
e.printStackTrace();
}
return "admin/faMemberList.tiles";
}
/**
* .
*
* @param searchVO ,
* @param model
* @return
* @throws Exception
*/
@RequestMapping("/faMemberCmmnList.do")
public String faMemberCmmnList(@ModelAttribute("memberSearchVO") final MemberSearchVO searchVO, final Model model) throws Exception {
try {
if (searchVO.getPlace1() == null || searchVO.getPlace1().length() == 0) {
searchVO.setPlace1("PS00");
}
/* 페이징 처리 정보 */
searchVO.setPageUnit(propertiesService.getInt("pageUnit"));
searchVO.setPageSize(propertiesService.getInt("pageSize"));
/* 페이징 처리 */
PaginationInfo paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(searchVO.getPageIndex());
paginationInfo.setRecordCountPerPage(searchVO.getPageUnit());
paginationInfo.setPageSize(searchVO.getPageSize());
searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
searchVO.setLastIndex(paginationInfo.getLastRecordIndex());
searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
int totSearchCnt = memberService.selectListCnt(searchVO);
paginationInfo.setTotalRecordCount(totSearchCnt);
model.addAttribute("paginationInfo", paginationInfo);
/* 게시판 상단 페이지 및 게시물 정보 표현을 위한 데이터 */
int totCnt = memberService.selectTotalCnt(searchVO);
model.addAttribute("totalCnt", totCnt);
model.addAttribute("resultList", memberService.selectList(searchVO));
model.addAttribute("place1List", codeService.getPlace1List(false));
} catch (Exception e) {
e.printStackTrace();
}
return "admin/faMemberCmmnList.tiles";
}
/**
* .
*
* @param searchVO
* VO
* @param model
* Model
* @return
* @throws Exception
*
*/
@RequestMapping("/faMemberListExcel.do")
public String faMemberListExcel(@ModelAttribute("memberSearchVO") final MemberSearchVO searchVO, final Model model) throws Exception {
String title = "외사경찰현황";
List<MemberVO> memberList = memberService.getFaListAll(searchVO);
LinkedHashMap<String, String> header = new LinkedHashMap<String, String>();
header.put("place1N2Str", "소속");
header.put("positionStr", "계급");
header.put("name", "성명");
header.put("userid", "아이디");
header.put("inoutStr", "근무형태");
header.put("jobtypeStr", "직별");
header.put("usegrade", "등급");
model.addAttribute("excel", new ExcelExporter<MemberVO>(header, memberList, title));
model.addAttribute("filename", title);
return "excelView";
}
/**
* .
*
* "/faMemberUpdateView.do" = -
* "/cmmnMemberUpdateView.do" = -
*
* @param memberVO
* @param model
* @param request
* @return
* @throws Exception
*/
@RequestMapping(value = {"/faMemberUpdateView.do", "/cmmnMemberUpdateView.do"}, method = RequestMethod.POST)
public String faMemberUpdateView(@ModelAttribute("memberVO") final MemberVO memberVO, final Model model,
final HttpServletRequest request) throws Exception {
/* 외사경찰 */
memberVO.setUsertype(UserType.FA);
model.addAttribute("memberVO", memberService.select(memberVO));
model.addAttribute("place1List", codeService.getPlace1List(false));
model.addAttribute("positionList", codeService.getPositionList());
model.addAttribute("dutiesList", codeService.getDutiesList());
model.addAttribute("jobTypeList", codeService.getJobTypeList());
model.addAttribute("scholarshipList", codeService.getScholarshipList());
/* create or modify 플래그 */
model.addAttribute("registerFlag", "modify");
/* 요청한 url에 따라 돌아갈 목록 타입을 설정한다. */
String requestUrl = request.getRequestURL().toString();
if (requestUrl.indexOf("/faMemberUpdateView.do") > 0) {
model.addAttribute("listType", "fa");
} else {
model.addAttribute("listType", "cmmn");
}
return "admin/faMemberAdd.tiles";
}
/**
* .
*
* @param multiRequest
* multpart
* @param memberVO
*
* @param bindingResult
*
* @param model
*
* @param status
*
* @return
* @throws Exception
*
*/
@RequestMapping(value = {"/faMemberUpdate.do", "/cmmnMemberUpdate.do"}, method = RequestMethod.POST)
public String faMemberUpdate(final MultipartHttpServletRequest multiRequest, @ModelAttribute("memberVO") final MemberVO memberVO,
final BindingResult bindingResult, final Model model, final SessionStatus status) throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
try {
/* 유효성 검사 */
if (bindingResult.hasErrors()) {
model.addAttribute("memberVO", memberVO);
model.addAttribute("place1List", codeService.getPlace1List(false));
model.addAttribute("positionList", codeService.getPositionList());
model.addAttribute("dutiesList", codeService.getDutiesList());
model.addAttribute("jobTypeList", codeService.getJobTypeList());
model.addAttribute("scholarshipList", codeService.getScholarshipList());
return "admin/faMemberAdd.tiles";
}
String [] deleteFiles = null;
result = memberService.updateFaMember(memberVO, multiRequest.getFileMap(), deleteFiles);
if ((Integer) result.get("result") != 1) {
return "redirect:/admin/faMemberAdd.do";
}
} catch (Exception e) {
e.printStackTrace();
}
/* 요청한 url에 따라 돌아갈 목록url을 반환한다. */
String requestUrl = multiRequest.getRequestURL().toString();
if (requestUrl.indexOf("/faMemberUpdate.do") > 0) {
return "redirect:/admin/faMemberList.do";
} else {
return "redirect:/admin/faMemberCmmnList.do";
}
}
/**
* .
*
* @param searchVO searchVO
* @param model
* @return
* @throws Exception
*/
@RequestMapping("/memberAuth.do")
public String memberAuth(final MemberSearchVO searchVO, final Model model) throws Exception {
LoginUserVO user = UserUtil.getMemberInfo();
if (StringUtils.isBlank(searchVO.getPlace1())) {
searchVO.setPlace1(user.getPlace1());
}
/* 페이징 처리 정보 */
searchVO.setPageUnit(20);
searchVO.setPageSize(propertiesService.getInt("pageSize"));
/* 페이징 처리 */
PaginationInfo paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(searchVO.getPageIndex());
paginationInfo.setRecordCountPerPage(searchVO.getPageUnit());
paginationInfo.setPageSize(searchVO.getPageSize());
searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
searchVO.setLastIndex(paginationInfo.getLastRecordIndex());
searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
int totSearchCnt = memberAuthService.getMemberListByPlace1Cnt(searchVO);
paginationInfo.setTotalRecordCount(totSearchCnt);
model.addAttribute("paginationInfo", paginationInfo);
HashMap<String, Object> result = memberAuthService.getMemberListByPlace1(searchVO);
model.addAttribute("head", result.get("head"));
model.addAttribute("section", result.get("section"));
model.addAttribute("resultList", result.get("resultList"));
model.addAttribute("loginUserVO", user);
String targetPlace1 = searchVO.getPlace1();
if (StringUtils.isBlank(targetPlace1)) {
targetPlace1 = user.getPlace1();
}
model.addAttribute("targetPlace1", targetPlace1);
List<CodeVO> placeList = codeService.getPlace1List(true);
model.addAttribute("placeList", placeList);
return "admin/faMemberAuth.tiles";
}
/**
* .
*
* @param memberVO userid, usegrade
* @return : - 1, - 0
* @throws Exception
*/
@ResponseBody
@RequestMapping(value = "/memberAuth.json")
public HashMap<String, Object> memberAuth(final MemberVO memberVO) throws Exception {
HashMap<String, Object> results = new HashMap<String, Object>();
int result = memberAuthService.updateMemberAuth(memberVO);
results.put("result", result);
return results;
}
/**
* .
*
* @param memberVO userid, usegrade
* @return : - 1, - 0
* @throws Exception
*/
@ResponseBody
@RequestMapping(value = "/memberRpt.json")
public HashMap<String, Object> memberRpt(final MemberVO memberVO) throws Exception {
HashMap<String, Object> results = new HashMap<String, Object>();
int result = memberAuthService.updateMemberRpt(memberVO);
results.put("result", result);
return results;
}
/**
* .
*
* @param memberVO userid
* @return : - 1, - 0
* @throws Exception
*/
@ResponseBody
@RequestMapping(value = "/updateSection.json")
public HashMap<String, Object> updateSection(final MemberVO memberVO) throws Exception {
HashMap<String, Object> results = new HashMap<String, Object>();
int result = memberAuthService.updateSection(memberVO);
results.put("result", result);
return results;
}
/**
* .
*
* @param memberVO userid
* @return : - 1, - 0
* @throws Exception
*/
@ResponseBody
@RequestMapping(value = "/updateHead.json")
public HashMap<String, Object> updateHead(final MemberVO memberVO) throws Exception {
HashMap<String, Object> results = new HashMap<String, Object>();
int result = memberAuthService.updateHead(memberVO);
results.put("result", result);
return results;
}
/**
* .
*
* @param searchVO ,
* @param model
* @return
* @throws Exception
*/
@RequestMapping("/cmmnMemberList.do")
public String memberList(@ModelAttribute("memberSearchVO") final MemberSearchVO searchVO, final Model model) throws Exception {
try {
/* 일반 경찰 */
searchVO.setUsertype(UserType.CM);
/* 페이징 처리 정보 */
searchVO.setPageUnit(propertiesService.getInt("pageUnit"));
searchVO.setPageSize(propertiesService.getInt("pageSize"));
/* 페이징 처리 */
PaginationInfo paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(searchVO.getPageIndex());
paginationInfo.setRecordCountPerPage(searchVO.getPageUnit());
paginationInfo.setPageSize(searchVO.getPageSize());
searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
searchVO.setLastIndex(paginationInfo.getLastRecordIndex());
searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
int totSearchCnt = memberService.selectListCnt(searchVO);
paginationInfo.setTotalRecordCount(totSearchCnt);
model.addAttribute("paginationInfo", paginationInfo);
/* 게시판 상단 페이지 및 게시물 정보 표현을 위한 데이터 */
int totCnt = memberService.selectTotalCnt(searchVO);
model.addAttribute("totalCnt", totCnt);
List<MemberVO> resultList = memberService.selectList(searchVO);
model.addAttribute("resultList", resultList);
model.addAttribute("place1List", codeService.getPlace1List(false));
} catch (Exception e) {
e.printStackTrace();
}
return "admin/cmmnMemberList.tiles";
}
/**
* .
*
* @param model Model
* @return
*/
@RequestMapping("/cmmnMemberListExcel.do")
public String memberListExcel(@ModelAttribute("memberSearchVO") final MemberSearchVO searchVO, final Model model) throws Exception {
/* 일반 경찰 */
searchVO.setUsertype(UserType.CM);
String title = "일반경찰현황";
searchVO.setUsertype("");
List<MemberVO> memberList = memberService.selectListAll(searchVO);
LinkedHashMap<String, String> header = new LinkedHashMap<String, String>();
header.put("place3Str", "소속");
header.put("positionStr", "계급");
header.put("useridStr", "아이디");
header.put("name", "성명");
model.addAttribute("excel", new ExcelExporter<MemberVO>(header, memberList, title));
model.addAttribute("filename", title);
return "excelView";
}
/**
* .
*
* @param searchVO ,
* @param model
* @return
* @throws Exception
*/
@RequestMapping("/userLogStatistics.do")
public String userLogStatistics(@ModelAttribute("logSearchVO") final LogSearchVO searchVO, final Model model) throws Exception {
try {
/* 페이징 처리 정보 */
searchVO.setPageUnit(propertiesService.getInt("pageUnit"));
searchVO.setPageSize(propertiesService.getInt("pageSize"));
if (StringUtils.isEmpty(searchVO.getSdate()) && StringUtils.isEmpty(searchVO.getEdate())) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar day = Calendar.getInstance();
day.add(Calendar.MONTH, -1);
searchVO.setSdate(sdf.format(day.getTime()));
searchVO.setEdate(sdf.format(new Date()));
}
/* 페이징 처리 */
PaginationInfo paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(searchVO.getPageIndex());
paginationInfo.setRecordCountPerPage(searchVO.getPageUnit());
paginationInfo.setPageSize(searchVO.getPageSize());
searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
searchVO.setLastIndex(paginationInfo.getLastRecordIndex());
searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
int totSearchCnt = logService.selectListCnt(searchVO);
paginationInfo.setTotalRecordCount(totSearchCnt);
model.addAttribute("paginationInfo", paginationInfo);
/* 게시판 상단 페이지 및 게시물 정보 표현을 위한 데이터 */
int totCnt = logService.selectTotalCnt(searchVO);
model.addAttribute("totalCnt", totCnt);
model.addAttribute("resultList", logService.getUserLogList(searchVO));
model.addAttribute("place1List", codeService.getPlace1List(false));
} catch (Exception e) {
e.printStackTrace();
}
return "admin/logStatistics.tiles";
}
/**
* .
*
* @param searchVO ,
* @param model
* @return
* @throws Exception
*/
@RequestMapping("/memberManage.do")
public String memberManage(@ModelAttribute("memberSearchVO") final MemberSearchVO searchVO, final Model model) throws Exception {
try {
/* 페이징 처리 정보 */
searchVO.setPageUnit(propertiesService.getInt("pageUnit"));
searchVO.setPageSize(propertiesService.getInt("pageSize"));
/* 페이징 처리 */
PaginationInfo paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(searchVO.getPageIndex());
paginationInfo.setRecordCountPerPage(searchVO.getPageUnit());
paginationInfo.setPageSize(searchVO.getPageSize());
searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
searchVO.setLastIndex(paginationInfo.getLastRecordIndex());
searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
int totSearchCnt = memberService.selectListCnt(searchVO);
paginationInfo.setTotalRecordCount(totSearchCnt);
model.addAttribute("paginationInfo", paginationInfo);
/* 게시판 상단 페이지 및 게시물 정보 표현을 위한 데이터 */
int totCnt = memberService.selectTotalCnt(searchVO);
model.addAttribute("totalCnt", totCnt);
List<MemberVO> memberList = memberService.selectList(searchVO);
model.addAttribute("resultList", memberList);
model.addAttribute("place1List", codeService.getPlace1List(false));
} catch (Exception e) {
e.printStackTrace();
}
return "admin/memberManage.tiles";
}
/**
* .
*
* @param searchVO ,
* @param model
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/initPw.json")
public HashMap<String, Object> initPw(final MemberVO memberVO, final String[] targetId) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
try {
resultMap = memberService.initPassword(memberVO, targetId);
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
@Autowired
private SessionRegistry sessionRegistry;
@Resource(name="securityMapper")
private SecurityMapper securityMapper;
@Resource(name="userService")
private UserDetailsService securityService;
@Resource(name="loginSuccessHandler")
private AuthenticationSuccessHandler successHandler;
/**
* .
*
* @param searchVO ,
* @param model
* @return
* @throws Exception
*/
@RequestMapping("/loginUser.do")
public void loginUser(final HttpServletRequest request, final HttpServletResponse response, final String userid) throws Exception {
Authentication authentication = null;
if (userid != null) {
authentication = login(userid);
} else {
authentication = UserUtil.getCurrentAuthentication();
}
successHandler.onAuthenticationSuccess(request, response, authentication);
}
/**
* .
*
* @param searchVO ,
* @param model
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/releaseConnection.json")
public HashMap<String, Object> releaseConnection(final MemberVO memberVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("result", logout(memberVO.getUserid()));
return resultMap;
}
/**
* .
*
* @param searchVO ,
* @param model
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/releaseRestriction.json")
public HashMap<String, Object> releaseRestriction(final MemberVO memberVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("result", 0);
try {
resultMap = memberService.initChkcnt(memberVO);
logout(memberVO.getUserid());
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
/**
* .
*
* @param userid
* @return - 1, - 0
* @throws Exception
*/
private final int logout(final String userid) {
int result = 0;
EgovUserDetails target = null;
List<Object> principals = sessionRegistry.getAllPrincipals();
for (Object principal: principals) {
if (principal instanceof EgovUserDetails) {
EgovUserDetails details = (EgovUserDetails) principal;
LoginUserVO vo = (LoginUserVO) details.getEgovUserVO();
if (userid.equals(vo.getUserid())) {
for (final SessionInformation session : sessionRegistry.getAllSessions(principal, false)) {
session.expireNow();
vo.setLoginchk("N");
result = securityMapper.updateLoginInfo(vo);
}
break;
}
}
}
return result;
}
/**
* .
*
* @param userid
* @return Authentication
* @throws Exception
*/
private final Authentication login(final String userid) {
Authentication auth = null;
try {
UserDetails user = securityService.loadUserByUsername(userid);
auth = new UsernamePasswordAuthenticationToken(user, null, user.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(auth);
} catch (Exception e) {
e.printStackTrace();
}
return auth;
}
/**
* .
*
* @param searchVO ,
* @param model
* @return
* @throws Exception
*/
@RequestMapping("/codeManage.do")
public String codeManage(final CodeVO codeVO, final Model model) throws Exception {
if (codeVO.getCode1() != null) {
model.addAttribute("code", codeService.getCodeValue("C000", codeVO.getCode1()));
}
model.addAttribute("code1List", codeService.getCodeValues("C000", null));
return "admin/codeManage.tiles";
}
/**
* .
*
* @param code1
* @param model
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/getCode2List.json")
public HashMap<String, Object> getCode2List(final String code1) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
try {
resultMap.put("code2List", codeService.getCodeValues(code1, null));
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
/**
* .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
@ResponseBody
@RequestMapping("/insertCode.json")
public HashMap<String, Object> insertCode(final CodeVO codeVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
try {
resultMap.put("result", codeService.insertCode(codeVO));
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
/**
* .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
@ResponseBody
@RequestMapping("/updateCode.json")
public HashMap<String, Object> updateCode(final CodeVO codeVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
try {
resultMap.put("result", codeService.updateCode(codeVO));
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
/**
* .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
@ResponseBody
@RequestMapping("/deleteCode.json")
public HashMap<String, Object> deleteCode(final CodeVO codeVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
try {
resultMap.put("result", codeService.deleteCode(codeVO));
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
}

View File

@ -0,0 +1,143 @@
package kcg.faics.arrest.service;
/**
* ArrestService.java
* @author
* @since 2017. 3. 17.
*
*
* ------------- -------- ---------------------------
* 2017. 3. 17.
*
*/
import java.util.HashMap;
import java.util.List;
import kcg.faics.arrest.vo.ArrestCountVO;
import kcg.faics.arrest.vo.ArrestSearchVO;
import kcg.faics.arrest.vo.ArrestVO;
import kcg.faics.cmmn.vo.CodeVO;
public interface ArrestService {
/**
* .
*
* @param
* @return 1
* @throws Exception
*
*/
List<CodeVO> getAddressAreaList(String area) throws Exception;
/**
* .
*
* @param arrestVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
HashMap<String, Object> insert(ArrestVO arrestVO) throws Exception;
/**
* .
*
* @param arrestVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
HashMap<String, Object> update(ArrestVO arrestVO) throws Exception;
/**
* .
*
* @param arrestVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
HashMap<String, Object> delete(ArrestVO arrestVO) throws Exception;
/**
* .
*
* @param arrestVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
ArrestVO select(ArrestVO arrestVO) throws Exception;
/**
* .
*
* @param arrestVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
List<ArrestVO> getArrestListAll(ArrestSearchVO arrestSearchVO) throws Exception;
/**
* ().
*
* @param arrestVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
List<ArrestVO> getArrestList(ArrestSearchVO arrestSearchVO) throws Exception;
/**
* ().
*
* @param arrestVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
List<ArrestVO> getArrestListExcel(ArrestSearchVO arrestSearchVO) throws Exception;
/**
* ().
*
* @param arrestVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
List<HashMap<String, Object>> getArrestListExcelHashMap(ArrestSearchVO arrestSearchVO) throws Exception;
/**
* .
*
* @param arrestVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
ArrestVO getArrestListCount(ArrestSearchVO arrestSearchVO) throws Exception;
/**
* .
*
* @param arrestVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
ArrestVO getArrestListCountExcel(ArrestSearchVO arrestSearchVO) throws Exception;
/**
* .
*
* @param arrestVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
ArrestCountVO getArrestListAllCount(ArrestSearchVO arrestSearchVO) throws Exception;
}

View File

@ -0,0 +1,218 @@
package kcg.faics.arrest.service.impl;
import java.util.HashMap;
import java.util.List;
import kcg.faics.arrest.vo.ArrestCountVO;
import kcg.faics.arrest.vo.ArrestSearchVO;
import kcg.faics.arrest.vo.ArrestVO;
import kcg.faics.board.vo.BoardSearchVO;
import kcg.faics.board.vo.BoardVO;
import kcg.faics.cmmn.vo.CodeVO;
import kcg.faics.member.vo.MemberSearchVO;
import kcg.faics.member.vo.MemberVO;
import org.springframework.stereotype.Repository;
import egovframework.rte.psl.dataaccess.EgovAbstractMapper;
/**
* ArrestMapper.java
* @author
* @since 2017. 3. 14.
*
*
* ------------- -------- ---------------------------
* 2017. 3. 16.
*
*/
@Repository("arrestMapper")
public class ArrestMapper extends EgovAbstractMapper {
/**
* .
*
* @param arrestVO
* @return
* @throws Exception
*/
public HashMap<String, Object> insertArrest(final ArrestVO arrestVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
int result = 0;
try {
result = insert("Arrest.insertArrest", arrestVO);
resultMap.put("result", result);
resultMap.put("id", "");
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
};
/**
* .
*
* @param arrestVO
* @return
* @throws Exception
*/
public HashMap<String, Object> updateArrest(final ArrestVO arrestVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
int result = 0;
try {
result = insert("Arrest.updateArrest", arrestVO);
resultMap.put("result", result);
resultMap.put("id", arrestVO.getArrestId());
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
/**
* .
*
* @param boardVO
* @return
* @throws Exception
*/
public HashMap<String, Object> deleteArrest(final ArrestVO arrestVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
int result = 0;
try {
result = insert("Arrest.deleteArrest", arrestVO);
resultMap.put("result", result);
resultMap.put("arrestId", arrestVO.getArrestId());
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
};
/**
* .
*
* @param onlyCentral
* - true, - false
* @return 1
* @throws Exception
*/
public List<CodeVO> getAddressAreaList(String area) throws Exception {
List<CodeVO> tempList = selectList("Arrest.getAddressAreaList", area);
return tempList;
}
/**
* .
*
* @param dataVO
* @return
* @throws Exception
*/
public ArrestVO getArrest(final ArrestVO dataVO) {
ArrestVO result = selectOne("Arrest.getArrest", dataVO);
return result;
}
/**
* (no paging) .
*
* @param arrestSearchVO
*
* @return
* @throws Exception
*
*/
public List<ArrestVO> getArrestListAll(final ArrestSearchVO arrestSearchVO) throws Exception {
return selectList("Arrest.getArrestListAll", arrestSearchVO);
}
/**
*
*
* @param arrestSearchVO
*
* @return
* @throws Exception
*
*/
public List<ArrestVO> getArrestList(final ArrestSearchVO arrestSearchVO) throws Exception {
return selectList("Arrest.getArrestList", arrestSearchVO);
}
/**
*
*
* @param arrestSearchVO
*
* @return
* @throws Exception
*
*/
public ArrestVO getArrestListCount(final ArrestSearchVO arrestSearchVO) throws Exception {
return selectOne("Arrest.getArrestListCount", arrestSearchVO);
}
/**
*
*
* @param arrestSearchVO
*
* @return
* @throws Exception
*
*/
public ArrestVO getArrestListCountExcel(final ArrestSearchVO arrestSearchVO) throws Exception {
return selectOne("Arrest.getArrestListCountExcel", arrestSearchVO);
}
/**
*
*
* @param arrestSearchVO
*
* @return
* @throws Exception
*
*/
public ArrestCountVO getArrestListAllCount(final ArrestSearchVO arrestSearchVO) throws Exception {
return selectOne("Arrest.getArrestListAllCount", arrestSearchVO);
}
/**
*
*
* @param arrestSearchVO
*
* @return
* @throws Exception
*
*/
public List<ArrestVO> getArrestListExcel(final ArrestSearchVO arrestSearchVO) throws Exception {
return selectList("Arrest.getArrestListExcel", arrestSearchVO);
}
/**
*
*
* @param arrestSearchVO
*
* @return
* @throws Exception
*
*/
public List<HashMap<String, Object>> getArrestListExcelHashMap(final ArrestSearchVO arrestSearchVO) {
return selectList("Arrest.getArrestListExcelHashMap", arrestSearchVO);
}
}

View File

@ -0,0 +1,247 @@
/**
* CommonService.java
* @author
* @since 2016. 10. 13.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 13.
*
*/
package kcg.faics.arrest.service.impl;
import java.util.HashMap;
import java.util.List;
import javax.annotation.Resource;
import kcg.faics.arrest.service.ArrestService;
import kcg.faics.arrest.vo.ArrestCountVO;
import kcg.faics.arrest.vo.ArrestSearchVO;
import kcg.faics.arrest.vo.ArrestVO;
import kcg.faics.cmmn.vo.CodeVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* ArrestServiceImpl.java
* @author
* @since 2016. 3. 17.
*
*
* ------------- -------- ---------------------------
* 2017. 3. 17.
*
*/
@Service("arrestService")
public class ArrestServiceImpl implements ArrestService {
/**
* ArrestMapper.
*/
@Resource(name = "arrestMapper")
private ArrestMapper arrestMapper;
/**
* .
*
* @param String area
* @param String area
* @return List<CodeVO>
* @exception Exception
*/
@Override
public List<CodeVO> getAddressAreaList(String area) throws Exception {
List<CodeVO> codeVOList = arrestMapper.getAddressAreaList(area);
return codeVOList;
}
/**
* .
*
* @param dataVO
* @param fileMap
* @return HashMap/ seq : , result : - 1, - 0
* @exception Exception
*/
@Override
@Transactional
public HashMap<String, Object> insert(final ArrestVO arrestVO) throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
//
if(!arrestVO.getShipProcType().equals("01")){
arrestVO.setCommissionCost("");
}
if(arrestVO.getMarginPaymentYn().equals("N")){
arrestVO.setMarginPaymentDate("");
}
result = arrestMapper.insertArrest(arrestVO);
return result;
}
/**
* .
*
* @param dataVO
* @param fileMap
* @return HashMap/ seq : , result : - 1, - 0
* @exception Exception
*/
@Override
@Transactional
public HashMap<String, Object> update(final ArrestVO arrestVO) throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
if(!arrestVO.getShipProcType().equals("01")){
arrestVO.setCommissionCost("");
}
if(arrestVO.getMarginPaymentYn().equals("N")){
arrestVO.setMarginPaymentDate("");
}
result = arrestMapper.updateArrest(arrestVO);
return result;
}
/**
* .
*
* @param dataVO
* @param fileMap
* @return HashMap/ seq : , result : - 1, - 0
* @exception Exception
*/
@Override
@Transactional
public HashMap<String, Object> delete(final ArrestVO arrestVO) throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
result = arrestMapper.deleteArrest(arrestVO);
return result;
}
/**
*
*
* @param dataVO userid
* @return
* @throws Exception
*/
@Override
public ArrestVO select(final ArrestVO dataVO) throws Exception {
ArrestVO result = arrestMapper.getArrest(dataVO);
return result;
}
/**
*
*
* @param dataVO userid
* @return
* @throws Exception
*/
@Override
public List<ArrestVO> getArrestListAll(final ArrestSearchVO arrestSearchVO) throws Exception {
return arrestMapper.getArrestListAll(arrestSearchVO);
}
/**
*
*
* @param dataVO userid
* @return
* @throws Exception
*/
@Override
public ArrestCountVO getArrestListAllCount(final ArrestSearchVO arrestSearchVO) throws Exception {
return arrestMapper.getArrestListAllCount(arrestSearchVO);
}
/**
*
*
* @param dataVO arrestSearchVO
* @return
* @throws Exception
*/
@Override
public List<ArrestVO> getArrestList(final ArrestSearchVO arrestSearchVO) throws Exception {
return arrestMapper.getArrestList(arrestSearchVO);
}
/**
* ()
*
* @param dataVO arrestSearchVO
* @return
* @throws Exception
*/
@Override
public List<ArrestVO> getArrestListExcel(final ArrestSearchVO arrestSearchVO) throws Exception {
return arrestMapper.getArrestListExcel(arrestSearchVO);
}
/**
*
*
* @param dataVO userid
* @return
* @throws Exception
*/
@Override
public ArrestVO getArrestListCount(final ArrestSearchVO arrestSearchVO) throws Exception {
return arrestMapper.getArrestListCount(arrestSearchVO);
}
/**
*
*
* @param dataVO arrestSearchVO
* @return
* @throws Exception
*/
@Override
public ArrestVO getArrestListCountExcel(final ArrestSearchVO arrestSearchVO)
throws Exception {
return arrestMapper.getArrestListCountExcel(arrestSearchVO);
}
/**
* ()
*
* @param dataVO arrestSearchVO
* @return
* @throws Exception
*/
@Override
public List<HashMap<String, Object>> getArrestListExcelHashMap(final ArrestSearchVO arrestSearchVO) throws Exception {
return arrestMapper.getArrestListExcelHashMap(arrestSearchVO);
}
}

View File

@ -0,0 +1,455 @@
package kcg.faics.arrest.vo;
public class ArrestCountVO {
/**
*
*/
private int particularBanCnt = 0;
/**
*
*/
private int withoutLicenseCnt = 0;
/**
*
*/
private int territWatersCnt = 0;
/**
* EEZ
*/
private int eezCnt = 0;
/**
*
*/
private int specBatlCnt = 0;
/**
* NLL
*/
private int nllCnt = 0;
/**
*
*/
private int shipCrewCnt = 0;
/**
*
*/
private int vioCnt = 0;
/**
*
*/
private int priatedAmt = 0;
/**
*
*/
private int procContNCnt = 0; //
/**
*
*/
private int procContYCnt = 0; //
/**
*
*/
private int paymentAmt = 0; //
/**
*
*/
private int noPaymentCnt = 0; //
/**
*
*/
private int noPaymentAmt = 0; //
/**
*
*/
private int shipProcTypeACnt = 0; //
/**
*
*/
private int shipProcTypeBCnt = 0; //
/**
*
*/
private int shipProcTypeCCnt = 0; //
/**
*
*/
private int shipProcTypeDCnt = 0; //
/**
*
*/
private int shipProcTypeECnt = 0; //
/**
*
*/
private int captainCount = 0; //
/**
*
*/
private int engineerCount = 0; //
/**
*
*/
private int mateCount = 0; //
/**
*
*/
private int crewCount = 0; //
/**
*
*/
private int commissionCost = 0; //
/**
*
*/
private int gearCast = 0; //
/**
*
*/
private int gearWidth = 0; //
/**
*
*/
private int fieldCnt = 0; //
/**
*
*/
private int totalCnt = 0;
/**
* @return the noPaymentAmt
*/
public int getNoPaymentAmt() {
return noPaymentAmt;
}
/**
* @param noPaymentAmt the noPaymentAmt to set
*/
public void setNoPaymentAmt(int noPaymentAmt) {
this.noPaymentAmt = noPaymentAmt;
}
/**
* @return the totalCnt
*/
public int getTotalCnt() {
return totalCnt;
}
/**
* @param totalCnt the totalCnt to set
*/
public void setTotalCnt(int totalCnt) {
this.totalCnt = totalCnt;
}
/**
* @return the fieldCnt
*/
public int getFieldCnt() {
return fieldCnt;
}
/**
* @param fieldCnt the fieldCnt to set
*/
public void setFieldCnt(int fieldCnt) {
this.fieldCnt = fieldCnt;
}
/**
* @return the particularBanCnt
*/
public int getParticularBanCnt() {
return particularBanCnt;
}
/**
* @param particularBanCnt the particularBanCnt to set
*/
public void setParticularBanCnt(int particularBanCnt) {
this.particularBanCnt = particularBanCnt;
}
/**
* @return the withoutLicenseCnt
*/
public int getWithoutLicenseCnt() {
return withoutLicenseCnt;
}
/**
* @param withoutLicenseCnt the withoutLicenseCnt to set
*/
public void setWithoutLicenseCnt(int withoutLicenseCnt) {
this.withoutLicenseCnt = withoutLicenseCnt;
}
/**
* @return the territWatersCnt
*/
public int getTerritWatersCnt() {
return territWatersCnt;
}
/**
* @param territWatersCnt the territWatersCnt to set
*/
public void setTerritWatersCnt(int territWatersCnt) {
this.territWatersCnt = territWatersCnt;
}
/**
* @return the eezCnt
*/
public int getEezCnt() {
return eezCnt;
}
/**
* @param eezCnt the eezCnt to set
*/
public void setEezCnt(int eezCnt) {
this.eezCnt = eezCnt;
}
/**
* @return the specBatlCnt
*/
public int getSpecBatlCnt() {
return specBatlCnt;
}
/**
* @param specBatlCnt the specBatlCnt to set
*/
public void setSpecBatlCnt(int specBatlCnt) {
this.specBatlCnt = specBatlCnt;
}
/**
* @return the nllCnt
*/
public int getNllCnt() {
return nllCnt;
}
/**
* @param nllCnt the nllCnt to set
*/
public void setNllCnt(int nllCnt) {
this.nllCnt = nllCnt;
}
/**
* @return the shipCrewCnt
*/
public int getShipCrewCnt() {
return shipCrewCnt;
}
/**
* @param shipCrewCnt the shipCrewCnt to set
*/
public void setShipCrewCnt(int shipCrewCnt) {
this.shipCrewCnt = shipCrewCnt;
}
/**
* @return the vioCnt
*/
public int getVioCnt() {
return vioCnt;
}
/**
* @param vioCnt the vioCnt to set
*/
public void setVioCnt(int vioCnt) {
this.vioCnt = vioCnt;
}
/**
* @return the priatedAmt
*/
public int getPriatedAmt() {
return priatedAmt;
}
/**
* @param priatedAmt the priatedAmt to set
*/
public void setPriatedAmt(int priatedAmt) {
this.priatedAmt = priatedAmt;
}
/**
* @return the procContNCnt
*/
public int getProcContNCnt() {
return procContNCnt;
}
/**
* @param procContNCnt the procContNCnt to set
*/
public void setProcContNCnt(int procContNCnt) {
this.procContNCnt = procContNCnt;
}
/**
* @return the procContYCnt
*/
public int getProcContYCnt() {
return procContYCnt;
}
/**
* @param procContYCnt the procContYCnt to set
*/
public void setProcContYCnt(int procContYCnt) {
this.procContYCnt = procContYCnt;
}
/**
* @return the paymentAmt
*/
public int getPaymentAmt() {
return paymentAmt;
}
/**
* @param paymentAmt the paymentAmt to set
*/
public void setPaymentAmt(int paymentAmt) {
this.paymentAmt = paymentAmt;
}
/**
* @return the noPaymentCnt
*/
public int getNoPaymentCnt() {
return noPaymentCnt;
}
/**
* @param noPaymentCnt the noPaymentCnt to set
*/
public void setNoPaymentCnt(int noPaymentCnt) {
this.noPaymentCnt = noPaymentCnt;
}
/**
* @return the shipProcTypeACnt
*/
public int getShipProcTypeACnt() {
return shipProcTypeACnt;
}
/**
* @param shipProcTypeACnt the shipProcTypeACnt to set
*/
public void setShipProcTypeACnt(int shipProcTypeACnt) {
this.shipProcTypeACnt = shipProcTypeACnt;
}
/**
* @return the shipProcTypeBCnt
*/
public int getShipProcTypeBCnt() {
return shipProcTypeBCnt;
}
/**
* @param shipProcTypeBCnt the shipProcTypeBCnt to set
*/
public void setShipProcTypeBCnt(int shipProcTypeBCnt) {
this.shipProcTypeBCnt = shipProcTypeBCnt;
}
/**
* @return the shipProcTypeCCnt
*/
public int getShipProcTypeCCnt() {
return shipProcTypeCCnt;
}
/**
* @param shipProcTypeCCnt the shipProcTypeCCnt to set
*/
public void setShipProcTypeCCnt(int shipProcTypeCCnt) {
this.shipProcTypeCCnt = shipProcTypeCCnt;
}
/**
* @return the shipProcTypeDCnt
*/
public int getShipProcTypeDCnt() {
return shipProcTypeDCnt;
}
/**
* @param shipProcTypeDCnt the shipProcTypeDCnt to set
*/
public void setShipProcTypeDCnt(int shipProcTypeDCnt) {
this.shipProcTypeDCnt = shipProcTypeDCnt;
}
/**
* @return the shipProcTypeECnt
*/
public int getShipProcTypeECnt() {
return shipProcTypeECnt;
}
/**
* @param shipProcTypeECnt the shipProcTypeECnt to set
*/
public void setShipProcTypeECnt(int shipProcTypeECnt) {
this.shipProcTypeECnt = shipProcTypeECnt;
}
/**
* @return the captainCount
*/
public int getCaptainCount() {
return captainCount;
}
/**
* @param captainCount the captainCount to set
*/
public void setCaptainCount(int captainCount) {
this.captainCount = captainCount;
}
/**
* @return the engineerCount
*/
public int getEngineerCount() {
return engineerCount;
}
/**
* @param engineerCount the engineerCount to set
*/
public void setEngineerCount(int engineerCount) {
this.engineerCount = engineerCount;
}
/**
* @return the mateCount
*/
public int getMateCount() {
return mateCount;
}
/**
* @param mateCount the mateCount to set
*/
public void setMateCount(int mateCount) {
this.mateCount = mateCount;
}
/**
* @return the crewCount
*/
public int getCrewCount() {
return crewCount;
}
/**
* @param crewCount the crewCount to set
*/
public void setCrewCount(int crewCount) {
this.crewCount = crewCount;
}
/**
* @return the commissionCost
*/
public int getCommissionCost() {
return commissionCost;
}
/**
* @param commissionCost the commissionCost to set
*/
public void setCommissionCost(int commissionCost) {
this.commissionCost = commissionCost;
}
/**
* @return the gearCast
*/
public int getGearCast() {
return gearCast;
}
/**
* @param gearCast the gearCast to set
*/
public void setGearCast(int gearCast) {
this.gearCast = gearCast;
}
/**
* @return the gearWidth
*/
public int getGearWidth() {
return gearWidth;
}
/**
* @param gearWidth the gearWidth to set
*/
public void setGearWidth(int gearWidth) {
this.gearWidth = gearWidth;
}
}

View File

@ -0,0 +1,349 @@
/*
* Copyright 2014 MOPAS(Ministry of Public Administration and Security).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kcg.faics.arrest.vo;
import kcg.faics.cmmn.bbs.BaseSearchVO;
/**
* ArrestSearchVO.java
* @author
* @since 2017. 3. 15.
*
*
* ------------- -------- ---------------------------
* 2017. 3. 15.
*
*/
public class ArrestSearchVO extends BaseSearchVO {
/**
*
*/
private String startDate = "";
/**
*
*/
private String endDate = "";
/**
* ()
*/
private String agencyType = "";
/**
*
*/
private String agencyGuard = "";
/**
* ()
*/
private String agencyVessel = "";
/**
*
*/
private String addrArea = "";
/**
*
*/
private String addrCity = "";
/**
*
*/
private String violateType = "";
/**
*
*/
private String shipName = "";
/**
* invasionType
*/
private String[] invasionType = null;
/**
*
*/
private String[] shipType = null;
/**
*
*/
private String[] procCondition = null;
/**
*
*/
private String[] arrShipTonnage = null;
/**
*
*/
private String[] marginPayment = null;
/**
*
*/
private String[] shipProcType = null;
/**
*
*/
private String[] shipQuality = null;
/**
*
*/
private String[] shipMent = null;
/**
* NLL
*/
private String[] nllYn = null;
/**
* ()
*/
private String[] specBatlYn = null;
/**
* @return the agencyType
*/
public String getAgencyType() {
return agencyType;
}
/**
* @param agencyType the agencyType to set
*/
public void setAgencyType(String agencyType) {
this.agencyType = agencyType;
}
/**
* @return the agencyGuard
*/
public String getAgencyGuard() {
return agencyGuard;
}
/**
* @param agencyGuard the agencyGuard to set
*/
public void setAgencyGuard(String agencyGuard) {
this.agencyGuard = agencyGuard;
}
/**
* @return the agencyVessel
*/
public String getAgencyVessel() {
return agencyVessel;
}
/**
* @param agencyVessel the agencyVessel to set
*/
public void setAgencyVessel(String agencyVessel) {
this.agencyVessel = agencyVessel;
}
/**
* @return the nllYn
*/
public String[] getNllYn() {
return nllYn;
}
/**
* @param nllYn the nllYn to set
*/
public void setNllYn(String[] nllYn) {
this.nllYn = nllYn;
}
/**
* @return the specBatlYn
*/
public String[] getSpecBatlYn() {
return specBatlYn;
}
/**
* @param specBatlYn the specBatlYn to set
*/
public void setSpecBatlYn(String[] specBatlYn) {
this.specBatlYn = specBatlYn;
}
/**
* @return the shipProcType
*/
public String[] getShipProcType() {
return shipProcType;
}
/**
* @param shipProcType the shipProcType to set
*/
public void setShipProcType(String[] shipProcType) {
this.shipProcType = shipProcType;
}
/**
* @return the shipQuality
*/
public String[] getShipQuality() {
return shipQuality;
}
/**
* @param shipQuality the shipQuality to set
*/
public void setShipQuality(String[] shipQuality) {
this.shipQuality = shipQuality;
}
/**
* @return the shipMent
*/
public String[] getShipMent() {
return shipMent;
}
/**
* @param shipMent the shipMent to set
*/
public void setShipMent(String[] shipMent) {
this.shipMent = shipMent;
}
/**
* @return the startDate
*/
public String getStartDate() {
return startDate;
}
/**
* @param startDate the startDate to set
*/
public void setStartDate(String startDate) {
this.startDate = startDate;
}
/**
* @return the endDate
*/
public String getEndDate() {
return endDate;
}
/**
* @param endDate the endDate to set
*/
public void setEndDate(String endDate) {
this.endDate = endDate;
}
/**
* @return the addrArea
*/
public String getAddrArea() {
return addrArea;
}
/**
* @param addrArea the addrArea to set
*/
public void setAddrArea(String addrArea) {
this.addrArea = addrArea;
}
/**
* @return the addrCity
*/
public String getAddrCity() {
return addrCity;
}
/**
* @param addrCity the addrCity to set
*/
public void setAddrCity(String addrCity) {
this.addrCity = addrCity;
}
/**
* @return the violateType
*/
public String getViolateType() {
return violateType;
}
/**
* @param violateType the violateType to set
*/
public void setViolateType(String violateType) {
this.violateType = violateType;
}
/**
* @return the invasionType
*/
public String getShipName() {
return shipName;
}
/**
* @param shipName the shipName to set
*/
public void setShipName(String shipName) {
this.shipName = shipName;
}
/**
* @return the invasionType
*/
public String[] getInvasionType() {
return invasionType;
}
/**
* @param invasionType the invasionType to set
*/
public void setInvasionType(String[] invasionType) {
this.invasionType = invasionType;
}
/**
* @return the shipType
*/
public String[] getShipType() {
return shipType;
}
/**
* @param shipType the shipType to set
*/
public void setShipType(String[] shipType) {
this.shipType = shipType;
}
/**
* @return the procCondition
*/
public String[] getProcCondition() {
return procCondition;
}
/**
* @param procCondition the procCondition to set
*/
public void setProcCondition(String[] procCondition) {
this.procCondition = procCondition;
}
/**
* @return the arrShipTonnage
*/
public String[] getArrShipTonnage() {
return arrShipTonnage;
}
/**
* @param arrShipTonnage the arrShipTonnage to set
*/
public void setArrShipTonnage(String[] arrShipTonnage) {
this.arrShipTonnage = arrShipTonnage;
}
/**
* @return the marginPayment
*/
public String[] getMarginPayment() {
return marginPayment;
}
/**
* @param marginPayment the marginPayment to set
*/
public void setMarginPayment(String[] marginPayment) {
this.marginPayment = marginPayment;
}
/**
* @return the obj.length
*/
public static int length(String[] obj){
return obj.length;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,508 @@
package kcg.faics.arrest.web;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import javax.annotation.Resource;
import kcg.faics.arrest.service.ArrestService;
import kcg.faics.arrest.vo.ArrestCountVO;
import kcg.faics.arrest.vo.ArrestSearchVO;
import kcg.faics.arrest.vo.ArrestVO;
import kcg.faics.cmmn.excel.ExcelExporter;
import kcg.faics.cmmn.service.CodeService;
import kcg.faics.cmmn.vo.CodeVO;
import kcg.faics.sec.AuthType;
import kcg.faics.sec.LoginUserVO;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
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.bind.annotation.ResponseBody;
import org.springframework.web.bind.support.SessionStatus;
/**
* ArrestController.java
* @author
* @since 2017. 3. 12.
*
*
* ------------- -------- ---------------------------
* 2017. 3. 12.
*
*/
@Controller
@RequestMapping("/arrest")
public class ArrestController {
/**
* .
*/
@Resource(name = "codeService")
private CodeService codeService;
/**
* .
*/
@Resource(name = "arrestService")
private ArrestService arrestService;
/**
* .
* @param arrestSearchVo
* @param model
* @return
* @throws Exception
*/
@RequestMapping(value = "/arrestListView.do")
public String arrestListView(final ArrestSearchVO arrestSearchVo, Model model) throws Exception {
try {
// 공통코드 조회
model = getCommonCode(model);
// 중국어선 나포정보 목록 조회
//arrestList = arrestService.getArrestListAll(arrestSearchVo);
// 중국어선 나포정보 목록 집계정보 조회(단건)
//arrestCntList = arrestService.getArrestListAllCount(arrestSearchVo);
//model.addAttribute("arrestList", arrestList);
//model.addAttribute("arrestCntList", arrestCntList);
model.addAttribute("listFlag", "init");
} catch (Exception e) {
e.printStackTrace();
}
return "/arrest/arrestList.tiles";
}
/**
* .
*
* @param arrestSearchVO
* @param model
* @return
* @throws Exception
*/
@RequestMapping(value = "/arrestList.do")
public String arrestList(@ModelAttribute final ArrestSearchVO arrestSearchVO, Model model) throws Exception {
List<ArrestVO> arrestList = null; // 중국어선나포정보목록
ArrestVO arrestCntList = null; // 중국어선나포정보 집계건수
HashMap<String, Object> resultMap = new HashMap<String, Object>();
try {
// 공통코드 조회
// model = getCommonCode(model);
model.addAttribute("arrestList", null);
model.addAttribute("arrestCntList", null);
// 중국어선 나포정보 목록 조회
arrestList = arrestService.getArrestList(arrestSearchVO);
if (arrestList.size() > 0) {
// 중국어선 나포정보 집계정보 조회
arrestCntList = arrestService.getArrestListCount(arrestSearchVO);
} else {
arrestCntList = null;
}
model.addAttribute("arrestList", arrestList);
model.addAttribute("arrestCntList", arrestCntList);
model.addAttribute("arrestSearchVO", arrestSearchVO);
resultMap.put("msg", "정상으로 조회되었습니다.");
resultMap.put("code", 0);
} catch (Exception e) {
e.printStackTrace();
}
return "/arrest/arrestResult";
}
/**
* .
*
* @param model Model
* @return model
* @throws Exception
*/
public Model getCommonCode(final Model model) throws Exception {
List<CodeVO> agencyTypeList = null; // 기관종류
List<CodeVO> placeList = null; // 소속
List<CodeVO> addressList = null; // 주소
List<CodeVO> violateTypeList = null; // 위반내용구분
List<CodeVO> shipTypeList = null; // 선종
List<CodeVO> shipMentList = null; // 선적
List<CodeVO> shipQualityList = null; // 선질
List<CodeVO> shipProcTypeList = null; // 선박처리
List<CodeVO> invasionTypeList = null; // 침범유형
List<CodeVO> woDetentionTypeList = null; // 무혐의불구속
List<CodeVO> marginPaymentYnList = null; // 담보금납부여부
LoginUserVO loginUserVo = new LoginUserVO();
try {
if (AuthType.LOCAL_HEADQUARTERS == loginUserVo.getAuthType()) {
placeList = codeService.getPlace1SubList(loginUserVo.getPlace1());
} else {
placeList = codeService.getPlace1List(false);
}
agencyTypeList = codeService.getCodeValues("T002", ""); /* 검거기관대분류 */
addressList = arrestService.getAddressAreaList("0000"); /* 주소(특별광역시도) */
violateTypeList = codeService.getCodeValues("T003", ""); /* 위반내용구분 */
shipTypeList = codeService.getCodeValues("FA81", ""); /* 선종 조회 */
shipMentList = codeService.getCodeValues("SSRR", ""); /* 선적 */
shipQualityList = codeService.getCodeValues("T004", ""); /* 선질 */
shipProcTypeList = codeService.getCodeValues("T007", ""); /* 선박처리 */
invasionTypeList = codeService.getCodeValues("T006", ""); /* 선박처리 */
woDetentionTypeList = codeService.getCodeValues("T005", ""); /* 선박처리 */
marginPaymentYnList = codeService.getCodeValues("T008", ""); /* 담보금납부여부 */
Collections.reverse(marginPaymentYnList);
//Collections.sort(marginPaymentYnList, comparator);
//CodeVO codeVO = marginPaymentYnList.get(1);
//marginPaymentYnList.set(1, marginPaymentYnList.get(0));
//marginPaymentYnList.set(0, codeVO);
model.addAttribute("placeList", placeList);
model.addAttribute("addressList", addressList);
model.addAttribute("shipQualityList", shipQualityList);
model.addAttribute("shipMentList", shipMentList);
model.addAttribute("shipTypeList", shipTypeList);
model.addAttribute("violateTypeList", violateTypeList);
model.addAttribute("agencyTypeList", agencyTypeList);
model.addAttribute("shipProcTypeList", shipProcTypeList);
model.addAttribute("invasionTypeList", invasionTypeList);
model.addAttribute("woDetentionTypeList", woDetentionTypeList);
model.addAttribute("marginPaymentYnList", marginPaymentYnList);
} catch (Exception e) {
e.printStackTrace();
}
return model;
}
/**
* / .
*
* @param arrestVo
* @param model
* @return
* @throws Exception
*/
@RequestMapping(value = "/arrestAdd.do")
public String arrestAdd(final ArrestVO arrestVo, Model model) throws Exception {
try {
// 공통코드 조회
model = getCommonCode(model);
model.addAttribute("regFlag", "create");
} catch (Exception e) {
e.printStackTrace();
}
return "/arrest/arrestAdd.tiles";
}
/**
* .
*
* @param area
* @param arrestVo
* @param model
* @return
* @throws Exception
*/
@RequestMapping(value = "/getAddressAreaList.do")
public String getAddressAreaList(@RequestParam("area") final String area,
final ArrestVO arrestVo, final Model model) throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
List<CodeVO> addressCityList = null;
try {
/* 특별광역시&도청 목록조회 */
addressCityList = arrestService.getAddressAreaList(area);
model.addAttribute("addressCityList", addressCityList);
result.put("result", "OK");
result.put("msg", "시목록 조회성공");
} catch (Exception e) {
e.printStackTrace();
}
return "/arrest/arrestAdd.tiles";
}
/**
* .
*
* @param codeVO
* VO
* @return
* @throws Exception
*
*/
@ResponseBody
@RequestMapping("/getAddressList.json")
public HashMap<String, Object> getAddressList(final CodeVO codeVO)
throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
List<CodeVO> addressCityList = null;
String area = codeVO.getCode1();
/* 특별광역시&도청 목록조회 */
addressCityList = arrestService.getAddressAreaList(area);
result.put("data", addressCityList);
// model.addAttribute("addressCityList", addressCityList);
return result;
}
/**
* .
*
* @param arrestVO
*
* @param bindingResult
*
* @param model
*
* @param status
*
* @return
* @throws Exception
*
*/
@RequestMapping(value = "/arrestInsert.do", method = RequestMethod.POST)
public String arrestTempInsert(
@ModelAttribute("arrestVO") final ArrestVO arrestVO,
final BindingResult bindingResult, final Model model,
final SessionStatus status) throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
try {
arrestVO.setDelYn("N"); // 삭제여부
/* 중국어선 나포정보 등록 */
result = arrestService.insert(arrestVO);
} catch (Exception e) {
e.printStackTrace();
}
if ((Integer) result.get("result") != 1) {
return "redirect:/arrest/arrestAdd.do";
}
return "redirect:/arrest/arrestListView.do";
}
/**
* .
* @param arrestVO
*
* @param bindingResult
*
* @param model
*
* @param status
*
* @return
* @throws Exception
*
*/
@RequestMapping(value = "/arrestUpdate.do", method = RequestMethod.POST)
public String arrestUpdate(@ModelAttribute("arrestVO") final ArrestVO arrestVO,
final BindingResult bindingResult, final Model model, final SessionStatus status) throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
try {
arrestVO.setDelYn("N"); // 삭제여부
result = arrestService.update(arrestVO);
} catch (Exception e) {
e.printStackTrace();
}
if ((Integer) result.get("result") != 1) {
return "redirect:/arrest/arrestAdd.do";
}
return "redirect:/arrest/arrestListView.do";
}
/**
* .
* @param arrestVO
*
* @param bindingResult
*
* @param model
*
* @param status
*
* @return
* @throws Exception
*
*/
@RequestMapping(value = "/arrestDelete.do", method = RequestMethod.POST)
public String arrestDelete(@ModelAttribute("arrestVO") final ArrestVO arrestVO,
final BindingResult bindingResult, final Model model, final SessionStatus status) throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
try {
arrestVO.setDelYn("Y"); // 삭제여부
result = arrestService.delete(arrestVO);
} catch (Exception e) {
e.printStackTrace();
}
if ((Integer) result.get("result") != 1) {
return "redirect:/arrest/arrestAdd.do";
}
return "redirect:/arrest/arrestListView.do";
}
/**
* .
*
* @param arrestVO
* @param model
* @return
* @throws Exception
*/
@RequestMapping("/arrestView.do")
public String arrestView(final ArrestVO arrestVO, Model model) throws Exception {
try {
// 중국어선 나포정보 단건조회
ArrestVO result = arrestService.select(arrestVO);
// 공통코드 조회
model = getCommonCode(model);
model.addAttribute("arrestVO", result);
model.addAttribute("regFlag", "modify");
} catch (Exception e) {
e.printStackTrace();
}
return "/arrest/arrestAdd.tiles";
}
/**
*
* @param searchVO
* @param model Model
* @return
*/
@RequestMapping("/arrestExcelDownload.do")
public String arrestExcelDownload(final ArrestSearchVO searchVO, final Model model) throws Exception {
Calendar cal = Calendar.getInstance();
ArrestVO arrestCntList = null;
String title = cal.get(cal.YEAR) + "년 중국어선 나포처리현황";
List<ArrestVO> arrestList = arrestService.getArrestListExcel(searchVO);
if (arrestList.size() > 0) {
arrestCntList = arrestService.getArrestListCount(searchVO);
LinkedHashMap<String, String> header = new LinkedHashMap<String, String>();
header.put("arrestDate", "나포일시");
header.put("addrStr", "위반장소");
header.put("violateDetail", "위반내용");
header.put("invasion3", "침범유형(영해)");
header.put("invasion4", "침범유형(EEZ)");
header.put("invasion1", "침범유형(특정금지)");
header.put("invasion2", "침범유형(무허가)");
header.put("specBatlYn", "침범유형(특공방)");
header.put("nllYn", "NLL");
header.put("agencyGuardStr", "검거기관");
header.put("agencyVessel", "서별(함정)");
header.put("shipName", "선박제원(선명)");
header.put("shipTonnage", "선박제원(톤수)");
header.put("shipCrewCnt", "선박제원(선원)");
header.put("shipQualityStr", "선박제원(선질)");
header.put("shipMentStr", "선박제원(선적)");
header.put("capName", "선장(나이)");
header.put("shipTypeStr", "선종");
header.put("vioFish", "범칙어종");
header.put("vioCnt", "범칙수량");
header.put("vioPriatedAmt", "위판금액");
header.put("procCondN", "조사중");
header.put("procCondY", "완료");
header.put("marginPaymentAmt", "납부액(만원)");
header.put("marginPaymentDate", "납부일시");
header.put("notPayment", "미납");
header.put("noMarginPaymentAmt", "미납금액(만원)");
header.put("shipProcTypeA", "위탁관리");
header.put("shipProcTypeB", "퇴거");
header.put("shipProcTypeC", "직접인계");
header.put("shipProcTypeD", "폐기");
header.put("shipProcTypeE", "몰수");
header.put("detentionTotalCnt", "구속(계)");
header.put("captainCount", "구속선장");
header.put("mateCount", "구속항해사");
header.put("engineerCount", "구속기관장");
header.put("crewCount", "구속선원");
header.put("woDetentionStr", "무혐의불구속");
header.put("fieldCnt", "현장조사건수");
header.put("fieldArrestDate", "나포일시");
header.put("fieldReleaseDate", "석방일시");
header.put("leadDistance", "거리(해리)");
header.put("commissionCost", "위탁금(원)");
header.put("gearCast", "틀");
header.put("gearWidth", "폭");
header.put("gearEtc", "기타");
arrestCntList.setDetentionTotalCnt(String.valueOf(arrestCntList.getCaptainCount()
+ arrestCntList.getMateCount()
+ arrestCntList.getEngineerCount()
+ arrestCntList.getCrewCount()));
arrestCntList.setSpecBatlYn(String.valueOf(arrestCntList.getSpecBatlCnt()));
arrestCntList.setNllYn(String.valueOf(arrestCntList.getNllCnt()));
arrestCntList.setNoPaymentCnt(String.valueOf(arrestCntList.getNotPayment()));
arrestList.add(0, arrestCntList);
model.addAttribute("excel", new ExcelExporter<ArrestVO>(header, arrestList, title));
model.addAttribute("filename", title);
return "excelView";
} else {
return "";
}
}
}

View File

@ -0,0 +1,60 @@
/**
* BoardPreventSqlInjectionAop.java
* @author
* @since 2016. 10. 19.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 19.
*
*/
package kcg.faics.board.aop;
import java.lang.reflect.Field;
import kcg.faics.cmmn.CommonsUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
/**
* BoardPreventSqlInjectionAop.java
* @author
* @since 2016. 10. 19.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 19.
*
*/
@Aspect
@Component
public class BoardPreventSqlInjectionAop {
// id를 필드로 가지고 있는 객체를 파라미터로 받는 메소드만 걸림
@Before("execution(public * kcg.faics.board.service.impl.*Mapper.*(kcg.faics.board.vo.BoardSearchVO))"
+ "|| execution(public * kcg.faics.board.service.impl.*Mapper.*(kcg.faics.board.vo.BoardVO))"
+ "|| execution(public * kcg.faics.board.service.impl.*Mapper.*(kcg.faics.board.vo.BoardFileVO))"
+ "|| execution(public * kcg.faics.board.service.impl.*Mapper.*(kcg.faics.board.vo.BoardCommentVO))")
public void beforeTargetMethod(JoinPoint thisJoinPoint) {
Object[] signatureArgs = thisJoinPoint.getArgs();
for (Object signatureArg: signatureArgs) {
Class<?> clz = signatureArg.getClass();
try {
Field field = clz.getDeclaredField("id");
field.setAccessible(true);
String id = (String) field.get(signatureArg);
id = CommonsUtils.sqlInjectionFilter(id);
field.set(signatureArg, id);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,30 @@
/**
* BoardService.java
* @author
* @since 2016. 10. 25.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 25.
*
*/
package kcg.faics.board.service;
import kcg.faics.board.vo.BoardSearchVO;
import kcg.faics.board.vo.BoardVO;
import kcg.faics.cmmn.bbs.BaseBbsExService;
import kcg.faics.cmmn.bbs.BaseBbsService;
/**
* BoardService.java
* @author
* @since 2016. 10. 25.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 25.
*
*/
public interface BoardService extends BaseBbsService<BoardSearchVO, BoardVO>, BaseBbsExService<BoardSearchVO, BoardVO> {
}

View File

@ -0,0 +1,90 @@
package kcg.faics.board.service.impl;
import java.util.HashMap;
import java.util.List;
import kcg.faics.board.vo.BoardCommentVO;
import org.springframework.stereotype.Repository;
import egovframework.rte.psl.dataaccess.EgovAbstractMapper;
/**
* BoardCommentMapper.java
* @author
* @since 2016. 9. 29.
*
*
* ------------- -------- ---------------------------
* 2016. 9. 29.
*
*/
@Repository("boardCommentMapper")
public class BoardCommentMapper extends EgovAbstractMapper {
/**
* throws Exception { .
*
* @param boardCommentVO
* @return
* @throws Exception
*/
public List<BoardCommentVO> selectCommentList(final BoardCommentVO boardCommentVO) throws Exception {
return selectList("BoardComment.selectCommentList", boardCommentVO);
}
/**
* .
*
* @param boardCommentVO
* @return
* @throws Exception
*/
public BoardCommentVO selectBoardComment(final BoardCommentVO boardCommentVO) throws Exception {
return selectOne("BoardComment.selectBoardComment", boardCommentVO);
}
/**
* .
*
* @param boardCommentVO
* @return - 1, - 0
* @throws Exception
*/
public HashMap<String, Object> insertBoardComment(final BoardCommentVO boardCommentVO) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
int result = 0;
result = insert("BoardComment.insertBoardComment", boardCommentVO);
map.put("seq", boardCommentVO.getSeq());
map.put("result", result);
return map;
}
/**
* .
*
* @param boardCommentVO
* @return - 1, - 0
* @throws Exception
*/
public int deleteBoardComment(final BoardCommentVO boardCommentVO) throws Exception {
return delete("BoardComment.deleteBoardComment", boardCommentVO);
}
/**
* .
*
* @param boardCommentVO
* @return - 1, - 0
* @throws Exception
*/
public int deleteBoardCommentAll(final BoardCommentVO boardCommentVO) throws Exception {
return delete("BoardComment.deleteBoardCommentAll", boardCommentVO);
}
}

View File

@ -0,0 +1,108 @@
/**
*
*/
package kcg.faics.board.service.impl;
import java.util.HashMap;
import java.util.List;
import javax.annotation.Resource;
import kcg.faics.board.vo.BoardCommentVO;
import kcg.faics.cmmn.bbs.BaseCommentService;
import org.springframework.stereotype.Service;
/**
* BoardCommentServiceImpl.java
* @author
* @since 2016. 9. 29.
*
*
* ------------- -------- ---------------------------
* 2016. 9. 29.
*
*/
@Service("boardCommentService")
public class BoardCommentServiceImpl implements BaseCommentService<BoardCommentVO> {
/**
* BoardMapper - Mapper
**/
@Resource(name = "boardCommentMapper")
private BoardCommentMapper boardCommentMapper;
/**
* .
*
* @param bdSeq
* @return
* @throws Exception
*/
@Override
public List<BoardCommentVO> selectList(final BoardCommentVO boardCommentVO) throws Exception {
return boardCommentMapper.selectCommentList(boardCommentVO);
}
/**
* .
*
* @param bcBdSeq
* @return
* @throws Exception
*/
@Override
public BoardCommentVO select(final BoardCommentVO boardCommentVO) throws Exception {
return boardCommentMapper.selectBoardComment(boardCommentVO);
}
/**
* .
*
* @param boardCommentVO
* @return
* @throws Exception
*/
@Override
public HashMap<String, Object> insert(final BoardCommentVO boardCommentVO) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
try {
map = boardCommentMapper.insertBoardComment(boardCommentVO);
} catch (Exception e) {
e.printStackTrace();
map.put("result", 0);
}
return map;
}
/**
* .
*
* @param bcBdSeq
* @return - 1, - 0
* @throws Exception
*/
@Override
public int delete(final BoardCommentVO boardCommentVO) throws Exception {
return boardCommentMapper.deleteBoardComment(boardCommentVO);
}
/**
* .
*
* @param bdSeq
* @return - 1, - 0
* @throws Exception
*/
@Override
public int deleteAll(final BoardCommentVO boardCommentVO) throws Exception {
return boardCommentMapper.deleteBoardCommentAll(boardCommentVO);
}
}

View File

@ -0,0 +1,74 @@
/**
*
*/
package kcg.faics.board.service.impl;
import java.util.List;
import kcg.faics.board.vo.BoardFileVO;
import org.springframework.stereotype.Repository;
import egovframework.rte.psl.dataaccess.EgovAbstractMapper;
/**
* .
* @author
* @since 2016. 9. 22.
* @version 1.0
* @see
* <pre>
*
* ---------- -------- -------------------------
* 2016.09.22
* </pre>
*/
@Repository("boardFileMapper")
public class BoardFileMapper extends EgovAbstractMapper {
/**
* DB .
*
* @param boardFileVO
* @return - 1, - 0
* @exception Exception
*/
public int insertFile(final BoardFileVO boardFileVO) throws Exception {
return insert("BoardFile.insertBoardFile", boardFileVO);
}
/**
* .
*
* @param boardFileVO
* @return
* @throws Exception
*/
public List<BoardFileVO> selectFiles(final BoardFileVO boardFileVO) throws Exception {
return selectList("BoardFile.selectBoardFiles", boardFileVO);
}
/**
* .
*
* @param boardFileVO
* @return
* @throws Exception
*/
public BoardFileVO selectFile(final BoardFileVO boardFileVO) throws Exception {
return selectOne("BoardFile.selectBoardFile", boardFileVO);
}
/**
* DB .
*
* @param bfSeq
* @return - 1, - 0
* @throws Exception
*/
public int deleteFile(final BoardFileVO boardFileVO) throws Exception {
return delete("BoardFile.deleteBoardFile", boardFileVO);
}
}

View File

@ -0,0 +1,207 @@
package kcg.faics.board.service.impl;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import kcg.faics.board.util.BoardUtils;
import kcg.faics.board.util.BoardVOHandler;
import kcg.faics.board.vo.BoardFileVO;
import kcg.faics.cmmn.bbs.BaseFileService;
import kcg.faics.cmmn.egov.file.EgovFileMngUtil;
import kcg.faics.cmmn.egov.vo.FileVO;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
/**
* BoardFileServiceImpl.java
* @author
* @since 2016. 9. 28.
*
*
* ------------- -------- ---------------------------
* 2016. 9. 28.
*
*/
@Service("boardFileService")
public class BoardFileServiceImpl implements BaseFileService<BoardFileVO> {
/**
* BoardFileMapper - Mapper
**/
@Resource(name = "boardFileMapper")
private BoardFileMapper boardFileMapper;
/**
* EgovFileMngUtil - Util
**/
@Resource(name = "EgovFileMngUtil")
private EgovFileMngUtil fileUtil;
/**
* .
*
* @param bfBdSeq
* @return
* @throws Exception
*/
@Override
public List<BoardFileVO> selectList(final BoardFileVO boardFileVO) throws Exception {
return (List<BoardFileVO>) boardFileMapper.selectFiles(boardFileVO);
}
/**
* .
*
* @param bfSeq
* @return
* @throws Exception
*/
@Override
public BoardFileVO select(final BoardFileVO boardFileVO) throws Exception {
return boardFileMapper.selectFile(boardFileVO);
}
/**
* DB .
*
* @param bfBdSeq
* @param fileVO
* @return - 1, - 0
* @exception Exception
*/
@Override
public int insert(final BoardFileVO boardFileVO) throws Exception {
return boardFileMapper.insertFile(boardFileVO);
}
/**
* .
*
* @param bfBdSeq
* @param fileMap ,
* @return - 1, - 0
* @exception Exception
*/
@Override
@Transactional
public int insertAndSaveFiles(BoardFileVO boardFileVO, final Map<String, MultipartFile> fileMap) throws Exception {
int result = 1;
String storePathKey = "";
String boardId = "";
/* 파일쓰기 */
if (!fileMap.isEmpty()) {
if (boardFileVO != null) {
boardId = boardFileVO.getId();
boardId = StringUtils.lowerCase(boardId);
}
storePathKey = BoardUtils.getStorePathKey(boardId);
List<FileVO> uploadedFile = fileUtil.parseFileInf(fileMap, "_", 0, "", storePathKey);
/* DB에 업로드한 첨부파일 레코드를 추가한다. */
Iterator<FileVO> itr = uploadedFile.iterator();
while (itr.hasNext()) {
FileVO fileVO = itr.next();
boardFileVO.setOrgName(fileVO.getOrignlFileNm());
boardFileVO.setSaveName(fileVO.getStreFileNm());
boardFileVO.setOrders(Integer.parseInt(fileVO.getFileSn().replace("file", "")));
result = insert(boardFileVO);
if (result != 1) {
throw new Exception();
}
}
}
return result;
}
/**
* .
*
* @param boardFileVO
* @return - 1, - 0
* @throws Exception
*/
@Override
public int deleteAndRemoveFile(final BoardFileVO boardFileVO) throws Exception {
int result = boardFileMapper.deleteFile(boardFileVO);
String storePathKey = "";
if (result == 1) {
/* DB에서 파일 데이터 삭제 후 실제 파일 삭제 여부는 보장하지 않는다. */
try {
storePathKey = BoardUtils.getStorePathKey(boardFileVO.getId());
fileUtil.deleteFile(boardFileVO.getSaveName(), storePathKey);
} catch (Exception e) {
e.printStackTrace();
}
}
return result;
}
/**
* .
*
* @param bfBdSeq
* @param deleteFiles
* @return - 1, - 0
* @throws Exception
*/
@Override
@Transactional
public int delete(final BoardFileVO boardFileVO) throws Exception {
int result = 1;
if (boardFileVO.getDeleteFiles() != null) {
for (String fileSeq : boardFileVO.getDeleteFiles()) {
BoardFileVO deleteFile = BoardVOHandler.getBFileVO(boardFileVO);
deleteFile.setSeq(Integer.parseInt(fileSeq));
deleteFile = select(deleteFile);
result = deleteAndRemoveFile(deleteFile);
if (result != 1) {
throw new Exception();
}
}
}
return result;
}
/**
* .
*
* @param bfBdSeq
* @return - 1, - 0
* @throws Exception
*/
@Override
@Transactional
public int deleteAndRemoveFiles(final BoardFileVO boardFileVO) throws Exception {
int result = 1;
List<BoardFileVO> fileList = boardFileMapper.selectFiles(boardFileVO);
if (fileList != null) {
for (BoardFileVO file : fileList) {
result = deleteAndRemoveFile(file);
if (result != 1) {
throw new Exception();
}
}
}
return result;
}
}

View File

@ -0,0 +1,163 @@
package kcg.faics.board.service.impl;
import java.util.HashMap;
import java.util.List;
import kcg.faics.board.vo.BoardSearchVO;
import kcg.faics.board.vo.BoardVO;
import org.springframework.stereotype.Repository;
import egovframework.rte.psl.dataaccess.EgovAbstractMapper;
/**
* BoardMapper.java
* @author
* @since 2016. 9. 29.
*
*
* ------------- -------- ---------------------------
* 2016. 9. 29.
*
*/
@Repository("boardMapper")
public class BoardMapper extends EgovAbstractMapper {
/**
* .
*
* @param searchVO ,
* @return
* @throws Exception
*/
public List<BoardVO> selectBoardList(final BoardSearchVO searchVO) throws Exception {
return selectList("Board.selectBoardList", searchVO);
}
/**
* .
*
* @param searchVO ,
* @return
* @exception Exception
*/
public int selectBoardListTotCnt(final BoardSearchVO searchVO) throws Exception {
return (Integer) selectOne("Board.selectBoardListTotCnt", searchVO);
}
/**
* .
* @param searchVO
*
* @return
* @throws Exception
*/
public int selectBoardTotalCnt(final BoardSearchVO searchVO) throws Exception {
return (Integer) selectOne("Board.selectBoardTotalCnt", searchVO);
}
/**
* group seq
*
* @param boardVO BoardVO
* @return - 1, - 0
* @throws Exception
*/
public int updateGrpStep(final BoardVO boardVO) throws Exception {
return update("Board.updateGrpStep", boardVO);
}
/**
* group seq
*
* @param boardVO BoardVO
* @return
* @throws Exception
*/
public BoardVO selectPrevBoard(final BoardVO boardVO) throws Exception {
return selectOne("Board.selectPrevBoard", boardVO);
}
/**
* prevSeq, nextSeq .
*
* @param boardVO BoardVO
* @return - 1, - 0
* @throws Exception
*/
public int updatePrevNextSeq(final BoardVO boardVO) throws Exception {
return update("Board.updatePrevNextSeq", boardVO);
}
/**
* .
*
* @param boardVO
* @return
* @throws Exception
*/
public HashMap<String, Object> insertBoard(final BoardVO boardVO) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
int result = 0;
try {
result = insert("Board.insertBoard", boardVO);
map.put("result", result);
map.put("seq", boardVO.getSeq());
} catch (Exception e) {
e.printStackTrace();
}
return map;
};
/**
* .
*
* @param boardVO VO
* @return
* @throws Exception
*/
public BoardVO selectBoard(final BoardVO boardVO) throws Exception {
return selectOne("Board.selectBoard", boardVO);
}
/**
* group 퀀 .
*
* @param boardVO VO
* @return - 1, - 0
* @throws Exception
*/
public int updateGrpSeq(final BoardVO boardVO) throws Exception {
return update("Board.updateGrpSeq", boardVO);
}
/**
* DB .
*
* @param boardVO VO
* @return - 1, - 0
* @throws Exception
*/
public int updateBoard(final BoardVO boardVO) throws Exception {
return update("Board.updateBoard", boardVO);
}
/**
* .
*
* @param boardVO VO
* @return HashMap/ seq : , result : - 1, - 0
* @throws Exception
*/
public int deleteBoard(final BoardVO boardVO) throws Exception {
return delete("Board.deleteBoard", boardVO);
}
}

View File

@ -0,0 +1,363 @@
package kcg.faics.board.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import kcg.faics.board.service.BoardService;
import kcg.faics.board.util.BoardVOHandler;
import kcg.faics.board.vo.BoardCommentVO;
import kcg.faics.board.vo.BoardFileVO;
import kcg.faics.board.vo.BoardSearchVO;
import kcg.faics.board.vo.BoardVO;
import kcg.faics.cmmn.bbs.BaseCommentService;
import kcg.faics.cmmn.bbs.BaseFileService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import egovframework.rte.fdl.cmmn.EgovAbstractServiceImpl;
/**
* BoardServiceImpl.java
* @author
* @since 2016. 9. 28.
*
*
* ------------- -------- ---------------------------
* 2016. 9. 28.
*
*/
@Service("boardService")
public class BoardServiceImpl extends EgovAbstractServiceImpl implements BoardService {
/**
* BoardMapper - Mapper
**/
@Resource(name = "boardMapper")
private BoardMapper boardMapper;
/**
* BoardFileService -
**/
@Resource(name = "boardFileService")
private BaseFileService<BoardFileVO> boardFileService;
/**
* BoardCommentService -
**/
@Resource(name = "boardCommentService")
private BaseCommentService<BoardCommentVO> boardCommentService;
/**
* .
*
* @param searchVO ,
* @return
* @throws Exception
*/
@Override
public List<BoardVO> selectList(final BoardSearchVO searchVO) throws Exception {
return boardMapper.selectBoardList(searchVO);
}
/**
* .
*
* @param searchVO ,
* @return
* @exception Exception
*/
@Override
public int selectListCnt(final BoardSearchVO searchVO) throws Exception {
return boardMapper.selectBoardListTotCnt(searchVO);
}
/**
* .
*
* @return
* @throws Exception
*/
@Override
public int selectTotalCnt(final BoardSearchVO searchVO) throws Exception {
return boardMapper.selectBoardTotalCnt(searchVO);
}
/**
* .
*
* @param bdSeq
* @return
* @throws Exception
*/
@Override
public BoardVO select(final BoardVO boardVO) throws Exception {
return boardMapper.selectBoard(boardVO);
}
/**
* or 퀀 .
*
* @param bdSeq 퀀
* @param prevNextChar (P) or {N)
* @param seqValue 퀀
* @return 1-, 0-
*/
private int updatePrevNextSeq(final BoardVO boardVO, final String prevNextChar, final int seqValue) {
int result = 0;
boolean isContinue = false;
try {
BoardVO updateBoard = boardMapper.selectBoard(boardVO);
if ("P".equals(prevNextChar)) {
updateBoard.setPrevSeq(seqValue);
isContinue = true;
} else if ("N".equals(prevNextChar)) {
updateBoard.setNextSeq(seqValue);
isContinue = true;
}
if (isContinue) {
result = boardMapper.updatePrevNextSeq(updateBoard);
}
} catch (Exception e) {
e.printStackTrace();
return result;
}
return result;
}
/**
* .
*
* @param boardVO
* @return HashMap/ seq : , result : - 1, - 0
* @throws Exception
*/
private HashMap<String, Object> insert(final BoardVO boardVO) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
/* 답글인 경우 */
if (boardVO.getIsReply() > 0) {
boardVO.setDepth(boardVO.getDepth() + 1);
boardVO.setStep(boardVO.getStep() + 1);
boardVO.setNextSeq(boardVO.getParentSeq());
}
/* seq 및 insert 결과 */
map = boardMapper.insertBoard(boardVO);
int seq = (Integer) map.get("seq");
int result = (Integer) map.get("result");
if (seq > 0 && result > 0) {
boardVO.setSeq(seq);
/* 답글인 경우 */
if (boardVO.getIsReply() > 0) {
// 스텝순서 변경
boardMapper.updateGrpStep(boardVO);
// 추가된 글의 다음글의 prevSeq 변경
BoardVO nextBoard = BoardVOHandler.getBoardVO(boardVO.getId(), boardVO.getParentSeq());
this.updatePrevNextSeq(nextBoard, "P", seq);
} else {
/* 새 게시글 추가의 경우 추가한 게시물의 group seq를 자기 자신으로 설정한다. */
boardMapper.updateGrpSeq(boardVO);
}
// 이전글 정보를 가져온다
BoardVO prevBoard = boardMapper.selectPrevBoard(boardVO);
if (prevBoard != null) {
/* 이전 글의 next_seq 설정 */
this.updatePrevNextSeq(prevBoard, "N", seq);
/* 현재 글의 prev_seq 설정 */
this.updatePrevNextSeq(boardVO, "P", prevBoard.getSeq());
} else {
this.updatePrevNextSeq(boardVO, "P", 0);
}
} else {
throw new Exception();
}
return map;
}
/**
* .
*
* @param boardVO
* @param fileMap
* @return HashMap/ seq : , result : - 1, - 0
* @exception Exception
*/
@Override
@Transactional
public HashMap<String, Object> insert(final BoardVO boardVO, final Map<String, MultipartFile> fileMap) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
/* seq 획득 */
map = insert(boardVO);
int seq = (Integer) map.get("seq");
int result = (Integer) map.get("result");
/* 파일 업로드 */
BoardFileVO boardFileVO = BoardVOHandler.getBFileVO(boardVO.getId(), seq, 0);
result = boardFileService.insertAndSaveFiles(boardFileVO, fileMap);
if (result != 1) {
throw new Exception();
} else {
map.put("result", result);
}
return map;
}
/**
* DB .
*
* @param boardVO VO
* @return - 1, - 0
* @throws Exception
*/
private int updateBoard(final BoardVO boardVO) throws Exception {
return boardMapper.updateBoard(boardVO);
};
/**
* .
*
* @param boardVO VO
* @param fileMap MultipartFile
* @param deleteFiles
* @return HashMap/ seq : , result : - 1, - 0
*/
@Override
@Transactional
public HashMap<String, Object> update(final BoardVO boardVO, final Map<String, MultipartFile> fileMap, final String[] deleteFiles) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
int result = 0;
BoardFileVO boardFileVO= BoardVOHandler.getBFileVO(boardVO);
boardFileVO.setDeleteFiles(deleteFiles);
boardFileService.delete(boardFileVO);
boardFileService.insertAndSaveFiles(boardFileVO, fileMap);
result = this.updateBoard(boardVO);
if (result != 1) {
throw new Exception();
} else {
map.put("result", result);
map.put("seq", boardVO.getSeq());
}
return map;
}
/**
* .
*
* @param bdSeq
* @return HashMap/ seq : , result : - 1, - 0
*/
@Transactional
@Override
public HashMap<String, Object> delete(final BoardVO boardVO) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
int result = 0;
/* 삭제 후 처리를 위해 데이터 캐싱 */
BoardVO delBoard = boardMapper.selectBoard(boardVO);
result = boardMapper.deleteBoard(delBoard);
if (result == 1) {
/* 이전 글, 다음 글의 이전/다음 시퀀스 재조정 */
int prevSeq = boardVO.getPrevSeq();
int nextSeq = boardVO.getNextSeq();
if (prevSeq > 0) {
this.updatePrevNextSeq(BoardVOHandler.getBoardVO(boardVO.getId(), prevSeq), "N", nextSeq);
}
if (nextSeq > 0) {
this.updatePrevNextSeq(BoardVOHandler.getBoardVO(boardVO.getId(), nextSeq), "P", prevSeq);
}
/* 파일을 삭제한다. */
boardFileService.deleteAndRemoveFiles(BoardVOHandler.getBFileVO(delBoard));
/* 댓글을 삭제한다. */
boardCommentService.deleteAll(BoardVOHandler.getBCommentVO(delBoard));
map.put("result", result);
} else {
throw new Exception();
}
return map;
};
/**
* .
*
* @param bdSeqs
* @return - 1, - 0
*/
@Override
public HashMap<String, Object> selectAndDelete(final BoardVO boardVO, final int[] boardList) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
int result = 0;
if (boardList != null) {
for (int seq : boardList) {
boardVO.setSeq(seq);
map = delete(boardVO);
result = (Integer) map.get("result");
if (result != 1) {
throw new Exception();
}
}
}
map.put("result", result);
return map;
};
/**
* 1 .
*
* @param boardVO VO
* @return 1-, 0-
*/
@Override
public int incHit(final BoardVO boardVO) throws Exception {
int result = 0;
boardVO.incHit();
result = this.updateBoard(boardVO);
return result;
}
@Override
public List<BoardVO> selectListAll(BoardSearchVO searchVO) throws Exception {
return null;
}
}

View File

@ -0,0 +1,67 @@
package kcg.faics.board.util;
import org.apache.commons.lang3.StringUtils;
/**
* .
*
* @author kimnomin
*
*/
public final class BoardUtils {
/**
* .
*/
private BoardUtils() {
}
/**
* .
*
* @param boardId
* ID
* @return
*/
public static String getStorePathKey(final String boardId) {
String storePathKey = "";
String boardIdLower = "";
if (StringUtils.isNotBlank(boardId)) {
boardIdLower = StringUtils.lowerCase(boardId);
}
switch (boardIdLower) {
case "bbs":
storePathKey = "Bbs.bbs.fileStorePath";
break;
case "data":
storePathKey = "Bbs.data.fileStorePath";
break;
case "fa_arrest_rpt":
storePathKey = "Bbs.faArrestReport.fileStorePath";
break;
case "fa_info_rpt":
storePathKey = "Bbs.faInfoReport.fileStorePath";
break;
case "fa_target":
storePathKey = "Bbs.faTarget.fileStorePath";
break;
case "guard_info":
storePathKey = "Bbs.guardInfo.fileStorePath";
break;
case "notice":
storePathKey = "Bbs.notice.fileStorePath";
break;
case "stat_bbs":
storePathKey = "Bbs.statBbs.fileStorePath";
break;
default:
storePathKey = "";
break;
}
return storePathKey;
}
}

View File

@ -0,0 +1,74 @@
/**
* ValueObjectHandler.java
* @author
* @since 2016. 10. 17.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 17.
*
*/
package kcg.faics.board.util;
import kcg.faics.board.vo.BoardCommentVO;
import kcg.faics.board.vo.BoardFileVO;
import kcg.faics.board.vo.BoardVO;
/**
* ValueObjectHandler.java
* @author
* @since 2016. 10. 17.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 17.
*
*/
public class BoardVOHandler {
public static BoardVO getBoardVO(final BoardVO boardVO) {
BoardVO vo = new BoardVO();
vo.setId(boardVO.getId());
vo.setSeq(boardVO.getSeq());
return vo;
}
public static BoardVO getBoardVO(final String bdId, final int bdSeq) {
BoardVO vo = new BoardVO();
vo.setId(bdId);
vo.setSeq(bdSeq);
return vo;
}
public static BoardFileVO getBFileVO(final BoardVO boardVO) {
BoardFileVO vo = new BoardFileVO();
vo.setId(boardVO.getId());
vo.setParentSeq(boardVO.getSeq());
return vo;
}
public static BoardFileVO getBFileVO(final String bdId, final int bdSeq, final int bfSeq) {
BoardFileVO vo = new BoardFileVO();
vo.setId(bdId);
vo.setParentSeq(bdSeq);
vo.setSeq(bfSeq);
return vo;
}
public static BoardFileVO getBFileVO(BoardFileVO boardFileVO) {
BoardFileVO vo = new BoardFileVO();
vo.setId(boardFileVO.getId());
vo.setParentSeq(boardFileVO.getParentSeq());
return vo;
}
public static BoardCommentVO getBCommentVO(final BoardVO boardVO) {
BoardCommentVO vo = new BoardCommentVO();
vo.setId(boardVO.getId());
vo.setParentSeq(boardVO.getSeq());
return vo;
}
}

View File

@ -0,0 +1,36 @@
package kcg.faics.board.vo;
import kcg.faics.cmmn.bbs.BaseCommentVO;
/**
* BoardCommentVO.java
* @author
* @since 2016. 9. 29.
*
*
* ------------- -------- ---------------------------
* 2016. 9. 29.
*
*/
public class BoardCommentVO extends BaseCommentVO {
/**
*
*/
private String id;
/**
* @return
*/
public String getId() {
return id;
}
/**
* @param
*/
public void setId(String id) {
this.id = id;
}
}

View File

@ -0,0 +1,42 @@
package kcg.faics.board.vo;
import kcg.faics.cmmn.bbs.BaseFileVO;
public class BoardFileVO extends BaseFileVO{
private String id;
private String[] deleteFiles;
public BoardFileVO() {
super();
}
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the deleteFiles
*/
public String[] getDeleteFiles() {
return deleteFiles;
}
/**
* @param deleteFiles the deleteFiles to set
*/
public void setDeleteFiles(String[] deleteFiles) {
this.deleteFiles = deleteFiles;
}
}

View File

@ -0,0 +1,96 @@
/*
* Copyright 2014 MOPAS(Ministry of Public Administration and Security).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kcg.faics.board.vo;
import kcg.faics.cmmn.bbs.BaseSearchVO;
/**
* BoardSearchVO.java
* @author
* @since 2016. 10. 24.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 24.
*
*/
public class BoardSearchVO extends BaseSearchVO {
/** 테이블 이름 */
private String id = "";
/** 카테고리 이름 */
private String category = " ";
/** 카테고리 이름 */
private String searchCondition = "";
public BoardSearchVO() {
super();
}
/**
* .
* @return
*/
public String getId() {
return id;
}
/**
* .
* @param id .
*/
public void setId(String id) {
this.id = id;
}
/**
* .
* @return
*/
public String getCategory() {
return category;
}
/**
* .
* @param id .
*/
public void setCategory(String category) {
if (category == null || category.equals("")) {
category = " ";
}
this.category = category;
}
/**
* @return .
*/
public String getSearchCondition() {
return searchCondition;
}
/**
* @param .
*/
public void setSearchCondition(String searchCondition) {
this.searchCondition = searchCondition;
}
}

View File

@ -0,0 +1,431 @@
package kcg.faics.board.vo;
import java.util.Date;
public class BoardVO {
/** 테이블 이름*/
private String id;
/** 게시글번호*/
private int seq;
/** 회원id*/
private String userId;
/** 그룹seq*/
private int groupSeq = 0;
/** 카테고리id*/
private String category = " ";
/** 회원이름*/
private String userName;
/** 게시글내용*/
private String content;
/** 게시글제목*/
private String subject;
/** ?0 */
private int parentSeq = 0;
/**
* 퀀 .
*/
private int prevSeq = 0;
/**
* 퀀 .
*/
private int nextSeq = 0;
/** ?3 */
private int step = 0;
/** ?4 */
private int depth = 0;
/** 등록날짜*/
private Date regdate;
/** 조회수*/
private int hit;
/** 추천수*/
private int recommend;
/** 등록자ip*/
private String ip = "0.0.0.0";
/** ?5 */
private int notice;
/** ?6 */
private int html;
/** ?7 */
private int num1;
/** ?8 */
private int num2;
/** 소속기관명*/
private String data1 = "";
/** 직급*/
private String data2 = "";
/** 소속기관id*/
private String place1 = "";
/** 직급id*/
private String position = "";
private int isReply;
/**
* .
*/
private int fileCnt = 0;
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the seq
*/
public int getSeq() {
return seq;
}
/**
* @param seq the seq to set
*/
public void setSeq(int seq) {
this.seq = seq;
}
/**
* @return the category
*/
public String getCategory() {
return category;
}
/**
* @return the userId
*/
public String getUserId() {
return userId;
}
/**
* @param userId the userId to set
*/
public void setUserId(String userId) {
this.userId = userId;
}
/**
* @return the groupSeq
*/
public int getGroupSeq() {
return groupSeq;
}
/**
* @param groupSeq the groupSeq to set
*/
public void setGroupSeq(int groupSeq) {
this.groupSeq = groupSeq;
}
/**
* @return the userName
*/
public String getUserName() {
return userName;
}
/**
* @param userName the userName to set
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* @return the parentSeq
*/
public int getParentSeq() {
return parentSeq;
}
/**
* @param parentSeq the parentSeq to set
*/
public void setParentSeq(int parentSeq) {
this.parentSeq = parentSeq;
}
/**
* @return the prevSeq
*/
public int getPrevSeq() {
return prevSeq;
}
/**
* @param prevSeq the prevSeq to set
*/
public void setPrevSeq(int prevSeq) {
this.prevSeq = prevSeq;
}
/**
* @return the nextSeq
*/
public int getNextSeq() {
return nextSeq;
}
/**
* @param nextSeq the nextSeq to set
*/
public void setNextSeq(int nextSeq) {
this.nextSeq = nextSeq;
}
/**
* @param category the category to set
*/
public void setCategory(String category) {
if (category == null || category.equals("")) {
category = " ";
}
this.category = category;
}
/**
* @return the content
*/
public String getContent() {
return content;
}
/**
* @param content the content to set
*/
public void setContent(String content) {
this.content = content;
}
/**
* @return the subject
*/
public String getSubject() {
return subject;
}
/**
* @param subject the subject to set
*/
public void setSubject(String subject) {
this.subject = subject;
}
/**
* @return the step
*/
public int getStep() {
return step;
}
/**
* @param step the step to set
*/
public void setStep(int step) {
this.step = step;
}
/**
* @return the depth
*/
public int getDepth() {
return depth;
}
/**
* @param depth the depth to set
*/
public void setDepth(int depth) {
this.depth = depth;
}
/**
* @return the regdate
*/
public Date getRegdate() {
return regdate;
}
/**
* @param regdate the regdate to set
*/
public void setRegdate(Date regdate) {
this.regdate = regdate;
}
/**
* @return the hit
*/
public int getHit() {
return hit;
}
/**
* @param hit the hit to set
*/
public void setHit(int hit) {
this.hit = hit;
}
/**
* @return the recommend
*/
public int getRecommend() {
return recommend;
}
/**
* @param recommend the recommend to set
*/
public void setRecommend(int recommend) {
this.recommend = recommend;
}
/**
* @return the ip
*/
public String getIp() {
return ip;
}
/**
* @param ip the ip to set
*/
public void setIp(String ip) {
this.ip = ip;
}
/**
* @return the notice
*/
public int getNotice() {
return notice;
}
/**
* @param notice the notice to set
*/
public void setNotice(int notice) {
this.notice = notice;
}
/**
* @return the html
*/
public int getHtml() {
return html;
}
/**
* @param html the html to set
*/
public void setHtml(int html) {
this.html = html;
}
/**
* @return the num1
*/
public int getNum1() {
return num1;
}
/**
* @param num1 the num1 to set
*/
public void setNum1(int num1) {
this.num1 = num1;
}
/**
* @return the num2
*/
public int getNum2() {
return num2;
}
/**
* @param num2 the num2 to set
*/
public void setNum2(int num2) {
this.num2 = num2;
}
/**
* @return the data1
*/
public String getData1() {
return data1;
}
/**
* @param data1 the data1 to set
*/
public void setData1(String data1) {
this.data1 = data1;
}
/**
* @return the data2
*/
public String getData2() {
return data2;
}
/**
* @param data2 the data2 to set
*/
public void setData2(String data2) {
this.data2 = data2;
}
/**
* @return the place1
*/
public String getPlace1() {
return place1;
}
/**
* @param place1 the place1 to set
*/
public void setPlace1(String place1) {
this.place1 = place1;
}
/**
* @return the position
*/
public String getPosition() {
return position;
}
/**
* @param position the position to set
*/
public void setPosition(String position) {
this.position = position;
}
/**
* 1 .
*/
public void incHit() {
this.hit += 1;
}
/**
* 1 .
*/
public void decHit() {
this.hit -= 1;
}
/**
* @return the isReply
*/
public int getIsReply() {
return isReply;
}
/**
* @param isReply the isReply to set
*/
public void setIsReply(int isReply) {
this.isReply = isReply;
}
/**
* @return the fileCnt
*/
public final int getFileCnt() {
return fileCnt;
}
/**
* @param fileCnt the fileCnt to set
*/
public final void setFileCnt(int fileCnt) {
this.fileCnt = fileCnt;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "BoardVO [id=" + id + ", seq=" + seq + ", userId=" + userId
+ ", groupSeq=" + groupSeq + ", category=" + category
+ ", userName=" + userName + ", content=" + content
+ ", subject=" + subject + ", parentSeq=" + parentSeq
+ ", prevSeq=" + prevSeq + ", nextSeq=" + nextSeq + ", step="
+ step + ", depth=" + depth + ", regdate=" + regdate + ", hit="
+ hit + ", recommend=" + recommend + ", ip=" + ip + ", notice="
+ notice + ", html=" + html + ", num1=" + num1 + ", num2="
+ num2 + ", data1=" + data1 + ", data2=" + data2 + ", place1="
+ place1 + ", position=" + position + ", isReply=" + isReply
+ "]";
}
}

View File

@ -0,0 +1,576 @@
package kcg.faics.board.web;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import kcg.faics.board.service.BoardService;
import kcg.faics.board.util.BoardUtils;
import kcg.faics.board.util.BoardVOHandler;
import kcg.faics.board.vo.BoardCommentVO;
import kcg.faics.board.vo.BoardFileVO;
import kcg.faics.board.vo.BoardSearchVO;
import kcg.faics.board.vo.BoardVO;
import kcg.faics.cmmn.bbs.BaseCommentService;
import kcg.faics.cmmn.bbs.BaseFileService;
import kcg.faics.cmmn.file.FileResponser;
import kcg.faics.sec.LoginUserVO;
import kcg.faics.sec.UserUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.FileCopyUtils;
import org.springframework.validation.BindingResult;
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.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springmodules.validation.commons.DefaultBeanValidator;
import egovframework.rte.fdl.property.EgovPropertyService;
import egovframework.rte.fdl.security.userdetails.util.EgovUserDetailsHelper;
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
/**
* .
*
* BoardController.java
* @author
* @since 2016. 9. 28.
*
*
* ------------- -------- ---------------------------
* 2016. 9. 28.
*
*/
@Controller
@SessionAttributes(types = BoardVO.class)
@RequestMapping("/bbs")
public class BoardController {
/**
* EgovPropertyService - properties .
**/
@Resource(name = "propertiesService")
private EgovPropertyService propertiesService;
/**
* Validator - .
**/
@Resource(name = "beanValidator")
private DefaultBeanValidator beanValidator;
/**
* BoardService - .
**/
@Resource(name = "boardService")
private BoardService boardService;
/**
* BoardFileService - .
**/
@Resource(name = "boardFileService")
private BaseFileService<BoardFileVO> boardFileService;
/**
* BoardCommentService - .
**/
@Resource(name = "boardCommentService")
private BaseCommentService<BoardCommentVO> boardCommentService;
/**
* .
*
* @param req Request
* @param searchVO ,
* @param model
* @return
* @throws Exception
*/
@RequestMapping(value = "/list.do")
public String boardList(final HttpServletRequest req, @ModelAttribute("searchVO") final BoardSearchVO searchVO, final Model model) throws Exception {
try {
/* 페이징 처리 정보 */
searchVO.setPageUnit(propertiesService.getInt("pageUnit"));
searchVO.setPageSize(propertiesService.getInt("pageSize"));
/* 페이징 처리 */
PaginationInfo paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(searchVO.getPageIndex());
paginationInfo.setRecordCountPerPage(searchVO.getPageUnit());
paginationInfo.setPageSize(searchVO.getPageSize());
searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
searchVO.setLastIndex(paginationInfo.getLastRecordIndex());
searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
int totSearchCnt = boardService.selectListCnt(searchVO);
paginationInfo.setTotalRecordCount(totSearchCnt);
model.addAttribute("paginationInfo", paginationInfo);
/* 게시판 리스트 */
List<BoardVO> boardList = boardService.selectList(searchVO);
model.addAttribute("resultList", boardList);
/* 게시판 상단 페이지 및 게시물 정보 표현을 위한 데이터 */
int totCnt = boardService.selectTotalCnt(searchVO);
model.addAttribute("totalCnt", totCnt);
} catch (Exception e) {
e.printStackTrace();
return "error/bizError";
}
return "board/boardList.tiles";
}
/**
* .
*
* @param boardVO VO
* @param model
* @return
* @throws Exception
*/
@RequestMapping(value = "/view.do", method = RequestMethod.GET)
public String boardView(final BoardVO boardVO, final Model model) throws Exception {
try {
/* 작성자와 조회자가 다른 경우 조회수 증가 */
BoardVO board = boardService.select(boardVO);
if (!UserUtil.isEqualMember(board.getUserId())) {
boardService.incHit(board);
}
/* 게시판 내용 */
model.addAttribute("boardVO", boardService.select(boardVO));
/* 게시판 파일내용 */
model.addAttribute("boardFileVO", boardFileService.selectList(BoardVOHandler.getBFileVO(boardVO)));
/* 게시판 덧글내용 */
model.addAttribute("boardCommentVOList", boardCommentService.selectList(BoardVOHandler.getBCommentVO(boardVO)));
/* 덧글 ModelAttribute */
model.addAttribute("boardCommentVO", BoardVOHandler.getBCommentVO(boardVO));
/* 세션 사용자 정보 */
model.addAttribute("loginUserVO", UserUtil.getMemberInfo());
} catch (Exception e) {
e.printStackTrace();
return "error/bizError";
}
return "board/boardView.tiles";
}
/**
* .
*
* @param model
* @param boardVO VO
* @return
* @throws Exception
*/
@RequestMapping(value = "/addView.do", method = RequestMethod.GET)
public String boardAddView(final Model model, final BoardVO boardVO) throws Exception {
BoardVO modelAttr = new BoardVO();
modelAttr.setId(boardVO.getId());
modelAttr.setCategory(boardVO.getCategory());
/* 게시물 입력 Form ModelAttribute */
model.addAttribute("boardVO", modelAttr);
/* create or modify 플래그 */
model.addAttribute("registerFlag", "create");
return "board/boardAdd.tiles";
}
/**
* .
*
* @param multiRequest multpart
* @param boardVO
* @param bindingResult
* @param model
* @param status
* @return
* @throws Exception
*/
@RequestMapping(value = "/add.do", method = RequestMethod.POST)
public String boardAdd(final MultipartHttpServletRequest multiRequest, @ModelAttribute("boardVO") final BoardVO boardVO,
final BindingResult bindingResult, final Model model, final SessionStatus status) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
/* 인증된 사용자인지 확인 */
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if (isAuthenticated) {
try {
/* 유효성 검사 */
// beanValidator.validate(boardVO, bindingResult);
if (bindingResult.hasErrors()) {
model.addAttribute("boardVO", boardVO);
return "board/boardAdd.tiles";
}
final Map<String, MultipartFile> fileMap = multiRequest.getFileMap();
/* 사용자 정보 입력 */
LoginUserVO user = UserUtil.getMemberInfo();
boardVO.setUserId(user.getUserid());
boardVO.setUserName(user.getName());
boardVO.setPosition(user.getPosition());
boardVO.setPlace1(user.getPlace1());
boardVO.setData1(user.getPlace1Yak());
boardVO.setData2(user.getPositionStr());
boardVO.setIsReply(-1);
map = boardService.insert(boardVO, fileMap);
status.setComplete();
int result = (Integer) map.get("result");
int seq = (Integer) map.get("seq");
if (result > 0 && seq > 0) {
return "redirect:/bbs/view.do?seq=" + seq + "&id=" + boardVO.getId();
}
} catch (Exception e) {
e.printStackTrace();
return "error/bizError";
}
}
return "error/bizError";
}
/**
* .
*
* @param boardVO VO
* @param model
* @return
* @throws Exception
*/
@RequestMapping(value = "/updateView.do", method = RequestMethod.POST)
public String updateView(final BoardVO boardVO, final Model model) throws Exception {
BoardVO updateBoard = boardService.select(boardVO);
try {
/* 글 작성자와 세션 사용자의 아이디를 비교하여 본인여부를 판단한다 */
if (updateBoard == null || !UserUtil.isEqualMember(updateBoard.getUserId()) && !UserUtil.isSysAdmin()) {
return "redirect:/bbs/view.do?seq=" + boardVO.getSeq() + "&id=" + boardVO.getId();
}
model.addAttribute("boardVO", updateBoard);
model.addAttribute("registerFlag", "modify");
model.addAttribute("boardFileVO", boardFileService.selectList(BoardVOHandler.getBFileVO(updateBoard)));
} catch (Exception e) {
e.printStackTrace();
return "error/bizError";
}
return "board/boardAdd.tiles";
}
/**
* .
*
* @param multiRequest multpart
* @param boardVO
* @param bindingResult
* @param model
* @param status
* @return
* @throws Exception
*/
@RequestMapping(value = "/update.do", method = RequestMethod.POST)
public String update(final MultipartHttpServletRequest multiRequest, @ModelAttribute("boardVO") final BoardVO boardVO,
final BindingResult bindingResult, final Model model, final SessionStatus status) throws Exception {
try {
/* 글 작성자와 세션 사용자의 아이디를 비교하여 본인여부를 판단한다 */
if (!UserUtil.isEqualMember(boardVO.getUserId()) && !UserUtil.isSysAdmin()) {
return "redirect:/bbs/view.do?seq=" + boardVO.getSeq() + "&id=" + boardVO.getId();
}
/* 유효성 검사 */
// beanValidator.validate(boardVO, bindingResult);
if (bindingResult.hasErrors()) {
model.addAttribute("boardVO", boardVO);
model.addAttribute("registerFlag", "modify");
return "board/boardAdd.tiles";
}
HashMap<String, Object> map = new HashMap<String, Object>();
String[] deleteFiles = multiRequest.getParameterValues("deleteFile");
final Map<String, MultipartFile> fileMap = multiRequest.getFileMap();
map = boardService.update(boardVO, fileMap, deleteFiles);
status.setComplete();
int result = (Integer) map.get("result");
int seq = (Integer) map.get("seq");
if (result > 0 && seq > 0) {
return "redirect:/bbs/view.do?seq=" + seq + "&id=" + boardVO.getId();
}
} catch (Exception e) {
e.printStackTrace();
return "error/bizError";
}
return "redirect:/bbs/list.do?id=" + boardVO.getId();
}
/**
* .
*
* @param boardVO VO
* @param model
* @param status
* @return
* @throws Exception
*/
@RequestMapping(value = "/delete.do", method = RequestMethod.POST)
public String delete(final BoardVO boardVO, final Model model, final SessionStatus status) throws Exception {
try {
BoardVO deleteBoard = boardService.select(boardVO);
if (deleteBoard == null || (!UserUtil.isEqualMember(deleteBoard.getUserId()) && !UserUtil.isSysAdmin())) {
return "redirect:/bbs/view.do?seq=" + boardVO.getSeq() + "&id=" + boardVO.getId();
}
HashMap<String, Object> map = new HashMap<String, Object>();
map = boardService.delete(boardVO);
status.setComplete();
if ((Integer) map.get("result") > 0) {
return "redirect:/bbs/list.do?id=" + boardVO.getId();
}
} catch (Exception e) {
e.printStackTrace();
return "error/bizError";
}
return "redirect:/bbs/view.do?seq=" + boardVO.getSeq() + "&id=" + boardVO.getId();
}
/**
* .
*
* @param bdId ID
* @param deleteBoard
* @param status
* @return
* @throws Exception
*/
@RequestMapping(value = "/selectedDelete.do", method = RequestMethod.POST)
public String deleteSelected(@RequestParam("id") final String bdId, final int[] deleteBoard, final SessionStatus status) throws Exception {
/* 관리자만 가능 */
if (UserUtil.isAdmin()) {
try {
BoardVO boardVO = BoardVOHandler.getBoardVO(bdId, 0);
if (deleteBoard != null) {
boardService.selectAndDelete(boardVO, deleteBoard);
}
} catch (Exception e) {
e.printStackTrace();
}
status.setComplete();
}
return "redirect:/bbs/list.do?id=" + bdId;
}
/**
* .
*
* @param boardVO VO
* @param model
* @param status SessionStatus
* @return
* @throws Exception
*/
@RequestMapping(value = "/replyView.do", method = RequestMethod.POST)
public String replyView(final BoardVO boardVO, final Model model, final SessionStatus status) throws Exception {
BoardVO replyVO = BoardVOHandler.getBoardVO(boardVO);
replyVO.setStep(boardVO.getStep());
replyVO.setGroupSeq(boardVO.getGroupSeq());
replyVO.setDepth(boardVO.getDepth());
model.addAttribute("boardVO", replyVO);
model.addAttribute("registerFlag", "reply");
return "board/boardAdd.tiles";
}
/**
* .
*
* @param boardVO VO
* @param bindingResult BindingResult
* @param model
* @param status SessionStatus
* @param multiRequest MultipartHttpServletRequest
* @return
*/
@RequestMapping(value = "/reply.do", method = RequestMethod.POST)
public String replyAdd(@ModelAttribute("boardVO") final BoardVO boardVO,
final BindingResult bindingResult, final Model model, final SessionStatus status, final MultipartHttpServletRequest multiRequest) {
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if (isAuthenticated) {
try {
// beanValidator.validate(boardVO, bindingResult);
if (bindingResult.hasErrors()) {
model.addAttribute("boardVO", boardVO);
return "board/boardAdd.tiles";
}
HashMap<String, Object> map = new HashMap<String, Object>();
final Map<String, MultipartFile> fileMap = multiRequest.getFileMap();
/* 사용자 정보 입력 */
LoginUserVO user = UserUtil.getMemberInfo();
boardVO.setUserId(user.getUserid());
boardVO.setUserName(user.getName());
boardVO.setPosition(user.getPosition());
boardVO.setPlace1(user.getPlace1());
boardVO.setData1(user.getPlace1Yak());
boardVO.setData2(user.getPositionStr());
boardVO.setIsReply(1);
map = boardService.insert(boardVO, fileMap);
status.setComplete();
int result = (Integer) map.get("result");
int seq = (Integer) map.get("seq");
if (result > 0 && seq > 0) {
return "redirect:/bbs/view.do?seq=" + seq + "&id=" + boardVO.getId();
}
} catch (Exception e) {
e.printStackTrace();
return "error/bizError";
}
}
return "redirect:/bbs/list.do?id=" + boardVO.getId();
}
/**
* .
*
* @param boardCommentVO
* @param status SessionStatus
* @return json
*/
@ResponseBody
@RequestMapping(value = "/commentAdd.json", method = RequestMethod.POST)
public Object comment(@ModelAttribute("boardCommentVO") final BoardCommentVO boardCommentVO, final SessionStatus status) {
HashMap<String, Object> ret = new HashMap<String, Object>();
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if (isAuthenticated) {
try {
LoginUserVO user = UserUtil.getMemberInfo();
boardCommentVO.setUserId(user.getUserid());
boardCommentVO.setUserName(user.getName());
ret = boardCommentService.insert(boardCommentVO);
if ((Integer) ret.get("result") > 0) {
ret.put("comment", boardCommentService.select(boardCommentVO));
}
} catch (Exception e) {
e.printStackTrace();
}
}
status.setComplete();
return ret;
}
/**
* .
*
* @param boardCommentVO VO
* @param status SessionStatus
* @return json
*/
@ResponseBody
@RequestMapping("/commentDelete.json")
public Object commentDelete(final BoardCommentVO boardCommentVO, final SessionStatus status) {
HashMap<String, Object> ret = new HashMap<String, Object>();
int result = 0;
try {
BoardCommentVO commentVO = boardCommentService.select(boardCommentVO);
if (UserUtil.isEqualMember(commentVO.getUserId()) || UserUtil.isSysAdmin()) {
result = boardCommentService.delete(boardCommentVO);
}
} catch (Exception e) {
e.printStackTrace();
}
status.setComplete();
ret.put("result", result);
return ret;
}
/**
* .
*
* @param boardFileVO VO
* @param request Request
* @param response Response
* @throws Exception
*/
@RequestMapping(value = "/download.do")
public void cvplFileDownload(final BoardFileVO boardFileVO, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
BoardFileVO vo = boardFileService.select(boardFileVO);
String fileOrgName = vo.getOrgName();
String storePathKey = BoardUtils.getStorePathKey(boardFileVO.getId());
String fileFullPath = propertiesService.getString(storePathKey) + vo.getSaveName();
File file = new File(fileFullPath);
if (file.exists()) {
FileResponser.setResponse(file, fileOrgName, request, response);
BufferedInputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(file));
FileCopyUtils.copy(in, response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}

View File

@ -0,0 +1,105 @@
/**
* CommonsUtils.java
* @author
* @since 2016. 10. 14.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 14.
*
*/
package kcg.faics.cmmn;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
/**
* CommonsUtils.java
* @author
* @since 2016. 10. 14.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 14.
* 2016. 12. 14. isEmpty
*
*/
public class CommonsUtils {
public static String sqlInjectionFilter(String str){
Pattern evilChars = Pattern.compile("\\[\'-#()@;=*/+%\\]");
str = evilChars.matcher(str).replaceAll("");
String lowerStr = str.toLowerCase();
if (lowerStr.contains("union") || lowerStr.contains("select") || lowerStr.contains("insert") || lowerStr.contains("drop")
|| lowerStr.contains("update") || lowerStr.contains("delete") || lowerStr.contains("join") || lowerStr.contains("from")
|| lowerStr.contains("where") || lowerStr.contains("substr") || lowerStr.contains("user_tables") || lowerStr.contains("user_tab_columns")) {
str = lowerStr;
str = str.replaceAll("union", "q-union");
str = str.replaceAll("select", "q-select");
str = str.replaceAll("insert", "q-insert");
str = str.replaceAll("drop", "q-drop");
str = str.replaceAll("update", "q-update");
str = str.replaceAll("delete", "q-delete");
str = str.replaceAll("join", "q-join");
str = str.replaceAll("from", "q-from");
str = str.replaceAll("where", "q-where");
str = str.replaceAll("substr", "q-substr");
str = str.replaceAll("user_tables", "q-user_tables");
str = str.replaceAll("user_tab_columns", "q-user_tab_columns");
}
return str;
}
public static HashMap<String, Object> getParameterMap(HttpServletRequest request){
@SuppressWarnings("unchecked")
Map<String, Object> paramMap = request.getParameterMap();
HashMap<String, Object> newMap = new HashMap<String, Object>();
Set<String> keySet = paramMap.keySet();
Iterator<String> it = keySet.iterator();
while (it.hasNext()) {
String key = it.next();
if (paramMap.get(key) instanceof String[]) {
newMap.put(key, ((String[]) paramMap.get(key))[0]);
} else {
newMap.put(key, paramMap.get(key));
}
}
return newMap;
}
/**
*
*
* @param s
* @return :true
*/
public static boolean isEmpty(final Object s) {
if (s == null) {
return true;
}
if ((s instanceof String) && ((String.valueOf(s)).trim().length() == 0)) {
return true;
}
if (s instanceof Map) {
return ((Map<?, ?>)s).isEmpty();
}
if (s instanceof List) {
return ((List<?>)s).isEmpty();
}
if (s instanceof Object[]) {
return (((Object[])s).length == 0);
}
return false;
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright 2008-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kcg.faics.cmmn;
import javax.servlet.ServletContext;
import org.springframework.web.context.ServletContextAware;
import egovframework.rte.ptl.mvc.tags.ui.pagination.AbstractPaginationRenderer;
/**
* @Class Name : ImagePaginationRenderer.java
* @Description : ImagePaginationRenderer Class
* @Modification Information
* @
* @
* @ --------- --------- -------------------------------
* @ 2009.03.16
*
* @author
* @since 2009. 03.16
* @version 1.0
* @see
*
* Copyright (C) by MOPAS All right reserved.
*/
public class ImagePaginationRenderer extends AbstractPaginationRenderer implements ServletContextAware {
private ServletContext servletContext;
public ImagePaginationRenderer() {
// no-op
}
/**
* PaginationRenderer
*
* @see
*/
public void initVariables() {
firstPageLabel = "<a href=\"#\" onclick=\"{0}({1}); return false;\">" + "<image src='" + servletContext.getContextPath() + "/images/cmmn/btn_page_pre10.gif' border=0/></a>&#160;";
previousPageLabel = "<a href=\"#\" onclick=\"{0}({1}); return false;\">" + "<image src='" + servletContext.getContextPath() + "/images/cmmn/btn_page_pre1.gif' border=0/></a>&#160;";
currentPageLabel = "<strong>{0}</strong>&#160;";
otherPageLabel = "<a href=\"#\" onclick=\"{0}({1}); return false;\">{2}</a>&#160;";
nextPageLabel = "<a href=\"#\" onclick=\"{0}({1}); return false;\">" + "<image src='" + servletContext.getContextPath() + "/images/cmmn/btn_page_next1.gif' border=0/></a>&#160;";
lastPageLabel = "<a href=\"#\" onclick=\"{0}({1}); return false;\">" + "<image src='" + servletContext.getContextPath() + "/images/cmmn/btn_page_next10.gif' border=0/></a>&#160;";
}
@Override
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
initVariables();
}
}

View File

@ -0,0 +1,24 @@
package kcg.faics.cmmn;
/**
* .
*
* @author kimnomin
*
*/
public final class MenuPosition {
/**
* . ()
*/
public static final String TOP = "T";
/**
* .
*/
public static final String TOP_SUB = "TS";
/**
* .
*/
private MenuPosition() {
}
}

View File

@ -0,0 +1,188 @@
/**
* BoardPreventSqlInjectionAop.java
* @author
* @since 2016. 10. 19.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 19.
*
*/
package kcg.faics.cmmn.aop;
import java.util.HashMap;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import kcg.faics.cmmn.service.LogService;
import kcg.faics.cmmn.service.MenuService;
import kcg.faics.cmmn.vo.MenuVO;
import kcg.faics.sec.LoginUserVO;
import kcg.faics.sec.UserUtil;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;
/**
* CommonAop.java
*
* @author
* @since 2016. 10. 19.
*
* ------------- -------- --------------------------- 2016.
* 10. 19. 2016. 11. 10.
*
*/
@Aspect
@Component
public class CommonAop {
@Resource(name = "menuService")
MenuService menuService;
@Resource(name = "logService")
LogService logService;
@Around("execution(* kcg.faics..*Controller.*(..))")
public Object menuGenerator(final ProceedingJoinPoint thisJoinPoint)
throws Throwable {
HttpServletRequest req = ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest();
String loginUrl = "/loginView.do";
String url = req.getRequestURI();
if (loginUrl.equals(url)) {
return thisJoinPoint.proceed();
}
LoginUserVO loginUserVO = null;
try {
loginUserVO = UserUtil.getMemberInfo();
} catch (Exception e) {
//세션정보가 없을 경우 로그인 페이지로 이동.
if (loginUserVO == null) {
return "redirect:" + loginUrl;
}
}
try {
for (Object obj : thisJoinPoint.getArgs()) {
if (obj instanceof Model) {
Model model = (Model) obj;
MenuVO menuVO = new MenuVO();
menuVO.setUserId(loginUserVO.getUserid());
menuVO.setUserType(loginUserVO.getType());
List<MenuVO> mainMenuList = menuService
.selectMainMenuList(menuVO);
model.addAttribute("mainMenuList", mainMenuList);
List<MenuVO> topSubMenuList = menuService
.selectTopSubMenuList(menuVO);
model.addAttribute("topSubMenuList", topSubMenuList);
HashMap<String, Object> menu = new HashMap<String, Object>();
String subStr = url.substring(1);
String boardId = "";
String group = subStr.split("/")[0];
String onlyUrl = subStr;
String qryCate = "";
if (onlyUrl.indexOf("/") > -1) {
onlyUrl = subStr.substring(onlyUrl.indexOf("/"));
} else {
return thisJoinPoint.proceed();
}
url = onlyUrl;
if (req.getParameter("id") != null) {
boardId = req.getParameter("id");
switch (boardId) {
// 외사통계-통계월보는 타이틀을 같이 쓸것이므로 카테고리를 나누지않는다.
case "stat_bbs":
break;
default:
if (req.getParameter("category") != null
&& !req.getParameter("category")
.equals(" ")) {
qryCate = "category="
+ req.getParameter("category");
// url = url + "/" +
// req.getParameter("category");
}
break;
}
}
menu.put("url", url);
menu.put("group", group);
menu.put("boardId", boardId);
menu.put("query", qryCate);
HashMap<String, Object> menuInfo = menuService
.getMenuInfo(menu);
menuVO.setId(Integer
.parseInt(menuInfo.get("ID").toString()));
menuInfo.put("userId", loginUserVO.getUserid());
List<MenuVO> currAndHigherMenuList = menuService
.selectListWithHigher(menuVO);
model.addAttribute("currAndHigherMenuList",
currAndHigherMenuList);
model.addAttribute("menu", menuInfo);
model.addAttribute("subMenu",
menuService.getSubmenu(menuInfo));
addUserLog(req, menu);
}
}
} catch (Exception e) {
// e.printStackTrace();
}
Object proc = thisJoinPoint.proceed();
return proc;
}
/**
* .
*
* @param req
* Request
* @param menu
* Map
*/
private void addUserLog(final HttpServletRequest req,
final HashMap<String, Object> menu) {
LoginUserVO user = (LoginUserVO) req.getSession()
.getAttribute("userVO");
HashMap<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("userid", user.getUserid());
paramMap.put("name", user.getName());
paramMap.put("userip", user.getIp());
paramMap.put("place1", user.getPlace1());
paramMap.put("position", user.getPosition());
paramMap.put("location1", menu.get("group"));
paramMap.put("location2", menu.get("url"));
paramMap.put("location3", req.getRequestURI());
try {
logService.insertUserLog(paramMap);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,40 @@
package kcg.faics.cmmn.bbs;
import java.util.HashMap;
/**
* .
*
* @author kimnomin
*
* @param <SearchT>
* VO
* @param <DataT>
* VO
*/
public interface BaseBbsExService<SearchT, DataT> extends BaseBbsService<SearchT, DataT> {
/**
* seq .
*
* @param dataVO
* data VO
* @param seq
* 퀀
* @return { result: 1- 0-, idx: idx }
* @throws Exception
*
*/
HashMap<String, Object> selectAndDelete(DataT dataVO, int[] seq) throws Exception;
/**
* 1 .
*
* @param dataVO
* data VO
* @return - 1, - 0
* @throws Exception
*
*/
int incHit(DataT dataVO) throws Exception;
}

View File

@ -0,0 +1,115 @@
package kcg.faics.cmmn.bbs;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.web.multipart.MultipartFile;
/**
* .
* CRUD .
*
* @author kimnomin
*
* @param <SearchT>
* VO
* @param <DataT>
* VO
*/
public interface BaseBbsService<SearchT, DataT> {
/**
* .
*
* @param dataVO
* VO ( PK .)
* @return
* @throws Exception
*
*/
DataT select(DataT dataVO) throws Exception;
/**
* .
*
* @param searchVO
* @return
* @throws Exception
*/
List<DataT> selectListAll(SearchT searchVO) throws Exception;
/**
* .
*
* @param searchVO
* ,
* @return
* @throws Exception
*
*/
List<DataT> selectList(SearchT searchVO) throws Exception;
/**
* .
*
* @param searchVO
* ,
* @return
* @throws Exception
*
*/
int selectListCnt(SearchT searchVO) throws Exception;
/**
* .
*
* @param searchVO
* ,
* @return
* @throws Exception
*
*/
int selectTotalCnt(SearchT searchVO) throws Exception;
/**
* .
*
* @param dataVO
* VO
* @param fileMap
* Map
* @return { result: 1- 0-, idx: idx }
*
* @throws Exception
*
*/
HashMap<String, Object> insert(DataT dataVO,
Map<String, MultipartFile> fileMap) throws Exception;
/**
* .
*
* @param dataVO
* VO
* @param fileMap
* Map
* @param deleteFiles
*
* @return { result: 1- 0-, idx: idx }
* @throws Exception
*
*/
HashMap<String, Object> update(DataT dataVO,
Map<String, MultipartFile> fileMap, String[] deleteFiles) throws Exception;
/**
* .
*
* @param dataVO
* VO
* @return { result: 1- 0-, idx: idx }
* @throws Exception
*
*/
HashMap<String, Object> delete(DataT dataVO) throws Exception;
}

View File

@ -0,0 +1,81 @@
/**
* BaseCommentService.java
* @author
* @since 2016. 10. 26.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 26.
*
*/
package kcg.faics.cmmn.bbs;
import java.util.HashMap;
import java.util.List;
/**
* BaseCommentService.java
* @author
* @since 2016. 10. 26.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 26.
*
*/
public interface BaseCommentService<T> {
/**
* .
*
* @param commentVO
* VO
* @return
* @throws Exception
*
*/
T select(T commentVO) throws Exception;
/**
* .
*
* @param commentVO
* VO
* @return
* @throws Exception
*
*/
List<T> selectList(T commentVO) throws Exception;
/**
* .
*
* @param commentVO
* VO
* @return map . result : 1-, 0-, seq :
* @throws Exception
*
*/
HashMap<String, Object> insert(T commentVO) throws Exception;
/**
* .
*
* @param commentVO
* File VO
* @return 1-, 0-
* @throws Exception
*
*/
int delete(T commentVO) throws Exception;
/**
* commentVO parentSeq .
*
* @param commentVO
* File VO
* @return 1-, 0-
* @throws Exception
*
*/
int deleteAll(T commentVO) throws Exception;
}

View File

@ -0,0 +1,142 @@
/**
* BaseCommentVO.java
* @author
* @since 2016. 10. 26.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 26.
*
*/
package kcg.faics.cmmn.bbs;
import java.util.Date;
/**
* BaseCommentVO.java
* @author
* @since 2016. 10. 26.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 26.
*
*/
public class BaseCommentVO {
/**
*
*/
private int seq;
/**
*
*/
private String userName;
/**
*
*/
private String content;
/**
*
*/
private Date regdate;
/**
* IP
*/
private String ip;
/**
*
*/
private String userId;
/**
*
*/
private int parentSeq;
/**
* @return
*/
public int getSeq() {
return seq;
}
/**
* @param
*/
public void setSeq(int seq) {
this.seq = seq;
}
/**
* @return
*/
public String getUserName() {
return userName;
}
/**
* @param
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* @return
*/
public String getContent() {
return content;
}
/**
* @param
*/
public void setContent(String content) {
this.content = content;
}
/**
* @return
*/
public Date getRegdate() {
return regdate;
}
/**
* @param
*/
public void setRegdate(Date regdate) {
this.regdate = regdate;
}
/**
* @return IP
*/
public String getIp() {
return ip;
}
/**
* @param IP
*/
public void setIp(String ip) {
this.ip = ip;
}
/**
* @return
*/
public String getUserId() {
return userId;
}
/**
* @param
*/
public void setUserId(String userId) {
this.userId = userId;
}
/**
* @return
*/
public int getParentSeq() {
return parentSeq;
}
/**
* @param
*/
public void setParentSeq(int parentSeq) {
this.parentSeq = parentSeq;
}
}

View File

@ -0,0 +1,97 @@
package kcg.faics.cmmn.bbs;
import java.util.List;
import java.util.Map;
import org.springframework.web.multipart.MultipartFile;
/**
* Interface.
*
* @author kimnomin
*
* @param <T>
* .
*/
public interface BaseFileService<T> {
/**
* .
*
* @param fileVO
* VO
* @return
* @throws Exception
*
*/
T select(T fileVO) throws Exception;
/**
* .
*
* @param fileVO
* VO
* @return
* @throws Exception
*
*/
List<T> selectList(T fileVO) throws Exception;
/**
* .
*
* @param fileVO
* File VO
* @return 1-, 0-
* @throws Exception
*
*/
int insert(T fileVO) throws Exception;
/**
* .
*
* @param fileVO
* File VO
* @return 1-, 0-
* @throws Exception
*
*/
int delete(T fileVO) throws Exception;
/**
* .
*
* @param fileVO
* File VO
* @param fileMap
* Map
* @return 1-, 0-
* @throws Exception
*
*/
int insertAndSaveFiles(T fileVO, Map<String, MultipartFile> fileMap)
throws Exception;
/**
* .
*
* @param fileVO
* File VO
* @return 1-, 0-
* @throws Exception
*
*/
int deleteAndRemoveFile(T fileVO) throws Exception;
/**
* fileVO parentSeq .
*
* @param fileVO
* File VO
* @return 1-, 0-
* @throws Exception
*
*/
int deleteAndRemoveFiles(T fileVO) throws Exception;
}

View File

@ -0,0 +1,114 @@
package kcg.faics.cmmn.bbs;
/**
* VO.
*
* 1. VO .
* 2. Data ( MyBatis) Alias .
*
* @author kimnomin
*
*/
public class BaseFileVO {
/**
* .
*/
private int seq;
/**
* .
*/
private int orders;
/**
* .
*/
private String orgName;
/**
* .
*/
private String saveName;
/**
* .
*/
private int parentSeq;
/**
* .
*
* @return
*/
public final int getSeq() {
return seq;
}
/**
* .
*
* @param seq
*/
public final void setSeq(final int seq) {
this.seq = seq;
}
/**
* .
*
* @return
*/
public final int getOrders() {
return orders;
}
/**
* .
*
* @param order
*/
public final void setOrders(final int order) {
this.orders = order;
}
/**
* .
*
* @return
*/
public final String getOrgName() {
return orgName;
}
/**
* .
*
* @param orgName
*/
public final void setOrgName(final String orgName) {
this.orgName = orgName;
}
/**
* .
*
* @return
*/
public final String getSaveName() {
return saveName;
}
/**
* .
*
* @param saveName
*/
public final void setSaveName(final String saveName) {
this.saveName = saveName;
}
/**
* .
*
* @return
*/
public final int getParentSeq() {
return parentSeq;
}
/**
* .
*
* @param parentSeq
*/
public final void setParentSeq(final int parentSeq) {
this.parentSeq = parentSeq;
}
}

View File

@ -0,0 +1,197 @@
package kcg.faics.cmmn.bbs;
/**
* Value Object.
*
* VO .
*
* @author kimnomin
*
*/
public class BaseSearchVO {
/**
* .
*/
private int pageIndex = 1;
/**
* .
*/
private int pageUnit; // properties에서 설정
/**
* .
*/
private int pageSize; // properties에서 설정
/**
* .
*/
private int firstIndex = 0;
/**
* .
*/
private int lastIndex = 1;
/**
* .
*/
private int recordCountPerPage = 10;
/**
* .
*/
private String searchKeyword = "";
/**
* .
*/
private String searchCondition = "";
/**
* .
*
* @return
*/
public final int getPageIndex() {
return pageIndex;
}
/**
* .
*
* @param pageIndex
*
*/
public final void setPageIndex(final int pageIndex) {
this.pageIndex = pageIndex;
}
/**
* .
*
* @return
*/
public final int getPageUnit() {
return pageUnit;
}
/**
* .
*
* @param pageUnit
*
*/
public final void setPageUnit(final int pageUnit) {
this.pageUnit = pageUnit;
}
/**
* .
*
* @return
*/
public final int getPageSize() {
return pageSize;
}
/**
* .
*
* @param pageSize
*
*/
public final void setPageSize(final int pageSize) {
this.pageSize = pageSize;
}
/**
* .
*
* @return
*/
public final int getFirstIndex() {
return firstIndex;
}
/**
* .
*
* @param firstIndex
*
*/
public final void setFirstIndex(final int firstIndex) {
this.firstIndex = firstIndex;
}
/**
* .
*
* @return
*/
public final int getLastIndex() {
return lastIndex;
}
/**
* .
*
* @param lastIndex
*
*/
public final void setLastIndex(final int lastIndex) {
this.lastIndex = lastIndex;
}
/**
* .
*
* @return
*/
public final int getRecordCountPerPage() {
return recordCountPerPage;
}
/**
* .
*
* @param recordCountPerPage
*
*/
public final void setRecordCountPerPage(final int recordCountPerPage) {
this.recordCountPerPage = recordCountPerPage;
}
/**
* .
*
* @return
*/
public final String getSearchKeyword() {
return searchKeyword;
}
/**
* .
*
* @param searchKeyword
*
*/
public final void setSearchKeyword(final String searchKeyword) {
this.searchKeyword = searchKeyword;
}
/**
* @return .
*/
public String getSearchCondition() {
return searchCondition;
}
/**
* @param .
*/
public void setSearchCondition(String searchCondition) {
this.searchCondition = searchCondition;
}
}

View File

@ -0,0 +1,34 @@
package kcg.faics.cmmn.bbs;
/**
* .
*
* @author kimnomin
*
*/
public enum PageType {
/**
* .
*/
List,
/**
* .
*/
View,
/**
* .
*/
Add,
/**
* .
*/
Upd,
/**
* .
*/
Del,
/**
* .
*/
Stats
}

View File

@ -0,0 +1,8 @@
/**
* .
*/
/**
* @author kimnomin
*
*/
package kcg.faics.cmmn.bbs;

View File

@ -0,0 +1,104 @@
/*
* CKEditor image upload module for Java.
* Copyright guavatak (https://github.com/guavatak/ckeditor-upload-filter-java)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author guavatak (https://github.com/guavatak/ckeditor-upload-filter-java)
*/
package kcg.faics.cmmn.ckeditor;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Filter class
* @author guavatak
* @since 2014.12.04
* @version 1.0
* @see
*
* <pre>
* << (Modification Information) >>
*
*
* ------- -------- ---------------------------
* 2014.12.04 ( )
* </pre>
*/
public class CkFilter implements Filter {
private static final Log log = LogFactory.getLog(CkFilter.class);
private static final String IMAGE_BASE_DIR_KEY = "ck.image.dir";
private static final String IMAGE_BASE_URL_KEY = "ck.image.url";
private static final String IMAGE_ALLOW_TYPE_KEY = "ck.image.type.allow";
private static final String IMAGE_SAVE_CLASS_KEY = "ck.image.save.class";
private CkImageSaver ckImageSaver;
public void init(FilterConfig filterConfig) throws ServletException {
String properties = filterConfig.getInitParameter("properties");
InputStream inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(properties);
Properties props = new Properties();
try {
props.load(inStream);
} catch (IOException e) {
log.error(e);
}
String imageBaseDir = (String) props.get(IMAGE_BASE_DIR_KEY);
String imageDomain = (String) props.get(IMAGE_BASE_URL_KEY);
String[] allowFileTypeArr = null;
String allowFileType = (String) props.get(IMAGE_ALLOW_TYPE_KEY);
if (StringUtils.isNotBlank(allowFileType)) {
allowFileTypeArr = StringUtils.split(allowFileType, ",");
}
String saveManagerClass = (String) props.get(IMAGE_SAVE_CLASS_KEY);
ckImageSaver = new CkImageSaver(imageBaseDir, imageDomain, allowFileTypeArr, saveManagerClass);
}
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
if (request.getContentType() == null || request.getContentType().indexOf("multipart") == -1) {
// contentType 이 multipart 가 아니라면 스킵한다.
chain.doFilter(request, response);
} else {
ckImageSaver.saveAndReturnUrlToClient(request, response);
}
}
public void destroy() {
// no-op
}
}

View File

@ -0,0 +1,158 @@
/*
* CKEditor image upload module for Java.
* Copyright guavatak (https://github.com/guavatak/ckeditor-upload-filter-java)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author guavatak (https://github.com/guavatak/ckeditor-upload-filter-java)
*/
package kcg.faics.cmmn.ckeditor;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartRequest;
/**
* Created by guava on 1/20/14.
*
* @author guavatak
* @since 2014.12.04
* @version 1.0
* @see
*
* <pre>
* << (Modification Information) >>
*
*
* ------- -------- ---------------------------
* 2014.12.04 ( )
* </pre>
*/
public class CkImageSaver {
private static final Log log = LogFactory.getLog(CkFilter.class);
private static final String FUNC_NO = "CKEditorFuncNum";
private String imageBaseDir;
private String imageDomain;
private String[] allowFileTypeArr;
private FileSaveManager fileSaveManager;
public CkImageSaver(String imageBaseDir, String imageDomain, String[] allowFileTypeArr, String saveManagerClass) {
this.imageBaseDir = imageBaseDir;
if (imageBaseDir.endsWith("/")) {
StringUtils.removeEnd(imageBaseDir, "/");
}
if (imageBaseDir.endsWith("\\")) {
StringUtils.removeEnd(imageBaseDir, "\\");
}
this.imageDomain = imageDomain;
if (imageDomain.endsWith("/")) {
StringUtils.removeEnd(imageDomain, "/");
}
this.allowFileTypeArr = allowFileTypeArr;
if (StringUtils.isBlank(saveManagerClass)) {
fileSaveManager = new DefaultFileSaveManager();
} else {
try {
Class<?> klass = Class.forName(saveManagerClass);
fileSaveManager = (FileSaveManager) klass.newInstance();
} catch (ClassNotFoundException e) {
log.error(e);
throw new RuntimeException(e);
} catch (InstantiationException e) {
log.error(e);
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
log.error(e);
throw new RuntimeException(e);
}
}
}
/**
* ckEditor .
* Request FileItem ,
* MultipartRequest .
*
* @param request Request
* @param response Response
* @throws IOException IO
*/
public void saveAndReturnUrlToClient(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
// Parse the request
try {
MultipartRequest req = (MultipartRequest) request;
MultipartFile f = req.getFile("upload");
String errorMessage = null;
String relUrl = null;
if (isAllowFileType(FilenameUtils.getName(f.getOriginalFilename()))) {
relUrl = fileSaveManager.saveFile(f, imageBaseDir, imageDomain);
} else {
errorMessage = "Restricted Image Format";
}
StringBuffer sb = new StringBuffer();
sb.append("<script type=\"text/javascript\">\n");
sb.append("window.parent.CKEDITOR.tools.callFunction(").append(request.getParameter(FUNC_NO)).append(", '");
sb.append(relUrl);
if (errorMessage != null) {
sb.append("', '").append(errorMessage);
}
sb.append("');\n </script>");
response.setContentType("text/html");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = response.getWriter();
out.print(sb.toString());
out.flush();
out.close();
} catch (Exception e) {
log.error(e);
}
}
protected boolean isAllowFileType(String fileName) {
boolean isAllow = false;
if (allowFileTypeArr != null && allowFileTypeArr.length > 0) {
for (String allowFileType : allowFileTypeArr) {
if (StringUtils.equalsIgnoreCase(allowFileType, StringUtils.substringAfterLast(fileName, "."))) {
isAllow = true;
break;
}
}
} else {
isAllow = true;
}
return isAllow;
}
}

View File

@ -0,0 +1,94 @@
/*
* CKEditor image upload module for Java.
* Copyright guavatak (https://github.com/guavatak/ckeditor-upload-filter-java)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author guavatak (https://github.com/guavatak/ckeditor-upload-filter-java)
*/
package kcg.faics.cmmn.ckeditor;
import java.io.File;
import java.io.IOException;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.MultipartFile;
/**
* Created by guava on 1/20/14.
*
* @author guavatak
* @since 2014.12.04
* @version 1.0
* @see
*
* <pre>
* << (Modification Information) >>
*
*
* ------- -------- ---------------------------
* 2014.12.04 ( )
* </pre>
*/
public class DefaultFileSaveManager implements FileSaveManager {
@Override
public String saveFile(FileItem fileItem, String imageBaseDir, String imageDomain) {
String originalFileName = FilenameUtils.getName(fileItem.getName());
String relUrl;
// filename
String subDir = File.separator + DirectoryPathManager.getDirectoryPathByDateType(DirectoryPathManager.DIR_DATE_TYPE.DATE_POLICY_YYYY_MM);
String fileName = RandomStringUtils.randomAlphanumeric(20) + "." + StringUtils.lowerCase(StringUtils.substringAfterLast(originalFileName, "."));
File newFile = new File(imageBaseDir + subDir + fileName);
File fileToSave = DirectoryPathManager.getUniqueFile(newFile.getAbsoluteFile());
try {
FileUtils.writeByteArrayToFile(fileToSave, fileItem.get());
} catch (IOException e) {
e.printStackTrace();
}
String savedFileName = FilenameUtils.getName(fileToSave.getAbsolutePath());
relUrl = StringUtils.replace(subDir, "\\", "/") + savedFileName;
return imageDomain + relUrl;
}
@Override
public String saveFile(final MultipartFile file, final String imageBaseDir, final String imageDomain) {
String originalFileName = FilenameUtils.getName(file.getOriginalFilename());
String relUrl;
// filename
String subDir = File.separator + DirectoryPathManager.getDirectoryPathByDateType(DirectoryPathManager.DIR_DATE_TYPE.DATE_POLICY_YYYY_MM);
String fileName = RandomStringUtils.randomAlphanumeric(20) + "." + StringUtils.lowerCase(StringUtils.substringAfterLast(originalFileName, "."));
File newFile = new File(imageBaseDir + subDir + fileName);
File fileToSave = DirectoryPathManager.getUniqueFile(newFile.getAbsoluteFile());
try {
FileUtils.writeByteArrayToFile(fileToSave, file.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
String savedFileName = FilenameUtils.getName(fileToSave.getAbsolutePath());
relUrl = StringUtils.replace(subDir, "\\", "/") + savedFileName;
return imageDomain + relUrl;
}
}

View File

@ -0,0 +1,83 @@
/*
* CKEditor image upload module for Java.
* Copyright guavatak (https://github.com/guavatak/ckeditor-upload-filter-java)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author guavatak (https://github.com/guavatak/ckeditor-upload-filter-java)
*/
package kcg.faics.cmmn.ckeditor;
import java.io.File;
import java.util.Calendar;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
/**
*
* @author guavatak
* @since 2014.12.04
* @version 1.0
* @see
*
* <pre>
* << (Modification Information) >>
*
*
* ------- -------- ---------------------------
* 2014.12.04 ( )
* </pre>
*/
public class DirectoryPathManager {
public enum DIR_DATE_TYPE {
DATE_POLICY_YYYY_MM_DD, DATE_POLICY_YYYY_MM, DATE_POLICY_YYYY
};
/**
* 2012/12/22/
* @param dateType
* @return
* @throws InvalidArgumentException
*/
public static String getDirectoryPathByDateType(DIR_DATE_TYPE policy) {
Calendar calendar = Calendar.getInstance();
StringBuffer sb = new StringBuffer();
sb.append(calendar.get(Calendar.YEAR)).append(File.separator);
if (policy.ordinal() <= DIR_DATE_TYPE.DATE_POLICY_YYYY_MM.ordinal()) {
sb.append(StringUtils.leftPad(String.valueOf(calendar.get(Calendar.MONTH)), 2, '0')).append(File.separator);
}
if (policy.ordinal() <= DIR_DATE_TYPE.DATE_POLICY_YYYY_MM_DD.ordinal()) {
sb.append(StringUtils.leftPad(String.valueOf(calendar.get(Calendar.DATE)), 2, '0')).append(File.separator);
}
return sb.toString();
}
public static File getUniqueFile(final File file) {
if (!file.exists())
return file;
File tmpFile = new File(file.getAbsolutePath());
File parentDir = tmpFile.getParentFile();
int count = 1;
String extension = FilenameUtils.getExtension(tmpFile.getName());
String baseName = FilenameUtils.getBaseName(tmpFile.getName());
do {
tmpFile = new File(parentDir, baseName + "_" + count++ + "_." + extension);
} while (tmpFile.exists());
return tmpFile;
}
}

View File

@ -0,0 +1,63 @@
/*
* CKEditor image upload module for Java.
* Copyright guavatak (https://github.com/guavatak/ckeditor-upload-filter-java)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author guavatak (https://github.com/guavatak/ckeditor-upload-filter-java)
*/
package kcg.faics.cmmn.ckeditor;
import org.apache.commons.fileupload.FileItem;
import org.springframework.web.multipart.MultipartFile;
/**
* Created by guava on 1/20/14.
*
* @author guavatak
* @since 2014.12.04
* @version 1.0
* @see
*
* <pre>
* << (Modification Information) >>
*
*
* ------- -------- ---------------------------
* 2014.12.04 ( )
* </pre>
*/
public interface FileSaveManager {
/**
*
* @param fileItem FileItem
* @param imageBaseDir . , . .
* @param imageDomain URL.
* "http://image.my.com" , "/ckimage" .
* .
* @return URL . URL ckeditor .
*/
String saveFile(FileItem fileItem, String imageBaseDir, String imageDomain);
/**
*
* @param file MultipartFile
* @param imageBaseDir . , . .
* @param imageDomain URL.
* "http://image.my.com" , "/ckimage" .
* .
* @return URL . URL ckeditor .
*/
String saveFile(MultipartFile file, String imageBaseDir, String imageDomain);
}

View File

@ -0,0 +1,83 @@
package kcg.faics.cmmn.egov;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Utility class to support to logging information
* @author Vincent Han
* @since 2014.09.18
* @version 1.0
* @see
*
* <pre>
* << (Modification Information) >>
*
*
* ------- -------- ---------------------------
* 2014.09.18
*
* </pre>
*/
public class EgovBasicLogger {
private static final Level IGNORE_INFO_LEVEL = Level.OFF;
private static final Level DEBUG_INFO_LEVEL = Level.FINEST;
private static final Level INFO_INFO_LEVEL = Level.INFO;
private static final Logger ignoreLogger = Logger.getLogger("ignore");
private static final Logger debugLogger = Logger.getLogger("debug");
private static final Logger infoLogger = Logger.getLogger("info");
/**
* .
* @param message
* @param exception
*/
public static void ignore(String message, Exception exception) {
if (exception == null) {
ignoreLogger.log(IGNORE_INFO_LEVEL, message);
} else {
ignoreLogger.log(IGNORE_INFO_LEVEL, message, exception);
}
}
/**
* .
* @param message
* @param exception
*/
public static void ignore(String message) {
ignore(message, null);
}
/**
* .
* @param message
* @param exception
*/
public static void debug(String message, Exception exception) {
if (exception == null) {
debugLogger.log(DEBUG_INFO_LEVEL, message);
} else {
debugLogger.log(DEBUG_INFO_LEVEL, message, exception);
}
}
/**
* .
* @param message
* @param exception
*/
public static void debug(String message) {
debug(message, null);
}
/**
* .
* @param message
* @param exception
*/
public static void info(String message) {
infoLogger.log(INFO_INFO_LEVEL, message);
}
}

View File

@ -0,0 +1,220 @@
package kcg.faics.cmmn.egov;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import kcg.faics.cmmn.egov.util.EgovWebUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Class Name : EgovProperties.java
* Description : properties Globals
* .
* Modification Information
*
*
* ------- -------- ---------------------------
* 2009.01.19
* 2011.07.20 Globals
* 2014.10.13 Globals.properties null
* 2016.09.22 path
* @author
* @since 2009. 01. 19
* @version 1.0
* @see
*
*/
public class EgovProperties {
private static final Logger LOGGER = LoggerFactory.getLogger(EgovProperties.class);
//파일구분자
final static String FILE_SEPARATOR = System.getProperty("file.separator");
//프로퍼티 파일의 물리적 위치
//public static final String GLOBALS_PROPERTIES_FILE = System.getProperty("user.home") + FILE_SEPARATOR + "egovProps" +FILE_SEPARATOR + "globals.properties";
//public static final String RELATIVE_PATH_PREFIX = EgovProperties.class.getResource("").getPath() + FILE_SEPARATOR+ ".." + FILE_SEPARATOR + ".." + FILE_SEPARATOR;
public static final String RELATIVE_PATH_PREFIX = EgovProperties.class.getResource("").getPath().substring(0, EgovProperties.class.getResource("").getPath().lastIndexOf("kcg"));
public static final String GLOBALS_PROPERTIES_FILE = RELATIVE_PATH_PREFIX + "property" + FILE_SEPARATOR + "globals.properties";
/**
* Key (Globals.java )
* @param keyName String
* @return String
*/
public static String getPathProperty(String keyName) {
String value = "";
LOGGER.debug("getPathProperty : {} = {}", GLOBALS_PROPERTIES_FILE, keyName);
FileInputStream fis = null;
try {
Properties props = new Properties();
fis = new FileInputStream(EgovWebUtil.filePathBlackList(GLOBALS_PROPERTIES_FILE));
props.load(new BufferedInputStream(fis));
value = props.getProperty(keyName).trim();
value = RELATIVE_PATH_PREFIX + "property" + System.getProperty("file.separator") + value;
} catch (FileNotFoundException fne) {
LOGGER.debug("Property file not found.", fne);
throw new RuntimeException("Property file not found", fne);
} catch (IOException ioe) {
LOGGER.debug("Property file IO exception", ioe);
throw new RuntimeException("Property file IO exception", ioe);
} finally {
EgovResourceCloseHelper.close(fis);
}
return value;
}
/**
* Key (Globals.java )
* @param keyName String
* @return String
*/
public static String getProperty(String keyName) {
String value = "";
LOGGER.debug("getProperty : {} = {}", GLOBALS_PROPERTIES_FILE, keyName);
FileInputStream fis = null;
try {
Properties props = new Properties();
fis = new FileInputStream(EgovWebUtil.filePathBlackList(GLOBALS_PROPERTIES_FILE));
props.load(new BufferedInputStream(fis));
if (props.getProperty(keyName) == null) {
return "";
}
value = props.getProperty(keyName).trim();
} catch (FileNotFoundException fne) {
LOGGER.debug("Property file not found.", fne);
throw new RuntimeException("Property file not found", fne);
} catch (IOException ioe) {
LOGGER.debug("Property file IO exception", ioe);
throw new RuntimeException("Property file IO exception", ioe);
} finally {
EgovResourceCloseHelper.close(fis);
}
return value;
}
/**
* Key
* @param fileName String
* @param key String
* @return String
*/
public static String getPathProperty(String fileName, String key) {
FileInputStream fis = null;
try {
Properties props = new Properties();
fis = new FileInputStream(EgovWebUtil.filePathBlackList(fileName));
props.load(new BufferedInputStream(fis));
fis.close();
String value = props.getProperty(key);
value = RELATIVE_PATH_PREFIX + "property" + System.getProperty("file.separator") + value;
return value;
} catch (FileNotFoundException fne) {
LOGGER.debug("Property file not found.", fne);
throw new RuntimeException("Property file not found", fne);
} catch (IOException ioe) {
LOGGER.debug("Property file IO exception", ioe);
throw new RuntimeException("Property file IO exception", ioe);
} finally {
EgovResourceCloseHelper.close(fis);
}
}
/**
* Key
* @param fileName String
* @param key String
* @return String
*/
public static String getProperty(String fileName, String key) {
FileInputStream fis = null;
try {
Properties props = new Properties();
fis = new FileInputStream(EgovWebUtil.filePathBlackList(fileName));
props.load(new BufferedInputStream(fis));
fis.close();
String value = props.getProperty(key);
return value;
} catch (FileNotFoundException fne) {
LOGGER.debug("Property file not found.", fne);
throw new RuntimeException("Property file not found", fne);
} catch (IOException ioe) {
LOGGER.debug("Property file IO exception", ioe);
throw new RuntimeException("Property file IO exception", ioe);
} finally {
EgovResourceCloseHelper.close(fis);
}
}
/**
* (key-value) .
* @param property String
* @return ArrayList
*/
public static ArrayList<Map<String, String>> loadPropertyFile(String property) {
// key - value 형태로 된 배열 결과
ArrayList<Map<String, String>> keyList = new ArrayList<Map<String, String>>();
String src = property.replace('\\', File.separatorChar).replace('/', File.separatorChar);
FileInputStream fis = null;
try {
File srcFile = new File(EgovWebUtil.filePathBlackList(src));
if (srcFile.exists()) {
Properties props = new Properties();
fis = new FileInputStream(src);
props.load(new BufferedInputStream(fis));
fis.close();
Enumeration<?> plist = props.propertyNames();
if (plist != null) {
while (plist.hasMoreElements()) {
Map<String, String> map = new HashMap<String, String>();
String key = (String) plist.nextElement();
map.put(key, props.getProperty(key));
keyList.add(map);
}
}
}
} catch (IOException ex) {
LOGGER.debug("IO Exception", ex);
throw new RuntimeException(ex);
} finally {
EgovResourceCloseHelper.close(fis);
}
return keyList;
}
}

View File

@ -0,0 +1,126 @@
package kcg.faics.cmmn.egov;
import java.io.Closeable;
import java.net.ServerSocket;
import java.net.Socket;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Wrapper;
/**
* Utility class to support to close resources
* @author Vincent Han
* @since 2014.09.18
* @version 1.0
* @see
*
* <pre>
* << (Modification Information) >>
*
*
* ------- -------- ---------------------------
* 2014.09.18
*
* </pre>
*/
public class EgovResourceCloseHelper {
/**
* Resource close .
* @param resources
*/
public static void close(Closeable ... resources) {
for (Closeable resource : resources) {
if (resource != null) {
try {
resource.close();
} catch (Exception ignore) {
EgovBasicLogger.ignore("Occurred Exception to close resource is ingored!!");
}
}
}
}
/**
* JDBC resource close
* @param objects
*/
public static void closeDBObjects(Wrapper ... objects) {
for (Object object : objects) {
if (object != null) {
if (object instanceof ResultSet) {
try {
((ResultSet)object).close();
} catch (Exception ignore) {
EgovBasicLogger.ignore("Occurred Exception to close resource is ingored!!");
}
} else if (object instanceof Statement) {
try {
((Statement)object).close();
} catch (Exception ignore) {
EgovBasicLogger.ignore("Occurred Exception to close resource is ingored!!");
}
} else if (object instanceof Connection) {
try {
((Connection)object).close();
} catch (Exception ignore) {
EgovBasicLogger.ignore("Occurred Exception to close resource is ingored!!");
}
} else {
throw new IllegalArgumentException("Wrapper type is not found : " + object.toString());
}
}
}
}
/**
* Socket resource close
* @param objects
*/
public static void closeSocketObjects(Socket socket, ServerSocket server) {
if (socket != null) {
try {
socket.shutdownOutput();
} catch (Exception ignore) {
EgovBasicLogger.ignore("Occurred Exception to shutdown ouput is ignored!!");
}
try {
socket.close();
} catch (Exception ignore) {
EgovBasicLogger.ignore("Occurred Exception to close resource is ignored!!");
}
}
if (server != null) {
try {
server.close();
} catch (Exception ignore) {
EgovBasicLogger.ignore("Occurred Exception to close resource is ignored!!");
}
}
}
/**
* Socket resource close
*
* @param sockets
*/
public static void closeSockets(Socket ... sockets) {
for (Socket socket : sockets) {
if (socket != null) {
try {
socket.shutdownOutput();
} catch (Exception ignore) {
EgovBasicLogger.ignore("Occurred Exception to shutdown ouput is ignored!!");
}
try {
socket.close();
} catch (Exception ignore) {
EgovBasicLogger.ignore("Occurred Exception to close resource is ignored!!");
}
}
}
}
}

View File

@ -0,0 +1,727 @@
package kcg.faics.cmmn.egov.file;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import kcg.faics.cmmn.egov.util.EgovStringUtil;
import kcg.faics.cmmn.egov.util.EgovWebUtil;
import kcg.faics.cmmn.egov.vo.FileVO;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.multipart.MultipartFile;
import egovframework.rte.fdl.property.EgovPropertyService;
/**
* @Class Name : EgovFileMngUtil.java
* @Description :
* @Modification Information
*
* ------- -------- ---------------------------
* 2009.02.13 2011.08.31 JJY 릿
* 2016.09.22 83~85, 126~136
* 2016.10.21 parseFileInf Override, deleteFile Override
*
* @author
* @since 2009. 02. 13
* @version 1.0
* @see
*
*/
@Component("EgovFileMngUtil")
public class EgovFileMngUtil {
public static final int BUFF_SIZE = 2048;
@Resource(name = "propertiesService")
protected EgovPropertyService propertyService;
private static final Logger LOGGER = LoggerFactory.getLogger(EgovFileMngUtil.class);
/**
* .
*
* <pre>
* : {}_{}.{}
* </pre>
*
* @param filePath
* @param fileNameExt ( )
* @return
*/
public String makeNewFileName(final String filePath, final String fileNameExt) {
int idx = 0;
String fileExt = "";
String fileName = "";
String newFileName = "";
String filePathName = filePath + fileNameExt;
String newFileNameExt = fileNameExt;
if (!StringUtils.isBlank(filePathName)) {
fileExt = FilenameUtils.getExtension(fileNameExt);
fileName = FilenameUtils.getName(fileNameExt);
fileName = FilenameUtils.removeExtension(fileName);
newFileName = fileName;
while (true) {
File f = new File(filePathName);
if (f.isFile()) {
newFileName = String.format("%s_%d", fileName, ++idx);
filePathName = String.format("%s%s.%s", filePath, newFileName, fileExt);
} else {
break;
}
}
newFileNameExt = newFileName;
if (!StringUtils.isBlank(fileExt)) {
newFileNameExt += "." + fileExt;
}
}
return newFileNameExt;
}
/**
* .
*
* @param files
*
* @param keyStr
*
* @param fileKeyParam
*
* @param atchFileId
* ID
* @param storePath
*
* @return List
* @throws Exception
*
*/
public List<FileVO> parseFileInf(final Map<String, MultipartFile> files,
final String keyStr, final int fileKeyParam,
final String atchFileId, final String storePath) throws Exception {
int fileKey = fileKeyParam;
String storePathString = "";
String atchFileIdString = "";
if (StringUtils.isBlank(storePath)) {
storePathString = propertyService.getString("Globals.fileStorePath");
} else {
storePathString = propertyService.getString(storePath);
}
if (StringUtils.isBlank(atchFileId)) {
// atchFileIdString = idgenService.getNextStringId();
atchFileIdString = atchFileId;
} else {
atchFileIdString = atchFileId;
}
File saveFolder = new File(storePathString);
if (!saveFolder.exists() || saveFolder.isFile()) {
saveFolder.mkdirs();
}
List<FileVO> result = new ArrayList<FileVO>();
if (files != null) {
Iterator<Entry<String, MultipartFile>> itr = files.entrySet().iterator();
MultipartFile file;
String filePath = "";
FileVO fvo;
while (itr.hasNext()) {
Entry<String, MultipartFile> entry = itr.next();
file = entry.getValue();
String orginFileName = file.getOriginalFilename();
// --------------------------------------
// 원 파일명이 없는 경우 처리
// (첨부가 되지 않은 input file type)
// --------------------------------------
if ("".equals(orginFileName)) {
continue;
}
// //------------------------------------
int index = orginFileName.lastIndexOf(".");
// String fileName = orginFileName.substring(0, index);
String fileExt = orginFileName.substring(index + 1);
String newName = orginFileName;
// KeyStr이 없으면 원래 파일명을 사용한다. by KNM
if (!StringUtils.isBlank(keyStr)) {
newName = keyStr + EgovStringUtil.getTimeStamp() + fileKey;
}
long fileSize = file.getSize();
// 같은 경로에 파일이 존재하면 파일 명을 수정한다.
String tempFileName = makeNewFileName(storePathString, newName);
if (!newName.equalsIgnoreCase(tempFileName)) {
newName = tempFileName;
}
if (StringUtils.isNotBlank(orginFileName)) {
filePath = storePathString + File.separator + newName;
file.transferTo(new File(filePath));
}
fvo = new FileVO();
fvo.setFileExtsn(fileExt);
fvo.setFileStreCours(storePathString);
fvo.setFileMg(Long.toString(fileSize));
fvo.setOrignlFileNm(orginFileName);
fvo.setStreFileNm(newName);
fvo.setAtchFileId(atchFileIdString);
fvo.setFileSn(entry.getKey());
// fvo.setFileSn(String.valueOf(fileKey));
writeFile(file, newName, storePathString);
result.add(fvo);
fileKey++;
}
}
return result;
}
/**
* .
*
* @param file
* @param newName
* @param stordFilePath
* @throws Exception
*/
protected void writeUploadedFile(MultipartFile file, String newName, String stordFilePath) throws Exception {
InputStream stream = null;
OutputStream bos = null;
String stordFilePathReal = (stordFilePath == null ? "" : stordFilePath).replaceAll("..", "");
try {
stream = file.getInputStream();
File cFile = new File(stordFilePathReal);
if (!cFile.isDirectory()) {
boolean flag = cFile.mkdir();
if (!flag) {
throw new IOException("Directory creation Failed ");
}
}
bos = new FileOutputStream(stordFilePathReal + File.separator + newName);
int bytesRead = 0;
byte[] buffer = new byte[BUFF_SIZE];
while ((bytesRead = stream.read(buffer, 0, BUFF_SIZE)) != -1) {
bos.write(buffer, 0, bytesRead);
}
} catch (FileNotFoundException fnfe) {
LOGGER.debug("fnfe: {}", fnfe);
} catch (IOException ioe) {
LOGGER.debug("ioe: {}", ioe);
} catch (Exception e) {
LOGGER.debug("e: {}", e);
} finally {
if (bos != null) {
try {
bos.close();
} catch (Exception ignore) {
LOGGER.debug("IGNORED: {}", ignore.getMessage());
}
}
if (stream != null) {
try {
stream.close();
} catch (Exception ignore) {
LOGGER.debug("IGNORED: {}", ignore.getMessage());
}
}
}
}
/**
* .
*
* @param request
* @param response
* @throws Exception
*/
public static void downFile(HttpServletRequest request, HttpServletResponse response) throws Exception {
String downFileName = EgovStringUtil.isNullToString(request.getAttribute("downFile")).replaceAll("..", "");
String orgFileName = EgovStringUtil.isNullToString(request.getAttribute("orgFileName")).replaceAll("..", "");
/*
* if ((String)request.getAttribute("downFile") == null) { downFileName
* = ""; } else { downFileName =
* EgovStringUtil.isNullToString(request.getAttribute("downFile")); }
*/
/*
* if ((String)request.getAttribute("orgFileName") == null) {
* orgFileName = ""; } else { orgFileName =
* (String)request.getAttribute("orginFile"); }
*/
File file = new File(downFileName);
if (!file.exists()) {
throw new FileNotFoundException(downFileName);
}
if (!file.isFile()) {
throw new FileNotFoundException(downFileName);
}
byte[] b = new byte[BUFF_SIZE]; // buffer size 2K.
String fName = (new String(orgFileName.getBytes(), "UTF-8")).replaceAll("\r\n", "");
response.setContentType("application/x-msdownload");
response.setHeader("Content-Disposition:", "attachment; filename=" + fName);
response.setHeader("Content-Transfer-Encoding", "binary");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "0");
BufferedInputStream fin = null;
BufferedOutputStream outs = null;
try {
fin = new BufferedInputStream(new FileInputStream(file));
outs = new BufferedOutputStream(response.getOutputStream());
int read = 0;
while ((read = fin.read(b)) != -1) {
outs.write(b, 0, read);
}
} finally {
if (outs != null) {
try {
outs.close();
} catch (Exception ignore) {
LOGGER.debug("IGNORED: {}", ignore.getMessage());
}
}
if (fin != null) {
try {
fin.close();
} catch (Exception ignore) {
LOGGER.debug("IGNORED: {}", ignore.getMessage());
}
}
}
}
/**
* .
*
* @param file
* @return
* @throws Exception
*
* public static HashMap<String, String>
* uploadFile(MultipartFile file) throws Exception {
*
* HashMap<String, String> map = new HashMap<String, String>();
* //Write File 이후 Move File???? String newName = ""; String
* stordFilePath =
* EgovProperties.getProperty("Globals.fileStorePath"); String
* orginFileName = file.getOriginalFilename();
*
* int index = orginFileName.lastIndexOf("."); //String fileName
* = orginFileName.substring(0, _index); String fileExt =
* orginFileName.substring(index + 1); long size =
* file.getSize();
*
* //newName 은 Naming Convention에 의해서 생성 newName =
* EgovStringUtil.getTimeStamp() + "." + fileExt;
* writeFile(file, newName, stordFilePath); //storedFilePath는 지정
* map.put(Globals.ORIGIN_FILE_NM, orginFileName);
* map.put(Globals.UPLOAD_FILE_NM, newName);
* map.put(Globals.FILE_EXT, fileExt);
* map.put(Globals.FILE_PATH, stordFilePath);
* map.put(Globals.FILE_SIZE, String.valueOf(size));
*
* return map; }
*/
/**
* .
*
* @param file
* @param newName
* @param stordFilePath
* @throws Exception
*/
protected static void writeFile(MultipartFile file, String newName, String stordFilePath) throws Exception {
InputStream stream = null;
OutputStream bos = null;
newName = EgovWebUtil.filePathBlackList(newName);
stordFilePath = EgovWebUtil.filePathBlackList(stordFilePath);
try {
stream = file.getInputStream();
File cFile = new File(stordFilePath);
if (!cFile.isDirectory()) {
cFile.mkdir();
}
bos = new FileOutputStream(stordFilePath + File.separator + newName);
int bytesRead = 0;
byte[] buffer = new byte[BUFF_SIZE];
while ((bytesRead = stream.read(buffer, 0, BUFF_SIZE)) != -1) {
bos.write(buffer, 0, bytesRead);
}
} catch (FileNotFoundException fnfe) {
LOGGER.debug("fnfe: {}", fnfe);
} catch (IOException ioe) {
LOGGER.debug("ioe: {}", ioe);
} catch (Exception e) {
LOGGER.debug("e: {}", e);
} finally {
if (bos != null) {
try {
bos.close();
} catch (Exception ignore) {
LOGGER.debug("IGNORED: {}", ignore.getMessage());
}
}
if (stream != null) {
try {
stream.close();
} catch (Exception ignore) {
LOGGER.debug("IGNORED: {}", ignore.getMessage());
}
}
}
}
/**
* .
*
* @param response
* @param streFileNm
* :
* @param orignFileNm
* @throws Exception
*/
public void downFile(HttpServletResponse response, String streFileNm, String orignFileNm) throws Exception {
// String downFileName =
// EgovStringUtil.isNullToString(request.getAttribute("downFile")).replaceAll("..","");
// String orgFileName =
// EgovStringUtil.isNullToString(request.getAttribute("orgFileName")).replaceAll("..","");
String downFileName = EgovStringUtil.isNullToString(streFileNm).replaceAll("..", "");
String orgFileName = EgovStringUtil.isNullToString(orignFileNm).replaceAll("..", "");
File file = new File(downFileName);
// log.debug(this.getClass().getName()+" downFile downFileName "+downFileName);
// log.debug(this.getClass().getName()+" downFile orgFileName "+orgFileName);
if (!file.exists()) {
throw new FileNotFoundException(downFileName);
}
if (!file.isFile()) {
throw new FileNotFoundException(downFileName);
}
// byte[] b = new byte[BUFF_SIZE]; //buffer size 2K.
int fSize = (int) file.length();
if (fSize > 0) {
BufferedInputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(file));
String mimetype = "text/html"; // "application/x-msdownload"
response.setBufferSize(fSize);
response.setContentType(mimetype);
response.setHeader("Content-Disposition:", "attachment; filename=" + orgFileName);
response.setContentLength(fSize);
// response.setHeader("Content-Transfer-Encoding","binary");
// response.setHeader("Pragma","no-cache");
// response.setHeader("Expires","0");
FileCopyUtils.copy(in, response.getOutputStream());
} finally {
if (in != null) {
try {
in.close();
} catch (Exception ignore) {
LOGGER.debug("IGNORED: {}", ignore.getMessage());
}
}
}
response.getOutputStream().flush();
response.getOutputStream().close();
}
/*
* String uploadPath = propertiesService.getString("fileDir");
*
* File uFile = new File(uploadPath, requestedFile); int fSize = (int)
* uFile.length();
*
* if (fSize > 0) { BufferedInputStream in = new BufferedInputStream(new
* FileInputStream(uFile));
*
* String mimetype = "text/html";
*
* response.setBufferSize(fSize); response.setContentType(mimetype);
* response.setHeader("Content-Disposition", "attachment; filename=\"" +
* requestedFile + "\""); response.setContentLength(fSize);
*
* FileCopyUtils.copy(in, response.getOutputStream()); in.close();
* response.getOutputStream().flush();
* response.getOutputStream().close(); } else {
* response.setContentType("text/html"); PrintWriter printwriter =
* response.getWriter(); printwriter.println("<html>");
* printwriter.println("<br><br><br><h2>Could not get file name:<br>" +
* requestedFile + "</h2>"); printwriter.println(
* "<br><br><br><center><h3><a href='javascript: history.go(-1)'>Back</a></h3></center>"
* ); printwriter.println("<br><br><br>&copy; webAccess");
* printwriter.println("</html>"); printwriter.flush();
* printwriter.close(); } //
*/
/*
* response.setContentType("application/x-msdownload");
* response.setHeader("Content-Disposition:", "attachment; filename=" +
* new String(orgFileName.getBytes(),"UTF-8" ));
* response.setHeader("Content-Transfer-Encoding","binary");
* response.setHeader("Pragma","no-cache");
* response.setHeader("Expires","0");
*
* BufferedInputStream fin = new BufferedInputStream(new
* FileInputStream(file)); BufferedOutputStream outs = new
* BufferedOutputStream(response.getOutputStream()); int read = 0;
*
* while ((read = fin.read(b)) != -1) { outs.write(b,0,read); }
* log.debug
* (this.getClass().getName()+" BufferedOutputStream Write Complete!!! "
* );
*
* outs.close(); fin.close(); //
*/
}
/**
* EgovFileTool &
*
* <pre>
* Comment : .
* </pre>
*
* @param savedFile
* @param storePath
* @return ,
*/
public String deleteFile(final String savedFile, final String storePath) {
if (StringUtils.isBlank(savedFile)) {
return "";
}
String storePathString = "";
if (StringUtils.isBlank(storePath)) {
storePathString = propertyService.getString("Globals.fileStorePath");
} else {
storePathString = propertyService.getString(storePath);
}
String fileDeletePath = storePathString + File.separator + savedFile;
// 인자값 유효하지 않은 경우 블랭크 리턴
if (fileDeletePath == null || fileDeletePath.equals("")) {
return "";
}
String result = "";
File file = new File(EgovWebUtil.filePathBlackList(fileDeletePath));
if (file.isFile()) {
result = deletePath(file);
} else {
result = "";
}
return result;
}
private String deletePath(File file) {
String result = "";
if (file.exists()) {
result = file.getAbsolutePath();
if (!file.delete()) {
result = "";
}
}
return result;
}
/**
* .
*
* @param files
*
* @param keyStr
*
* @param fileKeyParam
*
* @param atchFileId
* ID
* @param storePath
*
* @param folderNm
*
* @return List
* @throws Exception
*
*/
public List<FileVO> parseFileInf(final Map<String, MultipartFile> files,
final String keyStr, final int fileKeyParam,
final String atchFileId, final String storePath, final String folderNm) throws Exception {
int fileKey = fileKeyParam;
String storePathString = "";
String atchFileIdString = "";
if (StringUtils.isBlank(storePath)) {
storePathString = propertyService.getString(storePath, "Globals.fileStorePath");
} else {
storePathString = propertyService.getString(storePath);
}
storePathString = storePathString + folderNm + File.separator;
if (StringUtils.isBlank(atchFileId)) {
atchFileIdString = atchFileId;
} else {
atchFileIdString = atchFileId;
}
File saveFolder = new File(storePathString);
if (!saveFolder.exists() || saveFolder.isFile()) {
saveFolder.mkdirs();
}
List<FileVO> result = new ArrayList<FileVO>();
if (files != null) {
Iterator<Entry<String, MultipartFile>> itr = files.entrySet().iterator();
MultipartFile file;
String filePath = "";
FileVO fvo;
while (itr.hasNext()) {
Entry<String, MultipartFile> entry = itr.next();
file = entry.getValue();
String orginFileName = file.getOriginalFilename();
// --------------------------------------
// 원 파일명이 없는 경우 처리
// (첨부가 되지 않은 input file type)
// --------------------------------------
if ("".equals(orginFileName)) {
continue;
}
// //------------------------------------
int index = orginFileName.lastIndexOf(".");
String fileExt = orginFileName.substring(index + 1);
String newName = orginFileName;
// KeyStr이 없으면 원래 파일명을 사용한다. by KNM
if (!StringUtils.isBlank(keyStr)) {
newName = keyStr + EgovStringUtil.getTimeStamp() + fileKey;
}
long fileSize = file.getSize();
// 같은 경로에 파일이 존재하면 파일 명을 수정한다.
String tempFileName = makeNewFileName(storePathString, newName);
if (!newName.equalsIgnoreCase(tempFileName)) {
newName = tempFileName;
}
if (StringUtils.isNotBlank(orginFileName)) {
filePath = storePathString + File.separator + newName;
file.transferTo(new File(filePath));
}
fvo = new FileVO();
fvo.setFileExtsn(fileExt);
fvo.setFileStreCours(storePathString);
fvo.setFileMg(Long.toString(fileSize));
fvo.setOrignlFileNm(orginFileName);
fvo.setStreFileNm(newName);
fvo.setAtchFileId(atchFileIdString);
fvo.setFileSn(entry.getKey());
writeFile(file, newName, storePathString);
result.add(fvo);
fileKey++;
}
}
return result;
}
/**
* EgovFileTool &
*
* <pre>
* Comment : .
* </pre>
*
* @param savedFile
* @param storePath
* @param folderNm
* @return ,
*/
public String deleteFile(final String savedFile, final String storePath, final String folderNm) {
if (StringUtils.isBlank(savedFile)) {
return "";
}
String storePathString = "";
if (StringUtils.isBlank(storePath)) {
storePathString = propertyService.getString("Globals.fileStorePath");
} else {
storePathString = propertyService.getString(storePath);
}
String fileDeletePath = storePathString + File.separator + folderNm + File.separator + savedFile;
// 인자값 유효하지 않은 경우 블랭크 리턴
if (fileDeletePath == null || fileDeletePath.equals("")) {
return "";
}
String result = "";
File file = new File(EgovWebUtil.filePathBlackList(fileDeletePath));
if (file.isFile()) {
result = deletePath(file);
} else {
result = "";
}
return result;
}
}

View File

@ -0,0 +1,86 @@
package kcg.faics.cmmn.egov.file;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import kcg.faics.cmmn.egov.file.EgovFormBasedFileUtil;
import kcg.faics.cmmn.egov.file.EgovFormBasedFileVo;
import kcg.faics.cmmn.egov.util.EgovWebUtil;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
/**
* @Class Name : EgovFileUploadUtil.java
* @Description : Spring File Upload
* @Modification Information
*
*
* ------- -------- ---------------------------
* 2009.08.26
*
* @author
* @since 2009.08.26
* @version 1.0
* @see
*/
public class EgovFileUploadUtil extends EgovFormBasedFileUtil {
/**
* Upload .
*
* @param request
* @param where
* @param maxFileSize
* @return
* @throws Exception
*/
public static List<EgovFormBasedFileVo> uploadFiles(HttpServletRequest request, String where, long maxFileSize) throws Exception {
List<EgovFormBasedFileVo> list = new ArrayList<EgovFormBasedFileVo>();
MultipartHttpServletRequest mptRequest = (MultipartHttpServletRequest) request;
Iterator<?> fileIter = mptRequest.getFileNames();
while (fileIter.hasNext()) {
MultipartFile mFile = mptRequest.getFile((String) fileIter.next());
EgovFormBasedFileVo vo = new EgovFormBasedFileVo();
String tmp = mFile.getOriginalFilename();
if (tmp.lastIndexOf("\\") >= 0) {
tmp = tmp.substring(tmp.lastIndexOf("\\") + 1);
}
vo.setFileName(tmp);
vo.setContentType(mFile.getContentType());
vo.setServerSubPath(getTodayString());
vo.setPhysicalName(getPhysicalFileName());
vo.setSize(mFile.getSize());
if (tmp.lastIndexOf(".") >= 0) {
vo.setPhysicalName(vo.getPhysicalName()); // 2012.11 KISA 보안조치
}
if (mFile.getSize() > 0) {
InputStream is = null;
try {
is = mFile.getInputStream();
saveFile(is, new File(EgovWebUtil.filePathBlackList(where + SEPERATOR + vo.getServerSubPath() + SEPERATOR + vo.getPhysicalName())));
} finally {
if (is != null) {
is.close();
}
}
list.add(vo);
}
}
return list;
}
}

View File

@ -0,0 +1,283 @@
package kcg.faics.cmmn.egov.file;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import kcg.faics.cmmn.egov.EgovResourceCloseHelper;
import kcg.faics.cmmn.egov.util.EgovWebUtil;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.util.Streams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @Class Name : EgovFormBasedFileUtil.java
* @Description : Form-based File Upload
* @Modification Information
*
*
* ------- -------- ---------------------------
* 2009.08.26
*
* @author
* @since 2009.08.26
* @version 1.0
* @see
*/
public class EgovFormBasedFileUtil {
/** Buffer size */
public static final int BUFFER_SIZE = 8192;
public static final String SEPERATOR = File.separator;
private static final Logger LOGGER = LoggerFactory.getLogger(EgovFormBasedFileUtil.class);
/**
* .
* ex) 20090101
* @return
*/
public static String getTodayString() {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
return format.format(new Date());
}
/**
* .
* @return
*/
public static String getPhysicalFileName() {
return EgovFormBasedUUID.randomUUID().toString().replaceAll("-", "").toUpperCase();
}
/**
* .
* @param filename String
* @return
* @throws Exception
*/
protected static String convert(String filename) throws Exception {
//return java.net.URLEncoder.encode(filename, "utf-8");
return filename;
}
/**
* Stream .
* @param is InputStream
* @param file File
* @throws IOException
*/
public static long saveFile(InputStream is, File file) throws IOException {
// 디렉토리 생성
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
OutputStream os = null;
long size = 0L;
try {
os = new FileOutputStream(file);
int bytesRead = 0;
byte[] buffer = new byte[BUFFER_SIZE];
while ((bytesRead = is.read(buffer, 0, BUFFER_SIZE)) != -1) {
size += bytesRead;
os.write(buffer, 0, bytesRead);
}
} finally {
EgovResourceCloseHelper.close(os);
}
return size;
}
/**
* Upload .
*
* @param request
* @param where
* @param maxFileSize
* @return
* @throws Exception
*/
public static List<EgovFormBasedFileVo> uploadFiles(HttpServletRequest request, String where, long maxFileSize) throws Exception {
List<EgovFormBasedFileVo> list = new ArrayList<EgovFormBasedFileVo>();
// Check that we have a file upload request
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (isMultipart) {
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload();
upload.setFileSizeMax(maxFileSize); // SizeLimitExceededException
// Parse the request
FileItemIterator iter = upload.getItemIterator(request);
while (iter.hasNext()) {
FileItemStream item = iter.next();
String name = item.getFieldName();
InputStream stream = item.openStream();
if (item.isFormField()) {
LOGGER.info("Form field '{}' with value '{}' detected.", name, Streams.asString(stream));
} else {
LOGGER.info("File field '{}' with file name '{}' detected.", name, item.getName());
if ("".equals(item.getName())) {
continue;
}
// Process the input stream
EgovFormBasedFileVo vo = new EgovFormBasedFileVo();
String tmp = item.getName();
if (tmp.lastIndexOf("\\") >= 0) {
tmp = tmp.substring(tmp.lastIndexOf("\\") + 1);
}
vo.setFileName(tmp);
vo.setContentType(item.getContentType());
vo.setServerSubPath(getTodayString());
vo.setPhysicalName(getPhysicalFileName());
if (tmp.lastIndexOf(".") >= 0) {
vo.setPhysicalName(vo.getPhysicalName() + tmp.substring(tmp.lastIndexOf(".")));
}
long size = saveFile(stream, new File(EgovWebUtil.filePathBlackList(where) + SEPERATOR + vo.getServerSubPath() + SEPERATOR + vo.getPhysicalName()));
vo.setSize(size);
list.add(vo);
}
}
} else {
throw new IOException("form's 'enctype' attribute have to be 'multipart/form-data'");
}
return list;
}
/**
* Download .
*
* @param response
* @param where
* @param serverSubPath
* @param physicalName
* @param original
* @throws Exception
*/
public static void downloadFile(HttpServletResponse response, String where, String serverSubPath, String physicalName, String original) throws Exception {
String downFileName = where + SEPERATOR + serverSubPath + SEPERATOR + physicalName;
File file = new File(EgovWebUtil.filePathBlackList(downFileName));
if (!file.exists()) {
throw new FileNotFoundException(downFileName);
}
if (!file.isFile()) {
throw new FileNotFoundException(downFileName);
}
byte[] b = new byte[BUFFER_SIZE];
original = original.replaceAll("\r", "").replaceAll("\n", "");
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=\"" + convert(original) + "\";");
response.setHeader("Content-Transfer-Encoding", "binary");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "0");
BufferedInputStream fin = null;
BufferedOutputStream outs = null;
try {
fin = new BufferedInputStream(new FileInputStream(file));
outs = new BufferedOutputStream(response.getOutputStream());
int read = 0;
while ((read = fin.read(b)) != -1) {
outs.write(b, 0, read);
}
} finally {
EgovResourceCloseHelper.close(outs, fin);
}
}
/**
* .
*
* mimeType JSP .
* getServletConfig().getServletContext().getMimeType(name);
*
* @param response
* @param where
* @param serverSubPath
* @param physicalName
* @param mimeType
* @throws Exception
*/
public static void viewFile(HttpServletResponse response, String where, String serverSubPath, String physicalName, String mimeTypeParam) throws Exception {
String mimeType = mimeTypeParam;
String downFileName = where + SEPERATOR + serverSubPath + SEPERATOR + physicalName;
File file = new File(EgovWebUtil.filePathBlackList(downFileName));
if (!file.exists()) {
throw new FileNotFoundException(downFileName);
}
if (!file.isFile()) {
throw new FileNotFoundException(downFileName);
}
byte[] b = new byte[BUFFER_SIZE];
if (mimeType == null) {
mimeType = "application/octet-stream;";
}
response.setContentType(EgovWebUtil.removeCRLF(mimeType));
response.setHeader("Content-Disposition", "filename=image;");
BufferedInputStream fin = null;
BufferedOutputStream outs = null;
try {
fin = new BufferedInputStream(new FileInputStream(file));
outs = new BufferedOutputStream(response.getOutputStream());
int read = 0;
while ((read = fin.read(b)) != -1) {
outs.write(b, 0, read);
}
} finally {
EgovResourceCloseHelper.close(outs, fin);
}
}
}

View File

@ -0,0 +1,104 @@
package kcg.faics.cmmn.egov.file;
import java.io.Serializable;
/**
* @Class Name : EgovFormBasedFileVo.java
* @Description : Form-based File Upload VO
* @Modification Information
*
*
* ------- -------- ---------------------------
* 2009.08.26
*
* @author
* @since 2009.08.26
* @version 1.0
* @see
*
* Copyright (C) 2008 by MOPAS All right reserved.
*/
@SuppressWarnings("serial")
public class EgovFormBasedFileVo implements Serializable {
/** 파일명 */
private String fileName = "";
/** ContextType */
private String contentType = "";
/** 하위 디렉토리 지정 */
private String serverSubPath = "";
/** 물리적 파일명 */
private String physicalName = "";
/** 파일 사이즈 */
private long size = 0L;
/**
* fileName attribute .
* @return the fileName
*/
public String getFileName() {
return fileName;
}
/**
* fileName attribute .
* @param fileName the fileName to set
*/
public void setFileName(String fileName) {
this.fileName = fileName;
}
/**
* contentType attribute .
* @return the contentType
*/
public String getContentType() {
return contentType;
}
/**
* contentType attribute .
* @param contentType the contentType to set
*/
public void setContentType(String contentType) {
this.contentType = contentType;
}
/**
* serverSubPath attribute .
* @return the serverSubPath
*/
public String getServerSubPath() {
return serverSubPath;
}
/**
* serverSubPath attribute .
* @param serverSubPath the serverSubPath to set
*/
public void setServerSubPath(String serverSubPath) {
this.serverSubPath = serverSubPath;
}
/**
* physicalName attribute .
* @return the physicalName
*/
public String getPhysicalName() {
return physicalName;
}
/**
* physicalName attribute .
* @param physicalName the physicalName to set
*/
public void setPhysicalName(String physicalName) {
this.physicalName = physicalName;
}
/**
* size attribute .
* @return the size
*/
public long getSize() {
return size;
}
/**
* size attribute .
* @param size the size to set
*/
public void setSize(long size) {
this.size = size;
}
}

View File

@ -0,0 +1,529 @@
package kcg.faics.cmmn.egov.file;
import java.io.Serializable;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
/**
*
* A class that represents an immutable universally unique identifier (UUID). A
* UUID represents a 128-bit value.
*
* <p>
* There exist different variants of these global identifiers. The methods of
* this class are for manipulating the Leach-Salz variant, although the
* constructors allow the creation of any variant of UUID (described below).
*
* <p>
* The layout of a variant 2 (Leach-Salz) UUID is as follows:
*
* The most significant long consists of the following unsigned fields:
*
* <pre>
* 0xFFFFFFFF00000000 time_low
* 0x00000000FFFF0000 time_mid
* 0x000000000000F000 version
* 0x0000000000000FFF time_hi
* </pre>
*
* The least significant long consists of the following unsigned fields:
*
* <pre>
* 0xC000000000000000 variant
* 0x3FFF000000000000 clock_seq
* 0x0000FFFFFFFFFFFF node
* </pre>
*
* <p>
* The variant field contains a value which identifies the layout of the
* <tt>UUID</tt>. The bit layout described above is valid only for a
* <tt>UUID</tt> with a variant value of 2, which indicates the Leach-Salz
* variant.
*
* <p>
* The version field holds a value that describes the type of this <tt>UUID</tt>.
* There are four different basic types of UUIDs: time-based, DCE security,
* name-based, and randomly generated UUIDs. These types have a version value of
* 1, 2, 3 and 4, respectively.
*
* <p>
* For more information including algorithms used to create <tt>UUID</tt>s,
* see the Internet-Draft <a
* href="http://www.ietf.org/internet-drafts/draft-mealling-uuid-urn-03.txt">UUIDs
* and GUIDs</a> or the standards body definition at <a
* href="http://www.iso.ch/cate/d2229.html">ISO/IEC 11578:1996</a>.
*
* @version 1.14, 07/12/04
* @since 1.5
*/
@SuppressWarnings("serial")
public class EgovFormBasedUUID implements Serializable {
/*
* The most significant 64 bits of this UUID.
*
* @serial
*/
private final long mostSigBits;
/*
* The least significant 64 bits of this UUID.
*
* @serial
*/
private final long leastSigBits;
/*
* The version number associated with this UUID. Computed on demand.
*/
private transient int version = -1;
/*
* The variant number associated with this UUID. Computed on demand.
*/
private transient int variant = -1;
/*
* The timestamp associated with this UUID. Computed on demand.
*/
private transient volatile long timestamp = -1;
/*
* The clock sequence associated with this UUID. Computed on demand.
*/
private transient int sequence = -1;
/*
* The node number associated with this UUID. Computed on demand.
*/
private transient long node = -1;
/*
* The hashcode of this UUID. Computed on demand.
*/
private transient int hashCode = -1;
/*
* The random number generator used by this class to create random based
* UUIDs.
*/
private static volatile SecureRandom numberGenerator = null;
// Constructors and Factories
/*
* Private constructor which uses a byte array to construct the new UUID.
*/
private EgovFormBasedUUID(byte[] data) {
long msb = 0;
long lsb = 0;
for (int i = 0; i < 8; i++)
msb = (msb << 8) | (data[i] & 0xff);
for (int i = 8; i < 16; i++)
lsb = (lsb << 8) | (data[i] & 0xff);
this.mostSigBits = msb;
this.leastSigBits = lsb;
}
/**
* Constructs a new <tt>UUID</tt> using the specified data.
* <tt>mostSigBits</tt> is used for the most significant 64 bits of the
* <tt>UUID</tt> and <tt>leastSigBits</tt> becomes the least significant
* 64 bits of the <tt>UUID</tt>.
*
* @param mostSigBits
* @param leastSigBits
*/
public EgovFormBasedUUID(long mostSigBits, long leastSigBits) {
this.mostSigBits = mostSigBits;
this.leastSigBits = leastSigBits;
}
/**
* Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
*
* The <code>UUID</code> is generated using a cryptographically strong
* pseudo random number generator.
*
* @return a randomly generated <tt>UUID</tt>.
*/
public static EgovFormBasedUUID randomUUID() {
SecureRandom ng = numberGenerator;
if (ng == null) {
numberGenerator = ng = new SecureRandom();
}
byte[] randomBytes = new byte[16];
ng.nextBytes(randomBytes);
randomBytes[6] &= 0x0f; /* clear version */
randomBytes[6] |= 0x40; /* set to version 4 */
randomBytes[8] &= 0x3f; /* clear variant */
randomBytes[8] |= 0x80; /* set to IETF variant */
return new EgovFormBasedUUID(randomBytes);
}
/**
* Static factory to retrieve a type 3 (name based) <tt>UUID</tt> based on
* the specified byte array.
*
* @param name
* a byte array to be used to construct a <tt>UUID</tt>.
* @return a <tt>UUID</tt> generated from the specified array.
*/
public static EgovFormBasedUUID nameUUIDFromBytes(byte[] name) {
return null;
/*
* 2106.11.18
* FindBugs Array index is out of bounds. .
* .
*
*
MessageDigest md;
try {
// 2011.10.10 보안점검 후속조치 암호화 알고리즘 변경(MD5 -> SHA-256)
//md = MessageDigest.getInstance("MD5");
md = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException nsae) {
//throw new InternalError("MD5 not supported");
throw new InternalError("SHA-256 not supported");
}
// 2011.10.10 보안점검 후속조치
if (md == null) {
throw new RuntimeException("MessageDigest is null!!");
}
// 2014.09.20 보안점검 후속 조치
// Random 방식의 salt 추가
SecureRandom ng = new SecureRandom();
byte[] randomBytes = new byte[16];
ng.nextBytes(randomBytes);
md.reset();
md.update(randomBytes);
byte[] sha = md.digest(name);
byte[] md5Bytes = new byte[8];
System.arraycopy(sha, 0, md5Bytes, 0, 8);
//2011.10.10 보안점검 후속조치 끝
md5Bytes[6] &= 0x0f; clear version
md5Bytes[6] |= 0x30; set to version 3
md5Bytes[8] &= 0x3f; clear variant
md5Bytes[8] |= 0x80; set to IETF variant
return new EgovFormBasedUUID(md5Bytes);*/
}
/**
* Creates a <tt>UUID</tt> from the string standard representation as
* described in the {@link #toString} method.
*
* @param name
* a string that specifies a <tt>UUID</tt>.
* @return a <tt>UUID</tt> with the specified value.
* @throws IllegalArgumentException
* if name does not conform to the string representation as
* described in {@link #toString}.
*/
public static EgovFormBasedUUID fromString(String name) {
String[] components = name.split("-");
if (components.length != 5)
throw new IllegalArgumentException("Invalid UUID string: " + name);
for (int i = 0; i < 5; i++)
components[i] = "0x" + components[i];
long mostSigBits = Long.decode(components[0]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[1]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[2]).longValue();
long leastSigBits = Long.decode(components[3]).longValue();
leastSigBits <<= 48;
leastSigBits |= Long.decode(components[4]).longValue();
return new EgovFormBasedUUID(mostSigBits, leastSigBits);
}
// Field Accessor Methods
/**
* Returns the least significant 64 bits of this UUID's 128 bit value.
*
* @return the least significant 64 bits of this UUID's 128 bit value.
*/
public long getLeastSignificantBits() {
return leastSigBits;
}
/**
* Returns the most significant 64 bits of this UUID's 128 bit value.
*
* @return the most significant 64 bits of this UUID's 128 bit value.
*/
public long getMostSignificantBits() {
return mostSigBits;
}
/**
* The version number associated with this <tt>UUID</tt>. The version
* number describes how this <tt>UUID</tt> was generated.
*
* The version number has the following meaning:
* <p>
* <ul>
* <li>1 Time-based UUID
* <li>2 DCE security UUID
* <li>3 Name-based UUID
* <li>4 Randomly generated UUID
* </ul>
*
* @return the version number of this <tt>UUID</tt>.
*/
public int version() {
if (version < 0) {
// Version is bits masked by 0x000000000000F000 in MS long
version = (int) ((mostSigBits >> 12) & 0x0f);
}
return version;
}
/**
* The variant number associated with this <tt>UUID</tt>. The variant
* number describes the layout of the <tt>UUID</tt>.
*
* The variant number has the following meaning:
* <p>
* <ul>
* <li>0 Reserved for NCS backward compatibility
* <li>2 The Leach-Salz variant (used by this class)
* <li>6 Reserved, Microsoft Corporation backward compatibility
* <li>7 Reserved for future definition
* </ul>
*
* @return the variant number of this <tt>UUID</tt>.
*/
public int variant() {
if (variant < 0) {
// This field is composed of a varying number of bits
if ((leastSigBits >>> 63) == 0) {
variant = 0;
} else if ((leastSigBits >>> 62) == 2) {
variant = 2;
} else {
variant = (int) (leastSigBits >>> 61);
}
}
return variant;
}
/**
* The timestamp value associated with this UUID.
*
* <p>
* The 60 bit timestamp value is constructed from the time_low, time_mid,
* and time_hi fields of this <tt>UUID</tt>. The resulting timestamp is
* measured in 100-nanosecond units since midnight, October 15, 1582 UTC.
* <p>
*
* The timestamp value is only meaningful in a time-based UUID, which has
* version type 1. If this <tt>UUID</tt> is not a time-based UUID then
* this method throws UnsupportedOperationException.
*
* @throws UnsupportedOperationException
* if this UUID is not a version 1 UUID.
*/
public long timestamp() {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
long result = timestamp;
if (result < 0) {
result = (mostSigBits & 0x0000000000000FFFL) << 48;
result |= ((mostSigBits >> 16) & 0xFFFFL) << 32;
result |= mostSigBits >>> 32;
timestamp = result;
}
return result;
}
/**
* The clock sequence value associated with this UUID.
*
* <p>
* The 14 bit clock sequence value is constructed from the clock sequence
* field of this UUID. The clock sequence field is used to guarantee
* temporal uniqueness in a time-based UUID.
* <p>
*
* The clockSequence value is only meaningful in a time-based UUID, which
* has version type 1. If this UUID is not a time-based UUID then this
* method throws UnsupportedOperationException.
*
* @return the clock sequence of this <tt>UUID</tt>.
* @throws UnsupportedOperationException
* if this UUID is not a version 1 UUID.
*/
public int clockSequence() {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
if (sequence < 0) {
sequence = (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
}
return sequence;
}
/**
* The node value associated with this UUID.
*
* <p>
* The 48 bit node value is constructed from the node field of this UUID.
* This field is intended to hold the IEEE 802 address of the machine that
* generated this UUID to guarantee spatial uniqueness.
* <p>
*
* The node value is only meaningful in a time-based UUID, which has version
* type 1. If this UUID is not a time-based UUID then this method throws
* UnsupportedOperationException.
*
* @return the node value of this <tt>UUID</tt>.
* @throws UnsupportedOperationException
* if this UUID is not a version 1 UUID.
*/
public long node() {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
if (node < 0) {
node = leastSigBits & 0x0000FFFFFFFFFFFFL;
}
return node;
}
// Object Inherited Methods
/**
* Returns a <code>String</code> object representing this
* <code>UUID</code>.
*
* <p>
* The UUID string representation is as described by this BNF :
*
* <pre>
* UUID = &lt;time_low&gt; &quot;-&quot; &lt;time_mid&gt; &quot;-&quot;
* &lt;time_high_and_version&gt; &quot;-&quot;
* &lt;variant_and_sequence&gt; &quot;-&quot;
* &lt;node&gt;
* time_low = 4*&lt;hexOctet&gt;
* time_mid = 2*&lt;hexOctet&gt;
* time_high_and_version = 2*&lt;hexOctet&gt;
* variant_and_sequence = 2*&lt;hexOctet&gt;
* node = 6*&lt;hexOctet&gt;
* hexOctet = &lt;hexDigit&gt;&lt;hexDigit&gt;
* hexDigit =
* &quot;0&quot; | &quot;1&quot; | &quot;2&quot; | &quot;3&quot; | &quot;4&quot; | &quot;5&quot; | &quot;6&quot; | &quot;7&quot; | &quot;8&quot; | &quot;9&quot;
* | &quot;a&quot; | &quot;b&quot; | &quot;c&quot; | &quot;d&quot; | &quot;e&quot; | &quot;f&quot;
* | &quot;A&quot; | &quot;B&quot; | &quot;C&quot; | &quot;D&quot; | &quot;E&quot; | &quot;F&quot;
* </pre>
*
* @return a string representation of this <tt>UUID</tt>.
*/
@Override
public String toString() {
return (digits(mostSigBits >> 32, 8) + "-"
+ digits(mostSigBits >> 16, 4) + "-" + digits(mostSigBits, 4)
+ "-" + digits(leastSigBits >> 48, 4) + "-" + digits(
leastSigBits, 12));
}
/** Returns val represented by the specified number of hex digits. */
private static String digits(long val, int digits) {
long hi = 1L << (digits * 4);
return Long.toHexString(hi | (val & (hi - 1))).substring(1);
}
/**
* Returns a hash code for this <code>UUID</code>.
*
* @return a hash code value for this <tt>UUID</tt>.
*/
@Override
public int hashCode() {
if (hashCode == -1) {
hashCode = (int) ((mostSigBits >> 32) ^ mostSigBits
^ (leastSigBits >> 32) ^ leastSigBits);
}
return hashCode;
}
/**
* Compares this object to the specified object. The result is <tt>true</tt>
* if and only if the argument is not <tt>null</tt>, is a <tt>UUID</tt>
* object, has the same variant, and contains the same value, bit for bit,
* as this <tt>UUID</tt>.
*
* @param obj
* the object to compare with.
* @return <code>true</code> if the objects are the same;
* <code>false</code> otherwise.
*/
@Override
public boolean equals(Object obj) {
// 보안 취약점 점검 지적사항 반영 시작
if (obj == null)
return false;
// 보안 취약점 점검 지적사항 반영 시작 끝
if (!(obj instanceof EgovFormBasedUUID))
return false;
if (((EgovFormBasedUUID) obj).variant() != this.variant())
return false;
EgovFormBasedUUID id = (EgovFormBasedUUID) obj;
return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits);
}
// Comparison Operations
/**
* Compares this UUID with the specified UUID.
*
* <p>
* The first of two UUIDs follows the second if the most significant field
* in which the UUIDs differ is greater for the first UUID.
*
* @param val
* <tt>UUID</tt> to which this <tt>UUID</tt> is to be
* compared.
* @return -1, 0 or 1 as this <tt>UUID</tt> is less than, equal to, or
* greater than <tt>val</tt>.
*/
public int compareTo(EgovFormBasedUUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
return (this.mostSigBits < val.mostSigBits ? -1
: (this.mostSigBits > val.mostSigBits ? 1
: (this.leastSigBits < val.leastSigBits ? -1
: (this.leastSigBits > val.leastSigBits ? 1 : 0))));
}
/**
* Reconstitute the <tt>UUID</tt> instance from a stream (that is,
* deserialize it). This is necessary to set the transient fields to their
* correct uninitialized value so they will be recomputed on demand.
*/
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException, ClassNotFoundException {
in.defaultReadObject();
// Set "cached computation" fields to their initial values
version = -1;
variant = -1;
timestamp = -1;
sequence = -1;
node = -1;
hashCode = -1;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright 2008-2009 MOPAS(Ministry of Public Administration and Security).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kcg.faics.cmmn.egov.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
public class HTMLTagFilter implements Filter{
@SuppressWarnings("unused")
private FilterConfig config;
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// 2016 12 21 뿌릴때 안되서 막음.
// chain.doFilter(new HTMLTagFilterRequestWrapper((HttpServletRequest)request), response);
chain.doFilter(request, response);
}
public void init(FilterConfig config) throws ServletException {
this.config = config;
}
public void destroy() {
}
}

View File

@ -0,0 +1,109 @@
/*
* Copyright 2008-2009 MOPAS(Ministry of Public Administration and Security).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kcg.faics.cmmn.egov.filter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
public class HTMLTagFilterRequestWrapper extends HttpServletRequestWrapper {
public HTMLTagFilterRequestWrapper(HttpServletRequest request) {
super(request);
}
public String[] getParameterValues(String parameter) {
String[] values = super.getParameterValues(parameter);
if(values==null){
return null;
}
for (int i = 0; i < values.length; i++) {
if (values[i] != null) {
StringBuffer strBuff = new StringBuffer();
for (int j = 0; j < values[i].length(); j++) {
char c = values[i].charAt(j);
switch (c) {
case '<':
strBuff.append("&lt;");
break;
case '>':
strBuff.append("&gt;");
break;
//case '&':
//strBuff.append("&amp;");
//break;
case '"':
strBuff.append("&quot;");
break;
case '\'':
strBuff.append("&apos;");
break;
default:
strBuff.append(c);
break;
}
}
values[i] = strBuff.toString();
} else {
values[i] = null;
}
}
return values;
}
public String getParameter(String parameter) {
String value = super.getParameter(parameter);
if(value==null){
return null;
}
StringBuffer strBuff = new StringBuffer();
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
switch (c) {
case '<':
strBuff.append("&lt;");
break;
case '>':
strBuff.append("&gt;");
break;
case '&':
strBuff.append("&amp;");
break;
case '"':
strBuff.append("&quot;");
break;
case '\'':
strBuff.append("&apos;");
break;
default:
strBuff.append(c);
break;
}
}
value = strBuff.toString();
return value;
}
}

View File

@ -0,0 +1,36 @@
package kcg.faics.cmmn.egov.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class RequestBodyXSSFilter implements Filter {
@Override
public void destroy() {}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest)request;
HttpServletResponse res = (HttpServletResponse)response;
// RequestWrapper requestWrapper = null;
try{
// requestWrapper = new RequestWrapper(req);
}catch(Exception e){
e.printStackTrace();
}
chain.doFilter(req, res);
}
}

View File

@ -0,0 +1,895 @@
/**
* @Class Name : EgovStringUtil.java
* @Description :
* @Modification Information
*
*
* ------- -------- ---------------------------
* 2009.01.13
* 2009.02.13
*
* @author
* @since 2009. 01. 13
* @version 1.0
* @see
*
*/
package kcg.faics.cmmn.egov.util;
/*
* Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the ";License&quot;);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS"; BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.security.SecureRandom;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EgovStringUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(EgovStringUtil.class);
/**
* <code>""</code>.
*/
public static final String EMPTY = "";
/**
* <p>Padding </p>
*/
// private static final int PAD_LIMIT = 8192;
/**
* <p>An array of <code>String</code>s used for padding.</p>
* <p>Used for efficient space padding. The length of each String expands as needed.</p>
*/
/*
private static final String[] PADDING = new String[Character.MAX_VALUE];
static {
// space padding is most common, start with 64 chars
PADDING[32] = " ";
}
*/
/**
* .
* @param source
* @param output
* @param slength
* @return
*/
public static String cutString(String source, String output, int slength) {
String returnVal = null;
if (source != null) {
if (source.length() > slength) {
returnVal = source.substring(0, slength) + output;
} else
returnVal = source;
}
return returnVal;
}
/**
*
* @param source
* @param slength
* @return
*/
public static String cutString(String source, int slength) {
String result = null;
if (source != null) {
if (source.length() > slength) {
result = source.substring(0, slength);
} else
result = source;
}
return result;
}
/**
* <p>
* String ("") null .
* </p>
*
* <pre>
* StringUtil.isEmpty(null) = true
* StringUtil.isEmpty("") = true
* StringUtil.isEmpty(" ") = false
* StringUtil.isEmpty("bob") = false
* StringUtil.isEmpty(" bob ") = false
* </pre>
*
* @param str - null
* @return <code>true</code> - String null
*/
public static boolean isEmpty(String str) {
return str == null || str.length() == 0;
}
/**
* <p> (char) .</p>
*
* <pre>
* StringUtil.remove(null, *) = null
* StringUtil.remove("", *) = ""
* StringUtil.remove("queued", 'u') = "qeed"
* StringUtil.remove("queued", 'z') = "queued"
* </pre>
*
* @param str
* @param remove
* @return . null null
*/
public static String remove(String str, char remove) {
if (isEmpty(str) || str.indexOf(remove) == -1) {
return str;
}
char[] chars = str.toCharArray();
int pos = 0;
for (int i = 0; i < chars.length; i++) {
if (chars[i] != remove) {
chars[pos++] = chars[i];
}
}
return new String(chars, 0, pos);
}
/**
* <p> character(,) .</p>
*
* <pre>
* StringUtil.removeCommaChar(null) = null
* StringUtil.removeCommaChar("") = ""
* StringUtil.removeCommaChar("asdfg,qweqe") = "asdfgqweqe"
* </pre>
*
* @param str
* @return " , "
* null null
*/
public static String removeCommaChar(String str) {
return remove(str, ',');
}
/**
* <p> character(-) .</p>
*
* <pre>
* StringUtil.removeMinusChar(null) = null
* StringUtil.removeMinusChar("") = ""
* StringUtil.removeMinusChar("a-sdfg-qweqe") = "asdfgqweqe"
* </pre>
*
* @param str
* @return " - "
* null null
*/
public static String removeMinusChar(String str) {
return remove(str, '-');
}
/**
*
* @param source
* @param subject
* @param object
* @return sb.toString()
*/
public static String replace(String source, String subject, String object) {
StringBuffer rtnStr = new StringBuffer();
String preStr = "";
String nextStr = source;
String srcStr = source;
while (srcStr.indexOf(subject) >= 0) {
preStr = srcStr.substring(0, srcStr.indexOf(subject));
nextStr = srcStr.substring(srcStr.indexOf(subject) + subject.length(), srcStr.length());
srcStr = nextStr;
rtnStr.append(preStr).append(object);
}
rtnStr.append(nextStr);
return rtnStr.toString();
}
/**
*
* @param source
* @param subject
* @param object
* @return sb.toString() / source
*/
public static String replaceOnce(String source, String subject, String object) {
StringBuffer rtnStr = new StringBuffer();
String preStr = "";
String nextStr = source;
if (source.indexOf(subject) >= 0) {
preStr = source.substring(0, source.indexOf(subject));
nextStr = source.substring(source.indexOf(subject) + subject.length(), source.length());
rtnStr.append(preStr).append(object).append(nextStr);
return rtnStr.toString();
} else {
return source;
}
}
/**
* <code>subject</code> object .
*
* @param source
* @param subject
* @param object
* @return sb.toString()
*/
public static String replaceChar(String source, String subject, String object) {
StringBuffer rtnStr = new StringBuffer();
String preStr = "";
String nextStr = source;
String srcStr = source;
char chA;
for (int i = 0; i < subject.length(); i++) {
chA = subject.charAt(i);
if (srcStr.indexOf(chA) >= 0) {
preStr = srcStr.substring(0, srcStr.indexOf(chA));
nextStr = srcStr.substring(srcStr.indexOf(chA) + 1, srcStr.length());
srcStr = rtnStr.append(preStr).append(object).append(nextStr).toString();
}
}
return srcStr;
}
/**
* <p><code>str</code> <code>searchStr</code> (index) .</p>
*
* <p> <code>null</code> <code>-1</code> .</p>
*
* <pre>
* StringUtil.indexOf(null, *) = -1
* StringUtil.indexOf(*, null) = -1
* StringUtil.indexOf("", "") = 0
* StringUtil.indexOf("aabaabaa", "a") = 0
* StringUtil.indexOf("aabaabaa", "b") = 2
* StringUtil.indexOf("aabaabaa", "ab") = 1
* StringUtil.indexOf("aabaabaa", "") = 0
* </pre>
*
* @param str
* @param searchStr
* @return null -1
*/
public static int indexOf(String str, String searchStr) {
if (str == null || searchStr == null) {
return -1;
}
return str.indexOf(searchStr);
}
/**
* <p> decode .
* <code>sourStr</code> <code>compareStr</code>
* <code>returStr</code> , <code>defaultStr</code> .
* </p>
*
* <pre>
* StringUtil.decode(null, null, "foo", "bar")= "foo"
* StringUtil.decode("", null, "foo", "bar") = "bar"
* StringUtil.decode(null, "", "foo", "bar") = "bar"
* StringUtil.decode("하이", "하이", null, "bar") = null
* StringUtil.decode("하이", "하이 ", "foo", null) = null
* StringUtil.decode("하이", "하이", "foo", "bar") = "foo"
* StringUtil.decode("하이", "하이 ", "foo", "bar") = "bar"
* </pre>
*
* @param sourceStr
* @param compareStr
* @param returnStr sourceStr compareStr
* @param defaultStr sourceStr compareStr
* @return sourceStr compareStr (equal) returnStr ,
* <br/> defaultStr .
*/
public static String decode(String sourceStr, String compareStr, String returnStr, String defaultStr) {
if (sourceStr == null && compareStr == null) {
return returnStr;
}
if (sourceStr == null && compareStr != null) {
return defaultStr;
}
if (sourceStr != null && sourceStr.trim().equals(compareStr)) {
return returnStr;
}
return defaultStr;
}
/**
* <p> decode .
* <code>sourStr</code> <code>compareStr</code>
* <code>returStr</code> , <code>sourceStr</code> .
* </p>
*
* <pre>
* StringUtil.decode(null, null, "foo") = "foo"
* StringUtil.decode("", null, "foo") = ""
* StringUtil.decode(null, "", "foo") = null
* StringUtil.decode("하이", "하이", "foo") = "foo"
* StringUtil.decode("하이", "하이 ", "foo") = "하이"
* StringUtil.decode("하이", "바이", "foo") = "하이"
* </pre>
*
* @param sourceStr
* @param compareStr
* @param returnStr sourceStr compareStr
* @return sourceStr compareStr (equal) returnStr ,
* <br/> sourceStr .
*/
public static String decode(String sourceStr, String compareStr, String returnStr) {
return decode(sourceStr, compareStr, returnStr, sourceStr);
}
/**
* null null ""
* @param object
* @return resultVal
*/
public static String isNullToString(Object object) {
String string = "";
if (object != null) {
string = object.toString().trim();
}
return string;
}
/**
*<pre>
* String null &quot;&quot; .
* &#064;param src null String .
* &#064;return String null &quot;&quot; String .
*</pre>
*/
public static String nullConvert(Object src) {
//if (src != null && src.getClass().getName().equals("java.math.BigDecimal")) {
if (src != null && src instanceof java.math.BigDecimal) {
return ((BigDecimal) src).toString();
}
if (src == null || src.equals("null")) {
return "";
} else {
return ((String) src).trim();
}
}
/**
*<pre>
* String null &quot;&quot; .
* &#064;param src null String .
* &#064;return String null &quot;&quot; String .
*</pre>
*/
public static String nullConvert(String src) {
if (src == null || src.equals("null") || "".equals(src) || " ".equals(src)) {
return "";
} else {
return src.trim();
}
}
/**
*<pre>
* String null &quot;0&quot; .
* &#064;param src null String .
* &#064;return String null &quot;0&quot; String .
*</pre>
*/
public static int zeroConvert(Object src) {
if (src == null || src.equals("null")) {
return 0;
} else {
return Integer.parseInt(((String) src).trim());
}
}
/**
*<pre>
* String null &quot;&quot; .
* &#064;param src null String .
* &#064;return String null &quot;&quot; String .
*</pre>
*/
public static int zeroConvert(String src) {
if (src == null || src.equals("null") || "".equals(src) || " ".equals(src)) {
return 0;
} else {
return Integer.parseInt(src.trim());
}
}
/**
* <p> {@link Character#isWhitespace(char)}
* .</p>
*
* <pre>
* StringUtil.removeWhitespace(null) = null
* StringUtil.removeWhitespace("") = ""
* StringUtil.removeWhitespace("abc") = "abc"
* StringUtil.removeWhitespace(" ab c ") = "abc"
* </pre>
*
* @param str
* @return the , null <code>null</code>
*/
public static String removeWhitespace(String str) {
if (isEmpty(str)) {
return str;
}
int sz = str.length();
char[] chs = new char[sz];
int count = 0;
for (int i = 0; i < sz; i++) {
if (!Character.isWhitespace(str.charAt(i))) {
chs[count++] = str.charAt(i);
}
}
if (count == sz) {
return str;
}
return new String(chs, 0, count);
}
/**
* Html
*
* @param strString
* @return HTML
*/
public static String checkHtmlView(String strString) {
String strNew = "";
StringBuffer strTxt = new StringBuffer("");
char chrBuff;
int len = strString.length();
for (int i = 0; i < len; i++) {
chrBuff = (char) strString.charAt(i);
switch (chrBuff) {
case '<':
strTxt.append("&lt;");
break;
case '>':
strTxt.append("&gt;");
break;
case '"':
strTxt.append("&quot;");
break;
case 10:
strTxt.append("<br>");
break;
case ' ':
strTxt.append("&nbsp;");
break;
//case '&' :
//strTxt.append("&amp;");
//break;
default:
strTxt.append(chrBuff);
}
}
strNew = strTxt.toString();
return strNew;
}
/**
* .
* @param source
* @param separator
* @return result
*/
public static String[] split(String source, String separator) throws NullPointerException {
String[] returnVal = null;
int cnt = 1;
int index = source.indexOf(separator);
int index0 = 0;
while (index >= 0) {
cnt++;
index = source.indexOf(separator, index + 1);
}
returnVal = new String[cnt];
cnt = 0;
index = source.indexOf(separator);
while (index >= 0) {
returnVal[cnt] = source.substring(index0, index);
index0 = index + 1;
index = source.indexOf(separator, index + 1);
cnt++;
}
returnVal[cnt] = source.substring(index0);
return returnVal;
}
/**
* <p>{@link String#toLowerCase()} .</p>
*
* <pre>
* StringUtil.lowerCase(null) = null
* StringUtil.lowerCase("") = ""
* StringUtil.lowerCase("aBc") = "abc"
* </pre>
*
* @param str
* @return , null <code>null</code>
*/
public static String lowerCase(String str) {
if (str == null) {
return null;
}
return str.toLowerCase();
}
/**
* <p>{@link String#toUpperCase()} .</p>
*
* <pre>
* StringUtil.upperCase(null) = null
* StringUtil.upperCase("") = ""
* StringUtil.upperCase("aBc") = "ABC"
* </pre>
*
* @param str
* @return , null <code>null</code>
*/
public static String upperCase(String str) {
if (str == null) {
return null;
}
return str.toUpperCase();
}
/**
* <p> String (stripChars) .</p>
*
* <pre>
* StringUtil.stripStart(null, *) = null
* StringUtil.stripStart("", *) = ""
* StringUtil.stripStart("abc", "") = "abc"
* StringUtil.stripStart("abc", null) = "abc"
* StringUtil.stripStart(" abc", null) = "abc"
* StringUtil.stripStart("abc ", null) = "abc "
* StringUtil.stripStart(" abc ", null) = "abc "
* StringUtil.stripStart("yxabc ", "xyz") = "abc "
* </pre>
*
* @param str
* @param stripChars
* @return , null <code>null</code>
*/
public static String stripStart(String str, String stripChars) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
return str;
}
int start = 0;
if (stripChars == null) {
while ((start != strLen) && Character.isWhitespace(str.charAt(start))) {
start++;
}
} else if (stripChars.length() == 0) {
return str;
} else {
while ((start != strLen) && (stripChars.indexOf(str.charAt(start)) != -1)) {
start++;
}
}
return str.substring(start);
}
/**
* <p> String (stripChars) .</p>
*
* <pre>
* StringUtil.stripEnd(null, *) = null
* StringUtil.stripEnd("", *) = ""
* StringUtil.stripEnd("abc", "") = "abc"
* StringUtil.stripEnd("abc", null) = "abc"
* StringUtil.stripEnd(" abc", null) = " abc"
* StringUtil.stripEnd("abc ", null) = "abc"
* StringUtil.stripEnd(" abc ", null) = " abc"
* StringUtil.stripEnd(" abcyx", "xyz") = " abc"
* </pre>
*
* @param str
* @param stripChars
* @return , null <code>null</code>
*/
public static String stripEnd(String str, String stripChars) {
int end;
if (str == null || (end = str.length()) == 0) {
return str;
}
if (stripChars == null) {
while ((end != 0) && Character.isWhitespace(str.charAt(end - 1))) {
end--;
}
} else if (stripChars.length() == 0) {
return str;
} else {
while ((end != 0) && (stripChars.indexOf(str.charAt(end - 1)) != -1)) {
end--;
}
}
return str.substring(0, end);
}
/**
* <p> String , (stripChars) .</p>
*
* <pre>
* StringUtil.strip(null, *) = null
* StringUtil.strip("", *) = ""
* StringUtil.strip("abc", null) = "abc"
* StringUtil.strip(" abc", null) = "abc"
* StringUtil.strip("abc ", null) = "abc"
* StringUtil.strip(" abc ", null) = "abc"
* StringUtil.strip(" abcyx", "xyz") = " abc"
* </pre>
*
* @param str
* @param stripChars
* @return , null <code>null</code>
*/
public static String strip(String str, String stripChars) {
if (isEmpty(str)) {
return str;
}
String srcStr = str;
srcStr = stripStart(srcStr, stripChars);
return stripEnd(srcStr, stripChars);
}
/**
* .
* @param source
* @param separator
* @param arraylength
* @return
*/
public static String[] split(String source, String separator, int arraylength) throws NullPointerException {
String[] returnVal = new String[arraylength];
int cnt = 0;
int index0 = 0;
int index = source.indexOf(separator);
while (index >= 0 && cnt < (arraylength - 1)) {
returnVal[cnt] = source.substring(index0, index);
index0 = index + 1;
index = source.indexOf(separator, index + 1);
cnt++;
}
returnVal[cnt] = source.substring(index0);
if (cnt < (arraylength - 1)) {
for (int i = cnt + 1; i < arraylength; i++) {
returnVal[i] = "";
}
}
return returnVal;
}
/**
* A Z
*
* @param startChr
* -
* @param endChr
* -
* @return
* @exception MyException
* @see
*/
public static String getRandomStr(char startChr, char endChr) {
int randomInt;
String randomStr = null;
// 시작문자 및 종료문자를 아스키숫자로 변환한다.
int startInt = Integer.valueOf(startChr);
int endInt = Integer.valueOf(endChr);
// 시작문자열이 종료문자열보가 클경우
if (startInt > endInt) {
throw new IllegalArgumentException("Start String: " + startChr + " End String: " + endChr);
}
// 랜덤 객체 생성
SecureRandom rnd = new SecureRandom();
do {
// 시작문자 및 종료문자 중에서 랜덤 숫자를 발생시킨다.
randomInt = rnd.nextInt(endInt + 1);
} while (randomInt < startInt); // 입력받은 문자 'A'(65)보다 작으면 다시 랜덤 숫자 발생.
// 랜덤 숫자를 문자로 변환 후 스트링으로 다시 변환
randomStr = (char) randomInt + "";
// 랜덤문자열를 리턴
return randomStr;
}
/**
* (EUC-KR[KSC5601],UTF-8..)
* String temp = new String(.getBytes("바꾸기전 인코딩"),"바꿀 인코딩");
* String temp = new String(.getBytes("8859_1"),"KSC5601"); => UTF-8
* EUC-KR
*
* @param srcString
* -
* @param srcCharsetNm
* - CharsetNm
* @param charsetNm
* - CharsetNm
* @return ()
* @exception MyException
* @see
*/
public static String getEncdDcd(String srcString, String srcCharsetNm, String cnvrCharsetNm) {
String rtnStr = null;
if (srcString == null)
return null;
try {
rtnStr = new String(srcString.getBytes(srcCharsetNm), cnvrCharsetNm);
} catch (UnsupportedEncodingException e) {
rtnStr = null;
}
return rtnStr;
}
/**
* ('<' -> & lT)
* @param srcString - '<'
* @return ('<' -> "&lt"
* @exception MyException
* @see
*/
public static String getSpclStrCnvr(String srcString) {
String rtnStr = null;
try {
StringBuffer strTxt = new StringBuffer("");
char chrBuff;
int len = srcString.length();
for (int i = 0; i < len; i++) {
chrBuff = (char) srcString.charAt(i);
switch (chrBuff) {
case '<':
strTxt.append("&lt;");
break;
case '>':
strTxt.append("&gt;");
break;
case '&':
strTxt.append("&amp;");
break;
default:
strTxt.append(chrBuff);
}
}
rtnStr = strTxt.toString();
} catch (Exception e) {
LOGGER.debug("{}", e);
}
return rtnStr;
}
/**
* 17TIMESTAMP
*
* @param
* @return Timestamp
* @exception MyException
* @see
*/
public static String getTimeStamp() {
String rtnStr = null;
// 문자열로 변환하기 위한 패턴 설정(년도-월-일 시:분:초:초(자정이후 초))
String pattern = "yyyyMMddhhmmssSSS";
SimpleDateFormat sdfCurrent = new SimpleDateFormat(pattern, Locale.KOREA);
Timestamp ts = new Timestamp(System.currentTimeMillis());
rtnStr = sdfCurrent.format(ts.getTime());
return rtnStr;
}
/**
* html
*
* @param srcString
* @return String
* @exception Exception
* @see
*/
public static String getHtmlStrCnvr(String srcString) {
String tmpString = srcString;
tmpString = tmpString.replaceAll("&lt;", "<");
tmpString = tmpString.replaceAll("&gt;", ">");
tmpString = tmpString.replaceAll("&amp;", "&");
tmpString = tmpString.replaceAll("&nbsp;", " ");
tmpString = tmpString.replaceAll("&apos;", "\'");
tmpString = tmpString.replaceAll("&quot;", "\"");
return tmpString;
}
/**
* <p> character(-) .</p>
*
* <pre>
* StringUtil.addMinusChar("20100901") = "2010-09-01"
* </pre>
*
* @param date
* @return " - "
*/
public static String addMinusChar(String date) {
if (date.length() == 8)
return date.substring(0, 4).concat("-").concat(date.substring(4, 6)).concat("-").concat(date.substring(6, 8));
else
return "";
}
}

View File

@ -0,0 +1,111 @@
package kcg.faics.cmmn.egov.util;
import java.util.regex.Pattern;
/**
* ( )
*
* <pre>
* << (Modification Information) >>
*
*
* ------- -------- ---------------------------
* 2011.10.10
*
* </pre>
*/
public class EgovWebUtil {
public static String clearXSSMinimum(String value) {
if (value == null || value.trim().equals("")) {
return "";
}
String returnValue = value;
returnValue = returnValue.replaceAll("&", "&amp;");
returnValue = returnValue.replaceAll("<", "&lt;");
returnValue = returnValue.replaceAll(">", "&gt;");
returnValue = returnValue.replaceAll("\"", "&#34;");
returnValue = returnValue.replaceAll("\'", "&#39;");
returnValue = returnValue.replaceAll("[.]", "&#46;");
returnValue = returnValue.replaceAll("%2E", "&#46;");
returnValue = returnValue.replaceAll("%2F", "&#47;");
return returnValue;
}
public static String clearXSSMaximum(String value) {
String returnValue = value;
returnValue = clearXSSMinimum(returnValue);
returnValue = returnValue.replaceAll("%00", null);
returnValue = returnValue.replaceAll("%", "&#37;");
// \\. => .
returnValue = returnValue.replaceAll("\\.\\./", ""); // ../
returnValue = returnValue.replaceAll("\\.\\.\\\\", ""); // ..\
returnValue = returnValue.replaceAll("\\./", ""); // ./
returnValue = returnValue.replaceAll("%2F", "");
return returnValue;
}
public static String filePathBlackList(String value) {
String returnValue = value;
if (returnValue == null || returnValue.trim().equals("")) {
return "";
}
returnValue = returnValue.replaceAll("\\.\\./", ""); // ../
returnValue = returnValue.replaceAll("\\.\\.\\\\", ""); // ..\
returnValue = returnValue.replaceAll("\\.\\.", ""); // ..
return returnValue;
}
/**
* .
*
* @param value
* @return
*/
public static String filePathReplaceAll(String value) {
String returnValue = value;
if (returnValue == null || returnValue.trim().equals("")) {
return "";
}
returnValue = returnValue.replaceAll("/", "");
// Findbugs 수정 : replaceAll은 첫 번째 인자값을 정규식으로 취급하기때문에 역슬래쉬 1개를 표현하기 위해 4개를 입력해야 한다.
returnValue = returnValue.replaceAll("\\\\", "");
returnValue = returnValue.replaceAll("\\.\\.", ""); // ..
returnValue = returnValue.replaceAll("&", "");
return returnValue;
}
public static String filePathWhiteList(String value) {
return value;
}
public static boolean isIPAddress(String str) {
Pattern ipPattern = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
return ipPattern.matcher(str).matches();
}
public static String removeCRLF(String parameter) {
return parameter.replaceAll("\r", "").replaceAll("\n", "");
}
public static String removeSQLInjectionRisk(String parameter) {
return parameter.replaceAll("\\p{Space}", "").replaceAll("\\*", "").replaceAll("%", "").replaceAll(";", "").replaceAll("-", "").replaceAll("\\+", "").replaceAll(",", "");
}
public static String removeOSCmdRisk(String parameter) {
return parameter.replaceAll("\\p{Space}", "").replaceAll("\\*", "").replaceAll("[|]", "").replaceAll(";", "");
}
}

View File

@ -0,0 +1,242 @@
package kcg.faics.cmmn.egov.vo;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* @Class Name : FileVO.java
* @Description : VO
* @Modification Information
*
* ------- ------- ------------------- 2009. 3. 25.
*
*
* @author
* @since 2009. 3. 25.
* @version
* @see
*
*/
public class FileVO implements Serializable {
/**
* serialVersion UID
*/
private static final long serialVersionUID = -287950405903719128L;
/**
*
*/
public String atchFileId = "";
/**
*
*/
public String creatDt = "";
/**
*
*/
public String fileCn = "";
/**
*
*/
public String fileExtsn = "";
/**
*
*/
public String fileMg = "";
/**
*
*/
public String fileSn = "";
/**
*
*/
public String fileStreCours = "";
/**
*
*/
public String orignlFileNm = "";
/**
*
*/
public String streFileNm = "";
/**
* atchFileId attribute .
*
* @return the atchFileId
*/
public String getAtchFileId() {
return atchFileId;
}
/**
* atchFileId attribute .
*
* @param atchFileId
* the atchFileId to set
*/
public void setAtchFileId(String atchFileId) {
this.atchFileId = atchFileId;
}
/**
* creatDt attribute .
*
* @return the creatDt
*/
public String getCreatDt() {
return creatDt;
}
/**
* creatDt attribute .
*
* @param creatDt
* the creatDt to set
*/
public void setCreatDt(String creatDt) {
this.creatDt = creatDt;
}
/**
* fileCn attribute .
*
* @return the fileCn
*/
public String getFileCn() {
return fileCn;
}
/**
* fileCn attribute .
*
* @param fileCn
* the fileCn to set
*/
public void setFileCn(String fileCn) {
this.fileCn = fileCn;
}
/**
* fileExtsn attribute .
*
* @return the fileExtsn
*/
public String getFileExtsn() {
return fileExtsn;
}
/**
* fileExtsn attribute .
*
* @param fileExtsn
* the fileExtsn to set
*/
public void setFileExtsn(String fileExtsn) {
this.fileExtsn = fileExtsn;
}
/**
* fileMg attribute .
*
* @return the fileMg
*/
public String getFileMg() {
return fileMg;
}
/**
* fileMg attribute .
*
* @param fileMg
* the fileMg to set
*/
public void setFileMg(String fileMg) {
this.fileMg = fileMg;
}
/**
* fileSn attribute .
*
* @return the fileSn
*/
public String getFileSn() {
return fileSn;
}
/**
* fileSn attribute .
*
* @param fileSn
* the fileSn to set
*/
public void setFileSn(String fileSn) {
this.fileSn = fileSn;
}
/**
* fileStreCours attribute .
*
* @return the fileStreCours
*/
public String getFileStreCours() {
return fileStreCours;
}
/**
* fileStreCours attribute .
*
* @param fileStreCours
* the fileStreCours to set
*/
public void setFileStreCours(String fileStreCours) {
this.fileStreCours = fileStreCours;
}
/**
* orignlFileNm attribute .
*
* @return the orignlFileNm
*/
public String getOrignlFileNm() {
return orignlFileNm;
}
/**
* orignlFileNm attribute .
*
* @param orignlFileNm
* the orignlFileNm to set
*/
public void setOrignlFileNm(String orignlFileNm) {
this.orignlFileNm = orignlFileNm;
}
/**
* streFileNm attribute .
*
* @return the streFileNm
*/
public String getStreFileNm() {
return streFileNm;
}
/**
* streFileNm attribute .
*
* @param streFileNm
* the streFileNm to set
*/
public void setStreFileNm(String streFileNm) {
this.streFileNm = streFileNm;
}
/**
* toString .
*/
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}

View File

@ -0,0 +1,67 @@
/**
* AbstractExcelGenerator.java
* @author
* @since 2016. 10. 14.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 14.
*
*/
package kcg.faics.cmmn.excel;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* AbstractExcelGenerator.java
* @author
* @since 2016. 10. 14.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 14.
*
*/
public abstract class AbstractExcelExport implements ExcelExport {
/* 기본적으로 3번 라인이 시작라인 */
protected int firstRow = 2;
protected String template = null;
/* 파라미터 맵 */
protected Map<String, Object> document = null;
/**
* .
*
* @param document
* @return Workbook
*/
public abstract XSSFWorkbook makeExcel(XSSFWorkbook wb);
/**
* .
*
* @param
*/
protected void setTitleRow(XSSFSheet sheet, XSSFCellStyle style, String title) {
XSSFRow row = sheet.createRow(0);
XSSFCell cell = row.createCell(0);
cell.setCellValue(title);
if (style != null) {
}
cell.setCellStyle(style);
}
}

View File

@ -0,0 +1,27 @@
/**
* ExcelExport.java
* @author
* @since 2016. 10. 17.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 17.
*
*/
package kcg.faics.cmmn.excel;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* ExcelExport.java
* @author
* @since 2016. 10. 17.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 17.
*
*/
public interface ExcelExport {
public abstract XSSFWorkbook makeExcel(XSSFWorkbook wb);
}

View File

@ -0,0 +1,132 @@
package kcg.faics.cmmn.excel;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* .
*
* @author kimnomin
*
* @param <T> VO
*/
public class ExcelExporter<T> extends AbstractExcelExport {
/**
* .
* < VO , >
* ex) {title: }
*
* .
*
* !! !! key VO .
*/
private LinkedHashMap<String, String> headers;
/**
* VO List.
*/
private List<T> list;
/**
* .
*/
private String title;
/**
* .
*
* @param headers .
* @param list VO List.
* @param title .
*/
public ExcelExporter(final LinkedHashMap<String, String> headers, final List<T> list,
final String title) {
super();
this.headers = headers;
this.list = list;
this.title = title;
}
@Override
public XSSFWorkbook makeExcel(final XSSFWorkbook wb) {
if (list.size() <= 0 || headers.size() <= 0) {
return null;
}
XSSFSheet sheet = null;
XSSFRow row = null;
XSSFCell cell = null;
ExcelStyle style = new ExcelStyle(wb);
sheet = wb.createSheet(title);
setTitleRow(sheet, style.titleStyle, title);
Set<String> keySet = headers.keySet();
// 헤더
int loopIdx = 0;
row = sheet.createRow(firstRow);
cell = row.createCell(loopIdx);
cell.setCellValue("번호");
cell.setCellStyle(style.headerStyle);
loopIdx++;
for (String key : keySet) {
cell = row.createCell(loopIdx);
cell.setCellValue(headers.get(key));
cell.setCellStyle(style.headerStyle);
loopIdx++;
}
// 값
for (int i = 0; i < list.size(); i++) {
T t = list.get(i);
row = sheet.createRow(firstRow + 1 + i);
loopIdx = 0;
cell = row.createCell(loopIdx);
cell.setCellValue(i + 1);
cell.setCellStyle(style.normalTextStyle);
loopIdx++;
for (String key : keySet) {
String value = "";
try {
if (t instanceof Map<?, ?>) {
Object o = ((Map<?, ?>) t).get(key);
if (o instanceof String) {
value = o.toString();
} else if (o instanceof Integer || o instanceof Double) {
value = String.valueOf(o);
} else if (o instanceof BigDecimal) {
value = ((BigDecimal) o).toString();
}
} else {
Field f = t.getClass().getDeclaredField(key);
f.setAccessible(true);
Object val = f.get(t);
if (val != null) {
value = val.toString();
}
}
} catch (Exception e) {
e.printStackTrace();
}
cell = row.createCell(loopIdx);
cell.setCellValue(value);
cell.setCellStyle(style.normalTextStyle);
loopIdx++;
}
}
return wb;
}
}

View File

@ -0,0 +1,128 @@
package kcg.faics.cmmn.excel;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* ExcelStyle.java
* @author
* @since 2016. 10. 14.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 14.
*
*/
public class ExcelStyle {
private XSSFFont normalFont;
private XSSFFont boldFont;
private XSSFFont titleFont;
private XSSFColor yellowColor = new XSSFColor(new java.awt.Color(255, 255, 238));
private XSSFColor grayColor = new XSSFColor(new java.awt.Color(238, 238, 238));
private XSSFColor cyanColor = new XSSFColor(new java.awt.Color(238, 255, 255));
private DataFormat numericFormat;
public XSSFCellStyle titleStyle;
public XSSFCellStyle headerStyle;
public XSSFCellStyle firstRowTextStyle;
public XSSFCellStyle firstRowNumericStyle;
public XSSFCellStyle normalTextStyle;
public XSSFCellStyle normalLeftBoldTextStyle;
public XSSFCellStyle normalNumericStyle;
public ExcelStyle(XSSFWorkbook wb) {
defindeStyle(wb);
}
private void defindeStyle(XSSFWorkbook wb) {
numericFormat = wb.createDataFormat();
titleStyle = (XSSFCellStyle) wb.createCellStyle();
headerStyle = (XSSFCellStyle) wb.createCellStyle();
firstRowTextStyle = (XSSFCellStyle) wb.createCellStyle();
firstRowNumericStyle = (XSSFCellStyle) wb.createCellStyle();
normalTextStyle = (XSSFCellStyle) wb.createCellStyle();
normalLeftBoldTextStyle = (XSSFCellStyle) wb.createCellStyle();
normalNumericStyle = (XSSFCellStyle) wb.createCellStyle();
normalFont = (XSSFFont) wb.createFont();
normalFont.setFontName("돋음");
normalFont.setFontHeightInPoints((short) 9);
normalFont.setBoldweight(Font.BOLDWEIGHT_NORMAL);
boldFont = (XSSFFont) wb.createFont();
boldFont.setFontName("돋음");
boldFont.setFontHeightInPoints((short) 9);
boldFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
titleFont = (XSSFFont) wb.createFont();
titleFont.setFontName("돋음");
titleFont.setFontHeightInPoints((short) 12);
titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
titleStyle.setFont(titleFont);
titleStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
headerStyle.setAlignment(CellStyle.ALIGN_CENTER);
headerStyle.setFont(boldFont);
headerStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
headerStyle.setBorderTop(BorderStyle.HAIR);
headerStyle.setBorderLeft(BorderStyle.HAIR);
headerStyle.setBorderRight(BorderStyle.HAIR);
headerStyle.setBorderBottom(BorderStyle.HAIR);
headerStyle.setFillForegroundColor(grayColor);
headerStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
firstRowTextStyle.setAlignment(CellStyle.ALIGN_CENTER);
firstRowTextStyle.setFont(normalFont);
firstRowTextStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
firstRowTextStyle.setBorderTop(BorderStyle.HAIR);
firstRowTextStyle.setBorderLeft(BorderStyle.HAIR);
firstRowTextStyle.setBorderRight(BorderStyle.HAIR);
firstRowTextStyle.setBorderBottom(BorderStyle.HAIR);
firstRowTextStyle.setFillForegroundColor(yellowColor);
firstRowTextStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
firstRowNumericStyle.setAlignment(CellStyle.ALIGN_CENTER);
firstRowNumericStyle.setFont(normalFont);
firstRowNumericStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
firstRowNumericStyle.setBorderTop(BorderStyle.HAIR);
firstRowNumericStyle.setBorderLeft(BorderStyle.HAIR);
firstRowNumericStyle.setBorderRight(BorderStyle.HAIR);
firstRowNumericStyle.setBorderBottom(BorderStyle.HAIR);
firstRowNumericStyle.setFillForegroundColor(yellowColor);
firstRowNumericStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
firstRowNumericStyle.setDataFormat(numericFormat.getFormat("#,###"));
normalTextStyle.setAlignment(CellStyle.ALIGN_CENTER);
normalTextStyle.setFont(normalFont);
normalTextStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
normalTextStyle.setBorderTop(BorderStyle.HAIR);
normalTextStyle.setBorderLeft(BorderStyle.HAIR);
normalTextStyle.setBorderRight(BorderStyle.HAIR);
normalTextStyle.setBorderBottom(BorderStyle.HAIR);
normalNumericStyle.setAlignment(CellStyle.ALIGN_CENTER);
normalNumericStyle.setFont(normalFont);
normalNumericStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
normalNumericStyle.setBorderTop(BorderStyle.HAIR);
normalNumericStyle.setBorderLeft(BorderStyle.HAIR);
normalNumericStyle.setBorderRight(BorderStyle.HAIR);
normalNumericStyle.setBorderBottom(BorderStyle.HAIR);
normalNumericStyle.setDataFormat(numericFormat.getFormat("#,###"));
}
}

View File

@ -0,0 +1,70 @@
/**
* ExcelView.java
* @author
* @since 2016. 10. 14.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 14.
*
*/
package kcg.faics.cmmn.excel;
import java.net.URLEncoder;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import egovframework.rte.fdl.excel.util.AbstractPOIExcelView;
/**
* ExcelView.java
* @author
* @since 2016. 10. 14.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 14.
*
*/
public class ExcelView extends AbstractPOIExcelView {
/**
* .
*
* @param model Model
* @param model Model
* @param model Model
* @param model Model
*/
@Override
protected void buildExcelDocument(Map<String, Object> model, XSSFWorkbook wb, HttpServletRequest req, HttpServletResponse res) throws Exception {
if(model.get("filename") != null){
String userAgent = req.getHeader("User-Agent");
String fileName = (String)model.get("filename");
if(userAgent.indexOf("MSIE") > -1){
fileName = URLEncoder.encode(fileName, "utf-8");
}else{
fileName = new String(fileName.getBytes("utf-8"), "iso-8859-1");
}
model.put("filename", fileName);
}
ExcelExport export = (ExcelExport) model.get("excel");
try {
export.makeExcel(wb);
} catch (Exception e) {
e.printStackTrace();
XSSFSheet sheet = wb.createSheet("sheet1");
XSSFCell cell = getCell(sheet, 0, 0);
setText(cell, "Error");
}
}
}

View File

@ -0,0 +1,8 @@
/**
* Export .
*/
/**
* @author kimnomin
*
*/
package kcg.faics.cmmn.excel;

View File

@ -0,0 +1,123 @@
package kcg.faics.cmmn.file;
import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import javax.activation.MimetypesFileTypeMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* .
*
* @author kimnomin
*
*/
public final class FileResponser {
/**
* .
*/
private FileResponser() {
}
/**
* .
*
* @param request
* HttpServletRequest
* @return
*/
private static String getBrowser(final HttpServletRequest request) {
String header = request.getHeader("User-Agent");
if (header.indexOf("MSIE") > -1) {
return "MSIE";
} else if (header.indexOf("Trident") > -1) { // IE11 문자열 깨짐 방지
return "Trident";
} else if (header.indexOf("Chrome") > -1) {
return "Chrome";
} else if (header.indexOf("Opera") > -1) {
return "Opera";
}
return "Firefox";
}
/**
* Disposition .
*
* @param filename
*
* @param request
* HttpServletRequest
* @param response
* HttpServletResponse
* @throws Exception
*
*/
private static void setDisposition(final String filename,
final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
String browser = getBrowser(request);
String dispositionPrefix = "inline; filename=";
String encodedFilename = null;
if (browser.equals("MSIE")) {
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
} else if (browser.equals("Trident")) { // IE11 문자열 깨짐 방지
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
} else if (browser.equals("Firefox")) {
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
} else if (browser.equals("Opera")) {
encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\"";
} else if (browser.equals("Chrome")) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < filename.length(); i++) {
char c = filename.charAt(i);
if (c > '~') {
sb.append(URLEncoder.encode("" + c, "UTF-8"));
} else {
sb.append(c);
}
}
encodedFilename = sb.toString();
} else {
// throw new RuntimeException("Not supported browser");
throw new IOException("Not supported browser");
}
response.setHeader("Content-Disposition", dispositionPrefix + encodedFilename);
if ("Opera".equals(browser)) {
response.setContentType("application/octet-stream;charset=UTF-8");
}
}
/**
* Response .
*
* @param file
* @param fileOrgName
* @param request HttpServletRequest
* @param response HttpServletResponse
*/
public static void setResponse(final File file,
final String fileOrgName,
final HttpServletRequest request, final HttpServletResponse response) {
if (file == null || request == null || response == null) {
return;
}
MimetypesFileTypeMap mimeUtil = new MimetypesFileTypeMap();
String mimeType = mimeUtil.getContentType(fileOrgName);
response.setContentType(mimeType);
response.setContentLength((int) file.length());
try {
setDisposition(fileOrgName, request, response);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,135 @@
/**
* FileUploadUtil.java
* @author
* @since 2016. 10. 28.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 28.
*
*/
package kcg.faics.cmmn.file;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.annotation.Resource;
import kcg.faics.cmmn.egov.EgovResourceCloseHelper;
import kcg.faics.cmmn.egov.file.EgovFileMngUtil;
import kcg.faics.cmmn.egov.util.EgovStringUtil;
import kcg.faics.cmmn.egov.util.EgovWebUtil;
import org.apache.commons.io.FilenameUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import egovframework.rte.fdl.property.EgovPropertyService;
/**
* FileUploadUtil.java
* @author
* @since 2016. 10. 28.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 28.
*
*/
@Component("fileUploadUtil")
public class FileUploadUtil extends EgovFileMngUtil {
/**
* .
*/
@Resource(name = "propertiesService")
protected EgovPropertyService propertyService;
/** Buffer size */
public static final int BUFFER_SIZE = 8192;
/**
* .
*/
public static final String SEPERATOR = File.separator;
/**
* MultipartFile .
*
* @param mFile
*
* @param path
* Global Property
* @return
* @throws Exception
*
*/
public String uploadWithExt(final MultipartFile mFile, final String path) throws Exception {
String storePathString = "";
if ("".equals(path) || path == null) {
storePathString = propertyService.getString("Globals.fileStorePath");
} else {
storePathString = propertyService.getString(path);
}
String tmp = mFile.getOriginalFilename();
if (tmp.lastIndexOf("\\") >= 0) {
tmp = tmp.substring(tmp.lastIndexOf("\\") + 1);
}
//String ext = "." + tmp.substring(tmp.lastIndexOf(".") + 1, tmp.length()).toLowerCase();
String ext = FilenameUtils.getExtension(tmp);
String saveName = EgovStringUtil.getTimeStamp() + "." + ext;
saveName = super.makeNewFileName(storePathString, saveName);
//saveName = saveName.substring(0, saveName.length() - 3) + ext;
if (mFile.getSize() > 0) {
InputStream is = null;
try {
is = mFile.getInputStream();
saveFile(is, new File(EgovWebUtil.filePathBlackList(storePathString + saveName)));
} finally {
if (is != null) {
is.close();
}
}
}
return saveName;
}
/**
* Stream .
* @param is InputStream
* @param file File
* @throws IOException
*/
private long saveFile(final InputStream is, final File file) throws IOException {
// 디렉토리 생성
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
OutputStream os = null;
long size = 0L;
try {
os = new FileOutputStream(file);
int bytesRead = 0;
byte[] buffer = new byte[BUFFER_SIZE];
while ((bytesRead = is.read(buffer, 0, BUFFER_SIZE)) != -1) {
size += bytesRead;
os.write(buffer, 0, bytesRead);
}
} finally {
EgovResourceCloseHelper.close(os);
}
return size;
}
}

View File

@ -0,0 +1,8 @@
/**
* Package.
*/
/**
* @author kimnomin
*
*/
package kcg.faics.cmmn.file;

View File

@ -0,0 +1,29 @@
/**
*
*/
package kcg.faics.cmmn.json;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
/**
* CustomObjectMapper.java
* @author
* @since 2016. 9. 29.
*
*
* ------------- -------- ---------------------------
* 2016. 9. 29.
*
*/
public class CustomObjectMapper extends ObjectMapper {
private static final long serialVersionUID = 1L;
public CustomObjectMapper() {
DefaultSerializerProvider.Impl sp = new DefaultSerializerProvider.Impl();
sp.setNullValueSerializer(new NullSerializer());
this.setSerializerProvider(sp);
}
}

View File

@ -0,0 +1,29 @@
/**
*
*/
package kcg.faics.cmmn.json;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
/**
* NullSerializer.java
* @author
* @since 2016. 9. 29.
*
*
* ------------- -------- ---------------------------
* 2016. 9. 29.
*
*/
public class NullSerializer extends JsonSerializer<Object> {
@Override
public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
jsonGenerator.writeString("");
}
}

View File

@ -0,0 +1,369 @@
/**
* CommonService.java
* @author
* @since 2016. 10. 13.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 13.
*
*/
package kcg.faics.cmmn.service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import kcg.faics.cmmn.vo.CodeVO;
/**
* Service Interface.
*
* @author kimnomin
*
*/
public interface CodeService {
/**
* .
*/
String LIST_ALL_VAL = "ALL";
/**
* .
*/
String LIST_ALL_STR = "전체";
/**
* .
*/
String CODE1_AUTH = "AUTH";
/**
* .
*/
String CODE1_PLACE1 = "C001";
/**
* .
*/
String CODE1_POSITION = "C002";
/**
* .
*/
String CODE1_COPR = "CORP";
/**
* .
*/
String CODE1_EDU_COURSE = "EDUC";
/**
* .
*/
String CODE1_EDU_PLACE = "EDUP";
/**
* .
*/
Map<String, String[]> PLACE_CATEGORY = new TreeMap<String, String[]>(String.CASE_INSENSITIVE_ORDER) {
/**
* serialVersionUID.
*/
private static final long serialVersionUID = -8213220033671425747L;
{
//중부본부
put("ps90", new String[] { "PS14", "PS16", "PS05", "PS02", "PS50" });
//제주본부
put("PS91", new String[] { "PS13", "PS17" });
//서해본부
put("PS92", new String[] { "PS06", "PS07", "PS08", "PS09", "ps18" });
//남해본부
put("PS93", new String[] { "PS01", "PS11", "PS15", "PS12" });
//동해본부
//20171226 울진해양경찰서 추가(PS19)
put("PS94", new String[] { "PS03", "PS04", "PS10", "PS19" });
put("PS95", new String[] {});
put("PS96", new String[] {});
put("PS97", new String[] {});
put("PS99", new String[] {});
}
};
/**
* - .
*/
HashMap<String, String> CORP_GROUP = new HashMap<String, String>() {
/**
* serialVersionUID.
*/
private static final long serialVersionUID = -4741380958901687806L;
{
put("01", "업무협조기관");
put("02", "해운.항만관련 협회");
put("03", "외사관련업체");
put("04", "외국인고용업체");
put("05", "외국인투자업체");
}
};
/**
* .
*
* <pre>
* PHP
* PS98 -> PS17 .
*
* 20170330 5 (PS50)
* 20171226 (PS19)
* </pre>
*/
String[] POLICE_STATION_LIST = { "PS01", "PS02", "PS03", "PS04", "PS05", "PS06",
"PS07", "PS08", "PS09", "PS10", "PS11", "PS12", "PS13", "PS14", "PS16", "PS17", "ps18", "PS19", "PS50" };
/**
* .
*
* @param code1
*
* @param code2
*
* @return
* @throws Exception
*
*/
CodeVO getCodeValue(String code1, String code2) throws Exception;
/**
* .
*
* @param code1
*
* @param code2
*
* @return CodeVO
* @throws Exception
*
*/
List<CodeVO> getCodeValues(String code1, String code2) throws Exception;
/**
* 1 Detph .
*
* @param onlyCentral
* - true, - false
* @return 1
* @throws Exception
*
*/
List<CodeVO> getPlace1List(boolean onlyCentral) throws Exception;
/**
* 1 Detph .
*
* @param onlyCentral
* - true, - false
* @param includeAll
* "전체"
* @return 1
* @throws Exception
*
*/
List<CodeVO> getPlace1List(boolean onlyCentral, boolean includeAll) throws Exception;
/**
* codes .
*
* @param codes CODE
* @return
* @throws Exception
*
*/
List<CodeVO> getPlace1List(String[] codes) throws Exception;
/**
* codes .
*
* @param codes CODE
* @param includeAll "전체"
* @return
* @throws Exception
*
*/
List<CodeVO> getPlace1List(String[] codes, boolean includeAll) throws Exception;
/**
* 1 Depth code1 . get_agency_list
*
* @param place1Code
* 1 Depth Code
* @return
* @throws Exception
*
*/
List<CodeVO> getPlace1SubList(String place1Code) throws Exception;
/**
* 1 1 Depth code1 .
*
* @param place1Code
* 1 Depth Code
* @return
* @throws Exception
*
*/
List<CodeVO> getPlace1SubListWithMain(String place1Code) throws Exception;
/**
* 1 Depth code1 . get_agency_code
*
* @param place1Code
* 1 Depth Code
* @return
* @throws Exception
*
*/
String getPlace1HighCode(String place1Code) throws Exception;
/**
* .
*
* @param placeCode
* @return
* @throws Exception
*
*/
String getPlace1Str(final String placeCode) throws Exception;
/**
* .
*
* @param place1Code
* @param place2Code
* @return
* @throws Exception
*/
String getPlace2Str(final String place1Code, String place2Code) throws Exception;
/**
* .
*
* @param positionCode
* @return
* @throws Exception
*/
String getPositionStr(final String positionCode) throws Exception;
/**
* .
* @return
* @throws Exception
*
*/
List<CodeVO> getPositionList() throws Exception;
/**
* .
* @param codeVO
* @return
* @throws Exception
*
*/
List<CodeVO> getPlace2List(CodeVO codeVO) throws Exception;
/**
* .
* @param codeVO
* @return
* @throws Exception
*
*/
List<CodeVO> getPlace3List(CodeVO codeVO) throws Exception;
/**
* .
* @return
* @throws Exception
*
*/
List<CodeVO> getDutiesList() throws Exception;
/**
* .
* @return
* @throws Exception
*
*/
List<CodeVO> getJobTypeList() throws Exception;
/**
* .
* @return
* @throws Exception
*
*/
List<CodeVO> getScholarshipList() throws Exception;
/**
* / .
*
* @return /
* @throws Exception
*
*/
List<CodeVO> getCorpOrgList() throws Exception;
/**
* .
*
* @param includeAll
* "전체"
* @return
* @throws Exception
*
*/
List<CodeVO> getEduCourse(final boolean includeAll) throws Exception;
/**
* .
*
* @param includeAll
* "전체"
* @return
* @throws Exception
*
*/
List<CodeVO> getEduPlace(final boolean includeAll) throws Exception;
/**
* .
*
* @return
* @throws Exception
*
*/
List<CodeVO> getAuthList() throws Exception;
/**
* code .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
int updateCode(final CodeVO codeVO) throws Exception;
/**
* code .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
int insertCode(final CodeVO codeVO) throws Exception;
/**
* code .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
int deleteCode(final CodeVO codeVO) throws Exception;
}

View File

@ -0,0 +1,50 @@
package kcg.faics.cmmn.service;
import java.util.HashMap;
import java.util.List;
import kcg.faics.admin.vo.LogSearchVO;
import kcg.faics.admin.vo.LogVO;
/**
* LogService.java
* @author
* @since 2016. 11. 10.
*
*
* ------------- -------- ---------------------------
* 2016. 11. 10.
*
*/
public interface LogService {
List<LogVO> getUserLogList(LogSearchVO searchVO) throws Exception;
/**
* .
*
* @param paramMap
* @return - 1, - 0
* @throws Exception
*/
int insertUserLog(HashMap<String, Object> paramMap) throws Exception;
/**
* .
*
* @param searchVO ,
* @return
* @exception Exception
*/
int selectListCnt(LogSearchVO searchVO) throws Exception;
/**
* .
* @param searchVO
*
* @return
* @throws Exception
*/
int selectTotalCnt(LogSearchVO searchVO) throws Exception;
}

View File

@ -0,0 +1,61 @@
package kcg.faics.cmmn.service;
import java.util.HashMap;
import java.util.List;
import kcg.faics.cmmn.MenuPosition;
import kcg.faics.cmmn.vo.MenuVO;
/**
* .
*
* @author kimnomin
*
*/
public interface MenuService {
/**
* .
*
* @param menuVO
* VO
* @return
*/
List<MenuVO> selectListWithHigher(MenuVO menuVO);
/**
* .
*
* @param menuVO
* VO
* @return
*/
List<MenuVO> selectMainMenuList(MenuVO menuVO);
/**
* .
*
* @param menuVO
* VO
* @return
*/
List<MenuVO> selectTopSubMenuList(MenuVO menuVO);
/**
* .
*
* @param menu
*
* @return
*/
HashMap<String, Object> getMenuInfo(HashMap<String, Object> menu);
/**
* .
*
* @param menu
*
* @return
*/
List<HashMap<String, Object>> getSubmenu(HashMap<String, Object> menu);
}

View File

@ -0,0 +1,229 @@
/**
* CommonMapper.java
* @author
* @since 2016. 10. 13.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 13.
*
*/
package kcg.faics.cmmn.service.impl;
import java.util.HashMap;
import java.util.List;
import kcg.faics.cmmn.vo.CodeVO;
import org.springframework.stereotype.Repository;
import egovframework.rte.psl.dataaccess.EgovAbstractMapper;
/**
* Mapper.
*
* @author kimnomin
*
*/
@Repository("codeMapper")
public class CodeMapper extends EgovAbstractMapper {
/**
* .
*
* @param code1
*
* @param code2
*
* @return CodeVO
* @throws Exception
*
*/
public List<CodeVO> getCodeValues(final String code1, final String code2)
throws Exception {
CodeVO codeVO = new CodeVO();
codeVO.setCode1(code1);
codeVO.setCode2(code2);
return selectList("Code.getCodeValues", codeVO);
}
/**
* 1 Detph .
*
* @param onlyCentral
* - true, - false
* @return 1
* @throws Exception
*/
public List<CodeVO> getPlace1List(final boolean onlyCentral) throws Exception {
return selectList("Code.getPlace1List", onlyCentral);
}
/**
* .
* @return
* @throws Exception
*/
public List<CodeVO> getPositionList() throws Exception {
return selectList("Code.getPositionList");
};
/**
* .
* @param codeVO
* @return
* @throws Exception
*/
public List<CodeVO> getPlace2List(CodeVO codeVO) throws Exception {
return selectList("Code.getPlace2List", codeVO);
};
/**
* .
* @param codeVO
* @return
* @throws Exception
*/
public List<CodeVO> getPlace3List(CodeVO codeVO) throws Exception {
return selectList("Code.getPlace3List", codeVO);
};
/**
* .
* @return
* @throws Exception
*/
public List<CodeVO> getDutiesList() throws Exception {
return selectList("Code.getDutiesList");
};
/**
* .
* @return
* @throws Exception
*/
public List<CodeVO> getJobTypeList() throws Exception {
return selectList("Code.getJobTypeList");
};
/**
* .
* @return
* @throws Exception
*/
public List<CodeVO> getScholarshipList() throws Exception {
return selectList("Code.getScholarshipList");
};
/**
* .
*
* @param code
* @param
* @return
*/
public String getPlace1NameByCode(String code, boolean yak) {
CodeVO codeVO = selectOne("Code.getPlace1NameByCode", code);
return (yak) ? codeVO.getCodenmYak() : codeVO.getCodenm();
}
/**
* .
*
* @param place1
* @param place2
* @return
*/
public String getPlace2NameByCode(String code1, String code2) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("code1", code1);
map.put("code2", code2);
return selectOne("Code.getPlace2NameByCode", map);
}
/**
* .
*
* @param place1
* @param place2
* @return
*/
public String getPlace3NameByCode(String code2) {
return selectOne("Code.getPlace3NameByCode", code2);
}
/**
* .
*
* @param code
* @return
*/
public String getPositionNameByCode(String code) {
return selectOne("Code.getPositionNameByCode", code);
}
/**
* .
*
* @param code
* @return
*/
public String getDutiesNameByCode(String code) {
return selectOne("Code.getDutiesNameByCode", code);
}
/**
* .
*
* @param code
* @return
*/
public String getJobtypeNameByCode(String code) {
return selectOne("Code.getJobtypeNameByCode", code);
}
/**
* .
*
* @param code
* @return
*/
public String getScholarshipNameByCode(String code) {
return selectOne("Code.getScholarshipNameByCode", code);
}
/**
* code .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
public int updateCode(final CodeVO codeVO) throws Exception {
return update("Code.updateCode", codeVO);
}
/**
* code .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
public int insertCode(final CodeVO codeVO) throws Exception {
return insert("Code.insertCode", codeVO);
}
/**
* code .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
public int deleteCode(CodeVO codeVO) {
return delete("Code.deleteCode", codeVO);
}
}

View File

@ -0,0 +1,380 @@
/**
* CommonService.java
* @author
* @since 2016. 10. 13.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 13.
*
*/
package kcg.faics.cmmn.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import kcg.faics.cmmn.service.CodeService;
import kcg.faics.cmmn.vo.CodeVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* .
*
* @author kimnomin
*
*/
@Service("codeService")
public class CodeServiceImpl implements CodeService {
/**
* CodeMapper.
*/
@Resource(name = "codeMapper")
private CodeMapper codeMapper;
/**
* List "전체" .
*
* @param list List
* @return "전체" List
*/
private List<CodeVO> addAll(final List<CodeVO> list) {
if (list != null) {
CodeVO allVO = new CodeVO();
allVO.setCode1(LIST_ALL_VAL);
allVO.setCode2(LIST_ALL_VAL);
allVO.setCodenm(LIST_ALL_STR);
allVO.setCodenmYak(LIST_ALL_STR);
list.add(0, allVO);
}
return list;
}
@Override
public CodeVO getCodeValue(final String code1, final String code2) throws Exception {
CodeVO codeVO;
List<CodeVO> codes = getCodeValues(code1, code2);
if (codes.size() <= 0) {
codeVO = null;
} else {
codeVO = codes.get(0);
}
return codeVO;
}
@Override
public List<CodeVO> getCodeValues(final String code1, final String code2) throws Exception {
List<CodeVO> codeVOList = new ArrayList<CodeVO>();
try {
codeVOList = codeMapper.getCodeValues(code1, code2);
} catch (Exception e) {
e.printStackTrace();
codeVOList = null;
}
return codeVOList;
}
@Override
public List<CodeVO> getPlace1List(final boolean onlyCentral) throws Exception {
List<CodeVO> codeVOList = new ArrayList<CodeVO>();
try {
codeVOList = codeMapper.getPlace1List(onlyCentral);
} catch (Exception e) {
e.printStackTrace();
codeVOList = null;
}
return codeVOList;
}
@Override
public List<CodeVO> getPlace1List(final boolean onlyCentral, final boolean includeAll)
throws Exception {
List<CodeVO> codeVOList = getPlace1List(onlyCentral);
if (includeAll) {
codeVOList = addAll(codeVOList);
}
return codeVOList;
}
@Override
public List<CodeVO> getPlace1List(final String[] codes) {
List<CodeVO> codeVOList = new ArrayList<CodeVO>();
List<String> policeStationList = Arrays.asList(CodeService.POLICE_STATION_LIST);
boolean isContains = false;
try {
codeVOList = codeMapper.getPlace1List(false);
for (Iterator<CodeVO> it = codeVOList.iterator(); it.hasNext(); ) {
isContains = false;
CodeVO vo = it.next();
for (String item : policeStationList) {
if (item.equalsIgnoreCase(vo.getCode2())) {
isContains = true;
break;
}
}
if (!isContains) {
it.remove();
}
}
} catch (Exception e) {
e.printStackTrace();
codeVOList = null;
}
return codeVOList;
}
@Override
public List<CodeVO> getPlace1List(final String[] codes, final boolean includeAll)
throws Exception {
List<CodeVO> codeVOList = getPlace1List(codes);
if (includeAll) {
codeVOList = addAll(codeVOList);
}
return codeVOList;
}
@Override
public List<CodeVO> getPlace1SubList(final String place1Code) throws Exception {
CodeVO code = new CodeVO();
List<CodeVO> codes = new ArrayList<CodeVO>();
try {
String[] subCodes = PLACE_CATEGORY.get(place1Code);
if (subCodes != null) {
for (int i = 0; i < subCodes.length; i++) {
code = getCodeValue(CODE1_PLACE1, subCodes[i]);
codes.add(code);
}
}
} catch (Exception e) {
e.printStackTrace();
codes = null;
}
return codes;
}
@Override
public List<CodeVO> getPlace1SubListWithMain(final String place1Code) throws Exception {
CodeVO code = new CodeVO();
List<CodeVO> codes = new ArrayList<CodeVO>();
try {
String[] subCodes = PLACE_CATEGORY.get(place1Code);
if (subCodes != null) {
code = getCodeValue(CODE1_PLACE1, place1Code);
codes.add(code);
// 하위 기관
for (int i = 0; i < subCodes.length; i++) {
code = getCodeValue(CODE1_PLACE1, subCodes[i]);
codes.add(code);
}
}
} catch (Exception e) {
e.printStackTrace();
codes = null;
}
return codes;
}
@Override
public String getPlace1HighCode(final String place1Code) throws Exception {
for (Map.Entry<String, String[]> entry : PLACE_CATEGORY.entrySet()) {
String key = entry.getKey();
String[] values = entry.getValue();
for (String item : values) {
if (item.equalsIgnoreCase(place1Code)) {
return key;
}
}
}
return place1Code;
}
@Override
public String getPlace1Str(final String placeCode) throws Exception {
String retVal = "";
if (StringUtils.isBlank(placeCode)) {
retVal = "";
} else {
CodeVO codeVO = getCodeValue(CODE1_PLACE1, placeCode);
retVal = codeVO.getCodenm();
}
return retVal;
}
@Override
public String getPlace2Str(final String place1Code, final String place2Code)
throws Exception {
String retVal = "";
if (StringUtils.isBlank(place1Code) || StringUtils.isBlank(place2Code)) {
retVal = "";
} else {
CodeVO codeVO = getCodeValue(place1Code, place2Code);
retVal = codeVO.getCodenm();
}
return retVal;
}
@Override
public String getPositionStr(final String positionCode) throws Exception {
String retVal = "";
if (StringUtils.isBlank(positionCode)) {
retVal = "";
} else {
CodeVO codeVO = getCodeValue(CODE1_POSITION, positionCode);
retVal = codeVO.getCodenm();
}
return retVal;
}
/**
* .
* @return
* @throws Exception
*/
@Override
public List<CodeVO> getPositionList() throws Exception {
return codeMapper.getPositionList();
};
/**
* .
* @param codeVO
* @return
* @throws Exception
*/
@Override
public List<CodeVO> getPlace2List(final CodeVO codeVO) throws Exception {
return codeMapper.getPlace2List(codeVO);
};
/**
* .
* @param codeVO
* @return
* @throws Exception
*/
@Override
public List<CodeVO> getPlace3List(final CodeVO codeVO) throws Exception {
return codeMapper.getPlace3List(codeVO);
};
/**
* .
* @return
* @throws Exception
*/
@Override
public List<CodeVO> getDutiesList() throws Exception {
return codeMapper.getDutiesList();
};
/**
* .
* @return
* @throws Exception
*/
@Override
public List<CodeVO> getJobTypeList() throws Exception {
return codeMapper.getJobTypeList();
};
/**
* .
* @return
* @throws Exception
*/
@Override
public List<CodeVO> getScholarshipList() throws Exception {
return codeMapper.getScholarshipList();
};
@Override
public List<CodeVO> getCorpOrgList() throws Exception {
return getCodeValues(CODE1_COPR, null);
}
@Override
public List<CodeVO> getEduCourse(final boolean includeAll) throws Exception {
List<CodeVO> list = getCodeValues(CODE1_EDU_COURSE, null);
if (includeAll) {
list = addAll(list);
}
return list;
}
@Override
public List<CodeVO> getEduPlace(final boolean includeAll) throws Exception {
List<CodeVO> list = getCodeValues(CODE1_EDU_PLACE, null);
if (includeAll) {
list = addAll(list);
}
return list;
}
@Override
public List<CodeVO> getAuthList() throws Exception {
return getCodeValues(CODE1_AUTH, null);
}
/**
* code .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
@Override
public int updateCode(final CodeVO codeVO) throws Exception {
return codeMapper.updateCode(codeVO);
}
/**
* code .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
@Override
public int insertCode(final CodeVO codeVO) throws Exception {
return codeMapper.insertCode(codeVO);
}
/**
* code .
*
* @param codeVO CodeVO
* @return - 1, - 0
* @throws Exception
*/
@Transactional
@Override
public int deleteCode(final CodeVO codeVO) throws Exception {
return codeMapper.deleteCode(codeVO);
}
}

View File

@ -0,0 +1,85 @@
package kcg.faics.cmmn.service.impl;
import java.util.HashMap;
import java.util.List;
import kcg.faics.admin.vo.LogSearchVO;
import kcg.faics.admin.vo.LogVO;
import kcg.faics.sec.LoginUserVO;
import org.springframework.stereotype.Repository;
import egovframework.rte.psl.dataaccess.EgovAbstractMapper;
/**
* LogMapper.java
* @author
* @since 2016. 11. 10.
*
*
* ------------- -------- ---------------------------
* 2016. 11. 10.
*
*/
@Repository
public class LogMapper extends EgovAbstractMapper {
public List<LogVO> selectUserLog(LogSearchVO searchVO) throws Exception {
return selectList("Log.selectUserLog", searchVO);
}
public List<LogVO> selectLoginoutLog(LogSearchVO searchVO) throws Exception {
return selectList("Log.selectLoginoutLog", searchVO);
}
public List<HashMap<String, Object>> selectUrlInfo(LogVO logVO) throws Exception {
return selectList("Log.selectUrlInfo", logVO);
}
/**
* .
*
* @param paramMap
* @return - 1, - 0
* @throws Exception
*/
public int insertUserLog(HashMap<String, Object> paramMap) {
return insert("Log.insertUserLog", paramMap);
}
/**
* .
*
* @param searchVO ,
* @return
* @exception Exception
*/
public int selectLogListTotCnt(final LogSearchVO searchVO) throws Exception {
return (Integer) selectOne("Log.selectLogListTotCnt", searchVO);
}
/**
* .
* @param searchVO
*
* @return
* @throws Exception
*/
public int selectLogTotalCnt(final LogSearchVO searchVO) throws Exception {
return (Integer) selectOne("Log.selectLogTotalCnt", searchVO);
}
/**
*
*
* @param
* @return
* @throws Exception
*/
public int insertLoginoutLog(LoginUserVO user, int type) {
HashMap<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("user", user);
paramMap.put("type", type);
return (Integer) insert("Log.insertLoginoutLog", paramMap);
}
}

View File

@ -0,0 +1,106 @@
/**
* LogServiceImpl.java
* @author
* @since 2016. 11. 10.
*
*
* ------------- -------- ---------------------------
* 2016. 11. 10.
*
*/
package kcg.faics.cmmn.service.impl;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.annotation.Resource;
import kcg.faics.admin.vo.LogSearchVO;
import kcg.faics.admin.vo.LogVO;
import kcg.faics.cmmn.service.LogService;
import org.springframework.stereotype.Service;
/**
* LogServiceImpl.java
* @author
* @since 2016. 11. 10.
*
*
* ------------- -------- ---------------------------
* 2016. 11. 10.
*
*/
@Service("logService")
public class LogServiceImpl implements LogService {
@Resource(name="logMapper")
LogMapper logMapper;
@Override
public List<LogVO> getUserLogList(LogSearchVO searchVO) throws Exception {
List<LogVO> result = null;
if (searchVO.getType() == 1) {
result = logMapper.selectLoginoutLog(searchVO);
} else {
result = logMapper.selectUserLog(searchVO);
Iterator<LogVO> it = result.iterator();
while(it.hasNext()) {
LogVO vo = it.next();
String url = "";
List<HashMap<String, Object>> maps = logMapper.selectUrlInfo(vo);
for (int i = 0; i < maps.size(); i++) {
String name = (String) maps.get(i).get("NAME");
if (name != null) {
url = url + maps.get(i).get("NAME");
if (maps.size() != i + 1) {
url = url + " > ";
}
}
}
vo.setLocation1(url);
}
}
return result;
}
/**
* .
*
* @param paramMap
* @return - 1, - 0
* @throws Exception
*/
@Override
public int insertUserLog(HashMap<String, Object> paramMap) throws Exception {
return logMapper.insertUserLog(paramMap);
}
/**
* .
*
* @param searchVO ,
* @return
* @exception Exception
*/
@Override
public int selectListCnt(LogSearchVO searchVO) throws Exception {
return logMapper.selectLogListTotCnt(searchVO);
}
/**
* .
* @param searchVO
*
* @return
* @throws Exception
*/
@Override
public int selectTotalCnt(LogSearchVO searchVO) throws Exception {
return logMapper.selectLogTotalCnt(searchVO);
}
}

View File

@ -0,0 +1,64 @@
package kcg.faics.cmmn.service.impl;
import java.util.HashMap;
import java.util.List;
import kcg.faics.cmmn.vo.MenuVO;
import org.springframework.stereotype.Repository;
import egovframework.rte.psl.dataaccess.EgovAbstractMapper;
@Repository("menuMapper")
public class MenuMapper extends EgovAbstractMapper {
/**
* .
*
* @param menuVO
* VO
* @return
*/
public List<MenuVO> selectListWithHigher(final MenuVO menuVO) {
return selectList("Menu.selectListWithHigher", menuVO);
}
/**
* .
*
* @param menuVO VO
* @return
*/
public List<MenuVO> selectListWithConnectBy(final MenuVO menuVO) {
return selectList("Menu.selectListWithConnectBy", menuVO);
}
/**
* .
*
* @return
*/
public HashMap<String, Object> getMenuInfo(final HashMap<String, Object> menu) {
return selectOne("Menu.getMenuInfo", menu);
}
/**
* .
*
* @return
*/
public List<HashMap<String, Object>> getSubmenu(final HashMap<String, Object> menu) {
return selectList("Menu.getSubmenu", menu);
}
/**
*
*
* @param
* @return
* @throws Exception
*/
public HashMap<String, Object> getMenuInfoById(final HashMap<String, Object> menu) {
return selectOne("Menu.getMenuInfoById", menu);
}
}

View File

@ -0,0 +1,121 @@
package kcg.faics.cmmn.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.annotation.Resource;
import kcg.faics.cmmn.MenuPosition;
import kcg.faics.cmmn.service.MenuService;
import kcg.faics.cmmn.vo.MenuVO;
import kcg.faics.sec.LoginUserVO;
import kcg.faics.sec.UserUtil;
import org.springframework.stereotype.Service;
@Service("menuService")
public class MenuServiceImpl implements MenuService {
/**
* MenuMapper - Mapper .
**/
@Resource(name = "menuMapper")
private MenuMapper menuMapper;
@Override
public List<MenuVO> selectListWithHigher(final MenuVO menuVO) {
return menuMapper.selectListWithHigher(menuVO);
}
@Override
public List<MenuVO> selectMainMenuList(final MenuVO menuVO) {
LoginUserVO loginUserVO = UserUtil.getMemberInfo();
menuVO.setDepth(1);
menuVO.setMenuPosition(MenuPosition.TOP);
List<MenuVO> list = menuMapper.selectListWithConnectBy(menuVO);
List<MenuVO> menuList = new ArrayList<MenuVO>();
MenuVO prevMenu = null;
for (int i = 0; i < list.size(); i++) {
MenuVO currVO = list.get(i);
if (currVO.getDepth() == 0) {
prevMenu = currVO;
menuList.add(prevMenu);
} else if (currVO.getDepth() == 1) {
// 견문 메뉴 권한
if (loginUserVO.getAuthSearch() <= 0 && "견문검색".equals(currVO.getName())) {
continue;
}
if (loginUserVO.getAuthStatistics() <= 0 && "견문통계".equals(currVO.getName())) {
continue;
}
if (loginUserVO.getAuthManage() <= 0 && !UserUtil.isAdmin() && "관리기능".equals(currVO.getName())) {
continue;
}
prevMenu.getSubMenu().add(currVO);
}
}
return menuList;
}
@Override
public List<MenuVO> selectTopSubMenuList(final MenuVO menuVO) {
menuVO.setDepth(0);
menuVO.setMenuPosition(MenuPosition.TOP_SUB);
return menuMapper.selectListWithConnectBy(menuVO);
}
/**
* .
*
* @return
*/
@Override
public HashMap<String, Object> getMenuInfo(final HashMap<String, Object> menu) {
HashMap<String, Object> paramMenu = menuMapper.getMenuInfo(menu);
int depth = ((BigDecimal) paramMenu.get("DEPTH")).intValue();
if (depth < 3) {
return paramMenu;
} else {
menu.put("id", ((BigDecimal) paramMenu.get("PARENT")).intValue());
return menuMapper.getMenuInfoById(menu);
}
}
/**
* .
*
* @return
*/
@Override
public List<HashMap<String, Object>> getSubmenu(final HashMap<String, Object> menu) {
List<HashMap<String, Object>> submenu = menuMapper.getSubmenu(menu);
List<HashMap<String, Object>> result = new ArrayList<HashMap<String, Object>>();
LoginUserVO loginUserVO = UserUtil.getMemberInfo();
// 견문인 경우 권한에 따라 설정해야함.
if (submenu.size() > 0 && "report".equals(submenu.get(0).get("URL_GROUP"))) {
for (HashMap<String, Object> map : submenu) {
if (loginUserVO.getAuthApprove() <= 0 && "/approveList.do".equals(map.get("URL"))) {
continue;
}
if ((loginUserVO.getAuthApprove() <= 0 && loginUserVO.getAuthWaitList() <= 0) && "/waitList.do".equals(map.get("URL"))) {
continue;
}
result.add(map);
}
} else {
result = submenu;
}
return result;
}
}

View File

@ -0,0 +1,8 @@
/**
* Package.
*/
/**
* @author kimnomin
*
*/
package kcg.faics.cmmn.service;

View File

@ -0,0 +1,114 @@
package kcg.faics.cmmn.vo;
/**
* . (TCODE)
*
* @author kimnomin
*/
public class CodeVO {
/**
* .
*/
private String code1;
/**
* .
*/
private String code2;
/**
* .
*/
private String codenm;
/**
* .
*/
private String codenmYak;
/**
* .
*/
private String codeUseYN;
/**
* .
* @return
*/
public String getCode1() {
return code1;
}
/**
* .
*
* @param code1
*/
public void setCode1(final String code1) {
this.code1 = code1;
}
/**
* .
*
* @return
*/
public String getCode2() {
return code2;
}
/**
* .
*
* @param code2
*/
public void setCode2(final String code2) {
this.code2 = code2;
}
/**
* .
*
* @return
*/
public String getCodenm() {
return codenm;
}
/**
* .
*
* @param codenm
*/
public void setCodenm(final String codenm) {
this.codenm = codenm;
}
/**
* .
*
* @return
*/
public final String getCodenmYak() {
return codenmYak;
}
/**
* .
*
* @param codenmYak
*/
public final void setCodenmYak(final String codenmYak) {
this.codenmYak = codenmYak;
}
/**
* .
*
* @return
*/
public final String getCodeUseYN() {
return codeUseYN;
}
/**
* .
*
* @param codeUseYN
*/
public final void setCodeUseYN(final String codeUseYN) {
this.codeUseYN = codeUseYN;
}
}

View File

@ -0,0 +1,397 @@
package kcg.faics.cmmn.vo;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
/**
* VO.
*
* @author kimnomin
*
*/
public class MenuVO {
/**
* .
*/
private int id;
/**
* .
*/
private String name;
/**
* .
*/
private String engName;
/**
* .
*/
private int parent;
/**
* .
*/
private int depth;
/**
* URL.
*/
private String url;
/**
* URI. ( )
*/
private String uri;
/**
* .
*/
private String menuPosition;
/**
* .
*/
private String visible;
/**
* .
*/
private String urlGroup;
/**
* .
*/
private String subVisible;
/**
* Role .
*/
private int roleLevel;
/**
* URL GET .
*/
private String urlQuery;
/**
* ID. ( )
*/
private String boardId;
/**
* (HTML A TARGET ).
*/
private String windowTarget;
/**
* .
*/
private List<MenuVO> subMenu = new ArrayList<MenuVO>();
/**
* ID.
*/
private String userId;
/**
* .
*/
private int userType;
/**
* @return the id
*/
public final int getId() {
return id;
}
/**
* @param id
* the id to set
*/
public final void setId(final int id) {
this.id = id;
}
/**
* @return the name
*/
public final String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public final void setName(final String name) {
this.name = name;
}
/**
* @return the engName
*/
public final String getEngName() {
return engName;
}
/**
* @param engName
* the engName to set
*/
public final void setEngName(final String engName) {
this.engName = engName;
}
/**
* @return the parent
*/
public final int getParent() {
return parent;
}
/**
* @param parent
* the parent to set
*/
public final void setParent(final int parent) {
this.parent = parent;
}
/**
* @return the depth
*/
public final int getDepth() {
return depth;
}
/**
* @param depth
* the depth to set
*/
public final void setDepth(final int depth) {
this.depth = depth;
}
/**
* @return the url
*/
public final String getUrl() {
return url;
}
/**
* @param url
* the url to set
*/
public final void setUrl(final String url) {
this.url = url;
this.makeUri();
}
/**
* @return the uri
*/
public final String getUri() {
return uri;
}
/**
* Uri .
*/
public void makeUri() {
String uri = "#";
String qry = "";
if (StringUtils.isNotBlank((this.getUrl()))) {
uri = "";
if (StringUtils.isNotBlank((this.getUrlGroup()))) {
uri += this.getUrlGroup();
}
uri += this.getUrl();
if (StringUtils.isNotBlank((this.getBoardId()))) {
qry = "?id=" + this.getBoardId();
}
if (StringUtils.isNotBlank((this.getUrlQuery()))) {
if (StringUtils.isBlank(qry)) {
qry += "?";
} else {
qry += "&";
}
qry += this.getUrlQuery();
}
if (StringUtils.isNoneBlank(uri) && !"/".equals(uri.substring(0, 1))) {
uri = "/" + uri;
}
uri += qry;
}
this.setUri(uri);
}
/**
* @param uri
* the uri to set
*/
public final void setUri(final String uri) {
this.uri = uri;
}
/**
* @return the menuPosition
*/
public final String getMenuPosition() {
return menuPosition;
}
/**
* @param menuPosition
* the menuPosition to set
*/
public final void setMenuPosition(final String menuPosition) {
this.menuPosition = menuPosition;
}
/**
* @return the visible
*/
public final String getVisible() {
return visible;
}
/**
* @param visible
* the visible to set
*/
public final void setVisible(final String visible) {
this.visible = visible;
}
/**
* @return the urlGroup
*/
public final String getUrlGroup() {
return urlGroup;
}
/**
* @param urlGroup
* the urlGroup to set
*/
public final void setUrlGroup(final String urlGroup) {
this.urlGroup = urlGroup;
this.makeUri();
}
/**
* @return the subVisible
*/
public final String getSubVisible() {
return subVisible;
}
/**
* @param subVisible
* the subVisible to set
*/
public final void setSubVisible(final String subVisible) {
this.subVisible = subVisible;
}
/**
* @return the roleLevel
*/
public final int getRoleLevel() {
return roleLevel;
}
/**
* @param roleLevel
* the roleLevel to set
*/
public final void setRoleLevel(final int roleLevel) {
this.roleLevel = roleLevel;
}
/**
* @return the windowTarget
*/
public final String getWindowTarget() {
return windowTarget;
}
/**
* @param windowTarget
* the windowTarget to set
*/
public final void setWindowTarget(final String windowTarget) {
this.windowTarget = windowTarget;
}
/**
* @return the subMenu
*/
public final List<MenuVO> getSubMenu() {
return subMenu;
}
/**
* @param subMenu
* the subMenu to set
*/
public final void setSubMenu(final List<MenuVO> subMenu) {
this.subMenu = subMenu;
}
/**
* @return the urlQuery
*/
public final String getUrlQuery() {
return urlQuery;
}
/**
* @param urlQuery
* the urlQuery to set
*/
public final void setUrlQuery(final String urlQuery) {
this.urlQuery = urlQuery;
this.makeUri();
}
/**
* @return the boardId
*/
public final String getBoardId() {
return boardId;
}
/**
* @param boardId
* the boardId to set
*/
public final void setBoardId(final String boardId) {
this.boardId = boardId;
this.makeUri();
}
/**
* @return the userId
*/
public final String getUserId() {
return userId;
}
/**
* @param userId
* the userId to set
*/
public final void setUserId(final String userId) {
this.userId = userId;
}
/**
* @return the userType
*/
public final int getUserType() {
return userType;
}
/**
* @param userType
* the userType to set
*/
public final void setUserType(final int userType) {
this.userType = userType;
}
}

View File

@ -0,0 +1,8 @@
/**
* Value Object Package.
*/
/**
* @author kimnomin
*
*/
package kcg.faics.cmmn.vo;

View File

@ -0,0 +1,68 @@
package kcg.faics.cmmn.web;
import java.util.HashMap;
import java.util.List;
import javax.annotation.Resource;
import kcg.faics.cmmn.service.CodeService;
import kcg.faics.cmmn.vo.CodeVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* .
*
* CodeController.java
* @author
* @since 2016. 10. 10.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 10.
*
*/
@Controller
@RequestMapping("/code")
public class CodeController {
/**
* .
*/
@Resource(name = "codeService")
private CodeService codeService;
/**
* .
*
* @param codeVO VO
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/place2.json")
public HashMap<String, Object> place2Json(final CodeVO codeVO) throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
result.put("data", codeService.getPlace2List(codeVO));
return result;
}
/**
* .
*
* @param codeVO VO
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/place3.json")
public HashMap<String, Object> place3Json(final CodeVO codeVO) throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
result.put("data", codeService.getPlace3List(codeVO));
return result;
}
}

View File

@ -0,0 +1,162 @@
package kcg.faics.cmmn.web;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import kcg.faics.board.service.BoardService;
import kcg.faics.board.vo.BoardSearchVO;
import kcg.faics.board.vo.BoardVO;
import kcg.faics.report.service.ReportJudgeService;
import kcg.faics.report.vo.ReportSearchVO;
import kcg.faics.report.vo.ReportVO;
import kcg.faics.sec.LoginUserVO;
import kcg.faics.sec.UserUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import egovframework.rte.fdl.security.userdetails.util.EgovUserDetailsHelper;
/**
* .
*
* CommonController.java
* @author
* @since 2016. 10. 10.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 10.
*
*/
@Controller
@SessionAttributes(types = LoginUserVO.class)
public class CommonController {
/**
* BoardService - .
**/
@Resource(name = "boardService")
private BoardService boardService;
/**
* .
*/
@Resource(name = "reportJudgeService")
private ReportJudgeService judgeService;
/**
* . , .
*
* @param request
* Request
* @param model
* Model
* @return - , -
* @throws Exception
*
*/
@RequestMapping("/loginView.do")
public String loginView(final HttpServletRequest request, final Model model) throws Exception {
if (EgovUserDetailsHelper.isAuthenticated()) {
return "redirect:/main.do";
} else {
String error = request.getParameter("error");
model.addAttribute("login_error", error);
return "common/login";
}
}
/**
* .
*
* @param request
* Request
* @param model
* Model
* @return
* @throws Exception
*
*/
@RequestMapping(value = "/main.do")
public String actionMain(final HttpServletRequest request, final Model model) throws Exception {
if (EgovUserDetailsHelper.isAuthenticated()) {
BoardSearchVO searchVO = new BoardSearchVO();
searchVO.setRecordCountPerPage(5);
/* 내실적 조회 리스트 */
LoginUserVO loginUserVO = UserUtil.getMemberInfo();
ReportSearchVO reportSearchVO = new ReportSearchVO();
reportSearchVO.setRecordCountPerPage(5);
reportSearchVO.setType(loginUserVO.getType());
reportSearchVO.setUserid(loginUserVO.getUserid());
//최근 1달치
Calendar mon = Calendar.getInstance();
mon.add(Calendar.MONTH, -1);
SimpleDateFormat stSdf = new SimpleDateFormat("yyyy-MM-dd");
String stDate = stSdf.format(mon.getTime());
Date today = new Date();
SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
String enDate = date.format(today);
reportSearchVO.setDateStart(stDate);
reportSearchVO.setDateEnd(enDate);
reportSearchVO.setOrderCol("in_seq");
reportSearchVO.setOrderAsc("DESC");
List<ReportVO> reportList = judgeService.selectMyList(reportSearchVO);
model.addAttribute("reportList", reportList);
/* 공지사항 리스트 */
searchVO.setId("notice");
List<BoardVO> noticeList = boardService.selectList(searchVO);
model.addAttribute("noticeList", noticeList);
/* 게시판 리스트 */
searchVO.setId("bbs");
List<BoardVO> bbsList = boardService.selectList(searchVO);
model.addAttribute("bbsList", bbsList);
/* 자료실 리스트 */
searchVO.setId("data");
List<BoardVO> dataList = boardService.selectList(searchVO);
model.addAttribute("dataList", dataList);
return "main.tiles";
} else {
return "common/login";
}
}
/**
* .
*
* @return
* @exception Exception
*
*/
@RequestMapping("/accessDenied.do")
public String accessDenied() throws Exception {
return "error/EgovAccessDenied";
}
/**
* validator .
*
* @return
* @exception Exception
*
*/
@RequestMapping(value = "/validator.do")
public String validator() {
return "common/validator";
}
}

View File

@ -0,0 +1,192 @@
package kcg.faics.comn.validator;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.validator.Field;
import org.apache.commons.validator.GenericValidator;
import org.apache.commons.validator.ValidatorAction;
import org.apache.commons.validator.util.ValidatorUtils;
import org.apache.oro.text.perl.Perl5Util;
import org.springframework.validation.Errors;
import org.springframework.web.multipart.MultipartFile;
import org.springmodules.validation.commons.FieldChecks;
/**
* .
*
* @author kimnomin
*
*/
public class KcgFieldChecks extends FieldChecks {
/**
* sericalVersion UID.
*/
private static final long serialVersionUID = -2911390948016164140L;
/**
* <code>Log</code> used by this class.
*/
private static final Log LOGGER = LogFactory.getLog(FieldChecks.class);
/**
* .
*
* @param bean
* The bean validation is being performed on.
* @param va
* The <code>ValidatorAction</code> that is currently being
* performed.
* @param field
* field The <code>Field</code> object associated with the
* current field being validated.
* @param errors
* Errors The <code>Errors</code> object to add errors to if any
* validation errors occur.
* @return <code>true</code> Valid. <code>false</code> inValid.
*/
public static boolean validateFileExt(final Object bean,
final ValidatorAction va, final Field field, final Errors errors) {
String value = extractValue(bean, field);
String extStr = field.getVarValue("ext");
try {
String[] validExts;
String regexp = "";
if (!GenericValidator.isBlankOrNull(extStr)) {
int loopIdx = 0;
validExts = extStr.split(",");
regexp = "\\.(";
for (String s : validExts) {
if (loopIdx > 0) {
regexp += "|";
}
regexp += s;
loopIdx++;
}
regexp += ")$";
}
Perl5Util matcher = null;
try {
matcher = new Perl5Util();
} catch (Exception e) {
e.printStackTrace();
}
if (value != null) {
boolean isValid = matcher.match("/" + regexp + "/i", value);
if (!GenericValidator.isBlankOrNull(value) && !isValid) {
FieldChecks.rejectValue(errors, field, va);
return false;
} else {
return true;
}
} else {
return true;
}
} catch (Exception e) {
e.printStackTrace();
KcgFieldChecks.LOGGER.error(e.getMessage(), e);
}
return true;
}
public static boolean validateStrRegex(final Object bean,
final ValidatorAction va, final Field field, final Errors errors) {
String value = FieldChecks.extractValue(bean, field);
String idRegex = field.getVarValue("regex");
if (!value.matches(idRegex)) {
FieldChecks.rejectValue(errors, field, va);
return false;
} else {
return true;
}
}
/**
* .
*
* <pre>
* FieldCheck.extractValue Override.
* </pre>
*
* @param bean
*
* @param field
*
* @return bean.field
*/
protected static String extractValue(final Object bean, final Field field) {
String value = null;
if (bean == null) {
return null;
} else if (bean instanceof String) {
value = (String) bean;
} else {
value = getValueAsString(bean, field.getProperty());
}
return value;
}
/**
* .
*
* <pre>
* ValidatorUtils.getValueAsString .
* </pre>
*
* @param bean
* bean
* @param property
*
* @return bean.field
*/
public static String getValueAsString(final Object bean, final String property) {
Object value = null;
try {
value = PropertyUtils.getProperty(bean, property);
} catch (IllegalAccessException e) {
Log log = LogFactory.getLog(ValidatorUtils.class);
log.error(e.getMessage(), e);
} catch (InvocationTargetException e) {
Log log = LogFactory.getLog(ValidatorUtils.class);
log.error(e.getMessage(), e);
} catch (NoSuchMethodException e) {
Log log = LogFactory.getLog(ValidatorUtils.class);
log.error(e.getMessage(), e);
}
if (value == null) {
return null;
}
if (value instanceof String[]) {
return ((String[]) value).length > 0 ? value.toString() : "";
} else if (value instanceof Collection) {
return ((Collection) value).isEmpty() ? "" : value.toString();
} else if (value instanceof MultipartFile) {
MultipartFile file = (MultipartFile) value;
if (file.isEmpty()) {
return "";
} else {
return file.getOriginalFilename();
}
} else {
return value.toString();
}
}
}

View File

@ -0,0 +1,8 @@
/**
* Validator Package.
*/
/**
* @author kimnomin
*
*/
package kcg.faics.comn.validator;

View File

@ -0,0 +1,15 @@
package kcg.faics.equip.service;
import kcg.faics.cmmn.bbs.BaseBbsService;
import kcg.faics.equip.vo.ApproveVO;
import kcg.faics.equip.vo.EquipSearchVO;
/**
* .
*
* @author kimnomin
*
*/
public interface ApproveService extends BaseBbsService<EquipSearchVO, ApproveVO> {
}

View File

@ -0,0 +1,143 @@
/**
* FaEquipmentService.java
* @author
* @since 2016. 10. 13.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 13.
*
*/
package kcg.faics.equip.service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.web.multipart.MultipartFile;
import kcg.faics.equip.vo.EquipSearchVO;
import kcg.faics.equip.vo.EquipVO;
/**
* FaEquipmentService.java
* @author
* @since 2016. 10. 13.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 13.
*
*/
public interface EquipmentService {
/**
* .
*
* @return map
*/
List<HashMap<String, Object>> getEquipmentList() throws Exception;
/**
* .
*
* @param params
* type - or , year - , quater -
* @return map
*/
List<HashMap<String, Object>> getEquipUseStateList(EquipSearchVO searchVO) throws Exception;
/**
* .
*
* @return map
*/
List<HashMap<String, Object>> getEquipYearList() throws Exception;
/**
* .
*
* @return map
*/
List<HashMap<String, Object>> getEquipmentCodeList() throws Exception;
/**
* .
*
* @param params
* place1 - or , year - , quater -
* @return map
* @throws Exception
*/
List<HashMap<String, Object>> getEquipUseStateInfo(EquipSearchVO searchVO) throws Exception;
/**
* or .
*
* @param paramMap
* @return map
* @throws Exception
*/
int insertEquipUseState(EquipSearchVO searchVO, HashMap<String, HashMap<String, Object>> paramMap) throws Exception;
/**
*
*
* @param equipSearchVO
* @return List<EquipVO>
* @throws Exception
*
*/
List<EquipVO> getEquipList(EquipSearchVO equipSearchVO) throws Exception;
/**
* .
*
* @param dataVO
* VO ( PK .)
* @return
* @throws Exception
*
*/
EquipVO getEquipment(EquipVO equipVO) throws Exception;
/**
*
*
* @param equipVO
* @return
* @throws Exception
*
*/
HashMap<String, Object> insertEquipment(EquipVO equipVO, final Map<String, MultipartFile> fileMap) throws Exception;
/**
*
*
* @param equipVO
* @return
* @throws Exception
*
*/
HashMap<String, Object> updateEquipment(EquipVO equipVO, final Map<String, MultipartFile> fileMap, final String[] deleteFiles) throws Exception;
/**
* .
*
* @param equipVO
* @return Map("result") = 1 : , <else> :
* @throws Exception
*
*/
HashMap<String, Object> deleteEquipment(EquipVO equipVO) throws Exception;
/**
* .
*
* @param bfBdSeq
* @param fileMap ,
* @return - 1, - 0
* @exception Exception
*/
// public int insertAndSaveFiles(BoardFileVO boardFileVO, final Map<String, MultipartFile> fileMap) throws Exception;
}

View File

@ -0,0 +1,23 @@
package kcg.faics.equip.service;
import java.util.List;
import kcg.faics.equip.vo.StateWaitingSearchVO;
import kcg.faics.equip.vo.UseStateVO;
/**
* .
*
* @author kimnomin
*
*/
public interface StateWaitingService {
/**
* .
*
* @param searchVO
* VO
* @return
*/
List<UseStateVO> selectList(StateWaitingSearchVO searchVO);
}

View File

@ -0,0 +1,40 @@
package kcg.faics.equip.service.impl;
import org.springframework.stereotype.Repository;
import kcg.faics.equip.vo.ApproveVO;
import egovframework.rte.psl.dataaccess.EgovAbstractMapper;
/**
* Mapper.
*
* @author kimnomin
*
*/
@Repository("approveMapper")
public class ApproveMapper extends EgovAbstractMapper {
/**
* .
*/
private final String namespace = "EquipApprove";
/**
* .
*
* @param vo VO
* @return
*/
public ApproveVO select(final ApproveVO vo) {
return selectOne(namespace + ".select", vo);
}
/**
* .
*
* @param dataVO VO
* @return 1-, 0-
*/
public int insert(final ApproveVO dataVO) {
return insert(namespace + ".insert", dataVO);
}
}

View File

@ -0,0 +1,91 @@
package kcg.faics.equip.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import kcg.faics.equip.service.ApproveService;
import kcg.faics.equip.vo.ApproveVO;
import kcg.faics.equip.vo.EquipSearchVO;
/**
* .
*
* @author kimnomin
*
*/
@Service("approveService")
public class ApproveServiceImpl implements ApproveService {
/**
* Mapper.
*/
@Resource(name = "approveMapper")
private ApproveMapper approveMapper;
@Override
public ApproveVO select(final ApproveVO dataVO) throws Exception {
return approveMapper.select(dataVO);
}
@Override
public List<ApproveVO> selectListAll(final EquipSearchVO searchVO)
throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public List<ApproveVO> selectList(final EquipSearchVO searchVO) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public int selectListCnt(final EquipSearchVO searchVO) throws Exception {
// TODO Auto-generated method stub
return 0;
}
@Override
public int selectTotalCnt(final EquipSearchVO searchVO) throws Exception {
// TODO Auto-generated method stub
return 0;
}
@Override
public HashMap<String, Object> insert(final ApproveVO dataVO,
final Map<String, MultipartFile> fileMap) throws Exception {
HashMap<String, Object> result = new HashMap<String, Object>();
// 이미 결재 내역이 있으면 결재하지 않는다.
ApproveVO vo = select(dataVO);
if (vo == null) {
result.put("result", approveMapper.insert(dataVO));
} else {
result.put("result", 0);
}
return result;
}
@Override
public HashMap<String, Object> update(final ApproveVO dataVO,
final Map<String, MultipartFile> fileMap, final String[] deleteFiles)
throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public HashMap<String, Object> delete(final ApproveVO dataVO) throws Exception {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,212 @@
/**
* FaEquipmentMapper.java
* @author
* @since 2016. 10. 13.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 13.
*
*/
package kcg.faics.equip.service.impl;
import java.util.HashMap;
import java.util.List;
import kcg.faics.arrest.vo.ArrestSearchVO;
import kcg.faics.arrest.vo.ArrestVO;
import kcg.faics.equip.vo.EquipSearchVO;
import kcg.faics.equip.vo.EquipVO;
import org.springframework.stereotype.Repository;
import egovframework.rte.psl.dataaccess.EgovAbstractMapper;
/**
* FaEquipmentMapper.java
* @author
* @since 2016. 10. 13.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 13.
*
*/
@Repository("equipmentMapper")
public class EquipmentMapper extends EgovAbstractMapper {
/**
* .
*
* @return map
*/
public List<HashMap<String, Object>> getEquipmentList(HashMap<String, Object> params) {
return selectList("Equip.getEquipmentList", params);
}
/**
* .
*
* @param isUseState
- true, - false
* @return map
*/
public List<HashMap<String, Object>> getEquipUseStateList(HashMap<String, Object> params) {
return selectList("Equip.getEquipUseStateList", params);
}
/**
* .
*
* @return map
*/
public List<HashMap<String, Object>> getEquipYearList() {
return selectList("Equip.getEquipYearList");
}
/**
* .
*
* @return map
*/
public List<HashMap<String, Object>> getEquipmentCodeList() {
return selectList("Equip.getEquipmentCodeList");
}
/**
* .
*
* @param params
* place1 - or , year - , quater -
* @return
* @throws Exception
*/
public List<HashMap<String, Object>> getEquipUseStateInfo(EquipSearchVO params) {
return selectList("Equip.getEquipUseStateInfo", params);
}
/**
* .
*
* @param params
* place1 - or , year - , quater -
* @return
* @throws Exception
*/
public HashMap<String, Object> getEquipUseStateInfoByCode(HashMap<String, Object> params) {
return selectOne("Equip.getEquipUseStateInfoByCode", params);
}
/**
* .
*
* @param params
* @return 1-, 0-
* @throws Exception
*/
public int insertEquipUseState(HashMap<String, Object> params) {
return update("Equip.insertEquipUseState", params);
}
/**
* .
*
* @param params
* @return 1-, 0-
* @throws Exception
*/
public int updateEquipUseState(HashMap<String, Object> searchVO) {
return insert("Equip.updateEquipUseState", searchVO);
}
/**
*
*
* @param equipSearchVO
*
* @return
* @throws Exception
*
*/
public List<EquipVO> getEquipList(final EquipSearchVO equipSearchVO) throws Exception {
return selectList("Equip.getEquipList", equipSearchVO);
}
/**
* ()
*
* @param equipVO
*
* @return
* @throws Exception
*
*/
public EquipVO getEquipment(final EquipVO equipVO) throws Exception {
return selectOne("Equip.getEquipment", equipVO);
}
/**
* .
*
* @param equipVO
* @return result
* @throws Exception
*/
public HashMap<String, Object> insertEquipment(final EquipVO equipVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
int result = 0;
try {
result = insert("Equip.insertEquipment", equipVO);
resultMap.put("result", result);
resultMap.put("serNo", equipVO.getSerNo());
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
/**
* .
*
* @param equipVO
* @return result
* @throws Exception
*/
public HashMap<String, Object> deleteEquipment(final EquipVO equipVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
int result = 0;
try {
result = delete("Equip.deleteEquipment", equipVO);
resultMap.put("result", result);
resultMap.put("serNo", equipVO.getSerNo());
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
/**
* .
*
* @param equipVO
* @return result
* @throws Exception
*/
public HashMap<String, Object> updateEquipment(final EquipVO equipVO) throws Exception {
HashMap<String, Object> resultMap = new HashMap<String, Object>();
int result = 0;
try {
result = insert("Equip.updateEquipment", equipVO);
resultMap.put("result", result);
resultMap.put("serNo", equipVO.getSerNo());
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
}

View File

@ -0,0 +1,363 @@
/**
* FaEquipmentServiceImpl.java
* @author
* @since 2016. 10. 13.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 13.
*
*/
package kcg.faics.equip.service.impl;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import kcg.faics.board.util.BoardVOHandler;
import kcg.faics.board.vo.BoardFileVO;
import kcg.faics.cmmn.bbs.BaseFileService;
import kcg.faics.cmmn.egov.file.EgovFileMngUtil;
import kcg.faics.cmmn.file.FileUploadUtil;
import kcg.faics.cmmn.service.impl.CodeMapper;
import kcg.faics.equip.service.EquipmentService;
import kcg.faics.equip.vo.EquipSearchVO;
import kcg.faics.equip.vo.EquipVO;
/**
* FaEquipmentServiceImpl.java
* @author
* @since 2016. 10. 13.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 13.
*
*/
@Service("equipmentService")
public class EquipmentServiceImpl implements EquipmentService {
@Resource(name = "equipmentMapper")
EquipmentMapper equipmentMapper;
@Resource(name = "codeMapper")
CodeMapper codeMapper;
/**
* EgovFileMngUtil - Util
**/
@Resource(name = "EgovFileMngUtil")
private EgovFileMngUtil fileUtil;
/**
* BoardFileService -
**/
@Resource(name = "boardFileService")
private BaseFileService<BoardFileVO> boardFileService;
/**
* .
*/
@Resource(name = "fileUploadUtil")
private FileUploadUtil fileUploadUtil;
/**
* .
*/
@Resource(name = "EgovFileMngUtil")
private EgovFileMngUtil fileMngUtil;
/**
* .
*/
public static final String EQUIP_SAVE_PATH = "Equip.fileStorePath";
/**
* .
*
* @return map
*/
@Override
public List<HashMap<String, Object>> getEquipmentList() throws Exception {
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("place1", codeMapper.getPlace1List(true));
return equipmentMapper.getEquipmentList(params);
}
/**
* .
*
* @param params
* type - or , year - , quater -
* @return map
*/
@Override
public List<HashMap<String, Object>> getEquipUseStateList(final EquipSearchVO searchVO) throws Exception {
List<HashMap<String, Object>> result = null;
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("place1", codeMapper.getPlace1List(true));
params.put("criteria", searchVO);
params.put("type", (searchVO.getType().equals("a")) ? "EU_CNT" : "EU_CHECK");
result = equipmentMapper.getEquipUseStateList(params);
return result;
}
/**
* .
*
* @return map
*/
@Override
public List<HashMap<String, Object>> getEquipYearList() throws Exception {
List<HashMap<String, Object>> result = null;
result = equipmentMapper.getEquipYearList();
return result;
}
/**
* .
*
* @return map
*/
@Override
public List<HashMap<String, Object>> getEquipmentCodeList() throws Exception {
List<HashMap<String, Object>> result = null;
result = equipmentMapper.getEquipmentCodeList();
return result;
}
/**
* .
*
* @param params
* place1 - or , year - , quater -
* @return
* @throws Exception
*/
@Override
public List<HashMap<String, Object>> getEquipUseStateInfo(EquipSearchVO searchVO) throws Exception {
List<HashMap<String, Object>> result = null;
result = equipmentMapper.getEquipUseStateInfo(searchVO);
return result;
}
/**
* or .
*
* @param paramMap
* @return map
* @throws Exception
*/
@Override
@Transactional
public int insertEquipUseState(final EquipSearchVO searchVO, final HashMap<String, HashMap<String, Object>> paramMap) throws Exception {
int success = 0;
Set<String> keySet = paramMap.keySet();
Iterator<String> it = keySet.iterator();
while (it.hasNext()) {
HashMap<String, Object> value = paramMap.get(it.next());
HashMap<String, Object> record = equipmentMapper.getEquipUseStateInfoByCode(value);
boolean isInsert = (record == null) ? true : false;
if (isInsert) {
success = equipmentMapper.insertEquipUseState(value);
} else {
success = equipmentMapper.updateEquipUseState(value);
}
if (success != 1) {
throw new Exception();
}
}
return success;
};
/**
*
*
* @param arrestSearchVO
* @return
* @throws Exception
*/
@Override
public List<EquipVO> getEquipList(final EquipSearchVO EquipSearchVO) throws Exception {
return equipmentMapper.getEquipList(EquipSearchVO);
}
/**
*
*
* @param arrestSearchVO
* @return
* @throws Exception
*/
@Override
public EquipVO getEquipment(final EquipVO equipVO) throws Exception {
return equipmentMapper.getEquipment(equipVO);
}
/**
*
*
* @param equipVO
* @return
* @throws Exception
*/
@Override
public HashMap<String, Object> insertEquipment(final EquipVO equipVO, final Map<String, MultipartFile> fileMap) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
try{
/* 파일 업로드 */
//BoardFileVO boardFileVO = BoardVOHandler.getBFileVO("EQUIPMENT", serNo, 0);
//result = boardFileService.insertAndSaveFiles(boardFileVO, fileMap);
if (fileMap != null && fileMap.get("file1").getSize() > 0) {
String fileName1 = fileUploadUtil.uploadWithExt(fileMap.get("file1"), EQUIP_SAVE_PATH);
System.out.println("fileName1 : " + fileName1);
equipVO.setFileName1(fileName1);
}
if (fileMap != null && fileMap.get("file2").getSize() > 0) {
String fileName2 = fileUploadUtil.uploadWithExt(fileMap.get("file2"), EQUIP_SAVE_PATH);
equipVO.setFileName2(fileName2);
}
if (fileMap != null && fileMap.get("file3").getSize() > 0) {
String fileName3 = fileUploadUtil.uploadWithExt(fileMap.get("file3"), EQUIP_SAVE_PATH);
equipVO.setFileName3(fileName3);
}
map = equipmentMapper.insertEquipment(equipVO);
if ((Integer)map.get("result") != 1) {
throw new Exception();
} else {
map.put("result", 1);
}
}catch(Exception e){
e.printStackTrace();
}
return map;
}
/**
*
*
* @param equipVO
* @return
* @throws Exception
*/
@Override
public HashMap<String, Object> deleteEquipment(final EquipVO equipVO) throws Exception {
try{
/* 파일을 삭제한다. */
//boardFileService.deleteAndRemoveFiles(BoardVOHandler.getBFileVO(boardVO)(equipVO));
}catch(Exception e){
}
return equipmentMapper.deleteEquipment(equipVO);
}
/**
*
*
* @param equipVO
* @return
* @throws Exception
*/
@Override
public HashMap<String, Object> updateEquipment(final EquipVO dataVO, final Map<String, MultipartFile> fileMap, final String[] deleteFiles) throws Exception {
HashMap<String, Object> map = new HashMap<String, Object>();
try{
System.out.println(deleteFiles);
if( deleteFiles != null ){
for (int i = 0; i < deleteFiles.length; i++) {
if( deleteFiles[i].equals("1") ){
if (dataVO.getFileName1() != null || dataVO.getFileName1().equals("")) {
fileMngUtil.deleteFile(dataVO.getFileName1(), EQUIP_SAVE_PATH);
dataVO.setFileName1(null);
}
}else if( deleteFiles[i].equals("2") ){
// file2 삭제
if (dataVO.getFileName2() != null || dataVO.getFileName2().equals("")) {
fileMngUtil.deleteFile(dataVO.getFileName2(), EQUIP_SAVE_PATH);
dataVO.setFileName2(null);
}
}else if( deleteFiles[i].equals("3") ){
// file3 삭제
if (dataVO.getFileName3() != null || dataVO.getFileName2().equals("")) {
fileMngUtil.deleteFile(dataVO.getFileName2(), EQUIP_SAVE_PATH);
dataVO.setFileName3(null);
}
}
}
}
if( fileMap != null ){
if ( fileMap.get("file1") != null ) {
if( fileMap.get("file1").getSize() > 0){
String fileName1 = fileUploadUtil.uploadWithExt(fileMap.get("file1"), EQUIP_SAVE_PATH);
System.out.println("fileName1 : " + fileName1);
dataVO.setFileName1(fileName1);
}
}
if ( fileMap.get("file2") != null ) {
if( fileMap.get("file2").getSize() > 0){
String fileName2 = fileUploadUtil.uploadWithExt(fileMap.get("file2"), EQUIP_SAVE_PATH);
dataVO.setFileName2(fileName2);
}
}
if ( fileMap.get("file3") != null ) {
if( fileMap.get("file3").getSize() > 0){
String fileName3 = fileUploadUtil.uploadWithExt(fileMap.get("file3"), EQUIP_SAVE_PATH);
dataVO.setFileName3(fileName3);
}
}
}
map = equipmentMapper.updateEquipment(dataVO);
if ((Integer)map.get("result") != 1) {
throw new Exception();
} else {
map.put("result", 1);
}
}catch(Exception e){
}
return map;
}
}

View File

@ -0,0 +1,30 @@
package kcg.faics.equip.service.impl;
import java.util.List;
import kcg.faics.equip.vo.StateWaitingSearchVO;
import kcg.faics.equip.vo.UseStateVO;
import org.springframework.stereotype.Repository;
import egovframework.rte.psl.dataaccess.EgovAbstractMapper;
/**
* Mapper.
*
* @author kimnomin
*
*/
@Repository("equipStateWaitingMapper")
public class StateWaitingMapper extends EgovAbstractMapper {
/**
* .
*
* @param searchVO
* VO
* @return
*/
public List<UseStateVO> selectList(final StateWaitingSearchVO searchVO) {
return selectList("Equip.selectStateWaitingList", searchVO);
}
}

View File

@ -0,0 +1,31 @@
package kcg.faics.equip.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import kcg.faics.equip.service.StateWaitingService;
import kcg.faics.equip.vo.StateWaitingSearchVO;
import kcg.faics.equip.vo.UseStateVO;
/**
* .
*
* @author kimnomin
*
*/
@Service("equipStateWaitingSerivce")
public class StateWaitingServiceImpl implements StateWaitingService {
/**
* Mapper.
*/
@Resource(name = "equipStateWaitingMapper")
private StateWaitingMapper equipStateWaitingMapper;
@Override
public List<UseStateVO> selectList(final StateWaitingSearchVO searchVO) {
return equipStateWaitingMapper.selectList(searchVO);
}
}

View File

@ -0,0 +1,279 @@
package kcg.faics.equip.vo;
import java.util.Date;
/**
* VO.
*
* @author kimnomin
*
*/
public class ApproveVO {
/**
* .
*/
private int seq;
/**
* .
*/
private Date checkDate;
/**
* ().
*/
private String police;
/**
* ().
*/
private String policeStr;
/**
* .
*/
private String year;
/**
* .
*/
private String quater;
/**
* .
*/
private String place1;
/**
* .
*/
private String place1Str;
/**
* .
*/
private String position;
/**
* .
*/
private String positionStr;
/**
* .
*/
private String name;
/**
* ID.
*/
private String userId;
/**
* ID.
*/
private String proxyId;
/**
* .
*/
private String message;
/**
* @return the seq
*/
public final int getSeq() {
return seq;
}
/**
* @param seq
* the seq to set
*/
public final void setSeq(final int seq) {
this.seq = seq;
}
/**
* @return the checkDate
*/
public final Date getCheckDate() {
return checkDate;
}
/**
* @param checkDate
* the checkDate to set
*/
public final void setCheckDate(final Date checkDate) {
this.checkDate = checkDate;
}
/**
* @return the police
*/
public final String getPolice() {
return police;
}
/**
* @param police
* the police to set
*/
public final void setPolice(final String police) {
this.police = police;
}
/**
* @return the policeStr
*/
public final String getPoliceStr() {
return policeStr;
}
/**
* @param policeStr
* the policeStr to set
*/
public final void setPoliceStr(final String policeStr) {
this.policeStr = policeStr;
}
/**
* @return the year
*/
public final String getYear() {
return year;
}
/**
* @param year
* the year to set
*/
public final void setYear(final String year) {
this.year = year;
}
/**
* @return the quater
*/
public final String getQuater() {
return quater;
}
/**
* @param quater
* the quater to set
*/
public final void setQuater(final String quater) {
this.quater = quater;
}
/**
* @return the place1
*/
public final String getPlace1() {
return place1;
}
/**
* @param place1
* the place1 to set
*/
public final void setPlace1(final String place1) {
this.place1 = place1;
}
/**
* @return the place1Str
*/
public final String getPlace1Str() {
return place1Str;
}
/**
* @param place1Str
* the place1Str to set
*/
public final void setPlace1Str(final String place1Str) {
this.place1Str = place1Str;
}
/**
* @return the position
*/
public final String getPosition() {
return position;
}
/**
* @param position
* the position to set
*/
public final void setPosition(final String position) {
this.position = position;
}
/**
* @return the positionStr
*/
public final String getPositionStr() {
return positionStr;
}
/**
* @param positionStr
* the positionStr to set
*/
public final void setPositionStr(final String positionStr) {
this.positionStr = positionStr;
}
/**
* @return the name
*/
public final String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public final void setName(final String name) {
this.name = name;
}
/**
* @return the userId
*/
public final String getUserId() {
return userId;
}
/**
* @param userId
* the userId to set
*/
public final void setUserId(final String userId) {
this.userId = userId;
}
/**
* @return the proxyId
*/
public final String getProxyId() {
return proxyId;
}
/**
* @param proxyId
* the proxyId to set
*/
public final void setProxyId(final String proxyId) {
this.proxyId = proxyId;
}
/**
* @return the message
*/
public final String getMessage() {
return message;
}
/**
* @param message
* the message to set
*/
public final void setMessage(final String message) {
this.message = message;
}
}

View File

@ -0,0 +1,13 @@
package kcg.faics.equip.vo;
import kcg.faics.cmmn.bbs.BaseFileVO;
/**
* Value Object.
*
* @author lyh
*
*/
public class EquipFileVO extends BaseFileVO {
}

View File

@ -0,0 +1,78 @@
/**
* EquipSearchVO.java
* @author
* @since 2016. 10. 24.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 24.
*
*/
package kcg.faics.equip.vo;
/**
* EquipSearchVO.java
* @author
* @since 2016. 10. 24.
*
*
* ------------- -------- ---------------------------
* 2016. 10. 24.
*
*/
public class EquipSearchVO {
private int year;
private int quater;
private String type;
private String police;
/**
* @return the year
*/
public int getYear() {
return year;
}
/**
* @param year the year to set
*/
public void setYear(int year) {
this.year = year;
}
/**
* @return the quater
*/
public int getQuater() {
return quater;
}
/**
* @param quater the quater to set
*/
public void setQuater(int quater) {
this.quater = quater;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the police
*/
public String getPolice() {
return police;
}
/**
* @param police the police to set
*/
public void setPolice(String police) {
this.police = police;
}
}

Some files were not shown because too many files have changed in this diff Show More