commit 456bf8a7685d81d387e22f2a95c33412a16333cc Author: dsjang Date: Mon May 6 22:04:16 2024 +0900 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2065bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +HELP.md +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..91c724a --- /dev/null +++ b/build.gradle @@ -0,0 +1,69 @@ +plugins { + id 'java' + id 'war' + id 'org.springframework.boot' version '3.2.5' + id 'io.spring.dependency-management' version '1.1.4' +} + +group = 'com.munjaon' +version = '0.0.1-SNAPSHOT' + +java { + sourceCompatibility = '17' +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-batch' + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3' + compileOnly 'org.projectlombok:lombok' + developmentOnly 'org.springframework.boot:spring-boot-devtools' + runtimeOnly 'org.mariadb.jdbc:mariadb-java-client' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.3' + testImplementation 'org.springframework.batch:spring-batch-test' + + // https://mvnrepository.com/artifact/com.zaxxer/HikariCP + implementation 'com.zaxxer:HikariCP:4.0.3' + // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-cache + implementation 'org.springframework.boot:spring-boot-starter-cache:3.2.5' + providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' + // https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple + implementation 'com.googlecode.json-simple:json-simple:1.1.1' + // https://mvnrepository.com/artifact/org.apache.commons/commons-configuration2 + implementation 'org.apache.commons:commons-configuration2:2.10.1' + // https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils + implementation 'commons-beanutils:commons-beanutils:1.9.4' + // https://mvnrepository.com/artifact/io.netty/netty-all + implementation 'io.netty:netty-all:4.1.42.Final' + + testCompileOnly 'org.projectlombok:lombok' + testAnnotationProcessor 'org.projectlombok:lombok' +} + +tasks.named('test') { + useJUnitPlatform() +} + +// profile의 기본값 local로 설정 +ext.profile = (!project.hasProperty('profile') || !profile) ? 'local' : profile + +// 리소스 디렉토리 추가 +sourceSets { + main { + resources { + srcDirs "src/main/resources/${profile}" + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e644113 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..b82aa23 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..1aa94a4 --- /dev/null +++ b/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..25da30d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..95bb492 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'munjaon_server' diff --git a/src/main/java/com/munjaon/server/MunjaonServerApplication.java b/src/main/java/com/munjaon/server/MunjaonServerApplication.java new file mode 100644 index 0000000..51068da --- /dev/null +++ b/src/main/java/com/munjaon/server/MunjaonServerApplication.java @@ -0,0 +1,23 @@ +package com.munjaon.server; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.scheduling.annotation.EnableScheduling; + +@EnableCaching +@EnableScheduling +@SpringBootApplication +public class MunjaonServerApplication extends SpringBootServletInitializer { + + public static void main(String[] args) { + SpringApplication.run(MunjaonServerApplication.class, args); + } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { + return super.configure(builder); + } +} diff --git a/src/main/java/com/munjaon/server/api/controller/SampleController.java b/src/main/java/com/munjaon/server/api/controller/SampleController.java new file mode 100644 index 0000000..f4e361f --- /dev/null +++ b/src/main/java/com/munjaon/server/api/controller/SampleController.java @@ -0,0 +1,33 @@ +package com.munjaon.server.api.controller; + +import com.munjaon.server.api.dto.SampleDto; +import com.munjaon.server.api.dto.base.ApiResponse; +import com.munjaon.server.api.service.SampleService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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; + +@Slf4j +@RequestMapping("/api") +@RestController +@RequiredArgsConstructor +public class SampleController { + private final SampleService sampleService; + + @PostMapping("/sample") + public ResponseEntity postSample(@RequestBody SampleDto sample) throws ConfigurationException { + log.debug("sample : {}", sampleService.get()); + System.out.println("command : " + sample.getCommand()); + + /* 설정 Load */ + sampleService.printConfig(); + + return new ResponseEntity(ApiResponse.toResponse(200, "OK", sample), HttpStatus.OK); + } +} diff --git a/src/main/java/com/munjaon/server/api/dto/SampleDto.java b/src/main/java/com/munjaon/server/api/dto/SampleDto.java new file mode 100644 index 0000000..0b6ba20 --- /dev/null +++ b/src/main/java/com/munjaon/server/api/dto/SampleDto.java @@ -0,0 +1,12 @@ +package com.munjaon.server.api.dto; + +import com.munjaon.server.api.dto.base.BaseDto; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class SampleDto extends BaseDto { +} diff --git a/src/main/java/com/munjaon/server/api/dto/base/ApiResponse.java b/src/main/java/com/munjaon/server/api/dto/base/ApiResponse.java new file mode 100644 index 0000000..19ac493 --- /dev/null +++ b/src/main/java/com/munjaon/server/api/dto/base/ApiResponse.java @@ -0,0 +1,31 @@ +package com.munjaon.server.api.dto.base; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ApiResponse { + /* 응답코드 */ + private Integer code; + /* 응답 메시지 */ + private String message; + /* Response 객체 */ + private T data; + + public ApiResponse(final Integer code, final String message) { + this.code = code; + this.message = message; + } + + public static ApiResponse toResponse(final Integer code, final String message, final T t) { + return ApiResponse.builder().code(code) + .message(message) + .data(t) + .build(); + } +} diff --git a/src/main/java/com/munjaon/server/api/dto/base/BaseDto.java b/src/main/java/com/munjaon/server/api/dto/base/BaseDto.java new file mode 100644 index 0000000..2350535 --- /dev/null +++ b/src/main/java/com/munjaon/server/api/dto/base/BaseDto.java @@ -0,0 +1,13 @@ +package com.munjaon.server.api.dto.base; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class BaseDto { + protected String command; + protected String authKey; +} diff --git a/src/main/java/com/munjaon/server/api/mapper/SampleMapper.java b/src/main/java/com/munjaon/server/api/mapper/SampleMapper.java new file mode 100644 index 0000000..98173d0 --- /dev/null +++ b/src/main/java/com/munjaon/server/api/mapper/SampleMapper.java @@ -0,0 +1,8 @@ +package com.munjaon.server.api.mapper; + +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SampleMapper { + int get(); +} diff --git a/src/main/java/com/munjaon/server/api/service/SampleService.java b/src/main/java/com/munjaon/server/api/service/SampleService.java new file mode 100644 index 0000000..9901e49 --- /dev/null +++ b/src/main/java/com/munjaon/server/api/service/SampleService.java @@ -0,0 +1,31 @@ +package com.munjaon.server.api.service; + +import com.munjaon.server.api.mapper.SampleMapper; +import com.munjaon.server.cache.service.MemberService; +import com.munjaon.server.config.ServerConfig; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class SampleService { + private final SampleMapper sampleMapper; + + private final ServerConfig serverConfig; + + private final MemberService memberService; + + public int get() { + return sampleMapper.get(); + } + + public void printConfig() throws ConfigurationException { + log.info("server.run : {}", serverConfig.getString("server.run")); + log.info("sms.queue.count : {}", serverConfig.getInt("sms.queue.count")); + log.info("member list : {}", memberService.list()); + log.info("member get : {}", memberService.get("006star")); + } +} diff --git a/src/main/java/com/munjaon/server/cache/dto/MemberDto.java b/src/main/java/com/munjaon/server/cache/dto/MemberDto.java new file mode 100644 index 0000000..9dd0333 --- /dev/null +++ b/src/main/java/com/munjaon/server/cache/dto/MemberDto.java @@ -0,0 +1,26 @@ +package com.munjaon.server.cache.dto; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class MemberDto { + private String mberId; + private String esntlId; + private String mberSttus; + private String dept; + private float shortPrice; + private float longPrice; + private float picturePrice; + private float picture2Price; + private float picture3Price; + private float kakaoAtPrice; + private float kakaoFtPrice; + private float kakaoFtImgPrice; + private float kakaoFtWideImgPrice; + private float faxPrice; + private float userMoney; +} diff --git a/src/main/java/com/munjaon/server/cache/mapper/MemberMapper.java b/src/main/java/com/munjaon/server/cache/mapper/MemberMapper.java new file mode 100644 index 0000000..e75accd --- /dev/null +++ b/src/main/java/com/munjaon/server/cache/mapper/MemberMapper.java @@ -0,0 +1,35 @@ +package com.munjaon.server.cache.mapper; + +import com.munjaon.server.cache.dto.MemberDto; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface MemberMapper { + /** + * 회원테이블 마지막으로 변경된 시간 조회 + * @return + */ + String getLastModifiedTime(String tableSchema); + + /** + * 회원 전체 목록 + * @return + */ + List list(); + + /** + * 회원조회 + * @param mberId + * @return + */ + MemberDto get(String mberId); + + /** + * 회원상태 업데이트 + * @param params + * @return + */ + int updateStts(MemberDto params); +} diff --git a/src/main/java/com/munjaon/server/cache/service/MemberService.java b/src/main/java/com/munjaon/server/cache/service/MemberService.java new file mode 100644 index 0000000..c99a407 --- /dev/null +++ b/src/main/java/com/munjaon/server/cache/service/MemberService.java @@ -0,0 +1,89 @@ +package com.munjaon.server.cache.service; + +import com.munjaon.server.cache.dto.MemberDto; +import com.munjaon.server.cache.mapper.MemberMapper; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Slf4j +@Service +@RequiredArgsConstructor +public class MemberService { + private final MemberMapper memberMapper; + + /** + * 회원테이블 마지막으로 변경된 시간 조회 + * @return + */ + public String getLastModifiedTime(String tableSchema) { + return memberMapper.getLastModifiedTime(tableSchema); + } + + /** + * 회원 전체 목록 + * @return + */ + @Transactional(readOnly = true) + @Cacheable("cacheMember") + public List list() { + return memberMapper.list(); + } + + /** + * 회원조회 + * @param mberId + * @return + */ + @Transactional(readOnly = true) + @Cacheable(value = "cacheMember", key = "#mberId") + public MemberDto get(String mberId) { + return memberMapper.get(mberId); + } + + /** + * 회원 Cache 전체 삭제 + */ + @CacheEvict(value = "cacheMember", allEntries = true) + public void deleteAllMember(){ + log.info("Cache All Clear"); + } + + /** + * 회원 Cache 아이디 삭제 + * @param mberId + */ + @CacheEvict(value = "cacheMember", key = "#mberId") + public void deleteOneMember(final String mberId){ + log.info("Cache Clear: {}", mberId); + } + + /** + * 회원상태 업데이트 + * @param params + * @return + */ + @Transactional + public int updateStts(MemberDto params) { + return memberMapper.updateStts(params); + } + + /** + * 회원상태 업데이트 + * @param mberId + * @param mberSttus + * @return + */ + public int updateStts(String mberId, String mberSttus) { + MemberDto params = new MemberDto(); + params.setMberId(mberId); + params.setMberSttus(mberSttus); + + return memberMapper.updateStts(params); + } +} diff --git a/src/main/java/com/munjaon/server/config/DataSourceConfig.java b/src/main/java/com/munjaon/server/config/DataSourceConfig.java new file mode 100644 index 0000000..26d11fe --- /dev/null +++ b/src/main/java/com/munjaon/server/config/DataSourceConfig.java @@ -0,0 +1,51 @@ +package com.munjaon.server.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.mybatis.spring.boot.autoconfigure.SpringBootVFS; +import org.springframework.beans.factory.annotation.Autowired; +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 org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.sql.DataSource; + +@Configuration +@EnableTransactionManagement +@MapperScan(basePackages= "com.munjaon.server.**.mapper") +public class DataSourceConfig { + @Autowired + private ApplicationContext applicationContext; + + @Primary + @Bean(name = "datasource") + @ConfigurationProperties(prefix = "spring.datasource.server") + public DataSource dataSource() { + return DataSourceBuilder.create().build(); + } + + @Primary + @Bean(name = "factory") + public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { + SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean(); + sqlSessionFactory.setVfs(SpringBootVFS.class); + sqlSessionFactory.setDataSource(dataSource); + sqlSessionFactory.setTypeAliasesPackage("com.munjaon.server.**.dto"); + sqlSessionFactory.setConfigLocation(applicationContext.getResource("classpath:mybatis-config.xml")); + sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:/sqlmap/**/*.xml")); + return sqlSessionFactory.getObject(); + } + + @Primary + @Bean(name = "sqlSession") + public SqlSessionTemplate sqlSession(SqlSessionFactory sqlSessionFactory) { + return new SqlSessionTemplate(sqlSessionFactory); + } +} diff --git a/src/main/java/com/munjaon/server/config/ServerConfig.java b/src/main/java/com/munjaon/server/config/ServerConfig.java new file mode 100644 index 0000000..0bf1ed8 --- /dev/null +++ b/src/main/java/com/munjaon/server/config/ServerConfig.java @@ -0,0 +1,50 @@ +package com.munjaon.server.config; + +import jakarta.annotation.PostConstruct; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.configuration2.PropertiesConfiguration; +import org.apache.commons.configuration2.builder.ConfigurationBuilderEvent; +import org.apache.commons.configuration2.builder.ReloadingFileBasedConfigurationBuilder; +import org.apache.commons.configuration2.builder.fluent.Parameters; +import org.apache.commons.configuration2.event.Event; +import org.apache.commons.configuration2.event.EventListener; +import org.apache.commons.configuration2.ex.ConfigurationException; +import org.apache.commons.configuration2.reloading.PeriodicReloadingTrigger; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.util.concurrent.TimeUnit; + +@Slf4j +@Component +public class ServerConfig { + @Value("${agent.server-property-file}") + private String serverProperyFile; + + private ReloadingFileBasedConfigurationBuilder builder; + + @PostConstruct + void init() throws ConfigurationException { + log.info("serverProperyFile : {}", serverProperyFile); + builder = new ReloadingFileBasedConfigurationBuilder<>(PropertiesConfiguration.class).configure(new Parameters().fileBased().setFile(new File(serverProperyFile))); + + builder.addEventListener(ConfigurationBuilderEvent.CONFIGURATION_REQUEST, new EventListener() { + @Override + public void onEvent(Event event) { + log.info("builder.getConfiguration() is Called!!"); + } + }); + + PeriodicReloadingTrigger configReloadingTrigger = new PeriodicReloadingTrigger(builder.getReloadingController(), null, 1, TimeUnit.SECONDS); + configReloadingTrigger.start(); + } + + public String getString(String key) throws ConfigurationException { + return builder.getConfiguration().getString(key); + } + + public int getInt(String key) throws ConfigurationException { + return builder.getConfiguration().getInt(key, 3); + } +} diff --git a/src/main/java/com/munjaon/server/netty/config/BaseConfig.java b/src/main/java/com/munjaon/server/netty/config/BaseConfig.java new file mode 100644 index 0000000..0080db4 --- /dev/null +++ b/src/main/java/com/munjaon/server/netty/config/BaseConfig.java @@ -0,0 +1,15 @@ +package com.munjaon.server.netty.config; + +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.nio.NioEventLoopGroup; + +import java.net.InetSocketAddress; + +public interface BaseConfig { + NioEventLoopGroup bossGroup(); + NioEventLoopGroup workerGroup(); + InetSocketAddress port(); + ServerBootstrap serverBootstrap(); + ChannelInboundHandlerAdapter handler(); +} diff --git a/src/main/java/com/munjaon/server/netty/handler/SampleHandler.java b/src/main/java/com/munjaon/server/netty/handler/SampleHandler.java new file mode 100644 index 0000000..532b8ba --- /dev/null +++ b/src/main/java/com/munjaon/server/netty/handler/SampleHandler.java @@ -0,0 +1,21 @@ +package com.munjaon.server.netty.handler; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; + +public class SampleHandler extends SimpleChannelInboundHandler { + @Override + protected void channelRead0(ChannelHandlerContext channelHandlerContext, String s) throws Exception { + + } + + @Override + public void channelInactive(ChannelHandlerContext ctx) throws Exception { + + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + + } +} diff --git a/src/main/java/com/munjaon/server/netty/init/SampleNettyInitializer.java b/src/main/java/com/munjaon/server/netty/init/SampleNettyInitializer.java new file mode 100644 index 0000000..e2e1c48 --- /dev/null +++ b/src/main/java/com/munjaon/server/netty/init/SampleNettyInitializer.java @@ -0,0 +1,11 @@ +package com.munjaon.server.netty.init; + +import io.netty.channel.Channel; +import io.netty.channel.ChannelInitializer; + +public class SampleNettyInitializer extends ChannelInitializer { + @Override + protected void initChannel(Channel channel) throws Exception { + + } +} diff --git a/src/main/java/com/munjaon/server/queue/config/QueueConstants.java b/src/main/java/com/munjaon/server/queue/config/QueueConstants.java new file mode 100644 index 0000000..9357fc0 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/config/QueueConstants.java @@ -0,0 +1,80 @@ +package com.munjaon.server.queue.config; + +public final class QueueConstants { + /** Queue File Header Length - [Create Date:10 Byte, Push Count:10 Byte] */ + public static final int QUEUE_HEADER_LENGTH = 20; + // 큐에 저장할 SMS/URL 전체 바이트 길이 + public static final int SMS_TOTAL_BYTE_LENGTH = 473; + // 큐에 저장할 LMS/MMS 전체 바이트 길이 + public static final int MMS_TOTAL_BYTE_LENGTH = 3365; + + // 다음 부분은 SMS/URL/LMS/MMS에서 공통으로 사용되는 컬럼 + // 회원 시퀀스 + public static final int USERSEQ_BYTE_LENGTH = 10; + // 회원 아이디 + public static final int USERID_BYTE_LENGTH = 20; + // 요금제 정보 + public static final int FEETYPE_BYTE_LENGTH = 1; + // 단가정보 + public static final int UNITCOST_BYTE_LENGTH = 10; + // 선불일 경우 결제방법(0:현금 / 1:포인트)aqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAQ + public static final int CASHTYPE_BYTE_LENGTH = 1; + // 메시지 시퀀스34 + public static final int MSGID_BYTE_LENGTH = 20; + // 메시지 그룹 아이디 + public static final int MSGGROUPID_BYTE_LENGTH = 20; + // 서비스타입(S:SMS / U:URL / L:LMS / M:MMS) + public static final int SERVICETYPE_BYTE_LENGTH = 1; + // 결과코드(SendStatus) + public static final int SENDSTATUS_BYTE_LENGTH = 4; + // 회신번호 + public static final int SENDER_BYTE_LENGTH = 12; + // 수신번호 + public static final int RECEIVER_BYTE_LENGTH = 12; + // 예약시간 + public static final int RESERVEDT_BYTE_LENGTH = 15; + // 요청시간 + public static final int REQUESTDT_BYTE_LENGTH = 15; + // 원격접속지 주소 + public static final int REMOTEIP_BYTE_LENGTH = 25; + // 라우터시퀀스 + public static final int ROUTERSEQ_BYTE_LENGTH = 6; + // KISA 필터링 여부 + public static final int KISAFILTER_BYTE_LENGTH = 1; + // 파일카운트 + public static final int FILECNT_BYTE_LENGTH = 2; + // 파일사이즈 + public static final int FILESIZE_BYTE_LENGTH = 2; + // 파일명 + public static final int FILENAME_BYTE_LENGTH = 128; + // 제목 + public static final int SUBJECT_BYTE_LENGTH = 60; + // SMS/URL Message + public static final int SMSMSG_BYTE_LENGTH = 240; + // LMS/MMS Message + public static final int MMSMSG_BYTE_LENGTH = 3000; + + /** 리포트큐 전체 사이즈 및 데이터 개별 사이즈 + * REPORT_TOTAL_LENGTH : 62 + * REPORT_MSGID_LENGTH : 20 + * REPORT_RECEIVER_LENGTH : 12 + * REPORT_SENDDT_LENGTH : 20 + * REPORT_RESULT_LENGTH : 3 + * REPORT_TELECOM_LENGTH : 7 + * */ + /** 리포트큐 전체 사이즈 */ + public static final int REPORT_TOTAL_LENGTH = 62; + /** 리포트큐 MSGID 사이즈 */ + public static final int REPORT_MSGID_LENGTH = 20; + /** 리포트큐 RECEIVER 사이즈 */ + public static final int REPORT_RECEIVER_LENGTH = 12; + /** 리포트큐 SENDDT 사이즈 */ + public static final int REPORT_SENDDT_LENGTH = 20; + /** 리포트큐 RESULT 사이즈 */ + public static final int REPORT_RESULT_LENGTH = 3; + /** 리포트큐 TELECOM 사이즈 */ + public static final int REPORT_TELECOM_LENGTH = 7; + + // 큐에 저장하기전에 바이트를 채울 문자 + public static final byte SET_DEFAULT_BYTE = (byte) 0x20; +} diff --git a/src/main/java/com/munjaon/server/queue/dto/BasicMessageDto.java b/src/main/java/com/munjaon/server/queue/dto/BasicMessageDto.java new file mode 100644 index 0000000..e2e14d8 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/dto/BasicMessageDto.java @@ -0,0 +1,18 @@ +package com.munjaon.server.queue.dto; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class BasicMessageDto { + protected String userMsgID = ""; + protected String userSender = ""; + protected String userReceiver = ""; + protected String userMessage = ""; + protected String userMsgType = ""; + protected String userRequestDate = ""; + protected String sendStatus = "0"; +} diff --git a/src/main/java/com/munjaon/server/queue/dto/KakaoMessageDto.java b/src/main/java/com/munjaon/server/queue/dto/KakaoMessageDto.java new file mode 100644 index 0000000..1417049 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/dto/KakaoMessageDto.java @@ -0,0 +1,11 @@ +package com.munjaon.server.queue.dto; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class KakaoMessageDto extends BasicMessageDto { +} diff --git a/src/main/java/com/munjaon/server/queue/dto/MmsMessageDto.java b/src/main/java/com/munjaon/server/queue/dto/MmsMessageDto.java new file mode 100644 index 0000000..09c104b --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/dto/MmsMessageDto.java @@ -0,0 +1,19 @@ +package com.munjaon.server.queue.dto; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +public class MmsMessageDto extends BasicMessageDto { + private String userSubject = ""; + private int userFileCnt = 0; + private String userFileName01 = ""; + private String userFileName02 = ""; + private String userFileName03 = ""; + private int userFileSize01 = 0; + private int userFileSize02 = 0; + private int userFileSize03 = 0; +} diff --git a/src/main/java/com/munjaon/server/queue/enums/QueueService.java b/src/main/java/com/munjaon/server/queue/enums/QueueService.java new file mode 100644 index 0000000..1eac049 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/enums/QueueService.java @@ -0,0 +1,17 @@ +package com.munjaon.server.queue.enums; + +import lombok.Getter; + +@Getter +public enum QueueService { + SMS_QUEUE, + LMS_QUEUE, + MMS_QUEUE, + KAKAO_QUEUE; + + private Object service; + + public void setService(Object service) { + this.service = service; + } +} diff --git a/src/main/java/com/munjaon/server/queue/service/KakaoQueueService.java b/src/main/java/com/munjaon/server/queue/service/KakaoQueueService.java new file mode 100644 index 0000000..17aabd6 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/service/KakaoQueueService.java @@ -0,0 +1,11 @@ +package com.munjaon.server.queue.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class KakaoQueueService { +} diff --git a/src/main/java/com/munjaon/server/queue/service/LmsQueueService.java b/src/main/java/com/munjaon/server/queue/service/LmsQueueService.java new file mode 100644 index 0000000..8cd9a77 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/service/LmsQueueService.java @@ -0,0 +1,11 @@ +package com.munjaon.server.queue.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class LmsQueueService { +} diff --git a/src/main/java/com/munjaon/server/queue/service/MmsQueueService.java b/src/main/java/com/munjaon/server/queue/service/MmsQueueService.java new file mode 100644 index 0000000..7e4d5b4 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/service/MmsQueueService.java @@ -0,0 +1,11 @@ +package com.munjaon.server.queue.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class MmsQueueService { +} diff --git a/src/main/java/com/munjaon/server/queue/service/QueueServiceInjector.java b/src/main/java/com/munjaon/server/queue/service/QueueServiceInjector.java new file mode 100644 index 0000000..a220587 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/service/QueueServiceInjector.java @@ -0,0 +1,37 @@ +package com.munjaon.server.queue.service; + +import com.munjaon.server.queue.enums.QueueService; +import jakarta.annotation.PostConstruct; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.EnumSet; + +@Component +public class QueueServiceInjector { + @Autowired + private SmsQueueService smsQueueService; + @Autowired + private LmsQueueService lmsQueueService; + @Autowired + private MmsQueueService mmsQueueService; + @Autowired + private KakaoQueueService kakaoQueueService; + + @PostConstruct + public void postConstruct() { + for (QueueService svc : EnumSet.allOf(QueueService.class)) { + switch (svc) { + case SMS_QUEUE: svc.setService(smsQueueService); + break; + case LMS_QUEUE: svc.setService(lmsQueueService); + break; + case MMS_QUEUE: svc.setService(mmsQueueService); + break; + case KAKAO_QUEUE: svc.setService(kakaoQueueService); + break; + default: break; + } + } + } +} diff --git a/src/main/java/com/munjaon/server/queue/service/SmsQueueService.java b/src/main/java/com/munjaon/server/queue/service/SmsQueueService.java new file mode 100644 index 0000000..b923af7 --- /dev/null +++ b/src/main/java/com/munjaon/server/queue/service/SmsQueueService.java @@ -0,0 +1,11 @@ +package com.munjaon.server.queue.service; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class SmsQueueService { +} diff --git a/src/main/java/com/munjaon/server/scheduler/mapper/SchedulerMapper.java b/src/main/java/com/munjaon/server/scheduler/mapper/SchedulerMapper.java new file mode 100644 index 0000000..17a56e1 --- /dev/null +++ b/src/main/java/com/munjaon/server/scheduler/mapper/SchedulerMapper.java @@ -0,0 +1,8 @@ +package com.munjaon.server.scheduler.mapper; + +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SchedulerMapper { + int get(); +} diff --git a/src/main/java/com/munjaon/server/scheduler/service/CacheScheduleService.java b/src/main/java/com/munjaon/server/scheduler/service/CacheScheduleService.java new file mode 100644 index 0000000..63de942 --- /dev/null +++ b/src/main/java/com/munjaon/server/scheduler/service/CacheScheduleService.java @@ -0,0 +1,49 @@ +package com.munjaon.server.scheduler.service; + +import com.munjaon.server.cache.service.MemberService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +@RequiredArgsConstructor +public class CacheScheduleService { + private final MemberService memberService; + + @Value("${agent.db-name}") + private String tableSchema; + /* 사용자 테이블 마지막 업데이트 시간 */ + private String member_last_modified_time = null; + + @Scheduled(cron="0/5 * * * * *") + public void doService() throws Exception { + doMemberService(); + } + + private void doMemberService() { + if (member_last_modified_time == null) { + log.info("Member List Info is First Caching~~~"); + memberService.deleteAllMember(); +// memberService.list(); + + /* 회원 정보 마지막 변경시간 저장 */ + member_last_modified_time = memberService.getLastModifiedTime(tableSchema); + return; + } + + /* 변경이 없는 경우 */ + if (member_last_modified_time.equals(memberService.getLastModifiedTime(tableSchema))) { + return; + } + + /* 테이블에 변경이 있는 경우 */ + log.info("Member List Info is Delete And Caching~~~"); + memberService.deleteAllMember(); +// memberService.list(); + /* 회원 정보 마지막 변경시간 저장 */ + member_last_modified_time = memberService.getLastModifiedTime(tableSchema); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..ea3d1c8 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,11 @@ +spring: + application: + name: munjaon_server + profiles: + default: local + +mybatis: + configuration: + map-underscore-to-camel-case: true + type-aliases-package: com.munjaon.server.**.dto + mapper-locations: classpath:/sqlmap/**/*.xml \ No newline at end of file diff --git a/src/main/resources/dev/application-dev.yml b/src/main/resources/dev/application-dev.yml new file mode 100644 index 0000000..c9d6800 --- /dev/null +++ b/src/main/resources/dev/application-dev.yml @@ -0,0 +1,16 @@ +spring: + datasource: + server: + driver-class-name: org.mariadb.jdbc.Driver + jdbc-url: jdbc:mariadb://119.193.215.98:3306/mjon_agent + username: mjonUr_agent + password: mjagent123$ + +server: + port: 8090 + shutdown: graceful + +# ### 에이전트 설정 관련 #################################################################################### +agent: + server-property-file: C:/apps/agent_server/config/server.properties + db-name: mjon_agent_back \ No newline at end of file diff --git a/src/main/resources/local/application-local.yml b/src/main/resources/local/application-local.yml new file mode 100644 index 0000000..b673333 --- /dev/null +++ b/src/main/resources/local/application-local.yml @@ -0,0 +1,16 @@ +spring: + datasource: + server: + driver-class-name: org.mariadb.jdbc.Driver + jdbc-url: jdbc:mariadb://119.193.215.98:3306/mjon_agent_back + username: mjonUr_agent + password: mjagent123$ + +server: + port: 8090 + shutdown: graceful + +# ### 에이전트 설정 관련 #################################################################################### +agent: + server-property-file: C:/apps/agent_server/config/server.properties + db-name: mjon_agent_back \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..704d5bc --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,80 @@ + + + + + + + + + ${LOG_PATTERN} + + + + + + + + + + + ./log/info/info-${BY_DATE}.log + + INFO + ACCEPT + DENY + + + ${LOG_PATTERN} + + + ./backup/info/info-%d{yyyy-MM-dd}.%i.log + 100MB + 30 + 3GB + + + + + ./log/warn/warn-${BY_DATE}.log + + WARN + ACCEPT + DENY + + + ${LOG_PATTERN} + + + ./backup/warn/warn-%d{yyyy-MM-dd}.%i.log + 100MB + 30 + 3GB + + + + + ./log/error/error-${BY_DATE}.log + + ERROR + ACCEPT + DENY + + + ${LOG_PATTERN} + + + ./backup/error/error-%d{yyyy-MM-dd}.%i.log + 100MB + 30 + 3GB + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis-config.xml b/src/main/resources/mybatis-config.xml new file mode 100644 index 0000000..31cad6d --- /dev/null +++ b/src/main/resources/mybatis-config.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/prod/application-prod.yml b/src/main/resources/prod/application-prod.yml new file mode 100644 index 0000000..596b0b7 --- /dev/null +++ b/src/main/resources/prod/application-prod.yml @@ -0,0 +1,16 @@ +spring: + datasource: + server: + driver-class-name: org.mariadb.jdbc.Driver + jdbc-url: jdbc:mariadb://119.193.215.98:3306/mjon_agent + username: mjonUr_agent + password: mjagent123$ + +server: + port: 8090 + shutdown: graceful + +# ### 에이전트 설정 관련 #################################################################################### +agent: + server-property-file: C:/apps/agent_server/config/server.properties + db-name: mjon_agent_back diff --git a/src/main/resources/sqlmap/member_sql.xml b/src/main/resources/sqlmap/member_sql.xml new file mode 100644 index 0000000..dab6612 --- /dev/null +++ b/src/main/resources/sqlmap/member_sql.xml @@ -0,0 +1,54 @@ + + + + + + + + UPDATE lettngnrlmber SET MBER_STTUS = #{mberSttus} WHERE MBER_ID = #{mberId} + + \ No newline at end of file diff --git a/src/main/resources/sqlmap/sample_sql.xml b/src/main/resources/sqlmap/sample_sql.xml new file mode 100644 index 0000000..2d07b23 --- /dev/null +++ b/src/main/resources/sqlmap/sample_sql.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/src/main/resources/sqlmap/scheduler_sql.xml b/src/main/resources/sqlmap/scheduler_sql.xml new file mode 100644 index 0000000..c92a1d3 --- /dev/null +++ b/src/main/resources/sqlmap/scheduler_sql.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/src/test/java/com/munjaon/server/MunjaonServerApplicationTests.java b/src/test/java/com/munjaon/server/MunjaonServerApplicationTests.java new file mode 100644 index 0000000..02d04bf --- /dev/null +++ b/src/test/java/com/munjaon/server/MunjaonServerApplicationTests.java @@ -0,0 +1,13 @@ +package com.munjaon.server; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class MunjaonServerApplicationTests { + + @Test + void contextLoads() { + } + +}