feat: db분리
parent
8bc53deddd
commit
8b3821f6a3
@ -0,0 +1,55 @@
|
||||
package kr.xit.biz.sms.web;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import kr.xit.biz.ens.model.EnsDTO.SmsSndng;
|
||||
import kr.xit.biz.ens.model.EnsDTO.SndngMssageParam;
|
||||
import kr.xit.biz.ens.service.EnsBatchRequireNewService;
|
||||
import kr.xit.biz.sms.service.ISmsMessageService;
|
||||
import kr.xit.core.model.ApiResponseDTO;
|
||||
import kr.xit.core.model.IApiResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* description :
|
||||
*
|
||||
* packageName : kr.xit.biz.sms.web
|
||||
* fileName : SmsMessageController
|
||||
* author : limju
|
||||
* date : 2023-10-30
|
||||
* ======================================================================
|
||||
* 변경일 변경자 변경 내용
|
||||
* ----------------------------------------------------------------------
|
||||
* 2023-10-30 limju 최초 생성
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@Tag(name = " SmsMessageController", description = "SMS(xit) 연계 서비스")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/batch/ens/v1")
|
||||
public class SmsMessageController {
|
||||
private final ISmsMessageService service;
|
||||
private final EnsBatchRequireNewService requireNewService;
|
||||
|
||||
@Operation(summary = "SMS 메세지 연계", description = "SMS 메세지 연계")
|
||||
@PostMapping(value = "/sendMessages", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public IApiResponse sendMessages(@RequestBody final List<SmsSndng> lists) {
|
||||
service.sendSmsList(lists);
|
||||
return ApiResponseDTO.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "SMS 메세지 연계", description = "SMS 메세지 연계")
|
||||
@PostMapping(value = "/sendMessages2", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public IApiResponse sendMessages2(@RequestBody final SndngMssageParam reqDTO) {
|
||||
requireNewService.sendSms(reqDTO);
|
||||
return ApiResponseDTO.success();
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
//package kr.xit.core.spring.auto;
|
||||
//
|
||||
//import kr.xit.core.spring.config.db.PrimaryDatasourceConfig;
|
||||
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//
|
||||
///**
|
||||
// * <pre>
|
||||
// * description :
|
||||
// *
|
||||
// * packageName : kr.xit.core.spring.config.auto
|
||||
// * fileName : SecondaryDatabaseAutoConfiguration
|
||||
// * author : limju
|
||||
// * date : 2023-10-30
|
||||
// * ======================================================================
|
||||
// * 변경일 변경자 변경 내용
|
||||
// * ----------------------------------------------------------------------
|
||||
// * 2023-10-30 limju 최초 생성
|
||||
// *
|
||||
// * </pre>
|
||||
// */
|
||||
////@Configuration
|
||||
////@ConditionalOnClass(PrimaryDatasourceConfig.class)
|
||||
//@ConditionalOnProperty("spring.datasource.hikari.primary")
|
||||
//public class PrimaryDatabaseAutoConfiguration {
|
||||
// @Bean
|
||||
// public PrimaryDatasourceConfig primaryDatasourceConfig() {
|
||||
// return new PrimaryDatasourceConfig();
|
||||
// }
|
||||
//
|
||||
// //@ConditionalOnMissingBean(SecondaryMybatisConfig.class)
|
||||
//// @Bean
|
||||
//// public TransactionConfig transactionConfig() {
|
||||
//// return new TransactionConfig();
|
||||
//// }
|
||||
//}
|
@ -0,0 +1,38 @@
|
||||
//package kr.xit.core.spring.auto;
|
||||
//
|
||||
//import kr.xit.core.spring.config.db.SecondaryMybatisConfig;
|
||||
//import kr.xit.core.spring.config.db.TransactionConfig;
|
||||
//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//
|
||||
///**
|
||||
// * <pre>
|
||||
// * description :
|
||||
// *
|
||||
// * packageName : kr.xit.core.spring.config.auto
|
||||
// * fileName : SecondaryDatabaseAutoConfiguration
|
||||
// * author : limju
|
||||
// * date : 2023-10-30
|
||||
// * ======================================================================
|
||||
// * 변경일 변경자 변경 내용
|
||||
// * ----------------------------------------------------------------------
|
||||
// * 2023-10-30 limju 최초 생성
|
||||
// *
|
||||
// * </pre>
|
||||
// */
|
||||
////@Configuration
|
||||
//@ConditionalOnClass(SecondaryMybatisConfig.class)
|
||||
//@ConditionalOnProperty("spring.datasource.hikari.secondary")
|
||||
//public class SecondaryDatabaseAutoConfiguration {
|
||||
// @Bean
|
||||
// public SecondaryMybatisConfig secondaryMybatisConfig() {
|
||||
// return new SecondaryMybatisConfig();
|
||||
// }
|
||||
//
|
||||
// //@ConditionalOnMissingBean(SecondaryMybatisConfig.class)
|
||||
// @Bean
|
||||
// public TransactionConfig transactionConfig() {
|
||||
// return new TransactionConfig();
|
||||
// }
|
||||
//}
|
@ -0,0 +1,32 @@
|
||||
package kr.xit.core.spring.config.db;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* description :
|
||||
*
|
||||
* packageName : kr.xit.core.spring.config.db
|
||||
* fileName : DataSourceProperties
|
||||
* author : limju
|
||||
* date : 2023-10-30
|
||||
* ======================================================================
|
||||
* 변경일 변경자 변경 내용
|
||||
* ----------------------------------------------------------------------
|
||||
* 2023-10-30 limju 최초 생성
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class DataSourceProperties {
|
||||
private String driverClassName;
|
||||
private String jdbcUrl;
|
||||
private String username;
|
||||
private String password;
|
||||
private String readonly;
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
//package kr.xit.core.spring.config.db;
|
||||
//
|
||||
//import com.zaxxer.hikari.HikariConfig;
|
||||
//import com.zaxxer.hikari.HikariDataSource;
|
||||
//import javax.sql.DataSource;
|
||||
//import kr.xit.core.consts.Constants;
|
||||
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Primary;
|
||||
//
|
||||
////FIXME :: 재설정이 필요한 경우 해당 프로젝트에 동일한 파일로 재정의 하여 사용
|
||||
///**
|
||||
// * <pre>
|
||||
// * description : Datasource 설정 - FIXME:: spring.datasource 설정이 있는 경우만 loading
|
||||
// * - 조건 : spring.datasource
|
||||
// * 실제 필요한 경우만 커넥션을 점유하도록
|
||||
// * LazyConnectionDataSourceProxy 사용
|
||||
// * 일반 Datasource 사용시
|
||||
// * - Spring은 트랜잭션에 진입시 데이타 소스의 커넥션을 get
|
||||
// * - ehcache, hibernate 영속성 컨택슽트 1차캐시 등에도 커넥션을 get
|
||||
// * - multi-datasource 에서 트랜잭션 진입 이후 datasource 분기 불가
|
||||
// * packageName : kr.xit.core.spring.config.support
|
||||
// * fileName : DatasourceConfig
|
||||
// * author : julim
|
||||
// * date : 2023-04-28
|
||||
// * ======================================================================
|
||||
// * 변경일 변경자 변경 내용
|
||||
// * ----------------------------------------------------------------------
|
||||
// * 2023-04-28 julim 최초 생성
|
||||
// *
|
||||
// * </pre>
|
||||
// * @see PrimaryMybatisConfig
|
||||
// */
|
||||
////@ConditionalOnProperty(value = "spring", havingValue = "datasource", matchIfMissing = false)
|
||||
////@Configuration
|
||||
//public class DatasourceConfig {
|
||||
// @Bean(name = "primaryHikariConfig")
|
||||
// @Primary
|
||||
// @ConfigurationProperties(prefix = "spring.datasource.hikari.primary")
|
||||
// public HikariConfig primaryHikariConfig() {
|
||||
// // HikariConfig hikariConfig = new HikariConfig("spring.datasource.hikari");
|
||||
// // hikariConfig.setAutoCommit(false);
|
||||
// // return hikariConfig;
|
||||
// return new HikariConfig();
|
||||
// }
|
||||
//
|
||||
// @Bean(Constants.PRIMARY_DATA_SOURCE)
|
||||
// @Primary
|
||||
// public DataSource primaryDataSource() throws Exception{
|
||||
// //return new LazyConnectionDataSourceProxy(new HikariDataSource(primaryHikariConfig()));
|
||||
// return new HikariDataSource(primaryHikariConfig());
|
||||
// }
|
||||
//
|
||||
// //@ConditionalOnProperty(value = "spring.datasource.hikari", havingValue = "oracle", matchIfMissing = false)
|
||||
// @Bean(name = "secondaryHikariConfig")
|
||||
// @ConfigurationProperties(prefix = "spring.datasource.hikari.secondary")
|
||||
// public HikariConfig secondaryHikariConfig() {
|
||||
// // HikariConfig hikariConfig = new HikariConfig("spring.datasource.hikari");
|
||||
// // hikariConfig.setAutoCommit(false);
|
||||
// // return hikariConfig;
|
||||
// return new HikariConfig();
|
||||
// }
|
||||
//
|
||||
// @Bean(name = Constants.SECONDARY_DATA_SOURCE)
|
||||
// public DataSource secondaryDataSource() throws Exception{
|
||||
// //return new LazyConnectionDataSourceProxy(new HikariDataSource(secondaryHikariConfig()));
|
||||
// return new HikariDataSource(secondaryHikariConfig());
|
||||
// }
|
||||
//}
|
@ -0,0 +1,30 @@
|
||||
//package kr.xit.core.spring.config.db;
|
||||
//
|
||||
//import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
//
|
||||
///**
|
||||
// * <pre>
|
||||
// * description :
|
||||
// *
|
||||
// * packageName : kr.xit.core.spring.config.db
|
||||
// * fileName : DataSourceProperties
|
||||
// * author : limju
|
||||
// * date : 2023-10-30
|
||||
// * ======================================================================
|
||||
// * 변경일 변경자 변경 내용
|
||||
// * ----------------------------------------------------------------------
|
||||
// * 2023-10-30 limju 최초 생성
|
||||
// *
|
||||
// * </pre>
|
||||
// */
|
||||
//@ConfigurationProperties(prefix = "spring.datasource.hikari.primary")
|
||||
////@EnableAutoConfiguration(exclude = SecondaryDataSourceProperties.class)
|
||||
//public class PrimaryDataSourceProperties extends DataSourceProperties{
|
||||
// private String driverClassName;
|
||||
// private String jdbcUrl;
|
||||
// private String username;
|
||||
// private String password;
|
||||
// private String readonly;
|
||||
//
|
||||
//}
|
@ -0,0 +1,27 @@
|
||||
package kr.xit.core.spring.config.db;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* description :
|
||||
*
|
||||
* packageName : kr.xit.core.spring.config.db
|
||||
* fileName : DataSourceProperties
|
||||
* author : limju
|
||||
* date : 2023-10-30
|
||||
* ======================================================================
|
||||
* 변경일 변경자 변경 내용
|
||||
* ----------------------------------------------------------------------
|
||||
* 2023-10-30 limju 최초 생성
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.datasource.hikari")
|
||||
@Getter
|
||||
@Setter
|
||||
public class SecondaryDataSourceProperties {
|
||||
private String secondary;
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package kr.xit.core.spring.config.db;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import javax.sql.DataSource;
|
||||
import kr.xit.core.consts.Constants;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
//FIXME :: 재설정이 필요한 경우 해당 프로젝트에 동일한 파일로 재정의 하여 사용
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* description : Datasource 설정 - FIXME:: spring.datasource 설정이 있는 경우만 loading
|
||||
* - 조건 : spring.datasource
|
||||
* 실제 필요한 경우만 커넥션을 점유하도록
|
||||
* LazyConnectionDataSourceProxy 사용
|
||||
* 일반 Datasource 사용시
|
||||
* - Spring은 트랜잭션에 진입시 데이타 소스의 커넥션을 get
|
||||
* - ehcache, hibernate 영속성 컨택슽트 1차캐시 등에도 커넥션을 get
|
||||
* - multi-datasource 에서 트랜잭션 진입 이후 datasource 분기 불가
|
||||
* packageName : kr.xit.core.spring.config.support
|
||||
* fileName : DatasourceConfig
|
||||
* author : julim
|
||||
* date : 2023-04-28
|
||||
* ======================================================================
|
||||
* 변경일 변경자 변경 내용
|
||||
* ----------------------------------------------------------------------
|
||||
* 2023-04-28 julim 최초 생성
|
||||
*
|
||||
* </pre>
|
||||
* @see PrimaryMybatisConfig
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(value = "spring.datasource.hikari.secondary.username")
|
||||
public class SecondaryDatasourceConfig {
|
||||
@Bean(name = "secondaryHikariConfig")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.hikari.secondary")
|
||||
public HikariConfig secondaryHikariConfig() {
|
||||
// HikariConfig hikariConfig = new HikariConfig("spring.datasource.hikari");
|
||||
// hikariConfig.setAutoCommit(false);
|
||||
// return hikariConfig;
|
||||
return new HikariConfig();
|
||||
}
|
||||
|
||||
@Bean(name = Constants.SECONDARY_DATA_SOURCE)
|
||||
public DataSource secondaryDataSource() throws Exception{
|
||||
//return new LazyConnectionDataSourceProxy(new HikariDataSource(secondaryHikariConfig()));
|
||||
return new HikariDataSource(secondaryHikariConfig());
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
#org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
# kr.xit.core.spring.auto.PrimaryDatabaseAutoConfiguration, kr.xit.core.spring.auto.SecondaryDatabaseAutoConfiguration]
|
||||
#
|
Loading…
Reference in New Issue