Initial commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package org.egovframe.cloud.reservechecksevice;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ReserveCheckSeviceApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.egovframe.cloud.reservechecksevice.api;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@EnableConfigurationProperties
|
||||
@TestPropertySource(properties = {"spring.config.location=classpath:application-test.yml"})
|
||||
@ActiveProfiles(profiles = "test")
|
||||
class ReserveApiControllerTest {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.egovframe.cloud.reservechecksevice.config;
|
||||
|
||||
import io.r2dbc.h2.H2ConnectionConfiguration;
|
||||
import io.r2dbc.h2.H2ConnectionFactory;
|
||||
import io.r2dbc.h2.H2ConnectionOption;
|
||||
import io.r2dbc.spi.ConnectionFactory;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
|
||||
import org.springframework.r2dbc.connection.init.CompositeDatabasePopulator;
|
||||
import org.springframework.r2dbc.connection.init.ConnectionFactoryInitializer;
|
||||
import org.springframework.r2dbc.connection.init.ResourceDatabasePopulator;
|
||||
|
||||
@Profile("test")
|
||||
@TestConfiguration
|
||||
@EnableR2dbcRepositories
|
||||
public class R2dbcConfig {
|
||||
@Bean
|
||||
public H2ConnectionFactory connectionFactory() {
|
||||
return new H2ConnectionFactory(H2ConnectionConfiguration.builder()
|
||||
.tcp("localhost", "~/querydsl")
|
||||
.property(H2ConnectionOption.DB_CLOSE_DELAY, "-1")
|
||||
.username("sa")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ConnectionFactoryInitializer initializer(ConnectionFactory connectionFactory) {
|
||||
ConnectionFactoryInitializer initializer = new ConnectionFactoryInitializer();
|
||||
initializer.setConnectionFactory(connectionFactory);
|
||||
CompositeDatabasePopulator populator = new CompositeDatabasePopulator();
|
||||
populator.addPopulators(new ResourceDatabasePopulator(new ClassPathResource("schema-h2.sql")));
|
||||
initializer.setDatabasePopulator(populator);
|
||||
|
||||
return initializer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package org.egovframe.cloud.reservechecksevice.util;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* org.egovframe.cloud.boardservice.util.RestResponsePage
|
||||
* <p>
|
||||
* 페이지 API 조회 시 JSON 형식의 응답 데이터를 페이지 객체를 구현하여 마이그레이션 해주는 클래스
|
||||
*
|
||||
* @author 표준프레임워크센터 jooho
|
||||
* @version 1.0
|
||||
* @since 2021/07/08
|
||||
*
|
||||
* <pre>
|
||||
* << 개정이력(Modification Information) >>
|
||||
*
|
||||
* 수정일 수정자 수정내용
|
||||
* ---------- -------- ---------------------------
|
||||
* 2021/07/08 jooho 최초 생성
|
||||
* </pre>
|
||||
*/
|
||||
public class RestResponsePage<T> extends PageImpl<T> {
|
||||
|
||||
/**
|
||||
* Rest 응답 페이지 생성자
|
||||
*
|
||||
* @param content 목록
|
||||
* @param number 페이지 번호
|
||||
* @param size 조회할 데이터 수
|
||||
* @param totalElements 총 데이터 수
|
||||
* @param pageable 페이지 정보
|
||||
* @param last 마지막
|
||||
* @param totalPages 총 페이지
|
||||
* @param sort 정렬
|
||||
* @param first 처음
|
||||
* @param numberOfElements 조회된 데이터 수
|
||||
*/
|
||||
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
|
||||
public RestResponsePage(@JsonProperty("content") List<T> content,
|
||||
@JsonProperty("number") int number,
|
||||
@JsonProperty("size") int size,
|
||||
@JsonProperty("totalElements") Long totalElements,
|
||||
@JsonProperty("pageable") JsonNode pageable,
|
||||
@JsonProperty("last") boolean last,
|
||||
@JsonProperty("totalPages") int totalPages,
|
||||
@JsonProperty("sort") JsonNode sort,
|
||||
@JsonProperty("first") boolean first,
|
||||
@JsonProperty("numberOfElements") int numberOfElements) {
|
||||
super(content, PageRequest.of(number, size), totalElements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rest 응답 페이지 생성자
|
||||
*
|
||||
* @param content 목록
|
||||
* @param pageable 페이지 정보
|
||||
* @param total 총 데이터 수
|
||||
*/
|
||||
public RestResponsePage(List<T> content, Pageable pageable, long total) {
|
||||
super(content, pageable, total);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rest 응답 페이지 생성자
|
||||
*
|
||||
* @param content 목록
|
||||
*/
|
||||
public RestResponsePage(List<T> content) {
|
||||
super(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rest 응답 페이지 생성자
|
||||
*/
|
||||
public RestResponsePage() {
|
||||
super(Collections.emptyList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.egovframe.cloud.reservechecksevice.util;
|
||||
|
||||
import org.egovframe.cloud.common.domain.Role;
|
||||
import org.springframework.security.test.context.support.WithSecurityContext;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@WithSecurityContext(factory = WithMockCustomUserSecurityContextFactory.class)
|
||||
public @interface WithCustomMockUser {
|
||||
|
||||
String userId() default "user";
|
||||
Role role() default Role.ADMIN;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.egovframe.cloud.reservechecksevice.util;
|
||||
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.test.context.support.WithSecurityContextFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WithMockCustomUserSecurityContextFactory implements WithSecurityContextFactory<WithCustomMockUser> {
|
||||
|
||||
@Override
|
||||
public SecurityContext createSecurityContext(WithCustomMockUser mockUser) {
|
||||
SecurityContext context = SecurityContextHolder.createEmptyContext();
|
||||
List<SimpleGrantedAuthority> roleList = new ArrayList<>();
|
||||
roleList.add(new SimpleGrantedAuthority(mockUser.role().getKey()));
|
||||
UsernamePasswordAuthenticationToken authenticationToken =
|
||||
new UsernamePasswordAuthenticationToken(mockUser.userId(), null, roleList);
|
||||
context.setAuthentication(authenticationToken);
|
||||
|
||||
return context;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
spring:
|
||||
application:
|
||||
name: reserve-check-service
|
||||
|
||||
datasource:
|
||||
url: jdbc:h2:mem:testdb;MODE=MYSQL;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false
|
||||
username: sa
|
||||
password:
|
||||
driver-class-name: org.h2.Driver
|
||||
jpa:
|
||||
hibernate:
|
||||
generate-ddl: true
|
||||
ddl-auto: create-drop
|
||||
properties:
|
||||
hibernate:
|
||||
format_sql: true
|
||||
default_batch_fetch_size: 1000
|
||||
show-sql: true
|
||||
h2:
|
||||
console:
|
||||
enabled: true
|
||||
path: /h2
|
||||
|
||||
logging.level:
|
||||
org.hibernate.SQL: debug
|
||||
|
||||
file:
|
||||
directory: ${user.home}/msa-attach-volume
|
||||
messages:
|
||||
directory: ${file.directory}/messages
|
||||
|
||||
# jwt token
|
||||
token:
|
||||
secret: egovframe_user_token
|
||||
|
||||
# ftp server
|
||||
ftp:
|
||||
enabled: false # ftp 사용 여부, FTP 서버에 최상위 디렉토리 자동 생성 및 구현체를 결정하게 된다.
|
||||
|
||||
# eureka 가 포함되면 eureka server 도 등록되므로 해제한다.
|
||||
eureka:
|
||||
client:
|
||||
register-with-eureka: false
|
||||
fetch-registry: false
|
||||
@@ -0,0 +1,5 @@
|
||||
spring:
|
||||
cloud:
|
||||
config:
|
||||
uri: http://localhost:8888
|
||||
name: reserve-check-service
|
||||
@@ -0,0 +1,81 @@
|
||||
-- location Table Create SQL
|
||||
CREATE TABLE IF NOT EXISTS location
|
||||
(
|
||||
location_id BIGINT NOT NULL AUTO_INCREMENT COMMENT '지역 id',
|
||||
location_name VARCHAR(200) NULL COMMENT '지역 이름',
|
||||
sort_seq SMALLINT(3) NULL COMMENT '정렬 순서',
|
||||
use_at TINYINT(1) NULL DEFAULT 1 COMMENT '사용 여부',
|
||||
created_by VARCHAR(255) NULL COMMENT '생성자',
|
||||
create_date DATETIME NULL COMMENT '생성일',
|
||||
last_modified_by VARCHAR(255) NULL COMMENT '수정자',
|
||||
modified_date DATETIME NULL COMMENT '수정일',
|
||||
PRIMARY KEY (location_id)
|
||||
) ;
|
||||
|
||||
|
||||
|
||||
-- reserve_item Table Create SQL
|
||||
CREATE TABLE IF NOT EXISTS reserve_item
|
||||
(
|
||||
reserve_item_id BIGINT NOT NULL AUTO_INCREMENT COMMENT '예약 물품 id',
|
||||
reserve_item_name VARCHAR(200) NULL COMMENT '예약 물품 이름',
|
||||
location_id BIGINT NULL COMMENT '지역 id',
|
||||
category_id VARCHAR(20) NULL COMMENT '예약유형 - 공통코드 reserve-category',
|
||||
total_qty BIGINT(18) NULL COMMENT '총 재고/수용인원 수',
|
||||
inventory_qty BIGINT(18) NULL COMMENT '현재 남은 재고/수용인원 수',
|
||||
operation_start_date DATETIME NULL COMMENT '운영 시작 일',
|
||||
operation_end_date DATETIME NULL COMMENT '운영 종료 일',
|
||||
reserve_method_id VARCHAR(20) NULL COMMENT '예약 방법 - 공통코드 reserve-method',
|
||||
reserve_means_id VARCHAR(20) NULL COMMENT '예약 구분 (인터넷 예약 시) - 공통코드 reserve-means',
|
||||
request_start_date DATETIME NULL COMMENT '예약 신청 시작 일시',
|
||||
request_end_date DATETIME NULL COMMENT '예약 신청 종료 일시',
|
||||
period_at TINYINT(1) NULL DEFAULT 0 COMMENT '기간 지정 가능 여부 - true: 지정 가능, false: 지정 불가',
|
||||
period_max_count SMALLINT(3) NULL COMMENT '최대 예약 가능 일 수',
|
||||
external_url VARCHAR(500) NULL COMMENT '외부링크',
|
||||
selection_means_id VARCHAR(20) NULL COMMENT '선별 방법 - 공통코드 reserve-selection-means',
|
||||
free_at TINYINT(1) NULL DEFAULT 1 COMMENT '유/무료 - true: 무료, false: 유료',
|
||||
usage_cost DECIMAL(18, 0) NULL COMMENT '이용 요금',
|
||||
use_at TINYINT(1) NULL DEFAULT 1 COMMENT '사용 여부',
|
||||
purpose_content VARCHAR(4000) NULL COMMENT '용도',
|
||||
item_addr VARCHAR(500) NULL COMMENT '주소',
|
||||
target_id VARCHAR(20) NULL COMMENT '이용 대상 - 공통코드 reserve-target',
|
||||
excluded_content VARCHAR(2000) NULL COMMENT '사용허가 제외대상',
|
||||
homepage_url VARCHAR(500) NULL COMMENT '홈페이지 url',
|
||||
contact_no VARCHAR(50) NULL COMMENT '문의처',
|
||||
manager_dept_name VARCHAR(200) NULL COMMENT '담당자 소속',
|
||||
manager_name VARCHAR(200) NULL COMMENT '담당자 이름',
|
||||
manager_contact_no VARCHAR(50) NULL COMMENT '담당자 연락처',
|
||||
create_date DATETIME NULL COMMENT '생성일',
|
||||
created_by VARCHAR(255) NULL COMMENT '생성자',
|
||||
modified_date DATETIME NULL COMMENT '수정일',
|
||||
last_modified_by VARCHAR(255) NULL COMMENT '수정자',
|
||||
PRIMARY KEY (reserve_item_id),
|
||||
CONSTRAINT FK_reserve_item_location_id FOREIGN KEY (location_id)
|
||||
REFERENCES location (location_id) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ;
|
||||
|
||||
|
||||
|
||||
-- reserve Table Create SQL
|
||||
CREATE TABLE IF NOT EXISTS reserve
|
||||
(
|
||||
reserve_id BIGINT NOT NULL AUTO_INCREMENT COMMENT '예약 id',
|
||||
reserve_item_id BIGINT NULL COMMENT '예약 물품 id',
|
||||
reserve_qty BIGINT(18) NULL COMMENT '예약 신청인원/수량',
|
||||
reserve_purpose_content VARCHAR(4000) NULL COMMENT '예약신청 목적',
|
||||
attachment_code VARCHAR(255) NULL COMMENT '첨부파일 코드',
|
||||
reserve_start_date DATETIME NULL COMMENT '예약 신청 시작일',
|
||||
reserve_end_date DATETIME NULL COMMENT '예약 신청 종료일',
|
||||
reserve_status_id VARCHAR(20) NULL COMMENT '예약상태 - 공통코드(reserve-status)',
|
||||
user_id VARCHAR(255) NULL COMMENT '예약자 id',
|
||||
user_contact_no VARCHAR(50) NULL COMMENT '예약자 연락처',
|
||||
user_email_addr VARCHAR(500) NULL COMMENT '예약자 이메일',
|
||||
create_date DATETIME NULL COMMENT '생성일',
|
||||
created_by VARCHAR(255) NULL COMMENT '생성자',
|
||||
modified_date DATETIME NULL COMMENT '수정일',
|
||||
last_modified_by VARCHAR(255) NULL COMMENT '수정자',
|
||||
PRIMARY KEY (reserve_id),
|
||||
CONSTRAINT FK_reserve_reserve_item_id FOREIGN KEY (reserve_item_id)
|
||||
REFERENCES reserve_item (reserve_item_id) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ;
|
||||
|
||||
Reference in New Issue
Block a user