initial commit
This commit is contained in:
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space # 탭 대신 공백 사용 (탭 문자 발생 방지)
|
||||||
|
indent_size = 4 # 공백은 4칸으로 고정
|
||||||
|
end_of_line = lf # 줄바꿈은 무조건 LF로 통일 (리눅스 방식)
|
||||||
|
charset = utf-8 # 인코딩 통일
|
||||||
|
trim_trailing_whitespace = true # 줄 끝의 불필요한 공백 제거
|
||||||
|
insert_final_newline = true # 파일 끝에 빈 줄 하나 추가
|
||||||
77
.gitignore
vendored
Normal file
77
.gitignore
vendored
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
# --- Build outputs ---
|
||||||
|
/target/
|
||||||
|
/build/
|
||||||
|
/out/
|
||||||
|
|
||||||
|
# --- Maven ---
|
||||||
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
|
.mvn/wrapper/maven-wrapper.properties
|
||||||
|
.settings/
|
||||||
|
|
||||||
|
# --- Gradle ---
|
||||||
|
.gradle/
|
||||||
|
/gradle/
|
||||||
|
/gradlew
|
||||||
|
gradlew.bat
|
||||||
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# --- Logs ---
|
||||||
|
*.log
|
||||||
|
logs/
|
||||||
|
log/
|
||||||
|
|
||||||
|
# --- Spring Boot ---
|
||||||
|
*.pid
|
||||||
|
*.pid.lock
|
||||||
|
*.iml
|
||||||
|
|
||||||
|
# --- IDE (IntelliJ / Eclipse / STS / VSCode) ---
|
||||||
|
.idea/
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
.factorypath
|
||||||
|
.settings/
|
||||||
|
.springBeans
|
||||||
|
.springdsl
|
||||||
|
|
||||||
|
.vscode/
|
||||||
|
.history/
|
||||||
|
.remote/
|
||||||
|
|
||||||
|
# --- OS specific ---
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# --- Temporary / cache ---
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*.orig
|
||||||
|
.cache/
|
||||||
|
tmp/
|
||||||
|
bin/
|
||||||
|
generated/
|
||||||
|
|
||||||
|
# --- Security / credentials (예: 환경변수 파일) ---
|
||||||
|
.env
|
||||||
|
*.key
|
||||||
|
*.pem
|
||||||
|
*.p12
|
||||||
|
# application-*.yml
|
||||||
|
# application-*.properties
|
||||||
|
# application.properties
|
||||||
|
|
||||||
|
# --- Docker ---
|
||||||
|
/docker-compose.override.yml
|
||||||
|
|
||||||
|
# --- API Test Tool ---
|
||||||
|
api_test_tool/
|
||||||
117
.mvn/wrapper/MavenWrapperDownloader.java
vendored
Normal file
117
.mvn/wrapper/MavenWrapperDownloader.java
vendored
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2007-present the original author or 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.
|
||||||
|
*/
|
||||||
|
import java.net.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.channels.*;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class MavenWrapperDownloader {
|
||||||
|
|
||||||
|
private static final String WRAPPER_VERSION = "0.5.6";
|
||||||
|
/**
|
||||||
|
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
||||||
|
*/
|
||||||
|
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||||
|
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
||||||
|
* use instead of the default one.
|
||||||
|
*/
|
||||||
|
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||||
|
".mvn/wrapper/maven-wrapper.properties";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path where the maven-wrapper.jar will be saved to.
|
||||||
|
*/
|
||||||
|
private static final String MAVEN_WRAPPER_JAR_PATH =
|
||||||
|
".mvn/wrapper/maven-wrapper.jar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the property which should be used to override the default download url for the wrapper.
|
||||||
|
*/
|
||||||
|
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||||
|
|
||||||
|
public static void main(String args[]) {
|
||||||
|
System.out.println("- Downloader started");
|
||||||
|
File baseDirectory = new File(args[0]);
|
||||||
|
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||||
|
|
||||||
|
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||||
|
// wrapperUrl parameter.
|
||||||
|
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||||
|
String url = DEFAULT_DOWNLOAD_URL;
|
||||||
|
if(mavenWrapperPropertyFile.exists()) {
|
||||||
|
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||||
|
try {
|
||||||
|
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||||
|
Properties mavenWrapperProperties = new Properties();
|
||||||
|
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||||
|
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if(mavenWrapperPropertyFileInputStream != null) {
|
||||||
|
mavenWrapperPropertyFileInputStream.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Ignore ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("- Downloading from: " + url);
|
||||||
|
|
||||||
|
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||||
|
if(!outputFile.getParentFile().exists()) {
|
||||||
|
if(!outputFile.getParentFile().mkdirs()) {
|
||||||
|
System.out.println(
|
||||||
|
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||||
|
try {
|
||||||
|
downloadFileFromURL(url, outputFile);
|
||||||
|
System.out.println("Done");
|
||||||
|
System.exit(0);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
System.out.println("- Error downloading");
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||||
|
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||||
|
String username = System.getenv("MVNW_USERNAME");
|
||||||
|
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||||
|
Authenticator.setDefault(new Authenticator() {
|
||||||
|
@Override
|
||||||
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
|
return new PasswordAuthentication(username, password);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
URL website = new URL(urlString);
|
||||||
|
ReadableByteChannel rbc;
|
||||||
|
rbc = Channels.newChannel(website.openStream());
|
||||||
|
FileOutputStream fos = new FileOutputStream(destination);
|
||||||
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
|
fos.close();
|
||||||
|
rbc.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
83
deploy-aws.sh
Normal file
83
deploy-aws.sh
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# AWS 서버 파일 업로드 스크립트
|
||||||
|
# 사용법: ./deploy-aws.sh <aws-server> <aws-user> <aws-key> <jar-file> <deploy-path>
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
AWS_SERVER=$1
|
||||||
|
AWS_USER=$2
|
||||||
|
AWS_KEY_PATH=$3
|
||||||
|
JAR_FILE=$4
|
||||||
|
DEPLOY_PATH=$5
|
||||||
|
|
||||||
|
if [ -z "$AWS_SERVER" ] || [ -z "$AWS_USER" ] || [ -z "$AWS_KEY_PATH" ] || [ -z "$JAR_FILE" ] || [ -z "$DEPLOY_PATH" ]; then
|
||||||
|
echo "사용법: $0 <aws-server> <aws-user> <aws-key> <jar-file> <deploy-path>"
|
||||||
|
echo "예시: $0 47.129.51.216 root /path/to/key.pem target/core.jar /home/run"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== AWS 서버 파일 업로드 시작 ==="
|
||||||
|
echo "AWS Server: $AWS_SERVER"
|
||||||
|
echo "AWS User: $AWS_USER"
|
||||||
|
echo "JAR File: $JAR_FILE"
|
||||||
|
echo "Deploy Path: $DEPLOY_PATH"
|
||||||
|
|
||||||
|
# JAR 파일 존재 확인
|
||||||
|
if [ ! -f "$JAR_FILE" ]; then
|
||||||
|
echo "❌ JAR 파일을 찾을 수 없습니다: $JAR_FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# AWS 키 파일 존재 확인
|
||||||
|
if [ ! -f "$AWS_KEY_PATH" ]; then
|
||||||
|
echo "❌ AWS 키 파일을 찾을 수 없습니다: $AWS_KEY_PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# AWS 서버 연결 테스트
|
||||||
|
echo "AWS 서버 연결 테스트 중..."
|
||||||
|
ssh -i "$AWS_KEY_PATH" -o ConnectTimeout=10 -o StrictHostKeyChecking=no "$AWS_USER@$AWS_SERVER" "echo 'AWS 서버 연결 성공'"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "❌ AWS 서버 연결 실패"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# AWS 서버에서 배포 디렉토리 생성 및 권한 설정 (root 권한으로)
|
||||||
|
echo "AWS 서버에서 배포 디렉토리 생성 중... (root 권한)"
|
||||||
|
ssh -i "$AWS_KEY_PATH" "$AWS_USER@$AWS_SERVER" "sudo su - root <<'ROOT_SETUP'
|
||||||
|
# 배포 디렉토리 및 로그 디렉토리 생성
|
||||||
|
mkdir -p $DEPLOY_PATH/logs
|
||||||
|
chmod -R 755 $DEPLOY_PATH
|
||||||
|
echo '배포 디렉토리 생성 완료: $DEPLOY_PATH'
|
||||||
|
ROOT_SETUP
|
||||||
|
"
|
||||||
|
|
||||||
|
# JAR 파일 이름 추출
|
||||||
|
JAR_FILENAME=$(basename "$JAR_FILE")
|
||||||
|
|
||||||
|
# JAR 파일을 AWS 서버로 전송
|
||||||
|
echo "JAR 파일을 AWS 서버로 전송 중..."
|
||||||
|
scp -i "$AWS_KEY_PATH" "$JAR_FILE" "$AWS_USER@$AWS_SERVER:$DEPLOY_PATH/$JAR_FILENAME"
|
||||||
|
|
||||||
|
# JAR 파일 권한 설정 (root가 읽을 수 있도록)
|
||||||
|
echo "JAR 파일 권한 설정 중... (root 권한)"
|
||||||
|
ssh -i "$AWS_KEY_PATH" "$AWS_USER@$AWS_SERVER" "sudo su - root <<'ROOT_CHMOD'
|
||||||
|
chmod 644 $DEPLOY_PATH/$JAR_FILENAME
|
||||||
|
echo 'JAR 파일 권한 설정 완료'
|
||||||
|
echo '업로드된 파일: $DEPLOY_PATH/$JAR_FILENAME'
|
||||||
|
ls -lh $DEPLOY_PATH/$JAR_FILENAME
|
||||||
|
ROOT_CHMOD
|
||||||
|
"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "✅ AWS 서버 파일 업로드 성공!"
|
||||||
|
echo "JAR 파일이 $DEPLOY_PATH/$JAR_FILENAME 에 업로드되었습니다."
|
||||||
|
else
|
||||||
|
echo "❌ AWS 서버 파일 업로드 실패!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== AWS 서버 파일 업로드 완료 ==="
|
||||||
|
|
||||||
96
deploy-aws2.sh
Normal file
96
deploy-aws2.sh
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# AWS 서버 파일 업로드 스크립트
|
||||||
|
# 사용법: ./deploy-aws.sh <aws-server> <aws-user> <aws-key> <jar-file> <deploy-path>
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
AWS_SERVER=$1
|
||||||
|
AWS_USER=$2
|
||||||
|
AWS_KEY_PATH=$3
|
||||||
|
JAR_FILE=$4
|
||||||
|
DEPLOY_PATH=$5
|
||||||
|
|
||||||
|
if [ -z "$AWS_SERVER" ] || [ -z "$AWS_USER" ] || [ -z "$AWS_KEY_PATH" ] || [ -z "$JAR_FILE" ] || [ -z "$DEPLOY_PATH" ]; then
|
||||||
|
echo "사용법: $0 <aws-server> <aws-user> <aws-key> <jar-file> <deploy-path>"
|
||||||
|
echo "예시: $0 47.129.51.216 root /path/to/key.pem target/core.jar /home/run"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== AWS 서버 파일 업로드 시작 ==="
|
||||||
|
echo "AWS Server: $AWS_SERVER"
|
||||||
|
echo "AWS User: $AWS_USER"
|
||||||
|
echo "JAR File: $JAR_FILE"
|
||||||
|
echo "Deploy Path: $DEPLOY_PATH"
|
||||||
|
|
||||||
|
# JAR 파일 존재 확인
|
||||||
|
if [ ! -f "$JAR_FILE" ]; then
|
||||||
|
echo "❌ JAR 파일을 찾을 수 없습니다: $JAR_FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# AWS 키 파일 존재 확인
|
||||||
|
if [ ! -f "$AWS_KEY_PATH" ]; then
|
||||||
|
echo "❌ AWS 키 파일을 찾을 수 없습니다: $AWS_KEY_PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# AWS 서버 연결 테스트
|
||||||
|
echo "AWS 서버 연결 테스트 중..."
|
||||||
|
ssh -i "$AWS_KEY_PATH" -o ConnectTimeout=10 -o StrictHostKeyChecking=no "$AWS_USER@$AWS_SERVER" "echo 'AWS 서버 연결 성공'"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "❌ AWS 서버 연결 실패"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# AWS 서버에서 배포 디렉토리 생성 및 권한 설정 (root 권한으로)
|
||||||
|
echo "AWS 서버에서 배포 디렉토리 생성 중... (root 권한)"
|
||||||
|
ssh -i "$AWS_KEY_PATH" "$AWS_USER@$AWS_SERVER" "sudo su - root <<ROOT_SETUP
|
||||||
|
# 배포 디렉토리 및 로그 디렉토리 생성
|
||||||
|
mkdir -p $DEPLOY_PATH/logs
|
||||||
|
chmod -R 755 $DEPLOY_PATH
|
||||||
|
echo '배포 디렉토리 생성 완료: $DEPLOY_PATH'
|
||||||
|
ROOT_SETUP
|
||||||
|
"
|
||||||
|
|
||||||
|
# JAR 파일 이름 추출
|
||||||
|
JAR_FILENAME=$(basename "$JAR_FILE")
|
||||||
|
|
||||||
|
# 임시 업로드 경로 (rocky 계정 홈 디렉토리)
|
||||||
|
TEMP_PATH="/home/$AWS_USER/temp_${JAR_FILENAME}"
|
||||||
|
|
||||||
|
# JAR 파일을 AWS 서버의 임시 위치로 전송 (rocky 계정 권한으로)
|
||||||
|
echo "JAR 파일을 AWS 서버 임시 위치로 전송 중..."
|
||||||
|
scp -i "$AWS_KEY_PATH" "$JAR_FILE" "$AWS_USER@$AWS_SERVER:$TEMP_PATH"
|
||||||
|
|
||||||
|
# 임시 파일을 최종 위치로 이동 및 권한 설정 (root 권한으로)
|
||||||
|
echo "JAR 파일을 최종 위치로 이동 중... (root 권한)"
|
||||||
|
ssh -i "$AWS_KEY_PATH" "$AWS_USER@$AWS_SERVER" "sudo su - root <<ROOT_MOVE
|
||||||
|
# 배포 디렉토리 확인 및 생성
|
||||||
|
mkdir -p $DEPLOY_PATH
|
||||||
|
chmod -R 755 $DEPLOY_PATH
|
||||||
|
|
||||||
|
# 임시 파일을 최종 위치로 이동
|
||||||
|
mv $TEMP_PATH $DEPLOY_PATH/$JAR_FILENAME
|
||||||
|
|
||||||
|
# 파일 권한 설정
|
||||||
|
chmod 644 $DEPLOY_PATH/$JAR_FILENAME
|
||||||
|
chown root:root $DEPLOY_PATH/$JAR_FILENAME
|
||||||
|
|
||||||
|
echo 'JAR 파일 이동 및 권한 설정 완료'
|
||||||
|
echo '업로드된 파일: $DEPLOY_PATH/$JAR_FILENAME'
|
||||||
|
ls -lh $DEPLOY_PATH/$JAR_FILENAME
|
||||||
|
ROOT_MOVE
|
||||||
|
"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "✅ AWS 서버 파일 업로드 성공!"
|
||||||
|
echo "JAR 파일이 $DEPLOY_PATH/$JAR_FILENAME 에 업로드되었습니다."
|
||||||
|
else
|
||||||
|
echo "❌ AWS 서버 파일 업로드 실패!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== AWS 서버 파일 업로드 완료 ==="
|
||||||
|
|
||||||
BIN
filePath_IS_UNDEFINED/error-2026-01-07.0.gz
Normal file
BIN
filePath_IS_UNDEFINED/error-2026-01-07.0.gz
Normal file
Binary file not shown.
90
jenkinsfile
Normal file
90
jenkinsfile
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
environment {
|
||||||
|
JAVA_HOME = '/var/lib/jenkins/tools/openjdk17'
|
||||||
|
MAVEN_HOME = '/usr/share/maven'
|
||||||
|
PATH = "${MAVEN_HOME}/bin:${JAVA_HOME}/bin:${PATH}"
|
||||||
|
APP_NAME = 'triple'
|
||||||
|
VERSION = '0.0.1-SNAPSHOT'
|
||||||
|
JAR_FILE = "target/triple.jar"
|
||||||
|
AWS_SERVER = '13.215.48.238'
|
||||||
|
AWS_USER = 'root'
|
||||||
|
DEPLOY_PATH = '/home/build' // 빌드 산출물 업로드 경로
|
||||||
|
RUN_PATH = '/home/run' // 실행 경로
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Checkout') {
|
||||||
|
steps {
|
||||||
|
checkout scm
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
sh 'echo "Building application..."'
|
||||||
|
script {
|
||||||
|
def mvnHome = tool 'maven'
|
||||||
|
sh "${mvnHome}/bin/mvn clean package -Pdev -DskipTests -Dspring.profiles.active=dev"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Archive Artifacts') {
|
||||||
|
steps {
|
||||||
|
sh 'echo "Checking JAR file..."'
|
||||||
|
sh 'ls -la target/'
|
||||||
|
sh 'ls -la target/*.jar'
|
||||||
|
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Deploy to AWS') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// 실제 빌드된 JAR 파일 찾기
|
||||||
|
def jarFiles = sh(
|
||||||
|
script: 'find target -name "*.jar" -not -name "*-sources.jar" -not -name "*-javadoc.jar" | head -1',
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
if (!jarFiles) {
|
||||||
|
error "JAR 파일을 찾을 수 없습니다."
|
||||||
|
}
|
||||||
|
|
||||||
|
def actualJarFile = jarFiles.split('\n')[0]
|
||||||
|
echo "실제 JAR 파일: ${actualJarFile}"
|
||||||
|
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: 'coreserver', keyFileVariable: 'SSH_KEY')]) {
|
||||||
|
sh """
|
||||||
|
echo "Deploying to AWS server..."
|
||||||
|
chmod +x deploy-aws.sh
|
||||||
|
./deploy-aws.sh ${AWS_SERVER} ${AWS_USER} "\${SSH_KEY}" ${actualJarFile} ${DEPLOY_PATH}
|
||||||
|
echo "Uploading and running runApi.sh..."
|
||||||
|
chmod +x runApi.sh
|
||||||
|
scp -i "\${SSH_KEY}" runApi.sh ${AWS_USER}@${AWS_SERVER}:${RUN_PATH}/runApi.sh
|
||||||
|
ssh -i "\${SSH_KEY}" ${AWS_USER}@${AWS_SERVER} "chmod +x ${RUN_PATH}/runApi.sh && JAR_NAME=\$(basename ${actualJarFile}) BUILD_DIR=${DEPLOY_PATH} RUN_DIR=${RUN_PATH} ${RUN_PATH}/runApi.sh"
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
echo 'Pipeline succeeded!'
|
||||||
|
// 슬랙 알림 등 추가 가능
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
echo 'Pipeline failed!'
|
||||||
|
// 실패 알림 등 추가 가능
|
||||||
|
}
|
||||||
|
always {
|
||||||
|
// 빌드 결과 정리
|
||||||
|
sh 'echo "Build completed"'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
90
jenkinsfile2
Normal file
90
jenkinsfile2
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
environment {
|
||||||
|
JAVA_HOME = '/var/lib/jenkins/tools/openjdk17'
|
||||||
|
MAVEN_HOME = '/usr/share/maven'
|
||||||
|
PATH = "${MAVEN_HOME}/bin:${JAVA_HOME}/bin:${PATH}"
|
||||||
|
APP_NAME = 'triple'
|
||||||
|
VERSION = '0.0.1-SNAPSHOT'
|
||||||
|
JAR_FILE = "target/triple.jar"
|
||||||
|
AWS_SERVER = '13.229.206.39'
|
||||||
|
AWS_USER = 'rocky'
|
||||||
|
DEPLOY_PATH = '/home/build' // 빌드 산출물 업로드 경로
|
||||||
|
RUN_PATH = '/home/run' // 실행 경로
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Checkout') {
|
||||||
|
steps {
|
||||||
|
checkout scm
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
sh 'echo "Building application..."'
|
||||||
|
script {
|
||||||
|
def mvnHome = tool 'maven'
|
||||||
|
sh "${mvnHome}/bin/mvn clean package -Pdev -DskipTests -Dspring.profiles.active=dev"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Archive Artifacts') {
|
||||||
|
steps {
|
||||||
|
sh 'echo "Checking JAR file..."'
|
||||||
|
sh 'ls -la target/'
|
||||||
|
sh 'ls -la target/*.jar'
|
||||||
|
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Deploy to AWS') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// 실제 빌드된 JAR 파일 찾기
|
||||||
|
def jarFiles = sh(
|
||||||
|
script: 'find target -name "*.jar" -not -name "*-sources.jar" -not -name "*-javadoc.jar" | head -1',
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
if (!jarFiles) {
|
||||||
|
error "JAR 파일을 찾을 수 없습니다."
|
||||||
|
}
|
||||||
|
|
||||||
|
def actualJarFile = jarFiles.split('\n')[0]
|
||||||
|
echo "실제 JAR 파일: ${actualJarFile}"
|
||||||
|
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: 'coreserver2', keyFileVariable: 'SSH_KEY')]) {
|
||||||
|
sh """
|
||||||
|
echo "Deploying to AWS server..."
|
||||||
|
chmod +x deploy-aws2.sh
|
||||||
|
./deploy-aws2.sh ${AWS_SERVER} ${AWS_USER} "\${SSH_KEY}" ${actualJarFile} ${DEPLOY_PATH}
|
||||||
|
echo "Uploading and running runApi.sh..."
|
||||||
|
chmod +x runApi.sh
|
||||||
|
scp -i "\${SSH_KEY}" runApi.sh ${AWS_USER}@${AWS_SERVER}:/home/${AWS_USER}/temp_runApi.sh
|
||||||
|
ssh -i "\${SSH_KEY}" ${AWS_USER}@${AWS_SERVER} "sudo -i bash -c 'mv /home/${AWS_USER}/temp_runApi.sh ${RUN_PATH}/runApi.sh && chmod +x ${RUN_PATH}/runApi.sh && JAR_NAME=\$(basename ${actualJarFile}) BUILD_DIR=${DEPLOY_PATH} RUN_DIR=${RUN_PATH} ${RUN_PATH}/runApi.sh'"
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
echo 'Pipeline succeeded!'
|
||||||
|
// 슬랙 알림 등 추가 가능
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
echo 'Pipeline failed!'
|
||||||
|
// 실패 알림 등 추가 가능
|
||||||
|
}
|
||||||
|
always {
|
||||||
|
// 빌드 결과 정리
|
||||||
|
sh 'echo "Build completed"'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
310
mvnw
vendored
Normal file
310
mvnw
vendored
Normal file
@@ -0,0 +1,310 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you 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.
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Maven Start Up Batch script
|
||||||
|
#
|
||||||
|
# Required ENV vars:
|
||||||
|
# ------------------
|
||||||
|
# JAVA_HOME - location of a JDK home dir
|
||||||
|
#
|
||||||
|
# Optional ENV vars
|
||||||
|
# -----------------
|
||||||
|
# M2_HOME - location of maven2's installed home dir
|
||||||
|
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||||
|
# e.g. to debug Maven itself, use
|
||||||
|
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||||
|
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||||
|
|
||||||
|
if [ -f /etc/mavenrc ] ; then
|
||||||
|
. /etc/mavenrc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$HOME/.mavenrc" ] ; then
|
||||||
|
. "$HOME/.mavenrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# OS specific support. $var _must_ be set to either true or false.
|
||||||
|
cygwin=false;
|
||||||
|
darwin=false;
|
||||||
|
mingw=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN*) cygwin=true ;;
|
||||||
|
MINGW*) mingw=true;;
|
||||||
|
Darwin*) darwin=true
|
||||||
|
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||||
|
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||||
|
if [ -z "$JAVA_HOME" ]; then
|
||||||
|
if [ -x "/usr/libexec/java_home" ]; then
|
||||||
|
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||||
|
else
|
||||||
|
export JAVA_HOME="/Library/Java/Home"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ] ; then
|
||||||
|
if [ -r /etc/gentoo-release ] ; then
|
||||||
|
JAVA_HOME=`java-config --jre-home`
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$M2_HOME" ] ; then
|
||||||
|
## resolve links - $0 may be a link to maven's home
|
||||||
|
PRG="$0"
|
||||||
|
|
||||||
|
# need this for relative symlinks
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG="`dirname "$PRG"`/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
saveddir=`pwd`
|
||||||
|
|
||||||
|
M2_HOME=`dirname "$PRG"`/..
|
||||||
|
|
||||||
|
# make it fully qualified
|
||||||
|
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||||
|
|
||||||
|
cd "$saveddir"
|
||||||
|
# echo Using m2 at $M2_HOME
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||||
|
if $cygwin ; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||||
|
[ -n "$CLASSPATH" ] &&
|
||||||
|
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||||
|
if $mingw ; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ]; then
|
||||||
|
javaExecutable="`which javac`"
|
||||||
|
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||||
|
# readlink(1) is not available as standard on Solaris 10.
|
||||||
|
readLink=`which readlink`
|
||||||
|
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||||
|
if $darwin ; then
|
||||||
|
javaHome="`dirname \"$javaExecutable\"`"
|
||||||
|
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||||
|
else
|
||||||
|
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||||
|
fi
|
||||||
|
javaHome="`dirname \"$javaExecutable\"`"
|
||||||
|
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||||
|
JAVA_HOME="$javaHome"
|
||||||
|
export JAVA_HOME
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVACMD" ] ; then
|
||||||
|
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
|
||||||
|
else
|
||||||
|
JAVACMD="`which java`"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||||
|
echo " We cannot execute $JAVACMD" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JAVA_HOME" ] ; then
|
||||||
|
echo "Warning: JAVA_HOME environment variable is not set."
|
||||||
|
fi
|
||||||
|
|
||||||
|
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||||
|
|
||||||
|
# traverses directory structure from process work directory to filesystem root
|
||||||
|
# first directory with .mvn subdirectory is considered project base directory
|
||||||
|
find_maven_basedir() {
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "Path not specified to find_maven_basedir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
basedir="$1"
|
||||||
|
wdir="$1"
|
||||||
|
while [ "$wdir" != '/' ] ; do
|
||||||
|
if [ -d "$wdir"/.mvn ] ; then
|
||||||
|
basedir=$wdir
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||||
|
if [ -d "${wdir}" ]; then
|
||||||
|
wdir=`cd "$wdir/.."; pwd`
|
||||||
|
fi
|
||||||
|
# end of workaround
|
||||||
|
done
|
||||||
|
echo "${basedir}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# concatenates all lines of a file
|
||||||
|
concat_lines() {
|
||||||
|
if [ -f "$1" ]; then
|
||||||
|
echo "$(tr -s '\n' ' ' < "$1")"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||||
|
if [ -z "$BASE_DIR" ]; then
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||||
|
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||||
|
##########################################################################################
|
||||||
|
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||||
|
fi
|
||||||
|
if [ -n "$MVNW_REPOURL" ]; then
|
||||||
|
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||||
|
else
|
||||||
|
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||||
|
fi
|
||||||
|
while IFS="=" read key value; do
|
||||||
|
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||||
|
esac
|
||||||
|
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Downloading from: $jarUrl"
|
||||||
|
fi
|
||||||
|
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||||
|
if $cygwin; then
|
||||||
|
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v wget > /dev/null; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Found wget ... using wget"
|
||||||
|
fi
|
||||||
|
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||||
|
wget "$jarUrl" -O "$wrapperJarPath"
|
||||||
|
else
|
||||||
|
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
|
||||||
|
fi
|
||||||
|
elif command -v curl > /dev/null; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Found curl ... using curl"
|
||||||
|
fi
|
||||||
|
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||||
|
curl -o "$wrapperJarPath" "$jarUrl" -f
|
||||||
|
else
|
||||||
|
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo "Falling back to using Java to download"
|
||||||
|
fi
|
||||||
|
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||||
|
# For Cygwin, switch paths to Windows format before running javac
|
||||||
|
if $cygwin; then
|
||||||
|
javaClass=`cygpath --path --windows "$javaClass"`
|
||||||
|
fi
|
||||||
|
if [ -e "$javaClass" ]; then
|
||||||
|
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||||
|
fi
|
||||||
|
# Compiling the Java class
|
||||||
|
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||||
|
fi
|
||||||
|
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||||
|
# Running the downloader
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo " - Running MavenWrapperDownloader.java ..."
|
||||||
|
fi
|
||||||
|
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
##########################################################################################
|
||||||
|
# End of extension
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||||
|
if [ "$MVNW_VERBOSE" = true ]; then
|
||||||
|
echo $MAVEN_PROJECTBASEDIR
|
||||||
|
fi
|
||||||
|
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin; then
|
||||||
|
[ -n "$M2_HOME" ] &&
|
||||||
|
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||||
|
[ -n "$JAVA_HOME" ] &&
|
||||||
|
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||||
|
[ -n "$CLASSPATH" ] &&
|
||||||
|
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||||
|
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||||
|
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Provide a "standardized" way to retrieve the CLI args that will
|
||||||
|
# work with both Windows and non-Windows executions.
|
||||||
|
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||||
|
export MAVEN_CMD_LINE_ARGS
|
||||||
|
|
||||||
|
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
|
exec "$JAVACMD" \
|
||||||
|
$MAVEN_OPTS \
|
||||||
|
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||||
|
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||||
|
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
||||||
182
mvnw.cmd
vendored
Normal file
182
mvnw.cmd
vendored
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@REM or more contributor license agreements. See the NOTICE file
|
||||||
|
@REM distributed with this work for additional information
|
||||||
|
@REM regarding copyright ownership. The ASF licenses this file
|
||||||
|
@REM to you under the Apache License, Version 2.0 (the
|
||||||
|
@REM "License"); you may not use this file except in compliance
|
||||||
|
@REM with the License. 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,
|
||||||
|
@REM software distributed under the License is distributed on an
|
||||||
|
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
@REM KIND, either express or implied. See the License for the
|
||||||
|
@REM specific language governing permissions and limitations
|
||||||
|
@REM under the License.
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Maven Start Up Batch script
|
||||||
|
@REM
|
||||||
|
@REM Required ENV vars:
|
||||||
|
@REM JAVA_HOME - location of a JDK home dir
|
||||||
|
@REM
|
||||||
|
@REM Optional ENV vars
|
||||||
|
@REM M2_HOME - location of maven2's installed home dir
|
||||||
|
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||||
|
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||||
|
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||||
|
@REM e.g. to debug Maven itself, use
|
||||||
|
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||||
|
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||||
|
@echo off
|
||||||
|
@REM set title of command window
|
||||||
|
title %0
|
||||||
|
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||||
|
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||||
|
|
||||||
|
@REM set %HOME% to equivalent of $HOME
|
||||||
|
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||||
|
|
||||||
|
@REM Execute a user defined script before this one
|
||||||
|
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||||
|
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||||
|
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||||
|
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||||
|
:skipRcPre
|
||||||
|
|
||||||
|
@setlocal
|
||||||
|
|
||||||
|
set ERROR_CODE=0
|
||||||
|
|
||||||
|
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||||
|
@setlocal
|
||||||
|
|
||||||
|
@REM ==== START VALIDATION ====
|
||||||
|
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Error: JAVA_HOME not found in your environment. >&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||||
|
echo location of your Java installation. >&2
|
||||||
|
echo.
|
||||||
|
goto error
|
||||||
|
|
||||||
|
:OkJHome
|
||||||
|
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||||
|
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||||
|
echo location of your Java installation. >&2
|
||||||
|
echo.
|
||||||
|
goto error
|
||||||
|
|
||||||
|
@REM ==== END VALIDATION ====
|
||||||
|
|
||||||
|
:init
|
||||||
|
|
||||||
|
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||||
|
@REM Fallback to current working directory if not found.
|
||||||
|
|
||||||
|
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||||
|
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||||
|
|
||||||
|
set EXEC_DIR=%CD%
|
||||||
|
set WDIR=%EXEC_DIR%
|
||||||
|
:findBaseDir
|
||||||
|
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||||
|
cd ..
|
||||||
|
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||||
|
set WDIR=%CD%
|
||||||
|
goto findBaseDir
|
||||||
|
|
||||||
|
:baseDirFound
|
||||||
|
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||||
|
cd "%EXEC_DIR%"
|
||||||
|
goto endDetectBaseDir
|
||||||
|
|
||||||
|
:baseDirNotFound
|
||||||
|
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||||
|
cd "%EXEC_DIR%"
|
||||||
|
|
||||||
|
:endDetectBaseDir
|
||||||
|
|
||||||
|
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||||
|
|
||||||
|
@setlocal EnableExtensions EnableDelayedExpansion
|
||||||
|
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||||
|
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||||
|
|
||||||
|
:endReadAdditionalConfig
|
||||||
|
|
||||||
|
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||||
|
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||||
|
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||||
|
|
||||||
|
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||||
|
|
||||||
|
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||||
|
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||||
|
)
|
||||||
|
|
||||||
|
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||||
|
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||||
|
if exist %WRAPPER_JAR% (
|
||||||
|
if "%MVNW_VERBOSE%" == "true" (
|
||||||
|
echo Found %WRAPPER_JAR%
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
if not "%MVNW_REPOURL%" == "" (
|
||||||
|
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||||
|
)
|
||||||
|
if "%MVNW_VERBOSE%" == "true" (
|
||||||
|
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||||
|
echo Downloading from: %DOWNLOAD_URL%
|
||||||
|
)
|
||||||
|
|
||||||
|
powershell -Command "&{"^
|
||||||
|
"$webclient = new-object System.Net.WebClient;"^
|
||||||
|
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||||
|
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||||
|
"}"^
|
||||||
|
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
||||||
|
"}"
|
||||||
|
if "%MVNW_VERBOSE%" == "true" (
|
||||||
|
echo Finished downloading %WRAPPER_JAR%
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@REM End of extension
|
||||||
|
|
||||||
|
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||||
|
@REM work with both Windows and non-Windows executions.
|
||||||
|
set MAVEN_CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||||
|
if ERRORLEVEL 1 goto error
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:error
|
||||||
|
set ERROR_CODE=1
|
||||||
|
|
||||||
|
:end
|
||||||
|
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||||
|
|
||||||
|
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||||
|
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||||
|
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||||
|
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||||
|
:skipRcPost
|
||||||
|
|
||||||
|
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||||
|
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||||
|
|
||||||
|
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||||
|
|
||||||
|
exit /B %ERROR_CODE%
|
||||||
217
pom-real.xml
Normal file
217
pom-real.xml
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
<relativePath/> </parent>
|
||||||
|
|
||||||
|
<groupId>com.example</groupId>
|
||||||
|
<artifactId>apiServer</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name>apiServer</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
<properties>
|
||||||
|
<env>real</env>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
<springdoc.version>2.0.2</springdoc.version>
|
||||||
|
<jjwt.version>0.11.5</jjwt.version>
|
||||||
|
<mybatis.version>3.0.0</mybatis.version>
|
||||||
|
<lombok.version>1.18.30</lombok.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
||||||
|
<artifactId>thymeleaf-layout-dialect</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>${mybatis.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mariadb.jdbc</groupId>
|
||||||
|
<artifactId>mariadb-java-client</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.jettison</groupId>
|
||||||
|
<artifactId>jettison</artifactId>
|
||||||
|
<version>1.5.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20230227</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sf.json-lib</groupId>
|
||||||
|
<artifactId>json-lib</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
<classifier>jdk15</classifier>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-api</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-impl</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
|
<version>${springdoc.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jsoup</groupId>
|
||||||
|
<artifactId>jsoup</artifactId>
|
||||||
|
<version>1.15.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||||
|
<artifactId>httpclient5</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>4.10.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.xml.bind</groupId>
|
||||||
|
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-impl</artifactId>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.warrenstrange</groupId>
|
||||||
|
<artifactId>googleauth</artifactId>
|
||||||
|
<version>1.5.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-batch</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
|
||||||
|
<version>2.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.10.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>17</source>
|
||||||
|
<target>17</target>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
</path>
|
||||||
|
<path>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
222
pom.xml
Normal file
222
pom.xml
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
<relativePath/> </parent>
|
||||||
|
|
||||||
|
<groupId>com.example</groupId>
|
||||||
|
<artifactId>apiServer</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name>apiServer</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
<springdoc.version>2.0.2</springdoc.version>
|
||||||
|
<jjwt.version>0.11.5</jjwt.version>
|
||||||
|
<mybatis.version>3.0.0</mybatis.version>
|
||||||
|
<lombok.version>1.18.30</lombok.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
||||||
|
<artifactId>thymeleaf-layout-dialect</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>${mybatis.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mariadb.jdbc</groupId>
|
||||||
|
<artifactId>mariadb-java-client</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.jettison</groupId>
|
||||||
|
<artifactId>jettison</artifactId>
|
||||||
|
<version>1.5.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20230227</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sf.json-lib</groupId>
|
||||||
|
<artifactId>json-lib</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
<classifier>jdk15</classifier>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-api</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-impl</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
|
<version>${jjwt.version}</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
|
<version>${springdoc.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jsoup</groupId>
|
||||||
|
<artifactId>jsoup</artifactId>
|
||||||
|
<version>1.15.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||||
|
<artifactId>httpclient5</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>4.10.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.xml.bind</groupId>
|
||||||
|
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-impl</artifactId>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.warrenstrange</groupId>
|
||||||
|
<artifactId>googleauth</artifactId>
|
||||||
|
<version>1.5.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-batch</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
|
||||||
|
<version>2.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.10.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>17</source>
|
||||||
|
<target>17</target>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
</path>
|
||||||
|
<path>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
108
runApi.sh
Normal file
108
runApi.sh
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# API 서버 배포 및 실행 스크립트
|
||||||
|
# 사용법: sudo ./runApi.sh
|
||||||
|
# 필요한 경로/파일이 다를 경우 아래 변수만 수정하세요.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
JAR_NAME="${JAR_NAME:-apiServer-0.0.1-SNAPSHOT.jar}"
|
||||||
|
PID_FILE="${PID_FILE:-/home/api.pid}"
|
||||||
|
RUN_DIR="${RUN_DIR:-/home/run}"
|
||||||
|
BUILD_DIR="${BUILD_DIR:-/home/build}"
|
||||||
|
BACKUP_DIR="${BACKUP_DIR:-/home/backup}"
|
||||||
|
JAVA_BIN="${JAVA_BIN:-/home/openjdk17/bin/java}"
|
||||||
|
# SCOUTER_AGENT="${SCOUTER_AGENT:-/home/scouter/agent.java/scouter.agent.jar}"
|
||||||
|
# SCOUTER_CONF="${SCOUTER_CONF:-/home/scouter/agent.java/conf/scouter.conf}"
|
||||||
|
SPRING_PROFILE="${SPRING_PROFILE:-real}"
|
||||||
|
|
||||||
|
timestamp() {
|
||||||
|
date +"%Y%m%d_%H%M%S"
|
||||||
|
}
|
||||||
|
|
||||||
|
log() {
|
||||||
|
echo "[runApi] $*"
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_paths() {
|
||||||
|
mkdir -p "$RUN_DIR" "$BACKUP_DIR" "$BUILD_DIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_app() {
|
||||||
|
if [[ -f "$PID_FILE" ]]; then
|
||||||
|
local pid
|
||||||
|
pid=$(cat "$PID_FILE" 2>/dev/null || true)
|
||||||
|
if [[ -n "${pid:-}" ]] && ps -p "$pid" > /dev/null 2>&1; then
|
||||||
|
log "기존 프로세스 종료: $pid"
|
||||||
|
kill -9 "$pid" || true
|
||||||
|
else
|
||||||
|
log "PID 파일은 있으나 실행 중인 프로세스가 없습니다."
|
||||||
|
fi
|
||||||
|
rm -f "$PID_FILE"
|
||||||
|
else
|
||||||
|
log "종료할 PID 파일이 없습니다."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
backup_old() {
|
||||||
|
local current="$RUN_DIR/$JAR_NAME"
|
||||||
|
if [[ -f "$current" ]]; then
|
||||||
|
local backup="$BACKUP_DIR/oldApi_$(timestamp).jar"
|
||||||
|
log "기존 JAR 백업 -> $backup"
|
||||||
|
mv "$current" "$backup"
|
||||||
|
else
|
||||||
|
log "백업할 기존 JAR이 없습니다."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
copy_new() {
|
||||||
|
local source="$BUILD_DIR/$JAR_NAME"
|
||||||
|
local target="$RUN_DIR/$JAR_NAME"
|
||||||
|
|
||||||
|
# 소스와 타겟이 같으면 복사 불필요
|
||||||
|
if [[ "$source" == "$target" ]]; then
|
||||||
|
if [[ -f "$target" ]]; then
|
||||||
|
log "배포된 JAR 확인 -> $target"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
log "새 JAR을 찾을 수 없습니다: $target"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$source" ]]; then
|
||||||
|
log "새 JAR을 찾을 수 없습니다: $source"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "새 JAR 복사 -> $target"
|
||||||
|
cp "$source" "$target"
|
||||||
|
}
|
||||||
|
|
||||||
|
start_app() {
|
||||||
|
local target="$RUN_DIR/$JAR_NAME"
|
||||||
|
log "애플리케이션 시작"
|
||||||
|
local log_dir="${LOG_DIR:-/home/log/core}"
|
||||||
|
local log_file="${LOG_FILE:-$log_dir/apiServer.log}"
|
||||||
|
mkdir -p "$log_dir"
|
||||||
|
|
||||||
|
nohup "$JAVA_BIN" \
|
||||||
|
-Duser.timezone=GMT+09:00 \
|
||||||
|
-Dspring.profiles.active="$SPRING_PROFILE" \
|
||||||
|
-jar "$target" \
|
||||||
|
>> "$log_file" 2>&1 &
|
||||||
|
echo $! > "$PID_FILE"
|
||||||
|
log "시작 완료 (PID: $(cat "$PID_FILE"))"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
ensure_paths
|
||||||
|
stop_app
|
||||||
|
backup_old
|
||||||
|
copy_new
|
||||||
|
start_app
|
||||||
|
log "배포 완료"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|
||||||
15
src/main/java/com/bb/ApiServerApplication.java
Normal file
15
src/main/java/com/bb/ApiServerApplication.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package com.bb;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
|
@EnableAsync
|
||||||
|
@SpringBootApplication
|
||||||
|
public class ApiServerApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ApiServerApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
671
src/main/java/com/bb/admin/controller/AgentController.java
Normal file
671
src/main/java/com/bb/admin/controller/AgentController.java
Normal file
@@ -0,0 +1,671 @@
|
|||||||
|
package com.bb.admin.controller;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
|
import com.bb.model.CommonParamAdmin;
|
||||||
|
import com.bb.model.PageFormVO;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
import com.bb.model.Vendor;
|
||||||
|
import com.bb.service.CreditService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.PagingUtil;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "/agent")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public class AgentController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CreditService creditService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WebClient webClient; // 싱글톤 WebClient 주입
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* TPA 에이전트 목록 페이지 수정사항
|
||||||
|
1. 에이전트 -> "에이전시" 로 용어수정
|
||||||
|
2. 에이전시 목록 수정사항 :
|
||||||
|
- 단계 = 레벨.
|
||||||
|
- 번호 : 생성 순번 (컬럼 맨 앞으로)
|
||||||
|
- 분류 : 두가지 타입 (추후 추가될수있음) NA(Normal Agency), IA(Insure Agency)
|
||||||
|
NA, IA
|
||||||
|
- 타입 : Ota (Operator Agency) : 솔루션 운영하는 에이전시, Ppa (Paper Agency) : 하위 총판만 운영하는 에이전시
|
||||||
|
3. 검색옵션 추가 : 분류, 타입 각각 따로 검색 가능하도록 분리
|
||||||
|
4. 데이터 적용안되어 있는부분 적용 : 요율, 총 지급받은 금액 등
|
||||||
|
요율 : 기준요율만 적시 (벤더별 요율은 상세페이지에서 표시됨)
|
||||||
|
5. 소속 에이전트 삭제(어차피 내 소속임) 에이전트 아이디 클릭시 상세페이지 이동
|
||||||
|
6. 가입시각 -> 가입일시로 수정 , 가운데 "T" "%"문자 제거.
|
||||||
|
7. 관리 컬럼은 유지 타이틀 이름도 관리 유자, 내용 관리 글자 제거.
|
||||||
|
"정지"버튼 추가(클릭시 모든기능정지) "블랙"버튼 추가 (클릭시 로그인 및 PT충환전 중지)
|
||||||
|
위 기능 구현하도록 작업
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("")
|
||||||
|
public String list( HttpServletRequest request , ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
|
||||||
|
log.info("underSiteCredit" + underSiteCredit);
|
||||||
|
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
|
||||||
|
if(loginSite.getSiteLevel() >0) {
|
||||||
|
search.setUpperSiteId(loginSite.getSiteId());
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalCount = siteService.getSiteListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(10);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap> siteList = siteService.getSiteList(search);
|
||||||
|
model.put("siteList", siteList);
|
||||||
|
|
||||||
|
return "admin/agent";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/detail/{siteIdx}")
|
||||||
|
public String detail( HttpServletRequest request , ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
|
||||||
|
log.info("#-Agent::DETAIL::underSiteCredit" + underSiteCredit);
|
||||||
|
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
log.info("#-Agent::DETAIL::siteIdx {}" , search.getSiteIdx());
|
||||||
|
if(loginSite.getSiteLevel() >0) {
|
||||||
|
search.setUpperSiteId(""+loginSite.getSiteId());
|
||||||
|
}
|
||||||
|
Site targetSite = siteService.getSiteDetail(search);
|
||||||
|
model.put("targetSite", targetSite);
|
||||||
|
|
||||||
|
model.put("uppersiteIdx", loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
List<HashMap> vederRateList = siteService.getVenderRateList(targetSite);
|
||||||
|
model.put("vederRateList", vederRateList);
|
||||||
|
log.info("#-Agent::DETAIL::vederRateList {}", vederRateList.size());
|
||||||
|
log.info("#-Agent::DETAIL::vederRateList {}", vederRateList);
|
||||||
|
|
||||||
|
/*
|
||||||
|
HashMap vendorParam = new HashMap<>();
|
||||||
|
vendorParam.put("siteIdx", search.getSiteIdx());
|
||||||
|
vendorParam.put("vendor", "nexus");
|
||||||
|
HashMap<String, String> nexusInfo = siteService.getSiteOnlyVendorInfo(vendorParam);
|
||||||
|
log.info("#-Agent::DETAIL::nexusInfo::"+nexusInfo);
|
||||||
|
model.put("nexusInfo", nexusInfo);
|
||||||
|
|
||||||
|
vendorParam.put("vendor", "xtreem");
|
||||||
|
HashMap<String, String> xtreemInfo = siteService.getSiteOnlyVendorInfo(vendorParam);
|
||||||
|
log.info("#-Agent::DETAIL::xtreemInfo::"+xtreemInfo);
|
||||||
|
model.put("xtreemInfo", xtreemInfo);
|
||||||
|
*/
|
||||||
|
|
||||||
|
HashMap parsEvoInfo = siteService.getParseUseYn(targetSite.getSiteIdx());
|
||||||
|
int parsEvoAmount = (int) parsEvoInfo.get("parsEvoAmount");
|
||||||
|
model.put("parsEvoAmount", parsEvoAmount);
|
||||||
|
|
||||||
|
List<HashMap> mylist = siteService.getSiteVendorList2(targetSite.getSiteIdx());
|
||||||
|
List<HashMap> vendorlist = siteService.getVendorList2(targetSite.getSiteIdx());
|
||||||
|
model.put("mylist", mylist);
|
||||||
|
log.info("#-Agent::DETAIL::mylist::"+mylist);
|
||||||
|
model.put("vendorlist", vendorlist);
|
||||||
|
log.info("#-Agent::DETAIL::vendorlist::"+vendorlist);
|
||||||
|
|
||||||
|
HashMap creditInfo = siteService.getSiteSubCredit(targetSite.getSiteId());
|
||||||
|
model.put("subCreditInfo", creditInfo);
|
||||||
|
|
||||||
|
return "admin/popup";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/saveSvcr")
|
||||||
|
public @ResponseBody JSONObject saveSvcr(HttpServletRequest request, ModelMap model, CommonParamAdmin commonParamAdmin) throws Exception {
|
||||||
|
final String LOG_PREFIX = "#-SAVE_SCVR:::";
|
||||||
|
log.info(LOG_PREFIX + "CommonParamAdmin: " + commonParamAdmin.toString());
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
HashMap paramMap = mapper.readValue(commonParamAdmin.getParam().toString(), new TypeReference<HashMap>() {});
|
||||||
|
|
||||||
|
if(paramMap.get("vendorIdx") != null) {
|
||||||
|
SiteSearch targetSearch = new SiteSearch();
|
||||||
|
long targetSiteIdx = Long.parseLong(commonParamAdmin.getParam().get("targetSiteIdx").toString());
|
||||||
|
targetSearch.setSiteIdx(targetSiteIdx);
|
||||||
|
Site targetSite = siteService.getSiteDetail(targetSearch);
|
||||||
|
|
||||||
|
String siteUrl = targetSite.getSiteCbUrl() + "/gameRateChange";
|
||||||
|
paramMap.put("siteIdx", targetSiteIdx);
|
||||||
|
|
||||||
|
if(Integer.parseInt(paramMap.get("type").toString()) == 0) {
|
||||||
|
siteService.saveVendorRate(paramMap);
|
||||||
|
}
|
||||||
|
siteService.saveSvcr(paramMap, Integer.parseInt(paramMap.get("type").toString()));
|
||||||
|
|
||||||
|
// 외부 API 호출 (WebClient 방식)
|
||||||
|
if(Integer.parseInt(paramMap.get("type").toString()) == 0) {
|
||||||
|
sendGameRateChange(siteUrl, paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(targetSite.getSiteLevel() < 1) {
|
||||||
|
siteService.updateVendorUseYn(paramMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/saveSvcrAll")
|
||||||
|
public @ResponseBody JSONObject saveSvcrAll(HttpServletRequest request, ModelMap model, CommonParamAdmin commonParamAdmin) throws Exception {
|
||||||
|
final String LOG_PREFIX = "#-SAVE_SCVRALL:::";
|
||||||
|
log.info(LOG_PREFIX + "CommonParamAdmin: " + commonParamAdmin.toString());
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
for(int i=0; i < commonParamAdmin.getParamlist().length; i++) {
|
||||||
|
JSONObject paramData = commonParamAdmin.getParamlist()[i];
|
||||||
|
paramData.put("siteIdx", commonParamAdmin.getParam().get("targetSiteIdx"));
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
HashMap paramMap = mapper.readValue(paramData.toString(), new TypeReference<HashMap>() {});
|
||||||
|
|
||||||
|
long targetSiteIdx = Long.parseLong(commonParamAdmin.getParam().get("targetSiteIdx").toString());
|
||||||
|
SiteSearch targetSearch = new SiteSearch();
|
||||||
|
targetSearch.setSiteIdx(targetSiteIdx);
|
||||||
|
Site targetSite = siteService.getSiteDetail(targetSearch);
|
||||||
|
String siteUrl = targetSite.getSiteCbUrl() + "/gameRateChange";
|
||||||
|
|
||||||
|
if(paramMap.get("vendorIdx") != null) {
|
||||||
|
paramMap.put("siteIdx", targetSiteIdx);
|
||||||
|
if(Integer.parseInt(paramMap.get("type").toString()) == 0) {
|
||||||
|
siteService.saveVendorRate(paramMap);
|
||||||
|
}
|
||||||
|
siteService.saveSvcr(paramMap, Integer.parseInt(paramMap.get("type").toString()));
|
||||||
|
|
||||||
|
// 외부 API 호출 (WebClient 방식)
|
||||||
|
if(Integer.parseInt(paramMap.get("type").toString()) == 0) {
|
||||||
|
sendGameRateChange(siteUrl, paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(targetSite.getSiteLevel() < 1) {
|
||||||
|
siteService.updateVendorUseYn(paramMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WebClient를 이용한 외부 API 호출 공통 메서드 (동기 방식)
|
||||||
|
*/
|
||||||
|
private void sendGameRateChange(String url, HashMap paramMap) {
|
||||||
|
try {
|
||||||
|
log.info("##### WebClient gmeRateChange 시작 #####");
|
||||||
|
|
||||||
|
JSONObject paramBody = new JSONObject();
|
||||||
|
paramBody.put("siteApiKey", siteService.getSiteKey(paramMap));
|
||||||
|
paramBody.put("vendor", siteService.getVendorTitle(paramMap));
|
||||||
|
paramBody.put("vendorIdx", paramMap.get("vendorIdx"));
|
||||||
|
paramBody.put("gameRate", Double.parseDouble(paramMap.get("rate").toString()));
|
||||||
|
|
||||||
|
String response = webClient.post()
|
||||||
|
.uri(url)
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.accept(MediaType.APPLICATION_JSON)
|
||||||
|
.header("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36")
|
||||||
|
.bodyValue(paramBody.toString())
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(String.class)
|
||||||
|
.block(); // MVC 환경이므로 결과를 기다림(동기)
|
||||||
|
|
||||||
|
log.info("##### WebClient 응답 완료 : {}", response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("##### WebClient 호출 에러 : {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/add")
|
||||||
|
public String add( HttpServletRequest request , ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
|
||||||
|
log.info("underSiteCredit" + underSiteCredit);
|
||||||
|
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
return "admin/agentAdd";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/siteUpdate")
|
||||||
|
public @ResponseBody JSONObject siteUpdate( HttpServletRequest request, ModelMap model, Site site) throws Exception {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
site.setUpperSiteId(loginSite.getSiteId());
|
||||||
|
site.setUpperSiteIdx(loginSite.getSiteIdx());
|
||||||
|
final String LOG_PREFIX = "#-super::siteUpdate:::";
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "Site Info: " + site.toString());
|
||||||
|
log.info(LOG_PREFIX+ "Site IP: " + site.getSiteIp());
|
||||||
|
siteService.siteUpdate(LOG_PREFIX, site);
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/agentUpdate")
|
||||||
|
public @ResponseBody JSONObject agentUpdate( HttpServletRequest request, ModelMap model, Site site) throws Exception {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
// site.setSiteId(loginSite.getSiteId());
|
||||||
|
final String LOG_PREFIX = "#-super::agentUpdate:::";
|
||||||
|
|
||||||
|
if("new".equals(site.getSiteKey())) {
|
||||||
|
String newsiteKey = makeApiKey(loginSite.getSiteId());
|
||||||
|
site.setSiteKey(newsiteKey);
|
||||||
|
obj.put("DATA", newsiteKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "Site Info: " + site.toString());
|
||||||
|
log.info(LOG_PREFIX+ "Site IP: " + site.getSiteIp());
|
||||||
|
siteService.siteUpdate(LOG_PREFIX, site);
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/agentIpsUpdate")
|
||||||
|
public @ResponseBody JSONObject agentIpsUpdate( HttpServletRequest request, ModelMap model, Site site) throws Exception {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
// site.setSiteId(loginSite.getSiteId());
|
||||||
|
|
||||||
|
|
||||||
|
siteService.agentIpsUpdate(site) ;
|
||||||
|
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/forDefault")
|
||||||
|
public @ResponseBody JSONObject forDefault(HttpServletRequest request, ModelMap model, SiteSearch search) throws Exception {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
//Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
//Site site = (Site) authentication.getDetails();
|
||||||
|
|
||||||
|
Site site = siteService.getSiteDetail(search);
|
||||||
|
final String LOG_PREFIX = "#-Proc::forDefault::"+site.getSiteIdx()+"::";
|
||||||
|
log.info(LOG_PREFIX + "loginSite::" + site.toString());
|
||||||
|
log.info(LOG_PREFIX+ "Site IP: " + site.getSiteIp());
|
||||||
|
|
||||||
|
siteService.siteUpdate(LOG_PREFIX, site);
|
||||||
|
siteService.forDefaultProc(site);
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/saveParsEvoAmount")
|
||||||
|
public @ResponseBody JSONObject saveParsEvoAmount(HttpServletRequest request, ModelMap model, SiteSearch param) throws Exception {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
final String LOG_PREFIX = "#-Proc::saveParsEvoAmount::"+param.getSiteIdx()+"::";
|
||||||
|
log.info(LOG_PREFIX + "ParsEvoAmount::" + param.getParsEvoAmount());
|
||||||
|
|
||||||
|
int updResult = siteService.saveParsEvoAmount(param);
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/creditRateSave")
|
||||||
|
public @ResponseBody JSONObject setSave( HttpServletRequest request, ModelMap model, CommonParamAdmin commonParamAdmin ) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
log.info(commonParamAdmin.toString());
|
||||||
|
|
||||||
|
for(int i=0;i<commonParamAdmin.getParamlist().length;i++) {
|
||||||
|
JSONObject paramData = commonParamAdmin.getParamlist()[i];
|
||||||
|
paramData.put("siteIdx", commonParamAdmin.getParam().get("targetSiteIdx"));
|
||||||
|
paramData.put("insureUpSiteIdx", loginSite.getSiteIdx());
|
||||||
|
log.info(paramData.toString());
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
HashMap paramMap = mapper.readValue(paramData.toString(), new TypeReference<HashMap>() {});
|
||||||
|
if(paramMap.get("vendorIdx")!=null) {
|
||||||
|
siteService.saveVendorRate(paramMap);
|
||||||
|
siteService.updateVendorUseYn(paramMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/insurePoinRateSave")
|
||||||
|
public @ResponseBody JSONObject insurePointRateSave( HttpServletRequest request, ModelMap model, CommonParamAdmin commonParamAdmin ) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
log.info(commonParamAdmin.toString());
|
||||||
|
|
||||||
|
for(int i=0;i<commonParamAdmin.getParamlist().length;i++) {
|
||||||
|
JSONObject paramData = commonParamAdmin.getParamlist()[i];
|
||||||
|
paramData.put("siteIdx", commonParamAdmin.getParam().get("targetSiteIdx"));
|
||||||
|
paramData.put("insureUpSiteIdX", loginSite.getSiteIdx());
|
||||||
|
log.info(paramData.toString());
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
HashMap paramMap = mapper.readValue(paramData.toString(), new TypeReference<HashMap>() {});
|
||||||
|
siteService.saveVendorInsurePointRate(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/addProc")
|
||||||
|
public @ResponseBody JSONObject addProc( HttpServletRequest request, ModelMap model, Site site) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
site.setUpperSiteId(loginSite.getSiteId());
|
||||||
|
site.setUpperSiteIdx(loginSite.getSiteIdx());
|
||||||
|
site.setSiteKey(makeApiKey(site.getSiteId()));
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
if(site.getIsTransfer() == null || "".equals(site.getIsTransfer())) {
|
||||||
|
site.setIsTransfer("N");
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(site.toString());
|
||||||
|
|
||||||
|
siteService.addProc(site);
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/transaction")
|
||||||
|
public String transaction( HttpServletRequest request , ModelMap model , @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
search.setSiteId(loginSite.getSiteId());
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
int totalCount = creditService.getSiteTranListCnt(search);
|
||||||
|
if(totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(15);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap> list = creditService.getSiteTranList(search);
|
||||||
|
log.debug(""+list.size());
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/transaction";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/gamelink")
|
||||||
|
public String gamelink( HttpServletRequest request , ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
List<HashMap> mylist = siteService.getSiteVendorList(search);
|
||||||
|
List<HashMap> vendorlist = siteService.getVendorList(search);
|
||||||
|
|
||||||
|
model.put("mylist", mylist);
|
||||||
|
model.put("vendorlist", vendorlist);
|
||||||
|
|
||||||
|
return "admin/gamelink";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/venderlist")
|
||||||
|
public String venderlist( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
return "admin/venderlist";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/apiset")
|
||||||
|
public String apiset( HttpServletRequest request , ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
return "admin/apiset";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/siteVenderUpdate")
|
||||||
|
public @ResponseBody JSONObject siteVenderUpdate( HttpServletRequest request, ModelMap model, Vendor vendor) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
vendor.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
try {
|
||||||
|
siteService.siteVenderUpdate(vendor);
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
} catch(Exception e) {
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/parseOnOff")
|
||||||
|
public @ResponseBody JSONObject parseOnOff(HttpServletRequest request, ModelMap model, @RequestParam("pStatus") String pStatus) throws Exception {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
final String LOG_PREFIX = "#-Proc::parseOnOff:::";
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "전체 사이트 파싱설정::" + pStatus + "::START");
|
||||||
|
|
||||||
|
String useYn = "";
|
||||||
|
if("on".equals(pStatus)) {
|
||||||
|
useYn = "Y";
|
||||||
|
} else {
|
||||||
|
useYn = "N";
|
||||||
|
}
|
||||||
|
log.info(LOG_PREFIX + "updateParseUseYN useYn::" + useYn);
|
||||||
|
int result = siteService.updateParseUseYN(useYn);
|
||||||
|
log.info(LOG_PREFIX + "updateParseUseYN result::" + result);
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "전체 사이트 파싱설정::" + pStatus + "::END");
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String makeApiKey(String param) {
|
||||||
|
int n = 24; // n자리 쿠폰
|
||||||
|
char[] chs = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||||
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||||
|
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ,'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
|
||||||
|
|
||||||
|
Random rd = new Random();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
char ch = chs[rd.nextInt(chs.length)];
|
||||||
|
sb.append(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
559
src/main/java/com/bb/admin/controller/CreditController.java
Normal file
559
src/main/java/com/bb/admin/controller/CreditController.java
Normal file
@@ -0,0 +1,559 @@
|
|||||||
|
package com.bb.admin.controller;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.annotation.Secured;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.bb.model.Credit;
|
||||||
|
import com.bb.model.CreditPoint;
|
||||||
|
import com.bb.model.OTPInfo;
|
||||||
|
import com.bb.model.PageFormVO;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
import com.bb.service.CreditService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.PagingUtil;
|
||||||
|
import com.bb.util.TOTPTokenGenerator;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "/cash")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public class CreditController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CreditService creditService;
|
||||||
|
|
||||||
|
@GetMapping("/charge")
|
||||||
|
public String charge(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
log.info("underSiteCredit" + underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
PageFormVO pageVo = new PageFormVO();
|
||||||
|
search.setSiteId(loginSite.getSiteId());
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
search.setCreditType("CI");
|
||||||
|
|
||||||
|
int totalCount = creditService.getCreditListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if (search.getCount_per_list() == 0) {
|
||||||
|
commonForm.setCount_per_list(10);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap sum = creditService.getCreditSumToday(search);
|
||||||
|
model.put("sum", sum);
|
||||||
|
|
||||||
|
List<HashMap> list = creditService.getCreditList(search);
|
||||||
|
log.info("list" + list.size());
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/charge";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/chargeWait")
|
||||||
|
public String chargeWait(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
log.info("underSiteCredit" + underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
PageFormVO pageVo = new PageFormVO();
|
||||||
|
search.setSiteId(loginSite.getSiteId());
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
search.setCreditType("CI");
|
||||||
|
search.setCreditStatus(request.getParameter("creditStatus"));
|
||||||
|
log.info(search.getCreditStatus());
|
||||||
|
|
||||||
|
int totalCount = creditService.getCreditListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if (search.getCount_per_list() == 0) {
|
||||||
|
commonForm.setCount_per_list(10);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(search.getCreditStatus());
|
||||||
|
List<HashMap> list = creditService.getCreditList(search);
|
||||||
|
log.info("" + list.size());
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/apply";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/exchange")
|
||||||
|
public String exchange(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
log.info("underSiteCredit" + underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
PageFormVO pageVo = new PageFormVO();
|
||||||
|
search.setSiteId(loginSite.getSiteId());
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
search.setCreditType("CO");
|
||||||
|
search.setCreditStatus(request.getParameter("creditStatus"));
|
||||||
|
log.info(search.getCreditStatus());
|
||||||
|
|
||||||
|
int totalCount = creditService.getCreditListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if (search.getCount_per_list() == 0) {
|
||||||
|
commonForm.setCount_per_list(10);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap> list = creditService.getCreditList(search);
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/exchange";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/exchangeWait")
|
||||||
|
public String exchangeWait(HttpServletRequest request, ModelMap model,
|
||||||
|
@ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
log.info("underSiteCredit" + underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
PageFormVO pageVo = new PageFormVO();
|
||||||
|
search.setSiteId(loginSite.getSiteId());
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
search.setCreditType("CO");
|
||||||
|
|
||||||
|
int totalCount = creditService.getCreditListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if (search.getCount_per_list() == 0) {
|
||||||
|
commonForm.setCount_per_list(10);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap> list = creditService.getCreditList(search);
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/exchangeapply";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/addProc")
|
||||||
|
public @ResponseBody JSONObject addProc(HttpServletRequest request, ModelMap model, Credit credit)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
// enum('AI','AO','CI','CO','DP','CD','SDP','SCD')
|
||||||
|
// inout (받는사람 기준으로 인인지 아웃인지)
|
||||||
|
// status 바로적립 1, 승인대기 0
|
||||||
|
// siteId 타겟사이트 아이디
|
||||||
|
final String LOG_PREFIX = "#-super::CREDIT_DEPOSIT:::";
|
||||||
|
log.info(LOG_PREFIX + "Credit::" + credit.toString());
|
||||||
|
|
||||||
|
if ("AI".equals(credit.getCreditType()) || "AO".equals(credit.getCreditType())) {
|
||||||
|
OTPInfo otpManager = siteService.getOtpInfoByManger(loginSite.getSiteIdx());
|
||||||
|
if (otpManager == null || otpManager.getAccount().equals("")) {
|
||||||
|
log.error(LOG_PREFIX + "OTP정보가 없습니다.");
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
obj.put("MSG", "OTP정보가 없습니다.");
|
||||||
|
return obj;
|
||||||
|
} else {
|
||||||
|
log.info(LOG_PREFIX + "OTP Info::" + otpManager.toString());
|
||||||
|
String secret = otpManager.getSecretKey();
|
||||||
|
if (credit.getOtp() == null || "".equals(credit.getOtp())) {
|
||||||
|
log.error(LOG_PREFIX + "OTP 번호를 입력하세요.");
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
obj.put("MSG", "OTP 번호를 입력하세요.");
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean chkOtp = TOTPTokenGenerator.otpVerify(secret, Integer.parseInt(credit.getOtp()));
|
||||||
|
if (!chkOtp) {
|
||||||
|
log.error(LOG_PREFIX + "OTP 번호가 일치하지 않습니다.");
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
obj.put("MSG", "OTP 번호가 일치하지 않습니다.");
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SiteSearch search = new SiteSearch();
|
||||||
|
search.setSiteId(credit.getTargetSiteId());
|
||||||
|
search.setSiteIdx(credit.getTargetSiteIdx());
|
||||||
|
Site targetSite = siteService.getSiteDetail(search);
|
||||||
|
credit.setSiteLevel(targetSite.getSiteLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("AI".equals(credit.getCreditType())) { // 관리 직접 지금
|
||||||
|
|
||||||
|
if (siteCredit < credit.getCreditAmt()) {
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
obj.put("MSG", "크레딧이 모자릅니다.");
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
credit.setInOut("IN");
|
||||||
|
credit.setCreditStatus(1);
|
||||||
|
credit.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
credit.setSiteId(loginSite.getSiteId());
|
||||||
|
|
||||||
|
} else if ("AO".equals(credit.getCreditType())) { // 관리자 직접환급
|
||||||
|
|
||||||
|
long targetSiteCredit = siteService.getSiteCredit(credit.getTargetSiteId());
|
||||||
|
|
||||||
|
if (targetSiteCredit < credit.getCreditAmt()) {
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
obj.put("MSG", "해당 에이젼시의 크레딧이 모자릅니다.");
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
credit.setInOut("OUT");
|
||||||
|
credit.setCreditStatus(1);
|
||||||
|
credit.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
credit.setSiteId(loginSite.getSiteId());
|
||||||
|
|
||||||
|
} else if ("CI".equals(credit.getCreditType())) { // 충전 신청
|
||||||
|
|
||||||
|
long targetSiteCredit = siteService.getSiteCredit(loginSite.getUpperSiteId());
|
||||||
|
if (targetSiteCredit < credit.getCreditAmt()) {
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
obj.put("MSG", "싱으; 에이젼시의 크레딧이 모자릅니다. 상위 에이전시에 문의하세요");
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
credit.setInOut("IN");
|
||||||
|
credit.setCreditStatus(0);
|
||||||
|
|
||||||
|
credit.setSiteIdx(loginSite.getUpperSiteIdx());// 상위사이트아이디
|
||||||
|
credit.setSiteId(loginSite.getUpperSiteId());
|
||||||
|
|
||||||
|
credit.setTargetSiteIdx(loginSite.getSiteIdx()); // 타켓사이트 아이디;
|
||||||
|
credit.setTargetSiteId(loginSite.getSiteId());
|
||||||
|
|
||||||
|
credit.setCreditRate(loginSite.getSiteCreditRate());
|
||||||
|
|
||||||
|
} else if ("CO".equals(credit.getCreditType())) { // 환전 신청
|
||||||
|
|
||||||
|
if (siteCredit < credit.getCreditAmt()) {
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
obj.put("MSG", "크레딧이 모자릅니다.");
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
credit.setInOut("OUT");
|
||||||
|
credit.setCreditStatus(0);
|
||||||
|
|
||||||
|
credit.setSiteIdx(loginSite.getUpperSiteIdx());// 상위사이트아이디
|
||||||
|
credit.setSiteId(loginSite.getUpperSiteId());
|
||||||
|
|
||||||
|
credit.setTargetSiteIdx(loginSite.getSiteIdx()); // 타켓사이트 아이디;
|
||||||
|
credit.setTargetSiteId(loginSite.getSiteId());
|
||||||
|
|
||||||
|
credit.setCreditRate(loginSite.getSiteCreditRate());
|
||||||
|
|
||||||
|
} else if ("DP".equals(credit.getCreditType())) { // 베팅크레딧
|
||||||
|
// credit.setInOut("OUT");
|
||||||
|
// credit.setCreditStatus(1);
|
||||||
|
|
||||||
|
} else if ("CD".equals(credit.getCreditType())) { // 윈머니크레딧
|
||||||
|
// cash.setInOut("IN");
|
||||||
|
// cash.setCreditStatus(1);
|
||||||
|
} else if ("SDP".equals(credit.getCreditType())) { // 서브포인트충전 신청
|
||||||
|
// cash.setInOut("IN");
|
||||||
|
// cash.setCreditStatus(0);
|
||||||
|
|
||||||
|
credit.setInOut("IN");
|
||||||
|
credit.setCreditStatus(0);
|
||||||
|
credit.setSiteIdx(loginSite.getUpperSiteIdx());// 상위사이트아이디
|
||||||
|
credit.setSiteId(loginSite.getUpperSiteId());
|
||||||
|
|
||||||
|
credit.setTargetSiteIdx(loginSite.getSiteIdx()); // 타켓사이트 아이디;
|
||||||
|
credit.setTargetSiteId(loginSite.getSiteId());
|
||||||
|
credit.setCreditRate(loginSite.getSiteCreditRate());
|
||||||
|
|
||||||
|
} else if ("SCD".equals(credit.getCreditType())) { // 서브포인트환전 현재 없음
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(credit.toString());
|
||||||
|
|
||||||
|
int res = creditService.insertCredit(credit);
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/statusUpdate")
|
||||||
|
public @ResponseBody JSONObject statusUpdate(HttpServletRequest request, ModelMap model, Credit credit)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
|
||||||
|
// enum('AI','AO','CI','CO','DP','CD','SDP','SCD')
|
||||||
|
// inout (받는사람 기준으로 인인지 아웃인지)
|
||||||
|
// status 바로적립 1, 승인대기 0
|
||||||
|
// siteId 타겟사이트 아이디
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
log.info(credit.toString());
|
||||||
|
|
||||||
|
int res = creditService.updateStatus(credit);
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/point")
|
||||||
|
public String point(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
log.info("underSiteCredit" + underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
PageFormVO pageVo = new PageFormVO();
|
||||||
|
search.setSiteId(loginSite.getSiteId());
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
search.setCreditType("CO");
|
||||||
|
|
||||||
|
int totalCount = creditService.getPointListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if (search.getCount_per_list() == 0) {
|
||||||
|
commonForm.setCount_per_list(10);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap> list = creditService.getPointList(search);
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/applypoint";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/addPointProc")
|
||||||
|
public @ResponseBody JSONObject addPointProc(HttpServletRequest request, ModelMap model, CreditPoint point)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
JSONObject resObj = new JSONObject();
|
||||||
|
|
||||||
|
long sitePoint = siteService.getSitePoint(point.getTargetSiteId());
|
||||||
|
final String LOG_PREFIX = "#-addPointProc::" + loginSite.getSiteId() + "=>" + point.getTargetSiteId() + ":::";
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "CreditPoint Info : " + point.toString());
|
||||||
|
|
||||||
|
OTPInfo otpManager = siteService.getOtpInfoByManger(loginSite.getSiteIdx());
|
||||||
|
if (otpManager == null || otpManager.getAccount().equals("")) {
|
||||||
|
log.error(LOG_PREFIX + "OTP정보가 없습니다.");
|
||||||
|
resObj.put("RES", "FAIL");
|
||||||
|
resObj.put("MSG", "OTP정보가 없습니다.");
|
||||||
|
return resObj;
|
||||||
|
} else {
|
||||||
|
log.info(LOG_PREFIX + "OTP Info::" + otpManager.toString());
|
||||||
|
String secret = otpManager.getSecretKey();
|
||||||
|
if (point.getOtp() == null || "".equals(point.getOtp())) {
|
||||||
|
log.error(LOG_PREFIX + "OTP 번호를 입력하세요.");
|
||||||
|
resObj.put("RES", "FAIL");
|
||||||
|
resObj.put("MSG", "OTP 번호를 입력하세요.");
|
||||||
|
return resObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean chkOtp = TOTPTokenGenerator.otpVerify(secret, Integer.parseInt(point.getOtp()));
|
||||||
|
if (!chkOtp) {
|
||||||
|
log.error(LOG_PREFIX + "OTP 번호가 일치하지 않습니다.");
|
||||||
|
resObj.put("RES", "FAIL");
|
||||||
|
resObj.put("MSG", "OTP 번호가 일치하지 않습니다.");
|
||||||
|
return resObj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("POINT_DEPOSIT".equals(point.getVendor())) {
|
||||||
|
// 관리자 지급
|
||||||
|
String tranId = "POINT_DEPOSIT-" + loginSite.getSiteId() + ">" + point.getTargetSiteId() + "-" + time;
|
||||||
|
String betId = "포인트 수동지급-" + loginSite.getSiteId() + ">" + point.getTargetSiteId() + "-" + time;
|
||||||
|
point.setSiteIdx((long) loginSite.getSiteIdx());
|
||||||
|
point.setSiteId(loginSite.getSiteId());
|
||||||
|
point.setTranId(tranId);
|
||||||
|
point.setBetId(betId);
|
||||||
|
point.setPrePointAmt(sitePoint);
|
||||||
|
|
||||||
|
} else if ("POINT_WITHDRAW".equals(point.getVendor())) {
|
||||||
|
// 관리자 회수
|
||||||
|
if (sitePoint < point.getPointAmt().intValue()) {
|
||||||
|
resObj.put("RES", "FAIL");
|
||||||
|
resObj.put("MSG", "해당 에이젼시의 포인트가 부족합니다.");
|
||||||
|
return resObj;
|
||||||
|
}
|
||||||
|
String tranId = "POINT_WITHDRAW-" + loginSite.getSiteId() + ">" + point.getTargetSiteId() + "-" + time;
|
||||||
|
String betId = "포인트 수동회수-" + loginSite.getSiteId() + ">" + point.getTargetSiteId() + "-" + time;
|
||||||
|
point.setSiteIdx((long) loginSite.getSiteIdx());
|
||||||
|
point.setSiteId(loginSite.getSiteId());
|
||||||
|
point.setTranId(tranId);
|
||||||
|
point.setBetId(betId);
|
||||||
|
point.setPrePointAmt(sitePoint);
|
||||||
|
int pointAmt = point.getPointAmt().intValue() * -1;
|
||||||
|
point.setPointAmt(pointAmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "CreditPoint Info : " + point.toString());
|
||||||
|
int result = creditService.insertPoint(point);
|
||||||
|
log.info(LOG_PREFIX + "creditService.insertPoint() result : " + result);
|
||||||
|
|
||||||
|
resObj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return resObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
401
src/main/java/com/bb/admin/controller/GuestController.java
Normal file
401
src/main/java/com/bb/admin/controller/GuestController.java
Normal file
@@ -0,0 +1,401 @@
|
|||||||
|
package com.bb.admin.controller;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.codehaus.jettison.json.JSONArray;
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.annotation.Secured;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
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.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClientRequestException;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClientResponseException;
|
||||||
|
|
||||||
|
import com.bb.exception.ApiException;
|
||||||
|
import com.bb.model.ApiResponse;
|
||||||
|
import com.bb.model.BetParam;
|
||||||
|
import com.bb.model.NexusApiInfo;
|
||||||
|
import com.bb.model.PageFormVO;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
import com.bb.model.TplusApiInfo;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.service.StatService;
|
||||||
|
import com.bb.util.PagingUtil;
|
||||||
|
import com.bb.util.StringUtils;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "/guest")
|
||||||
|
public class GuestController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
StatService statService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@GetMapping("/guestLogin")
|
||||||
|
public String guestLogin(HttpServletRequest request, ModelMap model) throws Exception {
|
||||||
|
|
||||||
|
return "admin/guestLogin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/simpleReport")
|
||||||
|
//@Secured("ROLE_GUEST")
|
||||||
|
public String simpleReport(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
final String LOG_PREFIX = "#-SUPER::simpleReport::::";
|
||||||
|
|
||||||
|
if(search.getSearchSiteId() != null && !"".equals(search.getSearchSiteId())) {
|
||||||
|
Site targetSite = siteService.getSiteSimpleDetail(search);
|
||||||
|
if(targetSite != null) {
|
||||||
|
search.setSearchSiteIdx(targetSite.getSiteIdx());
|
||||||
|
} else {
|
||||||
|
search.setSearchSiteIdx(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
search.setSearchSiteIdx(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
String toDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date(System.currentTimeMillis()));
|
||||||
|
String startDay = "";
|
||||||
|
String endDay = "";
|
||||||
|
if(search.getStartDate() == null || "".equals(search.getStartDate())) {
|
||||||
|
startDay = toDay;
|
||||||
|
search.setStartDate(startDay);
|
||||||
|
} else {
|
||||||
|
startDay = search.getStartDate().substring(0, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(search.getEndDate() == null || "".equals(search.getEndDate())) {
|
||||||
|
endDay = toDay;
|
||||||
|
search.setEndDate(endDay);
|
||||||
|
} else {
|
||||||
|
endDay = search.getEndDate().substring(0, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "startDay::"+startDay);
|
||||||
|
log.info(LOG_PREFIX+ "endDay::"+endDay);
|
||||||
|
log.info(LOG_PREFIX+ "toDay::"+toDay);
|
||||||
|
search.setSiteDispYn("N");
|
||||||
|
if(startDay.equals(toDay) || endDay.equals(toDay)) {
|
||||||
|
search.setSiteDispYn("Y");
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String reqJsonStr = objectMapper.writeValueAsString(search);
|
||||||
|
JSONObject reqObj = new JSONObject(reqJsonStr);
|
||||||
|
log.info(LOG_PREFIX+ "Request {}", reqObj);
|
||||||
|
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
int totalCount = statService.getAgentReportCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
commonForm.setCount_per_list(30);
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
log.info(LOG_PREFIX+ "search.getStartDate {}", search.getStartDate());
|
||||||
|
log.info(LOG_PREFIX+ "search.getEndDate {}", search.getEndDate());
|
||||||
|
log.info(LOG_PREFIX+ "search.getSearchSiteIdx {}", search.getSearchSiteIdx());
|
||||||
|
log.info(LOG_PREFIX+ "search.getPage {}", search.getPage());
|
||||||
|
log.info(LOG_PREFIX+ "search.getLimit {}", search.getLimit());
|
||||||
|
log.info(LOG_PREFIX+ "search.getOffset {}", search.getOffset());
|
||||||
|
|
||||||
|
List<HashMap> siteList = statService.getAgentReportList(search);
|
||||||
|
model.put("siteList", siteList);
|
||||||
|
HashMap siteTotal = statService.getAgentReportTotal(search);
|
||||||
|
model.put("siteTotal", siteTotal);
|
||||||
|
|
||||||
|
return "admin/simpleReport";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping(value="/betDetail")
|
||||||
|
public ApiResponse betDetail(HttpServletRequest request, @RequestParam("betId") String betId) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
final String LOG_PREFIX = "#-CMN::BET-DETAIL::"+betId+":::";
|
||||||
|
JSONObject saveObj = null;
|
||||||
|
JSONArray saveObjs = null;
|
||||||
|
boolean isSaveEvoDetail = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// apiKey 체크
|
||||||
|
Site site = siteService.getSiteInfo(request);
|
||||||
|
if(site ==null) {
|
||||||
|
throw new ApiException("1000", "accessDinied");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 결과보내기
|
||||||
|
String dType = "detail_0";
|
||||||
|
|
||||||
|
HashMap betInfo = transService.getBetInfoByBetId(param);
|
||||||
|
log.info(LOG_PREFIX+ "betInfo {}", betInfo);
|
||||||
|
|
||||||
|
if(betInfo == null) betInfo = transService.getSiteBetByRefIdFromOld(param);
|
||||||
|
log.info(LOG_PREFIX+ "betInfo_OLD {}", betInfo);
|
||||||
|
|
||||||
|
if(betInfo != null) {
|
||||||
|
String category = betInfo.get("vendorCetegory").toString();
|
||||||
|
log.info(LOG_PREFIX+ "Game category : " + category);
|
||||||
|
|
||||||
|
if("svendor".equals(betInfo.get("vendorCode").toString())
|
||||||
|
|| "pink".equals(betInfo.get("vendorCode").toString())) {
|
||||||
|
String jsonStr = siteService.getOrgDetailData(param);
|
||||||
|
log.info(LOG_PREFIX+ "jsonStr : " + jsonStr);
|
||||||
|
if(jsonStr != null && !"".equals(jsonStr) && !"{}".equals(jsonStr)) {
|
||||||
|
dType = "detail_6";
|
||||||
|
apiResponse.put("dType", dType);
|
||||||
|
HashMap<String, Object> detailMap = new Gson().fromJson(jsonStr, HashMap.class);
|
||||||
|
apiResponse.put("detail", detailMap);
|
||||||
|
} else {
|
||||||
|
isSaveEvoDetail = true;
|
||||||
|
JSONObject dataObj = svendorService.getDetail(LOG_PREFIX, betInfo);
|
||||||
|
if(dataObj == null) {
|
||||||
|
apiResponse.put("detail", "betId is not exist");
|
||||||
|
} else {
|
||||||
|
if(dataObj.has("gameDetail") && !dataObj.isNull("gameDetail")) {
|
||||||
|
String detailType = StringUtils.getType(dataObj.getString("gameDetail"));
|
||||||
|
if(detailType.equals("URL")) {
|
||||||
|
dType = "detail_2";
|
||||||
|
apiResponse.put("dType", dType);
|
||||||
|
String detailUrl = dataObj.getString("gameDetail");
|
||||||
|
apiResponse.put("detail", detailUrl);
|
||||||
|
} else if(detailType.equals("JSON")) {
|
||||||
|
dType = "detail_6";
|
||||||
|
apiResponse.put("dType", dType);
|
||||||
|
JSONObject detailObj = dataObj.getJSONObject("gameDetail");
|
||||||
|
saveObj = detailObj;
|
||||||
|
HashMap<String, Object> detailMap = new Gson().fromJson(detailObj.toString(), HashMap.class);
|
||||||
|
apiResponse.put("detail", detailMap);
|
||||||
|
} else {
|
||||||
|
apiResponse.put("detail", "betId is not exist");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
apiResponse.put("detail", "betId is not exist");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if("nexus".equals(betInfo.get("vendorCode").toString()) || "ace2".equals(betInfo.get("vendorCode").toString())) {
|
||||||
|
String jsonStr = siteService.getOrgDetailData(param);
|
||||||
|
log.info(LOG_PREFIX+ "jsonStr : " + jsonStr);
|
||||||
|
if(jsonStr != null && !"".equals(jsonStr) && !"{}".equals(jsonStr)) {
|
||||||
|
dType = "detail_3";
|
||||||
|
apiResponse.put("dType", dType);
|
||||||
|
HashMap<String, Object> detailMap = new Gson().fromJson(jsonStr, HashMap.class);
|
||||||
|
apiResponse.put("detail", detailMap);
|
||||||
|
}
|
||||||
|
} else if("prime".equals(betInfo.get("vendorCode").toString())
|
||||||
|
|| "dpcore".equals(betInfo.get("vendorCode").toString())) {
|
||||||
|
log.info(LOG_PREFIX+ "========== BetDetail::PRIME ==========");
|
||||||
|
dType = "detail_9";
|
||||||
|
apiResponse.put("dType", dType);
|
||||||
|
|
||||||
|
String jsonStr = siteService.getOrgDetailData(param);
|
||||||
|
if(jsonStr != null && !"".equals(jsonStr) && !"{}".equals(jsonStr)) {
|
||||||
|
HashMap<String, Object> detailMap = new Gson().fromJson(jsonStr, HashMap.class);
|
||||||
|
apiResponse.put("detail", detailMap);
|
||||||
|
}
|
||||||
|
} else if("onix".equals(betInfo.get("vendorCode").toString())) {
|
||||||
|
log.info(LOG_PREFIX+ "========== BetDetail::ONIX ==========");
|
||||||
|
dType = "detail_8";
|
||||||
|
apiResponse.put("dType", dType);
|
||||||
|
|
||||||
|
String apiBaseUrl = betInfo.get("vendorApiUrl").toString();
|
||||||
|
|
||||||
|
// Step 1: Get round info from /csapi/getBetting
|
||||||
|
String bettingUrl = apiBaseUrl + "/csapi/getBetting";
|
||||||
|
JSONObject bettingBody = new JSONObject();
|
||||||
|
bettingBody.put("userid", betInfo.get("memberId").toString());
|
||||||
|
bettingBody.put("sdate", "2000-01-01 00:00:00.000");
|
||||||
|
bettingBody.put("edate", "2099-12-31 23:59:59.999");
|
||||||
|
bettingBody.put("pagesize", "1");
|
||||||
|
bettingBody.put("gameid", "0");
|
||||||
|
bettingBody.put("tranid", param.getBetId());
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "ONIX::Step1 getBetting Url: " + bettingUrl);
|
||||||
|
log.info(LOG_PREFIX+ "ONIX::Step1 getBetting Body: " + bettingBody.toString());
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<String> bettingRes = webClient.post()
|
||||||
|
.uri(bettingUrl)
|
||||||
|
.headers(h -> h.addAll(headers))
|
||||||
|
.bodyValue(bettingBody.toString())
|
||||||
|
.retrieve()
|
||||||
|
.toEntity(String.class)
|
||||||
|
.block();
|
||||||
|
if(bettingRes != null && bettingRes.getBody() != null) {
|
||||||
|
JSONObject bettingObj = new JSONObject(bettingRes.getBody());
|
||||||
|
log.info(LOG_PREFIX+ "ONIX::Step1 getBetting Response: " + bettingObj.toString());
|
||||||
|
|
||||||
|
int bettingResult = bettingObj.getInt("result");
|
||||||
|
if(bettingResult == 1 && bettingObj.has("data")) {
|
||||||
|
JSONArray dataArray = bettingObj.getJSONArray("data");
|
||||||
|
if(dataArray.length() > 0) {
|
||||||
|
JSONObject betData = dataArray.getJSONObject(0);
|
||||||
|
String round = betData.has("round") ? betData.getString("round") : "";
|
||||||
|
String realround = betData.has("realround") ? betData.getString("realround") : "";
|
||||||
|
String game = betData.has("game") ? betData.getString("game") : "";
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "ONIX::Betting Info - round: " + round + ", realround: " + realround + ", game: " + game);
|
||||||
|
|
||||||
|
// Step 2: Get detail link from /api/apigamedetail.aspx
|
||||||
|
if(!round.isEmpty() && !realround.isEmpty()) {
|
||||||
|
String gtype = game.toLowerCase().contains("slot") || game.toLowerCase().contains("prg") ? "sxprg" : "apievo";
|
||||||
|
String detailUrl = apiBaseUrl + "/api/apigamedetail.aspx?gtype=" + gtype;
|
||||||
|
|
||||||
|
if(gtype.equals("apievo")) {
|
||||||
|
detailUrl += "&round=" + round + "&realround=" + realround;
|
||||||
|
} else {
|
||||||
|
detailUrl += "&roundid=" + realround;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "ONIX::Step2 Detail Url: " + detailUrl);
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<String> detailRes = webClient.get()
|
||||||
|
.uri(detailUrl)
|
||||||
|
.retrieve()
|
||||||
|
.toEntity(String.class)
|
||||||
|
.block();
|
||||||
|
|
||||||
|
if(detailRes != null && detailRes.getBody() != null) {
|
||||||
|
JSONObject detailObj = new JSONObject(detailRes.getBody());
|
||||||
|
log.info(LOG_PREFIX+ "ONIX::Step2 Detail Response: " + detailObj.toString());
|
||||||
|
|
||||||
|
if(detailObj.getInt("result") == 1 && detailObj.has("link")) {
|
||||||
|
isSaveEvoDetail = true;
|
||||||
|
JSONObject saveData = new JSONObject();
|
||||||
|
saveData.put("link", detailObj.getString("link"));
|
||||||
|
saveData.put("betInfo", betData);
|
||||||
|
saveObj = saveData;
|
||||||
|
|
||||||
|
HashMap<String, Object> detailMap = new HashMap<>();
|
||||||
|
detailMap.put("link", detailObj.getString("link"));
|
||||||
|
detailMap.put("betInfo", new Gson().fromJson(betData.toString(), HashMap.class));
|
||||||
|
apiResponse.put("detail", detailMap);
|
||||||
|
log.info(LOG_PREFIX+ "ONIX::Detail loaded successfully");
|
||||||
|
} else {
|
||||||
|
apiResponse.put("detail", "betId is not exist");
|
||||||
|
String msg = detailObj.has("msg") ? detailObj.getString("msg") : "Unknown error";
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Detail Error: " + msg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
apiResponse.put("detail", "betId is not exist");
|
||||||
|
}
|
||||||
|
} catch(Exception detailEx) {
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Detail Exception: " + detailEx.getMessage());
|
||||||
|
apiResponse.put("detail", "betId is not exist");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// No round info, use betting data only
|
||||||
|
isSaveEvoDetail = true;
|
||||||
|
saveObj = betData;
|
||||||
|
HashMap<String, Object> detailMap = new Gson().fromJson(betData.toString(), HashMap.class);
|
||||||
|
apiResponse.put("detail", detailMap);
|
||||||
|
log.info(LOG_PREFIX+ "ONIX::Betting data loaded (no round info)");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
apiResponse.put("detail", "betId is not exist");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
apiResponse.put("detail", "betId is not exist");
|
||||||
|
String errorMsg = bettingObj.has("msg") ? bettingObj.getString("msg") : "Unknown error";
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Betting Error: " + errorMsg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
apiResponse.put("detail", "betId is not exist");
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Betting Response is null");
|
||||||
|
}
|
||||||
|
} catch(WebClientResponseException e) {
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Betting HttpClientErrorException : " + e.getMessage());
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Betting status code : " + e.getStatusCode().value());
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Betting response body : " + e.getResponseBodyAsString());
|
||||||
|
JSONObject errorJson = new JSONObject(e.getResponseBodyAsString());
|
||||||
|
String errorMsg = errorJson.has("msg") ? errorJson.getString("msg") : "Betting API error";
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Betting error : " + errorMsg);
|
||||||
|
throw new ApiException("P209", errorMsg);
|
||||||
|
} catch (WebClientRequestException rae) {
|
||||||
|
if(rae.getCause() instanceof io.netty.channel.ConnectTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Betting ConnectTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof io.netty.handler.timeout.ReadTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Betting ReadTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Betting InterruptedException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
throw new ApiException("P210", rae.getMessage());
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.error(LOG_PREFIX+ "ONIX::Betting Exception : " + e.getMessage());
|
||||||
|
throw new ApiException("P211", e.getMessage());
|
||||||
|
}
|
||||||
|
} else if("bet_radar".equals(betInfo.get("vendorCode").toString())) {
|
||||||
|
log.info(LOG_PREFIX+ "========== BetDetail::BET_RADAR ==========");
|
||||||
|
// bet_radar_log 테이블에서 조회
|
||||||
|
String radarLogJson = siteService.getMergedBetRadarLog(param.getBetId());
|
||||||
|
if(radarLogJson != null && !radarLogJson.isEmpty()) {
|
||||||
|
log.info(LOG_PREFIX+ "bet_radar_log found, returning merged json");
|
||||||
|
dType = "detail_radar";
|
||||||
|
apiResponse.put("dType", dType);
|
||||||
|
HashMap<String, Object> detailMap = new Gson().fromJson(radarLogJson, HashMap.class);
|
||||||
|
apiResponse.put("detail", detailMap);
|
||||||
|
apiResponse.success();
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
apiResponse.put("dType", dType);
|
||||||
|
apiResponse.put("detail", "betId is not exist");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
apiResponse.put("dType", dType);
|
||||||
|
apiResponse.put("detail", "betId is not exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.success();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(LOG_PREFIX+ "[Exception]::"+e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
424
src/main/java/com/bb/admin/controller/InsuranceController.java
Normal file
424
src/main/java/com/bb/admin/controller/InsuranceController.java
Normal file
@@ -0,0 +1,424 @@
|
|||||||
|
package com.bb.admin.controller;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.annotation.Secured;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.bb.model.CommonParamAdmin;
|
||||||
|
import com.bb.model.Insure;
|
||||||
|
import com.bb.model.PageFormVO;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
import com.bb.service.CreditService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.PagingUtil;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "/insurance")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public class InsuranceController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CreditService creditService;
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/addProc")
|
||||||
|
public @ResponseBody JSONObject addProc( HttpServletRequest request, ModelMap model, Insure insure) throws Exception {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
insure.setSiteId(loginSite.getSiteId());
|
||||||
|
insure.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
|
||||||
|
|
||||||
|
List<HashMap> vederRateList = siteService.getVenderRateList(loginSite);
|
||||||
|
if(vederRateList.size() <0) {
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
obj.put("MSG", "보험설정을 해주세요.");
|
||||||
|
return obj;
|
||||||
|
}else{
|
||||||
|
|
||||||
|
System.out.println(":dddddddddd" + vederRateList.get(0).get("insureUpSiteIdx"));
|
||||||
|
if(vederRateList.get(0).get("insureUpSiteIdx") == null || "null".equals(vederRateList.get(0).get("insureUpSiteIdx"))) {
|
||||||
|
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
obj.put("MSG", "보험적용컴퍼니가 없습니다. 보험설정을 해주세요.");
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
insure.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
insure.setSiteId(loginSite.getSiteId());
|
||||||
|
insure.setInsureUpSiteId(vederRateList.get(0).get("insureUpSiteId").toString());
|
||||||
|
insure.setInsureUpSiteIdx(Long.parseLong(vederRateList.get(0).get("insureUpSiteIdx").toString()));
|
||||||
|
insure.setPreCreditAmt(siteCredit);
|
||||||
|
insure.setPreCreditPoint(sitePoint);
|
||||||
|
insure.setPreInsureAmt(insureAmt);
|
||||||
|
insure.setPreInsurePoint(insurePointAmt);
|
||||||
|
insure.setStatus("0");
|
||||||
|
insure.setRegId(loginSite.getSiteId());
|
||||||
|
|
||||||
|
if("TRANIN".equals(insure.getInsureType())){ //충전 신청
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}else if("TRANOUT".equals(insure.getInsureType())){ //환전 신청
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int res = creditService.insertInsure(insure);
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/updateStatus")
|
||||||
|
public @ResponseBody JSONObject updateStatus( HttpServletRequest request, ModelMap model, Insure insure) throws Exception {
|
||||||
|
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
insure.setSiteId(loginSite.getSiteId());
|
||||||
|
insure.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
// 상위 보험 관련 데이터 가져오기
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
int res = creditService.updateInsureStatus(insure);
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/set")
|
||||||
|
public String index( HttpServletRequest request , ModelMap model) throws Exception {
|
||||||
|
System.out.println("index");
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
|
||||||
|
//상위 컴파니 불려오기
|
||||||
|
|
||||||
|
List<HashMap> flowList = siteService.getSiteFlow(loginSite);
|
||||||
|
model.put("flowList", flowList);
|
||||||
|
//벤더 리스트 rate 불러오기
|
||||||
|
List<HashMap> vederRateList = siteService.getVenderRateList(loginSite);
|
||||||
|
|
||||||
|
int uppersiteIdx = 0;
|
||||||
|
if(vederRateList.size()>0) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
uppersiteIdx = Integer.parseInt(vederRateList.get(0).get("insureUpSiteIdx").toString());
|
||||||
|
}catch(Exception e) {
|
||||||
|
uppersiteIdx = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model.put("uppersiteIdx", uppersiteIdx);
|
||||||
|
|
||||||
|
/*SELECT * FROM vendors_info vi
|
||||||
|
LEFT JOIN `site_rate_info` sri ON vi.vendorIdx = sri.vendorIdx
|
||||||
|
WHERE vi.delYn= 'N' AND vi.useYn ='Y'
|
||||||
|
AND sri.siteIdx = 1
|
||||||
|
*/
|
||||||
|
model.put("vederRateList", vederRateList);
|
||||||
|
|
||||||
|
return "admin/insuredSet";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/setSave")
|
||||||
|
public @ResponseBody JSONObject setSave( HttpServletRequest request, ModelMap model, CommonParamAdmin commonParamAdmin ) throws Exception {
|
||||||
|
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
log.info(commonParamAdmin.toString());
|
||||||
|
|
||||||
|
for(int i=0;i<commonParamAdmin.getParamlist().length;i++) {
|
||||||
|
JSONObject paramData = commonParamAdmin.getParamlist()[i];
|
||||||
|
paramData.put("siteIdx", loginSite.getSiteIdx());
|
||||||
|
paramData.put("insureUpSiteIdX", commonParamAdmin.getParam().get("uppersiteIdx"));
|
||||||
|
log.info(paramData.toString());
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
HashMap paramMap = mapper.readValue(paramData.toString(), new TypeReference<HashMap>() {});
|
||||||
|
|
||||||
|
siteService.saveVendorInsureRate(paramMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/betList")
|
||||||
|
public String betList( HttpServletRequest request ,ModelMap model , @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
System.out.println("index");
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
|
||||||
|
if("up".equals(search.getUpdown())){
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
}else if("down".equals(search.getUpdown())){
|
||||||
|
search.setUpperSiteId(loginSite.getSiteId());
|
||||||
|
}
|
||||||
|
search.setSearchType("BET");
|
||||||
|
search.setStatus("1");
|
||||||
|
|
||||||
|
int totalCount = creditService.getInsureListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(15);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<HashMap> list = creditService.getInsureList(search);
|
||||||
|
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/insuredBetList";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/history")
|
||||||
|
public String history( HttpServletRequest request , ModelMap model) throws Exception {
|
||||||
|
System.out.println("index");
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return "admin/insuredHistory";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/apply")
|
||||||
|
public String apply( HttpServletRequest request , ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
System.out.println("index");
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
search.setUpperSiteId(loginSite.getSiteId());
|
||||||
|
search.setSearchType("TRANIN");
|
||||||
|
|
||||||
|
if(search.getStatus()==null || "".equals(search.getStatus())) {
|
||||||
|
search.setStatus("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int totalCount = creditService.getInsureListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(10);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
model.put("searchVO", search);
|
||||||
|
List<HashMap> list = creditService.getInsureList(search);
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
// model.addObject("long", Long.parseLong(null));
|
||||||
|
|
||||||
|
|
||||||
|
return "admin/insuredApply";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/exchange")
|
||||||
|
public String exchange( HttpServletRequest request , ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
System.out.println("index");
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
search.setUpperSiteId(loginSite.getSiteId());
|
||||||
|
search.setSearchType("TRANOUT");
|
||||||
|
|
||||||
|
if(search.getStatus()==null || "".equals(search.getStatus())) {
|
||||||
|
search.setStatus("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int totalCount = creditService.getInsureListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(10);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
model.put("searchVO", search);
|
||||||
|
List<HashMap> list = creditService.getInsureList(search);
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
// model.addObject("long", Long.parseLong(null));
|
||||||
|
|
||||||
|
|
||||||
|
return "admin/insuredExchange";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
274
src/main/java/com/bb/admin/controller/MainController.java
Normal file
274
src/main/java/com/bb/admin/controller/MainController.java
Normal file
@@ -0,0 +1,274 @@
|
|||||||
|
package com.bb.admin.controller;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
|
import com.bb.model.ApiTestVO;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "")
|
||||||
|
public class MainController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WebClient webClient; // 싱글톤 WebClient 주입
|
||||||
|
|
||||||
|
@GetMapping("/")
|
||||||
|
@PreAuthorize("permitAll()")
|
||||||
|
public String first(HttpServletRequest request, ModelMap model) throws Exception {
|
||||||
|
System.out.println("error/404");
|
||||||
|
|
||||||
|
String code = request.getParameter("code");
|
||||||
|
model.put("code", code);
|
||||||
|
|
||||||
|
return "error/404";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/lg")
|
||||||
|
public String loginsForm(HttpServletRequest request, ModelMap model) throws Exception {
|
||||||
|
System.out.println("login");
|
||||||
|
|
||||||
|
return "admin/lg";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/index")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public String index(HttpServletRequest request, ModelMap model) throws Exception {
|
||||||
|
|
||||||
|
System.out.println("index");
|
||||||
|
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
// long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", 0);
|
||||||
|
// HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", 0);
|
||||||
|
// pot 정보 가져오기
|
||||||
|
|
||||||
|
// long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
// long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", 0);
|
||||||
|
model.put("insurePointAmt", 0);
|
||||||
|
|
||||||
|
Map dashInfo = siteService.getDashInfo(loginSite); // 베팅정보
|
||||||
|
Map dashInfo2 = siteService.getDashInfo2(loginSite); // 하부에이전수 수.
|
||||||
|
|
||||||
|
model.put("dashInfo", dashInfo);
|
||||||
|
model.put("dashInfo2", dashInfo2);
|
||||||
|
|
||||||
|
return "admin/index";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/mypage")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public String mypage(HttpServletRequest request, ModelMap model) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
log.info("underSiteCredit" + underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
Site mypageInfo = siteService.getSiteInfoMypage(loginSite);
|
||||||
|
model.put("mypageInfo", mypageInfo);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
return "admin/mypage";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/mypage/pwdUpdate")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public @ResponseBody JSONObject pwdUpdate(HttpServletRequest request, ModelMap model, Site site) throws Exception {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
site.setUpperSiteId(loginSite.getSiteId());
|
||||||
|
site.setUpperSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
Map siteParam = new HashMap();
|
||||||
|
siteParam.put("siteId", loginSite.getSiteId());
|
||||||
|
siteParam.put("sitePass", site.getNowPass());
|
||||||
|
|
||||||
|
Site checkSite = siteService.getSiteBypassword(siteParam);
|
||||||
|
|
||||||
|
if (checkSite == null) {
|
||||||
|
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
obj.put("MSG", "현재 비밀번호를 확인해주세요.");
|
||||||
|
return obj;
|
||||||
|
} else {
|
||||||
|
siteParam.put("newPass", site.getNewPass());
|
||||||
|
siteService.updatePass(siteParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/mypage/siteUpdate")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public @ResponseBody JSONObject siteUpdate(HttpServletRequest request, ModelMap model, Site site) throws Exception {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
site.setSiteId(loginSite.getSiteId());
|
||||||
|
final String LOG_PREFIX = "#-super::mySiteUpdate:::";
|
||||||
|
|
||||||
|
String siteKey = loginSite.getSiteKey();
|
||||||
|
if ("new".equals(site.getSiteKey())) {
|
||||||
|
siteKey = makeApiKey(loginSite.getSiteId());
|
||||||
|
site.setSiteKey(siteKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "Site Info: " + site.toString());
|
||||||
|
log.info(LOG_PREFIX + "Site IP: " + site.getSiteIp());
|
||||||
|
siteService.siteUpdate(LOG_PREFIX, site);
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
obj.put("DATA", siteKey);
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/manual/apiTest")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public @ResponseBody JSONObject apiTest(HttpServletRequest request, ModelMap model, ApiTestVO param)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("##### API Test 시작: {}", param.toString());
|
||||||
|
|
||||||
|
String apiUrl = param.getApiUrl();
|
||||||
|
|
||||||
|
// 1. 전송할 바디 데이터 구성
|
||||||
|
JSONObject paraJson = new JSONObject();
|
||||||
|
paraJson.put("userId", param.getUserId());
|
||||||
|
paraJson.put("nickName", param.getNickName());
|
||||||
|
paraJson.put("userIp", param.getUserIp());
|
||||||
|
paraJson.put("balance", param.getBalance());
|
||||||
|
|
||||||
|
// 빈 값이 아닐 때만 파라미터 추가
|
||||||
|
if (param.getVendorKey() != null && !"".equals(param.getVendorKey()))
|
||||||
|
paraJson.put("vendorKey", param.getVendorKey());
|
||||||
|
if (param.getBetId() != null && !"".equals(param.getBetId()))
|
||||||
|
paraJson.put("betId", param.getBetId());
|
||||||
|
if (param.getStartDate() != null && !"".equals(param.getStartDate()))
|
||||||
|
paraJson.put("startDate", param.getStartDate());
|
||||||
|
if (param.getEndDate() != null && !"".equals(param.getEndDate()))
|
||||||
|
paraJson.put("endDate", param.getEndDate());
|
||||||
|
if (param.getGameKey() != null && !"".equals(param.getGameKey()))
|
||||||
|
paraJson.put("gameKey", param.getGameKey());
|
||||||
|
if (param.getIsMobile() != null && !"".equals(param.getIsMobile()))
|
||||||
|
paraJson.put("isMobile", param.getIsMobile());
|
||||||
|
if (param.getLanguage() != null && !"".equals(param.getLanguage()))
|
||||||
|
paraJson.put("language", param.getLanguage());
|
||||||
|
|
||||||
|
// 2. WebClient를 이용한 호출 (동기 방식 .block())
|
||||||
|
String responseBody = webClient.post().uri(apiUrl).contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.accept(MediaType.APPLICATION_JSON).header("User-Agent", "PostmanRuntime/7.28.4")
|
||||||
|
.header("Authorization", loginSite.getSiteKey())
|
||||||
|
// 토큰이 있을 경우에만 헤더 추가
|
||||||
|
.headers(headers -> {
|
||||||
|
if (param.getToken() != null && !"".equals(param.getToken())) {
|
||||||
|
headers.add("token", param.getToken());
|
||||||
|
}
|
||||||
|
}).bodyValue(paraJson.toString()).retrieve().bodyToMono(String.class).block(); // 응답이 올 때까지 대기
|
||||||
|
|
||||||
|
// 3. 응답 결과 처리
|
||||||
|
JSONObject resJson = JSONObject.fromObject(responseBody);
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
obj.put("DATA", resJson);
|
||||||
|
|
||||||
|
log.info("##### API Test 응답 완료: {}", resJson.toString());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("##### API Test 에러 발생: {}", e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
obj.put("RES", "FAIL");
|
||||||
|
obj.put("MESSAGE", e.getMessage()); // 에러 메시지도 화면에 전달
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/limit")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public String limit(HttpServletRequest request, ModelMap model) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
return "admin/limit";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String makeApiKey(String param) {
|
||||||
|
|
||||||
|
int n = 10; // n자리 쿠폰
|
||||||
|
char[] chs = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
|
||||||
|
'J', 'K', 'L', 'M', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'N', 'O', 'P', 'Q',
|
||||||
|
'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
|
||||||
|
'z' };
|
||||||
|
|
||||||
|
Random rd = new Random();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
char ch = chs[rd.nextInt(chs.length)];
|
||||||
|
sb.append(ch);
|
||||||
|
}
|
||||||
|
return param + sb.toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
246
src/main/java/com/bb/admin/controller/ManualController.java
Normal file
246
src/main/java/com/bb/admin/controller/ManualController.java
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
package com.bb.admin.controller;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.annotation.Secured;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public class ManualController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/manual")
|
||||||
|
public String devmanual( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
|
||||||
|
return "admin/api_doc";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/apiLogdev")
|
||||||
|
public String devApiLog( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
return "admin/apiLogdev";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/apiIntro")
|
||||||
|
public String devIntro( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
return "admin/apiIntro";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/apiGame")
|
||||||
|
public String devGame( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
return "admin/apiGame";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/apiGamelist")
|
||||||
|
public String devGamelist( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
return "admin/apiGamelist";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/apiPartner")
|
||||||
|
public String devPartner( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
return "admin/apiPartner";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/apiBetList")
|
||||||
|
public String devBetlist( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return "admin/apiBetList";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/apiBetDetail")
|
||||||
|
public String devBetDe( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
return "admin/apiBetDetail";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/apiBetCallback")
|
||||||
|
public String devBetCall( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
return "admin/apiBetCallback";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/apiBetInfo1")
|
||||||
|
public String devInfo1( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
return "admin/apiBetInfo1";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/apiBetInfo2")
|
||||||
|
public String devInfo2( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
return "admin/apiBetInfo2";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping({"/apiAuth"})
|
||||||
|
public String apiAuth( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
return "admin/apiAuth";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping({"/apiPlay"})
|
||||||
|
public String apiPlay( HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
|
||||||
|
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
return "admin/apiPlay";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
339
src/main/java/com/bb/admin/controller/StatController.java
Normal file
339
src/main/java/com/bb/admin/controller/StatController.java
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
package com.bb.admin.controller;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.annotation.Secured;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import com.bb.model.PageFormVO;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.service.StatService;
|
||||||
|
import com.bb.util.DateTimeUtils;
|
||||||
|
import com.bb.util.PagingUtil;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "/stat")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public class StatController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
StatService statService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@GetMapping("")
|
||||||
|
public String loginForm(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
System.out.println(search.toString());
|
||||||
|
List<HashMap> list = statService.getSiteDailyReportList(search);
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
System.out.println(list.size());
|
||||||
|
|
||||||
|
return "admin/stat";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/bottom")
|
||||||
|
public String index(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
search.setUpperSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
List<HashMap> list = statService.getBottomSiteDailyReportList(search);
|
||||||
|
model.put("list", list);
|
||||||
|
return "admin/statBottom";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/pot")
|
||||||
|
public String mypage(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
String currDate = DateTimeUtils.getYyyymmdd();
|
||||||
|
String yyyy = currDate.substring(0, 4);
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
int mm = Integer.parseInt(currDate.substring(4, 6));
|
||||||
|
if (search.getStartDate() == null) {
|
||||||
|
|
||||||
|
String mmm = currDate.substring(4, 6);
|
||||||
|
model.put("yyyy", yyyy);
|
||||||
|
model.put("mmm", mmm);
|
||||||
|
search.setStartDate(mmm);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
String mmm = search.getStartDate();
|
||||||
|
model.put("yyyy", yyyy);
|
||||||
|
model.put("mmm", mmm);
|
||||||
|
search.setStartDate(mmm);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// model.put("", yyyy);
|
||||||
|
model.put("mm", mm);
|
||||||
|
|
||||||
|
HashMap list = statService.getMonthCredit(search);
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/statPot";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/casino")
|
||||||
|
public String statCasino(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
List<HashMap> list = statService.getVendorDailyReportList(search);
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/statCasino";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/user")
|
||||||
|
public String statUser(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
if (search.getStartDate() == null || "".equals(search.getStartDate())) {
|
||||||
|
String currDate = DateTimeUtils.getYyyymm();
|
||||||
|
search.setStartDate(currDate.substring(0, 4));
|
||||||
|
search.setEndDate(currDate.substring(4, 6));
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(search.getStartDate());
|
||||||
|
List<HashMap> list = statService.getUserDailyReportList(search);
|
||||||
|
|
||||||
|
model.put("list", list);
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/statUser";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/date")
|
||||||
|
public String statDate(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
System.out.println(search.getStartDate());
|
||||||
|
List<HashMap> list = statService.getUserReportSum(search);
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/statDate";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/agentReport")
|
||||||
|
public String agentReport(HttpServletRequest request, ModelMap model, @ModelAttribute("searchVO") SiteSearch search)
|
||||||
|
throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site) authentication.getDetails();
|
||||||
|
|
||||||
|
final String LOG_PREFIX = "#-SUPER::agentReport::::";
|
||||||
|
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
search.setSiteId(loginSite.getSiteId());
|
||||||
|
|
||||||
|
if(search.getSearchSiteId() != null && !"".equals(search.getSearchSiteId())) {
|
||||||
|
Site targetSite = siteService.getSiteSimpleDetail(search);
|
||||||
|
if(targetSite != null) {
|
||||||
|
search.setSearchSiteIdx(targetSite.getSiteIdx());
|
||||||
|
} else {
|
||||||
|
search.setSearchSiteIdx(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
search.setSearchSiteIdx(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
String toDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date(System.currentTimeMillis()));
|
||||||
|
String startDay = "";
|
||||||
|
String endDay = "";
|
||||||
|
if(search.getStartDate() == null || "".equals(search.getStartDate())) {
|
||||||
|
startDay = toDay;
|
||||||
|
search.setStartDate(startDay);
|
||||||
|
} else {
|
||||||
|
startDay = search.getStartDate().substring(0, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(search.getEndDate() == null || "".equals(search.getEndDate())) {
|
||||||
|
endDay = toDay;
|
||||||
|
search.setEndDate(endDay);
|
||||||
|
} else {
|
||||||
|
endDay = search.getEndDate().substring(0, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "startDay::"+startDay);
|
||||||
|
log.info(LOG_PREFIX+ "endDay::"+endDay);
|
||||||
|
log.info(LOG_PREFIX+ "toDay::"+toDay);
|
||||||
|
search.setSiteDispYn("N");
|
||||||
|
if(startDay.equals(toDay) || endDay.equals(toDay)) {
|
||||||
|
search.setSiteDispYn("Y");
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String reqJsonStr = objectMapper.writeValueAsString(search);
|
||||||
|
JSONObject reqObj = new JSONObject(reqJsonStr);
|
||||||
|
log.info(LOG_PREFIX+ "Request {}", reqObj);
|
||||||
|
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
if(loginSite.getSiteLevel() > 0) {
|
||||||
|
search.setUpperSiteId(loginSite.getSiteId());
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalCount = statService.getAgentReportCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
commonForm.setCount_per_list(30);
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
log.info(LOG_PREFIX+ "search.getStartDate {}", search.getStartDate());
|
||||||
|
log.info(LOG_PREFIX+ "search.getEndDate {}", search.getEndDate());
|
||||||
|
log.info(LOG_PREFIX+ "search.getSearchSiteIdx {}", search.getSearchSiteIdx());
|
||||||
|
log.info(LOG_PREFIX+ "search.getPage {}", search.getPage());
|
||||||
|
log.info(LOG_PREFIX+ "search.getLimit {}", search.getLimit());
|
||||||
|
log.info(LOG_PREFIX+ "search.getOffset {}", search.getOffset());
|
||||||
|
|
||||||
|
List<HashMap> siteList = statService.getAgentReportList(search);
|
||||||
|
model.put("siteList", siteList);
|
||||||
|
|
||||||
|
return "admin/agentReport";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
273
src/main/java/com/bb/admin/controller/UserController.java
Normal file
273
src/main/java/com/bb/admin/controller/UserController.java
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
package com.bb.admin.controller;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.annotation.Secured;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.bb.model.PageFormVO;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
import com.bb.model.WithdrewRequest;
|
||||||
|
import com.bb.service.CreditService;
|
||||||
|
import com.bb.service.GsoftService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.service.TplusService;
|
||||||
|
import com.bb.util.PagingUtil;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "user")
|
||||||
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TplusService tplusService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
GsoftService gsoftService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CreditService creditService;
|
||||||
|
|
||||||
|
@GetMapping("")
|
||||||
|
public String loginForm( HttpServletRequest request, ModelMap model , @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", 0);
|
||||||
|
model.put("siteCredit",siteCredit);
|
||||||
|
model.put("sitePoint", 0);
|
||||||
|
model.put("creditWait", 0);
|
||||||
|
model.put("insureAmt", 0);
|
||||||
|
model.put("insurePointAmt", 0);
|
||||||
|
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
log.info("#-SUPER::USER_DETAIL::Search : "+search.toString());
|
||||||
|
|
||||||
|
int totalCount = siteService.getSiteUserListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(100);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap> list = siteService.getSiteUserList(search);
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
return "admin/user";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/parseOnOff")
|
||||||
|
public @ResponseBody JSONObject parseOnOff(HttpServletRequest request, ModelMap model, @RequestParam("memberIdx") String memberIdx, @RequestParam("pStatus") String pStatus) throws Exception {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
final String LOG_PREFIX = "#-Proc::Evo::parseOnOff:::";
|
||||||
|
HashMap param = new HashMap<>();
|
||||||
|
param.put("memberIdx", memberIdx);
|
||||||
|
param.put("parseEvoYn", pStatus);
|
||||||
|
log.info(LOG_PREFIX + "전체 사이트 파싱설정::" + param.toString() + "::START");
|
||||||
|
|
||||||
|
int result = siteService.updateParseEvoYn(param);
|
||||||
|
log.info(LOG_PREFIX + "updateParseEvoYn result::" + result + "::END");
|
||||||
|
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/betlist")
|
||||||
|
public String index( HttpServletRequest request, ModelMap model , @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
search.setSiteId(loginSite.getSiteId());
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
|
||||||
|
int totalCount = creditService.getSiteBetListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(15);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
model.put("pageInfo", pageVo.getPagination());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<HashMap> list = creditService.getSiteBetList(search);
|
||||||
|
log.debug(""+list.size());
|
||||||
|
model.put("list", list);
|
||||||
|
|
||||||
|
|
||||||
|
return "admin/betlist";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/transaction")
|
||||||
|
public String mypage( HttpServletRequest request, ModelMap model ) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return "admin/transactionList";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/payments")
|
||||||
|
public String limit( HttpServletRequest request, ModelMap model ) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return "admin/payments";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/std")
|
||||||
|
public String std ( HttpServletRequest request, ModelMap model , @ModelAttribute("searchVO") SiteSearch search) throws Exception {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
Site loginSite = (Site)authentication.getDetails();
|
||||||
|
model.put("loginSite", loginSite);
|
||||||
|
long siteCredit = siteService.getSiteCredit(loginSite.getSiteId());
|
||||||
|
long underSiteCredit = siteService.getUnderSiteCredit(loginSite.getSiteId());
|
||||||
|
model.put("underSiteCredit", underSiteCredit);
|
||||||
|
model.put("siteCredit", siteCredit);
|
||||||
|
long sitePoint = siteService.getSitePoint(loginSite.getSiteId());
|
||||||
|
model.put("sitePoint", sitePoint);
|
||||||
|
HashMap creditWait = siteService.getCreditWait(loginSite.getSiteIdx());
|
||||||
|
model.put("creditWait", creditWait);
|
||||||
|
long insureAmt = siteService.getInsureAmt(loginSite.getSiteId());
|
||||||
|
long insurePointAmt = siteService.getInsurePointAmt(loginSite.getSiteId());
|
||||||
|
model.put("insureAmt", insureAmt);
|
||||||
|
model.put("insurePointAmt", insurePointAmt);
|
||||||
|
|
||||||
|
search.setSiteIdx(loginSite.getSiteIdx());
|
||||||
|
|
||||||
|
List<HashMap> venderAcountList = siteService.getTrasferVendorList();
|
||||||
|
|
||||||
|
|
||||||
|
for(HashMap vendor : venderAcountList) {
|
||||||
|
String balance ="0";
|
||||||
|
vendor.put("balance", balance);
|
||||||
|
}
|
||||||
|
|
||||||
|
model.put("list", venderAcountList);
|
||||||
|
|
||||||
|
return "admin/std";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/withdrawAll")
|
||||||
|
public synchronized @ResponseBody JSONObject withdrawAll(HttpServletRequest request, ModelMap model, WithdrewRequest withdrewRequest) throws Exception {
|
||||||
|
log.warn( " member withdrawAll 시작" + withdrewRequest.toString() );
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
List<HashMap> allMemberList = siteService.getAllMember2();
|
||||||
|
for(HashMap member:allMemberList) {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
long reqAtL = System.currentTimeMillis();
|
||||||
|
String reqAt = sdf.format(reqAtL);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info( " member betCheck 끝" );
|
||||||
|
obj.put("RES", "SUCCESS");
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
1273
src/main/java/com/bb/api/ApiAgentController.java
Normal file
1273
src/main/java/com/bb/api/ApiAgentController.java
Normal file
File diff suppressed because it is too large
Load Diff
734
src/main/java/com/bb/api/ApiBlockGameController.java
Normal file
734
src/main/java/com/bb/api/ApiBlockGameController.java
Normal file
@@ -0,0 +1,734 @@
|
|||||||
|
package com.bb.api;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.bb.jwt.JwtManager;
|
||||||
|
import com.bb.model.ApiResponse;
|
||||||
|
import com.bb.model.BlockGameVO;
|
||||||
|
import com.bb.model.CmnSearch;
|
||||||
|
import com.bb.model.Game;
|
||||||
|
import com.bb.model.GameVo;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.service.CommonService;
|
||||||
|
import com.bb.service.SettingService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.IPKit;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(value = "/api/v1/block")
|
||||||
|
public class ApiBlockGameController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SettingService settingService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CommonService commonService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final JwtManager jwtManager;
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/vendor-selectbox")
|
||||||
|
public ApiResponse vendorSelectBox(@RequestHeader String token, HttpServletRequest request) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::BLOCK::vendorSelectBox::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
List<HashMap<String, Object>> list = settingService.getBlockVendorSelectBoxList("CASINO");
|
||||||
|
log.info(LOG_PREFIX + "Block-Vendor-SelectBoxList cnt::"+list.size());
|
||||||
|
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/table-selectbox")
|
||||||
|
public ApiResponse tableSelectBox(@RequestHeader String token, HttpServletRequest request, @RequestBody CmnSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::BLOCK::tableSelectBox::"+tokenInfo.getSid()+"::::";
|
||||||
|
search.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "Request Param::"+search);
|
||||||
|
List<HashMap<String, Object>> list = settingService.getBlockTableSelectBoxList(search);
|
||||||
|
log.info(LOG_PREFIX + "Block-Table-SelectBoxList cnt::"+list.size());
|
||||||
|
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/table-list")
|
||||||
|
public ApiResponse blockTableList(@RequestHeader String token, HttpServletRequest request, @RequestBody CmnSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::BLOCK::blockTableList::"+tokenInfo.getSid()+"::::";
|
||||||
|
search.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "Request Param::"+search);
|
||||||
|
List<HashMap<String, Object>> list = settingService.getBlockTableSelectBoxList(search);
|
||||||
|
List<HashMap<String, Object>> mylist = new ArrayList<HashMap<String,Object>>();
|
||||||
|
String blockTableIds = settingService.getBlockTableIds(search);
|
||||||
|
if(blockTableIds == null) blockTableIds = "";
|
||||||
|
//String[] blockTableArr = blockTableIds.split("|");
|
||||||
|
for(HashMap<String, Object> item : list) {
|
||||||
|
String tableId = item.get("tableId").toString()+"|";
|
||||||
|
if(!"".equals(blockTableIds) && blockTableIds.contains(tableId)) {
|
||||||
|
mylist.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData.put("list", mylist);
|
||||||
|
responseData.put("blockTableIds", blockTableIds);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/table/save")
|
||||||
|
public ApiResponse blockGameSave(@RequestHeader String token, HttpServletRequest request, @RequestBody BlockGameVO param) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::BLOCK::blockGameSave::"+tokenInfo.getSid()+"::::";
|
||||||
|
param.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "BF::BlockGameVO::"+param);
|
||||||
|
CmnSearch search = new CmnSearch();
|
||||||
|
search.setSiteIdx(param.getSiteIdx());
|
||||||
|
search.setVendorIdx(param.getVendorIdx());
|
||||||
|
|
||||||
|
String vendorTitle = settingService.getVendorTitle(search);
|
||||||
|
if(vendorTitle == null || "".equals(vendorTitle)) {
|
||||||
|
log.error(LOG_PREFIX+ "VendorTitle is not null or empty");
|
||||||
|
apiResponse.setResultCode("99");
|
||||||
|
apiResponse.setResultMessage("VendorTitle is not null or empty");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
param.setVendorTitle(vendorTitle);
|
||||||
|
|
||||||
|
String blockTableIds = settingService.getBlockTableIds(search);
|
||||||
|
if(blockTableIds == null) blockTableIds = "";
|
||||||
|
log.info(LOG_PREFIX +"BF::blockTableIds::" + blockTableIds);
|
||||||
|
|
||||||
|
if(!"".equals(blockTableIds) && blockTableIds.contains(param.getBlockTableId())) {
|
||||||
|
log.info(LOG_PREFIX + param.getBlockTableId() + " is already saved");
|
||||||
|
} else {
|
||||||
|
blockTableIds = blockTableIds + param.getBlockTableId() + "|";
|
||||||
|
log.info(LOG_PREFIX +"AF::blockTableIds::" + blockTableIds);
|
||||||
|
param.setBlockTableIds(blockTableIds);
|
||||||
|
log.info(LOG_PREFIX +"AF::BlockGameVO::" + param);
|
||||||
|
int saveResult = settingService.blockTableIdSave(param);
|
||||||
|
log.info(LOG_PREFIX + "blockTableIdSave result::"+saveResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/table/delete")
|
||||||
|
public ApiResponse blockGameDelete(@RequestHeader String token, HttpServletRequest request, @RequestBody BlockGameVO param) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::BLOCK::blockGameDelete::"+tokenInfo.getSid()+"::::";
|
||||||
|
param.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "BF::BlockGameVO::"+param);
|
||||||
|
CmnSearch search = new CmnSearch();
|
||||||
|
search.setSiteIdx(param.getSiteIdx());
|
||||||
|
search.setVendorIdx(param.getVendorIdx());
|
||||||
|
|
||||||
|
String vendorTitle = settingService.getVendorTitle(search);
|
||||||
|
if(vendorTitle == null || "".equals(vendorTitle)) {
|
||||||
|
log.error(LOG_PREFIX+ "VendorTitle is not null or empty");
|
||||||
|
apiResponse.setResultCode("99");
|
||||||
|
apiResponse.setResultMessage("VendorTitle is not null or empty");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
param.setVendorTitle(vendorTitle);
|
||||||
|
|
||||||
|
String blockTableIds = settingService.getBlockTableIds(search);
|
||||||
|
if(blockTableIds == null) blockTableIds = "";
|
||||||
|
log.info(LOG_PREFIX +"BF::blockTableIds::" + blockTableIds);
|
||||||
|
|
||||||
|
if(!"".equals(blockTableIds) && !blockTableIds.contains(param.getBlockTableId())) {
|
||||||
|
log.info(LOG_PREFIX + param.getBlockTableId() + " is not found");
|
||||||
|
} else {
|
||||||
|
blockTableIds = blockTableIds.replace(param.getBlockTableId() + "|", "");
|
||||||
|
log.info(LOG_PREFIX +"AF::blockTableIds::" + blockTableIds);
|
||||||
|
param.setBlockTableIds(blockTableIds);
|
||||||
|
log.info(LOG_PREFIX +"AF::BlockGameVO::" + param);
|
||||||
|
int saveResult = settingService.blockTableIdSave(param);
|
||||||
|
log.info(LOG_PREFIX + "blockTableIdSave result::"+saveResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/slotVendors")
|
||||||
|
public ApiResponse slotVendors(@RequestHeader String token, HttpServletRequest request) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::BLOCK::slotVendors::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
CmnSearch search = new CmnSearch();
|
||||||
|
search.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
search.setCategory("SLOT");
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
List<HashMap<String, Object>> list = settingService.getBlockVendorSelectBoxList2(search);
|
||||||
|
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/slotGames")
|
||||||
|
public ApiResponse slotGames(@RequestHeader String token, HttpServletRequest request, @RequestBody CmnSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::BLOCK::slotGames::"+tokenInfo.getSid()+"::::";
|
||||||
|
search.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "Request Param::"+search);
|
||||||
|
|
||||||
|
HashMap apiInfo = commonService.getVendorApiInfo(search);
|
||||||
|
log.info(LOG_PREFIX + "API Info::"+apiInfo.toString());
|
||||||
|
// -- grand, svendor, tower, tplus
|
||||||
|
List<GameVo> gameList = null;
|
||||||
|
if("grand".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getGrandGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("svendor".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getSevenGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("pink".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getSevenGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("tplus".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getTplusGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("pracp".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getPracpGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("nexus".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getNexusGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("ace2".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getNexusGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("tower".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getTowerGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else {
|
||||||
|
log.error(LOG_PREFIX + "Not found vendor company");
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData.put("list", gameList);
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/slot-block/gameList")
|
||||||
|
public ApiResponse slotBlockGameList(@RequestHeader String token, HttpServletRequest request, @RequestBody CmnSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::BLOCK::slotGames::"+tokenInfo.getSid()+"::::";
|
||||||
|
search.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "Request Param::"+search);
|
||||||
|
|
||||||
|
HashMap apiInfo = commonService.getVendorApiInfo(search);
|
||||||
|
log.info(LOG_PREFIX + "API Info::"+apiInfo.toString());
|
||||||
|
// -- grand, svendor, tower, tplus
|
||||||
|
List<GameVo> gameList = null;
|
||||||
|
if("grand".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getGrandGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("svendor".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getSevenGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("pink".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getSevenGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("tplus".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getTplusGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("pracp".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getPracpGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("nexus".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getNexusGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("ace2".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getNexusGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else if("tower".equals(apiInfo.get("vendorTitle").toString())) {
|
||||||
|
gameList = commonService.getTowerGameList(LOG_PREFIX, apiInfo);
|
||||||
|
} else {
|
||||||
|
log.error(LOG_PREFIX + "Not found vendor company");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<GameVo> mylist = new ArrayList<>();
|
||||||
|
String blockTableIds = settingService.getBlockTableIds(search);
|
||||||
|
if(blockTableIds == null) blockTableIds = "";
|
||||||
|
//String[] blockTableArr = blockTableIds.split("|");
|
||||||
|
for(GameVo item : gameList) {
|
||||||
|
String tableId = item.getGameId()+"|";
|
||||||
|
if(!"".equals(blockTableIds) && blockTableIds.contains(tableId)) {
|
||||||
|
mylist.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData.put("list", mylist);
|
||||||
|
responseData.put("blockTableIds", blockTableIds);
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/slot-block/save")
|
||||||
|
public ApiResponse SlotBlockSave(@RequestHeader String token, HttpServletRequest request, @RequestBody BlockGameVO param) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::BLOCK::SlotBlockSave::"+tokenInfo.getSid()+"::::";
|
||||||
|
param.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "BF::BlockGameVO::"+param);
|
||||||
|
CmnSearch search = new CmnSearch();
|
||||||
|
search.setSiteIdx(param.getSiteIdx());
|
||||||
|
search.setVendorIdx(param.getVendorIdx());
|
||||||
|
|
||||||
|
String blockTableIds = settingService.getBlockTableIds(search);
|
||||||
|
if(blockTableIds == null) blockTableIds = "";
|
||||||
|
log.info(LOG_PREFIX +"BF::blockTableIds::" + blockTableIds);
|
||||||
|
|
||||||
|
if(!"".equals(blockTableIds) && blockTableIds.contains(param.getBlockTableId())) {
|
||||||
|
log.info(LOG_PREFIX + param.getBlockTableId() + " is already saved");
|
||||||
|
} else {
|
||||||
|
blockTableIds = blockTableIds + param.getBlockTableId() + "|";
|
||||||
|
log.info(LOG_PREFIX +"AF::blockTableIds::" + blockTableIds);
|
||||||
|
param.setBlockTableIds(blockTableIds);
|
||||||
|
log.info(LOG_PREFIX +"AF::BlockGameVO::" + param);
|
||||||
|
int saveResult = settingService.blockTableIdSave(param);
|
||||||
|
log.info(LOG_PREFIX + "blockTableIdSave result::"+saveResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/slot-block/delete")
|
||||||
|
public ApiResponse SlotBlockDelete(@RequestHeader String token, HttpServletRequest request, @RequestBody BlockGameVO param) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::BLOCK::SlotBlockDelete::"+tokenInfo.getSid()+"::::";
|
||||||
|
param.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "BF::BlockGameVO::"+param);
|
||||||
|
CmnSearch search = new CmnSearch();
|
||||||
|
search.setSiteIdx(param.getSiteIdx());
|
||||||
|
search.setVendorIdx(param.getVendorIdx());
|
||||||
|
|
||||||
|
String blockTableIds = settingService.getBlockTableIds(search);
|
||||||
|
if(blockTableIds == null) blockTableIds = "";
|
||||||
|
log.info(LOG_PREFIX +"BF::blockTableIds::" + blockTableIds);
|
||||||
|
|
||||||
|
if(!"".equals(blockTableIds) && !blockTableIds.contains(param.getBlockTableId())) {
|
||||||
|
log.info(LOG_PREFIX + param.getBlockTableId() + " is not found");
|
||||||
|
} else {
|
||||||
|
blockTableIds = blockTableIds.replace(param.getBlockTableId() + "|", "");
|
||||||
|
log.info(LOG_PREFIX +"AF::blockTableIds::" + blockTableIds);
|
||||||
|
param.setBlockTableIds(blockTableIds);
|
||||||
|
log.info(LOG_PREFIX +"AF::BlockGameVO::" + param);
|
||||||
|
int saveResult = settingService.blockTableIdSave(param);
|
||||||
|
log.info(LOG_PREFIX + "blockTableIdSave result::"+saveResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
301
src/main/java/com/bb/api/ApiCallbackSpeedTestController.java
Normal file
301
src/main/java/com/bb/api/ApiCallbackSpeedTestController.java
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
package com.bb.api;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import org.codehaus.jettison.json.JSONArray;
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.bb.jwt.JwtManager;
|
||||||
|
import com.bb.model.ApiResponse;
|
||||||
|
import com.bb.model.CallbackTestResult;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.service.CallBackTestService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.IPKit;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(value = "/api/v1/spdtest")
|
||||||
|
public class ApiCallbackSpeedTestController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CallBackTestService callBackService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final JwtManager jwtManager;
|
||||||
|
|
||||||
|
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
private static final SecureRandom random = new SecureRandom();
|
||||||
|
|
||||||
|
public static List<String> generateRandomStrings(int stringLength, int count) {
|
||||||
|
Set<String> uniqueStrings = new HashSet<>();
|
||||||
|
|
||||||
|
while (uniqueStrings.size() < count) {
|
||||||
|
StringBuilder sb = new StringBuilder(stringLength);
|
||||||
|
for (int i = 0; i < stringLength; i++) {
|
||||||
|
sb.append(CHARACTERS.charAt(random.nextInt(CHARACTERS.length())));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 시간 기반으로 중복 확률 줄이기 (나노타임 일부 추가)
|
||||||
|
sb.append(Long.toHexString(System.nanoTime()).substring(0, 4));
|
||||||
|
|
||||||
|
uniqueStrings.add(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ArrayList<>(uniqueStrings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/testBalance")
|
||||||
|
public ApiResponse testBalance(HttpServletRequest request, @RequestHeader String token, @Valid @RequestParam String memberId) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
log.error("#-API::SPD_TEST::testBalance::Authorization apiKey check");
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("#-API::SPD_TEST::testBalance::site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(token == null || token.equals("")) {
|
||||||
|
log.error("#-API::SPD_TEST::testBalance::Authorization apiKey check");
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization token check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::SPD_TEST::testBalance::"+tokenInfo.getSid()+"::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
List<CallbackTestResult> resultList = new ArrayList<>();
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "callBackService.getTestBalance() START--");
|
||||||
|
JSONObject responseObj = callBackService.getTestBalance(LOG_PREFIX, memberId, token, request.getHeader("Authorization").toString());
|
||||||
|
log.info(LOG_PREFIX+ "callBackService.getTestBalance() END--");
|
||||||
|
|
||||||
|
JSONObject dataObj = responseObj.getJSONObject("data");
|
||||||
|
JSONArray resultArray = dataObj.getJSONArray("resultList");
|
||||||
|
for(int i=0; i<resultArray.length(); i++) {
|
||||||
|
JSONObject item = resultArray.getJSONObject(i);
|
||||||
|
CallbackTestResult result = new CallbackTestResult();
|
||||||
|
result.setIndex(item.getInt("index"));
|
||||||
|
result.setStatus(item.getString("status"));
|
||||||
|
result.setMsg(item.getString("msg"));
|
||||||
|
result.setCallbackUrl(item.getString("callbackUrl"));
|
||||||
|
result.setRequestBody(item.getString("requestBody"));
|
||||||
|
result.setResponseData(item.getString("responseData"));
|
||||||
|
result.setTimeMs(item.getLong("timeMs"));
|
||||||
|
resultList.add(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData.put("resultList", resultList);
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.error("#-API::SPD_TEST::testBalance::"+ e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/testCasino")
|
||||||
|
public ApiResponse testCasino(HttpServletRequest request, @RequestHeader String token, @Valid @RequestParam String memberId) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
log.error("#-API::SPD_TEST::testCasino::Authorization apiKey check");
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("#-API::SPD_TEST::testCasino::site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(token == null || token.equals("")) {
|
||||||
|
log.error("#-API::SPD_TEST::testCasino::Authorization apiKey check");
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization token check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::SPD_TEST::testCasino::"+tokenInfo.getSid()+"::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
List<CallbackTestResult> resultList = new ArrayList<>();
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "callBackService.getTestChangeBalance() START--");
|
||||||
|
JSONObject responseObj = callBackService.getTestChangeBalance(LOG_PREFIX, memberId, token, request.getHeader("Authorization").toString());
|
||||||
|
log.info(LOG_PREFIX+ "callBackService.getTestChangeBalance() END--");
|
||||||
|
|
||||||
|
JSONObject dataObj = responseObj.getJSONObject("data");
|
||||||
|
JSONArray resultArray = dataObj.getJSONArray("resultList");
|
||||||
|
for(int i=0; i<resultArray.length(); i++) {
|
||||||
|
JSONObject item = resultArray.getJSONObject(i);
|
||||||
|
CallbackTestResult result = new CallbackTestResult();
|
||||||
|
result.setIndex(item.getInt("index"));
|
||||||
|
result.setStatus(item.getString("status"));
|
||||||
|
result.setMsg(item.getString("msg"));
|
||||||
|
result.setCallbackUrl(item.getString("callbackUrl"));
|
||||||
|
result.setRequestBody(item.getString("requestBody"));
|
||||||
|
result.setResponseData(item.getString("responseData"));
|
||||||
|
result.setTimeMs(item.getLong("timeMs"));
|
||||||
|
resultList.add(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData.put("resultList", resultList);
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.error("#-API::SPD_TEST::testBalance::"+ e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/testSlot")
|
||||||
|
public ApiResponse testSlot(HttpServletRequest request, @RequestHeader String token, @Valid @RequestParam String memberId) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
log.error("#-API::SPD_TEST::testSlot::Authorization apiKey check");
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("#-API::SPD_TEST::testSlot::site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(token == null || token.equals("")) {
|
||||||
|
log.error("#-API::SPD_TEST::testSlot::Authorization apiKey check");
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization token check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::SPD_TEST::testSlot::"+tokenInfo.getSid()+"::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
List<CallbackTestResult> resultList = new ArrayList<>();
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "callBackService.getTestChangeBalanceSlot() START--");
|
||||||
|
JSONObject responseObj = callBackService.getTestChangeBalanceSlot(LOG_PREFIX, memberId, token, request.getHeader("Authorization").toString());
|
||||||
|
log.info(LOG_PREFIX+ "callBackService.getTestChangeBalanceSlot() END--");
|
||||||
|
|
||||||
|
JSONObject dataObj = responseObj.getJSONObject("data");
|
||||||
|
JSONArray resultArray = dataObj.getJSONArray("resultList");
|
||||||
|
for(int i=0; i<resultArray.length(); i++) {
|
||||||
|
JSONObject item = resultArray.getJSONObject(i);
|
||||||
|
CallbackTestResult result = new CallbackTestResult();
|
||||||
|
result.setIndex(item.getInt("index"));
|
||||||
|
result.setStatus(item.getString("status"));
|
||||||
|
result.setMsg(item.getString("msg"));
|
||||||
|
result.setCallbackUrl(item.getString("callbackUrl"));
|
||||||
|
result.setRequestBody(item.getString("requestBody"));
|
||||||
|
result.setResponseData(item.getString("responseData"));
|
||||||
|
result.setTimeMs(item.getLong("timeMs"));
|
||||||
|
resultList.add(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData.put("resultList", resultList);
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.error("#-API::SPD_TEST::testBalance::"+ e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
1640
src/main/java/com/bb/api/ApiCallbackTestController.java
Normal file
1640
src/main/java/com/bb/api/ApiCallbackTestController.java
Normal file
File diff suppressed because it is too large
Load Diff
635
src/main/java/com/bb/api/ApiCommonController.java
Normal file
635
src/main/java/com/bb/api/ApiCommonController.java
Normal file
@@ -0,0 +1,635 @@
|
|||||||
|
package com.bb.api;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.codehaus.jettison.json.JSONArray;
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClientRequestException;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClientResponseException;
|
||||||
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
|
import com.bb.exception.ApiException;
|
||||||
|
import com.bb.jwt.JwtManager;
|
||||||
|
import com.bb.model.ApiResponse;
|
||||||
|
import com.bb.model.BanGameSearch;
|
||||||
|
import com.bb.model.CmnSearch;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.service.CommonService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.IPKit;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(value = "/api/v1/cmn")
|
||||||
|
public class ApiCommonController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CommonService commonService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WebClient webClient;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final JwtManager jwtManager;
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/code/category")
|
||||||
|
public ApiResponse gameCategoryList(@RequestHeader String token, HttpServletRequest request) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if (site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(site.getSiteIp() == null || "".equals(site.getSiteIp()) || "3.3.3.3".equals(site.getSiteIp())
|
||||||
|
|| site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0)) {
|
||||||
|
log.error("site.getSiteIp(" + site.getSiteIp() + "), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::CMN::gameCategoryList::" + tokenInfo.getSid() + "::::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX);
|
||||||
|
|
||||||
|
List<HashMap<String, String>> list = commonService.getGameCategoryList();
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/code/vendor")
|
||||||
|
public ApiResponse gameVendorList(@RequestHeader String token, HttpServletRequest request,
|
||||||
|
@RequestBody CmnSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if (site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(site.getSiteIp() == null || "".equals(site.getSiteIp()) || "3.3.3.3".equals(site.getSiteIp())
|
||||||
|
|| site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0)) {
|
||||||
|
log.error("site.getSiteIp(" + site.getSiteIp() + "), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::CMN::gameVendorList::" + tokenInfo.getSid() + "::::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX);
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> list = commonService.getGameVendorList(search);
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping("/banGameSet/{vendorTitle}/{vendorIdx}/{skin}")
|
||||||
|
public ApiResponse banGameSetByGet(@RequestHeader String token, HttpServletRequest request,
|
||||||
|
@PathVariable("vendorTitle") String vendorTitle, @PathVariable("vendorIdx") Long vendorIdx,
|
||||||
|
@PathVariable("skin") String skin) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if (site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(site.getSiteIp() == null || "".equals(site.getSiteIp()) || "3.3.3.3".equals(site.getSiteIp())
|
||||||
|
|| site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0)) {
|
||||||
|
log.error("site.getSiteIp(" + site.getSiteIp() + "), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::CMN::banGameSetByGet::" + tokenInfo.getSid() + "::::";
|
||||||
|
|
||||||
|
BanGameSearch search = new BanGameSearch();
|
||||||
|
search.setVendorTitle(vendorTitle);
|
||||||
|
search.setVendorIdx(vendorIdx);
|
||||||
|
search.setSkin(skin);
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "BanGameSearch : " + search.toString());
|
||||||
|
|
||||||
|
if (search.getVendorTitle() == null || "".equals(search.getVendorTitle())) {
|
||||||
|
apiResponse.setResultCode("-1");
|
||||||
|
apiResponse.setResultMessage("vendorTitle is not empty");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> banGameList = commonService.getBanGameList(search);
|
||||||
|
if (banGameList == null || banGameList.size() == 0) {
|
||||||
|
apiResponse.setResultCode("-2");
|
||||||
|
apiResponse.setResultMessage("banGameList empty");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "BanGameSearch : " + banGameList.toString());
|
||||||
|
|
||||||
|
if ("nexus".equals(search.getVendorTitle())) {
|
||||||
|
HashMap<String, Object> apiInfo = banGameList.get(0);
|
||||||
|
String apiBaseUrl = apiInfo.get("apiBaseUrl").toString();
|
||||||
|
String apiAgentId = apiInfo.get("apiAgentId").toString();
|
||||||
|
String apiKey = apiInfo.get("apiSecretKey").toString();
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
|
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||||
|
headers.setAcceptCharset(Arrays.asList(Charset.forName("UTF-8")));
|
||||||
|
|
||||||
|
for (HashMap<String, Object> item : banGameList) {
|
||||||
|
String apiVendorKey = item.get("apiVendorCode").toString();
|
||||||
|
String vendorCetegory = item.get("vendorCetegory").toString();
|
||||||
|
|
||||||
|
JSONObject bodyObj = new JSONObject();
|
||||||
|
bodyObj.put("vendorKey", apiVendorKey);
|
||||||
|
if (vendorCetegory.equals("CASINO")) {
|
||||||
|
if (search.getSkin() == null || search.getSkin().equals(""))
|
||||||
|
search.setSkin("B");
|
||||||
|
bodyObj.put("skin", search.getSkin());
|
||||||
|
} else if (vendorCetegory.equals("SLOT")) {
|
||||||
|
bodyObj.put("skin", "SLOT");
|
||||||
|
bodyObj.put("type", "Slot");
|
||||||
|
search.setSkin("");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
String bodyJson = bodyObj.toString();
|
||||||
|
log.info(LOG_PREFIX + "bodyJson::" + bodyJson);
|
||||||
|
|
||||||
|
String hashCode = getHashCode(LOG_PREFIX, bodyJson, apiKey);
|
||||||
|
headers.set("hash", hashCode);
|
||||||
|
headers.set("agent", apiAgentId);
|
||||||
|
log.info(LOG_PREFIX + "HttpHeaders::" + headers.toString());
|
||||||
|
|
||||||
|
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(apiBaseUrl + "/games");
|
||||||
|
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
||||||
|
params.add("vendorKey", apiVendorKey);
|
||||||
|
if (vendorCetegory.equals("CASINO")) {
|
||||||
|
params.add("skin", search.getSkin());
|
||||||
|
} else if (vendorCetegory.equals("SLOT")) {
|
||||||
|
params.add("skin", "SLOT");
|
||||||
|
params.add("type", "Slot");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
String responseBody = webClient.post().uri(uriBuilder.toUriString())
|
||||||
|
.headers(h -> h.addAll(headers)).bodyValue(params).retrieve()
|
||||||
|
.bodyToMono(String.class).block();
|
||||||
|
|
||||||
|
JSONObject resObj = new JSONObject(responseBody);
|
||||||
|
if (resObj.getInt("code") == 0) {
|
||||||
|
JSONArray games = resObj.getJSONArray("games");
|
||||||
|
int length = games.length();
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
JSONObject objGame = games.getJSONObject(i);
|
||||||
|
JSONObject objName = objGame.getJSONObject("names");
|
||||||
|
|
||||||
|
String gameType = objGame.getString("type");
|
||||||
|
String gameId = objGame.getString("id");
|
||||||
|
String gameKey = objGame.getString("key");
|
||||||
|
String gameTitleEn = objName.getString("en");
|
||||||
|
String gameTitleKo = objName.getString("ko");
|
||||||
|
|
||||||
|
item.put("banGameType", gameType);
|
||||||
|
item.put("banGameId", gameId);
|
||||||
|
item.put("banGameName", gameTitleEn + "||" + gameTitleKo);
|
||||||
|
item.put("banGameNameEng", gameTitleEn);
|
||||||
|
item.put("banGameKey", gameKey);
|
||||||
|
item.put("skin", search.getSkin());
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "item : " + item.toString());
|
||||||
|
int result = commonService.insertBanGameInfo(item);
|
||||||
|
log.info(LOG_PREFIX + "insertBanGameInfo result : " + result);
|
||||||
|
/*
|
||||||
|
* if(apiVendorKey.equals("evolution_casino")) { result =
|
||||||
|
* commonService.insertNexusGameInfo(item); log.info(LOG_PREFIX+
|
||||||
|
* "insertNexusGameInfo result : " + result); }
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
apiResponse.setResultCode("-99");
|
||||||
|
apiResponse.setResultMessage("api fail");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
} catch (WebClientResponseException e) {
|
||||||
|
log.error(LOG_PREFIX + "WebClientResponseException : " + e.getMessage());
|
||||||
|
throw new ApiException("E901", "API call failed");
|
||||||
|
} catch (WebClientRequestException e) {
|
||||||
|
log.error(LOG_PREFIX + "WebClientRequestException : " + e.getMessage());
|
||||||
|
throw new ApiException("E902", "Network error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ("ace2".equals(search.getVendorTitle())) {
|
||||||
|
HashMap<String, Object> apiInfo = banGameList.get(0);
|
||||||
|
String apiBaseUrl = apiInfo.get("apiBaseUrl").toString();
|
||||||
|
String apiAgentId = apiInfo.get("apiAgentId").toString();
|
||||||
|
String apiKey = apiInfo.get("apiSecretKey").toString();
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
|
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||||
|
headers.setAcceptCharset(Arrays.asList(Charset.forName("UTF-8")));
|
||||||
|
|
||||||
|
for (HashMap<String, Object> item : banGameList) {
|
||||||
|
String apiVendorKey = item.get("apiVendorCode").toString();
|
||||||
|
String vendorCetegory = item.get("vendorCetegory").toString();
|
||||||
|
|
||||||
|
JSONObject bodyObj = new JSONObject();
|
||||||
|
bodyObj.put("vendorKey", apiVendorKey);
|
||||||
|
if (vendorCetegory.equals("CASINO")) {
|
||||||
|
if (search.getSkin() == null || search.getSkin().equals(""))
|
||||||
|
search.setSkin("B");
|
||||||
|
bodyObj.put("skin", search.getSkin());
|
||||||
|
} else if (vendorCetegory.equals("SLOT")) {
|
||||||
|
bodyObj.put("skin", "SLOT");
|
||||||
|
bodyObj.put("type", "Slot");
|
||||||
|
search.setSkin("");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
String bodyJson = bodyObj.toString();
|
||||||
|
log.info(LOG_PREFIX + "bodyJson::" + bodyJson);
|
||||||
|
|
||||||
|
String hashCode = getHashCode(LOG_PREFIX, bodyJson, apiKey);
|
||||||
|
headers.set("hash", hashCode);
|
||||||
|
headers.set("agent", apiAgentId);
|
||||||
|
log.info(LOG_PREFIX + "HttpHeaders::" + headers.toString());
|
||||||
|
|
||||||
|
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(apiBaseUrl + "/games");
|
||||||
|
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
||||||
|
params.add("vendorKey", apiVendorKey);
|
||||||
|
if (vendorCetegory.equals("CASINO")) {
|
||||||
|
params.add("skin", search.getSkin());
|
||||||
|
} else if (vendorCetegory.equals("SLOT")) {
|
||||||
|
params.add("skin", "SLOT");
|
||||||
|
params.add("type", "Slot");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
String responseBody = webClient.post().uri(uriBuilder.toUriString())
|
||||||
|
.headers(h -> h.addAll(headers)).bodyValue(params).retrieve()
|
||||||
|
.bodyToMono(String.class).block();
|
||||||
|
|
||||||
|
JSONObject resObj = new JSONObject(responseBody);
|
||||||
|
if (resObj.getInt("code") == 0) {
|
||||||
|
JSONArray games = resObj.getJSONArray("games");
|
||||||
|
int length = games.length();
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
JSONObject objGame = games.getJSONObject(i);
|
||||||
|
JSONObject objName = objGame.getJSONObject("names");
|
||||||
|
|
||||||
|
String gameType = objGame.getString("type");
|
||||||
|
String gameId = objGame.getString("id");
|
||||||
|
String gameKey = objGame.getString("key");
|
||||||
|
String gameTitleEn = objName.getString("en");
|
||||||
|
String gameTitleKo = objName.getString("ko");
|
||||||
|
|
||||||
|
item.put("banGameType", gameType);
|
||||||
|
item.put("banGameId", gameId);
|
||||||
|
item.put("banGameName", gameTitleEn + "||" + gameTitleKo);
|
||||||
|
item.put("banGameNameEng", gameTitleEn);
|
||||||
|
item.put("banGameKey", gameKey);
|
||||||
|
item.put("skin", search.getSkin());
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "item : " + item.toString());
|
||||||
|
int result = commonService.insertBanGameInfo(item);
|
||||||
|
log.info(LOG_PREFIX + "insertBanGameInfo result : " + result);
|
||||||
|
/*
|
||||||
|
* if(apiVendorKey.equals("evolution_casino")) { result =
|
||||||
|
* commonService.insertNexusGameInfo(item); log.info(LOG_PREFIX+
|
||||||
|
* "insertNexusGameInfo result : " + result); }
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
apiResponse.setResultCode("-99");
|
||||||
|
apiResponse.setResultMessage("api fail");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
} catch (WebClientResponseException e) {
|
||||||
|
log.error(LOG_PREFIX + "WebClientResponseException : " + e.getMessage());
|
||||||
|
throw new ApiException("E901", "API call failed");
|
||||||
|
} catch (WebClientRequestException e) {
|
||||||
|
log.error(LOG_PREFIX + "WebClientRequestException : " + e.getMessage());
|
||||||
|
throw new ApiException("E902", "Network error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ("dpcore".equals(search.getVendorTitle())) {
|
||||||
|
HashMap<String, Object> apiInfo = banGameList.get(0);
|
||||||
|
String apiBaseUrl = apiInfo.get("apiBaseUrl").toString();
|
||||||
|
String apiAgentId = apiInfo.get("apiAgentId").toString();
|
||||||
|
String apiKey = "Bearer " + apiInfo.get("apiSecretKey").toString();
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||||
|
headers.set("Authorization", apiKey);
|
||||||
|
String gameUrl = apiBaseUrl + "/api/gameList";
|
||||||
|
|
||||||
|
for (HashMap<String, Object> item : banGameList) {
|
||||||
|
String apiVendorKey = item.get("apiVendorCode").toString();
|
||||||
|
JSONObject prams = new JSONObject();
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "DPCORE::Game List Url: " + gameUrl);
|
||||||
|
log.info(LOG_PREFIX + "DPCORE::Game List Headers: " + headers.toString());
|
||||||
|
|
||||||
|
try {
|
||||||
|
String responseBody = webClient.post().uri(gameUrl).headers(h -> h.addAll(headers))
|
||||||
|
.bodyValue(prams.toString()).retrieve().bodyToMono(String.class).block();
|
||||||
|
|
||||||
|
JSONArray games = new JSONArray(responseBody);
|
||||||
|
int length = games.length();
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
JSONObject objGame = games.getJSONObject(i);
|
||||||
|
String gameType = objGame.getString("gameType");
|
||||||
|
String gameId = objGame.getString("tableId");
|
||||||
|
String gameKey = objGame.getString("tableId");
|
||||||
|
String gameTitleEn = objGame.getString("tableName");
|
||||||
|
String gameTitleKo = objGame.getString("tableName");
|
||||||
|
|
||||||
|
item.put("banGameType", gameType);
|
||||||
|
item.put("banGameId", gameId);
|
||||||
|
item.put("banGameName", gameTitleEn + "||" + gameTitleKo);
|
||||||
|
item.put("banGameNameEng", gameTitleEn);
|
||||||
|
item.put("banGameKey", gameKey);
|
||||||
|
item.put("skin", search.getSkin());
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "item : " + item.toString());
|
||||||
|
int result = commonService.insertBanGameInfo(item);
|
||||||
|
log.info(LOG_PREFIX + "insertBanGameInfo result : " + result);
|
||||||
|
}
|
||||||
|
} catch (WebClientResponseException e) {
|
||||||
|
log.error(LOG_PREFIX + "WebClientResponseException : " + e.getMessage());
|
||||||
|
throw new ApiException("E901", "API call failed");
|
||||||
|
} catch (WebClientRequestException e) {
|
||||||
|
log.error(LOG_PREFIX + "WebClientRequestException : " + e.getMessage());
|
||||||
|
throw new ApiException("E902", "Network error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ("pink".equals(search.getVendorTitle())) {
|
||||||
|
HashMap<String, Object> apiInfo = banGameList.get(0);
|
||||||
|
String apiBaseUrl = apiInfo.get("apiBaseUrl").toString();
|
||||||
|
String apiAgentId = apiInfo.get("apiAgentId").toString();
|
||||||
|
String apiKey = apiInfo.get("apiSecretKey").toString();
|
||||||
|
String apiVendorCode = apiInfo.get("apiVendorCode").toString();
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
|
headers.set("Authorization", apiKey);
|
||||||
|
|
||||||
|
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(apiBaseUrl + "/gamelist");
|
||||||
|
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
||||||
|
params.add("vendor", apiVendorCode);
|
||||||
|
params.add("type", "all");
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "HttpHeaders::" + headers.toString());
|
||||||
|
log.info(LOG_PREFIX + "params::" + params.toString());
|
||||||
|
|
||||||
|
try {
|
||||||
|
String responseBody = webClient.post().uri(uriBuilder.toUriString())
|
||||||
|
.headers(h -> h.addAll(headers)).bodyValue(params).retrieve().bodyToMono(String.class)
|
||||||
|
.block();
|
||||||
|
JSONObject resObj = new JSONObject(responseBody);
|
||||||
|
|
||||||
|
if (resObj.getInt("code") == 0) {
|
||||||
|
log.info(LOG_PREFIX + "gameList::Response::code::" + resObj.getInt("code"));
|
||||||
|
log.info(LOG_PREFIX + "gameList::Response::msg::" + resObj.getString("msg"));
|
||||||
|
JSONArray games = resObj.getJSONArray("data");
|
||||||
|
int length = games.length();
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
JSONObject objGame = games.getJSONObject(i);
|
||||||
|
String gameType = objGame.getString("type");
|
||||||
|
String gameId = objGame.getString("game");
|
||||||
|
String gameKey = objGame.getString("game");
|
||||||
|
String gameTitleEn = objGame.getString("name");
|
||||||
|
String gameTitleKo = objGame.getString("kname");
|
||||||
|
|
||||||
|
apiInfo.put("banGameType", gameType);
|
||||||
|
apiInfo.put("banGameId", gameId);
|
||||||
|
apiInfo.put("banGameName", gameTitleEn + "||" + gameTitleKo);
|
||||||
|
apiInfo.put("banGameNameEng", gameTitleEn);
|
||||||
|
apiInfo.put("banGameKey", gameKey);
|
||||||
|
apiInfo.put("skin", search.getSkin());
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "item : " + apiInfo.toString());
|
||||||
|
int result = commonService.insertBanGameInfo(apiInfo);
|
||||||
|
log.info(LOG_PREFIX + "insertBanGameInfo result : " + result);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
apiResponse.setResultCode("-99");
|
||||||
|
apiResponse.setResultMessage("api fail");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
} catch (WebClientResponseException e) {
|
||||||
|
log.error(LOG_PREFIX + "WebClientResponseException : " + e.getMessage());
|
||||||
|
throw new ApiException("E901", "API call failed");
|
||||||
|
} catch (WebClientRequestException e) {
|
||||||
|
log.error(LOG_PREFIX + "WebClientRequestException : " + e.getMessage());
|
||||||
|
throw new ApiException("E902", "Network error");
|
||||||
|
}
|
||||||
|
} else if ("onix".equals(search.getVendorTitle())) {
|
||||||
|
HashMap<String, Object> apiInfo = banGameList.get(0);
|
||||||
|
String apiBaseUrl = apiInfo.get("apiBaseUrl").toString();
|
||||||
|
String apiAgentId = apiInfo.get("apiAgentId").toString();
|
||||||
|
String apiKey = "Bearer " + apiInfo.get("apiSecretKey").toString();
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||||
|
headers.set("Authorization", apiKey);
|
||||||
|
String gameUrl = apiBaseUrl + "/csapi/Provider";
|
||||||
|
|
||||||
|
for (HashMap<String, Object> item : banGameList) {
|
||||||
|
String apiVendorKey = item.get("apiVendorCode").toString();
|
||||||
|
JSONObject prams = new JSONObject();
|
||||||
|
prams.put("type", "0");
|
||||||
|
prams.put("gameid", "SxCasino");
|
||||||
|
prams.put("code", "evolution");
|
||||||
|
prams.put("gametype", "live");
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "ONIX::Game List Url: " + gameUrl);
|
||||||
|
log.info(LOG_PREFIX + "ONIX::Game List Headers: " + headers.toString());
|
||||||
|
|
||||||
|
try {
|
||||||
|
String responseBody = webClient.post().uri(gameUrl).headers(h -> h.addAll(headers))
|
||||||
|
.bodyValue(prams.toString()).retrieve().bodyToMono(String.class).block();
|
||||||
|
JSONObject resObj = new JSONObject(responseBody);
|
||||||
|
int resultCode = resObj.getInt("result");
|
||||||
|
|
||||||
|
if(resultCode == 1) {
|
||||||
|
JSONArray games = resObj.getJSONArray("data");
|
||||||
|
int length = games.length();
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
JSONObject objGame = games.getJSONObject(i);
|
||||||
|
String gameType = objGame.getString("type");
|
||||||
|
String gameId = objGame.getString("subcode");
|
||||||
|
String gameTitleEn = objGame.getString("name_eng");
|
||||||
|
String gameTitleKo = objGame.getString("name_kor");
|
||||||
|
|
||||||
|
item.put("banGameType", gameType);
|
||||||
|
item.put("banGameId", gameId);
|
||||||
|
item.put("banGameName", gameTitleEn + "||" + gameTitleKo);
|
||||||
|
item.put("banGameNameEng", gameTitleEn);
|
||||||
|
item.put("skin", search.getSkin());
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "item : " + item.toString());
|
||||||
|
int result = commonService.insertBanGameInfo(item);
|
||||||
|
log.info(LOG_PREFIX + "insertBanGameInfo result : " + result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (WebClientResponseException e) {
|
||||||
|
log.error(LOG_PREFIX + "WebClientResponseException : " + e.getMessage());
|
||||||
|
throw new ApiException("E901", "API call failed");
|
||||||
|
} catch (WebClientRequestException e) {
|
||||||
|
log.error(LOG_PREFIX + "WebClientRequestException : " + e.getMessage());
|
||||||
|
throw new ApiException("E902", "Network error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("#-API::CMN::banGameSet::" + e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getHashCode(String LOG_PREFIX, String body, String secretKey) {
|
||||||
|
String hashCode = "";
|
||||||
|
LOG_PREFIX = LOG_PREFIX + "::getHashCode::";
|
||||||
|
try {
|
||||||
|
// Json String Body + Secret Key
|
||||||
|
String result = body + secretKey;
|
||||||
|
// String result =
|
||||||
|
// "{\"username\":\"057007mptest01\",\"nickname\":\"007mptest01\",\"siteUsername\":\"057007mptest01\"}";
|
||||||
|
log.info(LOG_PREFIX + "Body + Secret Key::" + result);
|
||||||
|
// SHA-256 Hash make
|
||||||
|
MessageDigest digestObj = MessageDigest.getInstance("SHA-256");
|
||||||
|
byte[] hash_data = digestObj.digest(result.getBytes("UTF-8"));
|
||||||
|
|
||||||
|
// Base64 encoding
|
||||||
|
hashCode = Base64.getEncoder().encodeToString(hash_data);
|
||||||
|
log.info(LOG_PREFIX + "hashCode::" + hashCode);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("#-NexusService::getHashCode::Exception::" + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
580
src/main/java/com/bb/api/ApiCreditController.java
Normal file
580
src/main/java/com/bb/api/ApiCreditController.java
Normal file
@@ -0,0 +1,580 @@
|
|||||||
|
package com.bb.api;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.bb.jwt.JwtManager;
|
||||||
|
import com.bb.model.ApiResponse;
|
||||||
|
import com.bb.model.Credit;
|
||||||
|
import com.bb.model.CreditPointSearch;
|
||||||
|
import com.bb.model.CreditSearchVO;
|
||||||
|
import com.bb.model.PageFormVO;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.service.CreditService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.IPKit;
|
||||||
|
import com.bb.util.PagingUtil;
|
||||||
|
import com.bb.util.StringUtils;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(value = "/api/v1/credit")
|
||||||
|
public class ApiCreditController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CreditService creditService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final JwtManager jwtManager;
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/list")
|
||||||
|
public ApiResponse creditList(@RequestHeader String token, HttpServletRequest request, @RequestBody CreditSearchVO search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::CREDIT::creditList::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String reqJsonStr = objectMapper.writeValueAsString(search);
|
||||||
|
JSONObject reqObj = new JSONObject(reqJsonStr);
|
||||||
|
log.info(LOG_PREFIX+ "Request {}", reqObj);
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
if(search.getSiteIdx() == null || search.getSiteId() == null || search.getSiteId().equals("")) {
|
||||||
|
search.setSiteId(site.getSiteId());
|
||||||
|
search.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(search.getOrderStr() == null || search.getOrderStr().equals("")) {
|
||||||
|
search.setOrderStr("UPDATE_DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
search.setTransType(search.getTransType().trim());
|
||||||
|
|
||||||
|
if(search.getTransType().equals("AD-AI") || search.getTransType().equals("AD-AO") || search.getTransType().equals("AD")) {
|
||||||
|
// 관리자 지급/회수
|
||||||
|
search.setUpperSiteIdx((long) 2);
|
||||||
|
search.setUpperSiteId("tripleSuper");
|
||||||
|
search.setTargetSiteIdx(search.getSiteIdx());
|
||||||
|
search.setTargetSiteId(search.getSiteId());
|
||||||
|
|
||||||
|
search.setSearchSiteId("");
|
||||||
|
} else if(search.getTransType().equals("UP-AI") || search.getTransType().equals("UP-AO") || search.getTransType().equals("UP")) {
|
||||||
|
// 상부가 지급/회수
|
||||||
|
search.setTargetSiteIdx(search.getSiteIdx());
|
||||||
|
search.setTargetSiteId(search.getSiteId());
|
||||||
|
} else if(search.getTransType().equals("DW-AI") || search.getTransType().equals("DW-AO") || search.getTransType().equals("DW")) {
|
||||||
|
// 하부에 지급/회수
|
||||||
|
search.setUpperSiteIdx(search.getSiteIdx());
|
||||||
|
search.setUpperSiteId(search.getSiteId());
|
||||||
|
} else if(search.getTransType().equals("MAI") || search.getTransType().equals("MAO") || search.getTransType().equals("MAIO")) {
|
||||||
|
// 회원에 충전/환전
|
||||||
|
search.setUpperSiteIdx(search.getSiteIdx());
|
||||||
|
search.setUpperSiteId(search.getSiteId());
|
||||||
|
} else {
|
||||||
|
// 전체 검색
|
||||||
|
search.setUpperSiteIdx(search.getSiteIdx());
|
||||||
|
search.setUpperSiteId(search.getSiteId());
|
||||||
|
search.setTargetSiteIdx(search.getSiteIdx());
|
||||||
|
search.setTargetSiteId(search.getSiteId());
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "CreditSearchVO::"+search.toString());
|
||||||
|
|
||||||
|
int totalCount = creditService.getTransCreditListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(30);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
responseData.put("pageInfo", pageVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> list = creditService.getTransCreditList(search);
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/transaction")
|
||||||
|
public ApiResponse transaction(@RequestHeader String token, HttpServletRequest request, @RequestBody CreditSearchVO search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::CREDIT::transaction::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String reqJsonStr = objectMapper.writeValueAsString(search);
|
||||||
|
JSONObject reqObj = new JSONObject(reqJsonStr);
|
||||||
|
log.info(LOG_PREFIX+ "Request {}", reqObj);
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
if(search.getSiteIdx() == null || search.getSiteId() == null || search.getSiteId().equals("")) {
|
||||||
|
search.setSiteId(site.getSiteId());
|
||||||
|
search.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(search.getOrderStr() == null || search.getOrderStr().equals("")) {
|
||||||
|
search.setOrderStr("UPDATE_DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
search.setTransType(search.getTransType().trim());
|
||||||
|
|
||||||
|
search.setStartDatePartition(StringUtils.convertToDateOnly(search.getStartDate()));
|
||||||
|
search.setEndDatePartition(StringUtils.convertToDateOnly(search.getEndDate()));
|
||||||
|
|
||||||
|
if(search.getTransType().equals("AD-AI") || search.getTransType().equals("AD-AO") || search.getTransType().equals("AD")) {
|
||||||
|
// 관리자 지급/회수
|
||||||
|
search.setUpperSiteIdx((long) 2);
|
||||||
|
search.setUpperSiteId("tripleSuper");
|
||||||
|
search.setTargetSiteIdx(search.getSiteIdx());
|
||||||
|
search.setTargetSiteId(search.getSiteId());
|
||||||
|
|
||||||
|
search.setSearchSiteId("");
|
||||||
|
} else if(search.getTransType().equals("UP-AI") || search.getTransType().equals("UP-AO") || search.getTransType().equals("UP")) {
|
||||||
|
// 상부가 지급/회수
|
||||||
|
search.setTargetSiteIdx(search.getSiteIdx());
|
||||||
|
search.setTargetSiteId(search.getSiteId());
|
||||||
|
} else if(search.getTransType().equals("DW-AI") || search.getTransType().equals("DW-AO") || search.getTransType().equals("DW")) {
|
||||||
|
// 하부에 지급/회수
|
||||||
|
search.setUpperSiteIdx(search.getSiteIdx());
|
||||||
|
search.setUpperSiteId(search.getSiteId());
|
||||||
|
} else if(search.getTransType().equals("MAI") || search.getTransType().equals("MAO") || search.getTransType().equals("MAIO")) {
|
||||||
|
// 회원에 충전/환전
|
||||||
|
search.setUpperSiteIdx(search.getSiteIdx());
|
||||||
|
search.setUpperSiteId(search.getSiteId());
|
||||||
|
} else if(search.getTransType().equals("DP") || search.getTransType().equals("CD") || search.getTransType().equals("CDP")) {
|
||||||
|
// 회원 베팅/결과
|
||||||
|
search.setUpperSiteIdx(search.getSiteIdx());
|
||||||
|
search.setUpperSiteId(search.getSiteId());
|
||||||
|
} else {
|
||||||
|
// 전체 검색
|
||||||
|
search.setUpperSiteIdx(search.getSiteIdx());
|
||||||
|
search.setUpperSiteId(search.getSiteId());
|
||||||
|
search.setTargetSiteIdx(search.getSiteIdx());
|
||||||
|
search.setTargetSiteId(search.getSiteId());
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "CreditSearchVO::"+search.toString());
|
||||||
|
|
||||||
|
int totalCount = creditService.getTotalTransactionListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(30);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
responseData.put("pageInfo", pageVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> list = creditService.getTotalTransactionList(search);
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/addProc")
|
||||||
|
public ApiResponse addProc(@RequestHeader String token, HttpServletRequest request, @RequestBody Credit credit) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map data = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::CREDIT::addProc::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String reqJsonStr = objectMapper.writeValueAsString(credit);
|
||||||
|
JSONObject reqObj = new JSONObject(reqJsonStr);
|
||||||
|
log.info(LOG_PREFIX+ "Request {}", reqObj);
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
if("tripleSuper".equals(site.getSiteId())){
|
||||||
|
apiResponse.setResultCode("9991");
|
||||||
|
apiResponse.setResultMessage("Super admin is not allow");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if("AI".equals(credit.getCreditType())) {
|
||||||
|
// 관리자 or 상부 직접 지급
|
||||||
|
long siteCredit = siteService.getSiteCredit(tokenInfo.getSid());
|
||||||
|
if(siteCredit < credit.getCreditAmt()) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("크레딧이 모자릅니다");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(credit.getTargetSiteId() == null || credit.getTargetSiteId().equals("")) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("대상이 존재하지 않습니다");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
credit.setInOut("IN");
|
||||||
|
credit.setCreditStatus(1);
|
||||||
|
credit.setSiteIdx(site.getSiteIdx());
|
||||||
|
credit.setSiteId(site.getSiteId());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else if("AO".equals(credit.getCreditType())) {
|
||||||
|
// 관리자 or 상부 직접환급
|
||||||
|
|
||||||
|
if(credit.getTargetSiteId() == null || credit.getTargetSiteId().equals("")) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("대상이 존재하지 않습니다");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
long targetSiteCredit = siteService.getSiteCredit(credit.getTargetSiteId());
|
||||||
|
if(targetSiteCredit < credit.getCreditAmt()) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("해당 에이젼시의 크레딧이 모자릅니다");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
credit.setInOut("OUT");
|
||||||
|
credit.setCreditStatus(1);
|
||||||
|
credit.setSiteIdx(site.getSiteIdx());
|
||||||
|
credit.setSiteId(site.getSiteId());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("알 수 없는 요청");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "Credit::AF::"+credit.toString());
|
||||||
|
|
||||||
|
int result = creditService.insertCredit(credit);
|
||||||
|
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "insertCredit result::"+result);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.error(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(data);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/pointList")
|
||||||
|
public ApiResponse pointList(@RequestHeader String token, HttpServletRequest request, @Valid @RequestBody CreditPointSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::TRANS::betlist::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
|
||||||
|
PageFormVO pageVo = new PageFormVO();
|
||||||
|
search.setSearchSiteId(site.getSiteId());
|
||||||
|
search.setSearchSiteIdx((long) site.getSiteIdx());
|
||||||
|
search.setStartDate(search.getStartDate()+".000");
|
||||||
|
search.setEndDate(search.getEndDate()+".999");
|
||||||
|
|
||||||
|
if(search.getOrderStr() == null || search.getOrderStr().equals("")) {
|
||||||
|
search.setOrderStr("BETDATE_DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "CreditPointSearch::"+search.toString());
|
||||||
|
|
||||||
|
int totalCount = creditService.getCreditPointListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(30);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
responseData.put("pageInfo", pageVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap<String, String>> list = creditService.getCreditPointList(search);
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/betList")
|
||||||
|
public ApiResponse betList(@RequestHeader String token, HttpServletRequest request, @Valid @RequestBody CreditPointSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::TRANS::betlist::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
|
||||||
|
PageFormVO pageVo = new PageFormVO();
|
||||||
|
search.setSearchSiteId(site.getSiteId());
|
||||||
|
search.setSearchSiteIdx((long) site.getSiteIdx());
|
||||||
|
search.setStartDate(search.getStartDate()+".000");
|
||||||
|
search.setEndDate(search.getEndDate()+".999");
|
||||||
|
|
||||||
|
if(search.getOrderStr() == null || search.getOrderStr().equals("")) {
|
||||||
|
search.setOrderStr("BETDATE_DESC");
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "CreditPointSearch::"+search.toString());
|
||||||
|
|
||||||
|
search.setStartDatePartition(StringUtils.convertToDateOnly(search.getStartDate()));
|
||||||
|
search.setEndDatePartition(StringUtils.convertToDateOnly(search.getEndDate()));
|
||||||
|
|
||||||
|
int totalCount = creditService.getCreditBetListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(30);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
responseData.put("pageInfo", pageVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap<String, String>> list = creditService.getCreditBetList(search);
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
382
src/main/java/com/bb/api/ApiMainController.java
Normal file
382
src/main/java/com/bb/api/ApiMainController.java
Normal file
@@ -0,0 +1,382 @@
|
|||||||
|
package com.bb.api;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.bb.jwt.JwtClame;
|
||||||
|
import com.bb.jwt.JwtManager;
|
||||||
|
import com.bb.model.ApiResponse;
|
||||||
|
import com.bb.model.BoardSearch;
|
||||||
|
import com.bb.model.PageFormVO;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.service.StatService;
|
||||||
|
import com.bb.util.IPKit;
|
||||||
|
import com.bb.util.PagingUtil;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(value = "/api/v1")
|
||||||
|
public class ApiMainController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final JwtManager jwtManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
StatService statService;
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping(value="/login")
|
||||||
|
public ApiResponse agentBalance(HttpServletRequest request, @RequestBody JSONObject requestBody) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
final String LOG_PREFIX = "#-NSOFT::LOGIN::"+requestBody.getString("apiId")+":::";
|
||||||
|
try {
|
||||||
|
// apiKey 체크
|
||||||
|
log.info(LOG_PREFIX+ "Request Body: "+requestBody.toString());
|
||||||
|
String agentId = requestBody.getString("apiId");
|
||||||
|
if(agentId != null && "tripleSuper".equals(agentId)){
|
||||||
|
apiResponse.setResultCode("9991");
|
||||||
|
apiResponse.setResultMessage("Super admin login is not allow");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if("".equals(agentId)) {
|
||||||
|
apiResponse.setResultCode("9998");
|
||||||
|
apiResponse.setResultMessage("apiId is not null");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
String agentPwd = requestBody.getString("apiPwd");
|
||||||
|
if("".equals(agentPwd)) {
|
||||||
|
apiResponse.setResultCode("9998");
|
||||||
|
apiResponse.setResultMessage("agentPwd is not null");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
Map loginParam = new HashMap();
|
||||||
|
loginParam.put("siteId", agentId);
|
||||||
|
loginParam.put("sitePwd", agentPwd);
|
||||||
|
|
||||||
|
Site siteLogin = siteService.getSiteLoginApi(loginParam);
|
||||||
|
if(siteLogin == null) {
|
||||||
|
apiResponse.setResultCode("9997");
|
||||||
|
apiResponse.setResultMessage("agent info check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(siteLogin.getIps() +","+IPKit.getIpAddressByRequest(request) );
|
||||||
|
if( !( siteLogin.getIps() == null || "".equals(siteLogin.getIps()) || "3.3.3.3".equals(siteLogin.getIps()) || siteLogin.getIps().indexOf(IPKit.getIpAddressByRequest(request)) >= 0 ) ) {
|
||||||
|
log.error("#API::LOGIN::"+siteLogin.getSiteId() +"::siteLogin.getIps("+siteLogin.getIps()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
apiResponse.setResultMessage("access denied IP");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
JwtClame jwtinfo = new JwtClame();
|
||||||
|
jwtinfo.setSiteId(siteLogin.getSiteId());
|
||||||
|
String token = jwtManager.generateTokenAdmin(jwtinfo);
|
||||||
|
String refresh_token = jwtManager.generateTokenRefresh(jwtinfo);
|
||||||
|
|
||||||
|
Map data = new HashMap();
|
||||||
|
data.put("siteKey", siteLogin.getSiteKey());
|
||||||
|
data.put("token", token);
|
||||||
|
data.put("refresh_token", refresh_token);
|
||||||
|
data.put("isTransfer", siteLogin.getIsTransfer());
|
||||||
|
data.put("useParseStatMenu", siteLogin.getUseParseStatMenu());
|
||||||
|
log.info("#API::LOGIN::data::" + data.toString());
|
||||||
|
|
||||||
|
apiResponse.setData(data);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping(value="/myCredit")
|
||||||
|
public ApiResponse myCredit(@RequestHeader String token, HttpServletRequest request) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
try {
|
||||||
|
log.info(token.toString());
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( !( site.getSiteIp() == null || "".equals(site.getSiteIp()) || "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0 ) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
apiResponse.setResultMessage("access denied IP");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
//토큰체크
|
||||||
|
Map data = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
|
||||||
|
log.info(tokenInfo.getSid());
|
||||||
|
long siteCredit = siteService.getSiteCredit(tokenInfo.getSid());
|
||||||
|
long sitePoint = siteService.getSitePoint(tokenInfo.getSid());
|
||||||
|
data.put("credit", siteCredit);
|
||||||
|
data.put("point", sitePoint);
|
||||||
|
data.put("siteLevel", site.getSiteLevel());
|
||||||
|
if(site.getSiteLevel() == 1) {
|
||||||
|
HashMap creditInfo = siteService.getSiteSubCredit(tokenInfo.getSid());
|
||||||
|
data.put("subCreditInfo", creditInfo);
|
||||||
|
} else {
|
||||||
|
data.put("subCreditInfo", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(data);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping(value="/myBetInfo")
|
||||||
|
public ApiResponse myBetInfo(@RequestHeader String token, HttpServletRequest request, @RequestBody JSONObject param) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
try {
|
||||||
|
log.info(token.toString());
|
||||||
|
String authorization = request.getHeader("Authorization").toString();
|
||||||
|
log.info("#-myBetInfo::Authorization::"+authorization);
|
||||||
|
log.info("#-myBetInfo::param::"+param);
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp() == null || "".equals(site.getSiteIp()) || "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0 ) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
apiResponse.setResultMessage("access denied IP");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map data = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
|
||||||
|
log.info("#-myBetInfo::site::"+tokenInfo.getSid());
|
||||||
|
|
||||||
|
SiteSearch search = new SiteSearch();
|
||||||
|
search.setSiteIdx(site.getSiteIdx());
|
||||||
|
search.setStartDate(param.getString("targetDate"));
|
||||||
|
log.info("#-myBetInfo::search::"+search);
|
||||||
|
List<HashMap> stat = statService.getDashBoardList(search) ;
|
||||||
|
data.put("info", stat);
|
||||||
|
|
||||||
|
List<HashMap> statM = statService.getDashBoardMonth(search) ;
|
||||||
|
data.put("infoM", statM);
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(data);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("#-myBetInfo::Exception::"+ e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/board/list")
|
||||||
|
public ApiResponse boardList(@RequestHeader String token, HttpServletRequest request, @RequestBody BoardSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::MAIN::boardList::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
search.setSiteIdx(site.getSiteIdx());
|
||||||
|
search.setSiteId(tokenInfo.getSid());
|
||||||
|
log.info(LOG_PREFIX + "BoardSearch::"+search);
|
||||||
|
|
||||||
|
if(search.getViewType() == null || search.getViewType().equals("")) {
|
||||||
|
search.setViewType("main");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(search.getBoardType() == null || search.getBoardType().equals("")) {
|
||||||
|
search.setBoardType("notice");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(search.getViewType().equals("main")) {
|
||||||
|
List<HashMap<String, Object>> list = siteService.getBoardList(search);
|
||||||
|
responseData.put("boardList", list);
|
||||||
|
} else {
|
||||||
|
PageFormVO pageVo = new PageFormVO();
|
||||||
|
int totalCount = siteService.getBoardListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(30);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
responseData.put("pageInfo", pageVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> list = siteService.getBoardList(search);
|
||||||
|
responseData.put("boardList", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping("/board/{boardIdx}")
|
||||||
|
public ApiResponse boardList(@RequestHeader String token, HttpServletRequest request, @PathVariable long boardIdx) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::MAIN::boardList::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "BoardIdx::"+boardIdx);
|
||||||
|
|
||||||
|
HashMap<String, Object> detail = siteService.getBoardDetail(boardIdx);
|
||||||
|
responseData.put("boardDetail", detail);
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
407
src/main/java/com/bb/api/ApiSettingController.java
Normal file
407
src/main/java/com/bb/api/ApiSettingController.java
Normal file
@@ -0,0 +1,407 @@
|
|||||||
|
package com.bb.api;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.codehaus.jettison.json.JSONArray;
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.bb.jwt.JwtManager;
|
||||||
|
import com.bb.model.ApiResponse;
|
||||||
|
import com.bb.model.CmnSearch;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SiteVendorSkinVO;
|
||||||
|
import com.bb.service.BetRadarService;
|
||||||
|
import com.bb.service.SettingService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.IPKit;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(value = "/api/v1/setting")
|
||||||
|
public class ApiSettingController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SettingService settingService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
BetRadarService betRadarService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final JwtManager jwtManager;
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/vendor")
|
||||||
|
public ApiResponse settingVendorList(@RequestHeader String token, HttpServletRequest request, @RequestBody CmnSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::SETTING::settingVendorList::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// POJO to JSON
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String reqJsonStr = objectMapper.writeValueAsString(search);
|
||||||
|
JSONObject reqObj = new JSONObject(reqJsonStr);
|
||||||
|
log.info(LOG_PREFIX+ "Request {}", reqObj);
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
if(search.getSiteIdx() == null || search.getSiteIdx() == 0) {
|
||||||
|
search.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
search.setSiteId(tokenInfo.getSid());
|
||||||
|
}
|
||||||
|
log.info(LOG_PREFIX + "CmnSearch::"+search.toString());
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> list = settingService.getSettingVendorList(search);
|
||||||
|
for(HashMap<String, Object> item : list) {
|
||||||
|
Long vendorIdx = (Long) item.get("vendorIdx");
|
||||||
|
String vendorTitle = item.get("vendorTitle").toString();
|
||||||
|
search.setVendorIdx(vendorIdx);
|
||||||
|
search.setVendorTitle(vendorTitle);
|
||||||
|
List<HashMap<String, Object>> skinList = settingService.getSettingSkinList(search);
|
||||||
|
item.put("skinList", skinList);
|
||||||
|
}
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/skin")
|
||||||
|
public ApiResponse settingSkinList(@RequestHeader String token, HttpServletRequest request, @RequestBody CmnSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::SETTING::settingSkinList::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// POJO to JSON
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String reqJsonStr = objectMapper.writeValueAsString(search);
|
||||||
|
JSONObject reqObj = new JSONObject(reqJsonStr);
|
||||||
|
log.info(LOG_PREFIX+ "Request {}", reqObj);
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "CmnSearch::"+search.toString());
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> list = settingService.getSettingSkinList(search);
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/vendor/save")
|
||||||
|
public ApiResponse settingVendorSave(@RequestHeader String token, HttpServletRequest request, @RequestBody List<SiteVendorSkinVO> param) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::SETTING::settingSkinList::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// POJO to JSON
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String reqJsonStr = objectMapper.writeValueAsString(param);
|
||||||
|
JSONArray reqObj = new JSONArray(reqJsonStr);
|
||||||
|
log.info(LOG_PREFIX+ "Request {}", reqObj);
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
log.info(LOG_PREFIX + "List<SiteVendorSkinVO>::"+param.toString());
|
||||||
|
|
||||||
|
for(SiteVendorSkinVO item : param) {
|
||||||
|
if(!item.getCategory().equals("CASINO") && !item.getCategory().equals("HCASINO")) {
|
||||||
|
item.setSkinType("A");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (item.getSkinType()) {
|
||||||
|
case "A": item.setNexusSkinType("A");
|
||||||
|
item.setExtrSkinType("1");
|
||||||
|
break;
|
||||||
|
case "B": item.setNexusSkinType("B");
|
||||||
|
item.setExtrSkinType("2");
|
||||||
|
break;
|
||||||
|
case "C": item.setNexusSkinType("C");
|
||||||
|
item.setExtrSkinType("3");
|
||||||
|
break;
|
||||||
|
case "D": item.setNexusSkinType("D");
|
||||||
|
item.setExtrSkinType("4");
|
||||||
|
break;
|
||||||
|
case "E": item.setNexusSkinType("E");
|
||||||
|
item.setExtrSkinType("5");
|
||||||
|
break;
|
||||||
|
case "F": item.setNexusSkinType("E");
|
||||||
|
item.setExtrSkinType("6");
|
||||||
|
break;
|
||||||
|
case "G": item.setNexusSkinType("E");
|
||||||
|
item.setExtrSkinType("7");
|
||||||
|
break;
|
||||||
|
case "H": item.setNexusSkinType("E");
|
||||||
|
item.setExtrSkinType("8");
|
||||||
|
break;
|
||||||
|
case "I": item.setNexusSkinType("E");
|
||||||
|
item.setExtrSkinType("9");
|
||||||
|
break;
|
||||||
|
case "J": item.setNexusSkinType("E");
|
||||||
|
item.setExtrSkinType("10");
|
||||||
|
break;
|
||||||
|
default: item.setNexusSkinType("A");
|
||||||
|
item.setExtrSkinType("1");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int saveResult = settingService.settingVendorSkinSave(item);
|
||||||
|
log.info(LOG_PREFIX + "vendorIdx::"+item.getVendorIdx()+"::saveResult::"+saveResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/whiteIp")
|
||||||
|
public ApiResponse whiteIpList(@RequestHeader String token, HttpServletRequest request, @RequestBody CmnSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::SETTING::whiteIpList::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// POJO to JSON
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String reqJsonStr = objectMapper.writeValueAsString(search);
|
||||||
|
JSONObject reqObj = new JSONObject(reqJsonStr);
|
||||||
|
log.info(LOG_PREFIX+ "Request {}", reqObj);
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
if(search.getSiteIdx() == null || search.getSiteIdx() == 0) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("대상이 존재하지 않습니다");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
log.info(LOG_PREFIX + "CmnSearch::"+search.toString());
|
||||||
|
|
||||||
|
List<String> list = settingService.getWhiteIpList(search);
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/getSportsSetting")
|
||||||
|
public ApiResponse getSportsSetting(@RequestHeader String token, HttpServletRequest request) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::SETTING::getSportsSetting::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
HashMap<String, String> apiInfo = settingService.getBetRadarApiInfo(tokenInfo.getSid());
|
||||||
|
if(apiInfo == null || apiInfo.get("apiKey") == null) {
|
||||||
|
apiResponse.setResultCode("8888");
|
||||||
|
apiResponse.setResultMessage("Not found 'BetRadar' settings..");
|
||||||
|
log.info(LOG_PREFIX+ "Not found 'BetRadar' settings..");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
log.info(LOG_PREFIX + "ApiInfo::"+apiInfo.toString());
|
||||||
|
|
||||||
|
String url = betRadarService.getSportsSetting(LOG_PREFIX, apiInfo);
|
||||||
|
responseData.put("url", url);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.info("#-API::SETTING::getSportsSetting::"+ e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("#-API::SETTING::getSportsSetting::"+ e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
1058
src/main/java/com/bb/api/ApiStatController.java
Normal file
1058
src/main/java/com/bb/api/ApiStatController.java
Normal file
File diff suppressed because it is too large
Load Diff
1710
src/main/java/com/bb/api/ApiTransController.java
Normal file
1710
src/main/java/com/bb/api/ApiTransController.java
Normal file
File diff suppressed because it is too large
Load Diff
389
src/main/java/com/bb/api/ApiUserController.java
Normal file
389
src/main/java/com/bb/api/ApiUserController.java
Normal file
@@ -0,0 +1,389 @@
|
|||||||
|
package com.bb.api;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.bb.jwt.JwtManager;
|
||||||
|
import com.bb.model.ApiResponse;
|
||||||
|
import com.bb.model.CashParam;
|
||||||
|
import com.bb.model.Credit;
|
||||||
|
import com.bb.model.Member;
|
||||||
|
import com.bb.model.PageFormVO;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.UserSearch;
|
||||||
|
import com.bb.service.CreditService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.service.StatService;
|
||||||
|
import com.bb.util.IPKit;
|
||||||
|
import com.bb.util.PagingUtil;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping(value = "/api/v1/user")
|
||||||
|
public class ApiUserController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
StatService statService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CreditService creditService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final JwtManager jwtManager;
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/list")
|
||||||
|
public ApiResponse userList(@RequestHeader String token, HttpServletRequest request, @Valid @RequestBody UserSearch search) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::USER::userList::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
|
||||||
|
PageFormVO pageVo= new PageFormVO();
|
||||||
|
search.setSiteId(site.getSiteId());
|
||||||
|
search.setSiteIdx((long) site.getSiteIdx());
|
||||||
|
search.setTopId(tokenInfo.getSid());
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "UserSearch::"+search.toString());
|
||||||
|
|
||||||
|
int totalCount = siteService.getUserListCnt(search);
|
||||||
|
if (totalCount != 0) {
|
||||||
|
PageFormVO commonForm = new PageFormVO();
|
||||||
|
commonForm.setFunction_name("goPage");
|
||||||
|
commonForm.setPage(search.getPage());
|
||||||
|
commonForm.setCount_per_page(20);
|
||||||
|
if(search.getCount_per_list()==0) {
|
||||||
|
commonForm.setCount_per_list(30);
|
||||||
|
} else {
|
||||||
|
commonForm.setCount_per_list(search.getCount_per_list());
|
||||||
|
}
|
||||||
|
commonForm.setTatal_list_count(totalCount);
|
||||||
|
pageVo = PagingUtil.setPageUtil(commonForm);
|
||||||
|
search.setLimit(pageVo.getLimit());
|
||||||
|
search.setOffset(pageVo.getOffset());
|
||||||
|
search.setTatal_list_count(totalCount);
|
||||||
|
|
||||||
|
responseData.put("pageInfo", pageVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> list = siteService.getUserList(search);
|
||||||
|
responseData.put("list", list);
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping("/detail/{siteIdx}/{memberIdx}")
|
||||||
|
public ApiResponse userDetail( @RequestHeader String token, HttpServletRequest request, @PathVariable long siteIdx, @PathVariable long memberIdx) throws Exception {
|
||||||
|
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
try {
|
||||||
|
log.info(token.toString());
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( !( site.getSiteIp() == null || "".equals(site.getSiteIp()) || "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0 ) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
apiResponse.setResultMessage("access denied IP");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map responseData = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::USER::userDetail::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
UserSearch search = new UserSearch();
|
||||||
|
search.setSiteIdx(siteIdx);
|
||||||
|
search.setMemberIdx(memberIdx);
|
||||||
|
search.setTopId(tokenInfo.getSid());
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "UserSearch::"+search.toString());
|
||||||
|
|
||||||
|
HashMap<String, Object> targetUser = siteService.getUserDetail(search);
|
||||||
|
responseData.put("targetUser", targetUser); // 유저 상세정보
|
||||||
|
|
||||||
|
boolean isMyAgent = false;
|
||||||
|
List<HashMap> treeInfo = (List<HashMap>) targetUser.get("treeInfo");
|
||||||
|
for(HashMap item : treeInfo) {
|
||||||
|
if(tokenInfo.getSid().equals(item.get("upperSiteId").toString())) {
|
||||||
|
isMyAgent = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!isMyAgent) {
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO : 에이전트 상세 베팅통계 데이터
|
||||||
|
// TODO : 에이전트 상세 베팅통계 데이터
|
||||||
|
HashMap ydayBetInfo = statService.getYdayBetInfoByUser(targetUser);
|
||||||
|
log.info(LOG_PREFIX+ "ydayBetInfo {}", ydayBetInfo);
|
||||||
|
HashMap monthBetInfo = statService.getMonthBetInfoByUser(targetUser);
|
||||||
|
log.info(LOG_PREFIX+ "monthBetInfo {}", monthBetInfo);
|
||||||
|
responseData.put("ydayBetInfo", ydayBetInfo); // 어제 배팅통계
|
||||||
|
responseData.put("monthBetInfo", monthBetInfo); // 이번달 배팅통계
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.setData(responseData);
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/cashInOut")
|
||||||
|
public ApiResponse cashInOut(@RequestHeader String token, HttpServletRequest request, @RequestBody CashParam param) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Site site = siteService.getSiteInfoAPI(request);
|
||||||
|
if(site == null) {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("Authorization apiKey check");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( site.getSiteIp()==null || "".equals(site.getSiteIp())
|
||||||
|
|| "3.3.3.3".equals(site.getSiteIp()) || site.getSiteIp().indexOf(IPKit.getIpAddressByRequest(request)) >= 0) ) {
|
||||||
|
log.error("site.getSiteIp("+site.getSiteIp()+"), denied" + IPKit.getIpAddressByRequest(request));
|
||||||
|
apiResponse.setResultCode("10001");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO DO 토큰체크
|
||||||
|
Map data = new HashMap();
|
||||||
|
|
||||||
|
try {
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfoAdmin(token);
|
||||||
|
final String LOG_PREFIX = "#-API::CASH::cashInOut::"+tokenInfo.getSid()+"::::";
|
||||||
|
|
||||||
|
// 여기서 부터 로직
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String reqJsonStr = objectMapper.writeValueAsString(param);
|
||||||
|
JSONObject reqObj = new JSONObject(reqJsonStr);
|
||||||
|
log.info(LOG_PREFIX+ "Request {}", reqObj);
|
||||||
|
|
||||||
|
if("tripleSuper".equals(site.getSiteId())){
|
||||||
|
apiResponse.setResultCode("9991");
|
||||||
|
apiResponse.setResultMessage("Super admin is not allow");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if("N".equals(site.getIsTransfer())) {
|
||||||
|
apiResponse.setResultCode("9992");
|
||||||
|
apiResponse.setResultMessage("NOT_TRANSFER_SITE");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
//회원정보
|
||||||
|
param.setSiteIdx(site.getSiteIdx());
|
||||||
|
Member member = siteService.getMember2(param);
|
||||||
|
if(member == null) {
|
||||||
|
// Fail
|
||||||
|
log.error(LOG_PREFIX+ "9993:NOT_FOUND_USER");
|
||||||
|
apiResponse.setResultCode("9993");
|
||||||
|
apiResponse.setResultMessage("NOT_FOUND_USER");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
log.info(LOG_PREFIX+ "Member::"+member.toString());
|
||||||
|
|
||||||
|
long amount = Long.parseLong(param.getAmount());
|
||||||
|
|
||||||
|
// Insert credit_info : MAI, IN / MAO, OUT
|
||||||
|
Credit credit = new Credit();
|
||||||
|
credit.setSiteIdx(site.getSiteIdx());
|
||||||
|
credit.setSiteId(site.getSiteId());
|
||||||
|
credit.setTargetSiteIdx(member.getMemberIdx());
|
||||||
|
credit.setTargetSiteId(member.getMemberId());
|
||||||
|
credit.setCreditType(param.getCreditType());
|
||||||
|
if("MAI".equals(credit.getCreditType())) {
|
||||||
|
// 관리자 > 회원 보유금 지급
|
||||||
|
long siteCredit = site.getCredit();
|
||||||
|
if(siteCredit < amount) {
|
||||||
|
log.error(LOG_PREFIX+ "9994:사이트 크레딧 부족");
|
||||||
|
apiResponse.setResultCode("9994");
|
||||||
|
apiResponse.setResultMessage("사이트 크레딧 부족");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
credit.setCreditRate(null);
|
||||||
|
credit.setInOut("IN");
|
||||||
|
credit.setTranId("회원 보유금 지급");
|
||||||
|
credit.setCreditAmt(Long.parseLong(param.getAmount()));
|
||||||
|
credit.setUserAmt(Long.parseLong(param.getAmount()));
|
||||||
|
credit.setCreditStatus(1);
|
||||||
|
credit.setWaitTime(-5); // 재요청 대기시간 5초
|
||||||
|
credit.setPreBalance(member.getUserBalance());
|
||||||
|
int cnt = creditService.checkRequestTime(credit);
|
||||||
|
if(cnt > 0) {
|
||||||
|
// Fail
|
||||||
|
log.error(LOG_PREFIX+ "T1005:재요청 대기시간 5초");
|
||||||
|
apiResponse.setResultCode("T1005");
|
||||||
|
apiResponse.setResultMessage("재요청 대기시간 5초");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "Credit::"+credit.toString());
|
||||||
|
int result = creditService.insertCreditByCash(credit);
|
||||||
|
log.info(LOG_PREFIX+ "insertCredit result::"+result);
|
||||||
|
if(result < 0) {
|
||||||
|
// Fail
|
||||||
|
log.error(LOG_PREFIX+ "T1009:DEPOSIT_FAIL");
|
||||||
|
apiResponse.setResultCode("T1009");
|
||||||
|
apiResponse.setResultMessage("DEPOSIT_FAIL");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if("MAO".equals(credit.getCreditType())) {
|
||||||
|
// 관리자 < 회원 보유금 회수
|
||||||
|
long userBalance = member.getUserBalance();
|
||||||
|
if(param.getWithAll() != null && param.getWithAll().equals("Y")) {
|
||||||
|
amount = userBalance;
|
||||||
|
param.setAmount(Long.toString(amount));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(userBalance < amount) {
|
||||||
|
log.error(LOG_PREFIX+ "9995:유저 잔액 부족");
|
||||||
|
apiResponse.setResultCode("9995");
|
||||||
|
apiResponse.setResultMessage("유저 잔액 부족");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
credit.setCreditRate(null);
|
||||||
|
credit.setInOut("OUT");
|
||||||
|
credit.setTranId("회원 보유금 회수");
|
||||||
|
credit.setCreditAmt(Long.parseLong(param.getAmount()));
|
||||||
|
credit.setUserAmt(Long.parseLong(param.getAmount()));
|
||||||
|
credit.setCreditStatus(1);
|
||||||
|
credit.setWaitTime(-5); // 재요청 대기시간 5초
|
||||||
|
credit.setPreBalance(member.getUserBalance());
|
||||||
|
int cnt = creditService.checkRequestTime(credit);
|
||||||
|
if(cnt > 0) {
|
||||||
|
// Fail
|
||||||
|
log.error(LOG_PREFIX+ "T1005:재요청 대기시간 5초");
|
||||||
|
apiResponse.setResultCode("T1005");
|
||||||
|
apiResponse.setResultMessage("재요청 대기시간 5초");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "Credit::"+credit.toString());
|
||||||
|
int result = creditService.insertCreditByCash(credit);
|
||||||
|
log.info(LOG_PREFIX+ "insertCredit result::"+result);
|
||||||
|
if(result < 0) {
|
||||||
|
// Fail
|
||||||
|
log.error(LOG_PREFIX+ "T1009:WITHDRAW_FAIL");
|
||||||
|
apiResponse.setResultCode("T1009");
|
||||||
|
apiResponse.setResultMessage("WITHDRAW_FAIL");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
apiResponse.setResultCode("9999");
|
||||||
|
apiResponse.setResultMessage("알 수 없는 요청");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.error(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.setResultCode("99995");
|
||||||
|
apiResponse.setResultMessage("token is no valid");
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
62
src/main/java/com/bb/common/bean/RedisSession.java
Normal file
62
src/main/java/com/bb/common/bean/RedisSession.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package com.bb.common.bean;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
|
||||||
|
//import org.springframework.data.redis.core.ValueOperations;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.bb.common.model.OutLoginVO;
|
||||||
|
import com.bb.util.TempKey;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//@Component
|
||||||
|
/*
|
||||||
|
public class RedisSession {
|
||||||
|
|
||||||
|
@Resource(name="redisTemplate")
|
||||||
|
private ValueOperations<String, String> tokens;
|
||||||
|
private Gson gson = new Gson();
|
||||||
|
|
||||||
|
public String getToken(OutLoginVO outLoginVO) {
|
||||||
|
TempKey tempKey = new TempKey();
|
||||||
|
String newToken = tempKey.getKey(300);
|
||||||
|
String oldToken = getCheckId(outLoginVO);
|
||||||
|
String token = null;
|
||||||
|
if(oldToken == null) {
|
||||||
|
token = newToken;
|
||||||
|
}else {
|
||||||
|
token = oldToken;
|
||||||
|
}
|
||||||
|
setToken(token, outLoginVO);
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCheckId(OutLoginVO outLoginVO) {
|
||||||
|
String oldToken = (String) tokens.get(outLoginVO.getId()+outLoginVO.getDomain());
|
||||||
|
return oldToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setToken(String token, OutLoginVO outLoginVO) {
|
||||||
|
if(outLoginVO.getTimeout()==0 || outLoginVO.getTimeUnit()==null) {
|
||||||
|
tokens.set(token, gson.toJson(outLoginVO), 30, TimeUnit.MINUTES);
|
||||||
|
tokens.set(outLoginVO.getId()+outLoginVO.getDomain(), token, 30, TimeUnit.MINUTES);
|
||||||
|
}else {
|
||||||
|
tokens.set(token, gson.toJson(outLoginVO), outLoginVO.getTimeout(), outLoginVO.getTimeUnit());
|
||||||
|
tokens.set(outLoginVO.getId()+outLoginVO.getDomain(), token, outLoginVO.getTimeout(), outLoginVO.getTimeUnit());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutLoginVO getUserVO(String token) {
|
||||||
|
OutLoginVO outLoginVO = gson.fromJson(tokens.get(token), OutLoginVO.class);
|
||||||
|
if(outLoginVO != null) {
|
||||||
|
setToken(token, outLoginVO);
|
||||||
|
}
|
||||||
|
return outLoginVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.bb.common.controller;
|
||||||
|
|
||||||
|
public class BetResultProcController {
|
||||||
|
|
||||||
|
//베팅결과 가져와서 우리족 디비에넣고 해당사이트에로 연동 URL 보내주기 (베팅 , 당첨 )
|
||||||
|
|
||||||
|
//해당 사이트 크레딧 처리
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
39
src/main/java/com/bb/common/model/InChatMessageVO.java
Normal file
39
src/main/java/com/bb/common/model/InChatMessageVO.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package com.bb.common.model;
|
||||||
|
|
||||||
|
public class InChatMessageVO {
|
||||||
|
|
||||||
|
private String token; // 사용자 정보를 가져올 토큰
|
||||||
|
private String content; // 메세지 내용
|
||||||
|
private String type; // 채팅 타입
|
||||||
|
private String chatId; // 채팅 고유 아이디
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
public void setToken(String token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
public String getChatId() {
|
||||||
|
return chatId;
|
||||||
|
}
|
||||||
|
public void setChatId(String chatId) {
|
||||||
|
this.chatId = chatId;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InChatMessageVO [token=" + token + ", content=" + content + ", type=" + type + ", chatId=" + chatId
|
||||||
|
+ "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
43
src/main/java/com/bb/common/model/OutChatMessageVO.java
Normal file
43
src/main/java/com/bb/common/model/OutChatMessageVO.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package com.bb.common.model;
|
||||||
|
|
||||||
|
public class OutChatMessageVO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "OutChatMessageVO [id=" + id + ", content=" + content + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
51
src/main/java/com/bb/common/model/OutLoginVO.java
Normal file
51
src/main/java/com/bb/common/model/OutLoginVO.java
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package com.bb.common.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class OutLoginVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String domain;
|
||||||
|
private int timeout;
|
||||||
|
private TimeUnit timeUnit;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
public String getDomain() {
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
public void setDomain(String domain) {
|
||||||
|
this.domain = domain;
|
||||||
|
}
|
||||||
|
public int getTimeout() {
|
||||||
|
return timeout;
|
||||||
|
}
|
||||||
|
public void setTimeout(int timeout) {
|
||||||
|
this.timeout = timeout;
|
||||||
|
}
|
||||||
|
public TimeUnit getTimeUnit() {
|
||||||
|
return timeUnit;
|
||||||
|
}
|
||||||
|
public void setTimeUnit(TimeUnit timeUnit) {
|
||||||
|
this.timeUnit = timeUnit;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "OutLoginVO [id=" + id + ", name=" + name + ", domain=" + domain + ", timeout=" + timeout + ", timeUnit="
|
||||||
|
+ timeUnit + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
125
src/main/java/com/bb/config/AccessLogFilter.java
Normal file
125
src/main/java/com/bb/config/AccessLogFilter.java
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
/*
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import jakarta.servlet.*;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class AccessLogFilter implements Filter {
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(AccessLogFilter.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(FilterConfig filterConfig) throws ServletException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||||
|
CustomRequestWrapper customRequestWrapper = new CustomRequestWrapper((HttpServletRequest) servletRequest);
|
||||||
|
String accessLog = buildAccessLog(customRequestWrapper);
|
||||||
|
LOG.info(accessLog);
|
||||||
|
|
||||||
|
try {
|
||||||
|
filterChain.doFilter(customRequestWrapper, servletResponse);
|
||||||
|
} finally {
|
||||||
|
customRequestWrapper.setBody(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildAccessLog(CustomRequestWrapper customRequestWrapper) {
|
||||||
|
|
||||||
|
String requestURL = getRequestURL(customRequestWrapper);
|
||||||
|
String remoteAddr = getRemoteAddr(customRequestWrapper);
|
||||||
|
String method = getMethod(customRequestWrapper);
|
||||||
|
String queryString = getQueryString(customRequestWrapper);
|
||||||
|
String requestBody = getRequestBody(customRequestWrapper);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("##### ACCESS LOG {");
|
||||||
|
if (requestURL != null) {
|
||||||
|
sb
|
||||||
|
.append("\"").append("requestURL").append("\"")
|
||||||
|
.append(":")
|
||||||
|
.append("\"").append(requestURL).append("\"");
|
||||||
|
}
|
||||||
|
if (remoteAddr != null) {
|
||||||
|
sb
|
||||||
|
.append(",")
|
||||||
|
.append("\"").append("remoteAddr").append("\"")
|
||||||
|
.append(":")
|
||||||
|
.append("\"").append(remoteAddr).append("\"");
|
||||||
|
}
|
||||||
|
if (method != null) {
|
||||||
|
sb
|
||||||
|
.append(",")
|
||||||
|
.append("\"").append("method").append("\"")
|
||||||
|
.append(":")
|
||||||
|
.append("\"").append(method).append("\"");
|
||||||
|
}
|
||||||
|
if (queryString != null) {
|
||||||
|
sb
|
||||||
|
.append(",")
|
||||||
|
.append("\"").append("queryString").append("\"")
|
||||||
|
.append(":")
|
||||||
|
.append("\"").append(queryString).append("\"");
|
||||||
|
}
|
||||||
|
if (requestBody != null && requestBody.length() > 0) {
|
||||||
|
sb
|
||||||
|
.append(",")
|
||||||
|
.append("\"").append("body").append("\"")
|
||||||
|
.append(":")
|
||||||
|
.append("\"").append(requestBody).append("\"");
|
||||||
|
}
|
||||||
|
sb.append("}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getRequestBody(CustomRequestWrapper customRequestWrapper) {
|
||||||
|
String content = null;
|
||||||
|
String method = customRequestWrapper.getMethod().toLowerCase();
|
||||||
|
|
||||||
|
// POST, PUT + application/json
|
||||||
|
if (method.startsWith("p")) {
|
||||||
|
if (customRequestWrapper.getContentType().toLowerCase().indexOf("json") > 0) {
|
||||||
|
try {
|
||||||
|
content = new String(customRequestWrapper.getBody(), customRequestWrapper.getCharacterEncoding());
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
LOG.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getQueryString(CustomRequestWrapper customRequestWrapper) {
|
||||||
|
String queryString = null;
|
||||||
|
if (customRequestWrapper.getQueryString() != null) {
|
||||||
|
queryString = customRequestWrapper.getQueryString();
|
||||||
|
}
|
||||||
|
return queryString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getMethod(CustomRequestWrapper customRequestWrapper) {
|
||||||
|
return customRequestWrapper.getMethod();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getRemoteAddr(CustomRequestWrapper customRequestWrapper) {
|
||||||
|
return customRequestWrapper.getRemoteAddr();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getRequestURL(CustomRequestWrapper customRequestWrapper) {
|
||||||
|
return customRequestWrapper.getRequestURL().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
39
src/main/java/com/bb/config/ApiKeyFilter.java
Normal file
39
src/main/java/com/bb/config/ApiKeyFilter.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import jakarta.servlet.Filter;
|
||||||
|
import jakarta.servlet.FilterChain;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.ServletRequest;
|
||||||
|
import jakarta.servlet.ServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
import com.bb.util.StringUtils;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ApiKeyFilter implements Filter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||||
|
HttpServletRequest req = (HttpServletRequest) request;
|
||||||
|
HttpServletResponse res = (HttpServletResponse) response;
|
||||||
|
|
||||||
|
|
||||||
|
String reqKey = req.getHeader("Authorization");
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(reqKey)) {
|
||||||
|
|
||||||
|
res.setStatus(HttpStatus.UNAUTHORIZED.value());
|
||||||
|
} else {
|
||||||
|
request.setAttribute("Authorization", reqKey);
|
||||||
|
chain.doFilter(request, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
59
src/main/java/com/bb/config/AsyncConfig.java
Normal file
59
src/main/java/com/bb/config/AsyncConfig.java
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableAsync
|
||||||
|
public class AsyncConfig extends AsyncConfigurerSupport {
|
||||||
|
|
||||||
|
// 기본 실행 대기하는 Thread의 수
|
||||||
|
private final int CORE_POOL_SIZE = 10;
|
||||||
|
|
||||||
|
// 동시 동작하는 최대 Thread의 수
|
||||||
|
private final int MAX_POOL_SIZE = 50;
|
||||||
|
|
||||||
|
// MaxPoolSize 초과 요청에서 Thread 생성 요청 시, 해당 요청을 Queue에 저장하는데 이때 최대 수용 가능한 Queue의 수
|
||||||
|
private final int QUEUE_CAPACITY = 500;
|
||||||
|
|
||||||
|
// maxPoolSize가 모두 사용되다가 idle(쓰레드 휴식상태)로 돌아갔을 때 종료하기까지 대기하는 걸리는 시간
|
||||||
|
private final int KEEP_ALIVE_SECONDS = 60;
|
||||||
|
|
||||||
|
// 생성되는 Thread 접두사 지정
|
||||||
|
private final String CUSTOM_THREAD_NAME_PREFIX = "HSLOT-ASYNC-";
|
||||||
|
|
||||||
|
// 시스템을 종료(shutdown)할 때 queue에 남아있는 작업을 모두 완료한 후 종료 하도록 처리
|
||||||
|
private final boolean WAIT_FOR_TASKS_TO_COMPLETE_ON_SHOUTDOWN = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Executor getAsyncExecutor() {
|
||||||
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
|
executor.setCorePoolSize(CORE_POOL_SIZE);
|
||||||
|
executor.setMaxPoolSize(MAX_POOL_SIZE);
|
||||||
|
executor.setQueueCapacity(QUEUE_CAPACITY);
|
||||||
|
executor.setKeepAliveSeconds(KEEP_ALIVE_SECONDS);
|
||||||
|
executor.setThreadNamePrefix(CUSTOM_THREAD_NAME_PREFIX);
|
||||||
|
executor.setWaitForTasksToCompleteOnShutdown(WAIT_FOR_TASKS_TO_COMPLETE_ON_SHOUTDOWN);
|
||||||
|
executor.initialize();
|
||||||
|
return executor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 포인트 처리 전용 Executor 추가
|
||||||
|
@Bean(name = "pointTaskExecutor")
|
||||||
|
public Executor pointTaskExecutor() {
|
||||||
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
|
executor.setCorePoolSize(5);
|
||||||
|
executor.setMaxPoolSize(10);
|
||||||
|
executor.setQueueCapacity(100);
|
||||||
|
executor.setKeepAliveSeconds(60);
|
||||||
|
executor.setThreadNamePrefix("PointAsync-");
|
||||||
|
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||||
|
executor.initialize();
|
||||||
|
return executor;
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/main/java/com/bb/config/AuthFailureHandler.java
Normal file
35
src/main/java/com/bb/config/AuthFailureHandler.java
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import javax.xml.transform.Result;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import org.springframework.security.core.AuthenticationException;
|
||||||
|
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 로그인 실패 핸들러
|
||||||
|
*
|
||||||
|
* @author wedul
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class AuthFailureHandler extends SimpleUrlAuthenticationFailureHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
|
||||||
|
AuthenticationException exception) throws IOException, ServletException {
|
||||||
|
|
||||||
|
ObjectMapper om = new ObjectMapper();
|
||||||
|
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||||
|
//response.getWriter().print(om.writeValueAsString("FAIL"));
|
||||||
|
//response.getWriter().flush();
|
||||||
|
response.sendRedirect(request.getContextPath() + "/login?code=1");
|
||||||
|
}
|
||||||
|
}
|
||||||
144
src/main/java/com/bb/config/AuthProvider.java
Normal file
144
src/main/java/com/bb/config/AuthProvider.java
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.authentication.AuthenticationProvider;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.AuthenticationException;
|
||||||
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.bb.admin.controller.MainController;
|
||||||
|
import com.bb.exception.ApiException;
|
||||||
|
import com.bb.model.OTPInfo;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.TOTPTokenGenerator;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 스프링시큐리티 로그인 인증
|
||||||
|
* Path : 스프링시큐리티
|
||||||
|
* @FileName : AsRepairController.java
|
||||||
|
* @Version : 2019. 8. 27.
|
||||||
|
* @Author : LeeChunghan
|
||||||
|
* @Comment :
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component("authProvider")
|
||||||
|
public class AuthProvider implements AuthenticationProvider {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||||
|
String id = authentication.getName();
|
||||||
|
String password = authentication.getCredentials().toString();
|
||||||
|
String verificationCode = ((CustomWebAuthenticationDetails) authentication.getDetails()).getVerificationCode();
|
||||||
|
|
||||||
|
final String LOG_PREFIX = "#-AP::"+id+":::";
|
||||||
|
log.info(LOG_PREFIX+ "Authentication::"+authentication.toString());
|
||||||
|
log.info(LOG_PREFIX+ "verificationCode::"+verificationCode);
|
||||||
|
|
||||||
|
Site agency = null;
|
||||||
|
boolean isAdmin = false;
|
||||||
|
if(!"".equals(id)) {
|
||||||
|
log.info(LOG_PREFIX+ "Super Login!!!");
|
||||||
|
isAdmin = true;
|
||||||
|
agency = siteService.getSiteLogin(authentication);
|
||||||
|
} else {
|
||||||
|
log.info(LOG_PREFIX+ "Guest Login!!!");
|
||||||
|
isAdmin = false;
|
||||||
|
agency = siteService.getGuestLogin();
|
||||||
|
id = "oms";
|
||||||
|
}
|
||||||
|
|
||||||
|
OTPInfo otpInfo = siteService.getOtpInfo(agency.getSiteIdx());
|
||||||
|
if(otpInfo == null || otpInfo.getAccount().equals("")) {
|
||||||
|
log.error(LOG_PREFIX+ "OTP 정보를 찾을 수 없습니다.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(otpInfo.getSecretKey() == null || otpInfo.getSecretKey().equals("")) {
|
||||||
|
// Create New OTP
|
||||||
|
otpInfo = TOTPTokenGenerator.getGoogleAuthQRUrl(otpInfo);
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "makeOtp:: secret : " + otpInfo.getSecretKey());
|
||||||
|
log.info(LOG_PREFIX+ "makeOtp::account : " + otpInfo.getAccount());
|
||||||
|
log.info(LOG_PREFIX+ "makeOtp:: issuer : " + otpInfo.getIssuer());
|
||||||
|
log.info(LOG_PREFIX+ "makeOtp:: URL : " + otpInfo.getUrl());
|
||||||
|
|
||||||
|
int result = siteService.registSuperOtp(otpInfo);
|
||||||
|
log.info(LOG_PREFIX+ "makeOtp:: result : " + result);
|
||||||
|
} else {
|
||||||
|
log.info(LOG_PREFIX+ "OTP Info : " + otpInfo);
|
||||||
|
String secret = otpInfo.getSecretKey();
|
||||||
|
|
||||||
|
if(verificationCode == null || verificationCode.equals("")) {
|
||||||
|
log.error(LOG_PREFIX+ "OTP 번호를 입력하세요.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean chkOtp = TOTPTokenGenerator.otpVerify(secret, Integer.parseInt(verificationCode));
|
||||||
|
if(!chkOtp) {
|
||||||
|
log.error(LOG_PREFIX+ "OTP 번호가 일치하지 않습니다.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isAdmin) {
|
||||||
|
OTPInfo otpManager = siteService.getOtpInfoByManger(agency.getSiteIdx());
|
||||||
|
if(otpManager.getSecretKey() == null || otpManager.getSecretKey().equals("")) {
|
||||||
|
// Create New Manager OTP
|
||||||
|
otpManager = TOTPTokenGenerator.getGoogleAuthQRUrl(otpManager);
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "Manager makeOtp:: secret : " + otpManager.getSecretKey());
|
||||||
|
log.info(LOG_PREFIX+ "ManagermakeOtp::account : " + otpManager.getAccount());
|
||||||
|
log.info(LOG_PREFIX+ "ManagermakeOtp:: issuer : " + otpManager.getIssuer());
|
||||||
|
log.info(LOG_PREFIX+ "ManagermakeOtp:: URL : " + otpManager.getUrl());
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "Manager otpManager:: " + otpManager.toString());
|
||||||
|
int result = siteService.registSuperOtp(otpManager);
|
||||||
|
log.info(LOG_PREFIX+ "ManagermakeOtp:: result : " + result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(agency == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
Site loginVO = new Site();
|
||||||
|
loginVO = agency;
|
||||||
|
|
||||||
|
List<GrantedAuthority> roles = new ArrayList<GrantedAuthority>();
|
||||||
|
if(isAdmin) {
|
||||||
|
roles.add(new SimpleGrantedAuthority("ROLE_ADMIN"));
|
||||||
|
} else {
|
||||||
|
roles.add(new SimpleGrantedAuthority("ROLE_GUEST"));
|
||||||
|
}
|
||||||
|
|
||||||
|
UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken(id, password, roles);
|
||||||
|
result.setDetails(loginVO);
|
||||||
|
// log.info(LOG_PREFIX+ "UsernamePasswordAuthenticationToken result::"+result.getDetails().toString());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Class<?> authentication) {
|
||||||
|
return authentication.equals(UsernamePasswordAuthenticationToken.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
89
src/main/java/com/bb/config/AuthSuccessHandler.java
Normal file
89
src/main/java/com/bb/config/AuthSuccessHandler.java
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import com.bb.common.model.OutLoginVO;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
|
||||||
|
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
|
||||||
|
import org.springframework.security.web.context.SecurityContextRepository;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 스프링시큐리티 인증 성공 핸들러 (Spring Security 6 대응)
|
||||||
|
* 작성된 코드에서 JSON 출력 로직을 제거하고 명시적 세션 저장을 추가했습니다.
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class AuthSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
|
||||||
|
|
||||||
|
// [1번 방식 핵심] SecurityContextConfig에서 등록한 빈을 주입받아 사용합니다.
|
||||||
|
// 이를 통해 SecurityConfig와의 순환 참조 문제를 해결합니다.
|
||||||
|
@Autowired
|
||||||
|
private SecurityContextRepository securityContextRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
|
||||||
|
Authentication authentication) throws ServletException, IOException {
|
||||||
|
|
||||||
|
// 1. [핵심] SecurityContext 생성 및 명시적 저장
|
||||||
|
// Spring Security 6부터는 이 과정이 있어야 리다이렉트 후 @Secured가 권한을 올바르게 인식합니다.
|
||||||
|
SecurityContext context = SecurityContextHolder.createEmptyContext();
|
||||||
|
context.setAuthentication(authentication);
|
||||||
|
SecurityContextHolder.setContext(context);
|
||||||
|
|
||||||
|
// [수정] 빈으로 주입받은 repository를 통해 세션에 SecurityContext를 영구 저장 (Persistence)
|
||||||
|
securityContextRepository.saveContext(context, request, response);
|
||||||
|
request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, context);
|
||||||
|
|
||||||
|
// 2. 로그인 사용자 정보 추출 (UserDetails 대신 사용 중인 Site 객체)
|
||||||
|
Site login = (Site) authentication.getDetails();
|
||||||
|
final String LOG_PREFIX = "#-AS::" + (login != null ? login.getSiteId() : "Unknown") + ":::";
|
||||||
|
|
||||||
|
String authorities = authentication.getAuthorities()
|
||||||
|
.stream()
|
||||||
|
.map(GrantedAuthority::getAuthority)
|
||||||
|
.reduce((a, b) -> a + ", " + b)
|
||||||
|
.orElse("없음");
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "로그인 성공 - 권한: " + authorities);
|
||||||
|
|
||||||
|
// 3. 커스텀 세션 정보 저장
|
||||||
|
HttpSession session = request.getSession(true);
|
||||||
|
session.setAttribute("user", login);
|
||||||
|
|
||||||
|
// 4. 권한에 따른 리다이렉트 경로 결정
|
||||||
|
String targetUrl;
|
||||||
|
if (authorities.contains("ROLE_ADMIN")) {
|
||||||
|
// 관리자 세션 추가 정보 설정 (필요 시)
|
||||||
|
OutLoginVO outLoginVO = new OutLoginVO();
|
||||||
|
outLoginVO.setDomain(login != null ? login.getDomain() : "");
|
||||||
|
outLoginVO.setId(login != null ? login.getSiteId() : "");
|
||||||
|
|
||||||
|
targetUrl = "/index";
|
||||||
|
} else {
|
||||||
|
targetUrl = "/guest/simpleReport";
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "Redirecting to: " + targetUrl);
|
||||||
|
|
||||||
|
// 5. 리다이렉트 실행 (Clear prior attributes and redirect)
|
||||||
|
clearAuthenticationAttributes(request);
|
||||||
|
getRedirectStrategy().sendRedirect(request, response, targetUrl);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/main/java/com/bb/config/CachedByteArrayInputStream.java
Normal file
33
src/main/java/com/bb/config/CachedByteArrayInputStream.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
|
||||||
|
import jakarta.servlet.ReadListener;
|
||||||
|
import jakarta.servlet.ServletInputStream;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
|
||||||
|
public class CachedByteArrayInputStream extends ServletInputStream {
|
||||||
|
private ByteArrayInputStream in;
|
||||||
|
|
||||||
|
public CachedByteArrayInputStream(byte[] body) {
|
||||||
|
this.in = new ByteArrayInputStream(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isReady() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setReadListener(ReadListener readListener) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int read() {
|
||||||
|
return in.read();
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/main/java/com/bb/config/CorsConfig.java
Normal file
23
src/main/java/com/bb/config/CorsConfig.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class CorsConfig implements WebMvcConfigurer{
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
registry.addMapping("/api/**")
|
||||||
|
.allowedOriginPatterns("*")
|
||||||
|
.allowedHeaders("*") // 어떤 헤더들을 허용할 것인지
|
||||||
|
.allowedMethods("*") // 어떤 메서드를 허용할 것인지 (GET, POST...)
|
||||||
|
.allowCredentials(false) // 쿠키 요청을 허용한다(다른 도메인 서버
|
||||||
|
.maxAge(86400);
|
||||||
|
|
||||||
|
WebMvcConfigurer.super.addCorsMappings(registry);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
45
src/main/java/com/bb/config/CustomRequestWrapper.java
Normal file
45
src/main/java/com/bb/config/CustomRequestWrapper.java
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import jakarta.servlet.ServletInputStream;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class CustomRequestWrapper extends HttpServletRequestWrapper {
|
||||||
|
|
||||||
|
private byte[] body;
|
||||||
|
|
||||||
|
public CustomRequestWrapper(HttpServletRequest httpServletRequest) {
|
||||||
|
super(httpServletRequest);
|
||||||
|
try {
|
||||||
|
// this.body = IOUtils.toByteArray(httpServletRequest.getInputStream());
|
||||||
|
DataInputStream dis = new DataInputStream(httpServletRequest.getInputStream());
|
||||||
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
// byte[] buffer = new byte[0xFFFF];
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
for (int len = dis.read(buffer); len != -1; len = dis.read(buffer)) {
|
||||||
|
os.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
os.flush();
|
||||||
|
this.body = os.toByteArray();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
System.out.println("IOException");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getBody() {
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBody(byte[] body) {
|
||||||
|
this.body = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServletInputStream getInputStream() {
|
||||||
|
return new CachedByteArrayInputStream(this.body);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
25
src/main/java/com/bb/config/CustomServletWrappingFilter.java
Normal file
25
src/main/java/com/bb/config/CustomServletWrappingFilter.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
import org.springframework.web.util.ContentCachingRequestWrapper;
|
||||||
|
import org.springframework.web.util.ContentCachingResponseWrapper;
|
||||||
|
|
||||||
|
import jakarta.servlet.FilterChain;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CustomServletWrappingFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||||
|
ContentCachingRequestWrapper wrappingRequest = new ContentCachingRequestWrapper(request);
|
||||||
|
ContentCachingResponseWrapper wrappingResponse = new ContentCachingResponseWrapper(response);
|
||||||
|
filterChain.doFilter(wrappingRequest, wrappingResponse);
|
||||||
|
wrappingResponse.copyBodyToResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.security.web.authentication.WebAuthenticationDetails;
|
||||||
|
|
||||||
|
public class CustomWebAuthenticationDetails extends WebAuthenticationDetails {
|
||||||
|
|
||||||
|
private String verificationCode;
|
||||||
|
|
||||||
|
public CustomWebAuthenticationDetails(HttpServletRequest request) {
|
||||||
|
super(request);
|
||||||
|
verificationCode = request.getParameter("code");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVerificationCode() {
|
||||||
|
return verificationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.security.authentication.AuthenticationDetailsSource;
|
||||||
|
import org.springframework.security.web.authentication.WebAuthenticationDetails;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CustomWebAuthenticationDetailsSource implements AuthenticationDetailsSource<HttpServletRequest, WebAuthenticationDetails> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebAuthenticationDetails buildDetails(HttpServletRequest context) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return new CustomWebAuthenticationDetails(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
130
src/main/java/com/bb/config/DbConfig.java
Normal file
130
src/main/java/com/bb/config/DbConfig.java
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.AutoMappingBehavior;
|
||||||
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.apache.ibatis.type.JdbcType;
|
||||||
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
|
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
|
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||||
|
|
||||||
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class DbConfig {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** DataSource 트리플-Main 생성 */
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
@ConfigurationProperties(prefix = "spring.datasource1")
|
||||||
|
public DataSource mysql1DataSource() {
|
||||||
|
return DataSourceBuilder.create()
|
||||||
|
.type(HikariDataSource.class)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** DataSource 트리플-Sub 생성 */
|
||||||
|
@Bean
|
||||||
|
@ConfigurationProperties(prefix = "spring.datasource2")
|
||||||
|
public DataSource mysql2DataSource() {
|
||||||
|
return DataSourceBuilder.create()
|
||||||
|
.type(HikariDataSource.class)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** sqlSessionFactory 트리플-Main 생성 */
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
public SqlSessionFactory sqlSessionFactoryMain(@Autowired @Qualifier("mysql1DataSource") DataSource dataSource) throws Exception {
|
||||||
|
// logger.info("SqlSessionFactory Main Start");
|
||||||
|
org.apache.ibatis.session.Configuration configuration = this.getMybatisConfig();
|
||||||
|
|
||||||
|
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
|
||||||
|
factoryBean.setDataSource(dataSource);
|
||||||
|
factoryBean.setVfs(SpringBootVFS.class);
|
||||||
|
factoryBean.setConfiguration(configuration);
|
||||||
|
factoryBean.setTypeHandlersPackage("com.commax.tool.framework.mybatis.typehandler");
|
||||||
|
|
||||||
|
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
|
Resource[] resource = resolver.getResources("db1/**/*.xml");
|
||||||
|
factoryBean.setMapperLocations(resource);
|
||||||
|
|
||||||
|
return factoryBean.getObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** sqlSessionFactory 트리플-Sub 생성 */
|
||||||
|
@Bean
|
||||||
|
public SqlSessionFactory sqlSessionFactory(@Autowired @Qualifier("mysql2DataSource") DataSource dataSource) throws Exception {
|
||||||
|
//logger.info("SqlSessionFactory SUB Start");
|
||||||
|
org.apache.ibatis.session.Configuration configuration = this.getMybatisConfig();
|
||||||
|
|
||||||
|
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
|
||||||
|
factoryBean.setDataSource(dataSource);
|
||||||
|
factoryBean.setVfs(SpringBootVFS.class);
|
||||||
|
factoryBean.setConfiguration(configuration);
|
||||||
|
factoryBean.setTypeHandlersPackage("com.commax.tool.framework.mybatis.typehandler");
|
||||||
|
|
||||||
|
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
|
Resource[] resource = resolver.getResources("db2/**/*.xml");
|
||||||
|
factoryBean.setMapperLocations(resource);
|
||||||
|
|
||||||
|
return factoryBean.getObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** sqlSession 트리플-Main 생성 */
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
public SqlSession sqlSessionMain(@Autowired @Qualifier("sqlSessionFactoryMain") SqlSessionFactory factory) {
|
||||||
|
return new SqlSessionTemplate(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** sqlSession 트리플-Sub 생성 */
|
||||||
|
@Bean
|
||||||
|
public SqlSession sqlSessionSub(@Autowired @Qualifier("sqlSessionFactory") SqlSessionFactory factory) {
|
||||||
|
return new SqlSessionTemplate(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** MybatisConfig 설정정보 */
|
||||||
|
private org.apache.ibatis.session.Configuration getMybatisConfig() {
|
||||||
|
org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
|
||||||
|
configuration.setCacheEnabled(true);
|
||||||
|
configuration.setLazyLoadingEnabled(false);
|
||||||
|
configuration.setAggressiveLazyLoading(false);
|
||||||
|
configuration.setMultipleResultSetsEnabled(true);
|
||||||
|
configuration.setUseColumnLabel(true);
|
||||||
|
configuration.setAutoMappingBehavior(AutoMappingBehavior.PARTIAL);
|
||||||
|
configuration.setDefaultExecutorType(ExecutorType.SIMPLE);
|
||||||
|
configuration.setDefaultStatementTimeout(25000);
|
||||||
|
configuration.setMapUnderscoreToCamelCase(true);
|
||||||
|
configuration.setJdbcTypeForNull(JdbcType.NVARCHAR);
|
||||||
|
configuration.setLazyLoadTriggerMethods(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString")));
|
||||||
|
configuration.setLogPrefix("[SQL]");
|
||||||
|
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
21
src/main/java/com/bb/config/GlobalModelAdvice.java
Normal file
21
src/main/java/com/bb/config/GlobalModelAdvice.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
|
||||||
|
@ControllerAdvice
|
||||||
|
public class GlobalModelAdvice {
|
||||||
|
|
||||||
|
@ModelAttribute("currentURI")
|
||||||
|
public String currentURI(HttpServletRequest request) {
|
||||||
|
String uri = request.getRequestURI();
|
||||||
|
String query = request.getQueryString();
|
||||||
|
|
||||||
|
// 쿼리 스트링이 있다면 URI 뒤에 붙여서 반환 (예: /insurance/betList?updown=up)
|
||||||
|
if (query != null && !query.isEmpty()) {
|
||||||
|
return uri + "?" + query;
|
||||||
|
}
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
86
src/main/java/com/bb/config/GuestProvider.java
Normal file
86
src/main/java/com/bb/config/GuestProvider.java
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.authentication.AuthenticationProvider;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.AuthenticationException;
|
||||||
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.bb.model.OTPInfo;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.TOTPTokenGenerator;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component("guestProvider")
|
||||||
|
public class GuestProvider implements AuthenticationProvider {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||||
|
String verificationCode = ((CustomWebAuthenticationDetails) authentication.getDetails()).getVerificationCode();
|
||||||
|
|
||||||
|
final String LOG_PREFIX = "#-GuestProvider:::";
|
||||||
|
log.info(LOG_PREFIX+ "Authentication::"+authentication.toString());
|
||||||
|
log.info(LOG_PREFIX+ "verificationCode::"+verificationCode);
|
||||||
|
|
||||||
|
Site guest = siteService.getGuestLogin();
|
||||||
|
OTPInfo otpInfo = siteService.getOtpInfo(guest.getSiteIdx());
|
||||||
|
|
||||||
|
if(otpInfo.getSecretKey() == null || otpInfo.getSecretKey().equals("")) {
|
||||||
|
// Create New OTP
|
||||||
|
otpInfo = TOTPTokenGenerator.getGoogleAuthQRUrl(otpInfo);
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "makeOtp:: secret : " + otpInfo.getSecretKey());
|
||||||
|
log.info(LOG_PREFIX+ "makeOtp::account : " + otpInfo.getAccount());
|
||||||
|
log.info(LOG_PREFIX+ "makeOtp:: issuer : " + otpInfo.getIssuer());
|
||||||
|
log.info(LOG_PREFIX+ "makeOtp:: URL : " + otpInfo.getUrl());
|
||||||
|
|
||||||
|
int result = siteService.registSuperOtp(otpInfo);
|
||||||
|
log.info(LOG_PREFIX+ "makeOtp:: result : " + result);
|
||||||
|
} else {
|
||||||
|
log.info(LOG_PREFIX+ "OTP Info : " + otpInfo);
|
||||||
|
String secret = otpInfo.getSecretKey();
|
||||||
|
|
||||||
|
if(verificationCode == null || verificationCode.equals("")) {
|
||||||
|
log.error(LOG_PREFIX+ "OTP 번호를 입력하세요.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean chkOtp = TOTPTokenGenerator.otpVerify(secret, Integer.parseInt(verificationCode));
|
||||||
|
if(!chkOtp) {
|
||||||
|
log.error(LOG_PREFIX+ "OTP 번호가 일치하지 않습니다.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guest == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
List<GrantedAuthority> roles = new ArrayList<GrantedAuthority>();
|
||||||
|
roles.add(new SimpleGrantedAuthority("GUEST"));
|
||||||
|
|
||||||
|
UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken("oms", "ehfrhfo22#", roles);
|
||||||
|
result.setDetails(guest);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Class<?> authentication) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return authentication.equals(UsernamePasswordAuthenticationToken.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
83
src/main/java/com/bb/config/HttpInterceptor.java
Normal file
83
src/main/java/com/bb/config/HttpInterceptor.java
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
|
||||||
|
import com.bb.util.StringUtils;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class HttpInterceptor implements HandlerInterceptor {
|
||||||
|
private final static String REQUEST_POST = "POST";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
log.info("Requested Domain (Host): {}", request.getHeader("Host"));
|
||||||
|
log.info("[preHandle]"+request.getRequestURI() +","+request.getMethod());
|
||||||
|
|
||||||
|
|
||||||
|
log.info("___________________Parameter____________________________ ");
|
||||||
|
|
||||||
|
Enumeration params = request.getParameterNames();
|
||||||
|
while (params.hasMoreElements()) {
|
||||||
|
String name = (String) params.nextElement();
|
||||||
|
String value = request.getParameter(name);
|
||||||
|
log.info(name + "=" + value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
log.info("____________________________ Header ____________________________ ");
|
||||||
|
|
||||||
|
Enumeration<String> headers = request.getHeaderNames();
|
||||||
|
while (headers.hasMoreElements()) {
|
||||||
|
String name = (String) headers.nextElement();
|
||||||
|
String value = request.getHeader(name);
|
||||||
|
log.info(name + "=" + value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
log.info("____________________________ Request Body ____________________________ ");
|
||||||
|
/*
|
||||||
|
try {
|
||||||
|
DataInputStream dis = new DataInputStream(request.getInputStream());
|
||||||
|
String str = null;
|
||||||
|
while ((str = dis.readLine()) != null) {
|
||||||
|
log.info(new String(str.getBytes("ISO-8859-1"), "euc-kr")+"<br/>");
|
||||||
|
// utf-8로 전송된 한글은 깨짐
|
||||||
|
|
||||||
|
}
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.info("ERROR E : {}", e.getMessage());
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||||
|
log.info("[postHandle]"+request.getRequestURI());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object object, Exception ex) throws Exception {
|
||||||
|
log.info("[afterCompletion]"+request.getRequestURI());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
17
src/main/java/com/bb/config/InterceptorConfig.java
Normal file
17
src/main/java/com/bb/config/InterceptorConfig.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class InterceptorConfig implements WebMvcConfigurer {
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(new HttpInterceptor())
|
||||||
|
.addPathPatterns("/api/*") .addPathPatterns("/api/**")
|
||||||
|
.excludePathPatterns("/api/login", "/api/signUp"); // 해당 경로는 인터셉터가 가로채지 않는다.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
55
src/main/java/com/bb/config/OpenapiConfig.java
Normal file
55
src/main/java/com/bb/config/OpenapiConfig.java
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
// 중요: 패키지 경로에 .models 가 추가되었습니다.
|
||||||
|
import org.springdoc.core.models.GroupedOpenApi;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
|
||||||
|
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
|
||||||
|
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
|
||||||
|
import io.swagger.v3.oas.annotations.info.Info;
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityScheme;
|
||||||
|
import io.swagger.v3.oas.annotations.servers.Server;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@OpenAPIDefinition(
|
||||||
|
servers = {
|
||||||
|
@Server(url = "https://oprvender.com"),
|
||||||
|
@Server(url = "http://localhost"),
|
||||||
|
@Server(url = "http://lz.akrra.cc")
|
||||||
|
},
|
||||||
|
info = @Info(title = "My API", version = "v1")
|
||||||
|
)
|
||||||
|
@SecurityScheme(
|
||||||
|
name = "Authorization",
|
||||||
|
scheme = "basic",
|
||||||
|
type = SecuritySchemeType.APIKEY,
|
||||||
|
in = SecuritySchemeIn.HEADER
|
||||||
|
)
|
||||||
|
public class OpenapiConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public GroupedOpenApi publicOpenAPI() {
|
||||||
|
return GroupedOpenApi.builder()
|
||||||
|
.group("front")
|
||||||
|
.packagesToScan("com.bb.front")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public GroupedOpenApi adminAPI() {
|
||||||
|
return GroupedOpenApi.builder()
|
||||||
|
.group("admin")
|
||||||
|
.packagesToScan("com.bb.admin")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public GroupedOpenApi commonAPI() {
|
||||||
|
return GroupedOpenApi.builder()
|
||||||
|
.group("common")
|
||||||
|
.packagesToScan("com.bb.common")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/main/java/com/bb/config/RedisConfig.java
Normal file
26
src/main/java/com/bb/config/RedisConfig.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
//import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
//import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
/*
|
||||||
|
@Configuration
|
||||||
|
public class RedisConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public StringRedisTemplate stringRedisTemplate(
|
||||||
|
@Qualifier("redisConnectionFactory") RedisConnectionFactory redisConnectionFactory
|
||||||
|
) {
|
||||||
|
|
||||||
|
StringRedisTemplate template = new StringRedisTemplate();
|
||||||
|
template.setConnectionFactory(redisConnectionFactory);
|
||||||
|
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
43
src/main/java/com/bb/config/RestTemplateConfig.java
Normal file
43
src/main/java/com/bb/config/RestTemplateConfig.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import org.apache.hc.client5.http.classic.HttpClient;
|
||||||
|
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
|
||||||
|
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RestTemplateConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public HttpClient httpClient() {
|
||||||
|
// HttpClient 5에서는 PoolingHttpClientConnectionManager를 사용하여 커넥션 풀을 관리합니다.
|
||||||
|
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
|
||||||
|
connectionManager.setMaxTotal(4096); // 최대 오픈되는 커넥션 수
|
||||||
|
connectionManager.setDefaultMaxPerRoute(200); // IP, 포트 1쌍에 대해 수행할 커넥션 수
|
||||||
|
|
||||||
|
return HttpClientBuilder.create()
|
||||||
|
.setConnectionManager(connectionManager)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public HttpComponentsClientHttpRequestFactory factory(HttpClient httpClient) {
|
||||||
|
// HttpClient 5를 사용하는 팩토리 생성
|
||||||
|
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
|
||||||
|
|
||||||
|
// Spring Boot 3/HttpClient 5에서는 타임아웃 설정을 팩토리에서 직접 관리하거나
|
||||||
|
// 필요한 경우 빌더 단계에서 설정합니다.
|
||||||
|
factory.setConnectTimeout(3000); // 연결시간초과, ms
|
||||||
|
// 주의: v5용 팩토리에서 setReadTimeout은 지원되지 않을 수 있으므로,
|
||||||
|
// 런타임 에러 시 빌더의 RequestConfig 설정을 사용해야 합니다.
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate(HttpComponentsClientHttpRequestFactory factory) {
|
||||||
|
return new RestTemplate(factory);
|
||||||
|
}
|
||||||
|
}
|
||||||
122
src/main/java/com/bb/config/SecurityConfig.java
Normal file
122
src/main/java/com/bb/config/SecurityConfig.java
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
|
||||||
|
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
|
||||||
|
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
|
||||||
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
import org.springframework.security.web.context.SecurityContextRepository;
|
||||||
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
|
import org.springframework.web.cors.CorsConfigurationSource;
|
||||||
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Configuration
|
||||||
|
@EnableWebSecurity
|
||||||
|
@EnableMethodSecurity(securedEnabled = true, prePostEnabled = true, proxyTargetClass = true) // EnableGlobalMethodSecurity 대체
|
||||||
|
@ComponentScan(basePackages = {"com.bb.*"})
|
||||||
|
public class SecurityConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
AuthProvider authProvider;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
AuthFailureHandler authFailureHandler;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
AuthSuccessHandler authSuccessHandler;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CustomWebAuthenticationDetailsSource authenticationDetailsSource;
|
||||||
|
|
||||||
|
static final String SERVER_HOST_1 = "139-162-90-184.ip.linodeusercontent.com";
|
||||||
|
static final String SERVER_HOST_2 = "139-162-90-179.ip.linodeusercontent.com";
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public MethodSecurityExpressionHandler methodSecurityExpressionHandler() {
|
||||||
|
DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
|
||||||
|
// ROLE_ 접두사 규칙을 강제합니다.
|
||||||
|
expressionHandler.setDefaultRolePrefix("ROLE_");
|
||||||
|
return expressionHandler;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 기존 web.ignoring() 설정 부분
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public WebSecurityCustomizer webSecurityCustomizer() {
|
||||||
|
return (web) -> web.ignoring().requestMatchers(
|
||||||
|
"/v3/api-docs", "/swagger-resources/**", "/webjars/**", "/swagger/**", "/favicon.ico",
|
||||||
|
"/html/**", "/resources/**", "/websocket", "/websocket/**", "/images/**",
|
||||||
|
"/img/**", "/css/**", "/js/**"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 관리자 및 메인 보안 설정 (SecurityFilterChain)
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public SecurityFilterChain filterChain(HttpSecurity http, SecurityContextRepository securityContextRepository) throws Exception {
|
||||||
|
|
||||||
|
http
|
||||||
|
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
|
||||||
|
.csrf(csrf -> csrf.disable())
|
||||||
|
.headers(headers -> headers.frameOptions(frame -> frame.disable()))
|
||||||
|
.securityContext(context -> context
|
||||||
|
.securityContextRepository(securityContextRepository)
|
||||||
|
)
|
||||||
|
.authenticationProvider(authProvider);
|
||||||
|
|
||||||
|
http.authorizeHttpRequests(auth -> auth
|
||||||
|
.requestMatchers("/", "/login/**", "/lg/**", "/api/**", "/actuator/**", "/lunch/**", "/websocket", "/websocket/**", "/guest/guestLogin").permitAll()
|
||||||
|
.anyRequest().authenticated()
|
||||||
|
);
|
||||||
|
|
||||||
|
http.formLogin(form -> form
|
||||||
|
.loginPage("/lg")
|
||||||
|
.loginProcessingUrl("/authenticate")
|
||||||
|
.failureHandler(authFailureHandler)
|
||||||
|
.successHandler(authSuccessHandler)
|
||||||
|
.usernameParameter("id")
|
||||||
|
.passwordParameter("pw")
|
||||||
|
.authenticationDetailsSource(authenticationDetailsSource)
|
||||||
|
);
|
||||||
|
|
||||||
|
return http.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FilterRegistrationBean<ApiKeyFilter> filterRegistrationBean() {
|
||||||
|
FilterRegistrationBean<ApiKeyFilter> registrationBean = new FilterRegistrationBean<>();
|
||||||
|
ApiKeyFilter customURLFilter = new ApiKeyFilter();
|
||||||
|
|
||||||
|
registrationBean.setFilter(customURLFilter);
|
||||||
|
registrationBean.addUrlPatterns("/api/login");
|
||||||
|
registrationBean.setOrder(1);
|
||||||
|
|
||||||
|
return registrationBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public CorsConfigurationSource corsConfigurationSource() {
|
||||||
|
final CorsConfiguration configuration = new CorsConfiguration();
|
||||||
|
configuration.setAllowedOriginPatterns(Arrays.asList("*"));
|
||||||
|
configuration.addAllowedHeader("*");
|
||||||
|
configuration.addAllowedMethod("*");
|
||||||
|
configuration.setAllowCredentials(false);
|
||||||
|
|
||||||
|
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
|
source.registerCorsConfiguration("/**", configuration);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/main/java/com/bb/config/SecurityContextConfig.java
Normal file
26
src/main/java/com/bb/config/SecurityContextConfig.java
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
|
||||||
|
import org.springframework.security.web.context.SecurityContextRepository;
|
||||||
|
|
||||||
|
@Configuration // @Component보다 설정을 위한 @Configuration 권장
|
||||||
|
public class SecurityContextConfig {
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
// 부모 스레드의 SecurityContext를 자식 스레드에서 상속받도록 설정
|
||||||
|
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [핵심] 세션 저장소를 빈으로 등록하여 순환 참조 방지 및 공유
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public SecurityContextRepository securityContextRepository() {
|
||||||
|
return new HttpSessionSecurityContextRepository();
|
||||||
|
}
|
||||||
|
}
|
||||||
43
src/main/java/com/bb/config/WebClientConfig.java
Normal file
43
src/main/java/com/bb/config/WebClientConfig.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import io.netty.channel.ChannelOption;
|
||||||
|
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||||
|
import io.netty.handler.timeout.WriteTimeoutHandler;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import reactor.netty.http.client.HttpClient;
|
||||||
|
import reactor.netty.resources.ConnectionProvider;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class WebClientConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WebClient webClient() {
|
||||||
|
// 1. 커넥션 풀 설정
|
||||||
|
ConnectionProvider provider = ConnectionProvider.builder("my-connection-pool")
|
||||||
|
.maxConnections(4096) // 기존 MaxTotal(4096)과 매칭
|
||||||
|
.pendingAcquireTimeout(Duration.ofMillis(3000))
|
||||||
|
.maxIdleTime(Duration.ofSeconds(20))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 2. 타임아웃 및 Netty HttpClient 설정
|
||||||
|
HttpClient httpClient = HttpClient.create(provider)
|
||||||
|
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3000) // 기존 ConnectTimeout(3000)과 매칭
|
||||||
|
.responseTimeout(Duration.ofSeconds(8)) // 응답 대기 시간
|
||||||
|
.doOnConnected(conn ->
|
||||||
|
conn.addHandlerLast(new ReadTimeoutHandler(9, TimeUnit.SECONDS))
|
||||||
|
.addHandlerLast(new WriteTimeoutHandler(9, TimeUnit.SECONDS))
|
||||||
|
);
|
||||||
|
|
||||||
|
// 3. WebClient 빈 생성
|
||||||
|
return WebClient.builder()
|
||||||
|
.clientConnector(new ReactorClientHttpConnector(httpClient))
|
||||||
|
.codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(2 * 1024 * 1024)) // 2MB
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/main/java/com/bb/config/WebSocketConfig.java
Normal file
32
src/main/java/com/bb/config/WebSocketConfig.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.messaging.simp.config.ChannelRegistration;
|
||||||
|
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||||
|
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
||||||
|
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||||
|
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; // 인터페이스로 변경
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableWebSocketMessageBroker
|
||||||
|
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { // implements로 변경
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureMessageBroker(MessageBrokerRegistry config) {
|
||||||
|
config.enableSimpleBroker("/topic");
|
||||||
|
config.setApplicationDestinationPrefixes("/app");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||||
|
// 기존 allowedOriginPatterns("*") 유지
|
||||||
|
registry.addEndpoint("/websocket")
|
||||||
|
.setAllowedOriginPatterns("*")
|
||||||
|
.withSockJS();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureClientInboundChannel(ChannelRegistration registration) {
|
||||||
|
registration.interceptors(new WebSocketInterceptor());
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/main/java/com/bb/config/WebSocketInterceptor.java
Normal file
32
src/main/java/com/bb/config/WebSocketInterceptor.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package com.bb.config;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.messaging.Message;
|
||||||
|
import org.springframework.messaging.MessageChannel;
|
||||||
|
import org.springframework.messaging.support.ChannelInterceptor; // 인터페이스로 변경
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class WebSocketInterceptor implements ChannelInterceptor { // implements로 변경
|
||||||
|
Set<String> sessionSet = new HashSet<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||||
|
String simpMessageType = String.valueOf(message.getHeaders().get("simpMessageType"));
|
||||||
|
|
||||||
|
if(StringUtils.equals(simpMessageType, "CONNECT")) {
|
||||||
|
String simpSessionId = String.valueOf(message.getHeaders().get("simpSessionId"));
|
||||||
|
sessionSet.add(simpSessionId);
|
||||||
|
} else if(StringUtils.equals(simpMessageType, "DISCONNECT")) {
|
||||||
|
String simpSessionId = String.valueOf(message.getHeaders().get("simpSessionId"));
|
||||||
|
sessionSet.remove(simpSessionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// int uniqueJoinSessionCount = sessionSet.size();
|
||||||
|
|
||||||
|
// 인터페이스에는 super.preSend()가 없으므로 message를 그대로 리턴합니다.
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/main/java/com/bb/controller/PragmaticController.java
Normal file
5
src/main/java/com/bb/controller/PragmaticController.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package com.bb.controller;
|
||||||
|
|
||||||
|
public class PragmaticController {
|
||||||
|
|
||||||
|
}
|
||||||
14
src/main/java/com/bb/dao/CallBackDao.java
Normal file
14
src/main/java/com/bb/dao/CallBackDao.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CallBackDao {
|
||||||
|
|
||||||
|
void insertCallBackErrLog(HashMap logParam);
|
||||||
|
|
||||||
|
void insertBetRadarLog(HashMap sData);
|
||||||
|
|
||||||
|
List<HashMap> getBetRadarLogByBetId(String betId);
|
||||||
|
|
||||||
|
}
|
||||||
39
src/main/java/com/bb/dao/CallBackDaoImpl.java
Normal file
39
src/main/java/com/bb/dao/CallBackDaoImpl.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository("callBackDao")
|
||||||
|
public class CallBackDaoImpl implements CallBackDao {
|
||||||
|
|
||||||
|
/** 메인DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionMain")
|
||||||
|
protected SqlSession sqlSession;
|
||||||
|
|
||||||
|
/** 서브DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionSub")
|
||||||
|
protected SqlSession sqlSessionSub;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertCallBackErrLog(HashMap logParam) {
|
||||||
|
sqlSession.insert("insertCallBackErrLog", logParam);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertBetRadarLog(HashMap sData) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
sqlSession.insert("insertBetRadarLog", sData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getBetRadarLogByBetId(String betId) {
|
||||||
|
return sqlSessionSub.selectList("getBetRadarLogByBetId", betId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
10
src/main/java/com/bb/dao/CoinDao.java
Normal file
10
src/main/java/com/bb/dao/CoinDao.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import com.bb.model.CoinVo;
|
||||||
|
|
||||||
|
public interface CoinDao {
|
||||||
|
|
||||||
|
void saveCoinInfo(CoinVo coinInfo);
|
||||||
|
CoinVo getCoinInfo(String coinSymbol, String currency);
|
||||||
|
|
||||||
|
}
|
||||||
38
src/main/java/com/bb/dao/CoinDaoImpl.java
Normal file
38
src/main/java/com/bb/dao/CoinDaoImpl.java
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.bb.model.CoinVo;
|
||||||
|
|
||||||
|
@Repository("coinDao")
|
||||||
|
public class CoinDaoImpl implements CoinDao{
|
||||||
|
|
||||||
|
/** 메인DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionMain")
|
||||||
|
protected SqlSession sqlSession;
|
||||||
|
|
||||||
|
/** 서브DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionSub")
|
||||||
|
protected SqlSession sqlSessionSub;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveCoinInfo(CoinVo coinInfo) {
|
||||||
|
sqlSession.insert("saveCoinInfo", coinInfo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CoinVo getCoinInfo(String coinSymbol, String currency) {
|
||||||
|
Map param = new HashMap();
|
||||||
|
param.put("coinSymbol", coinSymbol);
|
||||||
|
param.put("currency", currency);
|
||||||
|
return sqlSessionSub.selectOne("getCoinInfo", param);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
23
src/main/java/com/bb/dao/CommonDao.java
Normal file
23
src/main/java/com/bb/dao/CommonDao.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bb.model.BanGameSearch;
|
||||||
|
import com.bb.model.CmnSearch;
|
||||||
|
|
||||||
|
public interface CommonDao {
|
||||||
|
|
||||||
|
List<HashMap<String, String>> getGameCategoryList();
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getGameVendorList(CmnSearch search);
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getBanGameList(BanGameSearch search);
|
||||||
|
|
||||||
|
int insertBanGameInfo(HashMap<String, Object> item);
|
||||||
|
|
||||||
|
int insertNexusGameInfo(HashMap<String, Object> item);
|
||||||
|
|
||||||
|
HashMap getVendorApiInfo(CmnSearch search);
|
||||||
|
|
||||||
|
}
|
||||||
60
src/main/java/com/bb/dao/CommonDaoImpl.java
Normal file
60
src/main/java/com/bb/dao/CommonDaoImpl.java
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.bb.model.BanGameSearch;
|
||||||
|
import com.bb.model.CmnSearch;
|
||||||
|
|
||||||
|
@Repository("commonDao")
|
||||||
|
public class CommonDaoImpl implements CommonDao {
|
||||||
|
|
||||||
|
/** 메인DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionMain")
|
||||||
|
protected SqlSession sqlSession;
|
||||||
|
|
||||||
|
/** 서브DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionSub")
|
||||||
|
protected SqlSession sqlSessionSub;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, String>> getGameCategoryList() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getGameCategoryList");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> getGameVendorList(CmnSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getGameVendorList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> getBanGameList(BanGameSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getBanGameList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertBanGameInfo(HashMap<String, Object> item) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.update("insertBanGameInfo", item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertNexusGameInfo(HashMap<String, Object> item) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.update("insertNexusGameInfo", item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getVendorApiInfo(CmnSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getVendorApiInfo", search);
|
||||||
|
}
|
||||||
|
}
|
||||||
98
src/main/java/com/bb/dao/CreditDao.java
Normal file
98
src/main/java/com/bb/dao/CreditDao.java
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import com.bb.model.CashParam;
|
||||||
|
import com.bb.model.Credit;
|
||||||
|
import com.bb.model.CreditPoint;
|
||||||
|
import com.bb.model.CreditPointSearch;
|
||||||
|
import com.bb.model.CreditSearchVO;
|
||||||
|
import com.bb.model.Insure;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
|
||||||
|
public interface CreditDao {
|
||||||
|
|
||||||
|
void insertCredit(Credit credit);
|
||||||
|
|
||||||
|
void insertCreditByCash(Credit credit);
|
||||||
|
|
||||||
|
void setSiteCreditUpdate(HashMap param);
|
||||||
|
|
||||||
|
int getCreditListCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getCreditList(SiteSearch search);
|
||||||
|
|
||||||
|
int getSiteTranListCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteTranList(SiteSearch search);
|
||||||
|
|
||||||
|
void updateStatus(Credit credit);
|
||||||
|
|
||||||
|
int getPointListCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getPointList(SiteSearch search);
|
||||||
|
|
||||||
|
int getSiteBetListCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteBetList(SiteSearch search);
|
||||||
|
|
||||||
|
void updateInsureStatus(Insure insure);
|
||||||
|
|
||||||
|
void insertInsure(Insure insure);
|
||||||
|
|
||||||
|
HashMap getMyInsureInfo(int siteIdx);
|
||||||
|
|
||||||
|
HashMap getMyRateInfo(int siteIdx);
|
||||||
|
|
||||||
|
int getInsureListCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getInsureList(SiteSearch search);
|
||||||
|
|
||||||
|
HashMap getCreditSumToday(SiteSearch search);
|
||||||
|
|
||||||
|
void updateSetStatus(Credit credit2);
|
||||||
|
|
||||||
|
void updateCreditYn(Credit credit);
|
||||||
|
|
||||||
|
String getRoundIdByGsoft(String refId);
|
||||||
|
|
||||||
|
void insertCreditAiAo(Credit credit);
|
||||||
|
|
||||||
|
void insertCreditPoint(HashMap pointParam);
|
||||||
|
|
||||||
|
int insertPoint(CreditPoint point);
|
||||||
|
|
||||||
|
int checkRequestTime(Credit credit);
|
||||||
|
|
||||||
|
int getCashInOutListCnt(CashParam param);
|
||||||
|
|
||||||
|
List<HashMap> getCashInOutList(CashParam param);
|
||||||
|
|
||||||
|
int getTransCreditListCnt(CreditSearchVO search);
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getTransCreditList(CreditSearchVO search);
|
||||||
|
|
||||||
|
int getTotalTransactionListCnt(CreditSearchVO search);
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getTotalTransactionList(CreditSearchVO search);
|
||||||
|
|
||||||
|
int getCreditPointListCnt(@Valid CreditPointSearch search);
|
||||||
|
|
||||||
|
List<HashMap<String, String>> getCreditPointList(@Valid CreditPointSearch search);
|
||||||
|
|
||||||
|
int getCreditBetListCnt(@Valid CreditPointSearch search);
|
||||||
|
|
||||||
|
List<HashMap<String, String>> getCreditBetList(@Valid CreditPointSearch search);
|
||||||
|
|
||||||
|
int getStatCreditListCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getStatCreditList(SiteSearch search);
|
||||||
|
|
||||||
|
HashMap getStatCreditTotal(SiteSearch search);
|
||||||
|
|
||||||
|
void updateSubCredit(Credit credit);
|
||||||
|
|
||||||
|
}
|
||||||
261
src/main/java/com/bb/dao/CreditDaoImpl.java
Normal file
261
src/main/java/com/bb/dao/CreditDaoImpl.java
Normal file
@@ -0,0 +1,261 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.bb.model.CashParam;
|
||||||
|
import com.bb.model.Credit;
|
||||||
|
import com.bb.model.CreditPoint;
|
||||||
|
import com.bb.model.CreditPointSearch;
|
||||||
|
import com.bb.model.CreditSearchVO;
|
||||||
|
import com.bb.model.Insure;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
|
||||||
|
@Repository("creditDao")
|
||||||
|
public class CreditDaoImpl implements CreditDao {
|
||||||
|
|
||||||
|
/** 메인DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionMain")
|
||||||
|
protected SqlSession sqlSession;
|
||||||
|
|
||||||
|
/** 서브DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionSub")
|
||||||
|
protected SqlSession sqlSessionSub;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertCredit(Credit credit) {
|
||||||
|
sqlSession.insert("insertCredit", credit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertCreditByCash(Credit credit) {
|
||||||
|
sqlSession.insert("insertCreditByCash", credit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSiteCreditUpdate(HashMap param) {
|
||||||
|
sqlSession.update("setSiteCreditUpdate", param);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCreditListCnt(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getCreditListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getCreditList(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectList("getCreditList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSiteTranListCnt(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getSiteTranListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getSiteTranList(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectList("getSiteTranList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateStatus(Credit credit) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
sqlSession.update("updateStatus", credit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPointListCnt(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getPointListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getPointList(SiteSearch search) {
|
||||||
|
return sqlSession.selectList("getPointList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSiteBetListCnt(SiteSearch search) {
|
||||||
|
return sqlSession.selectOne("getSiteBetListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getSiteBetList(SiteSearch search) {
|
||||||
|
return sqlSession.selectList("getSiteBetList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateInsureStatus(Insure insure) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
sqlSession.update("updateInsureStatus", insure);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertInsure(Insure insure) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
sqlSession.insert("insertInsure", insure);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getMyInsureInfo(int siteIdx) {
|
||||||
|
return sqlSession.selectOne("getMyInsureInfo", siteIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getMyRateInfo(int siteIdx) {
|
||||||
|
return sqlSession.selectOne("getMyRateInfo", siteIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInsureListCnt(SiteSearch search) {
|
||||||
|
return sqlSession.selectOne("getInsureListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getInsureList(SiteSearch search) {
|
||||||
|
return sqlSession.selectList("getInsureList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getCreditSumToday(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getCreditSumToday", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSetStatus(Credit credit2) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
sqlSession.update("updateSetStatus", credit2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateCreditYn(Credit credit) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
sqlSession.update("updateCreditYn", credit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRoundIdByGsoft(String refId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getRoundIdByGsoft", refId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertCreditAiAo(Credit credit) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
sqlSession.insert("insertCreditAiAo", credit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertCreditPoint(HashMap pointParam) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
sqlSession.insert("insertCreditPoint", pointParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertPoint(CreditPoint point) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.insert("insertPoint", point);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int checkRequestTime(Credit credit) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("checkRequestTime", credit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCashInOutListCnt(CashParam param) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getCashInOutListCnt", param);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getCashInOutList(CashParam param) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getCashInOutList", param);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTransCreditListCnt(CreditSearchVO search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getTransCreditListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> getTransCreditList(CreditSearchVO search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getTransCreditList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTotalTransactionListCnt(CreditSearchVO search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getTotalTransactionListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> getTotalTransactionList(CreditSearchVO search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getTotalTransactionList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCreditPointListCnt(@Valid CreditPointSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getCreditPointListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, String>> getCreditPointList(@Valid CreditPointSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getCreditPointList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCreditBetListCnt(@Valid CreditPointSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getCreditBetListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, String>> getCreditBetList(@Valid CreditPointSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getCreditBetList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatCreditListCnt(SiteSearch search) {
|
||||||
|
return sqlSessionSub.selectOne("getStatCreditListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getStatCreditList(SiteSearch search) {
|
||||||
|
return sqlSessionSub.selectList("getStatCreditList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getStatCreditTotal(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getStatCreditTotal", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateSubCredit(Credit credit) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
sqlSession.update("updateSubCredit", credit);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
34
src/main/java/com/bb/dao/SettingDao.java
Normal file
34
src/main/java/com/bb/dao/SettingDao.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bb.model.BlockGameVO;
|
||||||
|
import com.bb.model.CmnSearch;
|
||||||
|
import com.bb.model.SiteVendorSkinVO;
|
||||||
|
|
||||||
|
public interface SettingDao {
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getSettingVendorList(CmnSearch search);
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getSettingSkinList(CmnSearch search);
|
||||||
|
|
||||||
|
int settingVendorSkinSave(SiteVendorSkinVO item);
|
||||||
|
|
||||||
|
String getWhiteIpListStr(CmnSearch search);
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getBlockVendorSelectBoxList(String category);
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getBlockVendorSelectBoxList2(CmnSearch search);
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getBlockTableSelectBoxList(CmnSearch search);
|
||||||
|
|
||||||
|
String getBlockTableIds(CmnSearch search);
|
||||||
|
|
||||||
|
int blockTableIdSave(BlockGameVO blockGameVO);
|
||||||
|
|
||||||
|
String getVendorTitle(CmnSearch search);
|
||||||
|
|
||||||
|
HashMap<String, String> getBetRadarApiInfo(String siteId);
|
||||||
|
|
||||||
|
}
|
||||||
104
src/main/java/com/bb/dao/SettingDaoImpl.java
Normal file
104
src/main/java/com/bb/dao/SettingDaoImpl.java
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.bb.model.BlockGameVO;
|
||||||
|
import com.bb.model.CmnSearch;
|
||||||
|
import com.bb.model.SiteVendorSkinVO;
|
||||||
|
|
||||||
|
@Repository("settingDao")
|
||||||
|
public class SettingDaoImpl implements SettingDao {
|
||||||
|
|
||||||
|
/** 메인DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionMain")
|
||||||
|
protected SqlSession sqlSession;
|
||||||
|
|
||||||
|
/** 서브DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionSub")
|
||||||
|
protected SqlSession sqlSessionSub;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> getSettingVendorList(CmnSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getSettingVendorList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> getSettingSkinList(CmnSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getSettingSkinList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int settingVendorSkinSave(SiteVendorSkinVO item) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.update("settingVendorSkinSave", item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getWhiteIpListStr(CmnSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getWhiteIpListStr", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> getBlockVendorSelectBoxList(String category) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getBlockVendorSelectBoxList", category);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> getBlockVendorSelectBoxList2(CmnSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getBlockVendorSelectBoxList2", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> getBlockTableSelectBoxList(CmnSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getBlockTableSelectBoxList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBlockTableIds(CmnSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getBlockTableIds", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int blockTableIdSave(BlockGameVO blockGameVO) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.update("blockTableIdSave", blockGameVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVendorTitle(CmnSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getVendorTitle", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<String, String> getBetRadarApiInfo(String siteId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getBetRadarApiInfo", siteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
489
src/main/java/com/bb/dao/SiteDao.java
Normal file
489
src/main/java/com/bb/dao/SiteDao.java
Normal file
@@ -0,0 +1,489 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
|
||||||
|
import com.bb.model.BalanceParam;
|
||||||
|
import com.bb.model.BetParam;
|
||||||
|
import com.bb.model.BoardSearch;
|
||||||
|
import com.bb.model.CashParam;
|
||||||
|
import com.bb.model.CommonParam;
|
||||||
|
import com.bb.model.Game;
|
||||||
|
import com.bb.model.Member;
|
||||||
|
import com.bb.model.OTPInfo;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SitePwdVO;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
import com.bb.model.TrfApiInfo;
|
||||||
|
import com.bb.model.UserSearch;
|
||||||
|
import com.bb.model.Vendor;
|
||||||
|
import com.bb.model.VendorChangeBalanceLogVo;
|
||||||
|
|
||||||
|
|
||||||
|
public interface SiteDao {
|
||||||
|
|
||||||
|
Site getSiteInfo(String authorization);
|
||||||
|
|
||||||
|
Site getSiteInfoAPI(String authorization);
|
||||||
|
|
||||||
|
Member getMember(CommonParam commonParam);
|
||||||
|
|
||||||
|
Member getMember2(CashParam param);
|
||||||
|
|
||||||
|
void insertMember(CommonParam commonParam);
|
||||||
|
|
||||||
|
HashMap getVenderApiInfo(CommonParam commonParam);
|
||||||
|
|
||||||
|
int commonBetinsert(HashMap tranParam);
|
||||||
|
|
||||||
|
int commonBetinsert2(HashMap tranParam);
|
||||||
|
|
||||||
|
List<HashMap> getCbList();
|
||||||
|
|
||||||
|
void updateCbApi(HashMap upParam);
|
||||||
|
|
||||||
|
HashMap getSiteApiInfo(HashMap sParam);
|
||||||
|
|
||||||
|
HashMap getSiteApiInfo2(HashMap sParam);
|
||||||
|
|
||||||
|
Site getSiteLogin(Authentication authentication);
|
||||||
|
|
||||||
|
Site getSiteLoginApi(Map site);
|
||||||
|
|
||||||
|
Site getGuestLogin();
|
||||||
|
|
||||||
|
int getSiteListCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteList(SiteSearch search);
|
||||||
|
|
||||||
|
void addProc(Site site);
|
||||||
|
|
||||||
|
void addCreditInfo(Site site);
|
||||||
|
|
||||||
|
void addsiteFlow(Site site);
|
||||||
|
|
||||||
|
void insertVendors(Site site);
|
||||||
|
|
||||||
|
Site getSiteInfoMypage(Site site);
|
||||||
|
|
||||||
|
long getSiteCredit(String siteId);
|
||||||
|
|
||||||
|
long getUnderSiteCredit(String siteId);
|
||||||
|
|
||||||
|
long getSitePoint(String siteId);
|
||||||
|
|
||||||
|
void addPointInfo(Site site);
|
||||||
|
|
||||||
|
HashMap getCreditWait(int siteIdx);
|
||||||
|
|
||||||
|
int getSiteUserListCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteUserList(SiteSearch search);
|
||||||
|
|
||||||
|
int getTranCheck(String tranId);
|
||||||
|
|
||||||
|
void insertError(HashMap eParam);
|
||||||
|
|
||||||
|
int getFinalErr(String betId);
|
||||||
|
|
||||||
|
void updateSid(Member member);
|
||||||
|
|
||||||
|
long getInsureAmt(String siteId);
|
||||||
|
|
||||||
|
long getInsurePointAmt(String siteId);
|
||||||
|
|
||||||
|
void insertinsurance(Site site);
|
||||||
|
|
||||||
|
void insertinsurancePoint(Site site);
|
||||||
|
|
||||||
|
List<HashMap> getVenderRateList(Site loginSite);
|
||||||
|
|
||||||
|
int getBetCancelCount(String betId);
|
||||||
|
|
||||||
|
void updateBombKey(Member member);
|
||||||
|
|
||||||
|
Member getMemByBombAccId(HashMap memParam);
|
||||||
|
|
||||||
|
void insertBetDetail(Map detailMap);
|
||||||
|
|
||||||
|
String getBetInfo(BetParam param);
|
||||||
|
|
||||||
|
List<HashMap> getSiteFlow(Site loginSite);
|
||||||
|
|
||||||
|
void saveVendorRate(HashMap paramMap);
|
||||||
|
|
||||||
|
HashMap getEvoApiInfo();
|
||||||
|
|
||||||
|
String getSiteIdByRefId(String refId);
|
||||||
|
|
||||||
|
void updateDetailLastTime(HashMap evoInfo);
|
||||||
|
|
||||||
|
Site getSiteDetail(SiteSearch search);
|
||||||
|
|
||||||
|
Site getSiteSimpleDetail(SiteSearch search);
|
||||||
|
|
||||||
|
HashMap getVenderApiInfoByToken(Map paramV);
|
||||||
|
|
||||||
|
Site getSiteBypassword(Map siteParam);
|
||||||
|
|
||||||
|
void updatePass(Map siteParam);
|
||||||
|
|
||||||
|
void siteUpdate(Site site);
|
||||||
|
|
||||||
|
void saveVendorInsurePointRate(HashMap paramMap);
|
||||||
|
|
||||||
|
HashMap getDashInfo(Site loginSite);
|
||||||
|
|
||||||
|
HashMap getDashInfo2(Site loginSite);
|
||||||
|
|
||||||
|
void insertVendorsRate(Site site);
|
||||||
|
|
||||||
|
HashMap getMicroApiInfo();
|
||||||
|
|
||||||
|
int getApiStatus(HashMap tranParam);
|
||||||
|
|
||||||
|
void saveVendorInsureRate(HashMap paramMap);
|
||||||
|
|
||||||
|
void updateVendorUseYn(HashMap paramMap);
|
||||||
|
|
||||||
|
List<HashMap> getSiteVendorList(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getVendorList(SiteSearch search);
|
||||||
|
|
||||||
|
void siteVenderUpdate(Vendor vendor);
|
||||||
|
|
||||||
|
HashMap getDowinApiInfo();
|
||||||
|
|
||||||
|
long getSiteMaxBet(HashMap sParam);
|
||||||
|
|
||||||
|
Long getUserMaxBet(HashMap sParam);
|
||||||
|
|
||||||
|
int getBetCheckByHc(String refId);
|
||||||
|
|
||||||
|
void updatePragmaticId(Member member);
|
||||||
|
|
||||||
|
HashMap getProgmaticApiInfo();
|
||||||
|
|
||||||
|
HashMap getSiteApiInfoByPra(HashMap sParam);
|
||||||
|
|
||||||
|
String getlastDepostId(HashMap dParam);
|
||||||
|
|
||||||
|
List<HashMap> getNotUseMemberListProgama();
|
||||||
|
|
||||||
|
List<Game> getGameList(HashMap param);
|
||||||
|
|
||||||
|
HashMap getOnlyVenderInfo(CommonParam commonParam);
|
||||||
|
|
||||||
|
int getBotaAutoCancelCnt(String tranId);
|
||||||
|
|
||||||
|
int getBotaBetCnt(String tranId);
|
||||||
|
|
||||||
|
HashMap getProgmaticApiInfo2();
|
||||||
|
|
||||||
|
List<HashMap> getBotaBetListMinute();
|
||||||
|
|
||||||
|
String getSiteIdByRefId2(String string);
|
||||||
|
|
||||||
|
int getTranIdCheck(String string);
|
||||||
|
|
||||||
|
int getTranIdCheck2(String string);
|
||||||
|
|
||||||
|
HashMap getSiteMember(String string);
|
||||||
|
|
||||||
|
void updateDebitCancel(String refId);
|
||||||
|
|
||||||
|
void insertSiteCallBackLog(HashMap logParam);
|
||||||
|
|
||||||
|
List<HashMap> getBetList(BetParam param);
|
||||||
|
|
||||||
|
List<HashMap> getMonsterGameList();
|
||||||
|
|
||||||
|
HashMap getProgmaticApiInfo3(String code);
|
||||||
|
|
||||||
|
long getBetCancelAmt(String string);
|
||||||
|
|
||||||
|
int getBetIdCheck(String refId);
|
||||||
|
|
||||||
|
int getBetIdCheck2(String refId);
|
||||||
|
|
||||||
|
int getTranCheck2(String betId);
|
||||||
|
|
||||||
|
void insertSlotCity(HashMap slotMap);
|
||||||
|
|
||||||
|
void botaAutoCancel(HashMap tranParam);
|
||||||
|
|
||||||
|
void seattleCredit();
|
||||||
|
|
||||||
|
void updateDecimal(HashMap decimalParam);
|
||||||
|
|
||||||
|
List<HashMap> getonlyDebitList();
|
||||||
|
|
||||||
|
void insertAutoLose(HashMap loseCredit);
|
||||||
|
|
||||||
|
HashMap getBetCheck(BetParam param);
|
||||||
|
|
||||||
|
int callbackTokenCheck(String token);
|
||||||
|
|
||||||
|
HashMap getVenderInfo(BalanceParam param);
|
||||||
|
|
||||||
|
String getRefIdByTranId(String tranId);
|
||||||
|
|
||||||
|
List<HashMap> getCreditReSendList();
|
||||||
|
|
||||||
|
void updateMemCancelCnt(long memberIdx);
|
||||||
|
|
||||||
|
Long getMemberIdx(HashMap memParam);
|
||||||
|
|
||||||
|
int insertVendorChangeBalanceLog(VendorChangeBalanceLogVo logVo);
|
||||||
|
|
||||||
|
HashMap getGsoftVendorInfo(String gameID);
|
||||||
|
|
||||||
|
String getCreditRate(HashMap upParam);
|
||||||
|
|
||||||
|
void inserDemoUSer(String bombToken);
|
||||||
|
|
||||||
|
HashMap getDemoByBombAccId(HashMap memParam);
|
||||||
|
|
||||||
|
void updateDemoUSer(HashMap memParam);
|
||||||
|
|
||||||
|
List<HashMap> getTrasferVendorList();
|
||||||
|
|
||||||
|
List<HashMap> getAllMember();
|
||||||
|
|
||||||
|
int gethourBetCheck(long member);
|
||||||
|
|
||||||
|
List<HashMap> getAllMember2();
|
||||||
|
|
||||||
|
HashMap getUserVendorInfo(HashMap memParam);
|
||||||
|
|
||||||
|
Member getMemberByToken(Map authParam);
|
||||||
|
|
||||||
|
HashMap getSiteApiInfoByToken(Map authParam);
|
||||||
|
|
||||||
|
double getBetDepositAmt(String tranId);
|
||||||
|
|
||||||
|
void insertSplusTran(Map trxParam);
|
||||||
|
|
||||||
|
void updateSplusTran(Map trxParam);
|
||||||
|
|
||||||
|
String getCbData(String reserve_id);
|
||||||
|
|
||||||
|
void updatesPurchaseId(Map trxParam);
|
||||||
|
|
||||||
|
double getBetGapAmt(String pid);
|
||||||
|
|
||||||
|
void insertToken(String base64Token);
|
||||||
|
|
||||||
|
int getSplusToken(String base64Token);
|
||||||
|
|
||||||
|
String getRefIdByPurchaseId(String purchase_id);
|
||||||
|
|
||||||
|
List<HashMap> getSplusDetailData(BetParam param);
|
||||||
|
|
||||||
|
String getKorNameTeam(String txt);
|
||||||
|
|
||||||
|
String getKorNameLeague(String txt);
|
||||||
|
|
||||||
|
void insertVendorsCodeRate(Site site);
|
||||||
|
|
||||||
|
HashMap getBetInfoByTranId(String reference);
|
||||||
|
|
||||||
|
int getSuccDebitCnt(String betId);
|
||||||
|
|
||||||
|
HashMap<String, String> getSiteVendorInfo(HashMap param);
|
||||||
|
|
||||||
|
int updatePowerballApiInfo(HashMap<String, String> registParam);
|
||||||
|
|
||||||
|
List<HashMap<String, String>> getPowerBallInfoList(String gameType);
|
||||||
|
|
||||||
|
HashMap<String, String> getSiteApiInfoByApiKey(HashMap param);
|
||||||
|
|
||||||
|
HashMap<String, String> getSiteApiInfoByCallbackKey(HashMap param);
|
||||||
|
|
||||||
|
int updMemLastVendorIdx(HashMap memParam);
|
||||||
|
|
||||||
|
List<HashMap> getVendorListByVendorKey(HashMap venderInfo);
|
||||||
|
|
||||||
|
void vendorUpdate(HashMap venderInfo);
|
||||||
|
|
||||||
|
List<HashMap> getNexusSkinListByVendorKey(HashMap venderInfo);
|
||||||
|
|
||||||
|
void nexusSkinUpdate(HashMap venderInfo);
|
||||||
|
|
||||||
|
String getParseTarget();
|
||||||
|
|
||||||
|
String getParseTargetExtr();
|
||||||
|
|
||||||
|
HashMap getParseUseYn(int siteIdx);
|
||||||
|
|
||||||
|
void insertParseUse(HashMap parseParam);
|
||||||
|
|
||||||
|
List<HashMap> getApiBetVendorList(int siteIdx);
|
||||||
|
|
||||||
|
int getApiBetTransactionCnt(BetParam param);
|
||||||
|
|
||||||
|
List<HashMap> getApiBetTransactionList(BetParam param);
|
||||||
|
|
||||||
|
void updVendorMapForDefault(Site site);
|
||||||
|
|
||||||
|
void updVendorCreditRateForDefault(Site site);
|
||||||
|
|
||||||
|
void deleteVendorAccountForDefault(Site site);
|
||||||
|
|
||||||
|
HashMap getParseUserYn(HashMap pum);
|
||||||
|
|
||||||
|
void setParseUserYn(HashMap pum);
|
||||||
|
|
||||||
|
OTPInfo getOtpInfo(long siteIdx);
|
||||||
|
|
||||||
|
OTPInfo getOtpInfoByManger(long siteIdx);
|
||||||
|
|
||||||
|
int registSuperOtp(OTPInfo param);
|
||||||
|
|
||||||
|
HashMap<String, String> getSiteOnlyVendorInfo(HashMap vendorParam);
|
||||||
|
|
||||||
|
TrfApiInfo getTrfApiInfo(HashMap mapParam);
|
||||||
|
|
||||||
|
void agentIpsUpdate(Site site);
|
||||||
|
|
||||||
|
int insertEvoDetail(HashMap detailMap);
|
||||||
|
|
||||||
|
HashMap getCommonApiInfo(HashMap commonParam);
|
||||||
|
|
||||||
|
HashMap<String, String> getBeforeTranInfo(String vendorTranKey);
|
||||||
|
|
||||||
|
List<HashMap> getParseTargetGame(String gameType);
|
||||||
|
|
||||||
|
String getOrgDetailData(BetParam param);
|
||||||
|
|
||||||
|
String getParDetailData(BetParam param);
|
||||||
|
|
||||||
|
HashMap<String, Object> getBetInfoByTranKey(String vendorTranKey);
|
||||||
|
|
||||||
|
HashMap<String, String> getParseInfo(HashMap param);
|
||||||
|
|
||||||
|
int getBlockParseGameId(String gameId);
|
||||||
|
|
||||||
|
HashMap<String, String> getBeforeTranInfo2(String vendorTranKey);
|
||||||
|
|
||||||
|
String getMemberByIdx(HashMap memParam);
|
||||||
|
|
||||||
|
List<HashMap> getSiteVendorList2(int siteIdx);
|
||||||
|
|
||||||
|
List<HashMap> getVendorList2(int siteIdx);
|
||||||
|
|
||||||
|
void saveSvcr(HashMap paramMap);
|
||||||
|
|
||||||
|
int siteVenderCodeCheck(HashMap paramMap);
|
||||||
|
|
||||||
|
void saveVendorRate2(HashMap paramMap);
|
||||||
|
|
||||||
|
String getSiteKey(HashMap paramMap);
|
||||||
|
|
||||||
|
String getVendorTitle(HashMap paramMap);
|
||||||
|
|
||||||
|
Long getUserTimeout(HashMap accLog);
|
||||||
|
|
||||||
|
int updateUserTimeout(HashMap accLog);
|
||||||
|
|
||||||
|
String getGameKeyByNexusGameId(String gameId);
|
||||||
|
|
||||||
|
String getDebitIsParse(String betId);
|
||||||
|
|
||||||
|
int updateParseUseYN(String useYn);
|
||||||
|
|
||||||
|
int insertTheaTrxId(HashMap param);
|
||||||
|
|
||||||
|
HashMap<String, String> getApiKeyInfo(String vendorTitle);
|
||||||
|
|
||||||
|
HashMap<String, String> getApiKeyInfo2(HashMap<String, String> keyParam);
|
||||||
|
|
||||||
|
HashMap<String, Object> getRefBetInfoByTranId(String tranId);
|
||||||
|
|
||||||
|
int updMemberBalance(HashMap balanceMap);
|
||||||
|
|
||||||
|
int getMemberBalance(HashMap balanceMap);
|
||||||
|
|
||||||
|
HashMap<String, String> getMemberId(String vendorUsername);
|
||||||
|
|
||||||
|
int checkMemberId(String vendorUsername);
|
||||||
|
|
||||||
|
HashMap getNewSiteApiInfo(String vendorUsername);
|
||||||
|
|
||||||
|
HashMap getNewSiteVendorInfo(HashMap param);
|
||||||
|
|
||||||
|
int updateTestCnt(Site site);
|
||||||
|
|
||||||
|
int updateParseEvoYn(HashMap param);
|
||||||
|
|
||||||
|
int saveParsEvoAmount(SiteSearch param);
|
||||||
|
|
||||||
|
int getUserBalance(HashMap balanceMap);
|
||||||
|
|
||||||
|
List<HashMap> getMyDownSite(SiteSearch search);
|
||||||
|
|
||||||
|
HashMap<String, String> getCreditInfo(String siteId);
|
||||||
|
|
||||||
|
int checkDownSite(Map checkDown);
|
||||||
|
|
||||||
|
List<HashMap> getSiteTreeList(String siteId);
|
||||||
|
|
||||||
|
int getMyDownSiteCheck(Site targetsite);
|
||||||
|
|
||||||
|
void insertParseUseYn(Site site);
|
||||||
|
|
||||||
|
int updateSitePwd(SitePwdVO sitePwdVO);
|
||||||
|
|
||||||
|
Site getSite(Site site);
|
||||||
|
|
||||||
|
void siteVenderLobbyUpdate(Vendor vendor);
|
||||||
|
|
||||||
|
List<HashMap> getVendorMapList(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> geLobbyList(SiteSearch search);
|
||||||
|
|
||||||
|
String siteVenderRate(Vendor vendor);
|
||||||
|
|
||||||
|
int getBoardListCnt(BoardSearch search);
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getBoardList(BoardSearch search);
|
||||||
|
|
||||||
|
HashMap<String, Object> getBoardDetail(long boardIdx);
|
||||||
|
|
||||||
|
int getSiteCallbackErrLogListCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteCallbackErrLogList(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteTreeInfo(HashMap param);
|
||||||
|
|
||||||
|
int getUserListCnt(UserSearch search);
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getUserList(UserSearch search);
|
||||||
|
|
||||||
|
HashMap<String, Object> getUserDetail(UserSearch search);
|
||||||
|
|
||||||
|
void insertCmsIp(Site site);
|
||||||
|
|
||||||
|
int getSiteListCntForApi(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteListForApi(SiteSearch search);
|
||||||
|
|
||||||
|
Site getSiteDetailForApi(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getVendorListForApi(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteVendorListForApi(SiteSearch search);
|
||||||
|
|
||||||
|
HashMap getRefIdByVendorTranKey(String vendorTranKey);
|
||||||
|
|
||||||
|
int updateUserMaxBet(HashMap param);
|
||||||
|
|
||||||
|
int insertTranLog(HashMap logParam);
|
||||||
|
|
||||||
|
HashMap getSiteSubCredit(String siteId);
|
||||||
|
|
||||||
|
String getBetAmountByTranParam(HashMap param);
|
||||||
|
}
|
||||||
1396
src/main/java/com/bb/dao/SiteDaoImpl.java
Normal file
1396
src/main/java/com/bb/dao/SiteDaoImpl.java
Normal file
File diff suppressed because it is too large
Load Diff
24
src/main/java/com/bb/dao/SplusDao.java
Normal file
24
src/main/java/com/bb/dao/SplusDao.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface SplusDao {
|
||||||
|
|
||||||
|
void insertSplus(Map splusBetParam);
|
||||||
|
|
||||||
|
void udpateEvent(Map eventParam);
|
||||||
|
|
||||||
|
void udpateBet(Map splusBetParam);
|
||||||
|
|
||||||
|
void cancelBet(Map splusBetParam);
|
||||||
|
|
||||||
|
int getReserveCnt(Map trxParam);
|
||||||
|
|
||||||
|
int getCommitCnt(Map trxParam);
|
||||||
|
|
||||||
|
int getDeReverseCnt(Map trxParam);
|
||||||
|
|
||||||
|
int getCustomerCnt(Map trxParam);
|
||||||
|
|
||||||
|
}
|
||||||
78
src/main/java/com/bb/dao/SplusDaoImpl.java
Normal file
78
src/main/java/com/bb/dao/SplusDaoImpl.java
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository("splusDao")
|
||||||
|
public class SplusDaoImpl implements SplusDao {
|
||||||
|
|
||||||
|
/** 메인DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionMain")
|
||||||
|
protected SqlSession sqlSession;
|
||||||
|
|
||||||
|
/** 서브DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionSub")
|
||||||
|
protected SqlSession sqlSessionSub;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertSplus(Map splusBetParam) {
|
||||||
|
System.out.print("dsfsdfsdfsdfsdfsdf");
|
||||||
|
sqlSession.insert("insertSplus", splusBetParam);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void udpateEvent(Map eventParam) {
|
||||||
|
sqlSession.update("udpateEvent", eventParam);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void udpateBet(Map splusBetParam) {
|
||||||
|
sqlSession.update("udpateBet", splusBetParam);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelBet(Map splusBetParam) {
|
||||||
|
sqlSession.update("udpacancelBeteBet", splusBetParam);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getReserveCnt(Map trxParam) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getReserveCnt", trxParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCommitCnt(Map trxParam) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getCommitCnt", trxParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDeReverseCnt(Map trxParam) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getDeReverseCnt", trxParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCustomerCnt(Map trxParam) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getCustomerCnt", trxParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
89
src/main/java/com/bb/dao/StatDao.java
Normal file
89
src/main/java/com/bb/dao/StatDao.java
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bb.model.ReportSearch;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
|
||||||
|
public interface StatDao {
|
||||||
|
|
||||||
|
int getSiteDailyReportListCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteDailyReportList(SiteSearch search);
|
||||||
|
|
||||||
|
int getVendorDailyReportListCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getVendorDailyReportList(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getBottomSiteDailyReportList(SiteSearch search);
|
||||||
|
|
||||||
|
HashMap getMonthCredit(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getUserDailyReportList(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getUserReportSum(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getAdminPushInfo();
|
||||||
|
|
||||||
|
int getAgentReportCnt(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getAgentReportList(SiteSearch search);
|
||||||
|
|
||||||
|
int getAgentReportCnt2(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getAgentReportList2(SiteSearch search);
|
||||||
|
|
||||||
|
HashMap getAgentReportTotal(SiteSearch search);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
String getlastMonth(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getVendorDailyReportListDay(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getVendorDailyReportListMonth(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getVendorDailyReportListDaySUM(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getVendorDailyReportListMonthSUM(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteReportList(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteReportListSum(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteReportMemList(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteReportMemListSum(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteReportListToDay(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getSiteReportListSumToDay(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getDashBoardList(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getDashBoardMonth(SiteSearch search);
|
||||||
|
|
||||||
|
HashMap getYdayBetInfoBySite(Site targetSite);
|
||||||
|
|
||||||
|
HashMap getMonthBetInfoBySite(Site targetSite);
|
||||||
|
|
||||||
|
HashMap getYdayBetInfoByUser(HashMap targetUser);
|
||||||
|
|
||||||
|
HashMap getMonthBetInfoByUser(HashMap targetUser);
|
||||||
|
|
||||||
|
HashMap getVendorDailyReportMonthByParse(SiteSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getVendorDailyReportListDayByParse(SiteSearch search);
|
||||||
|
|
||||||
|
HashMap getHybridReport(ReportSearch search);
|
||||||
|
|
||||||
|
List<HashMap> getHybridReportList(@Valid ReportSearch search);
|
||||||
|
|
||||||
|
HashMap getHybridReportTotal(@Valid ReportSearch search);
|
||||||
|
|
||||||
|
}
|
||||||
236
src/main/java/com/bb/dao/StatDaoImpl.java
Normal file
236
src/main/java/com/bb/dao/StatDaoImpl.java
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.bb.model.ReportSearch;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.model.SiteSearch;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
@Repository("statDao")
|
||||||
|
public class StatDaoImpl implements StatDao {
|
||||||
|
|
||||||
|
/** 메인DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionMain")
|
||||||
|
protected SqlSession sqlSession;
|
||||||
|
|
||||||
|
/** 서브DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionSub")
|
||||||
|
protected SqlSession sqlSessionSub;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSiteDailyReportListCnt(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getSiteDailyReportListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getSiteDailyReportList(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectList("getSiteDailyReportList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVendorDailyReportListCnt(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getVendorDailyReportListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getVendorDailyReportList(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectList("getVendorDailyReportList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getBottomSiteDailyReportList(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectList("getBottomSiteDailyReportList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getMonthCredit(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getMonthCredit", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getUserDailyReportList(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectList("getUserDailyReportList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getUserReportSum(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectList("getUserReportSum", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getAdminPushInfo() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getAdminPushInfo", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAgentReportCnt(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getAgentReportCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getAgentReportList(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getAgentReportList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAgentReportCnt2(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getAgentReportCnt2", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getAgentReportList2(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getAgentReportList2", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getAgentReportTotal(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getAgentReportTotal", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getlastMonth(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.selectOne("getlastMonth", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getVendorDailyReportListDay(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getVendorDailyReportListDay", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getVendorDailyReportListMonth(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getVendorDailyReportListMonth", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getVendorDailyReportListDaySUM(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getVendorDailyReportListDaySUM", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getVendorDailyReportListMonthSUM(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getVendorDailyReportListMonthSUM", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getSiteReportList(SiteSearch search) {
|
||||||
|
return sqlSessionSub.selectList("getSiteReportList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getSiteReportListSum(SiteSearch search) {
|
||||||
|
return sqlSessionSub.selectList("getSiteReportListSum", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getSiteReportMemList(SiteSearch search) {
|
||||||
|
return sqlSessionSub.selectList("getSiteReportMemList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getSiteReportMemListSum(SiteSearch search) {
|
||||||
|
return sqlSessionSub.selectList("getSiteReportMemListSum", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getSiteReportListToDay(SiteSearch search) {
|
||||||
|
return sqlSessionSub.selectList("getSiteReportListToDay", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getSiteReportListSumToDay(SiteSearch search) {
|
||||||
|
return sqlSessionSub.selectList("getSiteReportListSumToDay", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getDashBoardList(SiteSearch search) {
|
||||||
|
return sqlSessionSub.selectList("getDashBoardList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getDashBoardMonth(SiteSearch search) {
|
||||||
|
return sqlSessionSub.selectList("getDashBoardMonth", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getYdayBetInfoBySite(Site targetSite) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getYdayBetInfoBySite", targetSite);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getMonthBetInfoBySite(Site targetSite) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getMonthBetInfoBySite", targetSite);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getYdayBetInfoByUser(HashMap targetUser) {
|
||||||
|
return sqlSessionSub.selectOne("getYdayBetInfoByUser", targetUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getMonthBetInfoByUser(HashMap targetUser) {
|
||||||
|
return sqlSessionSub.selectOne("getMonthBetInfoByUser", targetUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getVendorDailyReportMonthByParse(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getVendorDailyReportMonthByParse", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getVendorDailyReportListDayByParse(SiteSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getVendorDailyReportListDayByParse", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getHybridReport(ReportSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getHybridReport", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap> getHybridReportList(@Valid ReportSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getHybridReportList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getHybridReportTotal(@Valid ReportSearch search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getHybridReportTotal", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
5
src/main/java/com/bb/dao/TplusDao.java
Normal file
5
src/main/java/com/bb/dao/TplusDao.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
public interface TplusDao {
|
||||||
|
|
||||||
|
}
|
||||||
24
src/main/java/com/bb/dao/TplusDaoImpl.java
Normal file
24
src/main/java/com/bb/dao/TplusDaoImpl.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.bb.model.CronStatusVo;
|
||||||
|
|
||||||
|
@Repository("tplusDao")
|
||||||
|
public class TplusDaoImpl implements TplusDao {
|
||||||
|
|
||||||
|
/** 메인DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionMain")
|
||||||
|
protected SqlSession sqlSession;
|
||||||
|
|
||||||
|
/** 서브DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionSub")
|
||||||
|
protected SqlSession sqlSessionSub;
|
||||||
|
|
||||||
|
}
|
||||||
36
src/main/java/com/bb/dao/TransDao.java
Normal file
36
src/main/java/com/bb/dao/TransDao.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bb.model.BetParam;
|
||||||
|
import com.bb.model.NexusTrplVO;
|
||||||
|
import com.bb.model.TransSearchVO;
|
||||||
|
|
||||||
|
public interface TransDao {
|
||||||
|
|
||||||
|
int getTransBetListCnt(TransSearchVO search);
|
||||||
|
|
||||||
|
List<HashMap<String, Object>> getTransBetList(TransSearchVO search);
|
||||||
|
|
||||||
|
HashMap<String, Object> getTransBetListSum(TransSearchVO search);
|
||||||
|
|
||||||
|
int getTransBetFastListCnt(TransSearchVO search);
|
||||||
|
|
||||||
|
List<HashMap<String, String>> getTransBetFastList(TransSearchVO search);
|
||||||
|
|
||||||
|
HashMap<String, Object> getBetListItem(String betId);
|
||||||
|
|
||||||
|
HashMap<String, String> getTransBetFastListSum(TransSearchVO search);
|
||||||
|
|
||||||
|
HashMap getBetInfoByBetId(BetParam param);
|
||||||
|
|
||||||
|
String getGsoftRoundIdByBetId(String betId);
|
||||||
|
|
||||||
|
HashMap getSiteBetByRefIdFromOld(BetParam param);
|
||||||
|
|
||||||
|
HashMap<String, String> getApiInfo(String vendorTitle);
|
||||||
|
|
||||||
|
int deleteEvoDetailNull(HashMap detailMap);
|
||||||
|
|
||||||
|
}
|
||||||
98
src/main/java/com/bb/dao/TransDaoImpl.java
Normal file
98
src/main/java/com/bb/dao/TransDaoImpl.java
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
package com.bb.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.bb.model.BetParam;
|
||||||
|
import com.bb.model.NexusTrplVO;
|
||||||
|
import com.bb.model.TransSearchVO;
|
||||||
|
|
||||||
|
@Repository("transDao")
|
||||||
|
public class TransDaoImpl implements TransDao {
|
||||||
|
|
||||||
|
/** 메인DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionMain")
|
||||||
|
protected SqlSession sqlSession;
|
||||||
|
|
||||||
|
/** 서브DB 연결 */
|
||||||
|
@Autowired @Qualifier("sqlSessionSub")
|
||||||
|
protected SqlSession sqlSessionSub;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTransBetListCnt(TransSearchVO search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getTransBetListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, Object>> getTransBetList(TransSearchVO search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getTransBetList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<String, Object> getTransBetListSum(TransSearchVO search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getTransBetListSum", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTransBetFastListCnt(TransSearchVO search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getTransBetFastListCnt", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<HashMap<String, String>> getTransBetFastList(TransSearchVO search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectList("getTransBetFastList", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<String, Object> getBetListItem(String betId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getBetListItem", betId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<String, String> getTransBetFastListSum(TransSearchVO search) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getTransBetFastListSum", search);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getBetInfoByBetId(BetParam param) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getBetInfoByBetId", param);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGsoftRoundIdByBetId(String betId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getGsoftRoundIdByBetId", betId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap getSiteBetByRefIdFromOld(BetParam param) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getSiteBetByRefIdFromOld", param);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<String, String> getApiInfo(String vendorTitle) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSessionSub.selectOne("getApiInfo", vendorTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteEvoDetailNull(HashMap detailMap) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return sqlSession.delete("deleteEvoDetailNull", detailMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
37
src/main/java/com/bb/exception/ApiException.java
Normal file
37
src/main/java/com/bb/exception/ApiException.java
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package com.bb.exception;
|
||||||
|
|
||||||
|
import com.bb.model.ApiResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @FileName : ApiException
|
||||||
|
* @Project : skhappy
|
||||||
|
* @Date : 2019. 04. 10.
|
||||||
|
* @Author : pulip
|
||||||
|
* @Description :
|
||||||
|
*/
|
||||||
|
public class ApiException extends Exception {
|
||||||
|
protected ApiResponse apiResponse;
|
||||||
|
|
||||||
|
public ApiException() {
|
||||||
|
this("E001", "오류가 발생하였습니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiException(String message) {
|
||||||
|
this("E001", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public ApiException(ApiResponse apiResponse) {
|
||||||
|
this(apiResponse, "오류가 발생하였습니다.");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public ApiException(String resultCode, String message) {
|
||||||
|
this.apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
this.apiResponse.setResultCode(resultCode);
|
||||||
|
this.apiResponse.setResultMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiResponse getApiResponse() {
|
||||||
|
return this.apiResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/main/java/com/bb/exception/NoDataApiException.java
Normal file
9
src/main/java/com/bb/exception/NoDataApiException.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package com.bb.exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class NoDataApiException extends ApiException {
|
||||||
|
public NoDataApiException() {
|
||||||
|
super("9004", "조회된 데이터가 없습니다.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.bb.exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class RequestArraySizeApiException extends ApiException {
|
||||||
|
public RequestArraySizeApiException(String parameterName) {
|
||||||
|
super("9003", "요청 배열 파라미터 크기에 오류가 있습니다. : " + parameterName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.bb.exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class RequestHeaderApiException extends ApiException {
|
||||||
|
public RequestHeaderApiException(String headerName) {
|
||||||
|
super("9001", "요청 헤더정보가 없습니다 : " + headerName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.bb.exception;
|
||||||
|
|
||||||
|
|
||||||
|
public class RequestParameterApiException extends ApiException {
|
||||||
|
public RequestParameterApiException(String parameterName) {
|
||||||
|
super("9002", "필수 요청 파라미터가 없습니다. : " + parameterName);
|
||||||
|
}
|
||||||
|
}
|
||||||
177
src/main/java/com/bb/front/ApiCoinController.java
Normal file
177
src/main/java/com/bb/front/ApiCoinController.java
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
package com.bb.front;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
import org.codehaus.jettison.json.JSONArray;
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.bb.exception.ApiException;
|
||||||
|
import com.bb.jwt.JwtManager;
|
||||||
|
import com.bb.model.ApiResponse;
|
||||||
|
import com.bb.model.CoinVo;
|
||||||
|
import com.bb.model.Site;
|
||||||
|
import com.bb.service.CoinService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("/api/coin")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@SecurityRequirement(name = "Authorization")
|
||||||
|
public class ApiCoinController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final JwtManager jwtManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CoinService coinService;
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping(value="")
|
||||||
|
public ApiResponse getCoinInfo(@RequestHeader String token, HttpServletRequest request) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
|
||||||
|
String coinSymbol = request.getParameter("symbol");
|
||||||
|
String currency = request.getParameter("currency");
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
//apiKey 체크
|
||||||
|
Site site = siteService.getSiteInfo(request);
|
||||||
|
if(site==null) {
|
||||||
|
throw new ApiException("1000", "accessDinied");
|
||||||
|
}
|
||||||
|
if(token==null) {
|
||||||
|
throw new ApiException("1000", "accessDinied");
|
||||||
|
}
|
||||||
|
|
||||||
|
//토큰체크
|
||||||
|
JwtManager.TokenInfo tokenInfo = jwtManager.getTokenInfo(token);
|
||||||
|
if(token == null) {
|
||||||
|
log.error("#-p1::agentBalance::"+ "access denied token");
|
||||||
|
throw new ApiException("1000", "access denied token");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CoinVo coinVo = coinService.getCoinInfo(coinSymbol, currency);
|
||||||
|
|
||||||
|
|
||||||
|
apiResponse.put("info",coinVo);
|
||||||
|
apiResponse.success();
|
||||||
|
return apiResponse;
|
||||||
|
|
||||||
|
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.info("ddd" +e.toString());
|
||||||
|
apiResponse.fail();
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(fixedDelay = 300*1000) // 5분
|
||||||
|
public void getCoinAllInfo() throws Exception {
|
||||||
|
|
||||||
|
// Authentication auth =
|
||||||
|
// new UsernamePasswordAuthenticationToken("system", null,
|
||||||
|
// AuthorityUtils.createAuthorityList("ROLE_ADMIN"));
|
||||||
|
// SecurityContextHolder.getContext().setAuthentication(auth);
|
||||||
|
|
||||||
|
String hostname = InetAddress.getLocalHost().getHostName();
|
||||||
|
if("ip-172-31-40-216.ap-northeast-3.compute.internal".equals(hostname)) { // 3번 서버 호스트 네임으로 빠꺼야함
|
||||||
|
String[] currency = {"usd","krw"};
|
||||||
|
String cgApiKey = "CG-wJAwrJWZCSbzmBhk545CTcR3";
|
||||||
|
try {
|
||||||
|
|
||||||
|
for(int cu=0;cu<currency.length;cu++) {
|
||||||
|
|
||||||
|
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
|
||||||
|
Request req = new Request.Builder()
|
||||||
|
.url("https://pro-api.coingecko.com/api/v3/coins/markets?vs_currency="+currency[cu])
|
||||||
|
.get()
|
||||||
|
.addHeader("accept", "application/json")
|
||||||
|
.addHeader("x-cg-pro-api-key", cgApiKey)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try (Response response = client.newCall(req).execute()) {
|
||||||
|
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
log.info("Request failed with code: " + response.code());
|
||||||
|
} else {
|
||||||
|
String responseBody = response.body().string(); // 응답 본문 저장
|
||||||
|
// log.info("Response: " + responseBody);
|
||||||
|
|
||||||
|
// JSON 처리 예제
|
||||||
|
JSONArray coinList = new JSONArray(responseBody);
|
||||||
|
for (int c = 0; c < coinList.length(); c++) {
|
||||||
|
// log.info(coinList.get(c).toString());
|
||||||
|
JSONObject coinjson = new JSONObject(coinList.get(c).toString());
|
||||||
|
CoinVo coinInfo = new CoinVo();
|
||||||
|
|
||||||
|
coinInfo.setId(coinjson.getString("id"));
|
||||||
|
coinInfo.setSymbol(coinjson.getString("symbol"));
|
||||||
|
coinInfo.setName(coinjson.getString("name"));
|
||||||
|
coinInfo.setCurrency(currency[cu]);
|
||||||
|
coinInfo.setImage(coinjson.getString("image"));
|
||||||
|
coinInfo.setCurrentPrice(String.valueOf(coinjson.get("current_price")));
|
||||||
|
coinInfo.setMarketCap(String.valueOf(coinjson.get("market_cap")));
|
||||||
|
coinInfo.setMarketCapRank(coinjson.getInt("market_cap_rank"));
|
||||||
|
coinInfo.setFullyDilutedValuation(String.valueOf(coinjson.get("fully_diluted_valuation")));
|
||||||
|
coinInfo.setTotalVolume(String.valueOf(coinjson.get("total_volume")));
|
||||||
|
coinInfo.setHigh24h(String.valueOf(coinjson.get("high_24h")));
|
||||||
|
coinInfo.setLow24h(String.valueOf(coinjson.get("low_24h")));
|
||||||
|
coinInfo.setPriceChange24h(String.valueOf(coinjson.get("price_change_24h")));
|
||||||
|
coinInfo.setPriceChangePercentage24h(String.valueOf(coinjson.get("price_change_percentage_24h")));
|
||||||
|
coinInfo.setMarketCapChange24h(String.valueOf(coinjson.get("market_cap_change_24h")));
|
||||||
|
coinInfo.setMarketCapChangePercentage24h(String.valueOf(coinjson.get("market_cap_change_percentage_24h")));
|
||||||
|
coinInfo.setCirculatingSupply(String.valueOf(coinjson.get("circulating_supply")));
|
||||||
|
coinInfo.setTotalSupply(String.valueOf(coinjson.get("total_supply")));
|
||||||
|
coinInfo.setMaxSupply(String.valueOf(coinjson.get("max_supply")));
|
||||||
|
coinInfo.setAth(String.valueOf(coinjson.get("ath")));
|
||||||
|
coinInfo.setAthChangePercentage(String.valueOf(coinjson.get("ath_change_percentage")));
|
||||||
|
coinInfo.setAthDate(LocalDateTime.parse(coinjson.getString("ath_date"), DateTimeFormatter.ISO_DATE_TIME));
|
||||||
|
coinInfo.setAtl(String.valueOf(coinjson.get("atl")));
|
||||||
|
coinInfo.setAtlChangePercentage(String.valueOf(coinjson.get("atl_change_percentage")));
|
||||||
|
coinInfo.setAtlDate(LocalDateTime.parse(coinjson.getString("atl_date"), DateTimeFormatter.ISO_DATE_TIME));
|
||||||
|
coinInfo.setRoi(coinjson.isNull("roi") ? null : coinjson.get("roi").toString());
|
||||||
|
coinInfo.setLastUpdated(LocalDateTime.parse(coinjson.getString("last_updated"), DateTimeFormatter.ISO_DATE_TIME));
|
||||||
|
|
||||||
|
coinService.saveCoinInfo(coinInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("Error during API call", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.info("ddd" +e.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SecurityContextHolder.clearContext();
|
||||||
|
}
|
||||||
|
}
|
||||||
4401
src/main/java/com/bb/front/ApiFrontController.java
Normal file
4401
src/main/java/com/bb/front/ApiFrontController.java
Normal file
File diff suppressed because it is too large
Load Diff
1679
src/main/java/com/bb/front/CallBackAceController.java
Normal file
1679
src/main/java/com/bb/front/CallBackAceController.java
Normal file
File diff suppressed because it is too large
Load Diff
964
src/main/java/com/bb/front/CallBackBetGambleController.java
Normal file
964
src/main/java/com/bb/front/CallBackBetGambleController.java
Normal file
@@ -0,0 +1,964 @@
|
|||||||
|
package com.bb.front;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClientRequestException;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClientResponseException;
|
||||||
|
|
||||||
|
import com.bb.jwt.JwtManager;
|
||||||
|
import com.bb.model.ApiResponse;
|
||||||
|
import com.bb.model.AuthParam;
|
||||||
|
import com.bb.model.CheckVo;
|
||||||
|
import com.bb.model.CommonParam;
|
||||||
|
import com.bb.model.EvoResponse;
|
||||||
|
import com.bb.model.EvolutionVo;
|
||||||
|
import com.bb.model.Member;
|
||||||
|
import com.bb.model.PlayParam;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("/api/callback/evot")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@SecurityRequirement(name = "Authorization")
|
||||||
|
public class CallBackBetGambleController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final JwtManager jwtManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WebClient webClient;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value="/test")
|
||||||
|
public EvoResponse test(HttpServletRequest request, @RequestBody EvolutionVo evo) throws Exception {
|
||||||
|
EvoResponse evoResponse = new EvoResponse();
|
||||||
|
try {
|
||||||
|
log.debug(evo.toString());
|
||||||
|
|
||||||
|
JSONObject member = new JSONObject();
|
||||||
|
member.put("userId", "moka_gk01");
|
||||||
|
|
||||||
|
log.info("# site.getSiteCbUrl() : " + "https://dev-api.allboxstage.com/triple/balance");
|
||||||
|
log.info("# site.getSiteCbUrl() : " + member.toString());
|
||||||
|
|
||||||
|
HttpHeaders header = new HttpHeaders();
|
||||||
|
header.add("Content-Type", "application/json");
|
||||||
|
header.add("Accept", "application/json");
|
||||||
|
header.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
|
||||||
|
|
||||||
|
ResponseEntity<String> responseEntity = null;
|
||||||
|
try {
|
||||||
|
responseEntity = webClient.post()
|
||||||
|
.uri("https://dev-api.allboxstage.com/triple/balance")
|
||||||
|
.headers(h -> h.addAll(header))
|
||||||
|
.bodyValue(member.toString())
|
||||||
|
.retrieve()
|
||||||
|
.toEntity(String.class)
|
||||||
|
.block();
|
||||||
|
} catch(WebClientResponseException e) {
|
||||||
|
log.error("test::HttpClientErrorException : " + e.getMessage());
|
||||||
|
log.error("test::status code : " + e.getStatusCode().value());
|
||||||
|
log.error("test::response body : " + e.getResponseBodyAsString());
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
} catch (WebClientRequestException rae) {
|
||||||
|
if(rae.getCause() instanceof io.netty.channel.ConnectTimeoutException) {
|
||||||
|
log.error("test::ConnectTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof io.netty.handler.timeout.ReadTimeoutException) {
|
||||||
|
log.error("test::SocketTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error("test::InterruptedException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
log.error("test::WebClientRequestException : " + rae.getMessage());
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
|
||||||
|
log.info("status code : {}", responseEntity.getStatusCode());
|
||||||
|
log.info("body: {}", responseEntity.getBody());
|
||||||
|
|
||||||
|
JSONObject resData = new JSONObject(responseEntity.getBody());
|
||||||
|
|
||||||
|
if(resData.getInt("result_code") == 0) {
|
||||||
|
evoResponse.setUuid(evo.getUuid());
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
evoResponse.setBonus(0.0);
|
||||||
|
evoResponse.success();
|
||||||
|
}else {
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.error("test::Unexpected response status code");
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value="/")
|
||||||
|
public ApiResponse main(HttpServletRequest request, @RequestBody CheckVo check) throws Exception {
|
||||||
|
ApiResponse apiResponse = new ApiResponse();
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
apiResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
apiResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value={"/sid"})
|
||||||
|
public EvoResponse sid(HttpServletRequest request, @RequestBody CheckVo check) throws Exception {
|
||||||
|
EvoResponse evoResponse = new EvoResponse();
|
||||||
|
System.out.print("sid CHECK " + check.toString());
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//사이트정보
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
sParam.put("siteIdx",Integer.parseInt(check.getUserId().substring(0, 3), 16));
|
||||||
|
sParam.put("memberId", check.getUserId().substring(3, check.getUserId().length()));
|
||||||
|
String memberId =check.getUserId().substring(3, check.getUserId().length());
|
||||||
|
|
||||||
|
HashMap siteApiInfo = siteService.getSiteApiInfo(sParam);
|
||||||
|
|
||||||
|
AuthParam param = new AuthParam();
|
||||||
|
param.setBalance(0);
|
||||||
|
param.setUserId(memberId);
|
||||||
|
param.setNickName(check.getUserId());
|
||||||
|
|
||||||
|
CommonParam commonParam = new CommonParam();
|
||||||
|
commonParam.setSiteIdx(Integer.parseInt(siteApiInfo.get("siteIdx").toString()));
|
||||||
|
commonParam.setAuthParam(param);
|
||||||
|
|
||||||
|
System.out.print("CHECK " + check.toString());
|
||||||
|
|
||||||
|
Member member = siteService.getMember(commonParam);
|
||||||
|
|
||||||
|
if(member == null) {
|
||||||
|
siteService.insertMember(commonParam);
|
||||||
|
member = siteService.getMember(commonParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
String sid = makeApiKey("");
|
||||||
|
member.setLastSid(sid);
|
||||||
|
siteService.updateSid(member);
|
||||||
|
evoResponse.setSid(sid);
|
||||||
|
evoResponse.setUuid(check.getUuid());
|
||||||
|
evoResponse.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value={"/check"})
|
||||||
|
public EvoResponse check(HttpServletRequest request, @RequestBody CheckVo check) throws Exception {
|
||||||
|
EvoResponse evoResponse = new EvoResponse();
|
||||||
|
try {
|
||||||
|
System.out.print("check CHECK " + check.toString());
|
||||||
|
|
||||||
|
evoResponse.setSid(check.getSid());
|
||||||
|
evoResponse.setUuid(check.getUuid());
|
||||||
|
|
||||||
|
|
||||||
|
//사이트정보
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
sParam.put("siteIdx",Integer.parseInt(check.getUserId().substring(0, 3), 16));
|
||||||
|
sParam.put("memberId", check.getUserId().substring(3, check.getUserId().length()));
|
||||||
|
String memberId =check.getUserId().substring(3, check.getUserId().length());
|
||||||
|
|
||||||
|
|
||||||
|
HashMap siteApiInfo = siteService.getSiteApiInfo(sParam);
|
||||||
|
|
||||||
|
AuthParam param = new AuthParam();
|
||||||
|
param.setBalance(0);
|
||||||
|
param.setUserId(memberId);
|
||||||
|
param.setNickName(check.getUserId());
|
||||||
|
|
||||||
|
CommonParam commonParam = new CommonParam();
|
||||||
|
commonParam.setSiteIdx(Integer.parseInt(siteApiInfo.get("siteIdx").toString()));
|
||||||
|
commonParam.setAuthParam(param);
|
||||||
|
|
||||||
|
System.out.print("CHECK " + check.toString());
|
||||||
|
|
||||||
|
Member member = siteService.getMember(commonParam);
|
||||||
|
|
||||||
|
// 회원 없을경우 가입시키기
|
||||||
|
|
||||||
|
if(member == null) {
|
||||||
|
|
||||||
|
System.out.print("CHECK INVALID_PARAMETER");
|
||||||
|
|
||||||
|
evoResponse.fail("INVALID_PARAMETER");
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(!check.getSid().equals(member.getLastSid())) {
|
||||||
|
evoResponse.fail("INVALID_SID");
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
evoResponse.success();
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value="/balance")
|
||||||
|
public EvoResponse balance(HttpServletRequest request, @RequestBody EvolutionVo evo) throws Exception {
|
||||||
|
EvoResponse evoResponse = new EvoResponse();
|
||||||
|
try {
|
||||||
|
log.debug(evo.toString());
|
||||||
|
|
||||||
|
//사이트정보
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
|
||||||
|
sParam.put("siteIdx",Integer.parseInt(evo.getUserId().substring(0, 3), 16));
|
||||||
|
sParam.put("memberId", evo.getUserId().substring(3, evo.getUserId().length()));
|
||||||
|
String memberId =evo.getUserId().substring(3, evo.getUserId().length());
|
||||||
|
/*
|
||||||
|
AuthParam param = new AuthParam();
|
||||||
|
param.setBalance(0);
|
||||||
|
param.setUserId("moka_"+evo.getUserId());
|
||||||
|
param.setNickName(evo.getUserId());
|
||||||
|
|
||||||
|
CommonParam commonParam = new CommonParam();
|
||||||
|
commonParam.setSiteIdx(1);
|
||||||
|
commonParam.setAuthParam(param);
|
||||||
|
|
||||||
|
Member memberS = siteService.getMember(commonParam);
|
||||||
|
if(!evo.getSid().equals(memberS.getLastSid())) {
|
||||||
|
evoResponse.fail("INVALID_SID");
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
HashMap siteApiInfo = siteService.getSiteApiInfo(sParam);
|
||||||
|
|
||||||
|
if(siteApiInfo==null) {
|
||||||
|
|
||||||
|
evoResponse.setBalance(null);
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject member = new JSONObject();
|
||||||
|
member.put("userId", memberId);
|
||||||
|
|
||||||
|
log.info("# site.getSiteCbUrl() : " + siteApiInfo.get("siteCbUrl")+"/balance");
|
||||||
|
log.info("# site.getSiteCbUrl() : " + member.toString());
|
||||||
|
|
||||||
|
HttpHeaders header = new HttpHeaders();
|
||||||
|
header.add("Content-Type", "application/json");
|
||||||
|
header.add("Accept", "application/json");
|
||||||
|
header.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
|
||||||
|
|
||||||
|
ResponseEntity<String> responseEntity = null;
|
||||||
|
try {
|
||||||
|
responseEntity = webClient.post()
|
||||||
|
.uri(siteApiInfo.get("siteCbUrl")+"/balance")
|
||||||
|
.headers(h -> h.addAll(header))
|
||||||
|
.bodyValue(member.toString())
|
||||||
|
.retrieve()
|
||||||
|
.toEntity(String.class)
|
||||||
|
.block();
|
||||||
|
} catch(WebClientResponseException e) {
|
||||||
|
log.error("balance::HttpClientErrorException : " + e.getMessage());
|
||||||
|
log.error("balance::status code : " + e.getStatusCode().value());
|
||||||
|
log.error("balance::response body : " + e.getResponseBodyAsString());
|
||||||
|
evoResponse.setBalance(null);
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
} catch (WebClientRequestException rae) {
|
||||||
|
if(rae.getCause() instanceof io.netty.channel.ConnectTimeoutException) {
|
||||||
|
log.error("balance::ConnectTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof io.netty.handler.timeout.ReadTimeoutException) {
|
||||||
|
log.error("balance::SocketTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error("balance::InterruptedException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
log.error("balance::WebClientRequestException : " + rae.getMessage());
|
||||||
|
evoResponse.setBalance(null);
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
|
||||||
|
log.info("status code : {}", responseEntity.getStatusCode());
|
||||||
|
log.info("body: {}", responseEntity.getBody());
|
||||||
|
|
||||||
|
JSONObject resData = new JSONObject(responseEntity.getBody());
|
||||||
|
|
||||||
|
if(resData.getInt("result_code") == 0) {
|
||||||
|
evoResponse.setUuid(evo.getUuid());
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
evoResponse.setBonus(0.0);
|
||||||
|
evoResponse.success();
|
||||||
|
}else {
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.error("balance::Unexpected response status code");
|
||||||
|
evoResponse.setBalance(null);
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value="/debit")
|
||||||
|
public EvoResponse debit (HttpServletRequest request, @RequestBody EvolutionVo evo) throws Exception {
|
||||||
|
EvoResponse evoResponse = new EvoResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.debug(evo.toString());
|
||||||
|
//사이트정보
|
||||||
|
//사이트정보
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
|
||||||
|
sParam.put("siteIdx",Integer.parseInt(evo.getUserId().substring(0, 3), 16));
|
||||||
|
sParam.put("memberId", evo.getUserId().substring(3, evo.getUserId().length()));
|
||||||
|
String memberId =evo.getUserId().substring(3, evo.getUserId().length());
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
AuthParam param = new AuthParam();
|
||||||
|
param.setBalance(0);
|
||||||
|
param.setUserId("moka_"+evo.getUserId());
|
||||||
|
param.setNickName(evo.getUserId());
|
||||||
|
|
||||||
|
CommonParam commonParam = new CommonParam();
|
||||||
|
commonParam.setSiteIdx(1);
|
||||||
|
commonParam.setAuthParam(param);
|
||||||
|
|
||||||
|
Member memberS = siteService.getMember(commonParam);
|
||||||
|
if(!evo.getSid().equals(memberS.getLastSid())) {
|
||||||
|
evoResponse.fail("INVALID_SID");
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
HashMap siteApiInfo = siteService.getSiteApiInfo(sParam);
|
||||||
|
String siteId = siteApiInfo.get("siteId").toString();
|
||||||
|
|
||||||
|
if(siteApiInfo==null) {
|
||||||
|
|
||||||
|
evoResponse.setBalance(null);
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 사이트에 크레딧이 없을경우 에러 보냄 베팅막음
|
||||||
|
long targetSiteCredit = siteService.getSiteCredit(siteApiInfo.get("siteId").toString());
|
||||||
|
if(targetSiteCredit < evo.getTransaction().getAmount() ) {
|
||||||
|
System.out.println("no siteCredit");
|
||||||
|
evoResponse.setBalance(null);
|
||||||
|
evoResponse.fail("INSUFFICIENT_FUNDS2");
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//최대베팅액 (userMaxBet 우선 적용)
|
||||||
|
sParam.put("vendorIdx", 1);
|
||||||
|
long maxBet = siteService.getSiteMaxBet(sParam);
|
||||||
|
|
||||||
|
// userMaxBet 조회
|
||||||
|
long userMaxBet = 0;
|
||||||
|
Long userMaxBetObj = siteService.getUserMaxBet(sParam);
|
||||||
|
if(userMaxBetObj != null) {
|
||||||
|
userMaxBet = userMaxBetObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 최종 maxBet 결정: userMaxBet이 0이면 siteMaxBet 사용, 0이 아니면 userMaxBet 사용
|
||||||
|
long finalMaxBet = (userMaxBet > 0) ? userMaxBet : maxBet;
|
||||||
|
System.out.println("MaxBet Info - siteMaxBet: " + maxBet + ", userMaxBet: " + userMaxBet + ", finalMaxBet: " + finalMaxBet);
|
||||||
|
|
||||||
|
if(evo.getTransaction().getAmount() > finalMaxBet) {
|
||||||
|
System.out.println("Over bet money - finalMaxBet: " + finalMaxBet);
|
||||||
|
evoResponse.setBalance(null);
|
||||||
|
evoResponse.fail("INSUFFICIENT_FUNDS3");
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int fatErrCnt = siteService.getFinalErr(evo.getTransaction().getRefId());
|
||||||
|
|
||||||
|
if(fatErrCnt > 0) {
|
||||||
|
JSONObject member = new JSONObject();
|
||||||
|
member.put("userId", memberId);
|
||||||
|
|
||||||
|
HttpHeaders headerb = new HttpHeaders();
|
||||||
|
headerb.add("Content-Type", "application/json");
|
||||||
|
headerb.add("Accept", "application/json");
|
||||||
|
|
||||||
|
ResponseEntity<String> responseEntityb = null;
|
||||||
|
try {
|
||||||
|
responseEntityb = webClient.post()
|
||||||
|
.uri(siteApiInfo.get("siteCbUrl")+"/balance")
|
||||||
|
.headers(h -> h.addAll(headerb))
|
||||||
|
.bodyValue(member.toString())
|
||||||
|
.retrieve()
|
||||||
|
.toEntity(String.class)
|
||||||
|
.block();
|
||||||
|
} catch(WebClientResponseException e) {
|
||||||
|
log.error("debit(fatErrCnt)::HttpClientErrorException : " + e.getMessage());
|
||||||
|
log.error("debit(fatErrCnt)::status code : " + e.getStatusCode().value());
|
||||||
|
log.error("debit(fatErrCnt)::response body : " + e.getResponseBodyAsString());
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
} catch (WebClientRequestException rae) {
|
||||||
|
if(rae.getCause() instanceof io.netty.channel.ConnectTimeoutException) {
|
||||||
|
log.error("debit(fatErrCnt)::ConnectTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof io.netty.handler.timeout.ReadTimeoutException) {
|
||||||
|
log.error("debit(fatErrCnt)::SocketTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error("debit(fatErrCnt)::InterruptedException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
log.error("debit(fatErrCnt)::WebClientRequestException : " + rae.getMessage());
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(responseEntityb != null && responseEntityb.getStatusCode() == HttpStatus.OK) {
|
||||||
|
log.info("status code : {}", responseEntityb.getStatusCode());
|
||||||
|
log.info("body: {}", responseEntityb.getBody());
|
||||||
|
|
||||||
|
JSONObject resDatab = new JSONObject(responseEntityb.getBody());
|
||||||
|
|
||||||
|
evoResponse.setBalance(resDatab.getDouble("balance"));
|
||||||
|
evoResponse.fail("FINAL_ERROR_ACTION_FAILED");
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap tranParam = new HashMap();
|
||||||
|
tranParam.put("tranId", siteId+evo.getTransaction().getId());
|
||||||
|
tranParam.put("refId", siteId+evo.getTransaction().getRefId());
|
||||||
|
tranParam.put("siteIdx", siteApiInfo.get("siteIdx"));
|
||||||
|
tranParam.put("siteId", siteId);
|
||||||
|
tranParam.put("memberIdx", siteApiInfo.get("memberIdx"));
|
||||||
|
tranParam.put("memberId", memberId);
|
||||||
|
tranParam.put("vendorIdx", 1);
|
||||||
|
tranParam.put("vendorCode", "evolution");
|
||||||
|
tranParam.put("vendorTranKey", evo.getTransaction().getId());
|
||||||
|
tranParam.put("gameIdx", evo.getGame().getType());
|
||||||
|
tranParam.put("tranType", "debit");
|
||||||
|
tranParam.put("depositAmt", evo.getTransaction().getAmount());
|
||||||
|
tranParam.put("creditAmt", "0");
|
||||||
|
tranParam.put("isCancel", "N");
|
||||||
|
tranParam.put("isTie", "N");
|
||||||
|
tranParam.put("apiStatus", 0);
|
||||||
|
tranParam.put("completed", false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommonParam commonParam = new CommonParam();
|
||||||
|
commonParam.setSiteIdx(Integer.parseInt(siteApiInfo.get("siteIdx").toString()));
|
||||||
|
PlayParam param = new PlayParam();
|
||||||
|
param.setVendorKey("C01");
|
||||||
|
commonParam.setPlayParam(param);
|
||||||
|
HashMap venderInfo = siteService.getVenderApiInfo(commonParam);
|
||||||
|
tranParam.put("vendorApiId", venderInfo.get("vendorApiId").toString());
|
||||||
|
}catch(Exception e) {System.out.println("VI ERR:" + e.toString());}
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
|
||||||
|
HttpHeaders header = new HttpHeaders();
|
||||||
|
header.add("Content-Type", "application/json");
|
||||||
|
header.add("Accept", "application/json");
|
||||||
|
header.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
|
||||||
|
JSONObject debit = new JSONObject();
|
||||||
|
|
||||||
|
debit.put("betId", siteId+evo.getTransaction().getRefId());
|
||||||
|
debit.put("tranId", siteId+evo.getTransaction().getId());
|
||||||
|
debit.put("userId", memberId);
|
||||||
|
debit.put("vendorIdx", 1);
|
||||||
|
debit.put("vendorKey","C01");
|
||||||
|
debit.put("vendor", "evolution");
|
||||||
|
debit.put("gameIdx", 1);
|
||||||
|
debit.put("gameKey",evo.getGame().getType());
|
||||||
|
debit.put("tranType", "debit");
|
||||||
|
debit.put("debit", evo.getTransaction().getAmount());
|
||||||
|
debit.put("credit", 0);
|
||||||
|
debit.put("isCancel", 0);
|
||||||
|
debit.put("isBonus",0);
|
||||||
|
|
||||||
|
log.info("send code : {}", debit.toString());
|
||||||
|
|
||||||
|
ResponseEntity<String> responseEntity = null;
|
||||||
|
try {
|
||||||
|
responseEntity = webClient.post()
|
||||||
|
.uri(siteApiInfo.get("siteCbUrl")+"/changebalance")
|
||||||
|
.headers(h -> h.addAll(header))
|
||||||
|
.bodyValue(debit.toString())
|
||||||
|
.retrieve()
|
||||||
|
.toEntity(String.class)
|
||||||
|
.block();
|
||||||
|
} catch(WebClientResponseException e) {
|
||||||
|
log.error("debit::HttpClientErrorException : " + e.getMessage());
|
||||||
|
log.error("debit::status code : " + e.getStatusCode().value());
|
||||||
|
log.error("debit::response body : " + e.getResponseBodyAsString());
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
} catch (WebClientRequestException rae) {
|
||||||
|
if(rae.getCause() instanceof io.netty.channel.ConnectTimeoutException) {
|
||||||
|
log.error("debit::ConnectTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof io.netty.handler.timeout.ReadTimeoutException) {
|
||||||
|
log.error("debit::SocketTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error("debit::InterruptedException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
log.error("debit::WebClientRequestException : " + rae.getMessage());
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
|
||||||
|
log.info("status code : {}", responseEntity.getStatusCode());
|
||||||
|
log.info("bodyD: {}", responseEntity.getBody());
|
||||||
|
|
||||||
|
JSONObject resData = new JSONObject(responseEntity.getBody());
|
||||||
|
log.info("result_Dcode: {}", resData.getInt("result_code"));
|
||||||
|
|
||||||
|
if(resData.getLong("result_code") == 0) {
|
||||||
|
tranParam.put("balance", resData.getDouble("balance"));
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
log.info("result_Dcode: {}2");
|
||||||
|
evoResponse.setUuid(evo.getUuid());
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
evoResponse.setBonus(0.0);
|
||||||
|
|
||||||
|
evoResponse.success();
|
||||||
|
}else if(resData.getLong("result_code") == 80) {
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
evoResponse.fail("INSUFFICIENT_FUNDS");
|
||||||
|
|
||||||
|
}else if(resData.getLong("result_code") == 98) {
|
||||||
|
log.info("result_Dcode 98: {}1");
|
||||||
|
evoResponse.fail("BET_ALREADY_EXIST");
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
}else {
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.error("debit::Unexpected response status code");
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value={"/credit","/cancel"})
|
||||||
|
public EvoResponse credit (HttpServletRequest request, @RequestBody EvolutionVo evo) throws Exception {
|
||||||
|
EvoResponse evoResponse = new EvoResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.debug(evo.toString());
|
||||||
|
//사이트정보
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
|
||||||
|
sParam.put("siteIdx",Integer.parseInt(evo.getUserId().substring(0, 3), 16));
|
||||||
|
sParam.put("memberId", evo.getUserId().substring(3, evo.getUserId().length()));
|
||||||
|
String memberId =evo.getUserId().substring(3, evo.getUserId().length());
|
||||||
|
|
||||||
|
HashMap siteApiInfo = siteService.getSiteApiInfo(sParam);
|
||||||
|
String siteId = siteApiInfo.get("siteId").toString();
|
||||||
|
|
||||||
|
HashMap tranParam = new HashMap();
|
||||||
|
tranParam.put("tranId",siteId+evo.getTransaction().getId());
|
||||||
|
tranParam.put("refId", siteId+evo.getTransaction().getRefId());
|
||||||
|
tranParam.put("siteIdx", siteApiInfo.get("siteIdx"));
|
||||||
|
tranParam.put("siteId", siteId);
|
||||||
|
tranParam.put("memberIdx", siteApiInfo.get("memberIdx"));
|
||||||
|
tranParam.put("memberId", memberId);
|
||||||
|
tranParam.put("vendorIdx", 1);
|
||||||
|
tranParam.put("vendorCode", "evolution");
|
||||||
|
tranParam.put("vendorTranKey", evo.getTransaction().getId());
|
||||||
|
tranParam.put("gameIdx", evo.getGame().getType());
|
||||||
|
tranParam.put("tranType", "credit");
|
||||||
|
tranParam.put("depositAmt", 0);
|
||||||
|
tranParam.put("creditAmt", evo.getTransaction().getAmount());
|
||||||
|
|
||||||
|
tranParam.put("completed", true);
|
||||||
|
|
||||||
|
tranParam.put("isCancel", "N");
|
||||||
|
|
||||||
|
if(request.getRequestURI().indexOf("cancel") > 0 ) {
|
||||||
|
tranParam.put("isCancel", "Y");
|
||||||
|
}
|
||||||
|
tranParam.put("isTie", "N");
|
||||||
|
tranParam.put("apiStatus", 0);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommonParam commonParam = new CommonParam();
|
||||||
|
commonParam.setSiteIdx(Integer.parseInt(siteApiInfo.get("siteIdx").toString()));
|
||||||
|
PlayParam param = new PlayParam();
|
||||||
|
param.setVendorKey("C01");
|
||||||
|
commonParam.setPlayParam(param);
|
||||||
|
HashMap venderInfo = siteService.getVenderApiInfo(commonParam);
|
||||||
|
tranParam.put("vendorApiId", venderInfo.get("vendorApiId").toString());
|
||||||
|
}catch(Exception e) {System.out.println("VI ERR:" + e.toString());}
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
|
||||||
|
HttpHeaders header = new HttpHeaders();
|
||||||
|
header.add("Content-Type", "application/json");
|
||||||
|
header.add("Accept", "application/json");
|
||||||
|
header.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
|
||||||
|
JSONObject debit = new JSONObject();
|
||||||
|
|
||||||
|
debit.put("betId", siteId+evo.getTransaction().getRefId());
|
||||||
|
debit.put("tranId", siteId+evo.getTransaction().getId());
|
||||||
|
debit.put("userId", memberId);
|
||||||
|
debit.put("vendorIdx", 1);
|
||||||
|
debit.put("vendorKey","C01");
|
||||||
|
debit.put("vendor", "evolution");
|
||||||
|
debit.put("gameIdx", 1);
|
||||||
|
debit.put("gameKey",evo.getGame().getType());
|
||||||
|
debit.put("tranType", "credit");
|
||||||
|
debit.put("debit", 0);
|
||||||
|
debit.put("credit", evo.getTransaction().getAmount());
|
||||||
|
debit.put("isCancel",0);
|
||||||
|
debit.put("isBonus",0);
|
||||||
|
|
||||||
|
if(request.getRequestURI().indexOf("cancel") > 0 ) {
|
||||||
|
debit.put("isCancel",1);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("send code : {}", debit.toString());
|
||||||
|
|
||||||
|
ResponseEntity<String> responseEntity = null;
|
||||||
|
try {
|
||||||
|
responseEntity = webClient.post()
|
||||||
|
.uri(siteApiInfo.get("siteCbUrl")+"/changebalance")
|
||||||
|
.headers(h -> h.addAll(header))
|
||||||
|
.bodyValue(debit.toString())
|
||||||
|
.retrieve()
|
||||||
|
.toEntity(String.class)
|
||||||
|
.block();
|
||||||
|
} catch(WebClientResponseException e) {
|
||||||
|
log.error("credit::HttpClientErrorException : " + e.getMessage());
|
||||||
|
log.error("credit::status code : " + e.getStatusCode().value());
|
||||||
|
log.error("credit::response body : " + e.getResponseBodyAsString());
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
} catch (WebClientRequestException rae) {
|
||||||
|
if(rae.getCause() instanceof io.netty.channel.ConnectTimeoutException) {
|
||||||
|
log.error("credit::ConnectTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof io.netty.handler.timeout.ReadTimeoutException) {
|
||||||
|
log.error("credit::SocketTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error("credit::InterruptedException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
log.error("credit::WebClientRequestException : " + rae.getMessage());
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
|
||||||
|
log.info("status code : {}", responseEntity.getStatusCode());
|
||||||
|
log.info("bodyC: {}", responseEntity.getBody());
|
||||||
|
|
||||||
|
JSONObject resData = new JSONObject(responseEntity.getBody());
|
||||||
|
log.info("result_DCcode: {}", resData.getInt("result_code"));
|
||||||
|
if(resData.getLong("result_code") == 0) {
|
||||||
|
log.info("siteService.updateCbApi(tranParam)");
|
||||||
|
tranParam.put("balance", resData.getDouble("balance"));
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
|
||||||
|
evoResponse.setUuid(evo.getUuid());
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
evoResponse.setBonus(0.0);
|
||||||
|
evoResponse.success();
|
||||||
|
}else if(resData.getLong("result_code") == 99) {
|
||||||
|
|
||||||
|
if(request.getRequestURI().indexOf("cancel") > 0 ) {
|
||||||
|
|
||||||
|
HashMap eParam = new HashMap();
|
||||||
|
eParam.put("betId", evo.getTransaction().getRefId());
|
||||||
|
eParam.put("errorType", "FATAL_ERROR");
|
||||||
|
|
||||||
|
siteService.insertError(eParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
evoResponse.fail("BET_DOES_NOT_EXIST");
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
|
||||||
|
}else if(resData.getLong("result_code") == 98) {
|
||||||
|
evoResponse.fail("BET_ALREADY_SETTLED");
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
}else {
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.error("credit::Unexpected response status code");
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value={"/promo_payout"})
|
||||||
|
public EvoResponse promo_payout (HttpServletRequest request, @RequestBody EvolutionVo evo) throws Exception {
|
||||||
|
EvoResponse evoResponse = new EvoResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.debug(evo.toString());
|
||||||
|
//사이트정보
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
String[] usrinfo = evo.getUserId().split("_");
|
||||||
|
|
||||||
|
sParam.put("siteIdx",Integer.parseInt(evo.getUserId().substring(0, 3), 16));
|
||||||
|
sParam.put("memberId", evo.getUserId().substring(3, evo.getUserId().length()));
|
||||||
|
String memberId =evo.getUserId().substring(3, evo.getUserId().length());
|
||||||
|
|
||||||
|
HashMap siteApiInfo = siteService.getSiteApiInfo(sParam);
|
||||||
|
String siteId = siteApiInfo.get("siteId").toString();
|
||||||
|
|
||||||
|
HashMap tranParam = new HashMap();
|
||||||
|
tranParam.put("tranId",siteId+evo.getPromoTransaction().getId());
|
||||||
|
tranParam.put("refId", siteId+evo.getPromoTransaction().getId());
|
||||||
|
tranParam.put("siteIdx", siteApiInfo.get("siteIdx"));
|
||||||
|
tranParam.put("siteId", siteId);
|
||||||
|
tranParam.put("memberIdx", siteApiInfo.get("memberIdx"));
|
||||||
|
tranParam.put("memberId", memberId);
|
||||||
|
tranParam.put("vendorIdx", 1);
|
||||||
|
tranParam.put("vendorCode", "evolution");
|
||||||
|
tranParam.put("vendorTranKey", evo.getPromoTransaction().getId());
|
||||||
|
tranParam.put("gameIdx", evo.getPromoTransaction().getType());
|
||||||
|
tranParam.put("tranType", "promo");
|
||||||
|
tranParam.put("depositAmt", 0);
|
||||||
|
tranParam.put("creditAmt", evo.getPromoTransaction().getAmount());
|
||||||
|
|
||||||
|
tranParam.put("isCancel", "N");
|
||||||
|
|
||||||
|
if(request.getRequestURI().indexOf("cancel") > 0 ) {
|
||||||
|
tranParam.put("isCancel", "Y");
|
||||||
|
}
|
||||||
|
tranParam.put("isTie", "N");
|
||||||
|
tranParam.put("apiStatus", 0);
|
||||||
|
|
||||||
|
tranParam.put("completed", true);
|
||||||
|
try {
|
||||||
|
CommonParam commonParam = new CommonParam();
|
||||||
|
commonParam.setSiteIdx(Integer.parseInt(siteApiInfo.get("siteIdx").toString()));
|
||||||
|
PlayParam param = new PlayParam();
|
||||||
|
param.setVendorKey("C01");
|
||||||
|
commonParam.setPlayParam(param);
|
||||||
|
HashMap venderInfo = siteService.getVenderApiInfo(commonParam);
|
||||||
|
tranParam.put("vendorApiId", venderInfo.get("vendorApiId").toString());
|
||||||
|
}catch(Exception e) {System.out.println("VI ERR:" + e.toString());}
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
|
||||||
|
HttpHeaders header = new HttpHeaders();
|
||||||
|
header.add("Content-Type", "application/json");
|
||||||
|
header.add("Accept", "application/json");
|
||||||
|
header.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
|
||||||
|
JSONObject debit = new JSONObject();
|
||||||
|
|
||||||
|
debit.put("betId", siteId+evo.getPromoTransaction().getId());
|
||||||
|
debit.put("tranId", siteId+evo.getPromoTransaction().getId());
|
||||||
|
debit.put("userId", memberId);
|
||||||
|
debit.put("vendorIdx", 1);
|
||||||
|
debit.put("vendorKey","C01");
|
||||||
|
debit.put("vendor","evolution");
|
||||||
|
debit.put("gameIdx", 1);
|
||||||
|
debit.put("gameKey",evo.getPromoTransaction().getType());
|
||||||
|
debit.put("tranType", "credit");
|
||||||
|
debit.put("debit", 0);
|
||||||
|
debit.put("credit", evo.getPromoTransaction().getAmount());
|
||||||
|
debit.put("isCancel",0);
|
||||||
|
debit.put("isBonus",1);
|
||||||
|
|
||||||
|
log.info("send code : {}", debit.toString());
|
||||||
|
|
||||||
|
ResponseEntity<String> responseEntity = null;
|
||||||
|
try {
|
||||||
|
responseEntity = webClient.post()
|
||||||
|
.uri(siteApiInfo.get("siteCbUrl")+"/changebalance")
|
||||||
|
.headers(h -> h.addAll(header))
|
||||||
|
.bodyValue(debit.toString())
|
||||||
|
.retrieve()
|
||||||
|
.toEntity(String.class)
|
||||||
|
.block();
|
||||||
|
} catch(WebClientResponseException e) {
|
||||||
|
log.error("promo_payout::HttpClientErrorException : " + e.getMessage());
|
||||||
|
log.error("promo_payout::status code : " + e.getStatusCode().value());
|
||||||
|
log.error("promo_payout::response body : " + e.getResponseBodyAsString());
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
} catch (WebClientRequestException rae) {
|
||||||
|
if(rae.getCause() instanceof io.netty.channel.ConnectTimeoutException) {
|
||||||
|
log.error("promo_payout::ConnectTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof io.netty.handler.timeout.ReadTimeoutException) {
|
||||||
|
log.error("promo_payout::SocketTimeoutException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if(rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error("promo_payout::InterruptedException::" + rae.getMessage());
|
||||||
|
}
|
||||||
|
log.error("promo_payout::WebClientRequestException : " + rae.getMessage());
|
||||||
|
evoResponse.fail();
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
|
||||||
|
log.info("status code : {}", responseEntity.getStatusCode());
|
||||||
|
log.info("bodyC: {}", responseEntity.getBody());
|
||||||
|
|
||||||
|
JSONObject resData = new JSONObject(responseEntity.getBody());
|
||||||
|
log.info("result_DCcode: {}", resData.getInt("result_code"));
|
||||||
|
if(resData.getLong("result_code") == 0) {
|
||||||
|
log.info("siteService.updateCbApi(tranParam)");
|
||||||
|
tranParam.put("balance", resData.getDouble("balance"));
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
|
||||||
|
evoResponse.setUuid(evo.getUuid());
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
evoResponse.setBonus(0.0);
|
||||||
|
evoResponse.success();
|
||||||
|
}else if(resData.getLong("result_code") == 99) {
|
||||||
|
evoResponse.fail("BET_DOES_NOT_EXIST");
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
|
||||||
|
}else if(resData.getLong("result_code") == 98) {
|
||||||
|
evoResponse.fail("BET_ALREADY_SETTLED");
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
|
||||||
|
}else if(resData.getLong("result_code") == 70) {
|
||||||
|
evoResponse.fail("BET_ALREADY_SETTLED");
|
||||||
|
evoResponse.setBalance( resData.getDouble("balance"));
|
||||||
|
|
||||||
|
}else {
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.error("promo_payout::Unexpected response status code");
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info(e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
evoResponse.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
return evoResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private String makeApiKey(String param) {
|
||||||
|
|
||||||
|
int n = 20; // n자리 쿠폰
|
||||||
|
char[] chs = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||||
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||||
|
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ,'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
|
||||||
|
|
||||||
|
|
||||||
|
Random rd = new Random();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
char ch = chs[rd.nextInt(chs.length)];
|
||||||
|
sb.append(ch);
|
||||||
|
}
|
||||||
|
return param + sb.toString();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
559
src/main/java/com/bb/front/CallBackBombController.java
Normal file
559
src/main/java/com/bb/front/CallBackBombController.java
Normal file
@@ -0,0 +1,559 @@
|
|||||||
|
package com.bb.front;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.bb.jwt.JwtManager;
|
||||||
|
import com.bb.model.BombAuthVO;
|
||||||
|
import com.bb.model.BombReponseVo;
|
||||||
|
import com.bb.model.CommonParam;
|
||||||
|
import com.bb.model.Member;
|
||||||
|
import com.bb.model.PlayParam;
|
||||||
|
import com.bb.service.CallBackService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.AesUtil;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("/api/cb/pbomb")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@SecurityRequirement(name = "Authorization")
|
||||||
|
public class CallBackBombController {
|
||||||
|
|
||||||
|
// https://oprvender.com/api/cb/live
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final JwtManager jwtManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CallBackService callBackService;
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value = "/loginAuth", method = RequestMethod.POST)
|
||||||
|
public BombReponseVo minegameLoginAuth(@RequestBody BombAuthVO bombAuthVO, HttpServletRequest request)
|
||||||
|
throws Exception {
|
||||||
|
BombReponseVo bombReponseVo = new BombReponseVo();
|
||||||
|
log.info("#bomb::loginAuth::" + "bombAuthVO" + bombAuthVO.toString());
|
||||||
|
Gson gson = new Gson();
|
||||||
|
bombAuthVO = gson.fromJson(AesUtil.getAES128_Decode(bombAuthVO.getEp()), BombAuthVO.class);
|
||||||
|
log.info("#bomb::loginAuth::" + "dec bombAuthVO" + bombAuthVO.toString());
|
||||||
|
|
||||||
|
HashMap memParam = new HashMap();
|
||||||
|
memParam.put("bombAccId", bombAuthVO.getLoginToken());
|
||||||
|
|
||||||
|
Member member = siteService.getMemByBombAccId(memParam);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String accID = bombAuthVO.getAccID();
|
||||||
|
String token = bombAuthVO.getLoginToken();
|
||||||
|
|
||||||
|
log.info("#bomb::loginAuth::" + accID);
|
||||||
|
log.info("#bomb::loginAuth::" + token);
|
||||||
|
log.info("#bomb::loginAuth::" + member);
|
||||||
|
|
||||||
|
if (member.getBombAccId().equals(token)) {
|
||||||
|
|
||||||
|
log.info("#bomb::loginAuth::" + 1111111);
|
||||||
|
|
||||||
|
bombReponseVo.setAccId(accID);
|
||||||
|
bombReponseVo.setNickName(member.getMemberNick());
|
||||||
|
bombReponseVo.setCode(0);
|
||||||
|
bombReponseVo.setDemo(false);
|
||||||
|
|
||||||
|
// 밸런스 가져오기
|
||||||
|
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
// String[] usrinfo = accID.split("_");
|
||||||
|
|
||||||
|
// String memberId ="";
|
||||||
|
// String siteId ="";
|
||||||
|
sParam.put("siteIdx", Integer.parseInt(accID.substring(0, 3), 16));
|
||||||
|
sParam.put("memberId", accID.substring(3, accID.length()));
|
||||||
|
String memberId = accID.substring(3, accID.length());
|
||||||
|
|
||||||
|
HashMap siteApiInfo = siteService.getSiteApiInfo(sParam);
|
||||||
|
|
||||||
|
JSONObject parammember = new JSONObject();
|
||||||
|
parammember.put("userId", member.getMemberId());
|
||||||
|
|
||||||
|
// 밸런스가져오기
|
||||||
|
JSONObject resData = callBackService.getBalance(siteApiInfo, parammember);
|
||||||
|
if(resData == null) {
|
||||||
|
log.info("#bomb::debit::" + "balance callback error");
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
return bombReponseVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONObject resData = new JSONObject(responseEntity.getBody());
|
||||||
|
|
||||||
|
if (resData.getInt("result_code") == 0) {
|
||||||
|
|
||||||
|
if ("Y".equals(siteApiInfo.getOrDefault("bombDecYn", "").toString())) {
|
||||||
|
bombReponseVo.setBalance("" + (resData.getDouble("balance") * 0.01));
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setBalance("" + resData.getDouble("balance"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bombReponseVo.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bombReponseVo.fail();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
bombReponseVo.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("#bomb::loginAuth::" + "BOMB AUTH RESbody: {}", bombReponseVo);
|
||||||
|
return bombReponseVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value = "/bet", method = RequestMethod.POST)
|
||||||
|
public BombReponseVo minegameEncBet(@RequestBody BombAuthVO bombAuthVO, HttpServletRequest request)
|
||||||
|
throws Exception {
|
||||||
|
BombReponseVo bombReponseVo = new BombReponseVo();
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
bombAuthVO = gson.fromJson(AesUtil.getAES128_Decode(bombAuthVO.getEp()), BombAuthVO.class);
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
HashMap memParam = new HashMap();
|
||||||
|
memParam.put("bombAccId", bombAuthVO.getLoginToken());
|
||||||
|
Member member = siteService.getMemByBombAccId(memParam);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String accID = bombAuthVO.getAccID();
|
||||||
|
String userID = bombAuthVO.getUserID();
|
||||||
|
String token = bombAuthVO.getLoginToken();
|
||||||
|
String transferId = bombAuthVO.getTransferId();
|
||||||
|
Integer roomNo = bombAuthVO.getRoomNo();
|
||||||
|
double betAmount = (double) bombAuthVO.getAmount();
|
||||||
|
|
||||||
|
log.info("#bomb::debit::" + "bombgame bet accID : " + accID);
|
||||||
|
log.info("#bomb::debit::" + "bombgame bet userID : " + userID);
|
||||||
|
log.info("#bomb::debit::" + "bombgame bet token : " + token);
|
||||||
|
log.info("#bomb::debit::" + "bombgame bet roomNo : " + roomNo);
|
||||||
|
log.info("#bomb::debit::" + "bombgame bet transferId : " + transferId);
|
||||||
|
log.info("#bomb::debit::" + "bombgame bet betAmount : " + betAmount);
|
||||||
|
|
||||||
|
// 밸런스 가져오기
|
||||||
|
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
|
||||||
|
sParam.put("siteIdx", Integer.parseInt(accID.substring(0, 3), 16));
|
||||||
|
sParam.put("memberId", accID.substring(3, accID.length()));
|
||||||
|
String memberId = accID.substring(3, accID.length());
|
||||||
|
|
||||||
|
HashMap siteApiInfo = siteService.getSiteApiInfo(sParam);
|
||||||
|
String siteId = siteApiInfo.get("siteId").toString();
|
||||||
|
|
||||||
|
// 사이트에 크레딧이 없을경우 에러 보냄 베팅막음
|
||||||
|
long targetSiteCredit = siteService.getSiteCredit(siteId);
|
||||||
|
if (targetSiteCredit < betAmount) {
|
||||||
|
log.info("#bomb::debit::" + "no siteCredit");
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
return bombReponseVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 최대베팅액 (userMaxBet 우선 적용)
|
||||||
|
sParam.put("vendorIdx", 5);
|
||||||
|
long maxBet = siteService.getSiteMaxBet(sParam);
|
||||||
|
|
||||||
|
// userMaxBet 조회
|
||||||
|
long userMaxBet = 0;
|
||||||
|
Long userMaxBetObj = siteService.getUserMaxBet(sParam);
|
||||||
|
if(userMaxBetObj != null) {
|
||||||
|
userMaxBet = userMaxBetObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 최종 maxBet 결정: userMaxBet이 0이면 siteMaxBet 사용, 0이 아니면 userMaxBet 사용
|
||||||
|
long finalMaxBet = (userMaxBet > 0) ? userMaxBet : maxBet;
|
||||||
|
log.info("#bomb::debit::MaxBet Info - siteMaxBet: " + maxBet + ", userMaxBet: " + userMaxBet + ", finalMaxBet: " + finalMaxBet);
|
||||||
|
|
||||||
|
if (betAmount > finalMaxBet) {
|
||||||
|
log.info("#bomb::debit::" + "Over bet money - finalMaxBet: " + finalMaxBet);
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
return bombReponseVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject parammember = new JSONObject();
|
||||||
|
parammember.put("userId", member.getMemberId());
|
||||||
|
|
||||||
|
log.info("#bomb::debit::" + siteApiInfo);
|
||||||
|
JSONObject resData2 = callBackService.getBalance(siteApiInfo, parammember);
|
||||||
|
if(resData2 == null) {
|
||||||
|
log.info("#bomb::debit::" + "balance callback error");
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
return bombReponseVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resData2.getInt("result_code") == 0) {
|
||||||
|
|
||||||
|
if ("Y".equals(siteApiInfo.getOrDefault("bombDecYn", "").toString())) {
|
||||||
|
bombReponseVo.setBalance("" + (resData2.getDouble("balance") * 0.01));
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setBalance("" + resData2.getDouble("balance"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bombReponseVo.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (betAmount < 0) {
|
||||||
|
|
||||||
|
bombReponseVo.setCode(-99);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (member.getBombAccId().equals(token)) {
|
||||||
|
double curCashAmount = resData2.getDouble("balance");
|
||||||
|
|
||||||
|
if (curCashAmount >= betAmount) {
|
||||||
|
|
||||||
|
// betAmount 만큼 cashAmt 차감
|
||||||
|
// memberService.updateMineMemCashAmt(bombAuthVO);
|
||||||
|
|
||||||
|
HashMap tranParam = new HashMap();
|
||||||
|
tranParam.put("tranId", siteId + "D" + bombAuthVO.getTransferId());
|
||||||
|
tranParam.put("refId", siteId + bombAuthVO.getTransferId());
|
||||||
|
tranParam.put("siteIdx", siteApiInfo.get("siteIdx"));
|
||||||
|
|
||||||
|
tranParam.put("siteId", siteId);
|
||||||
|
|
||||||
|
tranParam.put("memberIdx", siteApiInfo.get("memberIdx"));
|
||||||
|
tranParam.put("memberId", memberId);
|
||||||
|
tranParam.put("vendorCetegory", "MINIGAME");
|
||||||
|
tranParam.put("vendorIdx", 5);
|
||||||
|
tranParam.put("vendorCode", "tpabomb");
|
||||||
|
tranParam.put("vendorTranKey", bombAuthVO.getTransferId());
|
||||||
|
tranParam.put("gameType", "");
|
||||||
|
tranParam.put("gameId", "");
|
||||||
|
tranParam.put("gameIdx", ""+roomNo);
|
||||||
|
tranParam.put("tranType", "debit");
|
||||||
|
tranParam.put("depositAmt", betAmount);
|
||||||
|
tranParam.put("creditAmt", "0");
|
||||||
|
tranParam.put("isCancel", "N");
|
||||||
|
tranParam.put("isTie", "N");
|
||||||
|
tranParam.put("apiStatus", 0);
|
||||||
|
tranParam.put("completed", false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommonParam commonParam = new CommonParam();
|
||||||
|
commonParam.setSiteIdx(Integer.parseInt(siteApiInfo.get("siteIdx").toString()));
|
||||||
|
PlayParam param = new PlayParam();
|
||||||
|
param.setVendorKey("M01");
|
||||||
|
commonParam.setPlayParam(param);
|
||||||
|
HashMap venderInfo = siteService.getVenderApiInfo(commonParam);
|
||||||
|
tranParam.put("vendorApiId", venderInfo.get("vendorApiId").toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("#bomb::debit::" + "VI ERR:" + e.toString());
|
||||||
|
}
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject debit = new JSONObject();
|
||||||
|
debit.put("betId", siteId + bombAuthVO.getTransferId());
|
||||||
|
debit.put("tranId", siteId + "D" + bombAuthVO.getTransferId());
|
||||||
|
debit.put("userId", memberId);
|
||||||
|
debit.put("vendorIdx", 5);
|
||||||
|
debit.put("vendorKey", "M01");
|
||||||
|
debit.put("vendor", "tpabomb");
|
||||||
|
debit.put("gameIdx", 1);
|
||||||
|
debit.put("gameKey", ""+roomNo);
|
||||||
|
debit.put("gameId", "");
|
||||||
|
debit.put("gameType", "");
|
||||||
|
debit.put("tranType", "debit");
|
||||||
|
|
||||||
|
if ("Y".equals(siteApiInfo.getOrDefault("bombDecYn", "").toString())) {
|
||||||
|
Double betAmountD = betAmount * 100;
|
||||||
|
debit.put("debit", betAmountD.longValue());
|
||||||
|
} else {
|
||||||
|
debit.put("debit", betAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
debit.put("credit", 0);
|
||||||
|
debit.put("isCancel", 0);
|
||||||
|
debit.put("isBonus", 0);
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
|
long nDate = System.currentTimeMillis();
|
||||||
|
String betDateTimeStr = sdf.format(nDate);
|
||||||
|
debit.put("requestAt", betDateTimeStr);
|
||||||
|
|
||||||
|
JSONObject resData = callBackService.changeBalance("#bomb::", siteApiInfo, debit);
|
||||||
|
|
||||||
|
log.info("#bomb::debit::" + "result_Dcode: {}", resData.getInt("result_code"));
|
||||||
|
|
||||||
|
if (resData.getLong("result_code") == 0) {
|
||||||
|
bombReponseVo.setCode(0);
|
||||||
|
bombReponseVo.setBalance("" + resData.getDouble("balance"));
|
||||||
|
|
||||||
|
if ("Y".equals(siteApiInfo.getOrDefault("bombDecYn", "").toString())) {
|
||||||
|
bombReponseVo.setBalance("" + (resData.getDouble("balance") * 0.01));
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setBalance("" + resData.getDouble("balance"));
|
||||||
|
}
|
||||||
|
|
||||||
|
tranParam.put("balance", bombReponseVo.getBalance());
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
log.info("#bomb::debit::" + "result_Dcode: {}2");
|
||||||
|
|
||||||
|
} else if (resData.getLong("result_code") == 80) {
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
|
||||||
|
} else if (resData.getLong("result_code") == 98) {
|
||||||
|
log.info("#bomb::debit::" + "result_Dcode 98: {}1");
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
obj.put("code", -1);
|
||||||
|
log.info("#bomb::debit::" + "bombgame info curr cash : " + curCashAmount + ", reqest : "
|
||||||
|
+ betAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setCode(-99);
|
||||||
|
log.info("#bomb::debit::" + "bombgame info token : " + member.getBombAccId() + ", reqest : "
|
||||||
|
+ token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
log.info("#bomb::debit::" + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bombReponseVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value = { "/payout", "/end" }, method = RequestMethod.POST)
|
||||||
|
public BombReponseVo minegameEncCredit(@RequestBody BombAuthVO bombAuthVO, HttpServletRequest request)
|
||||||
|
throws Exception {
|
||||||
|
BombReponseVo bombReponseVo = new BombReponseVo();
|
||||||
|
log.info("#bomb::credit::" + "bombAuthVO" + bombAuthVO.toString());
|
||||||
|
Gson gson = new Gson();
|
||||||
|
bombAuthVO = gson.fromJson(AesUtil.getAES128_Decode(bombAuthVO.getEp()), BombAuthVO.class);
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
HashMap memParam = new HashMap();
|
||||||
|
memParam.put("bombAccId", bombAuthVO.getLoginToken());
|
||||||
|
Member member = siteService.getMemByBombAccId(memParam);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String accID = bombAuthVO.getAccID();
|
||||||
|
String userID = bombAuthVO.getUserID();
|
||||||
|
String token = bombAuthVO.getLoginToken();
|
||||||
|
String transferId = bombAuthVO.getTransferId();
|
||||||
|
Integer roomNo = bombAuthVO.getRoomNo();
|
||||||
|
double betAmount = (double) bombAuthVO.getAmount();
|
||||||
|
|
||||||
|
String bombs = bombAuthVO.getBombs();
|
||||||
|
String play = bombAuthVO.getPlay();
|
||||||
|
String endDate = bombAuthVO.getEndDate();
|
||||||
|
|
||||||
|
log.info("#bomb::credit::" + "bombgame bet accID : " + accID);
|
||||||
|
log.info("#bomb::credit::" + "bombgame bet userID : " + userID);
|
||||||
|
log.info("#bomb::credit::" + "bombgame bet token : " + token);
|
||||||
|
log.info("#bomb::credit::" + "bombgame bet roomNo : " + roomNo);
|
||||||
|
log.info("#bomb::credit::" + "bombgame bet transferId : " + transferId);
|
||||||
|
log.info("#bomb::credit::" + "bombgame bet betAmount : " + betAmount);
|
||||||
|
|
||||||
|
log.info("#bomb::credit::" + "bombgame bet bombs : " + bombs);
|
||||||
|
log.info("#bomb::credit::" + "bombgame bet play : " + play);
|
||||||
|
|
||||||
|
// 밸런스 가져오기
|
||||||
|
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
sParam.put("siteIdx", Integer.parseInt(accID.substring(0, 3), 16));
|
||||||
|
sParam.put("memberId", accID.substring(3, accID.length()));
|
||||||
|
String memberId = accID.substring(3, accID.length());
|
||||||
|
|
||||||
|
HashMap siteApiInfo = siteService.getSiteApiInfo(sParam);
|
||||||
|
String siteId = siteApiInfo.get("siteId").toString();
|
||||||
|
|
||||||
|
JSONObject parammember = new JSONObject();
|
||||||
|
parammember.put("userId", member.getMemberId());
|
||||||
|
|
||||||
|
JSONObject resData2 = callBackService.getBalance(siteApiInfo, parammember);
|
||||||
|
if(resData2 == null) {
|
||||||
|
log.info("#bomb::credit::" + "balance callback error");
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
return bombReponseVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resData2.getInt("result_code") == 0) {
|
||||||
|
|
||||||
|
if ("Y".equals(siteApiInfo.getOrDefault("bombDecYn", "").toString())) {
|
||||||
|
bombReponseVo.setBalance("" + (resData2.getDouble("balance") * 0.01));
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setBalance("" + resData2.getDouble("balance"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bombReponseVo.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (betAmount < 0) {
|
||||||
|
|
||||||
|
bombReponseVo.setCode(-99);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (member.getBombAccId().equals(token)) {
|
||||||
|
double curCashAmount = resData2.getDouble("balance");
|
||||||
|
|
||||||
|
if (betAmount >= 0) {
|
||||||
|
|
||||||
|
// betAmount 만큼 cashAmt 차감
|
||||||
|
// memberService.updateMineMemCashAmt(bombAuthVO);
|
||||||
|
|
||||||
|
HashMap tranParam = new HashMap();
|
||||||
|
tranParam.put("tranId", siteId + "C" + bombAuthVO.getTransferId());
|
||||||
|
tranParam.put("refId", siteId + bombAuthVO.getTransferId());
|
||||||
|
tranParam.put("siteIdx", siteApiInfo.get("siteIdx"));
|
||||||
|
|
||||||
|
tranParam.put("siteId", siteId);
|
||||||
|
|
||||||
|
tranParam.put("memberIdx", siteApiInfo.get("memberIdx"));
|
||||||
|
tranParam.put("memberId", memberId);
|
||||||
|
tranParam.put("vendorCetegory", "MINIGAME");
|
||||||
|
tranParam.put("vendorIdx", 5);
|
||||||
|
tranParam.put("vendorCode", "tpabomb");
|
||||||
|
tranParam.put("vendorTranKey", bombAuthVO.getTransferId());
|
||||||
|
tranParam.put("gameType", "");
|
||||||
|
tranParam.put("gameId", "");
|
||||||
|
tranParam.put("gameIdx", ""+roomNo);
|
||||||
|
tranParam.put("tranType", "credit");
|
||||||
|
tranParam.put("depositAmt", 0);
|
||||||
|
tranParam.put("creditAmt", betAmount);
|
||||||
|
tranParam.put("isCancel", "N");
|
||||||
|
tranParam.put("isTie", "N");
|
||||||
|
tranParam.put("apiStatus", 0);
|
||||||
|
|
||||||
|
tranParam.put("completed", true);
|
||||||
|
|
||||||
|
// 게임별로 상세내역 넣어주기 있을 경우에만
|
||||||
|
JSONObject detail = new JSONObject();
|
||||||
|
|
||||||
|
detail.put("roomNo ", roomNo);
|
||||||
|
detail.put("play", play);
|
||||||
|
detail.put("bombs", bombs);
|
||||||
|
tranParam.put("detail", detail.toString());
|
||||||
|
|
||||||
|
try {
|
||||||
|
CommonParam commonParam = new CommonParam();
|
||||||
|
commonParam.setSiteIdx(Integer.parseInt(siteApiInfo.get("siteIdx").toString()));
|
||||||
|
PlayParam param = new PlayParam();
|
||||||
|
param.setVendorKey("M01");
|
||||||
|
commonParam.setPlayParam(param);
|
||||||
|
HashMap venderInfo = siteService.getVenderApiInfo(commonParam);
|
||||||
|
tranParam.put("vendorApiId", venderInfo.get("vendorApiId").toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("#bomb::credit::" + "VI ERR:" + e.toString());
|
||||||
|
}
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
JSONObject debit = new JSONObject();
|
||||||
|
|
||||||
|
debit.put("betId", siteId + bombAuthVO.getTransferId());
|
||||||
|
debit.put("tranId", siteId + "C" + bombAuthVO.getTransferId());
|
||||||
|
debit.put("userId", memberId);
|
||||||
|
debit.put("vendorIdx", 5);
|
||||||
|
debit.put("vendorKey", "M01");
|
||||||
|
debit.put("vendor", "tpabomb");
|
||||||
|
debit.put("gameIdx", 1);
|
||||||
|
debit.put("gameKey", roomNo);
|
||||||
|
debit.put("gameId", "");
|
||||||
|
debit.put("gameType", "");
|
||||||
|
debit.put("tranType", "credit");
|
||||||
|
debit.put("debit", 0);
|
||||||
|
|
||||||
|
if ("Y".equals(siteApiInfo.getOrDefault("bombDecYn", "").toString())) {
|
||||||
|
Double betAmountD = betAmount * 100;
|
||||||
|
debit.put("credit", betAmountD.longValue());
|
||||||
|
} else {
|
||||||
|
|
||||||
|
debit.put("credit", betAmount);
|
||||||
|
}
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
|
long nDate = System.currentTimeMillis();
|
||||||
|
String betDateTimeStr = sdf.format(nDate);
|
||||||
|
debit.put("requestAt", betDateTimeStr);
|
||||||
|
debit.put("isCancel", 0);
|
||||||
|
debit.put("isBonus", 0);
|
||||||
|
debit.put("detail", detail);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject resData = callBackService.changeBalance("#bomb::", siteApiInfo, debit);
|
||||||
|
log.info("#bomb::credit::" + "result_Dcode: {}", resData.getInt("result_code"));
|
||||||
|
|
||||||
|
if (resData.getLong("result_code") == 0) {
|
||||||
|
|
||||||
|
bombReponseVo.setCode(0);
|
||||||
|
|
||||||
|
if ("Y".equals(siteApiInfo.getOrDefault("bombDecYn", "").toString())) {
|
||||||
|
bombReponseVo.setBalance("" + (resData.getDouble("balance") * 0.01));
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setBalance("" + resData.getDouble("balance"));
|
||||||
|
}
|
||||||
|
|
||||||
|
tranParam.put("balance", bombReponseVo.getBalance());
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
log.info("#bomb::debit::" + "result_Dcode: {}2");
|
||||||
|
|
||||||
|
} else if (resData.getLong("result_code") == 80) {
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
|
||||||
|
} else if (resData.getLong("result_code") == 98) {
|
||||||
|
log.info("#bomb::credit::" + "result_Dcode 98: {}1");
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
obj.put("code", -1);
|
||||||
|
log.info("#bomb::credit::" + "bombgame info curr cash : " + curCashAmount + ", reqest : "
|
||||||
|
+ betAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setCode(-99);
|
||||||
|
log.info("#bomb::credit::" + "bombgame info token : " + member.getBombAccId() + ", reqest : "
|
||||||
|
+ token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
bombReponseVo.setCode(-1);
|
||||||
|
log.info("#bomb::credit::" + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bombReponseVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
159
src/main/java/com/bb/front/CallBackBombDemoController.java
Normal file
159
src/main/java/com/bb/front/CallBackBombDemoController.java
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
package com.bb.front;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.bb.jwt.JwtManager;
|
||||||
|
import com.bb.model.BombAuthVO;
|
||||||
|
import com.bb.model.BombReponseVo;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.bb.util.AesUtil;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("/api/cb/demopbomb")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@SecurityRequirement(name = "Authorization")
|
||||||
|
public class CallBackBombDemoController {
|
||||||
|
|
||||||
|
// https://oprvender.com/api/cb/live
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private final JwtManager jwtManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value="/loginAuth", method=RequestMethod.POST)
|
||||||
|
public BombReponseVo minegameLoginAuth(@RequestBody BombAuthVO bombAuthVO, HttpServletRequest request) throws Exception {
|
||||||
|
BombReponseVo bombReponseVo = new BombReponseVo();
|
||||||
|
System.out.println("bombAuthVO" + bombAuthVO.toString());
|
||||||
|
Gson gson = new Gson();
|
||||||
|
bombAuthVO = gson.fromJson(AesUtil.getAES128_Decode(bombAuthVO.getEp()), BombAuthVO.class);
|
||||||
|
System.out.println("dec bombAuthVO" + bombAuthVO.toString());
|
||||||
|
|
||||||
|
|
||||||
|
HashMap memParam = new HashMap();
|
||||||
|
memParam.put("bombAccId", bombAuthVO.getLoginToken());
|
||||||
|
HashMap demomember = siteService.getDemoByBombAccId(memParam);
|
||||||
|
|
||||||
|
try {
|
||||||
|
String accID = bombAuthVO.getAccID();
|
||||||
|
String token= bombAuthVO.getLoginToken();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(demomember.get("bombAccId").toString().equals(token)) {
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(1111111);
|
||||||
|
|
||||||
|
|
||||||
|
bombReponseVo.setAccId(accID);
|
||||||
|
bombReponseVo.setNickName( demomember.get("bombAccId").toString());
|
||||||
|
bombReponseVo.setCode(0);
|
||||||
|
bombReponseVo.setBalance(""+(Double.parseDouble(demomember.get("creditAmt").toString())));
|
||||||
|
bombReponseVo.setDemo(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
bombReponseVo.fail();
|
||||||
|
}
|
||||||
|
}catch(Exception e) {
|
||||||
|
bombReponseVo.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("BOMB AUTH RESbody: {}", bombReponseVo);
|
||||||
|
return bombReponseVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value="/bet", method=RequestMethod.POST)
|
||||||
|
public BombReponseVo minegameEncBet(@RequestBody BombAuthVO bombAuthVO, HttpServletRequest request) throws Exception {
|
||||||
|
BombReponseVo bombReponseVo = new BombReponseVo();
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
bombAuthVO = gson.fromJson(AesUtil.getAES128_Decode(bombAuthVO.getEp()), BombAuthVO.class);
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HashMap memParam = new HashMap();
|
||||||
|
memParam.put("bombAccId", bombAuthVO.getLoginToken());
|
||||||
|
HashMap demomember = siteService.getDemoByBombAccId(memParam);
|
||||||
|
double balance = Double.parseDouble(demomember.get("creditAmt").toString());
|
||||||
|
double betAmount = (double)bombAuthVO.getAmount();
|
||||||
|
log.warn("DEMO BALANCE memINFO {} {} ", demomember.toString(), betAmount);
|
||||||
|
if(balance < balance - betAmount) {
|
||||||
|
|
||||||
|
bombReponseVo.setCode(-99);
|
||||||
|
return bombReponseVo;
|
||||||
|
} else {
|
||||||
|
bombReponseVo.setBalance("" +( balance - betAmount));
|
||||||
|
memParam.put("creditAmt", "" +( balance - betAmount));
|
||||||
|
siteService.updateDemoUSer(memParam);
|
||||||
|
}
|
||||||
|
log.warn("DEMO BALANCE memParam {}", memParam.toString());
|
||||||
|
|
||||||
|
return bombReponseVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(value={"/payout", "/end"}, method=RequestMethod.POST)
|
||||||
|
public BombReponseVo minegameEncCredit(@RequestBody BombAuthVO bombAuthVO, HttpServletRequest request) throws Exception {
|
||||||
|
BombReponseVo bombReponseVo = new BombReponseVo();
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
bombAuthVO = gson.fromJson(AesUtil.getAES128_Decode(bombAuthVO.getEp()), BombAuthVO.class);
|
||||||
|
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HashMap memParam = new HashMap();
|
||||||
|
memParam.put("bombAccId", bombAuthVO.getLoginToken());
|
||||||
|
HashMap demomember = siteService.getDemoByBombAccId(memParam);
|
||||||
|
|
||||||
|
double balance = Double.parseDouble(demomember.get("creditAmt").toString());
|
||||||
|
double betAmount = (double)bombAuthVO.getAmount();
|
||||||
|
log.warn("DEMO BALANCE memINFO {} {} ", demomember.toString(), betAmount);
|
||||||
|
bombReponseVo.setBalance("" +( balance + betAmount));
|
||||||
|
memParam.put("creditAmt", "" +( balance + betAmount));
|
||||||
|
siteService.updateDemoUSer(memParam);
|
||||||
|
log.warn("DEMO BALANCE memParam {}", memParam.toString());
|
||||||
|
return bombReponseVo;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
1682
src/main/java/com/bb/front/CallBackBtiController.java
Normal file
1682
src/main/java/com/bb/front/CallBackBtiController.java
Normal file
File diff suppressed because it is too large
Load Diff
1286
src/main/java/com/bb/front/CallBackDpcoreController.java
Normal file
1286
src/main/java/com/bb/front/CallBackDpcoreController.java
Normal file
File diff suppressed because it is too large
Load Diff
1684
src/main/java/com/bb/front/CallBackNexusController.java
Normal file
1684
src/main/java/com/bb/front/CallBackNexusController.java
Normal file
File diff suppressed because it is too large
Load Diff
973
src/main/java/com/bb/front/CallBackOnixController.java
Normal file
973
src/main/java/com/bb/front/CallBackOnixController.java
Normal file
@@ -0,0 +1,973 @@
|
|||||||
|
package com.bb.front;
|
||||||
|
|
||||||
|
import java.net.SocketTimeoutException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.apache.http.conn.ConnectTimeoutException;
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
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.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.client.ResourceAccessException;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import com.bb.model.OnixResponse;
|
||||||
|
import com.bb.service.AsyncSiteService;
|
||||||
|
import com.bb.service.CallBackService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
/**
|
||||||
|
* Onix Seamless API Callback Controller
|
||||||
|
*
|
||||||
|
* API 엔드포인트:
|
||||||
|
* - /balance: 유저 잔고 조회
|
||||||
|
* - /changeBalance: 유저 머니 변경 (베팅, 승리, 취소 등)
|
||||||
|
*
|
||||||
|
* 모든 응답은 2초 이내로 반환되어야 함
|
||||||
|
* CORS 헤더 필수: Access-Control-Allow-Origin: *
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@SecurityRequirement(name = "Authorization")
|
||||||
|
@EnableScheduling
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/callback/onix")
|
||||||
|
public class CallBackOnixController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CallBackService callBackService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsyncSiteService asyncCallBackService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
RestTemplate restTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(path = {"/balance", "/balance/"})
|
||||||
|
public ResponseEntity<OnixResponse> balance(HttpServletRequest request, @RequestParam("userid") String onixUsername) throws Exception {
|
||||||
|
OnixResponse response = null;
|
||||||
|
|
||||||
|
long siteIdx = Long.parseLong(onixUsername.substring(0, 3), 16);
|
||||||
|
String memberId = onixUsername.substring(3, onixUsername.length());
|
||||||
|
final String LOG_PREFIX = "#-CB::ONIX::balance::"+memberId+":::";
|
||||||
|
log.info(LOG_PREFIX+ "Request::" + onixUsername);
|
||||||
|
|
||||||
|
try {
|
||||||
|
//사이트정보
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
sParam.put("siteIdx", siteIdx);
|
||||||
|
sParam.put("memberId", memberId);
|
||||||
|
log.info(LOG_PREFIX + "SITE_API_INFO_PARAM::"+sParam.toString());
|
||||||
|
HashMap siteApiInfo = siteService.getSiteApiInfo(sParam);
|
||||||
|
if(siteApiInfo == null) {
|
||||||
|
log.error(LOG_PREFIX+ "Error Msg: NOT_FOUND_SITE_INFO");
|
||||||
|
response = new OnixResponse();
|
||||||
|
response.setResult(0);
|
||||||
|
response.setBalance(0);
|
||||||
|
return new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(siteApiInfo.get("memberIdx") == null) {
|
||||||
|
log.error(LOG_PREFIX+ "존재하지 않는 회원");
|
||||||
|
response = new OnixResponse();
|
||||||
|
response.setResult(0);
|
||||||
|
response.setBalance(0);
|
||||||
|
return new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ##--isTransfer 처리-##
|
||||||
|
long balance = 0L;
|
||||||
|
if("N".equals(siteApiInfo.get("isTransfer").toString())) {
|
||||||
|
log.info(LOG_PREFIX + "PLAY_SEAMLESS");
|
||||||
|
JSONObject member = new JSONObject();
|
||||||
|
member.put("userId", memberId);
|
||||||
|
log.info(LOG_PREFIX+ "balance Req ::"+ member.toString());
|
||||||
|
JSONObject resData = callBackService.getBalance(siteApiInfo, member);
|
||||||
|
if(resData == null) {
|
||||||
|
log.error(LOG_PREFIX+ "Error Msg: BALANCE_CALLBACK_ERROR");
|
||||||
|
response = new OnixResponse();
|
||||||
|
response.setResult(0);
|
||||||
|
response.setBalance(0);
|
||||||
|
return new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
log.info(LOG_PREFIX+ "balance Res ::"+ resData.toString());
|
||||||
|
balance = resData.getLong("balance"); // int -> long 변경
|
||||||
|
} else {
|
||||||
|
log.info(LOG_PREFIX + "PLAY_TRANSFER");
|
||||||
|
HashMap balanceMap = new HashMap<>();
|
||||||
|
balanceMap.put("siteIdx", siteIdx);
|
||||||
|
balanceMap.put("memberId", memberId);
|
||||||
|
balance = siteService.getUserBalance(balanceMap);
|
||||||
|
|
||||||
|
if(siteApiInfo.get("siteCbUrl") != null && !"".equals(siteApiInfo.get("siteCbUrl").toString())) {
|
||||||
|
JSONObject member = new JSONObject();
|
||||||
|
member.put("userId", memberId);
|
||||||
|
member.put("balance", balance);
|
||||||
|
asyncCallBackService.asyncBalance(LOG_PREFIX, siteApiInfo, member);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Onix 문서: {"result":1, "balance": 10000} 형식으로 응답
|
||||||
|
response = new OnixResponse();
|
||||||
|
response.setResult(1); // 성공 = 1
|
||||||
|
response.setBalance(balance);
|
||||||
|
|
||||||
|
} catch (ResourceAccessException rae) {
|
||||||
|
if(rae.getCause() instanceof ConnectTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "[ConnectTimeoutException]"+rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rae.getCause() instanceof SocketTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "[SocketTimeoutException]"+rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error(LOG_PREFIX+ "[InterruptedException]"+rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
response = new OnixResponse();
|
||||||
|
response.setResult(0);
|
||||||
|
response.setBalance(0);
|
||||||
|
return new ResponseEntity<OnixResponse>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(LOG_PREFIX+ "[Exception]"+e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
response = new OnixResponse();
|
||||||
|
response.setResult(0);
|
||||||
|
response.setBalance(0);
|
||||||
|
return new ResponseEntity<OnixResponse>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResponseEntity<OnixResponse> res = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
log.info(LOG_PREFIX+ "Response::" + response.toString());
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(path = {"/changeBalance", "/changeBalance/"})
|
||||||
|
public ResponseEntity<OnixResponse> changeBalance(HttpServletRequest request, @RequestBody net.sf.json.JSONObject requestBody) {
|
||||||
|
|
||||||
|
ResponseEntity<OnixResponse> resEntity = null;
|
||||||
|
log.info("#-CB::ONIX::changeBalance::Request::" + requestBody.toString());
|
||||||
|
|
||||||
|
String onixUsername = requestBody.getString("userid");
|
||||||
|
long siteIdx = Long.parseLong(onixUsername.substring(0, 3), 16);
|
||||||
|
String memberId = onixUsername.substring(3, onixUsername.length());
|
||||||
|
String transactionId = requestBody.getString("tranid");
|
||||||
|
String transactionType = requestBody.getString("type");
|
||||||
|
|
||||||
|
final String LOG_PREFIX = "#-CB::ONIX::changeBalance::"+memberId+"::"+transactionId+"::"+transactionType+":::";
|
||||||
|
log.info(LOG_PREFIX+ "Request::" + requestBody.toString());
|
||||||
|
|
||||||
|
try {
|
||||||
|
// "time":"2023-07-05 21:16:39.473"
|
||||||
|
String betDateTimeStr = requestBody.getString("time");
|
||||||
|
log.info(LOG_PREFIX+ "========== BF_betDateTimeStr::" + betDateTimeStr);
|
||||||
|
betDateTimeStr = betDateTimeStr.substring(0, 19);
|
||||||
|
betDateTimeStr = betDateTimeStr.replace("T", " ");
|
||||||
|
//log.info(LOG_PREFIX+ "========== MF_betDateTimeStr::" + betDateTimeStr);
|
||||||
|
//betDateTimeStr = makeEdate(LOG_PREFIX, betDateTimeStr, 32400000);
|
||||||
|
log.info(LOG_PREFIX+ "========== AF_betDateTimeStr::" + betDateTimeStr);
|
||||||
|
|
||||||
|
// 사이트 정보 조회
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
sParam.put("siteIdx", siteIdx);
|
||||||
|
sParam.put("memberId", memberId);
|
||||||
|
sParam.put("vendor", "onix");
|
||||||
|
sParam.put("vendorGameCode", "evolution");
|
||||||
|
log.info(LOG_PREFIX + "getSiteVendorInfo::" + sParam.toString());
|
||||||
|
HashMap<String, String> siteVendorInfo = siteService.getSiteVendorInfo(sParam);
|
||||||
|
|
||||||
|
if(siteVendorInfo == null) {
|
||||||
|
log.error(LOG_PREFIX + "존재하지 않는 회원입니다");
|
||||||
|
OnixResponse response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(transactionType.equals("bet")) {
|
||||||
|
int amount = Math.abs(requestBody.getInt("amount"));
|
||||||
|
resEntity = callBet(LOG_PREFIX, siteIdx, memberId, requestBody, betDateTimeStr, siteVendorInfo, amount);
|
||||||
|
|
||||||
|
} else if(transactionType.equals("win") || transactionType.equals("lose")) {
|
||||||
|
int amount = Math.abs(requestBody.getInt("amount"));
|
||||||
|
resEntity = callWin(LOG_PREFIX, siteIdx, memberId, requestBody, betDateTimeStr, siteVendorInfo, amount);
|
||||||
|
|
||||||
|
} else if(transactionType.equals("cancel")) {
|
||||||
|
int amount = Math.abs(requestBody.getInt("amount"));
|
||||||
|
resEntity = callCancel(LOG_PREFIX, siteIdx, memberId, requestBody, betDateTimeStr, siteVendorInfo, amount);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log.error(LOG_PREFIX + "unknown_transaction_type");
|
||||||
|
OnixResponse response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ResourceAccessException rae) {
|
||||||
|
if (rae.getCause() instanceof ConnectTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX + "[ConnectTimeoutException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if (rae.getCause() instanceof SocketTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX + "[SocketTimeoutException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if (rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error(LOG_PREFIX + "[InterruptedException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
OnixResponse response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
return resEntity;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(LOG_PREFIX + "[Exception]" + e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
OnixResponse response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "Response::" + resEntity.toString());
|
||||||
|
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ResponseEntity<OnixResponse> callBet(String LOG_PREFIX, long siteIdx, String memberId,
|
||||||
|
net.sf.json.JSONObject transaction, String betDateTimeStr, HashMap<String, String> siteVendorInfo, int amount) {
|
||||||
|
|
||||||
|
LOG_PREFIX = LOG_PREFIX + "callBet:::";
|
||||||
|
ResponseEntity<OnixResponse> resEntity = null;
|
||||||
|
OnixResponse response = new OnixResponse();
|
||||||
|
|
||||||
|
// ##--isTransfer 처리-##
|
||||||
|
final String IS_TRANSFER = siteVendorInfo.get("isTransfer").toString();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
String gameType = ""; // transaction.optString("gametype");
|
||||||
|
String gameName = transaction.optString("title");
|
||||||
|
|
||||||
|
String tableId = transaction.optString("subcode");
|
||||||
|
String targetTableId = tableId.replaceAll(" ", "").toLowerCase();
|
||||||
|
|
||||||
|
String banGameType = siteVendorInfo.get("banGameType").toString().replaceAll(" ", "").toLowerCase();
|
||||||
|
String banGameId = siteVendorInfo.get("banGameId").toString().replaceAll(" ", "").toLowerCase();
|
||||||
|
|
||||||
|
if (!"".equals(gameType) && !"".equals(banGameType) && banGameType.contains(gameType + "|")) {
|
||||||
|
log.error(LOG_PREFIX + "Ban Game Type : " + gameType);
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!"".equals(targetTableId) && !"".equals(banGameId) && banGameId.contains(targetTableId + "|")) {
|
||||||
|
log.error(LOG_PREFIX + "Ban Game Id : " + banGameId);
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
String siteId = siteVendorInfo.get("siteId").toString();
|
||||||
|
long memberIdx = Long.parseLong(siteVendorInfo.get("memberIdx").toString());
|
||||||
|
String vendorApiId = siteVendorInfo.get("vendorApiId").toString();
|
||||||
|
|
||||||
|
String tranId = transaction.getString("tranid");
|
||||||
|
String betId = transaction.getString("realround");
|
||||||
|
String betKey = betId;
|
||||||
|
String vendorKey = siteVendorInfo.get("vendorKey").toString();
|
||||||
|
int vendorIdx = Integer.parseInt(siteVendorInfo.get("vendorIdx").toString());
|
||||||
|
String vendorCetegory = siteVendorInfo.get("vendorCetegory").toString();
|
||||||
|
|
||||||
|
// ##--isTransfer 처리-##
|
||||||
|
if(IS_TRANSFER.equals("Y")) {
|
||||||
|
// tranId 중복체크
|
||||||
|
int cntTr = siteService.getTranIdCheck2(tranId);
|
||||||
|
if(cntTr > 0) {
|
||||||
|
HashMap balanceMap = new HashMap<>();
|
||||||
|
balanceMap.put("siteIdx", siteIdx);
|
||||||
|
balanceMap.put("memberId", memberId);
|
||||||
|
int balance = siteService.getUserBalance(balanceMap);
|
||||||
|
log.error(LOG_PREFIX+ "중복요청::Response::" + response.toString());
|
||||||
|
response = OnixResponse.success(balance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (siteVendorInfo.get("lastInVendorIdx") == null || "0".equals(siteVendorInfo.get("lastInVendorIdx").toString())) {
|
||||||
|
HashMap memParam = new HashMap<>();
|
||||||
|
memParam.put("siteIdx", siteIdx);
|
||||||
|
memParam.put("memberIdx", memberIdx);
|
||||||
|
memParam.put("lastInVendorIdx", Integer.parseInt(siteVendorInfo.get("vendorIdx").toString()));
|
||||||
|
int updResult = siteService.updMemLastVendorIdx(memParam);
|
||||||
|
} else {
|
||||||
|
int lastInVendorIdx = Integer.parseInt(siteVendorInfo.get("lastInVendorIdx").toString());
|
||||||
|
if (lastInVendorIdx != vendorIdx) {
|
||||||
|
log.error(LOG_PREFIX + "VendorIdx doesn't match");
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long siteCredit = Long.parseLong(siteVendorInfo.get("credit").toString());
|
||||||
|
// ##--isTransfer 처리-##
|
||||||
|
if (siteCredit < amount && IS_TRANSFER.equals("N")) {
|
||||||
|
log.error(LOG_PREFIX + "NO_SITE_CREDIT");
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 최대 베팅 금액 처리 (userMaxBet 우선 적용)
|
||||||
|
long siteMaxBet = Long.parseLong(siteVendorInfo.get("siteMaxBet").toString());
|
||||||
|
long userMaxBet = 0;
|
||||||
|
if(siteVendorInfo.get("userMaxBet") != null && !siteVendorInfo.get("userMaxBet").toString().isEmpty()) {
|
||||||
|
try {
|
||||||
|
userMaxBet = Long.parseLong(siteVendorInfo.get("userMaxBet").toString());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
userMaxBet = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 최종 maxBet 결정: userMaxBet이 0이면 siteMaxBet 사용, 0이 아니면 userMaxBet 사용
|
||||||
|
long finalMaxBet = (userMaxBet > 0) ? userMaxBet : siteMaxBet;
|
||||||
|
log.info(LOG_PREFIX+ "MaxBet Info - siteMaxBet: " + siteMaxBet + ", userMaxBet: " + userMaxBet + ", finalMaxBet: " + finalMaxBet);
|
||||||
|
|
||||||
|
if (finalMaxBet < amount) {
|
||||||
|
log.error(LOG_PREFIX + "MAX_BET_AMOUNT_OVER");
|
||||||
|
log.error(LOG_PREFIX + "finalMaxBet : " + finalMaxBet + ", amount : " + amount);
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isParsing = false;
|
||||||
|
String game = transaction.optString("game");
|
||||||
|
if("evolution_new".equals(game)) {
|
||||||
|
isParsing = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap tranParam = new HashMap();
|
||||||
|
tranParam.put("tranId", tranId);
|
||||||
|
tranParam.put("refId", betId);
|
||||||
|
tranParam.put("siteIdx", siteIdx);
|
||||||
|
tranParam.put("siteId", siteId);
|
||||||
|
tranParam.put("memberIdx", memberIdx);
|
||||||
|
tranParam.put("memberId", memberId);
|
||||||
|
tranParam.put("vendorCetegory", vendorCetegory);
|
||||||
|
tranParam.put("vendorIdx", vendorIdx);
|
||||||
|
tranParam.put("vendorCode", "onix");
|
||||||
|
tranParam.put("vendorTranKey", betKey);
|
||||||
|
tranParam.put("gameType", gameType);
|
||||||
|
tranParam.put("gameId", tableId);
|
||||||
|
tranParam.put("gameIdx", gameName);
|
||||||
|
tranParam.put("tranType", "debit");
|
||||||
|
tranParam.put("depositAmt", amount);
|
||||||
|
tranParam.put("creditAmt", "0");
|
||||||
|
tranParam.put("isCancel", "N");
|
||||||
|
if(isParsing) {
|
||||||
|
tranParam.put("isTie", "P");
|
||||||
|
} else {
|
||||||
|
tranParam.put("isTie", "N");
|
||||||
|
}
|
||||||
|
tranParam.put("apiStatus", 0);
|
||||||
|
tranParam.put("vendorApiId", vendorApiId);
|
||||||
|
|
||||||
|
JSONObject callBackObj = new JSONObject();
|
||||||
|
callBackObj.put("betId", betId);
|
||||||
|
callBackObj.put("tranId", tranId);
|
||||||
|
callBackObj.put("betKey", betKey);
|
||||||
|
callBackObj.put("userId", memberId);
|
||||||
|
callBackObj.put("vendorIdx", vendorIdx);
|
||||||
|
callBackObj.put("vendorKey", vendorKey);
|
||||||
|
callBackObj.put("vendor", "onix");
|
||||||
|
callBackObj.put("gameIdx", vendorIdx);
|
||||||
|
callBackObj.put("gameKey", gameName);
|
||||||
|
callBackObj.put("gameId", tableId);
|
||||||
|
callBackObj.put("gameType", gameType);
|
||||||
|
callBackObj.put("tranType", "debit");
|
||||||
|
callBackObj.put("debit", amount);
|
||||||
|
callBackObj.put("credit", 0);
|
||||||
|
callBackObj.put("isCancel", 0);
|
||||||
|
callBackObj.put("isBonus", 0);
|
||||||
|
if(isParsing) {
|
||||||
|
callBackObj.put("isData", "Y");
|
||||||
|
} else {
|
||||||
|
callBackObj.put("isData", "N");
|
||||||
|
}
|
||||||
|
callBackObj.put("requestAt", betDateTimeStr);
|
||||||
|
|
||||||
|
// ##--isTransfer 처리-##
|
||||||
|
if(IS_TRANSFER.equals("N")) {
|
||||||
|
log.info(LOG_PREFIX + "PLAY_SEAMLESS");
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_BET_START-----");
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_BET_END-----");
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "SEND_BET request body: " + callBackObj.toString());
|
||||||
|
JSONObject resData = callBackService.changeBalance(LOG_PREFIX, siteVendorInfo, callBackObj);
|
||||||
|
log.info(LOG_PREFIX + "SEND_BET status code: " + resData.getLong("result_code"));
|
||||||
|
log.info(LOG_PREFIX + "SEND_BET response body: " + resData.toString());
|
||||||
|
|
||||||
|
if (resData.getLong("result_code") == 0) {
|
||||||
|
tranParam.put("balance", resData.getInt("balance"));
|
||||||
|
tranParam.put("isTransfer", IS_TRANSFER);
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "UPDATE_CALLBACK_API_STATUS END");
|
||||||
|
|
||||||
|
long balance = resData.getLong("balance");
|
||||||
|
response = OnixResponse.success(balance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
} else if (resData.getLong("result_code") == 98) {
|
||||||
|
long balance = resData.getLong("balance");
|
||||||
|
response = OnixResponse.success(balance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
} else if (resData.getLong("result_code") == 80) {
|
||||||
|
long balance = resData.getLong("balance");
|
||||||
|
response = OnixResponse.success(balance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
} else {
|
||||||
|
String msg = "";
|
||||||
|
if (resData.has("error_msg")) msg = resData.getString("error_msg");
|
||||||
|
log.error(LOG_PREFIX + msg);
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.info(LOG_PREFIX + "PLAY_TRANSFER");
|
||||||
|
HashMap balanceMap = new HashMap<>();
|
||||||
|
balanceMap.put("siteIdx", siteIdx);
|
||||||
|
balanceMap.put("memberId", memberId);
|
||||||
|
int balance = siteService.getUserBalance(balanceMap);
|
||||||
|
int afBalance = balance - amount;
|
||||||
|
|
||||||
|
if(balance < amount) {
|
||||||
|
log.error(LOG_PREFIX + "beforeBalance is less than amount");
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_BET_START-----");
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_BET_END-----");
|
||||||
|
|
||||||
|
tranParam.put("balance", afBalance);
|
||||||
|
tranParam.put("preBalance", balance);
|
||||||
|
tranParam.put("isTransfer", IS_TRANSFER);
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "UPDATE_CALLBACK_API_STATUS END");
|
||||||
|
|
||||||
|
response = OnixResponse.success(afBalance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
|
||||||
|
if(siteVendorInfo.get("siteCbUrl") != null && !"".equals(siteVendorInfo.get("siteCbUrl").toString())) {
|
||||||
|
callBackObj.put("balance", afBalance);
|
||||||
|
asyncCallBackService.asyncChangeBalance(LOG_PREFIX, siteVendorInfo, callBackObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ResourceAccessException rae) {
|
||||||
|
if (rae.getCause() instanceof ConnectTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX + "[ConnectTimeoutException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if (rae.getCause() instanceof SocketTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX + "[SocketTimeoutException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if (rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error(LOG_PREFIX + "[InterruptedException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(LOG_PREFIX + "[Exception]" + e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ResponseEntity<OnixResponse> callWin(String LOG_PREFIX, long siteIdx, String memberId,
|
||||||
|
net.sf.json.JSONObject transaction, String betDateTimeStr, HashMap<String, String> siteVendorInfo, int amount) {
|
||||||
|
|
||||||
|
LOG_PREFIX = LOG_PREFIX + "callWin:::";
|
||||||
|
ResponseEntity<OnixResponse> resEntity = null;
|
||||||
|
OnixResponse response = new OnixResponse();
|
||||||
|
|
||||||
|
// ##--isTransfer 처리-##
|
||||||
|
final String IS_TRANSFER = siteVendorInfo.get("isTransfer").toString();
|
||||||
|
|
||||||
|
try {
|
||||||
|
String siteId = siteVendorInfo.get("siteId").toString();
|
||||||
|
long memberIdx = Long.parseLong(siteVendorInfo.get("memberIdx").toString());
|
||||||
|
String vendorApiId = siteVendorInfo.get("vendorApiId").toString();
|
||||||
|
|
||||||
|
String tranId = transaction.getString("tranid");
|
||||||
|
String betId = transaction.getString("realround");
|
||||||
|
String betKey = betId;
|
||||||
|
String vendorKey = siteVendorInfo.get("vendorKey").toString();
|
||||||
|
int vendorIdx = Integer.parseInt(siteVendorInfo.get("vendorIdx").toString());
|
||||||
|
String vendorCetegory = siteVendorInfo.get("vendorCetegory").toString();
|
||||||
|
|
||||||
|
net.sf.json.JSONArray details = transaction.optJSONArray("details");
|
||||||
|
net.sf.json.JSONObject detailObj = null;
|
||||||
|
String gameType = ""; // transaction.optString("");
|
||||||
|
String gameName = transaction.optString("title");
|
||||||
|
if(details != null && details.size() > 0) {
|
||||||
|
detailObj = details.optJSONObject(0);
|
||||||
|
if(detailObj != null) {
|
||||||
|
gameType = detailObj.optString("gameType");
|
||||||
|
HashMap detailMap = new HashMap<>();
|
||||||
|
detailMap.put("refId", betId);
|
||||||
|
detailMap.put("orgDetail", detailObj.toString());
|
||||||
|
detailMap.put("parDetail", null);
|
||||||
|
try {
|
||||||
|
int result = siteService.insertEvoDetail(detailMap);
|
||||||
|
log.info(LOG_PREFIX+ "insertEvoDetail result::" + result);
|
||||||
|
} catch(DataIntegrityViolationException de) {
|
||||||
|
log.error(LOG_PREFIX+ "Duplicate refId");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(gameType == null) gameType = "";
|
||||||
|
}
|
||||||
|
String tableId = transaction.optString("subcode");
|
||||||
|
|
||||||
|
// ##--isTransfer 처리-##
|
||||||
|
if(IS_TRANSFER.equals("Y")) {
|
||||||
|
// tranId 중복체크
|
||||||
|
int cntTr = siteService.getTranIdCheck2(tranId);
|
||||||
|
if(cntTr > 0) {
|
||||||
|
HashMap balanceMap = new HashMap<>();
|
||||||
|
balanceMap.put("siteIdx", siteIdx);
|
||||||
|
balanceMap.put("memberId", memberId);
|
||||||
|
int balance = siteService.getUserBalance(balanceMap);
|
||||||
|
log.error(LOG_PREFIX+ "중복요청::Response::" + response.toString());
|
||||||
|
response = OnixResponse.success(balance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 베팅 체크
|
||||||
|
int cntBet = siteService.getBetIdCheck2(betId);
|
||||||
|
if(cntBet == 0) {
|
||||||
|
// 처리한 베팅 존재X
|
||||||
|
log.error(LOG_PREFIX+ "처리한 베팅 존재X");
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (siteVendorInfo.get("lastInVendorIdx") == null || "0".equals(siteVendorInfo.get("lastInVendorIdx").toString())) {
|
||||||
|
HashMap memParam = new HashMap<>();
|
||||||
|
memParam.put("siteIdx", siteIdx);
|
||||||
|
memParam.put("memberIdx", memberIdx);
|
||||||
|
memParam.put("lastInVendorIdx", Integer.parseInt(siteVendorInfo.get("vendorIdx").toString()));
|
||||||
|
int updResult = siteService.updMemLastVendorIdx(memParam);
|
||||||
|
} else {
|
||||||
|
int lastInVendorIdx = Integer.parseInt(siteVendorInfo.get("lastInVendorIdx").toString());
|
||||||
|
if (lastInVendorIdx != vendorIdx) {
|
||||||
|
log.error(LOG_PREFIX + "VendorIdx doesn't match");
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isParsing = false;
|
||||||
|
String game = transaction.optString("game");
|
||||||
|
if("evolution_new".equals(game)) {
|
||||||
|
isParsing = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap tranParam = new HashMap();
|
||||||
|
tranParam.put("tranId", tranId);
|
||||||
|
tranParam.put("refId", betId);
|
||||||
|
tranParam.put("siteIdx", siteIdx);
|
||||||
|
tranParam.put("siteId", siteId);
|
||||||
|
tranParam.put("memberIdx", memberIdx);
|
||||||
|
tranParam.put("memberId", memberId);
|
||||||
|
tranParam.put("vendorCetegory", vendorCetegory);
|
||||||
|
tranParam.put("vendorIdx", vendorIdx);
|
||||||
|
tranParam.put("vendorCode", "onix");
|
||||||
|
tranParam.put("vendorTranKey", betKey);
|
||||||
|
tranParam.put("gameType", gameType);
|
||||||
|
tranParam.put("gameId", tableId);
|
||||||
|
tranParam.put("gameIdx", gameName);
|
||||||
|
tranParam.put("tranType", "credit");
|
||||||
|
tranParam.put("depositAmt", "0");
|
||||||
|
tranParam.put("creditAmt", amount);
|
||||||
|
tranParam.put("isCancel", "N");
|
||||||
|
if(isParsing) {
|
||||||
|
tranParam.put("isTie", "P");
|
||||||
|
} else {
|
||||||
|
tranParam.put("isTie", "N");
|
||||||
|
}
|
||||||
|
tranParam.put("apiStatus", 0);
|
||||||
|
tranParam.put("vendorApiId", vendorApiId);
|
||||||
|
|
||||||
|
JSONObject callBackObj = new JSONObject();
|
||||||
|
callBackObj.put("betId", betId);
|
||||||
|
callBackObj.put("tranId", tranId);
|
||||||
|
callBackObj.put("betKey", betKey);
|
||||||
|
callBackObj.put("userId", memberId);
|
||||||
|
callBackObj.put("vendorIdx", vendorIdx);
|
||||||
|
callBackObj.put("vendorKey", vendorKey);
|
||||||
|
callBackObj.put("vendor", "onix");
|
||||||
|
callBackObj.put("gameIdx", vendorIdx);
|
||||||
|
callBackObj.put("gameKey", gameName);
|
||||||
|
callBackObj.put("gameId", tableId);
|
||||||
|
callBackObj.put("gameType", gameType);
|
||||||
|
callBackObj.put("tranType", "credit");
|
||||||
|
callBackObj.put("debit", 0);
|
||||||
|
callBackObj.put("credit", amount);
|
||||||
|
callBackObj.put("isCancel", 0);
|
||||||
|
callBackObj.put("isBonus", 0);
|
||||||
|
if(isParsing) {
|
||||||
|
callBackObj.put("isData", "Y");
|
||||||
|
} else {
|
||||||
|
callBackObj.put("isData", "N");
|
||||||
|
}
|
||||||
|
callBackObj.put("requestAt", betDateTimeStr);
|
||||||
|
|
||||||
|
// ##--isTransfer 처리-##
|
||||||
|
if(IS_TRANSFER.equals("N")) {
|
||||||
|
log.info(LOG_PREFIX + "PLAY_SEAMLESS");
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_RESULT_START-----");
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_RESULT_END-----");
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "SEND_RESULT request body: " + callBackObj.toString());
|
||||||
|
JSONObject resData = callBackService.changeBalance(LOG_PREFIX, siteVendorInfo, callBackObj);
|
||||||
|
log.info(LOG_PREFIX + "SEND_RESULT status code: " + resData.getLong("result_code"));
|
||||||
|
log.info(LOG_PREFIX + "SEND_RESULT response body: " + resData.toString());
|
||||||
|
|
||||||
|
if (resData.getLong("result_code") == 0) {
|
||||||
|
tranParam.put("balance", resData.getInt("balance"));
|
||||||
|
tranParam.put("isTransfer", IS_TRANSFER);
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "UPDATE_CALLBACK_API_STATUS END");
|
||||||
|
|
||||||
|
long balance = resData.getLong("balance");
|
||||||
|
response = OnixResponse.success(balance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
} else if (resData.getLong("result_code") == 98) {
|
||||||
|
long balance = resData.getLong("balance");
|
||||||
|
response = OnixResponse.success(balance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
} else {
|
||||||
|
String msg = "";
|
||||||
|
if (resData.has("error_msg")) msg = resData.getString("error_msg");
|
||||||
|
log.error(LOG_PREFIX + msg);
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.info(LOG_PREFIX + "PLAY_TRANSFER");
|
||||||
|
HashMap balanceMap = new HashMap<>();
|
||||||
|
balanceMap.put("siteIdx", siteIdx);
|
||||||
|
balanceMap.put("memberId", memberId);
|
||||||
|
int balance = siteService.getUserBalance(balanceMap);
|
||||||
|
int afBalance = balance + amount;
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_RESULT_START-----");
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_RESULT_END-----");
|
||||||
|
|
||||||
|
tranParam.put("balance", afBalance);
|
||||||
|
tranParam.put("preBalance", balance);
|
||||||
|
tranParam.put("isTransfer", IS_TRANSFER);
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "UPDATE_CALLBACK_API_STATUS END");
|
||||||
|
|
||||||
|
response = OnixResponse.success(afBalance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
|
||||||
|
if(siteVendorInfo.get("siteCbUrl") != null && !"".equals(siteVendorInfo.get("siteCbUrl").toString())) {
|
||||||
|
callBackObj.put("balance", afBalance);
|
||||||
|
asyncCallBackService.asyncChangeBalance(LOG_PREFIX, siteVendorInfo, callBackObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ResourceAccessException rae) {
|
||||||
|
if (rae.getCause() instanceof ConnectTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX + "[ConnectTimeoutException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if (rae.getCause() instanceof SocketTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX + "[SocketTimeoutException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if (rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error(LOG_PREFIX + "[InterruptedException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(LOG_PREFIX + "[Exception]" + e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ResponseEntity<OnixResponse> callCancel(String LOG_PREFIX, long siteIdx, String memberId,
|
||||||
|
net.sf.json.JSONObject transaction, String betDateTimeStr, HashMap<String, String> siteVendorInfo, int amount) {
|
||||||
|
|
||||||
|
LOG_PREFIX = LOG_PREFIX + "callCancel:::";
|
||||||
|
ResponseEntity<OnixResponse> resEntity = null;
|
||||||
|
OnixResponse response = new OnixResponse();
|
||||||
|
|
||||||
|
// ##--isTransfer 처리-##
|
||||||
|
final String IS_TRANSFER = siteVendorInfo.get("isTransfer").toString();
|
||||||
|
|
||||||
|
try {
|
||||||
|
String siteId = siteVendorInfo.get("siteId").toString();
|
||||||
|
long memberIdx = Long.parseLong(siteVendorInfo.get("memberIdx").toString());
|
||||||
|
String vendorApiId = siteVendorInfo.get("vendorApiId").toString();
|
||||||
|
|
||||||
|
String tranId = transaction.getString("tranid");
|
||||||
|
String betId = transaction.getString("realround");
|
||||||
|
String betKey = betId;
|
||||||
|
String vendorKey = siteVendorInfo.get("vendorKey").toString();
|
||||||
|
int vendorIdx = Integer.parseInt(siteVendorInfo.get("vendorIdx").toString());
|
||||||
|
String vendorCetegory = siteVendorInfo.get("vendorCetegory").toString();
|
||||||
|
|
||||||
|
net.sf.json.JSONArray details = transaction.optJSONArray("details");
|
||||||
|
net.sf.json.JSONObject detailObj = null;
|
||||||
|
String gameType = ""; // transaction.optString("");
|
||||||
|
String gameName = transaction.optString("title");
|
||||||
|
if(details != null && details.size() > 0) {
|
||||||
|
detailObj = details.optJSONObject(0);
|
||||||
|
if(detailObj != null) {
|
||||||
|
gameType = detailObj.optString("gameType");
|
||||||
|
HashMap detailMap = new HashMap<>();
|
||||||
|
detailMap.put("refId", betId);
|
||||||
|
detailMap.put("orgDetail", detailObj.toString());
|
||||||
|
detailMap.put("parDetail", null);
|
||||||
|
try {
|
||||||
|
int result = siteService.insertEvoDetail(detailMap);
|
||||||
|
log.info(LOG_PREFIX+ "insertEvoDetail result::" + result);
|
||||||
|
} catch(DataIntegrityViolationException de) {
|
||||||
|
log.error(LOG_PREFIX+ "Duplicate refId");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(gameType == null) gameType = "";
|
||||||
|
}
|
||||||
|
String tableId = transaction.optString("subcode");
|
||||||
|
|
||||||
|
// ##--isTransfer 처리-##
|
||||||
|
if(IS_TRANSFER.equals("Y")) {
|
||||||
|
// tranId 중복체크
|
||||||
|
int cntTr = siteService.getTranIdCheck2(tranId);
|
||||||
|
if(cntTr > 0) {
|
||||||
|
HashMap balanceMap = new HashMap<>();
|
||||||
|
balanceMap.put("siteIdx", siteIdx);
|
||||||
|
balanceMap.put("memberId", memberId);
|
||||||
|
int balance = siteService.getUserBalance(balanceMap);
|
||||||
|
log.error(LOG_PREFIX+ "중복요청::Response::" + response.toString());
|
||||||
|
response = OnixResponse.success(balance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 베팅 체크
|
||||||
|
int cntBet = siteService.getBetIdCheck2(betId);
|
||||||
|
if(cntBet == 0) {
|
||||||
|
// 처리한 베팅 존재X
|
||||||
|
log.error(LOG_PREFIX+ "처리한 베팅 존재X");
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (siteVendorInfo.get("lastInVendorIdx") == null || "0".equals(siteVendorInfo.get("lastInVendorIdx").toString())) {
|
||||||
|
HashMap memParam = new HashMap<>();
|
||||||
|
memParam.put("siteIdx", siteIdx);
|
||||||
|
memParam.put("memberIdx", memberIdx);
|
||||||
|
memParam.put("lastInVendorIdx", Integer.parseInt(siteVendorInfo.get("vendorIdx").toString()));
|
||||||
|
int updResult = siteService.updMemLastVendorIdx(memParam);
|
||||||
|
} else {
|
||||||
|
int lastInVendorIdx = Integer.parseInt(siteVendorInfo.get("lastInVendorIdx").toString());
|
||||||
|
if (lastInVendorIdx != vendorIdx) {
|
||||||
|
log.error(LOG_PREFIX + "VendorIdx doesn't match");
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isParsing = false;
|
||||||
|
String game = transaction.optString("game");
|
||||||
|
if("evolution_new".equals(game)) {
|
||||||
|
isParsing = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap tranParam = new HashMap();
|
||||||
|
tranParam.put("tranId", tranId);
|
||||||
|
tranParam.put("refId", betId);
|
||||||
|
tranParam.put("siteIdx", siteIdx);
|
||||||
|
tranParam.put("siteId", siteId);
|
||||||
|
tranParam.put("memberIdx", memberIdx);
|
||||||
|
tranParam.put("memberId", memberId);
|
||||||
|
tranParam.put("vendorCetegory", vendorCetegory);
|
||||||
|
tranParam.put("vendorIdx", vendorIdx);
|
||||||
|
tranParam.put("vendorCode", "onix");
|
||||||
|
tranParam.put("vendorTranKey", betKey);
|
||||||
|
tranParam.put("gameType", gameType);
|
||||||
|
tranParam.put("gameId", tableId);
|
||||||
|
tranParam.put("gameIdx", gameName);
|
||||||
|
tranParam.put("tranType", "credit");
|
||||||
|
tranParam.put("depositAmt", "0");
|
||||||
|
tranParam.put("creditAmt", amount);
|
||||||
|
tranParam.put("isCancel", "Y");
|
||||||
|
if(isParsing) {
|
||||||
|
tranParam.put("isTie", "P");
|
||||||
|
} else {
|
||||||
|
tranParam.put("isTie", "N");
|
||||||
|
}
|
||||||
|
tranParam.put("apiStatus", 0);
|
||||||
|
tranParam.put("vendorApiId", vendorApiId);
|
||||||
|
|
||||||
|
JSONObject callBackObj = new JSONObject();
|
||||||
|
callBackObj.put("betId", betId);
|
||||||
|
callBackObj.put("tranId", tranId);
|
||||||
|
callBackObj.put("betKey", betKey);
|
||||||
|
callBackObj.put("userId", memberId);
|
||||||
|
callBackObj.put("vendorIdx", vendorIdx);
|
||||||
|
callBackObj.put("vendorKey", vendorKey);
|
||||||
|
callBackObj.put("vendor", "onix");
|
||||||
|
callBackObj.put("gameIdx", vendorIdx);
|
||||||
|
callBackObj.put("gameKey", gameName);
|
||||||
|
callBackObj.put("gameId", tableId);
|
||||||
|
callBackObj.put("gameType", gameType);
|
||||||
|
callBackObj.put("tranType", "credit");
|
||||||
|
callBackObj.put("debit", 0);
|
||||||
|
callBackObj.put("credit", amount);
|
||||||
|
callBackObj.put("isCancel", 1);
|
||||||
|
callBackObj.put("isBonus", 0);
|
||||||
|
if(isParsing) {
|
||||||
|
callBackObj.put("isData", "Y");
|
||||||
|
} else {
|
||||||
|
callBackObj.put("isData", "N");
|
||||||
|
}
|
||||||
|
callBackObj.put("requestAt", betDateTimeStr);
|
||||||
|
|
||||||
|
// ##--isTransfer 처리-##
|
||||||
|
if(IS_TRANSFER.equals("N")) {
|
||||||
|
log.info(LOG_PREFIX + "PLAY_SEAMLESS");
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_CANCEL_START-----");
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_CANCEL_END-----");
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "SEND_CANCEL request body: " + callBackObj.toString());
|
||||||
|
JSONObject resData = callBackService.changeBalance(LOG_PREFIX, siteVendorInfo, callBackObj);
|
||||||
|
log.info(LOG_PREFIX + "SEND_CANCEL status code: " + resData.getLong("result_code"));
|
||||||
|
log.info(LOG_PREFIX + "SEND_CANCEL response body: " + resData.toString());
|
||||||
|
|
||||||
|
if (resData.getLong("result_code") == 0) {
|
||||||
|
tranParam.put("balance", resData.getInt("balance"));
|
||||||
|
tranParam.put("isTransfer", IS_TRANSFER);
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "UPDATE_CALLBACK_API_STATUS END");
|
||||||
|
|
||||||
|
long balance = resData.getLong("balance");
|
||||||
|
response = OnixResponse.success(balance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
} else if (resData.getLong("result_code") == 98) {
|
||||||
|
long balance = resData.getLong("balance");
|
||||||
|
response = OnixResponse.success(balance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
} else {
|
||||||
|
String msg = "";
|
||||||
|
if (resData.has("error_msg")) msg = resData.getString("error_msg");
|
||||||
|
log.error(LOG_PREFIX + msg);
|
||||||
|
response = OnixResponse.failure();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.info(LOG_PREFIX + "PLAY_TRANSFER");
|
||||||
|
HashMap balanceMap = new HashMap<>();
|
||||||
|
balanceMap.put("siteIdx", siteIdx);
|
||||||
|
balanceMap.put("memberId", memberId);
|
||||||
|
int balance = siteService.getUserBalance(balanceMap);
|
||||||
|
int afBalance = balance + amount;
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_RESULT_START-----");
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_RESULT_END-----");
|
||||||
|
|
||||||
|
tranParam.put("balance", afBalance);
|
||||||
|
tranParam.put("preBalance", balance);
|
||||||
|
tranParam.put("isTransfer", IS_TRANSFER);
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "UPDATE_CALLBACK_API_STATUS END");
|
||||||
|
|
||||||
|
response = OnixResponse.success(afBalance);
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.OK);
|
||||||
|
|
||||||
|
if(siteVendorInfo.get("siteCbUrl") != null && !"".equals(siteVendorInfo.get("siteCbUrl").toString())) {
|
||||||
|
callBackObj.put("balance", afBalance);
|
||||||
|
asyncCallBackService.asyncChangeBalance(LOG_PREFIX, siteVendorInfo, callBackObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ResourceAccessException rae) {
|
||||||
|
if (rae.getCause() instanceof ConnectTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX + "[ConnectTimeoutException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if (rae.getCause() instanceof SocketTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX + "[SocketTimeoutException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
if (rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error(LOG_PREFIX + "[InterruptedException]" + rae.getMessage());
|
||||||
|
}
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(LOG_PREFIX + "[Exception]" + e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
resEntity = new ResponseEntity<OnixResponse>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String makeEdate(String LOG_PREFIX, String paramDate, int flag) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
String eDate = "";
|
||||||
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
|
try {
|
||||||
|
Date date = sdf1.parse(paramDate);
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
calendar.add(Calendar.MILLISECOND, flag);
|
||||||
|
Date date2 = calendar.getTime();
|
||||||
|
eDate = sdf2.format(date2);
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.error(LOG_PREFIX+ "makeEdate::Exception::"+e.getMessage());
|
||||||
|
}
|
||||||
|
return eDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
710
src/main/java/com/bb/front/CallBackPowerBall.java
Normal file
710
src/main/java/com/bb/front/CallBackPowerBall.java
Normal file
@@ -0,0 +1,710 @@
|
|||||||
|
package com.bb.front;
|
||||||
|
|
||||||
|
import java.net.SocketTimeoutException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.apache.http.conn.ConnectTimeoutException;
|
||||||
|
import org.codehaus.jettison.json.JSONArray;
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.client.ResourceAccessException;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClientRequestException;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClientResponseException;
|
||||||
|
|
||||||
|
import com.bb.model.PowerballData;
|
||||||
|
import com.bb.model.PowerballRequest;
|
||||||
|
import com.bb.model.PowerballResponse;
|
||||||
|
import com.bb.service.CallBackService;
|
||||||
|
import com.bb.service.SiteService;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("/api/callback/powerball")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@SecurityRequirement(name = "Authorization")
|
||||||
|
public class CallBackPowerBall {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SiteService siteService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CallBackService callBackService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WebClient webClient;
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(path = "/balance")
|
||||||
|
public ResponseEntity<PowerballResponse> balance(HttpServletRequest request, @RequestParam String id, @RequestParam String siteName) throws Exception {
|
||||||
|
PowerballResponse response = null;
|
||||||
|
PowerballData data = null;
|
||||||
|
HttpStatus httpStatus = HttpStatus.OK;
|
||||||
|
|
||||||
|
//사이트정보
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
long siteIdx = Long.parseLong(id.substring(0, 3), 16);
|
||||||
|
String memberId = id.substring(3, id.length());
|
||||||
|
final String LOG_PREFIX = "#-CB::POWER_BALL::"+memberId+"::BALANCE::::";
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "id:"+id+", siteName:"+siteName);
|
||||||
|
|
||||||
|
try {
|
||||||
|
sParam.put("siteIdx", siteIdx);
|
||||||
|
sParam.put("memberId", memberId);
|
||||||
|
HashMap siteApiInfo = siteService.getSiteApiInfo(sParam);
|
||||||
|
if(siteApiInfo == null) {
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("NOT_FOUND_USER");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteName);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
log.error(LOG_PREFIX+ "Response Body: "+response.toString());
|
||||||
|
return new ResponseEntity<PowerballResponse>(response, httpStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject member = new JSONObject();
|
||||||
|
member.put("userId", memberId);
|
||||||
|
log.info(LOG_PREFIX + "SEND_BALANCE request body: " + member.toString());
|
||||||
|
|
||||||
|
HttpHeaders header = new HttpHeaders();
|
||||||
|
header.add("Content-Type", "application/json");
|
||||||
|
header.add("Accept", "application/json");
|
||||||
|
header.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
|
||||||
|
|
||||||
|
ResponseEntity<String> responseEntity = webClient.post()
|
||||||
|
.uri(siteApiInfo.get("siteCbUrl")+"/balance")
|
||||||
|
.headers(h -> h.addAll(header))
|
||||||
|
.bodyValue(member.toString())
|
||||||
|
.retrieve()
|
||||||
|
.toEntity(String.class)
|
||||||
|
.block();
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "SEND_BALANCE status code: " + responseEntity.getStatusCode());
|
||||||
|
log.info(LOG_PREFIX+ "SEND_BALANCE response body: " + responseEntity.getBody());
|
||||||
|
|
||||||
|
JSONObject resData = new JSONObject(responseEntity.getBody());
|
||||||
|
int balance = resData.getInt("balance");
|
||||||
|
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("SUCCESS");
|
||||||
|
response.setMsg("");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteName);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance(Integer.toString(balance));
|
||||||
|
response.setData(data);
|
||||||
|
|
||||||
|
} catch (WebClientResponseException e) {
|
||||||
|
// HttpServerErrorException handling
|
||||||
|
if (e.getStatusCode().is5xxServerError()) {
|
||||||
|
log.error(LOG_PREFIX+ "WebClientResponseException 5xx: " + e.getResponseBodyAsString());
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("BALANCE_SERVER_ERROR");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteName);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
}
|
||||||
|
// HttpClientErrorException handling
|
||||||
|
else if (e.getStatusCode().is4xxClientError()) {
|
||||||
|
log.error(LOG_PREFIX+ "WebClientResponseException 4xx: " + e.getResponseBodyAsString());
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("BALANCE_SERVER_ERROR");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteName);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
} else {
|
||||||
|
log.error(LOG_PREFIX+ "WebClientResponseException: " + e.getResponseBodyAsString());
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("BALANCE_SERVER_ERROR");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteName);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (WebClientRequestException e) {
|
||||||
|
// 타임아웃 등 연결 오류
|
||||||
|
Throwable cause = e.getCause();
|
||||||
|
if (cause instanceof ConnectTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "ConnectTimeoutException: " + cause.getMessage());
|
||||||
|
} else if (cause instanceof SocketTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "SocketTimeoutException: " + cause.getMessage());
|
||||||
|
} else {
|
||||||
|
log.error(LOG_PREFIX+ "WebClientRequestException: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("TIMEOUT_ERROR");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteName);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
} catch (ResourceAccessException rae) {
|
||||||
|
if(rae.getCause() instanceof ConnectTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "ConnectTimeoutException: " + rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rae.getCause() instanceof SocketTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "SocketTimeoutException: " + rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error(LOG_PREFIX+ "InterruptedException: " + rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("TIMEOUT_ERROR");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteName);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
*/
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(LOG_PREFIX+ "Exception: " + e.getMessage());
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("BALANCE_SERVER_ERROR");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteName);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.error(LOG_PREFIX+ "Response Body: " + response.toString());
|
||||||
|
ResponseEntity<PowerballResponse> res = new ResponseEntity<PowerballResponse>(response, httpStatus);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(path = "/bet")
|
||||||
|
public ResponseEntity<PowerballResponse> bet(HttpServletRequest request, @RequestBody net.sf.json.JSONObject reqBodyObj) throws Exception {
|
||||||
|
PowerballResponse response = null;
|
||||||
|
PowerballData data = null;
|
||||||
|
HttpStatus httpStatus = HttpStatus.OK;
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
PowerballRequest reqBody = mapper.readValue(reqBodyObj.toString(), new TypeReference<PowerballRequest>() {});
|
||||||
|
|
||||||
|
//사이트정보
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
long siteIdx = Long.parseLong(reqBody.getId().substring(0, 3), 16);
|
||||||
|
String memberId = reqBody.getId().substring(3, reqBody.getId().length());
|
||||||
|
|
||||||
|
String siteId = reqBody.getSiteId();
|
||||||
|
String id = reqBody.getId();
|
||||||
|
String transactionId = reqBody.getBetId();
|
||||||
|
String gameName = reqBody.getGameName();
|
||||||
|
|
||||||
|
String gameType = reqBody.getGameType();
|
||||||
|
String gameTypeName = "";
|
||||||
|
String betType = reqBody.getBetType();
|
||||||
|
String betTypeName = "";
|
||||||
|
String rateType = "";
|
||||||
|
|
||||||
|
final String LOG_PREFIX = "#-CB::POWER_BALL::"+memberId+"::"+transactionId+"::BET::::";
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "reqBodyObj:"+reqBodyObj);
|
||||||
|
log.info(LOG_PREFIX+ "reqBody:"+reqBody);
|
||||||
|
|
||||||
|
try {
|
||||||
|
sParam.put("siteIdx", siteIdx);
|
||||||
|
sParam.put("memberId", memberId);
|
||||||
|
sParam.put("vendor", "");
|
||||||
|
sParam.put("vendorGameCode", "powerball");
|
||||||
|
log.info(LOG_PREFIX + "getSiteVendorInfo::"+sParam.toString());
|
||||||
|
HashMap<String,String> siteVendorInfo = siteService.getSiteVendorInfo(sParam);
|
||||||
|
if(siteVendorInfo == null) {
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("NOT_FOUND_USER");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
log.error(LOG_PREFIX+ "Response Body: "+response.toString());
|
||||||
|
return new ResponseEntity<PowerballResponse>(response, httpStatus);
|
||||||
|
}
|
||||||
|
log.info(LOG_PREFIX + "siteVendorInfo::"+siteVendorInfo.toString());
|
||||||
|
|
||||||
|
long memberIdx = Long.parseLong(siteVendorInfo.get("memberIdx").toString());
|
||||||
|
String vendorApiId = siteVendorInfo.get("vendorApiId").toString();
|
||||||
|
|
||||||
|
int amount = Math.abs(reqBody.getBetAmt());
|
||||||
|
long siteCredit = Long.parseLong(siteVendorInfo.get("credit").toString());
|
||||||
|
if(siteCredit < amount) {
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("NO_SITE_CREDIT");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
log.error(LOG_PREFIX+ "Response Body: "+response.toString());
|
||||||
|
return new ResponseEntity<PowerballResponse>(response, httpStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
String vendorTranKey = transactionId;
|
||||||
|
String tranId = siteId + "#D#" + vendorTranKey;
|
||||||
|
String betId = siteId + "#" + vendorTranKey;
|
||||||
|
String vendorKey = siteVendorInfo.get("vendorKey").toString();
|
||||||
|
int vendorIdx = Integer.parseInt(siteVendorInfo.get("vendorIdx").toString());
|
||||||
|
String vendorCetegory = siteVendorInfo.get("vendorCetegory").toString();
|
||||||
|
|
||||||
|
List<HashMap<String,String>> infoList = siteService.getPowerBallInfoList(gameType);
|
||||||
|
for(HashMap<String,String> info : infoList) {
|
||||||
|
if(betType.equals(info.get("betType").toString())) {
|
||||||
|
gameTypeName = info.get("gameTypeName").toString();
|
||||||
|
betTypeName = info.get("betTypeName").toString();
|
||||||
|
rateType = info.get("rateType").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(gameTypeName.equals("") || betTypeName.equals("")) {
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("NOT_FOUND_GAME_TYPE");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
log.error(LOG_PREFIX+ "Response Body: "+response.toString());
|
||||||
|
return new ResponseEntity<PowerballResponse>(response, httpStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap tranParam = new HashMap();
|
||||||
|
tranParam.put("tranId", tranId);
|
||||||
|
tranParam.put("refId", betId);
|
||||||
|
tranParam.put("siteIdx", siteIdx);
|
||||||
|
tranParam.put("siteId", siteId);
|
||||||
|
tranParam.put("memberIdx", memberIdx);
|
||||||
|
tranParam.put("memberId", memberId);
|
||||||
|
tranParam.put("vendorCetegory", vendorCetegory);
|
||||||
|
tranParam.put("vendorIdx", vendorIdx);
|
||||||
|
tranParam.put("vendorCode", "powerball");
|
||||||
|
tranParam.put("vendorTranKey", vendorTranKey);
|
||||||
|
tranParam.put("gameType", gameType);
|
||||||
|
tranParam.put("gameId", "");
|
||||||
|
tranParam.put("gameIdx", gameName+"("+gameTypeName+")");
|
||||||
|
tranParam.put("tranType", "debit");
|
||||||
|
tranParam.put("depositAmt", amount);
|
||||||
|
tranParam.put("creditAmt", 0);
|
||||||
|
tranParam.put("isCancel", "N");
|
||||||
|
tranParam.put("isTie", "N");
|
||||||
|
tranParam.put("apiStatus", 0);
|
||||||
|
tranParam.put("vendorApiId", vendorApiId);
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_BET_START-----");
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_BET_END-----");
|
||||||
|
|
||||||
|
JSONObject debit = new JSONObject();
|
||||||
|
debit.put("betId", betId);
|
||||||
|
debit.put("tranId", tranId);
|
||||||
|
debit.put("userId", memberId);
|
||||||
|
debit.put("vendorIdx", vendorIdx);
|
||||||
|
debit.put("vendorKey", vendorKey);
|
||||||
|
debit.put("vendor", "powerball");
|
||||||
|
debit.put("gameIdx", vendorIdx);
|
||||||
|
debit.put("gameKey", gameName+"("+gameTypeName+")");
|
||||||
|
debit.put("gameType", gameType);
|
||||||
|
debit.put("gameId", "");
|
||||||
|
debit.put("tranType", "debit");
|
||||||
|
debit.put("debit", amount);
|
||||||
|
debit.put("credit", 0);
|
||||||
|
debit.put("isCancel", 0);
|
||||||
|
debit.put("isBonus", 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* betType : 유저가 배팅한 타입
|
||||||
|
* gameType : 게임 타입
|
||||||
|
* resultType : 결과 타입
|
||||||
|
*/
|
||||||
|
|
||||||
|
JSONArray detailsArr = new JSONArray();
|
||||||
|
|
||||||
|
JSONObject detailItem = new JSONObject();
|
||||||
|
detailItem.put("detailId", betType+"("+betTypeName+")");
|
||||||
|
detailItem.put("detailType", rateType);
|
||||||
|
detailItem.put("detailName", gameType+"("+gameTypeName+")");
|
||||||
|
detailItem.put("betAmt", amount);
|
||||||
|
detailItem.put("betWinAmt", 0);
|
||||||
|
detailsArr.put(detailItem);
|
||||||
|
|
||||||
|
debit.put("betDetails", detailsArr);
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "SEND_DEBIT request body: " + debit.toString());
|
||||||
|
JSONObject resData = new JSONObject();
|
||||||
|
resData = callBackService.changeBalance(LOG_PREFIX, siteVendorInfo, debit);
|
||||||
|
log.info(LOG_PREFIX + "SEND_DEBIT status code: " + resData.getLong("result_code"));
|
||||||
|
log.info(LOG_PREFIX + "SEND_DEBIT response body: " + resData.toString());
|
||||||
|
|
||||||
|
if(resData.getLong("result_code") == 0) {
|
||||||
|
tranParam.put("balance", resData.getInt("balance"));
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "UPDATE_CALLBACK_API_STATUS END");
|
||||||
|
|
||||||
|
int balance = resData.getInt("balance");
|
||||||
|
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("SUCCESS");
|
||||||
|
response.setMsg("");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance(Integer.toString(balance));
|
||||||
|
response.setData(data);
|
||||||
|
} else {
|
||||||
|
String msg = "";
|
||||||
|
if(resData.has("error_msg")) msg = resData.getString("error_msg");
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg(msg);
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ResourceAccessException rae) {
|
||||||
|
if(rae.getCause() instanceof ConnectTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "ConnectTimeoutException: " + rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rae.getCause() instanceof SocketTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "SocketTimeoutException: " + rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error(LOG_PREFIX+ "InterruptedException: " + rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("TIMEOUT_ERROR");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(LOG_PREFIX+ "Exception: " + e.getMessage());
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("BET_SERVER_ERROR");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
httpStatus = HttpStatus.OK;
|
||||||
|
log.error(LOG_PREFIX+ "Response Body: " + response.toString());
|
||||||
|
ResponseEntity<PowerballResponse> res = new ResponseEntity<PowerballResponse>(response, httpStatus);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping(path = "/result")
|
||||||
|
public ResponseEntity<PowerballResponse> result(HttpServletRequest request, @RequestBody net.sf.json.JSONObject reqBodyObj) throws Exception {
|
||||||
|
PowerballResponse response = null;
|
||||||
|
PowerballData data = null;
|
||||||
|
HttpStatus httpStatus = HttpStatus.OK;
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
PowerballRequest reqBody = mapper.readValue(reqBodyObj.toString(), new TypeReference<PowerballRequest>() {});
|
||||||
|
|
||||||
|
//사이트정보
|
||||||
|
HashMap sParam = new HashMap();
|
||||||
|
long siteIdx = Long.parseLong(reqBody.getId().substring(0, 3), 16);
|
||||||
|
String memberId = reqBody.getId().substring(3, reqBody.getId().length());
|
||||||
|
|
||||||
|
String siteId = reqBody.getSiteId();
|
||||||
|
String id = reqBody.getId();
|
||||||
|
String transactionId = reqBody.getBetId();
|
||||||
|
String gameName = reqBody.getGameName();
|
||||||
|
|
||||||
|
String gameType = reqBody.getGameType();
|
||||||
|
String gameTypeName = "";
|
||||||
|
String betType = reqBody.getBetType();
|
||||||
|
String betTypeName = "";
|
||||||
|
if(reqBody.getResultType() == null) {
|
||||||
|
reqBody.setResultType("");
|
||||||
|
}
|
||||||
|
String resultType = reqBody.getResultType();
|
||||||
|
String resultTypeName = "";
|
||||||
|
String rateType = "";
|
||||||
|
|
||||||
|
final String LOG_PREFIX = "#-CB::POWER_BALL::"+memberId+"::"+transactionId+"::RESULT::::";
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX+ "reqBodyObj:"+reqBodyObj);
|
||||||
|
log.info(LOG_PREFIX+ "reqBody:"+reqBody);
|
||||||
|
|
||||||
|
try {
|
||||||
|
sParam.put("siteIdx", siteIdx);
|
||||||
|
sParam.put("memberId", memberId);
|
||||||
|
sParam.put("vendor", "");
|
||||||
|
sParam.put("vendorGameCode", "powerball");
|
||||||
|
log.info(LOG_PREFIX + "getSiteVendorInfo::"+sParam.toString());
|
||||||
|
HashMap<String,String> siteVendorInfo = siteService.getSiteVendorInfo(sParam);
|
||||||
|
if(siteVendorInfo == null) {
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("NOT_FOUND_USER");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
log.error(LOG_PREFIX+ "Response Body: "+response.toString());
|
||||||
|
return new ResponseEntity<PowerballResponse>(response, httpStatus);
|
||||||
|
}
|
||||||
|
log.info(LOG_PREFIX + "siteVendorInfo::"+siteVendorInfo.toString());
|
||||||
|
|
||||||
|
long memberIdx = Long.parseLong(siteVendorInfo.get("memberIdx").toString());
|
||||||
|
String vendorApiId = siteVendorInfo.get("vendorApiId").toString();
|
||||||
|
|
||||||
|
int amount = Math.abs(reqBody.getBetWinAmt());
|
||||||
|
long siteCredit = Long.parseLong(siteVendorInfo.get("credit").toString());
|
||||||
|
if(siteCredit < amount) {
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("NO_SITE_CREDIT");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
log.error(LOG_PREFIX+ "Response Body: "+response.toString());
|
||||||
|
return new ResponseEntity<PowerballResponse>(response, httpStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
String vendorTranKey = transactionId;
|
||||||
|
String tranId = siteId + "#C#" + vendorTranKey;
|
||||||
|
String betId = siteId + "#" + vendorTranKey;
|
||||||
|
String vendorKey = siteVendorInfo.get("vendorKey").toString();
|
||||||
|
int vendorIdx = Integer.parseInt(siteVendorInfo.get("vendorIdx").toString());
|
||||||
|
String vendorCetegory = siteVendorInfo.get("vendorCetegory").toString();
|
||||||
|
|
||||||
|
List<HashMap<String,String>> infoList = siteService.getPowerBallInfoList(gameType);
|
||||||
|
for(HashMap<String,String> info : infoList) {
|
||||||
|
if(betType.equals(info.get("betType").toString())) {
|
||||||
|
gameTypeName = info.get("gameTypeName").toString();
|
||||||
|
betTypeName = info.get("betTypeName").toString();
|
||||||
|
rateType = info.get("rateType").toString();
|
||||||
|
}
|
||||||
|
if(resultType.equals(info.get("betType").toString())) {
|
||||||
|
resultTypeName = info.get("betTypeName").toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(gameTypeName.equals("") || betTypeName.equals("")) {
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("NOT_FOUND_GAME_TYPE");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
log.error(LOG_PREFIX+ "Response Body: "+response.toString());
|
||||||
|
return new ResponseEntity<PowerballResponse>(response, httpStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap tranParam = new HashMap();
|
||||||
|
tranParam.put("tranId", tranId);
|
||||||
|
tranParam.put("refId", betId);
|
||||||
|
tranParam.put("siteIdx", siteIdx);
|
||||||
|
tranParam.put("siteId", siteId);
|
||||||
|
tranParam.put("memberIdx", memberIdx);
|
||||||
|
tranParam.put("memberId", memberId);
|
||||||
|
tranParam.put("vendorCetegory", vendorCetegory);
|
||||||
|
tranParam.put("vendorIdx", vendorIdx);
|
||||||
|
tranParam.put("vendorCode", "powerball");
|
||||||
|
tranParam.put("vendorTranKey", vendorTranKey);
|
||||||
|
tranParam.put("gameType", gameType);
|
||||||
|
tranParam.put("gameId", "");
|
||||||
|
tranParam.put("gameIdx", gameName+"("+gameTypeName+")");
|
||||||
|
tranParam.put("tranType", "credit");
|
||||||
|
tranParam.put("depositAmt", 0);
|
||||||
|
tranParam.put("creditAmt", amount);
|
||||||
|
tranParam.put("isCancel", "N");
|
||||||
|
tranParam.put("isTie", "N");
|
||||||
|
tranParam.put("apiStatus", 0);
|
||||||
|
tranParam.put("vendorApiId", vendorApiId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* betType : 유저가 배팅한 타입
|
||||||
|
* gameType : 게임 타입
|
||||||
|
* resultType : 결과 타입
|
||||||
|
*/
|
||||||
|
|
||||||
|
JSONArray detailsArr = new JSONArray();
|
||||||
|
JSONObject detailItem = new JSONObject();
|
||||||
|
detailItem.put("detailId", betType+"("+betTypeName+")");
|
||||||
|
detailItem.put("detailType", rateType);
|
||||||
|
detailItem.put("detailName", gameType+"("+gameTypeName+")");
|
||||||
|
detailItem.put("betAmt", 0);
|
||||||
|
detailItem.put("betWinAmt", amount);
|
||||||
|
|
||||||
|
JSONObject detailCredit = new JSONObject();
|
||||||
|
detailCredit.put("rateType", rateType);
|
||||||
|
detailCredit.put("betType", betType);
|
||||||
|
detailCredit.put("betTypeName", betTypeName);
|
||||||
|
detailCredit.put("gameType", gameType);
|
||||||
|
detailCredit.put("gameTypeName", gameTypeName);
|
||||||
|
detailCredit.put("resultType", resultType);
|
||||||
|
detailCredit.put("resultTypeName", resultTypeName);
|
||||||
|
detailCredit.put("betAmt", reqBody.getBetAmt());
|
||||||
|
detailCredit.put("betWinAmt", reqBody.getBetWinAmt());
|
||||||
|
|
||||||
|
detailItem.put("detail", detailCredit);
|
||||||
|
detailsArr.put(detailItem);
|
||||||
|
|
||||||
|
tranParam.put("detail", detailCredit.toString());
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_BET_START-----");
|
||||||
|
siteService.commonBetinsert(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "-----INSERT_BET_END-----");
|
||||||
|
|
||||||
|
JSONObject credit = new JSONObject();
|
||||||
|
credit.put("betId", betId);
|
||||||
|
credit.put("tranId", tranId);
|
||||||
|
credit.put("userId", memberId);
|
||||||
|
credit.put("vendorIdx", vendorIdx);
|
||||||
|
credit.put("vendorKey", vendorKey);
|
||||||
|
credit.put("vendor", "powerball");
|
||||||
|
credit.put("gameIdx", vendorIdx);
|
||||||
|
credit.put("gameKey", gameName+"("+gameTypeName+")");
|
||||||
|
credit.put("gameType", gameType);
|
||||||
|
credit.put("gameId", "");
|
||||||
|
credit.put("tranType", "credit");
|
||||||
|
credit.put("debit", 0);
|
||||||
|
credit.put("credit", amount);
|
||||||
|
credit.put("isCancel", 0);
|
||||||
|
credit.put("isBonus", 0);
|
||||||
|
credit.put("betDetails", detailsArr);
|
||||||
|
|
||||||
|
log.info(LOG_PREFIX + "SEND_CREDIT request body: " + credit.toString());
|
||||||
|
JSONObject resData = new JSONObject();
|
||||||
|
resData = callBackService.changeBalance(LOG_PREFIX, siteVendorInfo, credit);
|
||||||
|
log.info(LOG_PREFIX + "SEND_CREDIT status code: " + resData.getLong("result_code"));
|
||||||
|
log.info(LOG_PREFIX + "SEND_CREDIT response body: " + resData.toString());
|
||||||
|
|
||||||
|
if(resData.getLong("result_code") == 0) {
|
||||||
|
tranParam.put("balance", resData.getInt("balance"));
|
||||||
|
int res = siteService.updateCbApi(tranParam);
|
||||||
|
log.info(LOG_PREFIX + "UPDATE_CALLBACK_API_STATUS END");
|
||||||
|
|
||||||
|
int balance = resData.getInt("balance");
|
||||||
|
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("SUCCESS");
|
||||||
|
response.setMsg("");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance(Integer.toString(balance));
|
||||||
|
response.setData(data);
|
||||||
|
} else {
|
||||||
|
String msg = "";
|
||||||
|
if(resData.has("error_msg")) msg = resData.getString("error_msg");
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg(msg);
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ResourceAccessException rae) {
|
||||||
|
if(rae.getCause() instanceof ConnectTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "ConnectTimeoutException: " + rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rae.getCause() instanceof SocketTimeoutException) {
|
||||||
|
log.error(LOG_PREFIX+ "SocketTimeoutException: " + rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rae.getCause() instanceof InterruptedException) {
|
||||||
|
log.error(LOG_PREFIX+ "InterruptedException: " + rae.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("TIMEOUT_ERROR");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(LOG_PREFIX+ "Exception: " + e.getMessage());
|
||||||
|
response = new PowerballResponse();
|
||||||
|
response.setResult("FAILED");
|
||||||
|
response.setMsg("RESULT_SERVER_ERROR");
|
||||||
|
data = new PowerballData();
|
||||||
|
data.setSiteId(siteId);
|
||||||
|
data.setMemId(id);
|
||||||
|
data.setBalance("0");
|
||||||
|
response.setData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
httpStatus = HttpStatus.OK;
|
||||||
|
log.error(LOG_PREFIX+ "Response Body: " + response.toString());
|
||||||
|
ResponseEntity<PowerballResponse> res = new ResponseEntity<PowerballResponse>(response, httpStatus);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user