├── src ├── main │ ├── resources │ │ ├── application-mvc.properties │ │ ├── application.properties │ │ ├── logback.xml │ │ └── datasource.properties │ └── java │ │ └── org │ │ └── openpaas │ │ └── egovframework │ │ └── comcomponent │ │ └── dorojuso │ │ ├── exception │ │ ├── DoroJusoExistsException.java │ │ ├── DoroJusoDoesNotExistException.java │ │ ├── DoroJusoException.java │ │ └── DoroJusoBadRequestException.java │ │ ├── model │ │ ├── ResultMessage.java │ │ ├── DoroJusoInfoResult.java │ │ ├── DoroJuso.java │ │ ├── Juso.java │ │ ├── Common.java │ │ └── DoroJusoInfo.java │ │ ├── Application.java │ │ ├── common │ │ └── StringUtils.java │ │ ├── MysqlConfig.java │ │ ├── SimpleCORSFilter.java │ │ ├── dao │ │ ├── DoroJusoDAO.java │ │ └── impl │ │ │ └── DoroJusoDAOImpl.java │ │ ├── controller │ │ ├── DoroJusoController.java │ │ ├── BaseController.java │ │ └── DoroJusoManagerController.java │ │ └── service │ │ ├── DoroJusoService.java │ │ └── DoroJusoManagerService.java └── test │ ├── java │ └── org │ │ └── openpaas │ │ └── egovframework │ │ └── comcomponent │ │ └── dorojuso │ │ ├── model │ │ └── fixture │ │ │ ├── DoroJusoFixture.java │ │ │ └── DataFixture.java │ │ ├── common │ │ ├── JsonUtils.java │ │ └── HttpClientUtils.java │ │ └── controller │ │ ├── DoroJusoControllerTest.java │ │ ├── DoroJusoRestTest.java │ │ └── DoroJusoManagerRestTest.java │ └── resources │ └── test.properties ├── README.md ├── doc └── database │ ├── juso.mwb │ ├── juso.mwb.bak │ ├── convert.sh │ └── doro_juso.sql ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── manifest.yml ├── gradlew.bat └── gradlew /src/main/resources/application-mvc.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=50000 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Open PaaS Project 2 | 3 | - eGov Common component Sample 4 | - Doro Juso API -------------------------------------------------------------------------------- /doc/database/juso.mwb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaaS-TA/SERVICE-EGOV-COMMON-JUSO/HEAD/doc/database/juso.mwb -------------------------------------------------------------------------------- /doc/database/juso.mwb.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaaS-TA/SERVICE-EGOV-COMMON-JUSO/HEAD/doc/database/juso.mwb.bak -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaaS-TA/SERVICE-EGOV-COMMON-JUSO/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /manifest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | applications: 3 | - name: openpaas-mysql-broker 4 | memory: 512M 5 | instances: 1 6 | path: build/libs/openpaas-cf-service-java-broker-mysql.war -------------------------------------------------------------------------------- /doc/database/convert.sh: -------------------------------------------------------------------------------- 1 | rm -rf doro_juso.txt 2 | ln -s ./doro_juso/gun_X.txt doro_juso.txt 3 | mysqlimport -u root -p egov_common --fields-terminated-by="|" --lines-terminated-by="\n" /home/wso2/doro_juso.txt -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Apr 10 11:17:29 MDT 2014 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip 7 | -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/datasource.properties: -------------------------------------------------------------------------------- 1 | # mysql Database Settings 2 | JDBC.Driver = com.mysql.jdbc.Driver 3 | JDBC.Url = jdbc:mysql://10.30.60.110:3306/egov_common?autoReconnect=true&useUnicode=true&characterEncoding=utf8 4 | #JDBC.Url = jdbc:mysql://localhost:51002/egov_common?autoReconnect=true&useUnicode=true&characterEncoding=utf8 5 | JDBC.Username= egov 6 | JDBC.Password =openpaas -------------------------------------------------------------------------------- /src/test/java/org/openpaas/egovframework/comcomponent/dorojuso/model/fixture/DoroJusoFixture.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.model.fixture; 2 | 3 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJuso; 4 | 5 | 6 | public class DoroJusoFixture { 7 | 8 | public static DoroJuso getDoroJuso() { 9 | return new DoroJuso(); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/test.properties: -------------------------------------------------------------------------------- 1 | # test properties 2 | test_base_protocol = http:// 3 | test_base_url = 115.68.46.28:50000 4 | #test_base_url = localhost:50000 5 | 6 | # DoroJuso 7 | dorojuso_path=/addrlink/addrLinkApi.do 8 | 9 | 10 | 11 | # Manager 12 | dorojuso_manager_path=/dorojuso/manager 13 | 14 | building_code=TEST000000000000000000000 15 | building_code_exist=1165010200103260002004362 16 | building_code_fail=TEST000000000000000000001 -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/exception/DoroJusoExistsException.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.exception; 2 | 3 | /** 4 | * 도로주소가 있을 경우 Exception (Insert시) 5 | * 6 | * @author 안찬영 7 | * 8 | * History 9 | * 2015.7.1 최초 Framework 구성시 작업 10 | */ 11 | public class DoroJusoExistsException extends Exception { 12 | 13 | private static final long serialVersionUID = -914571358227517785L; 14 | 15 | /** 16 | * 생성자 (query를 설정) 17 | * @param query 18 | */ 19 | public DoroJusoExistsException(String query) { 20 | super("DoroJuso is existed : query = " + query); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/exception/DoroJusoDoesNotExistException.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.exception; 2 | 3 | /** 4 | * 도로주소가 존재하지 않을 경우 Exception (Update, Delete시) 5 | * 6 | * @author 안찬영 7 | * 8 | * History 9 | * 2015.7.1 최초 Framework 구성시 작업 10 | */ 11 | public class DoroJusoDoesNotExistException extends Exception { 12 | 13 | private static final long serialVersionUID = -62090827040416788L; 14 | 15 | /** 16 | * 생성자 (query를 메세지로) 17 | * @param query 18 | */ 19 | public DoroJusoDoesNotExistException(String query) { 20 | super("DoroJuso does not exist: query = " + query); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/model/ResultMessage.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | /** 6 | * 결과 정보 (관리용) 7 | * 8 | * @author 안찬영 9 | * 10 | * History 11 | * 2015.7.14 도로명주소 검색 개발 12 | */ 13 | public class ResultMessage { 14 | 15 | /** 16 | * 메세지 17 | */ 18 | private String message; 19 | 20 | public ResultMessage(String message) { 21 | this.message = message; 22 | } 23 | 24 | public String getMessage() { 25 | return message; 26 | } 27 | 28 | public void setMessage(String message) { 29 | this.message = message; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/Application.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * Spring Boot에서 시작 Class 9 | * 10 | * @author 안찬영 11 | * 12 | * History 13 | * 2015.7.1 최초 Framework 구성시 작업 14 | */ 15 | @EnableAutoConfiguration 16 | @ComponentScan 17 | public class Application { 18 | 19 | /** 20 | * main 함수 21 | * 22 | * @param args 23 | */ 24 | public static void main(String[] args) { 25 | SpringApplication.run(Application.class, args); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/common/StringUtils.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.common; 2 | 3 | /** 4 | * String 처리를 위한 Utility 5 | * 6 | * @author 안찬영 7 | * 8 | * History 9 | * 2015.7.1 최초 Framework 구성시 작업 10 | */ 11 | public class StringUtils { 12 | 13 | /** 14 | * DB의 우편번호 (6자리)를 xxx-xxx형태로 변환 15 | * 16 | * @param zipcode 우편번호 (6자리 xxxxxx) 17 | * @return xxx-xxx형태의 우편번호 18 | */ 19 | public static String changeZipCode(String zipcode) { 20 | String result = ""; 21 | 22 | if (null == zipcode) return ""; 23 | if (zipcode.length() != 6) return ""; 24 | 25 | result = zipcode.substring(0, 3) + "-" + zipcode.substring(3, 6); 26 | 27 | return result; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/openpaas/egovframework/comcomponent/dorojuso/model/fixture/DataFixture.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.model.fixture; 2 | 3 | import java.io.IOException; 4 | 5 | import com.fasterxml.jackson.core.JsonGenerationException; 6 | import com.fasterxml.jackson.databind.JsonMappingException; 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | 9 | 10 | public class DataFixture { 11 | 12 | public static String getOrgOneGuid() { 13 | return "org-guid-one"; 14 | } 15 | 16 | public static String getSpaceOneGuid() { 17 | return "space-guid-one"; 18 | } 19 | 20 | public static String toJson(Object object) throws JsonGenerationException, JsonMappingException, IOException { 21 | ObjectMapper mapper = new ObjectMapper(); 22 | return mapper.writeValueAsString(object); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/exception/DoroJusoException.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.exception; 2 | 3 | /** 4 | * 일반적인 오류 Exception 5 | * 6 | * @author 안찬영 7 | * 8 | * History 9 | * 2015.7.1 최초 Framework 구성시 작업 10 | */ 11 | public class DoroJusoException extends Exception { 12 | 13 | private static final long serialVersionUID = -5544859893499349135L; 14 | 15 | /** 16 | * 생성자 (Message 설정) 17 | * @param message 18 | */ 19 | public DoroJusoException(String message) { 20 | super(message); 21 | } 22 | 23 | /** 24 | * 생성자 (Message, throwable 설정) 25 | * @param message 26 | * @param cause 27 | */ 28 | public DoroJusoException(String message, Throwable cause) { 29 | super(message, cause); 30 | } 31 | 32 | /** 33 | * 생성자 (throwable 설정) 34 | * @param cause 35 | */ 36 | public DoroJusoException(Throwable cause) { 37 | super(cause); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/exception/DoroJusoBadRequestException.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.exception; 2 | 3 | /** 4 | * 잘못된 Request가 있을 경우의 Exception 5 | * 6 | * @author 안찬영 7 | * 8 | * History 9 | * 2015.7.1 최초 Framework 구성시 작업 10 | */ 11 | public class DoroJusoBadRequestException extends Exception { 12 | 13 | private static final long serialVersionUID = 4719676639792071582L; 14 | 15 | /** 16 | * 생성자 (Message 설정) 17 | * @param message 18 | */ 19 | public DoroJusoBadRequestException(String message) { 20 | super(message); 21 | } 22 | 23 | /** 24 | * 생성자 (메세지와 throwable 설정) 25 | * @param message 26 | * @param cause 27 | */ 28 | public DoroJusoBadRequestException(String message, Throwable cause) { 29 | super(message, cause); 30 | } 31 | 32 | /** 33 | * 생성자 (throwable 설정) 34 | * @param cause 35 | */ 36 | public DoroJusoBadRequestException(Throwable cause) { 37 | super(cause); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/model/DoroJusoInfoResult.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 9 | 10 | import org.hibernate.validator.constraints.NotEmpty; 11 | 12 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 13 | import com.fasterxml.jackson.annotation.JsonProperty; 14 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 15 | 16 | /** 17 | * 주소 리스트 (관리용) 18 | * 19 | * @author 안찬영 20 | * 21 | * History 22 | * 2015.7.14 도로명주소 검색 개발 23 | */ 24 | @XmlRootElement(name="results") 25 | @JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) 26 | @JsonIgnoreProperties(ignoreUnknown = true) 27 | public class DoroJusoInfoResult { 28 | 29 | /** 30 | * 주소 리스트 31 | */ 32 | @NotEmpty 33 | @JsonSerialize 34 | @JsonProperty("juso") 35 | private List juso = new ArrayList(); 36 | 37 | public List getJuso() { 38 | return juso; 39 | } 40 | 41 | public void setJuso(List juso) { 42 | this.juso = juso; 43 | } 44 | 45 | 46 | } -------------------------------------------------------------------------------- /src/test/java/org/openpaas/egovframework/comcomponent/dorojuso/common/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.common; 2 | 3 | import java.io.IOException; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.http.ResponseEntity; 7 | 8 | import com.fasterxml.jackson.core.JsonParseException; 9 | import com.fasterxml.jackson.databind.JsonMappingException; 10 | import com.fasterxml.jackson.databind.JsonNode; 11 | import com.fasterxml.jackson.databind.ObjectMapper; 12 | 13 | public class JsonUtils { 14 | 15 | private static final Logger logger = LoggerFactory.getLogger(JsonUtils.class) ; 16 | 17 | static public JsonNode convertToJson(ResponseEntity httpResponse) throws Exception { 18 | 19 | ObjectMapper mapper = new ObjectMapper(); 20 | JsonNode json = null; 21 | try { 22 | json = mapper.readValue(httpResponse.getBody(), JsonNode.class); 23 | } catch (JsonParseException e) { 24 | throw new Exception(e.getMessage()); 25 | } catch (JsonMappingException e) { 26 | throw new Exception(e.getMessage()); 27 | } catch (IOException e) { 28 | throw new Exception(e.getMessage()); 29 | } catch (Exception e){ 30 | logger.warn("Json Convert: Exception"); 31 | throw new Exception(e.getMessage()); 32 | } 33 | 34 | logger.info("Json Convert: Complete"); 35 | 36 | return json; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/model/DoroJuso.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 9 | 10 | import org.hibernate.validator.constraints.NotEmpty; 11 | 12 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 13 | import com.fasterxml.jackson.annotation.JsonProperty; 14 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 15 | 16 | /** 17 | * 도로 주소 객체 18 | * 19 | * @author 안찬영 20 | * 21 | * History 22 | * 2015.7.14 도로명주소 검색 개발 23 | */ 24 | @XmlRootElement(name="results") 25 | @JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) 26 | @JsonIgnoreProperties(ignoreUnknown = true) 27 | public class DoroJuso { 28 | 29 | /** 30 | * 공통 부분 31 | */ 32 | @NotEmpty 33 | @JsonSerialize 34 | @JsonProperty("common") 35 | private Common common; 36 | 37 | /** 38 | * 주소 리스트 39 | */ 40 | @NotEmpty 41 | @JsonSerialize 42 | @JsonProperty("juso") 43 | private List juso = new ArrayList(); 44 | 45 | 46 | public Common getCommon() { 47 | return common; 48 | } 49 | 50 | 51 | public void setCommon(Common common) { 52 | this.common = common; 53 | } 54 | 55 | 56 | public List getJuso() { 57 | return juso; 58 | } 59 | 60 | 61 | public void setJuso(List juso) { 62 | this.juso = juso; 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/MysqlConfig.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.context.annotation.PropertySource; 9 | //import org.springframework.context.annotation.PropertySources; 10 | import org.springframework.core.env.Environment; 11 | import org.springframework.jdbc.datasource.DriverManagerDataSource; 12 | 13 | /** 14 | * MySQL에 대한 Datasource 정의 15 | * 16 | * @author 안찬영 17 | * 18 | * History 19 | * 2015.7.1 최초 Framework 구성시 작업 20 | */ 21 | @Configuration 22 | @PropertySource("classpath:datasource.properties") 23 | public class MysqlConfig { 24 | 25 | @Autowired 26 | private Environment env; 27 | 28 | /** 29 | * Datasource 정의 30 | * Properties 파일에서 정보를 가져옴 31 | * 32 | * @return DataSource 33 | */ 34 | @Bean 35 | public DataSource dataSource() { 36 | DriverManagerDataSource dataSource = new DriverManagerDataSource(); 37 | //dataSource.setDriverClassName("com.mysql.jdbc.Driver"); 38 | dataSource.setDriverClassName(env.getRequiredProperty("JDBC.Driver")); 39 | dataSource.setUrl(env.getProperty("JDBC.Url")); 40 | dataSource.setUsername(env.getProperty("JDBC.Username")); 41 | dataSource.setPassword(env.getProperty("JDBC.Password")); 42 | 43 | return dataSource; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/SimpleCORSFilter.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso; 2 | 3 | import java.io.IOException; 4 | import javax.servlet.Filter; 5 | import javax.servlet.FilterChain; 6 | import javax.servlet.FilterConfig; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.ServletRequest; 9 | import javax.servlet.ServletResponse; 10 | import javax.servlet.http.HttpServletResponse; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * Cross-site HTTP request 처리를 위한 필터 15 | * 16 | * @Author 안찬영 17 | * 18 | * History 19 | * 2015.7.1 최초 Framework 구성시 작업 20 | */ 21 | @Component 22 | public class SimpleCORSFilter implements Filter { 23 | 24 | /** 25 | * Filter 추가 26 | * 27 | * @param req ServletRequest 28 | * @param res ServletReponse 29 | * @param chain FilterChain 30 | */ 31 | public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { 32 | HttpServletResponse response = (HttpServletResponse) res; 33 | response.setHeader("Access-Control-Allow-Origin", "*"); 34 | response.setHeader("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS, DELETE"); 35 | response.setHeader("Access-Control-Max-Age", "3600"); 36 | response.setHeader("Access-Control-Allow-Headers", "x-requested-with"); 37 | chain.doFilter(req, res); 38 | } 39 | 40 | /** 41 | * 초기화 42 | */ 43 | public void init(FilterConfig filterConfig) {} 44 | 45 | /** 46 | * 종료 47 | */ 48 | public void destroy() {} 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/dao/DoroJusoDAO.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoException; 6 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoExistsException; 7 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJusoInfo; 8 | 9 | /** 10 | * 도로명 주소 DAO Interface 11 | * 12 | * @author 안찬영 13 | * 14 | * History 15 | * 2015.7.14 도로명주소 검색 개발 16 | */ 17 | public interface DoroJusoDAO { 18 | 19 | /** 20 | * 도로 정보 리스트 가져오기 21 | * 22 | * @param currentPage 현재 페이지 23 | * @param pageTotal 페이지내 정보 갯수 24 | * @param keyword 검색 키워드 25 | * @return 도로정보 리스트 26 | */ 27 | abstract public List getDoroJuso(int currentPage, int pageTotal, String keyword); 28 | 29 | /** 30 | * 도로주소 하나 가져오기 31 | * 32 | * @param gunmul_no 건물번호 33 | * @return 34 | */ 35 | abstract public DoroJusoInfo getDoroJusoOne(String gunmul_no); 36 | 37 | /** 38 | * 도로주소 등록 39 | * 40 | * @param doroJusoInfo 도로주소 정보 41 | * @return 등록된 갯수 42 | * @throws DoroJusoException 서버 내부 오류 43 | * @throws DoroJusoExistsException 존재하는 도로주소정보일 경우 오류 44 | */ 45 | abstract public int insertDoroJuso(DoroJusoInfo doroJusoInfo) throws DoroJusoException, DoroJusoExistsException; 46 | 47 | /** 48 | * 도로주소 수정 49 | * 50 | * @param doroJusoInfo 도로주소 정보 51 | * @return 수정된 갯수 52 | * @throws DoroJusoException 서버 내부 오류 53 | */ 54 | abstract public int updateDoroJuso(DoroJusoInfo doroJusoInfo) throws DoroJusoException; 55 | 56 | /** 57 | * 도로주소 삭제 58 | * 59 | * @param building_code 건물관리 번호 60 | * @return 삭제된 갯수 61 | * @throws DoroJusoException 서버 내부 오류 62 | */ 63 | abstract public int deleteDoroJuso(String building_code) throws DoroJusoException; 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/test/java/org/openpaas/egovframework/comcomponent/dorojuso/common/HttpClientUtils.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.common; 2 | 3 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJusoInfo; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.http.HttpEntity; 7 | import org.springframework.http.HttpMethod; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.web.client.DefaultResponseErrorHandler; 11 | import org.springframework.web.client.RestTemplate; 12 | 13 | public class HttpClientUtils { 14 | 15 | private static final Logger logger = LoggerFactory.getLogger(HttpClientUtils.class); 16 | 17 | static public ResponseEntity send(String url, HttpEntity entity, HttpMethod httpMethod) throws Exception { 18 | 19 | RestTemplate client = new RestTemplate(); 20 | ResponseEntity httpResponse=null; 21 | try { 22 | httpResponse = client.exchange(url, httpMethod, entity, String.class); 23 | } catch (Exception e) { 24 | 25 | if(e.getMessage().equals("404 Not Found")) 26 | { 27 | throw new Exception("Server Not Found"); 28 | } 29 | logger.error(e.getMessage()); 30 | throw new Exception(e.getMessage()); 31 | } 32 | 33 | logger.info("Http Response"); 34 | return httpResponse; 35 | } 36 | 37 | public static ResponseEntity sendDoroJusoInfo(String url, HttpEntity entity, HttpMethod httpMethod) { 38 | RestTemplate client = new RestTemplate(); 39 | client.setErrorHandler(new DefaultResponseErrorHandler(){ 40 | protected boolean hasError(HttpStatus statusCode) { 41 | return false; 42 | }}); 43 | 44 | ResponseEntity httpResponse=null; 45 | // try { 46 | httpResponse = client.exchange(url, httpMethod, entity, String.class); 47 | // } catch (Exception e) { 48 | // if(e.getMessage().equals("404 Not Found")) 49 | // { 50 | // throw new Exception("Server Not Found"); 51 | // } 52 | // logger.error(e.getMessage()); 53 | // throw new Exception(e.getMessage()); 54 | // } 55 | 56 | logger.info("Http Response"); 57 | return httpResponse; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /src/test/java/org/openpaas/egovframework/comcomponent/dorojuso/controller/DoroJusoControllerTest.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.controller; 2 | 3 | import static org.hamcrest.Matchers.hasSize; 4 | import static org.mockito.Mockito.when; 5 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; 6 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; 7 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 8 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 9 | 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | import org.mockito.InjectMocks; 13 | import org.mockito.Mock; 14 | import org.mockito.MockitoAnnotations; 15 | import org.openpaas.egovframework.comcomponent.dorojuso.controller.DoroJusoController; 16 | import org.openpaas.egovframework.comcomponent.dorojuso.model.fixture.DoroJusoFixture; 17 | import org.openpaas.egovframework.comcomponent.dorojuso.service.DoroJusoService; 18 | import org.springframework.http.MediaType; 19 | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; 20 | import org.springframework.test.web.servlet.MockMvc; 21 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 22 | 23 | public class DoroJusoControllerTest { 24 | 25 | MockMvc mockMvc; 26 | 27 | @InjectMocks 28 | DoroJusoController controller; 29 | 30 | @Mock 31 | DoroJusoService doroJusoService; 32 | 33 | @Before 34 | public void setup() { 35 | MockitoAnnotations.initMocks(this); 36 | 37 | this.mockMvc = MockMvcBuilders.standaloneSetup(controller).setMessageConverters(new MappingJackson2HttpMessageConverter()).build(); 38 | } 39 | 40 | /** 41 | * 정상적으로 데이터 조회가 되는지 확인 42 | * errorCode = 0, 데이터는 존재함. 43 | * 44 | * @throws Exception 45 | */ 46 | // @Test 47 | public void catalogIsRetrievedCorrectly() throws Exception {when(doroJusoService.getDoroJuso(1, 100, "강남대로")).thenReturn(DoroJusoFixture.getDoroJuso()); 48 | 49 | this.mockMvc.perform(get("/addrlink/addrLinkApi.do") 50 | .param("currentPage", "1") 51 | .param("countPerPage", "100") 52 | .param("keyword", "강남대로") 53 | .accept(MediaType.APPLICATION_JSON)) 54 | .andExpect(status().isOk()) 55 | .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) 56 | .andExpect(jsonPath("$.juso", hasSize(1))); 57 | 58 | // TO DO - check rest of the json including plans 59 | } 60 | 61 | /** 62 | * query해서 가져오는 갯수를 1000보다 크게 했을 경우 오류 확인 63 | * 64 | */ 65 | 66 | /** 67 | * 특정 Query에 대해 갯수가 정확하게 넘어오는지 확인 68 | * currentPage, countPerPage 등 response의 데이터를 비교 검증 69 | */ 70 | 71 | /** 72 | * JSON, XML 로 변환이 잘되서 넘어오는지 확인 73 | */ 74 | } 75 | -------------------------------------------------------------------------------- /doc/database/doro_juso.sql: -------------------------------------------------------------------------------- 1 | -- MySQL Script generated by MySQL Workbench 2 | -- 06/26/15 11:09:52 3 | -- Model: New Model Version: 1.0 4 | -- MySQL Workbench Forward Engineering 5 | 6 | SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; 7 | SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; 8 | SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; 9 | 10 | -- ----------------------------------------------------- 11 | -- Schema egov_common 12 | -- ----------------------------------------------------- 13 | 14 | -- ----------------------------------------------------- 15 | -- Schema egov_common 16 | -- ----------------------------------------------------- 17 | CREATE SCHEMA IF NOT EXISTS `egov_common` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; 18 | USE `egov_common` ; 19 | 20 | -- ----------------------------------------------------- 21 | -- Table `egov_common`.`doro_juso` 22 | -- ----------------------------------------------------- 23 | CREATE TABLE IF NOT EXISTS `egov_common`.`doro_juso` ( 24 | `code` CHAR(10) NULL COMMENT '', 25 | `sido` VARCHAR(40) NULL COMMENT '', 26 | `sigungu` VARCHAR(40) NULL COMMENT '', 27 | `eupmyundong` VARCHAR(40) NULL COMMENT '', 28 | `ri` VARCHAR(40) NULL COMMENT '', 29 | `san` CHAR(1) NULL COMMENT '0:대지, 1:산', 30 | `bunji` SMALLINT(4) NULL COMMENT '', 31 | `ho` SMALLINT(4) NULL COMMENT '', 32 | `doro_code` CHAR(12) NULL COMMENT '시군구코드(5)+도로명번호(7)', 33 | `doro` VARCHAR(80) NULL COMMENT '', 34 | `jiha` CHAR(1) NULL COMMENT '0:지상, 1:지하, 2:공중', 35 | `bon` SMALLINT(5) NULL COMMENT '', 36 | `bu` SMALLINT(5) NULL COMMENT '', 37 | `gunmul` VARCHAR(40) NULL COMMENT '', 38 | `gunmul_sangse` VARCHAR(100) NULL COMMENT '', 39 | `gunmul_no` VARCHAR(25) NOT NULL COMMENT '', 40 | `eupmyundong_no` SMALLINT(2) NULL COMMENT '', 41 | `hang_code` CHAR(10) NULL COMMENT '', 42 | `hang` VARCHAR(20) NULL COMMENT '', 43 | `zipcode` CHAR(6) NULL COMMENT '', 44 | `zipno` CHAR(3) NULL COMMENT '', 45 | `dayaeng` VARCHAR(40) NULL COMMENT '', 46 | `idong` CHAR(2) NULL COMMENT '31 : 건물번호 부여, 34, 변경, 63 : 건물번호 폐지\n72 : 건물군내 일부 건물 폐지,\n73 : 건물군내 일부 건물 생성', 47 | `update_date` CHAR(8) NULL COMMENT '', 48 | `defore_doro` VARCHAR(25) NULL COMMENT '', 49 | `sigungu_gunmul` VARCHAR(200) NULL COMMENT '', 50 | `gongdong` CHAR(1) NULL COMMENT '0:비공동주택, 1:공동주택', 51 | `gicho_no` CHAR(5) NULL COMMENT '', 52 | `juso_sang` CHAR(1) NULL COMMENT '0:미부여, 1:부여', 53 | `bigo1` VARCHAR(15) NULL COMMENT '', 54 | `bigo2` VARCHAR(15) NULL COMMENT '', 55 | PRIMARY KEY (`gunmul_no`) COMMENT '') 56 | ENGINE = InnoDB; 57 | 58 | CREATE INDEX `IDX_SIGUNGU` ON `egov_common`.`doro_juso` (`sigungu` ASC) COMMENT ''; 59 | 60 | CREATE INDEX `IDX_DONG` ON `egov_common`.`doro_juso` (`eupmyundong` ASC) COMMENT ''; 61 | 62 | CREATE INDEX `IDX_DORO` ON `egov_common`.`doro_juso` (`doro` ASC) COMMENT ''; 63 | 64 | 65 | SET SQL_MODE=@OLD_SQL_MODE; 66 | SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; 67 | SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; 68 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/controller/DoroJusoController.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.controller; 2 | 3 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoException; 4 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJuso; 5 | import org.openpaas.egovframework.comcomponent.dorojuso.service.DoroJusoService; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.http.MediaType; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.RequestParam; 15 | import org.springframework.web.bind.annotation.ResponseBody; 16 | 17 | /** 18 | * 도로주소 검색 Contoller 19 | * 일반 사용자가 도로주소를 검색할때 사용하는 부분임 20 | * 21 | * @author 안찬영 22 | * 23 | * History 24 | * 2015.7.14 도로명주소 검색 개발 25 | */ 26 | @Controller 27 | public class DoroJusoController extends BaseController { 28 | 29 | private static final Logger logger = LoggerFactory.getLogger(DoroJusoController.class); 30 | 31 | @Autowired 32 | private DoroJusoService service; 33 | 34 | @Autowired 35 | public DoroJusoController(DoroJusoService service) { 36 | this.service = service; 37 | } 38 | 39 | /** 40 | * OPTION으로 요청이 왔을 때의 처리 41 | * API 플랫폼에서 해당 API의 유효성검증등으로 사용하고 있음 42 | * 43 | * @param currentPage 44 | * @param countPerPage 45 | * @param keyword 46 | * @return 47 | * @throws DoroJusoException 48 | */ 49 | @RequestMapping(value = "/addrlink/addrLinkApi.do", method = RequestMethod.OPTIONS) 50 | public @ResponseBody DoroJuso getDoroJusoOption(@RequestParam(value="currentPage") int currentPage, 51 | @RequestParam(value="countPerPage") int countPerPage, 52 | @RequestParam(value="keyword") String keyword) throws DoroJusoException { 53 | 54 | logger.debug("OPTION: /addrlink/addrLinkApi.do "); 55 | logger.debug("currentPage:" + currentPage); 56 | logger.debug("countPerPage:" + countPerPage); 57 | logger.debug("keyword:" + keyword); 58 | 59 | return new DoroJuso(); 60 | } 61 | 62 | /** 63 | * 도로명 주소를 호출하는 API (json과 xml을 지원함) 64 | * 65 | * @param currentPage 현재 패이지 66 | * @param countPerPage 패이지내 갯수 67 | * @param keyword 검색어 68 | * @return 도로명 주소 리스트 69 | * @throws DoroJusoException 70 | */ 71 | @RequestMapping(value = "/addrlink/addrLinkApi.do", method = RequestMethod.GET, produces = {"application/json", "application/xml"}) 72 | public @ResponseBody DoroJuso getDoroJuso(@RequestParam(value="currentPage") int currentPage, 73 | @RequestParam(value="countPerPage") int countPerPage, 74 | @RequestParam(value="keyword") String keyword) throws DoroJusoException { 75 | 76 | logger.debug("GET: /addrlink/addrLinkApi.do "); 77 | logger.debug("currentPage:" + currentPage); 78 | logger.debug("countPerPage:" + countPerPage); 79 | logger.debug("keyword:" + keyword); 80 | 81 | return service.getDoroJuso(currentPage, countPerPage, keyword); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/controller/BaseController.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.controller; 2 | 3 | import javax.servlet.http.HttpServletResponse; 4 | 5 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoDoesNotExistException; 6 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoExistsException; 7 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoBadRequestException; 8 | import org.openpaas.egovframework.comcomponent.dorojuso.model.ResultMessage; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.http.HttpStatus; 12 | import org.springframework.http.ResponseEntity; 13 | import org.springframework.http.converter.HttpMessageNotReadableException; 14 | import org.springframework.validation.BindingResult; 15 | import org.springframework.validation.FieldError; 16 | import org.springframework.web.bind.MethodArgumentNotValidException; 17 | import org.springframework.web.bind.annotation.ExceptionHandler; 18 | import org.springframework.web.bind.annotation.ResponseBody; 19 | 20 | /** 21 | * Controller 들의 상위 Controller로 공통으로 사용하는 Exception, error 핸들링을 정의함. 22 | * 23 | * History 24 | * 2015.7.1 최초 Framework 구성시 작업 25 | */ 26 | public class BaseController { 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(BaseController.class); 29 | 30 | /** 31 | * Insert시 도로 주소가 존재할때의 Exception 32 | * 33 | * @param ex 34 | * @param response 35 | * @return 36 | */ 37 | @ExceptionHandler(DoroJusoExistsException.class) 38 | @ResponseBody 39 | public ResponseEntity handleException( 40 | DoroJusoExistsException ex, 41 | HttpServletResponse response) { 42 | return getErrorResponse(ex.getMessage(), HttpStatus.CONFLICT); 43 | } 44 | 45 | /** 46 | * Delete, Update시 도로주소가 존재하지 않을 경우의 Exception 47 | * 48 | * @param ex 49 | * @param response 50 | * @return 51 | */ 52 | @ExceptionHandler(DoroJusoDoesNotExistException.class) 53 | @ResponseBody 54 | public ResponseEntity handleException( 55 | DoroJusoDoesNotExistException ex, 56 | HttpServletResponse response) { 57 | return getErrorResponse(ex.getMessage(), HttpStatus.NOT_FOUND); 58 | } 59 | 60 | /** 61 | * 도로주소 Insert, Update시 정보가 잘못 요청되면 발생하는 Exception 62 | * 63 | * @param ex 64 | * @param response 65 | * @return 66 | */ 67 | @ExceptionHandler(DoroJusoBadRequestException.class) 68 | @ResponseBody 69 | public ResponseEntity handleException( 70 | DoroJusoBadRequestException ex, 71 | HttpServletResponse response) { 72 | return getErrorResponse(ex.getMessage(), HttpStatus.BAD_REQUEST); 73 | } 74 | 75 | /** 76 | * 일반적인 Exception으로 서버에서 발생되는 내부 오류등을 정의함. 77 | * 78 | * @param ex 79 | * @param response 80 | * @return 81 | */ 82 | @ExceptionHandler(Exception.class) 83 | @ResponseBody 84 | public ResponseEntity handleException( 85 | Exception ex, 86 | HttpServletResponse response) { 87 | logger.warn("Exception", ex); 88 | return getErrorResponse(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); 89 | } 90 | 91 | /** 92 | * 발생된 Exception을 Status Code를 설정하여 Response를 보냄 93 | * 94 | * @param message 95 | * @param status 96 | * @return 97 | */ 98 | public ResponseEntity getErrorResponse(String message, HttpStatus status) { 99 | return new ResponseEntity(new ResultMessage(message), 100 | status); 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/model/Juso.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.model; 2 | 3 | import javax.xml.bind.annotation.XmlAccessorType; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | 6 | import org.hibernate.validator.constraints.NotEmpty; 7 | 8 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonProperty; 11 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 12 | 13 | /** 14 | * 주소 객체 15 | * 16 | * @author 안찬영 17 | * 18 | * History 19 | * 2015.7.14 도로명주소 검색 개발 20 | */ 21 | @XmlRootElement 22 | //@XmlAccessorType(XmlAccessType.FIELD) 23 | @JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) 24 | @JsonIgnoreProperties(ignoreUnknown = true) 25 | public class Juso { 26 | 27 | /** 28 | * 도로 주소 (전체) 29 | */ 30 | @NotEmpty 31 | @JsonSerialize 32 | @JsonProperty("roadAddr") 33 | private String roadAddr; 34 | 35 | /** 36 | * 도로 주소 부분1 37 | */ 38 | @NotEmpty 39 | @JsonSerialize 40 | @JsonProperty("roadAddrPart1") 41 | private String roadAddrPart1; 42 | 43 | /** 44 | * 도로주소 부분2 45 | */ 46 | @NotEmpty 47 | @JsonSerialize 48 | @JsonProperty("roadAddrPart2") 49 | private String roadAddrPart2; 50 | 51 | /** 52 | * 지번 주소 53 | */ 54 | @JsonSerialize 55 | @JsonProperty("jibunAddr") 56 | private String jibunAddr; 57 | 58 | /** 59 | * 영문 도로 주소 60 | */ 61 | @NotEmpty 62 | @JsonSerialize 63 | @JsonProperty("engAddr") 64 | private String engAddr; 65 | 66 | /** 67 | * 우편번호 68 | */ 69 | @NotEmpty 70 | @JsonSerialize 71 | @JsonProperty("zipNo") 72 | private String zipNo; 73 | 74 | /** 75 | * 관리 코드 76 | */ 77 | @NotEmpty 78 | @JsonSerialize 79 | @JsonProperty("admCd") 80 | private String admCd; 81 | 82 | /** 83 | * 도로관리 번호 84 | */ 85 | @NotEmpty 86 | @JsonSerialize 87 | @JsonProperty("rnMgtSn") 88 | private String rnMgtSn; 89 | 90 | /** 91 | * 건물관리 번호(Primary Key) 92 | */ 93 | @NotEmpty 94 | @JsonSerialize 95 | @JsonProperty("bdMgtSn") 96 | private String bdMgtSn; 97 | 98 | @NotEmpty 99 | public String getRoadAddr() { 100 | return roadAddr; 101 | } 102 | 103 | public void setRoadAddr(String roadAddr) { 104 | this.roadAddr = roadAddr; 105 | } 106 | 107 | public String getRoadAddrPart1() { 108 | return roadAddrPart1; 109 | } 110 | 111 | public void setRoadAddrPart1(String roadAddrPart1) { 112 | this.roadAddrPart1 = roadAddrPart1; 113 | } 114 | 115 | public String getRoadAddrPart2() { 116 | return roadAddrPart2; 117 | } 118 | 119 | public void setRoadAddrPart2(String roadAddrPart2) { 120 | this.roadAddrPart2 = roadAddrPart2; 121 | } 122 | 123 | public String getJibunAddr() { 124 | return jibunAddr; 125 | } 126 | 127 | public void setJibunAddr(String jibunAddr) { 128 | this.jibunAddr = jibunAddr; 129 | } 130 | 131 | public String getEngAddr() { 132 | return engAddr; 133 | } 134 | 135 | public void setEngAddr(String engAddr) { 136 | this.engAddr = engAddr; 137 | } 138 | 139 | public String getZipNo() { 140 | return zipNo; 141 | } 142 | 143 | public void setZipNo(String zipNo) { 144 | this.zipNo = zipNo; 145 | } 146 | 147 | public String getAdmCd() { 148 | return admCd; 149 | } 150 | 151 | public void setAdmCd(String admCd) { 152 | this.admCd = admCd; 153 | } 154 | 155 | public String getRnMgtSn() { 156 | return rnMgtSn; 157 | } 158 | 159 | public void setRnMgtSn(String rnMgtSn) { 160 | this.rnMgtSn = rnMgtSn; 161 | } 162 | 163 | public String getBdMgtSn() { 164 | return bdMgtSn; 165 | } 166 | 167 | public void setBdMgtSn(String bdMgtSn) { 168 | this.bdMgtSn = bdMgtSn; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/model/Common.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.model; 2 | 3 | import javax.xml.bind.annotation.XmlRootElement; 4 | 5 | import org.hibernate.validator.constraints.NotEmpty; 6 | 7 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 8 | import com.fasterxml.jackson.annotation.JsonIgnore; 9 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 10 | import com.fasterxml.jackson.annotation.JsonProperty; 11 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 12 | 13 | /** 14 | * API 결과에서 공통으로 사용되는 부분 (성공여부, 오류코드 등) 15 | * 16 | * @author 안찬영 17 | * 18 | * History 19 | * 2015.7.14 도로명주소 검색 개발 20 | */ 21 | @XmlRootElement 22 | @JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) 23 | @JsonIgnoreProperties(ignoreUnknown = true) 24 | public class Common { 25 | 26 | /** 27 | * 정상 28 | */ 29 | @JsonIgnore 30 | public static String OK = "0"; // 정상 31 | /** 32 | * 정상 메세지 33 | */ 34 | @JsonIgnore 35 | public static String MSG_OK = "정상"; // 정상 36 | /** 37 | * 시스템 오류 38 | */ 39 | @JsonIgnore 40 | public static String ERR_SYSTEM = "-999"; // 시스템 에러 41 | /** 42 | * 시스템 오류 메세지 43 | */ 44 | @JsonIgnore 45 | public static String MSG_ERR_SYSTEM = "시스템에서 오류가 발생하였습니다."; // 시스템 에러 46 | 47 | /** 48 | * DoroJuso 기존 API에서 정의되어 있었으나 이번에서는 구현하지 않음. 49 | * API플랫폼에서 치리되는 부분임 50 | */ 51 | // API 플랫폼에서는 자체 오류메세제 전달 52 | // public static String ERR_AUTH = "E001"; // 승인되지 않은 Key 입니다. 53 | // API 플랫폼에서는 자체 오류메세제 전달 54 | // public static String ERR_SITE = "E002"; // 승인되지 않은 사이트 입니다. 55 | // API 플랫폼에서는 자체 오류메세제 전달 56 | // public static String ERR_PATH = "E003"; // 정상적인 경로로 접속하시기 바랍니다. 57 | /** 58 | * 최대값오류 59 | */ 60 | @JsonIgnore 61 | public static String ERR_MAX = "E004"; 62 | /** 63 | * 최대값 오류 메세지 64 | */ 65 | @JsonIgnore 66 | public static String MSG_ERR_MAX = "검색 결과는 최대 1000건 입니다. currentPage, countPerpage를 확인 하시기 바랍니다."; 67 | /** 68 | * 검색 결과가 많을 경우 오류 69 | */ 70 | @JsonIgnore 71 | public static String ERR_TOOMANY = "P001"; // 검색 결과가 너무 많습니다. 도로명 주소 또는 지번을 입력하세요. 72 | /** 73 | * 검색 결과가 많을 경우 오류 메세지 74 | */ 75 | @JsonIgnore 76 | public static String MSG_ERR_TOOMANY = "검색 결과가 너무 많습니다. 도로명 주소 또는 지번을 입력하세요."; 77 | 78 | /** 79 | * 전체 갯수 80 | */ 81 | @NotEmpty 82 | @JsonSerialize 83 | @JsonProperty("totalCount") 84 | private int totalCount; 85 | 86 | /** 87 | * 현재 페이지 88 | */ 89 | @NotEmpty 90 | @JsonSerialize 91 | @JsonProperty("currentPage") 92 | private int currentPage; 93 | 94 | /** 95 | * 페이지당 갯수 96 | */ 97 | @NotEmpty 98 | @JsonSerialize 99 | @JsonProperty("countPerPage") 100 | private int countPerPage; 101 | 102 | /** 103 | * 오류 코드 104 | */ 105 | @NotEmpty 106 | @JsonSerialize 107 | @JsonProperty("errorCode") 108 | private String errorCode; 109 | 110 | /** 111 | * 오류 메세지 112 | */ 113 | @NotEmpty 114 | @JsonSerialize 115 | @JsonProperty("errorMessage") 116 | private String errorMessage; 117 | 118 | public int getTotalCount() { 119 | return totalCount; 120 | } 121 | 122 | public void setTotalCount(int totalCount) { 123 | this.totalCount = totalCount; 124 | } 125 | 126 | public int getCurrentPage() { 127 | return currentPage; 128 | } 129 | 130 | public void setCurrentPage(int currentPage) { 131 | this.currentPage = currentPage; 132 | } 133 | 134 | public int getCountPerPage() { 135 | return countPerPage; 136 | } 137 | 138 | public void setCountPerPage(int countPerPage) { 139 | this.countPerPage = countPerPage; 140 | } 141 | 142 | public String getErrorCode() { 143 | return errorCode; 144 | } 145 | 146 | public void setErrorCode(String errorCode) { 147 | this.errorCode = errorCode; 148 | } 149 | 150 | public String getErrorMessage() { 151 | return errorMessage; 152 | } 153 | 154 | public void setErrorMessage(String errorMessage) { 155 | this.errorMessage = errorMessage; 156 | } 157 | 158 | 159 | 160 | } 161 | 162 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/service/DoroJusoService.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.openpaas.egovframework.comcomponent.dorojuso.common.StringUtils; 7 | import org.openpaas.egovframework.comcomponent.dorojuso.dao.DoroJusoDAO; 8 | import org.openpaas.egovframework.comcomponent.dorojuso.dao.impl.DoroJusoDAOImpl; 9 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoException; 10 | import org.openpaas.egovframework.comcomponent.dorojuso.model.Common; 11 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJuso; 12 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJusoInfo; 13 | import org.openpaas.egovframework.comcomponent.dorojuso.model.Juso; 14 | import org.slf4j.Logger; 15 | import org.slf4j.LoggerFactory; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.stereotype.Service; 18 | 19 | /** 20 | * 도로주소 조회 Service 21 | * 22 | * @author 안찬영 23 | * 24 | * History 25 | * 2015.7.14 도로명주소 검색 개발 26 | */ 27 | @Service 28 | public class DoroJusoService { 29 | 30 | private static final Logger logger = LoggerFactory.getLogger(DoroJusoService.class); 31 | 32 | @Autowired 33 | DoroJusoDAO doroJusoDao; 34 | 35 | private static int MAX_ADDRESS = 1000; 36 | 37 | /** 38 | * 도로 주소 정보 조회 39 | * 40 | * @param currentPage 현재 페이지 41 | * @param countPerPage 페이지당 정보 갯수 42 | * @param keyword 검색 키워드 43 | * @return 도로주소 정보 44 | * @throws DoroJusoException 서버 내부 오류 45 | */ 46 | public DoroJuso getDoroJuso(int currentPage, int countPerPage, String keyword) throws DoroJusoException { 47 | 48 | logger.debug("getDoroJuso service"); 49 | 50 | // 건수, 메세지 등 정보 51 | DoroJuso doroJuso = new DoroJuso(); 52 | List jusos = new ArrayList(); 53 | 54 | Common common = new Common(); 55 | common.setCurrentPage(currentPage); 56 | common.setCountPerPage(countPerPage); 57 | 58 | 59 | if (countPerPage > MAX_ADDRESS) { 60 | 61 | common.setErrorCode(Common.ERR_MAX); 62 | common.setErrorMessage(Common.MSG_ERR_MAX); 63 | 64 | } else { 65 | try { 66 | 67 | List doroJusos = doroJusoDao.getDoroJuso(currentPage, countPerPage, keyword); 68 | 69 | 70 | if (doroJusos.size() > MAX_ADDRESS) { 71 | 72 | common.setErrorCode(Common.ERR_TOOMANY); 73 | common.setErrorMessage(Common.MSG_ERR_TOOMANY); 74 | 75 | } else { 76 | 77 | for (DoroJusoInfo item: doroJusos) { 78 | 79 | Juso juso = new Juso(); 80 | 81 | // 전체 도로명 주소 82 | juso.setRoadAddr(item.getSido() + " " + item.getSigungu() + " " + item.getDoro() + " " + item.getBon() + " (" + item.getEupmyundong() + ")"); 83 | // 도로명 주소 84 | juso.setRoadAddrPart1(item.getSido() + " " + item.getSigungu() + " " + item.getDoro() + " " + item.getBon()); 85 | // 도로명주소 상세 86 | juso.setRoadAddrPart2("(" + item.getEupmyundong() + ")"); 87 | // 지번 88 | juso.setJibunAddr(item.getSido() + " " + item.getSigungu() + " " + item.getEupmyundong() + " " + item.getBunji() + "-" + item.getHo()); 89 | // 도로명주소 (영문) 90 | juso.setEngAddr(""); 91 | // 우편번호 92 | juso.setZipNo(StringUtils.changeZipCode(item.getZipcode())); 93 | // 행정구역코드 94 | juso.setAdmCd(item.getCode()); 95 | // 도로명코드 96 | juso.setRnMgtSn(item.getDoro_code()); 97 | // 건물관리번호 98 | juso.setBdMgtSn(item.getGunmul_no()); 99 | 100 | jusos.add(juso); 101 | 102 | } 103 | 104 | common.setTotalCount(doroJusos.size()); 105 | 106 | common.setErrorCode(Common.OK); 107 | common.setErrorMessage(Common.MSG_OK); 108 | } 109 | 110 | 111 | } catch (Exception ex) { 112 | 113 | common.setErrorCode(Common.ERR_SYSTEM); 114 | common.setErrorMessage(Common.MSG_ERR_SYSTEM); 115 | 116 | } 117 | 118 | } 119 | 120 | // Return 객체 만들기 121 | // 공토 부분 122 | doroJuso.setCommon(common); 123 | // 주소 정보 124 | doroJuso.setJuso(jusos); 125 | 126 | return doroJuso; 127 | } 128 | 129 | 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/service/DoroJusoManagerService.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.service; 2 | 3 | import java.util.List; 4 | 5 | import org.openpaas.egovframework.comcomponent.dorojuso.dao.DoroJusoDAO; 6 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoBadRequestException; 7 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoDoesNotExistException; 8 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoException; 9 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoExistsException; 10 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJusoInfo; 11 | import org.openpaas.egovframework.comcomponent.dorojuso.model.ResultMessage; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | 15 | /** 16 | * 도로주소 관리 Service 17 | * 18 | * @author 안찬영 19 | * 20 | * History 21 | * 2015.7.14 도로명주소 검색 개발 22 | */ 23 | @Service 24 | public class DoroJusoManagerService { 25 | 26 | @Autowired 27 | DoroJusoDAO dao; 28 | 29 | /** 30 | * 도로주소 정보 가져오기 31 | * 32 | * @param currentPage 현재 페이지 33 | * @param countPerPage 페이지당 갯수 34 | * @param keyword 검색 키워드 35 | * @return 도로주소 리스트 36 | * @throws DoroJusoException 내부 서버 오류 37 | */ 38 | public List getDoroJusoInfo(int currentPage, int countPerPage, String keyword) throws DoroJusoException { 39 | 40 | return dao.getDoroJuso(currentPage, countPerPage, keyword); 41 | } 42 | 43 | /** 44 | * 한개의 도로주소 조회 45 | * 46 | * @param gunmul_no 건물관리 번호 47 | * @return 도로주소 정보 48 | * @throws DoroJusoException 내부 서버 오류 49 | */ 50 | public DoroJusoInfo getDoroJusoInfoOne(String gunmul_no) throws DoroJusoException { 51 | 52 | return dao.getDoroJusoOne(gunmul_no); 53 | } 54 | 55 | /** 56 | * 도로주소 등록 57 | * 58 | * @param doroJusoInfo 도로주소 정보 59 | * @return 결과 메세지 60 | * @throws DoroJusoException 서버 내부 오류 61 | * @throws DoroJusoExistsException 도로주소가 존재할 경우 오류 62 | */ 63 | public ResultMessage insertDoroJusoInfo(DoroJusoInfo doroJusoInfo) throws DoroJusoException, DoroJusoExistsException { 64 | 65 | int count = dao.insertDoroJuso(doroJusoInfo); 66 | 67 | if (count < 1) { 68 | throw new DoroJusoException("Failed to insert a DoroJusoInfo. gumnul_no:"+ doroJusoInfo.getGunmul_no()); 69 | } 70 | 71 | return new ResultMessage("DoroJuso saved. gumnul_no:"+ doroJusoInfo.getGunmul_no()); 72 | } 73 | 74 | /** 75 | * 도로주소 정보 수정 76 | * 77 | * @param building_code 건물관리 번호 78 | * @param doroJusoInfo 도록 주소 정보 79 | * @return 결과 메세지 80 | * @throws DoroJusoBadRequestException 정보가 부정확할 경우 오류 81 | * @throws DoroJusoException 서버 내부 오류 82 | * @throws DoroJusoDoesNotExistException 존재하지 않는 도로정보일 경우 오류 83 | */ 84 | public ResultMessage updateDoroJusoInfo(String building_code, DoroJusoInfo doroJusoInfo) throws DoroJusoBadRequestException, DoroJusoException, DoroJusoDoesNotExistException { 85 | 86 | if (!building_code.equals(doroJusoInfo.getGunmul_no())) { 87 | throw new DoroJusoBadRequestException("Gunmul_no is not same PATH value. (PATH value:" + building_code + ", gumnul_no:" + doroJusoInfo.getGunmul_no() + ")"); 88 | } 89 | 90 | int count = dao.updateDoroJuso(doroJusoInfo); 91 | 92 | if (count < 1) { 93 | throw new DoroJusoException("Failed to update a DoroJusoInfo. gumnul_no:"+ doroJusoInfo.getGunmul_no()); 94 | } 95 | 96 | return new ResultMessage("DoroJuso updated. gunmul_no:" + doroJusoInfo.getGunmul_no()); 97 | } 98 | 99 | /** 100 | * 도로주소 삭제 101 | * 102 | * @param building_code 건물관리 번호 103 | * @return 결과 메세지 104 | * @throws DoroJusoException 서버 내부 오류 105 | * @throws DoroJusoDoesNotExistException 도로주소가 존재하지 않을 경우 오류 106 | */ 107 | public ResultMessage deleteDoroJusoInfo(String building_code) throws DoroJusoException, DoroJusoDoesNotExistException{ 108 | 109 | int count = dao.deleteDoroJuso(building_code); 110 | 111 | if (count < 1) { 112 | throw new DoroJusoException("Failed to delete a DoroJusoInfo. gumnul_no:"+ building_code); 113 | } 114 | 115 | return new ResultMessage("DoroJuso deleted. gunmul_no:" + building_code); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/test/java/org/openpaas/egovframework/comcomponent/dorojuso/controller/DoroJusoRestTest.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.controller; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.File; 6 | import java.io.FileInputStream; 7 | import java.io.FileNotFoundException; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.io.StringReader; 11 | import java.util.Properties; 12 | 13 | import javax.servlet.http.HttpServletResponse; 14 | import javax.xml.parsers.DocumentBuilder; 15 | import javax.xml.parsers.DocumentBuilderFactory; 16 | 17 | import org.junit.Before; 18 | import org.junit.BeforeClass; 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | import org.openpaas.egovframework.comcomponent.dorojuso.common.HttpClientUtils; 22 | import org.openpaas.egovframework.comcomponent.dorojuso.common.JsonUtils; 23 | import org.springframework.http.HttpEntity; 24 | import org.springframework.http.HttpHeaders; 25 | import org.springframework.http.HttpMethod; 26 | import org.springframework.http.HttpStatus; 27 | import org.springframework.http.MediaType; 28 | import org.springframework.http.ResponseEntity; 29 | import org.springframework.util.StringUtils; 30 | import org.w3c.dom.Document; 31 | import org.xml.sax.InputSource; 32 | 33 | import ch.qos.logback.core.net.server.Client; 34 | 35 | import com.fasterxml.jackson.databind.JsonNode; 36 | 37 | /** 38 | */ 39 | public class DoroJusoRestTest { 40 | 41 | private static Properties prop = new Properties(); 42 | 43 | @BeforeClass 44 | public static void init() { 45 | 46 | System.out.println("== Started test DoroJuso API =="); 47 | 48 | // Initialization 49 | // Get properties information 50 | String propFile = "test.properties"; 51 | 52 | InputStream inputStream = DoroJusoRestTest.class.getClassLoader().getResourceAsStream(propFile); 53 | 54 | try { 55 | prop.load(inputStream); 56 | } catch (IOException e) { 57 | // TODO Auto-generated catch block 58 | e.printStackTrace(); 59 | System.err.println(e); 60 | } 61 | 62 | } 63 | 64 | /** 65 | * JSON 형태로 조회 66 | * - JSON 파싱이 잘되는지 확인함 67 | */ 68 | @Test 69 | public void getDoroJusoTest_normalJSON() { 70 | 71 | System.out.println("Start - normal JSON"); 72 | 73 | HttpHeaders headers = new HttpHeaders(); 74 | headers.set("Accept", "application/json"); 75 | HttpEntity entity = new HttpEntity("", headers); 76 | ResponseEntity response = null; 77 | 78 | boolean bException = false; 79 | 80 | try { 81 | 82 | String url = prop.getProperty("test_base_protocol") + prop.getProperty("test_base_url") + prop.getProperty("dorojuso_path"); 83 | url += "?currentPage=10&countPerPage=10&keyword=강남대로10"; 84 | 85 | response = HttpClientUtils.send(url, entity, HttpMethod.GET); 86 | 87 | } catch (Exception ex) { 88 | 89 | assertFalse("exception:" + ex.getMessage(), true); 90 | bException = true; 91 | 92 | } 93 | 94 | 95 | if (!bException) { 96 | 97 | try { 98 | 99 | JsonNode json = JsonUtils.convertToJson(response); 100 | 101 | if (!json.get("common").get("errorCode").asText().equals("0")) { 102 | System.err.println("reponse is not ok."); 103 | bException = true; 104 | } 105 | 106 | } catch (Exception e) { 107 | assertFalse("exception (JSON convert):" + e.getMessage(), true); 108 | } 109 | 110 | if (!bException) assertTrue("OK", true); 111 | } 112 | 113 | 114 | System.out.println("End - normal JSON"); 115 | } 116 | 117 | 118 | /** 119 | * XML 형태로 조회 120 | * - XML 파싱이 잘되는지 확인함 121 | */ 122 | @Test 123 | public void getDoroJusoTest_normalXML() { 124 | 125 | System.out.println("Start - normal XML"); 126 | 127 | HttpHeaders headers = new HttpHeaders(); 128 | headers.set("Accept", "application/xml"); 129 | HttpEntity entity = new HttpEntity("", headers); 130 | ResponseEntity response = null; 131 | 132 | boolean bException = false; 133 | 134 | try { 135 | 136 | String url = prop.getProperty("test_base_protocol") + prop.getProperty("test_base_url") + prop.getProperty("dorojuso_path"); 137 | url += "?currentPage=10&countPerPage=10&keyword=강남대로10"; 138 | 139 | response = HttpClientUtils.send(url, entity, HttpMethod.GET); 140 | 141 | } catch (Exception ex) { 142 | 143 | assertFalse("exception:" + ex.getMessage(), true); 144 | bException = true; 145 | 146 | } 147 | 148 | 149 | if (!bException) { 150 | 151 | try { 152 | 153 | DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 154 | DocumentBuilder builder; 155 | 156 | builder = factory.newDocumentBuilder(); 157 | Document document = builder.parse(new InputSource(new StringReader(response.getBody()))); 158 | 159 | if (!document.getFirstChild().getNodeName().equals("common")) { 160 | System.err.println("reponse is not ok."); 161 | bException = true; 162 | } 163 | 164 | } catch (Exception e) { 165 | assertFalse("exception (XML convert):" + e.getMessage(), true); 166 | } 167 | 168 | if (!bException) assertTrue("OK", true); 169 | } 170 | 171 | 172 | System.out.println("End - normal XML"); 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/controller/DoroJusoManagerController.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.controller; 2 | 3 | 4 | import java.util.List; 5 | 6 | import javax.servlet.http.HttpServletResponse; 7 | import javax.validation.Valid; 8 | 9 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoBadRequestException; 10 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoDoesNotExistException; 11 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoException; 12 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoExistsException; 13 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJuso; 14 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJusoInfo; 15 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJusoInfoResult; 16 | import org.openpaas.egovframework.comcomponent.dorojuso.model.ResultMessage; 17 | import org.openpaas.egovframework.comcomponent.dorojuso.service.DoroJusoManagerService; 18 | import org.slf4j.Logger; 19 | import org.slf4j.LoggerFactory; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.http.HttpStatus; 22 | import org.springframework.http.ResponseEntity; 23 | import org.springframework.stereotype.Controller; 24 | import org.springframework.web.bind.annotation.ExceptionHandler; 25 | import org.springframework.web.bind.annotation.PathVariable; 26 | import org.springframework.web.bind.annotation.RequestBody; 27 | import org.springframework.web.bind.annotation.RequestMapping; 28 | import org.springframework.web.bind.annotation.RequestMethod; 29 | import org.springframework.web.bind.annotation.RequestParam; 30 | import org.springframework.web.bind.annotation.ResponseBody; 31 | 32 | /** 33 | * 도로명 주소 관리를 위한 Controller 34 | * 35 | * @author 안찬영 36 | * 37 | * History 38 | * 2015.7.14 도로명주소 검색 개발 39 | */ 40 | @Controller 41 | public class DoroJusoManagerController extends BaseController { 42 | 43 | private static final Logger logger = LoggerFactory.getLogger(DoroJusoManagerController.class); 44 | 45 | @Autowired 46 | private DoroJusoManagerService manager; 47 | 48 | /** 49 | * OPTIONS 요청에 대한 처리 50 | * 51 | */ 52 | @RequestMapping(value = "/dorojuso/manager/**", method = RequestMethod.OPTIONS) 53 | @ResponseBody 54 | public String getOptions() { 55 | logger.debug("Mnager OPTIONS : "); 56 | return ""; 57 | } 58 | 59 | /** 60 | * 도로명 주소 검색 (Path 방식) 61 | * 62 | * @param currentPage 현재 페이지 63 | * @param countPerPage 페이지내 주소 갯수 64 | * @param keyword 검색 키워드 65 | */ 66 | @RequestMapping(value = "/dorojuso/manager/{currentPage}/{countPerPage}/{keyword}", method = RequestMethod.GET) 67 | @ResponseBody 68 | public DoroJusoInfoResult getDoroJusoInfo( @PathVariable("currentPage") int currentPage, 69 | @PathVariable("countPerPage") int countPerPage, 70 | @PathVariable("keyword") String keyword ) throws DoroJusoException { 71 | 72 | logger.debug( "Manager GET: getDoroJuso"); 73 | 74 | List doros = manager.getDoroJusoInfo(currentPage, countPerPage, keyword); 75 | 76 | DoroJusoInfoResult jusos = new DoroJusoInfoResult(); 77 | jusos.setJuso(doros); 78 | 79 | return jusos; 80 | } 81 | 82 | /** 83 | * 도로명 주소 검색 (Parameter 방식) 84 | * 85 | * @param currentPage 현재 페이지 86 | * @param countPerPage 페이지내 주소 갯수 87 | * @param keyword 검색 키워드 88 | */ 89 | @RequestMapping(value = "/dorojuso/manager", method = RequestMethod.GET) 90 | @ResponseBody 91 | public DoroJusoInfoResult getDoroJusoInfoParam( @RequestParam(value="currentPage", required=false, defaultValue="10") int currentPage, 92 | @RequestParam(value="countPerPage", required=false, defaultValue="10") int countPerPage, 93 | @RequestParam(value="keyword", required=false) String keyword) throws DoroJusoException { 94 | 95 | logger.debug( "Manager GET: getDoroJuso"); 96 | 97 | List doros = manager.getDoroJusoInfo(currentPage, countPerPage, keyword); 98 | 99 | DoroJusoInfoResult jusos = new DoroJusoInfoResult(); 100 | jusos.setJuso(doros); 101 | 102 | return jusos; 103 | } 104 | 105 | /** 106 | * 한개의 도로명 주소 검색 107 | * 108 | * @param gunmul_no 건물관리번호(Key) 109 | * @return 도로주소 정보 110 | * @throws DoroJusoException 111 | */ 112 | @RequestMapping(value = "/dorojuso/manager/{gunmul_no}", method = RequestMethod.GET) 113 | @ResponseBody 114 | public DoroJusoInfo getDoroJusoInfoOne( @PathVariable("gunmul_no") String gunmul_no) throws DoroJusoException { 115 | 116 | logger.debug( "Manager GET: getDoroJuso"); 117 | 118 | DoroJusoInfo doro = manager.getDoroJusoInfoOne(gunmul_no); 119 | 120 | return doro; 121 | } 122 | 123 | /** 124 | * 도로주소 등록 125 | * 126 | * @param doroJusoInfo 도로주소 정보 127 | * @return 128 | * @throws DoroJusoException 서버문제 발생시 오류(DB연결등) 129 | * @throws DoroJusoExistsException 존재하는 주소일 경우 오류 130 | */ 131 | @RequestMapping(value = "/dorojuso/manager", method = RequestMethod.POST) 132 | @ResponseBody 133 | public ResultMessage insertDoroJusoInfo(@RequestBody DoroJusoInfo doroJusoInfo) throws DoroJusoException, DoroJusoExistsException { 134 | 135 | logger.debug( "Manager POST: insertDoroJusoInfo"); 136 | 137 | logger.info(doroJusoInfo.toString()); 138 | 139 | return manager.insertDoroJusoInfo(doroJusoInfo); 140 | } 141 | 142 | /** 143 | * 도로주소 정보 수정 144 | * 145 | * @param building_code 건물관리 번호 146 | * @param doroJusoInfo 도로 주소 정보 147 | * @return 148 | * @throws DoroJusoException 서버 내부 오류 149 | * @throws DoroJusoDoesNotExistException 존재하지 않는 도로주소일 경우 오류 150 | * @throws DoroJusoBadRequestException 요청한 정보의 속성에 문제가 있을 경우 151 | */ 152 | @RequestMapping(value = "/dorojuso/manager/{building_code}", method = RequestMethod.PUT) 153 | @ResponseBody 154 | public ResultMessage updateDoroJusoInfo( @PathVariable("building_code") String building_code, @RequestBody DoroJusoInfo doroJusoInfo ) throws DoroJusoException, DoroJusoDoesNotExistException, DoroJusoBadRequestException { 155 | 156 | logger.debug( "Manager PUT: updateDoroJusoInfo"); 157 | 158 | return manager.updateDoroJusoInfo(building_code, doroJusoInfo); 159 | } 160 | 161 | /** 162 | * 도로 주소 삭제 163 | * 164 | * @param building_code 건물관리 번호 165 | * @return 166 | * @throws DoroJusoException 서버 내부 오류 167 | * @throws DoroJusoDoesNotExistException 존재하지 않는 도로정보일 경우 오류 168 | */ 169 | @RequestMapping(value = "/dorojuso/manager/{building_code}", method = RequestMethod.DELETE) 170 | @ResponseBody 171 | public ResultMessage deleteDoroJusoInfo( @PathVariable("building_code") String building_code) throws DoroJusoException, DoroJusoDoesNotExistException { 172 | 173 | logger.debug( "Manager DELETE: deleteDoroJusoInfo"); 174 | 175 | return manager.deleteDoroJusoInfo(building_code); 176 | } 177 | 178 | } 179 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/dao/impl/DoroJusoDAOImpl.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.dao.impl; 2 | 3 | import java.sql.ResultSet; 4 | import java.sql.SQLException; 5 | import java.util.List; 6 | 7 | import javax.annotation.PostConstruct; 8 | import javax.sql.DataSource; 9 | 10 | import org.openpaas.egovframework.comcomponent.dorojuso.dao.DoroJusoDAO; 11 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoException; 12 | import org.openpaas.egovframework.comcomponent.dorojuso.exception.DoroJusoExistsException; 13 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJusoInfo; 14 | import org.slf4j.Logger; 15 | import org.slf4j.LoggerFactory; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.core.env.Environment; 18 | import org.springframework.dao.DuplicateKeyException; 19 | import org.springframework.stereotype.Repository; 20 | import org.springframework.jdbc.core.BeanPropertyRowMapper; 21 | import org.springframework.jdbc.core.JdbcTemplate; 22 | import org.springframework.jdbc.core.RowMapper; 23 | import org.springframework.jdbc.core.support.JdbcDaoSupport; 24 | 25 | /** 26 | * 도로정보 DAO 구현 27 | * 28 | * @author 안찬영 29 | * 30 | * History 31 | * 2015.7.14 도로명주소 검색 개발 32 | */ 33 | @Repository 34 | public class DoroJusoDAOImpl extends JdbcDaoSupport implements DoroJusoDAO { 35 | 36 | private static final Logger logger = LoggerFactory.getLogger(DoroJusoDAOImpl.class); 37 | 38 | @Autowired 39 | private DataSource dataSource; 40 | 41 | @PostConstruct 42 | private void initialize() { 43 | setDataSource(dataSource); 44 | } 45 | 46 | /** 47 | * 도로주소 리스트 조회 48 | */ 49 | public List getDoroJuso(int currentPage, int pageTotal, String keyword) { 50 | 51 | logger.info("getDoroJuso"); 52 | 53 | String sql = "SELECT * FROM doro_juso " + 54 | "WHERE sigungu LIKE '" + keyword + "%' OR eupmyundong LIKE '" + keyword + "%' OR doro LIKE '" + keyword + "%' " + 55 | "ORDER BY sido, sigungu, eupmyundong, doro ASC " + 56 | "LIMIT " + pageTotal + " offset " + currentPage; 57 | 58 | List doroJusos = getJdbcTemplate().query(sql, new BeanPropertyRowMapper(DoroJusoInfo.class)); 59 | 60 | logger.info("getDoroJuso finished : " + doroJusos.size()); 61 | 62 | return doroJusos; 63 | } 64 | 65 | /** 66 | * 도로 정보 하나 조회 67 | */ 68 | public DoroJusoInfo getDoroJusoOne(String gunmul_no) { 69 | 70 | logger.info("getDoroJusoOne"); 71 | 72 | String sql = "SELECT * FROM doro_juso " + 73 | "WHERE gunmul_no = '" + gunmul_no + "'"; 74 | 75 | List doroJusos = getJdbcTemplate().query(sql, new BeanPropertyRowMapper(DoroJusoInfo.class)); 76 | 77 | logger.info("getDoroJuso finished : " + doroJusos.size()); 78 | 79 | 80 | DoroJusoInfo doroInfo = new DoroJusoInfo(); 81 | 82 | if (doroJusos.size() > 0) { 83 | doroInfo = doroJusos.get(0); 84 | } 85 | 86 | return doroInfo; 87 | } 88 | 89 | /** 90 | * 도로 정보 등록 91 | */ 92 | public int insertDoroJuso(DoroJusoInfo doroJusoInfo) throws DoroJusoException, DoroJusoExistsException { 93 | 94 | logger.info("insertDoroJuso"); 95 | 96 | String sql = "INSERT INTO doro_juso (code, sido, sigungu, eupmyundong, ri, " 97 | + "san, bunji, ho, doro_code, doro, " 98 | + "jiha, bon, bu, gunmul, gunmul_sangse, " 99 | + "gunmul_no, eupmyundong_no, hang_code, hang, zipcode, " 100 | + "zipno, dayaeng, idong, update_date, defore_doro, " 101 | + "sigungu_gunmul, gongdong, gicho_no, juso_sang, bigo1, " 102 | + "bigo2) " 103 | + "VALUES " 104 | + "(?,?,?,?,?," 105 | + "?,?,?,?,?," 106 | + "?,?,?,?,?," 107 | + "?,?,?,?,?," 108 | + "?,?,?,?,?," 109 | + "?,?,?,?,?," 110 | + "?)"; 111 | 112 | int result = 0; 113 | 114 | try { 115 | result = getJdbcTemplate().update(sql, doroJusoInfo.getCode(), doroJusoInfo.getSido(), doroJusoInfo.getSigungu(), doroJusoInfo.getEupmyundong(), doroJusoInfo.getRi(), 116 | doroJusoInfo.getSan(), doroJusoInfo.getBunji(), doroJusoInfo.getHo(), doroJusoInfo.getDoro(), doroJusoInfo.getDoro(), 117 | doroJusoInfo.getJiha(), doroJusoInfo.getBon(), doroJusoInfo.getBu(), doroJusoInfo.getGunmul(), doroJusoInfo.getGunmul_sangse(), 118 | doroJusoInfo.getGunmul_no(), doroJusoInfo.getEupmyundong_no(), doroJusoInfo.getHang_code(), doroJusoInfo.getHang(), doroJusoInfo.getZipcode(), 119 | doroJusoInfo.getZipno(), doroJusoInfo.getDayaeng(), doroJusoInfo.getIdong(), doroJusoInfo.getUpdate_date(), doroJusoInfo.getDefore_doro(), 120 | doroJusoInfo.getSigungu_gunmul(), doroJusoInfo.getGongdong(), doroJusoInfo.getGicho_no(), doroJusoInfo.getJuso_sang(), doroJusoInfo.getBigo1(), 121 | doroJusoInfo.getBigo2() ); 122 | } catch (DuplicateKeyException ex) { 123 | throw new DoroJusoExistsException(ex.getMessage()); 124 | } 125 | 126 | return result; 127 | } 128 | 129 | /** 130 | * 도로 정보 수정 131 | */ 132 | public int updateDoroJuso(DoroJusoInfo doroJusoInfo) throws DoroJusoException { 133 | 134 | String sql = "UPDATE doro_juso " 135 | + "SET " 136 | + "code = ?, sido = ?, sigungu = ?, eupmyundong = ?, ri = ?, " 137 | + "san = ?, bunji = ?, ho = ?, doro_code = ?, doro = ?, " 138 | + "jiha = ?, bon = ?, bu = ?, gunmul = ?, gunmul_sangse = ?, " 139 | // + "gunmul_no, " 140 | + "eupmyundong_no = ?, hang_code = ?, hang = ?, zipcode = ?, " 141 | + "zipno = ?, dayaeng = ?, idong = ?, update_date = ?, defore_doro = ?, " 142 | + "sigungu_gunmul = ?, gongdong = ?, gicho_no = ?, juso_sang = ?, bigo1 = ?, " 143 | + "bigo2 = ? " 144 | + "WHERE gunmul_no = ?"; 145 | 146 | int result = 0; 147 | 148 | try { 149 | result = getJdbcTemplate().update(sql, doroJusoInfo.getCode(), doroJusoInfo.getSido(), doroJusoInfo.getSigungu(), doroJusoInfo.getEupmyundong(), doroJusoInfo.getRi(), 150 | doroJusoInfo.getSan(), doroJusoInfo.getBunji(), doroJusoInfo.getHo(), doroJusoInfo.getDoro(), doroJusoInfo.getDoro(), 151 | doroJusoInfo.getJiha(), doroJusoInfo.getBon(), doroJusoInfo.getBu(), doroJusoInfo.getGunmul(), doroJusoInfo.getGunmul_sangse(), 152 | // doroJusoInfo.getGunmul_no(), 153 | doroJusoInfo.getEupmyundong_no(), doroJusoInfo.getHang_code(), doroJusoInfo.getHang(), doroJusoInfo.getZipcode(), 154 | doroJusoInfo.getZipno(), doroJusoInfo.getDayaeng(), doroJusoInfo.getIdong(), doroJusoInfo.getUpdate_date(), doroJusoInfo.getDefore_doro(), 155 | doroJusoInfo.getSigungu_gunmul(), doroJusoInfo.getGongdong(), doroJusoInfo.getGicho_no(), doroJusoInfo.getJuso_sang(), doroJusoInfo.getBigo1(), 156 | doroJusoInfo.getBigo2(), 157 | doroJusoInfo.getGunmul_no()); 158 | } catch (Exception ex) { 159 | throw new DoroJusoException(ex.getMessage()); 160 | } 161 | 162 | return result; 163 | } 164 | 165 | /** 166 | * 도로정보 삭제 167 | */ 168 | public int deleteDoroJuso(String building_code) throws DoroJusoException{ 169 | 170 | String sql = "DELETE FROM doro_juso " 171 | + "WHERE gunmul_no = ?"; 172 | 173 | int result = 0; 174 | 175 | try { 176 | result = getJdbcTemplate().update(sql, building_code); 177 | } catch (Exception ex) { 178 | throw new DoroJusoException(ex.getMessage()); 179 | } 180 | 181 | return result; 182 | } 183 | 184 | } 185 | -------------------------------------------------------------------------------- /src/main/java/org/openpaas/egovframework/comcomponent/dorojuso/model/DoroJusoInfo.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | 6 | /** 7 | * 도로주소 DB 객체 8 | * @author 안찬영 9 | * 10 | * History 11 | * 2015.7.14 도로명주소 검색 개발 12 | */ 13 | //@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE) 14 | //@JsonIgnoreProperties(ignoreUnknown = true) 15 | public class DoroJusoInfo { 16 | 17 | /** 18 | * 법전동코드 19 | */ 20 | private String code; 21 | /** 22 | * 시도명 23 | */ 24 | private String sido; 25 | /** 26 | * 시군구명 27 | */ 28 | private String sigungu; 29 | /** 30 | * 법정읍면동명 31 | */ 32 | private String eupmyundong; 33 | /** 34 | * 법정리명 35 | */ 36 | private String ri; 37 | /** 38 | * 산여부 39 | */ 40 | private String san; 41 | /** 42 | * 지번본번(번지) 43 | */ 44 | private int bunji; 45 | /** 46 | * 지번부번(호) 47 | */ 48 | private int ho; 49 | /** 50 | * 도로명코드 51 | */ 52 | private String doro_code; 53 | /** 54 | * 도로명 55 | */ 56 | private String doro; 57 | /** 58 | * 지하여부 59 | */ 60 | private String jiha; 61 | /** 62 | * 건물본번 63 | */ 64 | private int bon; 65 | /** 66 | * 건물부번 67 | */ 68 | private int bu; 69 | /** 70 | * 건축물대장 건물명 71 | */ 72 | private String gunmul; 73 | /** 74 | * 상세건물명 75 | */ 76 | private String gunmul_sangse; 77 | /** 78 | * 건물관리번호 79 | */ 80 | private String gunmul_no; 81 | /** 82 | * 읍면동일련번호 83 | */ 84 | private int eupmyundong_no; 85 | /** 86 | * 행정동코드 87 | */ 88 | private String hang_code; 89 | /** 90 | * 행정동명 91 | */ 92 | private String hang; 93 | /** 94 | * 우편번호 95 | */ 96 | private String zipcode; 97 | /** 98 | * 우편일련번호 99 | */ 100 | private String zipno; 101 | /** 102 | * 다량배달처명 103 | */ 104 | private String dayaeng; 105 | /** 106 | * 이동사유코드 107 | */ 108 | private String idong; 109 | /** 110 | * 변경일자 111 | */ 112 | private String update_date; 113 | /** 114 | * 변경전도로명주소 115 | */ 116 | private String defore_doro; 117 | /** 118 | * 시군구용 건물명 119 | */ 120 | private String sigungu_gunmul; 121 | /** 122 | * 공동주택여부 123 | */ 124 | private String gongdong; 125 | /** 126 | * 기초구역번호 127 | */ 128 | private String gicho_no; 129 | /** 130 | * 상세주소여부 131 | */ 132 | private String juso_sang; 133 | /** 134 | * 비고1 135 | */ 136 | private String bigo1; 137 | /** 138 | * 비고2 139 | */ 140 | private String bigo2; 141 | 142 | public String getCode() { 143 | return code; 144 | } 145 | public void setCode(String code) { 146 | this.code = code; 147 | } 148 | public String getSido() { 149 | return sido; 150 | } 151 | public void setSido(String sido) { 152 | this.sido = sido; 153 | } 154 | public String getSigungu() { 155 | return sigungu; 156 | } 157 | public void setSigungu(String sigungu) { 158 | this.sigungu = sigungu; 159 | } 160 | public String getEupmyundong() { 161 | return eupmyundong; 162 | } 163 | public void setEupmyundong(String eupmyundong) { 164 | this.eupmyundong = eupmyundong; 165 | } 166 | public String getRi() { 167 | return ri; 168 | } 169 | public void setRi(String ri) { 170 | this.ri = ri; 171 | } 172 | public String getSan() { 173 | return san; 174 | } 175 | public void setSan(String san) { 176 | this.san = san; 177 | } 178 | public int getBunji() { 179 | return bunji; 180 | } 181 | public void setBunji(int bunji) { 182 | this.bunji = bunji; 183 | } 184 | public int getHo() { 185 | return ho; 186 | } 187 | public void setHo(int ho) { 188 | this.ho = ho; 189 | } 190 | public String getDoro_code() { 191 | return doro_code; 192 | } 193 | public void setDoro_code(String doro_code) { 194 | this.doro_code = doro_code; 195 | } 196 | public String getDoro() { 197 | return doro; 198 | } 199 | public void setDoro(String doro) { 200 | this.doro = doro; 201 | } 202 | public String getJiha() { 203 | return jiha; 204 | } 205 | public void setJiha(String jiha) { 206 | this.jiha = jiha; 207 | } 208 | public int getBon() { 209 | return bon; 210 | } 211 | public void setBon(int bon) { 212 | this.bon = bon; 213 | } 214 | public int getBu() { 215 | return bu; 216 | } 217 | public void setBu(int bu) { 218 | this.bu = bu; 219 | } 220 | public String getGunmul() { 221 | return gunmul; 222 | } 223 | public void setGunmul(String gunmul) { 224 | this.gunmul = gunmul; 225 | } 226 | public String getGunmul_sangse() { 227 | return gunmul_sangse; 228 | } 229 | public void setGunmul_sangse(String gunmul_sangse) { 230 | this.gunmul_sangse = gunmul_sangse; 231 | } 232 | public String getGunmul_no() { 233 | return gunmul_no; 234 | } 235 | public void setGunmul_no(String gunmul_no) { 236 | this.gunmul_no = gunmul_no; 237 | } 238 | public int getEupmyundong_no() { 239 | return eupmyundong_no; 240 | } 241 | public void setEupmyundong_no(int eupmyundong_no) { 242 | this.eupmyundong_no = eupmyundong_no; 243 | } 244 | public String getHang_code() { 245 | return hang_code; 246 | } 247 | public void setHang_code(String hang_code) { 248 | this.hang_code = hang_code; 249 | } 250 | public String getHang() { 251 | return hang; 252 | } 253 | public void setHang(String hang) { 254 | this.hang = hang; 255 | } 256 | public String getZipcode() { 257 | return zipcode; 258 | } 259 | public void setZipcode(String zipcode) { 260 | this.zipcode = zipcode; 261 | } 262 | public String getZipno() { 263 | return zipno; 264 | } 265 | public void setZipno(String zipno) { 266 | this.zipno = zipno; 267 | } 268 | public String getDayaeng() { 269 | return dayaeng; 270 | } 271 | public void setDayaeng(String dayaeng) { 272 | this.dayaeng = dayaeng; 273 | } 274 | public String getIdong() { 275 | return idong; 276 | } 277 | public void setIdong(String idong) { 278 | this.idong = idong; 279 | } 280 | public String getUpdate_date() { 281 | return update_date; 282 | } 283 | public void setUpdate_date(String update_date) { 284 | this.update_date = update_date; 285 | } 286 | public String getDefore_doro() { 287 | return defore_doro; 288 | } 289 | public void setDefore_doro(String defore_doro) { 290 | this.defore_doro = defore_doro; 291 | } 292 | public String getSigungu_gunmul() { 293 | return sigungu_gunmul; 294 | } 295 | public void setSigungu_gunmul(String sigungu_gunmul) { 296 | this.sigungu_gunmul = sigungu_gunmul; 297 | } 298 | public String getGongdong() { 299 | return gongdong; 300 | } 301 | public void setGongdong(String gongdong) { 302 | this.gongdong = gongdong; 303 | } 304 | public String getGicho_no() { 305 | return gicho_no; 306 | } 307 | public void setGicho_no(String gicho_no) { 308 | this.gicho_no = gicho_no; 309 | } 310 | public String getJuso_sang() { 311 | return juso_sang; 312 | } 313 | public void setJuso_sang(String juso_sang) { 314 | this.juso_sang = juso_sang; 315 | } 316 | public String getBigo1() { 317 | return bigo1; 318 | } 319 | public void setBigo1(String bigo1) { 320 | this.bigo1 = bigo1; 321 | } 322 | public String getBigo2() { 323 | return bigo2; 324 | } 325 | public void setBigo2(String bigo2) { 326 | this.bigo2 = bigo2; 327 | } 328 | 329 | 330 | @Override 331 | public String toString() { 332 | return "DoroJusoInfo [code=" + code + ", sido=" + sido + ", sigungu=" 333 | + sigungu + ", eupmyundong=" + eupmyundong + ", ri=" + ri 334 | + ", san=" + san + ", bunji=" + bunji + ", ho=" + ho 335 | + ", doro_code=" + doro_code + ", doro=" + doro + ", jiha=" 336 | + jiha + ", bon=" + bon + ", bu=" + bu + ", gunmul=" + gunmul 337 | + ", gunmul_sangse=" + gunmul_sangse + ", gunmul_no=" 338 | + gunmul_no + ", eupmyundong_no=" + eupmyundong_no 339 | + ", hang_code=" + hang_code + ", hang=" + hang + ", zipcode=" 340 | + zipcode + ", zipno=" + zipno + ", dayaeng=" + dayaeng 341 | + ", idong=" + idong + ", update_date=" + update_date 342 | + ", defore_doro=" + defore_doro + ", sigungu_gunmul=" 343 | + sigungu_gunmul + ", gongdong=" + gongdong + ", gicho_no=" 344 | + gicho_no + ", juso_sang=" + juso_sang + ", bigo1=" + bigo1 345 | + ", bigo2=" + bigo2 + ", getCode()=" + getCode() 346 | + ", getSido()=" + getSido() + ", getSigungu()=" + getSigungu() 347 | + ", getEupmyundong()=" + getEupmyundong() + ", getRi()=" 348 | + getRi() + ", getSan()=" + getSan() + ", getBunji()=" 349 | + getBunji() + ", getHo()=" + getHo() + ", getDoro_code()=" 350 | + getDoro_code() + ", getDoro()=" + getDoro() + ", getJiha()=" 351 | + getJiha() + ", getBon()=" + getBon() + ", getBu()=" + getBu() 352 | + ", getGunmul()=" + getGunmul() + ", getGunmul_sangse()=" 353 | + getGunmul_sangse() + ", getGunmul_no()=" + getGunmul_no() 354 | + ", getEupmyundong_no()=" + getEupmyundong_no() 355 | + ", getHang_code()=" + getHang_code() + ", getHang()=" 356 | + getHang() + ", getZipcode()=" + getZipcode() 357 | + ", getZipno()=" + getZipno() + ", getDayaeng()=" 358 | + getDayaeng() + ", getIdong()=" + getIdong() 359 | + ", getUpdate_date()=" + getUpdate_date() 360 | + ", getDefore_doro()=" + getDefore_doro() 361 | + ", getSigungu_gunmul()=" + getSigungu_gunmul() 362 | + ", getGongdong()=" + getGongdong() + ", getGicho_no()=" 363 | + getGicho_no() + ", getJuso_sang()=" + getJuso_sang() 364 | + ", getBigo1()=" + getBigo1() + ", getBigo2()=" + getBigo2() 365 | + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() 366 | + ", toString()=" + super.toString() + "]"; 367 | } 368 | 369 | } 370 | -------------------------------------------------------------------------------- /src/test/java/org/openpaas/egovframework/comcomponent/dorojuso/controller/DoroJusoManagerRestTest.java: -------------------------------------------------------------------------------- 1 | package org.openpaas.egovframework.comcomponent.dorojuso.controller; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.File; 6 | import java.io.FileInputStream; 7 | import java.io.FileNotFoundException; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.io.StringReader; 11 | import java.util.Properties; 12 | 13 | import javax.servlet.http.HttpServletResponse; 14 | import javax.xml.parsers.DocumentBuilder; 15 | import javax.xml.parsers.DocumentBuilderFactory; 16 | 17 | import org.junit.AfterClass; 18 | import org.junit.Before; 19 | import org.junit.BeforeClass; 20 | import org.junit.Test; 21 | import org.openpaas.egovframework.comcomponent.dorojuso.common.HttpClientUtils; 22 | import org.openpaas.egovframework.comcomponent.dorojuso.common.JsonUtils; 23 | import org.openpaas.egovframework.comcomponent.dorojuso.model.DoroJusoInfo; 24 | import org.springframework.http.HttpEntity; 25 | import org.springframework.http.HttpHeaders; 26 | import org.springframework.http.HttpMethod; 27 | import org.springframework.http.HttpStatus; 28 | import org.springframework.http.MediaType; 29 | import org.springframework.http.ResponseEntity; 30 | import org.springframework.util.StringUtils; 31 | import org.w3c.dom.Document; 32 | import org.xml.sax.InputSource; 33 | 34 | import ch.qos.logback.core.net.server.Client; 35 | 36 | import com.fasterxml.jackson.databind.JsonNode; 37 | 38 | /** 39 | */ 40 | public class DoroJusoManagerRestTest { 41 | 42 | private static Properties prop = new Properties(); 43 | 44 | @BeforeClass 45 | public static void init() { 46 | 47 | System.out.println("== Started test DoroJuso API =="); 48 | 49 | // Initialization 50 | // Get properties information 51 | String propFile = "test.properties"; 52 | 53 | InputStream inputStream = DoroJusoManagerRestTest.class.getClassLoader().getResourceAsStream(propFile); 54 | 55 | try { 56 | prop.load(inputStream); 57 | } catch (IOException e) { 58 | // TODO Auto-generated catch block 59 | e.printStackTrace(); 60 | System.err.println(e); 61 | } 62 | } 63 | 64 | private DoroJusoInfo makeSampleDoroJusoInfo() { 65 | 66 | DoroJusoInfo info = new DoroJusoInfo(); 67 | 68 | // init Test data 69 | info.setCode("1165010200"); 70 | info.setSido("서울특별시"); 71 | info.setSigungu("서초구"); 72 | info.setEupmyundong("양재동"); 73 | info.setRi(""); 74 | info.setSan("0"); 75 | info.setBunji(326); 76 | info.setHo(2); 77 | info.setDoro_code("116504163008"); 78 | info.setDoro("강남대로12길"); 79 | info.setJiha("0"); 80 | info.setBon(8); 81 | info.setBu(0); 82 | info.setGunmul("성경빌딩"); 83 | info.setGunmul_sangse(""); 84 | info.setGunmul_no(prop.getProperty("building_code")); // Primary Key 85 | info.setEupmyundong_no(1); 86 | info.setHang_code("1165065200"); 87 | info.setHang("양재2동"); 88 | info.setZipcode("137897"); 89 | info.setZipno("001"); 90 | info.setDayaeng(""); 91 | info.setIdong(""); 92 | info.setDefore_doro(""); 93 | info.setSigungu_gunmul("성경빌딩"); 94 | info.setGongdong("0"); 95 | info.setGicho_no("06779"); 96 | info.setJuso_sang("0"); 97 | info.setBigo1(""); 98 | info.setBigo2(""); 99 | 100 | return info; 101 | } 102 | 103 | @AfterClass 104 | public static void deleteTestData() { 105 | HttpHeaders headers = new HttpHeaders(); 106 | headers.set("Accept", "application/json"); 107 | 108 | HttpEntity entity = new HttpEntity("", headers); 109 | ResponseEntity response = null; 110 | 111 | boolean bException = false; 112 | 113 | try { 114 | 115 | String url = prop.getProperty("test_base_protocol") + prop.getProperty("test_base_url") + prop.getProperty("dorojuso_manager_path"); 116 | url += "/" + prop.getProperty("building_code"); 117 | 118 | response = HttpClientUtils.send(url, entity, HttpMethod.DELETE); 119 | 120 | } catch (Exception ex) { 121 | System.err.println("After class exception:" + ex.getMessage()); 122 | } 123 | } 124 | 125 | /** 126 | * 도로 주소 가져오기가 잘되는지 확인 127 | * - JSON 파싱이 잘되는지 확인함 128 | */ 129 | @Test 130 | public void getDoroJusoInfoTest_normalJSON() { 131 | 132 | System.out.println("Start - normal JSON"); 133 | 134 | HttpHeaders headers = new HttpHeaders(); 135 | headers.set("Accept", "application/json"); 136 | HttpEntity entity = new HttpEntity("", headers); 137 | ResponseEntity response = null; 138 | 139 | boolean bException = false; 140 | 141 | try { 142 | 143 | String url = prop.getProperty("test_base_protocol") + prop.getProperty("test_base_url") + prop.getProperty("dorojuso_manager_path"); 144 | url += "/10/10/강남대로10"; 145 | 146 | response = HttpClientUtils.send(url, entity, HttpMethod.GET); 147 | 148 | } catch (Exception ex) { 149 | 150 | assertFalse("exception:" + ex.getMessage(), true); 151 | bException = true; 152 | 153 | } 154 | 155 | if (!bException) { 156 | try { 157 | JsonNode json = JsonUtils.convertToJson(response); 158 | } catch (Exception e) { 159 | assertFalse("exception (JSON convert):" + e.getMessage(), true); 160 | bException = true; 161 | } 162 | } 163 | 164 | if (!bException) assertTrue("OK", true); 165 | 166 | System.out.println("End - normal JSON"); 167 | } 168 | 169 | /** 170 | * Insert가 잘되는 지 확인 171 | */ 172 | @Test 173 | public void insertDoroJusoInfoTest_normal() { 174 | 175 | System.out.println("Start - insert normal"); 176 | 177 | HttpHeaders headers = new HttpHeaders(); 178 | headers.set("Accept", "application/json"); 179 | 180 | HttpEntity entity = new HttpEntity(makeSampleDoroJusoInfo(), headers); 181 | ResponseEntity response = null; 182 | 183 | boolean bException = false; 184 | 185 | try { 186 | 187 | String url = prop.getProperty("test_base_protocol") + prop.getProperty("test_base_url") + prop.getProperty("dorojuso_manager_path"); 188 | 189 | response = HttpClientUtils.sendDoroJusoInfo(url, entity, HttpMethod.POST); 190 | 191 | if (response.getStatusCode() != HttpStatus.OK) { 192 | assertFalse("Error: status code is " + response.getStatusCode(), true); 193 | bException = true; 194 | } 195 | 196 | 197 | } catch (Exception ex) { 198 | 199 | assertFalse("exception:" + ex.getMessage(), true); 200 | bException = true; 201 | 202 | } 203 | 204 | if (!bException) assertTrue("OK", true); 205 | 206 | System.out.println("End - insert normal "); 207 | } 208 | 209 | /** 210 | * Insert가 잘되는 지 확인 211 | * - 중복된 것을 insert 할때 오류가 오는지 확인 212 | */ 213 | @Test 214 | public void insertDoroJusoInfoTest_exist() { 215 | 216 | System.out.println("Start - insert existed"); 217 | 218 | HttpHeaders headers = new HttpHeaders(); 219 | headers.set("Accept", "application/json"); 220 | 221 | // 존재하는 주소 222 | DoroJusoInfo insertInfo = makeSampleDoroJusoInfo(); 223 | insertInfo.setGunmul_no(prop.getProperty("building_code_exist")); 224 | 225 | HttpEntity entity = new HttpEntity(insertInfo, headers); 226 | ResponseEntity response = null; 227 | 228 | boolean bException = false; 229 | 230 | try { 231 | 232 | String url = prop.getProperty("test_base_protocol") + prop.getProperty("test_base_url") + prop.getProperty("dorojuso_manager_path"); 233 | 234 | response = HttpClientUtils.sendDoroJusoInfo(url, entity, HttpMethod.POST); 235 | 236 | System.out.println("Status:" + response.getStatusCode()); 237 | 238 | if (response.getStatusCode() == HttpStatus.CONFLICT) { 239 | bException = true; 240 | assertTrue("OK", true); 241 | } 242 | 243 | } catch (Exception ex) { 244 | System.err.println(ex.getMessage()); 245 | assertFalse("Exception", true); 246 | bException = true; 247 | } 248 | 249 | if (!bException) assertFalse("Error", true); 250 | 251 | System.out.println("End - insert existed"); 252 | } 253 | 254 | /** 255 | * Update가 잘되는 지 확인 256 | */ 257 | @Test 258 | public void updateDoroJusoInfoTest_normal() { 259 | 260 | System.out.println("Start - update normal"); 261 | 262 | HttpHeaders headers = new HttpHeaders(); 263 | headers.set("Accept", "application/json"); 264 | 265 | // 존재하는 주소 266 | DoroJusoInfo updateInfo = makeSampleDoroJusoInfo(); 267 | updateInfo.setBigo1("Updated"); 268 | 269 | HttpEntity entity = new HttpEntity(updateInfo, headers); 270 | ResponseEntity response = null; 271 | 272 | boolean bException = false; 273 | 274 | try { 275 | 276 | String url = prop.getProperty("test_base_protocol") + prop.getProperty("test_base_url") + prop.getProperty("dorojuso_manager_path"); 277 | url += "/" + updateInfo.getGunmul_no(); 278 | 279 | response = HttpClientUtils.sendDoroJusoInfo(url, entity, HttpMethod.PUT); 280 | 281 | System.out.println("Status:" + response.getStatusCode()); 282 | 283 | if (response.getStatusCode() != HttpStatus.OK) { 284 | assertFalse("Error:" + response.getStatusCode(), true); 285 | bException = true; 286 | } 287 | 288 | } catch (Exception ex) { 289 | System.err.println(ex.getMessage()); 290 | bException = true; 291 | } 292 | 293 | if (!bException) assertTrue("OK", true); 294 | 295 | System.out.println("End - update normal"); 296 | } 297 | 298 | /** 299 | * Update가 잘되는 지 확인 300 | * - 없는 코드를 update 할때 오류가 오는지 확인 301 | */ 302 | @Test 303 | public void updateDoroJusoInfoTest_noGunmulNo() { 304 | 305 | System.out.println("Start - update no gunmul_no"); 306 | 307 | HttpHeaders headers = new HttpHeaders(); 308 | headers.set("Accept", "application/json"); 309 | 310 | // 존재하는 주소 311 | DoroJusoInfo updateInfo = makeSampleDoroJusoInfo(); 312 | updateInfo.setBigo1("Updated"); 313 | updateInfo.setGunmul_no(prop.getProperty("building_code_fail")); 314 | 315 | HttpEntity entity = new HttpEntity(updateInfo, headers); 316 | ResponseEntity response = null; 317 | 318 | boolean bException = false; 319 | 320 | try { 321 | 322 | String url = prop.getProperty("test_base_protocol") + prop.getProperty("test_base_url") + prop.getProperty("dorojuso_manager_path"); 323 | url += "/" + updateInfo.getGunmul_no(); 324 | 325 | response = HttpClientUtils.sendDoroJusoInfo(url, entity, HttpMethod.PUT); 326 | 327 | System.out.println("Status:" + response.getStatusCode()); 328 | 329 | if (response.getStatusCode() == HttpStatus.INTERNAL_SERVER_ERROR) { 330 | bException = true; 331 | assertTrue("OK:" + response.getStatusCode(), true); 332 | } 333 | 334 | } catch (Exception ex) { 335 | System.err.println(ex.getMessage()); 336 | bException = true; 337 | } 338 | 339 | if (!bException) assertFalse("Error", true); 340 | 341 | System.out.println("End - update no gunmul no"); 342 | } 343 | 344 | /** 345 | * Update가 잘되는 지 확인 346 | * - 요청 builing code가 DoroJusoInfo 내의 코드와 다를 경우 347 | */ 348 | @Test 349 | public void updateDoroJusoInfoTest_diffGunmulNo() { 350 | 351 | System.out.println("Start - update difference gunmul_no"); 352 | 353 | HttpHeaders headers = new HttpHeaders(); 354 | headers.set("Accept", "application/json"); 355 | 356 | // 존재하는 주소 357 | DoroJusoInfo updateInfo = makeSampleDoroJusoInfo(); 358 | updateInfo.setBigo1("Updated"); 359 | 360 | HttpEntity entity = new HttpEntity(updateInfo, headers); 361 | ResponseEntity response = null; 362 | 363 | boolean bException = false; 364 | 365 | try { 366 | 367 | String url = prop.getProperty("test_base_protocol") + prop.getProperty("test_base_url") + prop.getProperty("dorojuso_manager_path"); 368 | url += "/" + prop.getProperty("building_code_fail"); 369 | 370 | response = HttpClientUtils.sendDoroJusoInfo(url, entity, HttpMethod.PUT); 371 | 372 | System.out.println("Status:" + response.getStatusCode()); 373 | 374 | if (response.getStatusCode() == HttpStatus.BAD_REQUEST) { 375 | assertTrue("OK:" + response.getStatusCode(), true); 376 | bException = true; 377 | } 378 | 379 | } catch (Exception ex) { 380 | System.err.println(ex.getMessage()); 381 | bException = true; 382 | } 383 | 384 | if (!bException) assertFalse("OK", true); 385 | 386 | System.out.println("End - update difference gunmul no"); 387 | } 388 | 389 | /** 390 | * Delete가 잘되는 지 확인 (Insert에서 만든 정보) 391 | * 392 | * 이 테스트는 본 Unit 테스크가 종료되는 시점에 AfterClass로 테스트 데이터를 주우고 있어 에러가 없으면 통과하는 것으로 간주합니다. 393 | */ 394 | // @Test 395 | public void deleteDoroJusoInfoTest_normal() { 396 | 397 | System.out.println("Start - delete normal"); 398 | 399 | HttpHeaders headers = new HttpHeaders(); 400 | headers.set("Accept", "application/json"); 401 | 402 | // 존재하는 주소 403 | HttpEntity entity = new HttpEntity("", headers); 404 | ResponseEntity response = null; 405 | 406 | boolean bException = false; 407 | 408 | try { 409 | 410 | String url = prop.getProperty("test_base_protocol") + prop.getProperty("test_base_url") + prop.getProperty("dorojuso_manager_path"); 411 | url += "/" + prop.getProperty("building_code"); 412 | 413 | response = HttpClientUtils.send(url, entity, HttpMethod.DELETE); 414 | 415 | System.out.println("Status:" + response.getStatusCode()); 416 | 417 | if (response.getStatusCode() != HttpStatus.OK) { 418 | assertFalse("Error:" + response.getStatusCode(), true); 419 | bException = true; 420 | } 421 | 422 | } catch (Exception ex) { 423 | System.err.println(ex.getMessage()); 424 | bException = true; 425 | } 426 | 427 | if (!bException) assertTrue("OK", true); 428 | 429 | System.out.println("End - delete normal"); 430 | } 431 | 432 | /** 433 | * Delete가 잘되는 지 확인 434 | * - 없는 코드를 delete 할때 오류가 오는지 확인 435 | */ 436 | @Test 437 | public void deleteDoroJusoInfoTest_noGunmulNo() { 438 | 439 | System.out.println("Start - delete normal"); 440 | 441 | HttpHeaders headers = new HttpHeaders(); 442 | headers.set("Accept", "application/json"); 443 | 444 | // 존재하는 주소 445 | HttpEntity entity = new HttpEntity("", headers); 446 | ResponseEntity response = null; 447 | 448 | boolean bException = false; 449 | 450 | try { 451 | 452 | String url = prop.getProperty("test_base_protocol") + prop.getProperty("test_base_url") + prop.getProperty("dorojuso_manager_path"); 453 | url += "/" + prop.getProperty("building_code_fail"); 454 | 455 | response = HttpClientUtils.send(url, entity, HttpMethod.DELETE); 456 | 457 | System.out.println("Status:" + response.getStatusCode()); 458 | 459 | if (response.getStatusCode() != HttpStatus.OK) { 460 | assertFalse("Error:" + response.getStatusCode(), true); 461 | bException = true; 462 | } 463 | 464 | } catch (Exception ex) { 465 | System.err.println(ex.getMessage()); 466 | bException = true; 467 | } 468 | 469 | if (!bException) assertTrue("OK", true); 470 | 471 | System.out.println("End - delete normal"); 472 | } 473 | 474 | } 475 | --------------------------------------------------------------------------------