ads367 / yj_portal star
방선주 방선주 06-27
240627 방선주 오라클 멀티db 적용 및 문자메시지 임시 코드 적용
@366cfd78d1d2029fe770c035a3e1b9ffeb452b00
pom.xml
--- pom.xml
+++ pom.xml
@@ -201,6 +201,14 @@
 			<artifactId>commons-lang3</artifactId>
 			<version>3.14.0</version>
 		</dependency>
+
+		<!-- oracle  추가 -->
+		<dependency>
+			<groupId>com.oracle.database.jdbc</groupId>
+			<artifactId>ojdbc10</artifactId>
+			<version>19.16.0.0</version>
+		</dependency>
+
 	</dependencies>
 
 	<build>
src/main/java/com/takensoft/CmsApplication.java
--- src/main/java/com/takensoft/CmsApplication.java
+++ src/main/java/com/takensoft/CmsApplication.java
@@ -6,7 +6,7 @@
 import org.springframework.scheduling.annotation.EnableScheduling;
 
 @SpringBootApplication
-@MapperScan(basePackages="com.takensoft.*.*.dao, com.takensoft.*.*.*.dao")
+//@MapperScan(basePackages="com.takensoft.*.*.dao, com.takensoft.*.*.*.dao")
 @EnableScheduling
 public class CmsApplication {
 
 
src/main/java/com/takensoft/common/config/CmsDataSourceConfig.java (added)
+++ src/main/java/com/takensoft/common/config/CmsDataSourceConfig.java
@@ -0,0 +1,63 @@
+package com.takensoft.common.config;
+
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import javax.sql.DataSource;
+
+@Configuration
+@MapperScan(basePackages="com.takensoft.*.*.dao, com.takensoft.*.*.*.dao", sqlSessionFactoryRef = "cmsSqlSessionFactory")
+public class CmsDataSourceConfig {
+
+    @Primary
+    @Bean(name = "cmsDataSource")
+    @ConfigurationProperties(prefix = "spring.cms.datasource")
+    public DataSource cmsDataSource() {
+        return DataSourceBuilder.create().build();
+    }
+
+    @Primary
+    @Bean(name = "cmsSqlSessionFactory")
+    public SqlSessionFactory cmsSqlSessionFactory(@Qualifier("cmsDataSource") DataSource cmsDataSource,
+                                                  ApplicationContext applicationContext) throws Exception {
+        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
+        sqlSessionFactoryBean.setDataSource(cmsDataSource);
+        sqlSessionFactoryBean.setTypeAliasesPackage("com.takensoft.**.**.vo, com.takensoft.**.**.dto, com.takensoft.common");
+        sqlSessionFactoryBean.setMapperLocations(applicationContext.getResources("classpath:mybatis/mapper/**/*-SQL.xml"));
+
+        // MyBatis Configuration 설정 추가
+        org.apache.ibatis.session.Configuration myBatisConfig = new org.apache.ibatis.session.Configuration();
+        myBatisConfig.setCacheEnabled(true);
+        myBatisConfig.setLazyLoadingEnabled(false);
+        myBatisConfig.setMultipleResultSetsEnabled(true);
+        myBatisConfig.setUseColumnLabel(true);
+        myBatisConfig.setUseGeneratedKeys(false);
+        myBatisConfig.setDefaultExecutorType(org.apache.ibatis.session.ExecutorType.SIMPLE);
+        myBatisConfig.setDefaultStatementTimeout(25000);
+        myBatisConfig.setCallSettersOnNulls(true);
+        myBatisConfig.setMapUnderscoreToCamelCase(true);
+
+        sqlSessionFactoryBean.setConfiguration(myBatisConfig);
+
+        return sqlSessionFactoryBean.getObject();
+    }
+
+    @Primary
+    @Bean(name = "firstSessionTemplate")
+    public SqlSessionTemplate firstSqlSessionTemplate(@Qualifier("cmsSqlSessionFactory") SqlSessionFactory cmsSqlSessionFactory) {
+        return new SqlSessionTemplate(cmsSqlSessionFactory);
+    }
+}
+
+
+
+
 
src/main/java/com/takensoft/common/config/UmsDataSourceConfig.java (added)
+++ src/main/java/com/takensoft/common/config/UmsDataSourceConfig.java
@@ -0,0 +1,56 @@
+package com.takensoft.common.config;
+
+
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.context.WebApplicationContext;
+
+import javax.sql.DataSource;
+
+@Configuration
+@MapperScan(basePackages="com.takensoft.ums.dao", sqlSessionFactoryRef = "umsSqlSessionFactory")
+public class UmsDataSourceConfig {
+    @Bean(name = "umsDataSource")
+    @ConfigurationProperties(prefix="spring.ums.datasource")
+    public DataSource umsDataSource() {
+        return DataSourceBuilder.create().build();
+    }
+
+    @Bean(name = "umsSqlSessionFactory")
+    public SqlSessionFactory umsSqlSessionFactory(@Qualifier("umsDataSource") DataSource umsDataSource,
+                                                  ApplicationContext applicationContext) throws Exception {
+        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
+        sqlSessionFactoryBean.setDataSource(umsDataSource);
+        sqlSessionFactoryBean.setTypeAliasesPackage("com.takensoft.ums.vo");
+        sqlSessionFactoryBean.setMapperLocations(applicationContext.getResources("classpath:mybatis/mapper-ora/**/*-SQL.xml"));
+
+        // MyBatis Configuration 설정 추가
+        org.apache.ibatis.session.Configuration myBatisConfig = new org.apache.ibatis.session.Configuration();
+        myBatisConfig.setCacheEnabled(true);
+        myBatisConfig.setLazyLoadingEnabled(false);
+        myBatisConfig.setMultipleResultSetsEnabled(true);
+        myBatisConfig.setUseColumnLabel(true);
+        myBatisConfig.setUseGeneratedKeys(false);
+        myBatisConfig.setDefaultExecutorType(org.apache.ibatis.session.ExecutorType.SIMPLE);
+        myBatisConfig.setDefaultStatementTimeout(25000);
+        myBatisConfig.setCallSettersOnNulls(true);
+        myBatisConfig.setMapUnderscoreToCamelCase(true);
+
+        sqlSessionFactoryBean.setConfiguration(myBatisConfig);
+
+        return sqlSessionFactoryBean.getObject();
+    }
+
+    @Bean(name = "umsSessionTemplate")
+    public SqlSessionTemplate umsSqlSessionTemplate(@Qualifier("umsSqlSessionFactory") SqlSessionFactory umsSqlSessionFactory) {
+        return new SqlSessionTemplate(umsSqlSessionFactory);
+    }
+}
src/main/java/com/takensoft/portal/entDscsnAply/service/Impl/EntDscsnAplyServiceImpl.java
--- src/main/java/com/takensoft/portal/entDscsnAply/service/Impl/EntDscsnAplyServiceImpl.java
+++ src/main/java/com/takensoft/portal/entDscsnAply/service/Impl/EntDscsnAplyServiceImpl.java
@@ -11,6 +11,7 @@
 import com.takensoft.portal.entDscsnAply.dao.EntDscsnAplyDAO;
 import com.takensoft.portal.entDscsnAply.service.EntDscsnAplyService;
 import com.takensoft.portal.entDscsnAply.vo.EntDscsnAplyVO;
+import com.takensoft.ums.service.UmsService;
 import lombok.RequiredArgsConstructor;
 import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
 import org.springframework.stereotype.Service;
@@ -38,6 +39,7 @@
     private final IdgenService entDscsnAplyIdgn;
     private final FileService fileService;
     private final CommonUtils commonUtils;
+    private final UmsService umsService;
 
     /**
      * @author 박정하
@@ -81,8 +83,12 @@
         // 기업상담신청 등록
         int insertResult = entDscsnAplyDAO.entDscsnAplyInsert(entDscsnAplyVO);
 
+        // 기업 상담 등록 시 문자 메시지 발송
+//        Map<String, Object> umsResult = umsService.save();
+
         // 결과 반환
         result.put("insertResult", insertResult);
+//        result.put("umsResult", umsResult);
         return result;
     }
 
 
src/main/java/com/takensoft/ums/dao/UmsDAO.java (added)
+++ src/main/java/com/takensoft/ums/dao/UmsDAO.java
@@ -0,0 +1,24 @@
+package com.takensoft.ums.dao;
+
+import com.takensoft.ums.vo.UmsVO;
+import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author  : 방선주
+ * @since   : 2024.06.25
+ *
+ * 문자서비스 Mapper
+ */
+@Mapper
+public interface UmsDAO {
+    /**
+     * 문자 메시지 목록 조회
+     */
+    public int save(UmsVO umsVO) throws Exception;
+
+    public List<UmsVO> findAll() throws Exception;
+}
+
 
src/main/java/com/takensoft/ums/service/Impl/UmsServiceImpl.java (added)
+++ src/main/java/com/takensoft/ums/service/Impl/UmsServiceImpl.java
@@ -0,0 +1,60 @@
+package com.takensoft.ums.service.Impl;
+
+import com.takensoft.cms.mber.dto.AdmMbrDTO;
+import com.takensoft.cms.mber.service.AdmMbrService;
+import com.takensoft.cms.mber.vo.MberVO;
+import com.takensoft.ums.dao.UmsDAO;
+import com.takensoft.ums.service.UmsService;
+import com.takensoft.ums.vo.UmsVO;
+import lombok.RequiredArgsConstructor;
+import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author  : 방선주
+ * @since   : 2024.06.25
+ *
+ * UmsServiceImpl - 문자 메시지 전송을 위한 서비스 구현체
+ */
+
+@Service("umsService")
+@RequiredArgsConstructor
+public class UmsServiceImpl extends EgovAbstractServiceImpl implements UmsService {
+
+    private final UmsDAO umsDAO;
+    private final AdmMbrService admMbrService;
+
+    @Override
+    @Transactional
+    public Map<String, Object> save() throws Exception {
+        Map<String, Object> result = new HashMap<>();
+
+        // 슈퍼관리자 정보 찾아 가져오기
+        String mbrId = "MBR_000000000000001";
+        AdmMbrDTO admMbrDTO = admMbrService.mbrDetail(mbrId);
+        UmsVO umsVO = new UmsVO();
+        umsVO.setUserId("mono_customer"); // 계정 전달 필요
+        umsVO.setScheduleType("0"); // 즉시 전달 1: 예약
+        umsVO.setTitle("온라인 상담 신규 접수"); // 제목 (null 가능)
+        umsVO.setMsgContent("신규 온라인 상담 신청 건이 등록 되었습니다. "); // 내용
+        umsVO.setCallingNum("054-639-6161"); // 회신번호
+        umsVO.setPhoneNum(admMbrDTO.getMblTelno()); // 슈퍼 관리자 전화번호 가져오기
+
+
+        result.put("status", umsDAO.save(umsVO));
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> findAll() throws Exception {
+        Map<String, Object> result = new HashMap<>();
+        List<UmsVO> list = umsDAO.findAll();
+        result.put("list", list);
+        return result;
+    }
+}
 
src/main/java/com/takensoft/ums/service/UmsService.java (added)
+++ src/main/java/com/takensoft/ums/service/UmsService.java
@@ -0,0 +1,16 @@
+package com.takensoft.ums.service;
+
+import java.util.Map;
+
+/**
+ * @author  : 방선주
+ * @since   : 2024.06.25
+ *
+ * UmsService - 문자 메시지 전송을 위한 서비스
+ */
+
+public interface UmsService {
+    public Map<String, Object> save() throws Exception;
+
+    public Map<String, Object> findAll() throws Exception;
+}
 
src/main/java/com/takensoft/ums/vo/UmsVO.java (added)
+++ src/main/java/com/takensoft/ums/vo/UmsVO.java
@@ -0,0 +1,87 @@
+package com.takensoft.ums.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author  : 방선주
+ * @since   : 2024.06.25
+ *
+ * 게시판 관리 관련 VO
+ */
+@Setter
+@Getter
+@AllArgsConstructor
+public class UmsVO {
+    /**
+     * 문자 메시지 아이디
+     */
+    private String id;
+    /**
+     * ums 로그인 아이디
+     */
+    private String userId;
+    /**
+     * 스케쥴 타입구분(0:즉시, 1:예약)
+     */
+    private String scheduleType;
+    /**
+     * 제목
+     */
+    private String title;
+    /**
+     * 메시지 내용
+     */
+    private String msgContent;
+    /**
+     * 회신번호
+     */
+    private String callingNum;
+    /**
+     * 수신자
+     */
+    private String tgtNm;
+    /**
+     * 수신번호
+     */
+    private String phoneNum;
+    /**
+     * 상태코드 (0: 미전송, 1: 전송, 2:에러)
+     */
+    private String stateCd;
+    /**
+     * STATE_CD 값이 ‘2’일 경우 상세 에러메시지
+     */
+    private String resultMsg;
+    /**
+     * 카카오 알림톡 전송 시 템플릿코드 입력(SMS일
+     * 경우 NULL)
+     */
+    private String templateCd;
+    /**
+     * 푸시전송여부 ‘Y’일경우 푸시로 전송
+     */
+    private String pushSendYn;
+    /**
+     * 푸시전송 시 식별자 아이디(앱아이디)
+     */
+    private String pushId;
+    /**
+     * 카카오알림톡 재전송 후 실패 시 문자전송.
+     */
+    private String pushResendTpCd;
+    /**
+     * 예약전송일시
+     */
+    private String reservDttm;
+    /**
+     * DB입력시간
+     */
+    private String regDttm;
+
+
+    public UmsVO() {
+
+    }
+}
 
src/main/java/com/takensoft/ums/web/UmsController.java (added)
+++ src/main/java/com/takensoft/ums/web/UmsController.java
@@ -0,0 +1,49 @@
+package com.takensoft.ums.web;
+
+import com.takensoft.common.util.ResponseData;
+import com.takensoft.ums.service.UmsService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author  : 방선주
+ * @since   : 2024.06.25
+ *
+ * UmsController - 문자 메시지 전송을 위한 컨트롤러
+ */
+@RestController
+@RequiredArgsConstructor
+@Slf4j
+@RequestMapping(value="/ums")
+public class UmsController {
+
+    private final UmsService umsService;
+
+    // 문자 메시지 테이블 확인
+    @PostMapping(value="/saveUmsInfo.json")
+    public ResponseEntity<?> saveUmsInfo() throws Exception {
+        // 목록 조회
+//        Map<String, Object> result = umsService.findAll();
+        Map<String, Object> result = umsService.save();
+
+        // 응답처리
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
+        ResponseData responseData = new ResponseData();
+        responseData.setStatus(HttpStatus.OK);
+        responseData.setMessage("정상적으로 조회가 처리되었습니다.");
+        responseData.setData(result);
+        return new ResponseEntity<>(responseData, headers, HttpStatus.OK);
+    }
+}
src/main/resources/application.yml
--- src/main/resources/application.yml
+++ src/main/resources/application.yml
@@ -11,17 +11,36 @@
   jpa:
     open-in-view: false
   #Datasource Configuration
-  datasource:
-    driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
-    url: jdbc:log4jdbc:postgresql://210.180.118.83:5432/yj_cms?currentSchema=yj_cms
-    username: takensoft
-    password: tts96314728!@
+  cms:
+    datasource:
+      driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
+      jdbc-url: jdbc:log4jdbc:postgresql://210.180.118.83:5432/yj_cms?currentSchema=yj_cms
+      username: takensoft
+      password: tts96314728!@
+
     # postgresql
     # mariaDB
     #driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
     #url: jdbc:log4jdbc:mariadb://210.180.118.83/yj_portal
     #username: takensoft
     #password: tts96314728!@
+
+  # 오라클 설정
+#  ums:
+#    datasource:
+#      driver-class-name: oracle.jdbc.OracleDriver
+#      jdbc-url: jdbc:oracle:thin:@localhost:1521:xe
+#      username: c##test1
+#      password: 1234
+
+#  # 오라클 설정
+#  ums:
+#    datasource:
+#      driver-class-name: oracle.jdbc.OracleDriver
+#      jdbc-url: jdbc:oracle:thin:@111.6.1.32:1521:ora10
+#      username: mono_customer
+#      password: mono_customer
+
   sql:
     init:
       platform: postgres
@@ -41,19 +60,19 @@
       static-locations: file:///C:/uploadFiles/, classpath:/static/
 
 # Mybatis settings
-mybatis:
-  type-aliases-package: com.takensoft.**.**.vo, com.takensoft.**.**.dto, com.takensoft.common
-  mapper-locations: classpath:mybatis/mapper/**/*-SQL.xml
-  configuration:
-    cache-enabled: true # mapper 캐시 전역 사용여부
-    lazy-loading-enabled: false # MyBatis 지연 로딩 사용여부
-    multiple-result-sets-enabled: true # 한 개의 구문에서 여러 개의 ResultSet 허용 여부
-    use-column-label: true # 컬럼명 대신 컬럼 라벨 사용 여부
-    use-generated-keys: false # 키 자동 생성
-    default-executor-type: SIMPLE
-    default-statement-timeout: 25000
-    call-setters-on-nulls: true
-    map-underscore-to-camel-case: true # 카멜케이스 사용
+#mybatis:
+#  type-aliases-package: com.takensoft.**.**.vo, com.takensoft.**.**.dto, com.takensoft.common
+#  mapper-locations: classpath:mybatis/mapper/**/*-SQL.xml
+#  configuration:
+#    cache-enabled: true # mapper 캐시 전역 사용여부
+#    lazy-loading-enabled: false # MyBatis 지연 로딩 사용여부
+#    multiple-result-sets-enabled: true # 한 개의 구문에서 여러 개의 ResultSet 허용 여부
+#    use-column-label: true # 컬럼명 대신 컬럼 라벨 사용 여부
+#    use-generated-keys: false # 키 자동 생성
+#    default-executor-type: SIMPLE
+#    default-statement-timeout: 25000
+#    call-setters-on-nulls: true
+#    map-underscore-to-camel-case: true # 카멜케이스 사용
 
 # jwt
 jwt:
@@ -68,8 +87,9 @@
 # frontUrl
 front:
   #url: http://192.168.0.95
-  url: http://165.229.169.115
-#  url: http://192.168.0.96
+#  url: http://165.229.169.115
+  url: http://192.168.0.96
+#  url: http://165.229.169.114
 #  url: http://localhost
 
 # 암복호화
 
src/main/resources/mybatis/mapper-ora/ums/ums-SQL.xml (added)
+++ src/main/resources/mybatis/mapper-ora/ums/ums-SQL.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takensoft.ums.dao.UmsDAO">
+    <insert id="save" parameterType="UmsVO">
+        INSERT INTO CUSTOMER_SMS_SEND (
+                                       USER_ID
+                                      , SCHEDULE_TYPE
+                                      , TITLE
+                                      ,MSG_CONTENT
+                                      , CALLING_NUM
+                                      ,PHONE_NUM
+                                      , RESERV_DTTM
+                                      , REG_DTTM
+        ) VALUES (
+                     #{userId},
+                     #{scheduleType},
+                     #{title},
+                     #{msgContent},
+                     #{callingNum},
+                     #{phoneNum},
+                     NULL,
+                     TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS')
+                 )
+    </insert>
+
+    <select id="findAll" resultType="UmsVO">
+        SELECT * FROM CUSTOMER_SMS_SEND
+    </select>
+</mapper>(파일 끝에 줄바꿈 문자 없음)
Add a comment
List