스마트서비스 최종완료보고 버전
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
# Getting Started
|
||||
|
||||
### Reference Documentation
|
||||
For further reference, please consider the following sections:
|
||||
|
||||
* [Official Gradle documentation](https://docs.gradle.org)
|
||||
* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.7.3/gradle-plugin/reference/html/)
|
||||
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.7.3/gradle-plugin/reference/html/#build-image)
|
||||
* [Spring Boot DevTools](https://docs.spring.io/spring-boot/docs/2.7.3/reference/htmlsingle/#using.devtools)
|
||||
* [Spring Web](https://docs.spring.io/spring-boot/docs/2.7.3/reference/htmlsingle/#web)
|
||||
* [Spring Session](https://docs.spring.io/spring-session/reference/)
|
||||
* [JDBC API](https://docs.spring.io/spring-boot/docs/2.7.3/reference/htmlsingle/#data.sql)
|
||||
|
||||
### Guides
|
||||
The following guides illustrate how to use some features concretely:
|
||||
|
||||
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
|
||||
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
|
||||
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
|
||||
* [Accessing Relational Data using JDBC with Spring](https://spring.io/guides/gs/relational-data-access/)
|
||||
* [Managing Transactions](https://spring.io/guides/gs/managing-transactions/)
|
||||
|
||||
### Additional Links
|
||||
These additional references should also help you:
|
||||
|
||||
* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
rmdir /q /s .gradle\
|
||||
rmdir /q /s bin\
|
||||
rmdir /q /s build\
|
||||
rmdir /q /s lib\
|
||||
@@ -0,0 +1,56 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '3.2.0'
|
||||
id 'io.spring.dependency-management' version '1.1.3'
|
||||
id 'java'
|
||||
//id 'war'
|
||||
}
|
||||
|
||||
group = 'com.handong'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
sourceCompatibility = '21'
|
||||
targetCompatibility = '21'
|
||||
|
||||
// Configure Java toolchain to use Java 21 for compilation and execution where supported
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
}
|
||||
//apply plugin: 'war'
|
||||
//bootWar.enabled = false
|
||||
//war.enabled = true
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
developmentOnly 'org.springframework.boot:spring-boot-devtools'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
//runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
|
||||
//runtimeOnly 'mysql:mysql-connector-java:5.1.44'
|
||||
runtimeOnly 'com.mysql:mysql-connector-j:8.0.33'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
|
||||
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3'
|
||||
|
||||
implementation 'javax.servlet:jstl:1.2'
|
||||
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
|
||||
implementation 'org.apache.poi:poi:5.2.2'
|
||||
implementation 'org.apache.poi:poi-ooxml:5.2.2'
|
||||
|
||||
// JWT
|
||||
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
|
||||
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
|
||||
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
|
||||
|
||||
// Redis
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
Vendored
+234
@@ -0,0 +1,234 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+89
@@ -0,0 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1 @@
|
||||
rootProject.name = 'smartservice'
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.handong.smartservice.JwtAuth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.UserInfo;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.ExpiredJwtException;
|
||||
import io.jsonwebtoken.JwtException;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
public class JwtAuthFilter extends OncePerRequestFilter {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final JwtProvider jwtProvider;
|
||||
|
||||
|
||||
public JwtAuthFilter(JwtProvider jwtProvider) {
|
||||
this.jwtProvider = jwtProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||
String uri = request.getRequestURI();
|
||||
|
||||
logger.info("doFilterInternal: " + uri);
|
||||
|
||||
//if (uri.compareTo("/api/add-transaction.do") == 0 ||
|
||||
// uri.compareTo("/api/sign-in.do") == 0 ||
|
||||
// uri.compareTo("/api/sval2.do") == 0) {
|
||||
// filterChain.doFilter(request, response);
|
||||
// return;
|
||||
//}
|
||||
if (_AG.isSkipAuthUri(uri)) {
|
||||
filterChain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
String auth = request.getHeader("Authorization");
|
||||
if (auth == null) {
|
||||
//logger.info("doFilterInternal: auth == null");
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (auth != null && auth.startsWith("Bearer ")) {
|
||||
String token = auth.substring(7);
|
||||
if (token == null) {
|
||||
logger.info("doFilterInternal: token == null, req = " + uri);
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Claims claims = jwtProvider.getClaims(token);
|
||||
|
||||
//List<GrantedAuthority> authorities = List.of(new SimpleGrantedAuthority("ROLE_USER"));
|
||||
//UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(_AG.createJwtUserInfo(claims), authorities, List.of());
|
||||
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(_AG.createJwtUserInfo(claims), null, List.of());
|
||||
|
||||
SecurityContext context = SecurityContextHolder.createEmptyContext();
|
||||
context.setAuthentication(authentication);
|
||||
SecurityContextHolder.setContext(context);
|
||||
}
|
||||
catch (ExpiredJwtException e) {
|
||||
//e.printStackTrace();
|
||||
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
||||
return;
|
||||
}
|
||||
catch (JwtException | IllegalArgumentException e) {
|
||||
//e.printStackTrace();
|
||||
logger.info("doFilterInternal, JWT validation failed, uri={}, msg={}", uri, e.getMessage());
|
||||
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.handong.smartservice.JwtAuth;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.ExpiredJwtException;
|
||||
import io.jsonwebtoken.JwtException;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import io.jsonwebtoken.io.Decoders;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Key;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@Component
|
||||
public class JwtProvider {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
//private final long ACCESS_TOKEN_EXPIRE = 1000L * 30; //TestCode 30sec
|
||||
//private final long REFRESH_TOKEN_EXPIRE = 1000L * 60 * 2; //TestCode 2min
|
||||
private final long ACCESS_TOKEN_EXPIRE = 1000L * 60 * 60; // 60min
|
||||
private final long REFRESH_TOKEN_EXPIRE = 1000L * 60 * 60 * 24 * 14; // 14day
|
||||
|
||||
private final Key signingKey;
|
||||
|
||||
private final JwtTokenStore tokenStore;
|
||||
|
||||
public JwtProvider(@Value("${jwt.secret}") String secret) {
|
||||
signingKey = Keys.hmacShaKeyFor(Decoders.BASE64.decode(secret));
|
||||
this.tokenStore = new JwtTokenStoreMap();
|
||||
//this.tokenStore = new JwtTokenStoreRedis();
|
||||
}
|
||||
|
||||
public long getRefreshExpire() {
|
||||
return REFRESH_TOKEN_EXPIRE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public String createAccessToken(Long gid, String user_id, String nick_name, Long permission, Long biz_group_id) {
|
||||
Date now = new Date();
|
||||
return Jwts.builder()
|
||||
.setSubject(gid.toString())
|
||||
.claim("user_id", user_id)
|
||||
.claim("nick_name", nick_name)
|
||||
.claim("permission", permission)
|
||||
.claim("biz_group_id", biz_group_id)
|
||||
.setIssuedAt(now)
|
||||
.setExpiration(new Date(now.getTime() + ACCESS_TOKEN_EXPIRE))
|
||||
.signWith(signingKey, SignatureAlgorithm.HS256)
|
||||
.compact();
|
||||
}
|
||||
*/
|
||||
public String createAccessToken(Long gid, Map<String, Object> claims) {
|
||||
Date now = new Date();
|
||||
return Jwts.builder()
|
||||
.setSubject(gid.toString())
|
||||
.addClaims(claims)
|
||||
.setIssuedAt(now)
|
||||
.setExpiration(new Date(now.getTime() + ACCESS_TOKEN_EXPIRE))
|
||||
.signWith(signingKey, SignatureAlgorithm.HS256)
|
||||
.compact();
|
||||
}
|
||||
|
||||
public String createRefreshToken(Long gid) {
|
||||
Date now = new Date();
|
||||
String token = Jwts.builder()
|
||||
.setSubject(gid.toString())
|
||||
.setIssuedAt(now)
|
||||
.setExpiration(new Date(now.getTime() + REFRESH_TOKEN_EXPIRE))
|
||||
.signWith(signingKey, SignatureAlgorithm.HS256)
|
||||
.compact();
|
||||
|
||||
tokenStore.save(gid, token, REFRESH_TOKEN_EXPIRE);
|
||||
return token;
|
||||
}
|
||||
|
||||
public boolean isValidate(String token) {
|
||||
Long gid = 0L;
|
||||
try {
|
||||
Claims claims = Jwts.parserBuilder()
|
||||
.setSigningKey(signingKey)
|
||||
.build()
|
||||
.parseClaimsJws(token)
|
||||
.getBody();
|
||||
|
||||
if (claims.getExpiration().before(new Date()))
|
||||
return false; // expired
|
||||
|
||||
gid = Long.parseLong(claims.getSubject());
|
||||
|
||||
String storedToken = tokenStore.get(gid);
|
||||
|
||||
if (storedToken != null && token.compareTo(storedToken) == 0)
|
||||
return true;
|
||||
}
|
||||
catch (ExpiredJwtException e) {
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Long getGid(String token) {
|
||||
String strGid = Jwts.parserBuilder()
|
||||
.setSigningKey(signingKey)
|
||||
.build()
|
||||
.parseClaimsJws(token)
|
||||
.getBody()
|
||||
.getSubject();
|
||||
|
||||
return Long.parseLong(strGid);
|
||||
}
|
||||
|
||||
public Claims getClaims(String token) {
|
||||
return Jwts.parserBuilder()
|
||||
.setSigningKey(signingKey)
|
||||
.build()
|
||||
.parseClaimsJws(token)
|
||||
.getBody();
|
||||
}
|
||||
|
||||
public void delete(Long gid) {
|
||||
tokenStore.delete(gid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.handong.smartservice.JwtAuth;
|
||||
|
||||
public interface JwtTokenStore {
|
||||
public String get(Long gid);
|
||||
public void save(Long gid, String token, Long expireTime);
|
||||
public void delete(Long gid);
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.handong.smartservice.JwtAuth;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
public class JwtTokenStoreMap implements JwtTokenStore {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
Map<Long, String> mapToken = new HashMap<>();
|
||||
Map<Long, Long> mapExpire = new HashMap<>();
|
||||
int removeExpireSkip = 0;
|
||||
|
||||
public JwtTokenStoreMap() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Long gid) {
|
||||
return mapToken.get(gid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Long gid, String token, Long expireTime) {
|
||||
if (removeExpireSkip++ > 500) {
|
||||
removeExpireSkip = 0;
|
||||
|
||||
long currTime = System.currentTimeMillis();
|
||||
Iterator<Map.Entry<Long, Long>> iterator = mapExpire.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<Long, Long> entry = iterator.next();
|
||||
|
||||
logger.info("JwtTokenStoreMap, save, expire = " + entry.getValue() + ", currTime = " + currTime);
|
||||
if (entry.getValue() < currTime) {
|
||||
mapToken.remove(entry.getKey());
|
||||
iterator.remove();
|
||||
logger.info("remove refresh token : " + entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mapToken.put(gid, token);
|
||||
mapExpire.put(gid, System.currentTimeMillis() + expireTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Long gid) {
|
||||
mapToken.remove(gid);
|
||||
mapExpire.remove(gid);
|
||||
}
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.handong.smartservice.JwtAuth;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class JwtTokenStoreRedis implements JwtTokenStore {
|
||||
|
||||
//private final StringRedisTemplate redisTemplate;
|
||||
|
||||
//public JwtTokenStoreRedis(StringRedisTemplate redisTemplate) {
|
||||
public JwtTokenStoreRedis() {
|
||||
}
|
||||
|
||||
public String get(Long gid) {
|
||||
//redisTemplate.opsForValue().get("refreshToken:" + gid);
|
||||
return "";
|
||||
}
|
||||
|
||||
public void save(Long gid, String token, Long expireTime) {
|
||||
//redisTemplate.opsForValue().set("refreshToken:" + gid, token, expireTime, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public void delete(Long gid) {
|
||||
//redisTemplate.delete("refreshToken:" + gid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.handong.smartservice;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
/*
|
||||
@Value("${spring.data.redis.host}")
|
||||
private String redisHost;
|
||||
|
||||
@Value("${spring.data.redis.port}")
|
||||
private int redisPort;
|
||||
|
||||
@Value("${spring.data.redis.password}") // 비밀번호 없는 경우 기본값 empty
|
||||
private String redisPassword;
|
||||
|
||||
@Bean
|
||||
public RedisConnectionFactory redisConnectionFactory() {
|
||||
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
|
||||
config.setHostName(redisHost);
|
||||
config.setPort(redisPort);
|
||||
if (!redisPassword.isEmpty()) {
|
||||
config.setPassword(redisPassword);
|
||||
}
|
||||
return new LettuceConnectionFactory(config);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
return new StringRedisTemplate(redisConnectionFactory);
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.handong.smartservice;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
public class ServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(SmartServiceApplication.class);
|
||||
}
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.handong.smartservice;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.handong.smartservice.mapper")
|
||||
public class SmartServiceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SmartServiceApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.handong.smartservice;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.security.web.firewall.HttpFirewall;
|
||||
import org.springframework.security.web.firewall.StrictHttpFirewall;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import com.handong.smartservice.JwtAuth.JwtAuthFilter;
|
||||
import com.handong.smartservice.JwtAuth.JwtProvider;
|
||||
|
||||
|
||||
@EnableTransactionManagement
|
||||
@Configuration
|
||||
public class SpringSecurityConfig {
|
||||
|
||||
private final JwtProvider jwtProvider;
|
||||
|
||||
|
||||
public SpringSecurityConfig(JwtProvider jwtProvider) {
|
||||
this.jwtProvider = jwtProvider;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HttpFirewall allowDoubleSlashFirewall() {
|
||||
StrictHttpFirewall firewall = new StrictHttpFirewall();
|
||||
firewall.setAllowUrlEncodedDoubleSlash(true);
|
||||
// firewall.setAllowSemicolon(true);
|
||||
// firewall.setAllowBackSlash(true);
|
||||
return firewall;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebSecurityCustomizer webSecurityCustomizer(HttpFirewall firewall) {
|
||||
return (web) -> web.httpFirewall(firewall);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager(AuthenticationConfiguration configuration) throws Exception {
|
||||
return configuration.getAuthenticationManager();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
//return http.csrf(csrf -> csrf.disable()).build(); //TestCode
|
||||
|
||||
http.csrf(csrf -> csrf.disable())
|
||||
.sessionManagement(sessionManagement ->
|
||||
sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
||||
)
|
||||
.authorizeHttpRequests(auth -> auth
|
||||
.anyRequest().permitAll()
|
||||
)
|
||||
//.authorizeHttpRequests(auth -> auth
|
||||
// .requestMatchers("/api/sign-in.do").permitAll()
|
||||
// .anyRequest().authenticated()
|
||||
//)
|
||||
.addFilterBefore(new JwtAuthFilter(jwtProvider), UsernamePasswordAuthenticationFilter.class);
|
||||
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
package com.handong.smartservice;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.handong.smartservice.component.UserInfo;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
|
||||
//import com.handong.smartservice.model.OperatingHistoryModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigInteger;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
|
||||
|
||||
@Configuration
|
||||
public class _AG {
|
||||
static public String MEDIA_UPLOAD_LOCAL_PATH;
|
||||
|
||||
//@Value("${app-global.upload-file-path}")
|
||||
void setMEDIA_UPLOAD_LOCAL_PATH(String str) {
|
||||
MEDIA_UPLOAD_LOCAL_PATH = str;
|
||||
}
|
||||
|
||||
public static String getCurrentDateTime() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.KOREA);
|
||||
Date date = new Date();
|
||||
return simpleDateFormat.format(date);
|
||||
}
|
||||
|
||||
// Timestamp to yyyy-MM-dd HH:mm:ss
|
||||
public static String timestampToStr(Object timestamp) {
|
||||
if (timestamp == null)
|
||||
return "";
|
||||
String str = timestamp.toString();
|
||||
return str.substring(0, str.length() - 2);
|
||||
}
|
||||
|
||||
static public boolean hasText(String str) {
|
||||
if (str == null || str.isEmpty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static public String safeStr(String str) {
|
||||
if (str == null || str.isEmpty())
|
||||
return "";
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static public Long toLong(String str) {
|
||||
if (str == null || str.isEmpty())
|
||||
return 0L;
|
||||
|
||||
return Long.parseLong(str);
|
||||
}
|
||||
|
||||
static public Long toLongOrNull(String str) {
|
||||
if (str == null || str.isEmpty())
|
||||
return null;
|
||||
|
||||
return Long.parseLong(str);
|
||||
}
|
||||
|
||||
static public Long toLong(Integer obj) {
|
||||
if (obj == null)
|
||||
return 0L;
|
||||
|
||||
return obj.longValue();
|
||||
}
|
||||
|
||||
static public Long toLong(BigInteger obj) {
|
||||
if (obj == null)
|
||||
return 0L;
|
||||
|
||||
return obj.longValue();
|
||||
}
|
||||
|
||||
static public Boolean toBoolean(String str) {
|
||||
if (str == null || str.isEmpty())
|
||||
return false;
|
||||
|
||||
return Boolean.parseBoolean(str);
|
||||
}
|
||||
|
||||
static public String mapToJson(Map<String, Object> map) {
|
||||
String json = "{}";
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
//json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(data);
|
||||
json = mapper.writeValueAsString(map);
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
static public String mapToJson2(Map<String, String> map) {
|
||||
String json = "{}";
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
//json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(data);
|
||||
json = mapper.writeValueAsString(map);
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
static public String saveUploadedFile(MultipartFile[] attached_files, String strFileName) {
|
||||
Date today = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Seoul"));
|
||||
|
||||
String strSaveFileName = dateFormat.format(today) + "_" + strFileName;
|
||||
|
||||
try {
|
||||
File file = new File(_AG.MEDIA_UPLOAD_LOCAL_PATH + strSaveFileName);
|
||||
attached_files[0].transferTo(file);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
return strSaveFileName;
|
||||
}
|
||||
|
||||
static public Long getNumberFromQuery(String strColName, List<Map<String, Object>> qeuryResult) {
|
||||
if (qeuryResult == null || qeuryResult.size() == 0)
|
||||
return 0L;
|
||||
|
||||
return (Long)qeuryResult.get(0).get(strColName);
|
||||
}
|
||||
|
||||
static public String getIpAddr(HttpServletRequest request) {
|
||||
String ip = request.getHeader("X-Forwarded-For");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("X-Real-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("X-RealIP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("REMOTE_ADDR");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
if (ip != null && !ip.isEmpty()) {
|
||||
ip = ip.split(",")[0].trim();
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
//static public void addHistory(EntityManager entityManager, int nType, String strAction, String gid) {
|
||||
// OperatingHistoryModel operatingHistoryModel = new OperatingHistoryModel(entityManager);
|
||||
// operatingHistoryModel.addOperatingHistory(nType, strAction, gid);
|
||||
//}
|
||||
|
||||
//JWT Auth
|
||||
static public boolean isSkipAuthUri(String uri) {
|
||||
if (uri.compareTo("/api/miss-slot.do") == 0 ||
|
||||
uri.compareTo("/api/terminal-state.do") == 0 ||
|
||||
uri.compareTo("/api/sign-in.do") == 0 ||
|
||||
uri.compareTo("/api/sval2.do") == 0 ||
|
||||
uri.compareTo("/api/add-transaction.do") == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static public UserInfo createJwtUserInfo(Claims claims) {
|
||||
UserInfo principal = new UserInfo(
|
||||
Long.parseLong(claims.getSubject()),
|
||||
claims.get("user_id", String.class),
|
||||
claims.get("nick_name", String.class),
|
||||
claims.get("permission", Number.class),
|
||||
claims.get("biz_group_id", Number.class)
|
||||
);
|
||||
return principal;
|
||||
}
|
||||
|
||||
static public Map<String, Object> createUserInfoMap(String user_id, String nick_name, Long permission, Long biz_group_id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("user_id", user_id);
|
||||
map.put("nick_name", nick_name);
|
||||
map.put("permission", permission);
|
||||
map.put("biz_group_id", biz_group_id);
|
||||
return map;
|
||||
}
|
||||
//
|
||||
|
||||
// 사업자 번호 하이픈 자동추가
|
||||
static public String formatBusinessNumber(String input) {
|
||||
String digits = input.replaceAll("\\D", "");
|
||||
|
||||
if (digits.length() > 10) {
|
||||
digits = digits.substring(0, 10);
|
||||
}
|
||||
|
||||
return digits.replaceFirst("^(\\d{3})(\\d{2})(\\d{5})$", "$1-$2-$3");
|
||||
}
|
||||
|
||||
// 사업자번호 검증
|
||||
static public boolean isValidBusinessNumber(String input) {
|
||||
//return true; //TestCode
|
||||
|
||||
String digits = input.replaceAll("\\D", "");
|
||||
if (digits.length() != 10) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int[] weights = {1, 3, 7, 1, 3, 7, 1, 3, 5};
|
||||
int sum = 0;
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
int num = Character.getNumericValue(digits.charAt(i));
|
||||
sum += num * weights[i];
|
||||
}
|
||||
|
||||
sum += (Character.getNumericValue(digits.charAt(8)) * 5) / 10;
|
||||
|
||||
int checkDigit = (10 - (sum % 10)) % 10;
|
||||
return checkDigit == Character.getNumericValue(digits.charAt(9));
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.handong.smartservice.component;
|
||||
|
||||
public class CtErrorCode {
|
||||
static public final int NO_ERROR = 0;
|
||||
static public final int FAILED_CONNECT_DB = -2;
|
||||
static public final int QUERY_ERROR = -3;
|
||||
static public final int EXCEPTION_OCCRUED = -5;
|
||||
static public final int INVALID_PARAMETER = -6;
|
||||
static public final int FILE_IO_ERROR = -7;
|
||||
|
||||
static public final int UNCORRECT_DATA = -8;
|
||||
static public final int INVALID_USER = -9;
|
||||
static public final int ALREADY_EXIST = -11;
|
||||
static public final int THIRDPARTY_ERROR = -12;
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package com.handong.smartservice.component;
|
||||
|
||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.apache.poi.poifs.crypt.EncryptionInfo;
|
||||
import org.apache.poi.poifs.crypt.EncryptionMode;
|
||||
import org.apache.poi.poifs.crypt.Encryptor;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
|
||||
public class CtExcelMaker {
|
||||
static private final Logger logger = LoggerFactory.getLogger(CtExcelMaker.class);
|
||||
|
||||
static public String getBrowser(HttpServletRequest request) {
|
||||
String header = request.getHeader("User-Agent");
|
||||
if (header.indexOf("MSIE") > -1) {
|
||||
return "MSIE";
|
||||
} else if (header.indexOf("Trident") > -1) {
|
||||
return "Trident";
|
||||
} else if (header.indexOf("Chrome") > -1) {
|
||||
return "Chrome";
|
||||
} else if (header.indexOf("Opera") > -1) {
|
||||
return "Opera";
|
||||
}
|
||||
return "Firefox";
|
||||
}
|
||||
|
||||
static public void makeExcelResponse(HttpServletRequest request, HttpServletResponse response,
|
||||
String strFileName, String[] arrHeader, String[] arrColumn, List<Map<String, String>> listContents, String strPassword) {
|
||||
logger.info("ExcelLeader, makeExcelResponse, file name = " + strFileName);
|
||||
|
||||
try {
|
||||
XSSFRow row = null;
|
||||
XSSFCell cell = null;
|
||||
int nRowIndex = 0;
|
||||
|
||||
XSSFWorkbook workBook = new XSSFWorkbook();
|
||||
|
||||
XSSFSheet sheet = workBook.createSheet("sheet");
|
||||
|
||||
row = sheet.createRow(nRowIndex++);
|
||||
|
||||
// header
|
||||
int i = 0;
|
||||
for (; i < arrHeader.length; i++) {
|
||||
cell = row.createCell(i);
|
||||
cell.setCellValue(new XSSFRichTextString(arrHeader[i]));
|
||||
}
|
||||
|
||||
for (i = 0; i < listContents.size(); i++) {
|
||||
Map<String, String> col = listContents.get(i);
|
||||
|
||||
row = sheet.createRow(nRowIndex++);
|
||||
Object cellData;
|
||||
for (int j = 0; j < arrColumn.length; j++) {
|
||||
cell = row.createCell(j);
|
||||
cellData = col.get(arrColumn[j]);
|
||||
if (cellData == null)
|
||||
cell.setCellValue(new XSSFRichTextString(""));
|
||||
else
|
||||
cell.setCellValue(new XSSFRichTextString(cellData.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
String strTmp = strFileName + ".xlsx";
|
||||
String browser = getBrowser(request);
|
||||
if (browser.contains("MSIE") || browser.contains("Trident")) {
|
||||
String strDownloadName = URLEncoder.encode(strTmp, "UTF-8").replaceAll("\\+", "%20");
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + strDownloadName + ";");
|
||||
} else {
|
||||
//val strDownloadName = String(strTmp.toByteArray(Charsets.UTF_8), Charsets.ISO_8859_1)
|
||||
String strDownloadName = URLEncoder.encode(strTmp, "UTF-8");
|
||||
response.addHeader("Content-Disposition", "attachment;filename=\"" + strDownloadName + "\"");
|
||||
}
|
||||
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||
|
||||
//fuck!!! not working over poi 4
|
||||
if (strPassword != null && strPassword.isEmpty() == false) {
|
||||
EncryptionInfo info = new EncryptionInfo(EncryptionMode.standard);
|
||||
Encryptor encryptor = info.getEncryptor();
|
||||
encryptor.confirmPassword(strPassword);
|
||||
|
||||
ByteArrayOutputStream osByteArray = new ByteArrayOutputStream();
|
||||
workBook.write(osByteArray);
|
||||
InputStream isTmp = new ByteArrayInputStream(osByteArray.toByteArray());
|
||||
OPCPackage opc = OPCPackage.open(isTmp);
|
||||
POIFSFileSystem poifs = new POIFSFileSystem();
|
||||
OutputStream osTemp = encryptor.getDataStream(poifs);
|
||||
opc.save(osTemp);
|
||||
opc.close();
|
||||
|
||||
OutputStream osResponse = response.getOutputStream();
|
||||
poifs.writeFilesystem(osResponse);
|
||||
osResponse.close();
|
||||
osByteArray.close();
|
||||
return;
|
||||
}
|
||||
|
||||
OutputStream osResponse = response.getOutputStream();
|
||||
workBook.write(osResponse);
|
||||
osResponse.close();
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.handong.smartservice.component;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CtResponse extends HashMap<String, Object> {
|
||||
|
||||
public CtResponse() {
|
||||
put("errCode", ErrorCode.NO_ERROR);
|
||||
}
|
||||
|
||||
public CtResponse(String key, Object obj) {
|
||||
put("errCode", ErrorCode.NO_ERROR);
|
||||
put(key, obj);
|
||||
}
|
||||
|
||||
public CtResponse(int errCode) {
|
||||
put("errCode", errCode);
|
||||
}
|
||||
|
||||
public int errCode() {
|
||||
return (int)get("errCode");
|
||||
}
|
||||
|
||||
public void setErrCode(int errCode) {
|
||||
put("errCode", errCode);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
String json = "{}";
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
//json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(data);
|
||||
json = mapper.writeValueAsString(this);
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.handong.smartservice.component;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.handong.smartservice.mapper.BizGroupMapper;
|
||||
import com.handong.smartservice.mapper.OperatingHistoryMapper;
|
||||
|
||||
@Component
|
||||
public class DbLogger {
|
||||
private static OperatingHistoryMapper operatingHistoryMapper;
|
||||
|
||||
@Autowired
|
||||
public DbLogger(OperatingHistoryMapper mapper){
|
||||
DbLogger.operatingHistoryMapper = mapper;
|
||||
}
|
||||
|
||||
public static void insert(Long type, String action, Long gid) {
|
||||
operatingHistoryMapper.insertOperatingHistory(type, action, gid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.handong.smartservice.component;
|
||||
|
||||
public class ErrorCode extends CtErrorCode {
|
||||
static public final int INVALID_TOKEN = -15;
|
||||
static public final int INVALID_REFRESH = -16;
|
||||
|
||||
static public final int INVALID_BIZ_REG_NUM = -17;
|
||||
//...
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.handong.smartservice.component;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public abstract class RcTree {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
|
||||
protected abstract Map<String, Object> makeNewNode(Map<String, Object> item);
|
||||
|
||||
|
||||
public Map<String, Object> searchTreeNode(List<Map<String, Object>> listRcTree, String key) {
|
||||
Map<String, Object> node = null;
|
||||
|
||||
for(int i = 0; i < listRcTree.size(); i++) {
|
||||
node = listRcTree.get(i);
|
||||
if (key.compareTo((String)node.get("key")) == 0) {
|
||||
return node;
|
||||
}
|
||||
|
||||
Object children = node.get("children");
|
||||
if (children != null) {
|
||||
Map<String, Object> parentNode = searchTreeNode((List<Map<String, Object>>)children, key);
|
||||
if (parentNode != null)
|
||||
return parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> convert(List<Map<String, Object>> listTreeDb) {
|
||||
List<Map<String, Object>> listRcTree = new ArrayList<Map<String, Object>>();
|
||||
listTreeDb.forEach(item -> {
|
||||
Map<String, Object> newNode = makeNewNode(item);
|
||||
|
||||
if (item.get("pid") == null || listRcTree.size() == 0) {
|
||||
listRcTree.add(newNode);
|
||||
}
|
||||
else {
|
||||
// search parent node
|
||||
final String pid = item.get("pid") != null ? item.get("pid").toString() : "";
|
||||
logger.debug("pid = " + pid);
|
||||
|
||||
Map<String, Object> parentNode = searchTreeNode(listRcTree, pid);
|
||||
logger.debug("convert, parentNode = " + parentNode);
|
||||
|
||||
if (parentNode != null) {
|
||||
List<Map<String, Object>> children = null;
|
||||
Object childrenNode = parentNode.get("children");
|
||||
if (childrenNode == null) {
|
||||
children = new ArrayList<Map<String, Object>>();
|
||||
}
|
||||
else {
|
||||
children = (List<Map<String, Object>>)childrenNode;
|
||||
}
|
||||
children.add(newNode);
|
||||
parentNode.put("children", children);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return listRcTree;
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package com.handong.smartservice.component;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
|
||||
public class RcTreeBizGroup extends RcTree {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public static List<Map<String, Object>> convertDb2RcTree(List<Map<String, Object>> listTreeDb) {
|
||||
RcTree rcTree = new RcTreeBizGroup();
|
||||
return rcTree.convert(listTreeDb);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> makeNewNode(Map<String, Object> item) {
|
||||
Map<String, Object> newNode = new LinkedHashMap<String, Object>();
|
||||
|
||||
String biz_group_id = item.get("biz_group_id").toString();
|
||||
newNode.put("key", biz_group_id);
|
||||
logger.debug("key(biz_group_id): " + biz_group_id);
|
||||
|
||||
String name = (String)item.get("name");
|
||||
newNode.put("name", name);
|
||||
|
||||
String biz_reg_num = _AG.formatBusinessNumber((String)item.get("biz_reg_num"));
|
||||
newNode.put("biz_reg_num", biz_reg_num);
|
||||
|
||||
//... newNode.put("title", name + "(" + biz_reg_num + ")");
|
||||
newNode.put("title", name);
|
||||
logger.debug("title(name): " + name);
|
||||
|
||||
Timestamp reg_time = (Timestamp)item.get("reg_time");
|
||||
if (reg_time != null)
|
||||
newNode.put("reg_time", reg_time);
|
||||
|
||||
String email = (String)item.get("email");
|
||||
if (email != null)
|
||||
newNode.put("email", email);
|
||||
|
||||
String phone = (String)item.get("phone");
|
||||
if (phone != null)
|
||||
newNode.put("phone", phone);
|
||||
|
||||
String ceo = (String)item.get("ceo");
|
||||
if (ceo != null)
|
||||
newNode.put("ceo", ceo);
|
||||
|
||||
String address = (String)item.get("address");
|
||||
if (address != null)
|
||||
newNode.put("address", address);
|
||||
|
||||
Long top_group_id = (Long)item.get("top_group_id");
|
||||
if (address != null)
|
||||
newNode.put("top_group_id", top_group_id);
|
||||
|
||||
Long hasChildren = (Long)item.get("hasChildren");
|
||||
newNode.put("isLeaf", hasChildren == null || hasChildren == 0 ? true : false);
|
||||
|
||||
return newNode;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.handong.smartservice.component;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RcTreeLocation extends RcTree {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public static List<Map<String, Object>> convertDb2RcTree(List<Map<String, Object>> listTreeDb) {
|
||||
RcTree rcTree = new RcTreeLocation();
|
||||
return rcTree.convert(listTreeDb);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> makeNewNode(Map<String, Object> item) {
|
||||
Map<String, Object> newNode = new LinkedHashMap<String, Object>();
|
||||
|
||||
String location = item.get("location_id").toString();
|
||||
newNode.put("key", location);
|
||||
logger.debug("key(biz_group_id): " + location);
|
||||
|
||||
String name = (String)item.get("name");
|
||||
newNode.put("name", name);
|
||||
|
||||
String description = (String)item.get("description");
|
||||
newNode.put("description", description);
|
||||
|
||||
newNode.put("title", name);
|
||||
logger.debug("title: " + name);
|
||||
|
||||
Timestamp reg_time = (Timestamp)item.get("reg_time");
|
||||
if (reg_time != null)
|
||||
newNode.put("reg_time", reg_time);
|
||||
|
||||
String address = (String)item.get("address");
|
||||
if (address != null)
|
||||
newNode.put("address", address);
|
||||
|
||||
newNode.put("isLeaf", false);
|
||||
|
||||
return newNode;
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
package com.handong.smartservice.component;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RcTree_old {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public static List<Map<String, Object>> convertDb2RcTree(List<Map<String, Object>> listTreeDb) {
|
||||
RcTree_old rcTree = new RcTree_old();
|
||||
return rcTree.convert(listTreeDb);
|
||||
}
|
||||
|
||||
public Map<String, Object> searchTreeNode(List<Map<String, Object>> listRcTree, String key) {
|
||||
Map<String, Object> node = null;
|
||||
|
||||
for(int i = 0; i < listRcTree.size(); i++) {
|
||||
node = listRcTree.get(i);
|
||||
if (key.compareTo((String)node.get("key")) == 0) {
|
||||
return node;
|
||||
}
|
||||
|
||||
Object children = node.get("children");
|
||||
if (children != null) {
|
||||
Map<String, Object> parentNode = searchTreeNode((List<Map<String, Object>>)children, key);
|
||||
if (parentNode != null)
|
||||
return parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> convert(List<Map<String, Object>> listTreeDb) {
|
||||
List<Map<String, Object>> listRcTree = new ArrayList<Map<String, Object>>();
|
||||
listTreeDb.forEach(item -> {
|
||||
Map<String, Object> newNode = new LinkedHashMap<String, Object>();
|
||||
|
||||
String biz_group_id = item.get("biz_group_id").toString();
|
||||
newNode.put("key", biz_group_id);
|
||||
logger.debug("key(biz_group_id): " + biz_group_id);
|
||||
|
||||
String name = (String)item.get("name");
|
||||
newNode.put("name", name);
|
||||
|
||||
String biz_reg_num = (String)item.get("biz_reg_num");
|
||||
newNode.put("biz_reg_num", biz_reg_num);
|
||||
|
||||
newNode.put("title", name + "(" + biz_reg_num + ")");
|
||||
logger.debug("title(name): " + name);
|
||||
|
||||
Timestamp reg_time = (Timestamp)item.get("reg_time");
|
||||
if (reg_time != null)
|
||||
newNode.put("reg_time", reg_time);
|
||||
|
||||
String email = (String)item.get("email");
|
||||
if (email != null)
|
||||
newNode.put("email", email);
|
||||
|
||||
String phone = (String)item.get("phone");
|
||||
if (phone != null)
|
||||
newNode.put("phone", phone);
|
||||
|
||||
String ceo = (String)item.get("ceo");
|
||||
if (ceo != null)
|
||||
newNode.put("ceo", ceo);
|
||||
|
||||
String address = (String)item.get("address");
|
||||
if (address != null)
|
||||
newNode.put("address", address);
|
||||
|
||||
newNode.put("isLeaf", false);
|
||||
|
||||
if (item.get("pid") == null || listRcTree.size() == 0) {
|
||||
listRcTree.add(newNode);
|
||||
}
|
||||
else {
|
||||
// search parent node
|
||||
final String pid = item.get("pid") != null ? item.get("pid").toString() : "";
|
||||
logger.debug("pid = " + pid);
|
||||
|
||||
Map<String, Object> parentNode = searchTreeNode(listRcTree, pid);
|
||||
logger.debug("convert, parentNode = " + parentNode);
|
||||
|
||||
if (parentNode != null) {
|
||||
List<Map<String, Object>> children = null;
|
||||
Object childrenNode = parentNode.get("children");
|
||||
if (childrenNode == null) {
|
||||
children = new ArrayList<Map<String, Object>>();
|
||||
}
|
||||
else {
|
||||
children = (List<Map<String, Object>>)childrenNode;
|
||||
}
|
||||
children.add(newNode);
|
||||
parentNode.put("children", children);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return listRcTree;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.handong.smartservice.component;
|
||||
|
||||
public class UserInfo {
|
||||
|
||||
private final Long gid;
|
||||
private final String userId;
|
||||
private final String nickName;
|
||||
private final Long permission;
|
||||
private final Long bizGroupId;
|
||||
|
||||
public UserInfo(Long gid, String user_id, String nick_name, Number permission, Number bizGroupId) {
|
||||
this.gid = gid;
|
||||
this.userId = user_id;
|
||||
this.nickName = nick_name;
|
||||
this.permission = permission != null ? permission.longValue() : 0L;
|
||||
this.bizGroupId = bizGroupId != null ? bizGroupId.longValue() : 0L;
|
||||
}
|
||||
|
||||
public Long getGid() { return gid; }
|
||||
public String getUserId() { return userId; }
|
||||
public String getNickName() { return nickName; }
|
||||
public Long getPermission() { return permission; }
|
||||
public Long getBizGroupId() { return bizGroupId; }
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.handong.smartservice.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
|
||||
@Controller
|
||||
public class IndexController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@RequestMapping(value = {"/", "/index"}, method = RequestMethod.GET)
|
||||
public String index(HttpServletRequest request, HttpServletResponse response) {
|
||||
//logger.info("[TRACE] session : " + AppGlobal.sessionToMap(session).toString());
|
||||
|
||||
//if (session.getAttribute("account_id") == null) {
|
||||
// session.invalidate();
|
||||
// return "redirect:/login";
|
||||
//}
|
||||
|
||||
return "/index";
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtExcelMaker;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.mapper.AccountMapper;
|
||||
import com.handong.smartservice.service.AccountService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class AccountController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final AccountService accountService;
|
||||
|
||||
|
||||
public AccountController(AccountService accountService) {
|
||||
this.accountService = accountService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-account.do", method = RequestMethod.POST)
|
||||
public CtResponse getAccountList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
|
||||
Boolean is_group_access = _AG.toBoolean(body.get("is_group_access"));
|
||||
String nick_name = body.get("nick_name");
|
||||
String user_id = body.get("user_id");
|
||||
String email = body.get("email");
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
|
||||
Map<String, Object> mapResult = accountService.getAccountList(offset, limit, date_start, date_end, is_excel, is_group_access, user_id, email, nick_name, biz_group_id);
|
||||
|
||||
if (is_excel) {
|
||||
List<Map<String, String>> list = (List<Map<String, String>>)mapResult.get("list");
|
||||
|
||||
for (Map<String, String> item : list) {
|
||||
item.replace("reg_time", _AG.timestampToStr(item.get("reg_time")));
|
||||
}
|
||||
|
||||
String[] arrHeader = {"등록일", "그룹", "아이디", "닉네임", "이메일", "상태"};
|
||||
String[] arrColumn = {"reg_time", "biz_group_name", "user_id", "nick_name", "email", "state"};
|
||||
|
||||
CtExcelMaker.makeExcelResponse(request, response, "계정목록", arrHeader, arrColumn, list, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse addOrModifyAccount(boolean isModify, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long gid = _AG.toLong(body.get("gid"));
|
||||
String user_id = body.get("user_id");
|
||||
String user_pw = body.get("user_pw");
|
||||
String email = body.get("email");
|
||||
String nick_name = body.get("nick_name");
|
||||
Long state = _AG.toLong(body.get("state"));
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
Long new_biz_group_id = _AG.toLong(body.get("new_biz_group_id"));
|
||||
|
||||
if (user_id == null || user_id.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = accountService.addOrModifyAccount(isModify, gid, user_id, user_pw, email, nick_name, state, biz_group_id, new_biz_group_id);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add-account.do", method = RequestMethod.POST)
|
||||
public CtResponse addAccount(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyAccount(false, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/modify-account.do", method = RequestMethod.POST)
|
||||
public CtResponse modifyAccount(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyAccount(true, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/remove-account.do", method = RequestMethod.POST)
|
||||
public CtResponse removeAccount(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
String ids = body.get("ids");
|
||||
|
||||
return accountService.removeAccount(ids);
|
||||
}
|
||||
}
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.JwtAuth.JwtProvider;
|
||||
import com.handong.smartservice.component.CtErrorCode;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.component.UserInfo;
|
||||
import com.handong.smartservice.service.AccountService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class AuthController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final AccountService accountService;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
private final JwtProvider jwtProvider;
|
||||
|
||||
|
||||
public AuthController(AccountService accountService, PasswordEncoder passwordEncoder, JwtProvider jwtProvider) {
|
||||
this.accountService = accountService;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
this.jwtProvider = jwtProvider;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/sign-in.do", method = RequestMethod.POST)
|
||||
public CtResponse signIn(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
String user_id = body.get("id");
|
||||
String user_pw = body.get("pw");
|
||||
|
||||
logger.info("user_id = " + user_id); //TestComment
|
||||
|
||||
CtResponse result = accountService.getAccount(0L, user_id);
|
||||
Map<String, Object> mapAccount = (Map<String, Object>)result.get("result");
|
||||
|
||||
if (mapAccount == null) { // not found
|
||||
result.setErrCode(ErrorCode.INVALID_USER);
|
||||
return result;
|
||||
}
|
||||
|
||||
if ("2".equals(mapAccount.get("state"))) { // stopped user
|
||||
result.setErrCode(ErrorCode.INVALID_USER);
|
||||
return result;
|
||||
}
|
||||
|
||||
Long gid = (Long)mapAccount.get("gid");
|
||||
logger.info("gid: " + gid);
|
||||
|
||||
String nick_name = (String)mapAccount.get("nick_name");
|
||||
Long permission = (Long)mapAccount.get("permission");
|
||||
Long biz_group_id = (Long)mapAccount.get("biz_group_id");
|
||||
String encPw = (String)mapAccount.get("user_pw");
|
||||
// 1 : $2a$10$HaPODuNOvfKE/MD0JxTrX.CxZ4zeGxjmcwaGE.jyx0KzWGQh3vVeG
|
||||
// 1234: $2a$10$fg4gH81OiYVm3AItCvKQvOPWnRx8YsXHymIDJI88XCTKk/3Kah092
|
||||
|
||||
// password check
|
||||
logger.info("------ enc pw: " + passwordEncoder.encode(user_pw));
|
||||
if (passwordEncoder.matches(user_pw, encPw) == false) {
|
||||
result.setErrCode(ErrorCode.INVALID_USER);
|
||||
return result;
|
||||
}
|
||||
|
||||
//mapAccount.put("sval1", jwtProvider.createAccessToken(gid, user_id, nick_name, permission, biz_group_id));
|
||||
mapAccount.put("sval1", jwtProvider.createAccessToken(gid, _AG.createUserInfoMap(user_id, nick_name, permission, biz_group_id)));
|
||||
String refreshToken = jwtProvider.createRefreshToken(gid);
|
||||
|
||||
/*
|
||||
ResponseCookie cookie = ResponseCookie.from("sval2", refreshToken)
|
||||
.httpOnly(true)
|
||||
.secure(true)
|
||||
.sameSite("Strict")
|
||||
.path("/")
|
||||
.maxAge(jwtProvider.getRefreshExpire())
|
||||
.build();
|
||||
*/
|
||||
ResponseCookie cookie = ResponseCookie.from("sval2", refreshToken)
|
||||
.httpOnly(true)
|
||||
.secure(false)
|
||||
.sameSite("Lax")
|
||||
.path("/")
|
||||
.build();
|
||||
response.addHeader("Set-Cookie", cookie.toString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/sign-out.do", method = RequestMethod.POST)
|
||||
public CtResponse signOut(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody Map<String, String> body, Authentication authentication) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
Long gid = _AG.toLong(body.get("gid"));
|
||||
UserInfo userInfo = (UserInfo)authentication.getPrincipal();
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
if (gid != userInfo.getGid()) {
|
||||
result.setErrCode(CtErrorCode.UNCORRECT_DATA);
|
||||
return result;
|
||||
}
|
||||
|
||||
jwtProvider.delete(gid);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/sval2.do") // security value 2(token refresh)
|
||||
public ResponseEntity<?> tokenRefresh(HttpServletRequest request, @CookieValue(value = "sval2", required = false) String refreshToken) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
if (refreshToken == null) {
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
||||
}
|
||||
|
||||
if (jwtProvider.isValidate(refreshToken) == false) {
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
||||
}
|
||||
|
||||
Long gid = jwtProvider.getGid(refreshToken);
|
||||
|
||||
logger.info("gid: " + gid);
|
||||
|
||||
CtResponse result = accountService.getAccount(gid, null);
|
||||
Map<String, Object> mapAccount = (Map<String, Object>)result.get("result");
|
||||
|
||||
if (mapAccount == null) { // not found
|
||||
result.setErrCode(ErrorCode.INVALID_USER);
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
if ("2".equals(mapAccount.get("state"))) { // stopped user
|
||||
result.setErrCode(ErrorCode.INVALID_USER);
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
String user_id = (String)mapAccount.get("user_id");
|
||||
String nick_name = (String)mapAccount.get("user_id");
|
||||
Long permission = (Long)mapAccount.get("permission");
|
||||
Long biz_group_id = (Long)mapAccount.get("biz_group_id");
|
||||
//String newAccessToken = jwtProvider.createAccessToken(gid, user_id, nick_name, permission, biz_group_id);
|
||||
String newAccessToken = jwtProvider.createAccessToken(gid, _AG.createUserInfoMap(user_id, nick_name, permission, biz_group_id));
|
||||
|
||||
mapAccount.put("sval1", newAccessToken);
|
||||
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.mapper.BizGroupMapper;
|
||||
import com.handong.smartservice.service.BizGroupService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class BizGroupController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final BizGroupService bizGroupService;
|
||||
|
||||
|
||||
public BizGroupController(BizGroupService bizGroupService) {
|
||||
this.bizGroupService = bizGroupService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-biz-group.do", method = RequestMethod.POST)
|
||||
public CtResponse getBizGroupList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long offset = _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
String name = body.get("name");
|
||||
|
||||
String biz_reg_num = body.get("biz_reg_num");
|
||||
if (biz_reg_num != null && biz_reg_num.isEmpty() == false) {
|
||||
biz_reg_num = biz_reg_num.replaceAll("-", "");
|
||||
}
|
||||
|
||||
String email = body.get("email");
|
||||
String phone = body.get("phone");
|
||||
String address = body.get("address");
|
||||
|
||||
Map<String, Object> mapResult = bizGroupService.getBizGroupList(offset, limit, date_start, date_end, name, biz_reg_num, email, phone, address);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public CtResponse addOrModifyBizGroup(boolean isModify, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
Long pid = _AG.toLong(body.get("pid"));
|
||||
Long top_group_id = _AG.toLong(body.get("top_group_id"));
|
||||
String name = body.get("name");
|
||||
|
||||
|
||||
String biz_reg_num = body.get("biz_reg_num");
|
||||
|
||||
if (biz_reg_num != null && biz_reg_num.isEmpty() == false) {
|
||||
biz_reg_num = biz_reg_num.replaceAll("-", "");
|
||||
if (_AG.isValidBusinessNumber(biz_reg_num) == false) {
|
||||
result.setErrCode(ErrorCode.INVALID_BIZ_REG_NUM);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
String email = body.get("email");
|
||||
String phone = body.get("phone");
|
||||
String ceo = body.get("ceo");
|
||||
String address = body.get("address");
|
||||
|
||||
//if (name == null || name.isEmpty() || biz_reg_num == null || biz_reg_num.isEmpty()) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = bizGroupService.addOrModifyBizGroup(isModify, biz_group_id, pid, top_group_id, name, biz_reg_num, email, phone, ceo, address);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add-biz-group.do", method = RequestMethod.POST)
|
||||
public CtResponse addBizGroup(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyBizGroup(false, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/modify-biz-group.do", method = RequestMethod.POST)
|
||||
public CtResponse modifyBizGroup(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyBizGroup(true, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/remove-biz-group.do", method = RequestMethod.POST)
|
||||
public CtResponse removeBizGroup(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
String ids = body.get("ids");
|
||||
|
||||
CtResponse result = bizGroupService.removeBizGroup(ids);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// ver 2
|
||||
@RequestMapping(value = "/get-biz-group2.do", method = RequestMethod.POST)
|
||||
public CtResponse getBizGroup2(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
Boolean isRoot = _AG.toBoolean(body.get("isRoot"));
|
||||
Long pid = _AG.toLong(body.get("pid"));
|
||||
Long top_group_id = _AG.toLong(body.get("top_group_id"));
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
String name = body.get("name");
|
||||
|
||||
String biz_reg_num = body.get("biz_reg_num");
|
||||
if (biz_reg_num != null && biz_reg_num.isEmpty() == false) {
|
||||
biz_reg_num = biz_reg_num.replaceAll("-", "");
|
||||
}
|
||||
|
||||
return bizGroupService.getBizGroup2(isRoot, pid, top_group_id, date_start, date_end, name, biz_reg_num);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-biz-group3.do", method = RequestMethod.POST)
|
||||
public CtResponse getBizGroup3(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
|
||||
return bizGroupService.getBizGroup3(biz_group_id);
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import com.handong.smartservice.component.CtExcelMaker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.service.DeviceService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class DeviceController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final DeviceService deviceService;
|
||||
|
||||
|
||||
public DeviceController(DeviceService deviceService) {
|
||||
this.deviceService = deviceService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-device.do", method = RequestMethod.POST)
|
||||
public CtResponse getDeviceList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
Boolean is_group_access = _AG.toBoolean(body.get("is_group_access"));
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
String name = body.get("name");
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
|
||||
Map<String, Object> mapResult = deviceService.getDeviceList(is_excel, offset, limit, is_group_access, biz_group_id, name, date_start, date_end);
|
||||
|
||||
if (is_excel) {
|
||||
List<Map<String, String>> list = (List<Map<String, String>>)mapResult.get("list");
|
||||
|
||||
for (Map<String, String> item : list) {
|
||||
item.replace("reg_time", _AG.timestampToStr(item.get("reg_time")));
|
||||
item.replace("connect_time", _AG.timestampToStr(item.get("connect_time")));
|
||||
item.replace("disconnect_time", _AG.timestampToStr(item.get("disconnect_time")));
|
||||
}
|
||||
|
||||
String[] arrHeader = {"등록일", "그룹", "장치명", "단말기TID", "가동시간", "장애발생시간", "관리자"};
|
||||
String[] arrColumn = {"reg_time", "biz_group_name", "name", "uid1", "connect_time", "disconnect_time", "manager_name"};
|
||||
|
||||
CtExcelMaker.makeExcelResponse(request, response, "무인기기목록", arrHeader, arrColumn, list, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public CtResponse addOrModifyDevice(boolean isModify, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
//CtResponse result = new CtResponse();
|
||||
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
Long new_biz_group_id = _AG.toLong(body.get("new_biz_group_id"));
|
||||
Long device_id = _AG.toLong(body.get("device_id"));
|
||||
Long terminal_id = _AG.toLong(body.get("terminal_id"));
|
||||
String name = body.get("name");
|
||||
String uid1 = body.get("uid1");
|
||||
String manager_name = body.get("manager_name");
|
||||
|
||||
//if (name == null || name.isEmpty() || uid1 == null || uid1.isEmpty()) {
|
||||
// result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
// return result;
|
||||
//}
|
||||
|
||||
return deviceService.addOrModifyDevice(isModify, biz_group_id, new_biz_group_id, device_id, terminal_id, name, uid1, manager_name);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add-device.do", method = RequestMethod.POST)
|
||||
public CtResponse addDevice(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyDevice(false, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/modify-device.do", method = RequestMethod.POST)
|
||||
public CtResponse modifyDevice(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyDevice(true, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/remove-device.do", method = RequestMethod.POST)
|
||||
public CtResponse removeDevice(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
//String ids = body.get("ids");
|
||||
//CtResult result = deviceService.removeDevice(ids);
|
||||
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
Long device_id = _AG.toLong(body.get("device_id"));
|
||||
|
||||
return deviceService.removeDevice(biz_group_id, device_id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/config-device.do", method = RequestMethod.POST)
|
||||
public CtResponse configDevice(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long device_id = _AG.toLong(body.get("device_id"));
|
||||
|
||||
Map<String, Object> mapResult = deviceService.configDevice(device_id);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/error-device.do", method = RequestMethod.POST)
|
||||
public CtResponse selectDeviceByError(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
|
||||
Map<String, Object> mapResult = deviceService.selectDeviceByError(biz_group_id);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.service.ErrorHistoryService;
|
||||
import com.handong.smartservice.service.VocService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class ErrorHistoryController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final ErrorHistoryService errorHistoryService;
|
||||
|
||||
|
||||
public ErrorHistoryController(ErrorHistoryService errorHistoryService) {
|
||||
this.errorHistoryService = errorHistoryService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-error-history.do", method = RequestMethod.POST)
|
||||
public CtResponse getErrorHistory(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
String uid1 = body.get("uid1");
|
||||
Long uid1_type = _AG.toLong(body.get("uid1_type"));
|
||||
String slot = body.get("slot");
|
||||
|
||||
Map<String, Object> mapResult = errorHistoryService.getErrorHistoryList(is_excel, offset, limit, date_start, date_end, uid1, uid1_type, slot);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-miss.do", method = RequestMethod.POST)
|
||||
public CtResponse getMiss(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long state = _AG.toLong(body.get("state"));
|
||||
|
||||
Map<String, Object> mapResult = errorHistoryService.getMiss(state);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/miss-slot.do", method = RequestMethod.POST)
|
||||
public CtResponse missSlot(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
String uid1 = body.get("uid1");
|
||||
Long uid1_type = _AG.toLong(body.get("uid1_type"));
|
||||
String slot = body.get("slot");
|
||||
|
||||
Map<String, Object> mapResult = errorHistoryService.missSlot(uid1, uid1_type, slot);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+295
@@ -0,0 +1,295 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtExcelMaker;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.service.GoodsService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class GoodsController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final GoodsService goodsService;
|
||||
|
||||
|
||||
public GoodsController(GoodsService goodsService) {
|
||||
this.goodsService = goodsService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-goods.do", method = RequestMethod.POST)
|
||||
public CtResponse getGoodsList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
Boolean is_group_access = _AG.toBoolean(body.get("is_group_access"));
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
Long device_id = _AG.toLong(body.get("device_id"));
|
||||
Long state = _AG.toLong(body.get("state"));
|
||||
String code = body.get("code");
|
||||
String name = body.get("name");
|
||||
String vendor = body.get("vendor");
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
|
||||
Map<String, Object> mapResult = goodsService.getGoodsList(is_excel, offset, limit, is_group_access, biz_group_id, device_id, state, code, name, vendor, date_start, date_end);
|
||||
|
||||
if (is_excel) {
|
||||
List<Map<String, String>> list = (List<Map<String, String>>)mapResult.get("list");
|
||||
|
||||
for (Map<String, String> item : list) {
|
||||
item.replace("reg_time", _AG.timestampToStr(item.get("reg_time")));
|
||||
}
|
||||
|
||||
String[] arrHeader = {"등록일", "사업자", "상품코드", "상품명", "가격", "공급사"};
|
||||
String[] arrColumn = {"reg_time", "biz_group_name", "code", "name", "price", "vendor"};
|
||||
|
||||
CtExcelMaker.makeExcelResponse(request, response, "상품목록", arrHeader, arrColumn, list, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse addOrModifyGoods(boolean isModify, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
Long goods_id = _AG.toLong(body.get("goods_id"));
|
||||
String code = body.get("code");
|
||||
String name = body.get("name");
|
||||
String vendor = body.get("vendor");
|
||||
Long price = _AG.toLongOrNull(body.get("price"));// nullable
|
||||
Long inventory = _AG.toLongOrNull(body.get("inventory"));// nullable
|
||||
|
||||
if (code == null || code.isEmpty() || name == null || name.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = goodsService.addOrModifyGoods(isModify, biz_group_id, goods_id, code, name, price, inventory, vendor);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add-goods.do", method = RequestMethod.POST)
|
||||
public CtResponse addGoods(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyGoods(false, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/modify-goods.do", method = RequestMethod.POST)
|
||||
public CtResponse modifyGoods(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyGoods(true, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/remove-goods.do", method = RequestMethod.POST)
|
||||
public CtResponse removeGoods(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
String ids = body.get("ids");
|
||||
|
||||
CtResponse result = goodsService.removeGoods(ids);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
@RequestMapping(value = "/get-device-goods.do", method = RequestMethod.POST)
|
||||
public CtResponse getDeviceGoodsList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long device_id = _AG.toLong(body.get("device_id"));
|
||||
String slot = body.get("slot");
|
||||
Long goods_id = _AG.toLong(body.get("goods_id"));
|
||||
|
||||
if (device_id == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
Map<String, Object> mapResult = goodsService.getDeviceGoodsList(device_id, slot, goods_id);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(value = "/manage-device-goods.do", method = RequestMethod.POST)
|
||||
public CtResponse addOrModifyDeviceGoods(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
//logger.info("body: " + body);
|
||||
//logger.info("prev_device_goods: " + body.get("prev_device_goods"));
|
||||
//logger.info("new_device_goods: " + body.get("new_device_goods"));
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long device_id = _AG.toLong((Integer)body.get("device_id"));
|
||||
List<Map<String, String>> prev_device_goods = (List<Map<String, String>>)body.get("prev_device_goods");
|
||||
List<Map<String, String>> new_device_goods = (List<Map<String, String>>)body.get("new_device_goods");
|
||||
|
||||
Long biz_group_id = _AG.toLong((Integer)body.get("biz_group_id"));
|
||||
boolean isSaveTemplate = (boolean)body.get("isSaveTemplate");
|
||||
String templateName = (String)body.get("templateName");
|
||||
List<Map<String, String>> goods_template_elements = (List<Map<String, String>>)body.get("goods_template_elements");
|
||||
Map<String, Object> goods_template_inventory = (Map<String, Object>)body.get("goods_template_inventory");
|
||||
|
||||
if (device_id == null) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
if (prev_device_goods != null && prev_device_goods.size() != 0) {
|
||||
goodsService.deleteDeviceGoods(device_id, prev_device_goods);
|
||||
}
|
||||
|
||||
if (new_device_goods != null && new_device_goods.size() != 0) {
|
||||
result = goodsService.addDeviceGoods(device_id, new_device_goods);
|
||||
}
|
||||
|
||||
if (isSaveTemplate) {
|
||||
result = goodsService.addGoodsTemplate(biz_group_id, templateName, goods_template_inventory, goods_template_elements);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value="/get-goods-templates.do", method = RequestMethod.POST)
|
||||
public CtResponse getGoodsTemplate(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
Boolean is_group_access = _AG.toBoolean(body.get("is_group_access"));
|
||||
|
||||
// goods_template_id 가 있으면 하나만 탐색
|
||||
// biz_group_id 가 있으면 모두 탐색
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
Long goods_template_id = _AG.toLong(body.get("goods_template_id"));
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
|
||||
if (biz_group_id == 0 && goods_template_id == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
logger.info("biz_group_id: " + biz_group_id);
|
||||
logger.info("goods_template_id: " + goods_template_id);
|
||||
|
||||
try {
|
||||
Map<String, Object> mapResult;
|
||||
if (goods_template_id != 0) {
|
||||
mapResult = goodsService.getGoodsTemplateById(goods_template_id);
|
||||
}
|
||||
else {
|
||||
mapResult = goodsService.getGoodsTemplateByBizGroupId(biz_group_id);
|
||||
}
|
||||
result.put("result", mapResult);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(value="/manage-goods-template.do", method = RequestMethod.POST)
|
||||
public CtResponse manageGoodsTemplate(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long biz_group_id = _AG.toLong((Integer)body.get("biz_group_id"));
|
||||
Long goods_template_id = _AG.toLong((Integer)body.get("goods_template_id"));
|
||||
String goods_template_name = (String)body.get("goods_template_name");
|
||||
Map<String, Object> goods_template_inventory = (Map<String, Object>)body.get("goods_template_inventory");
|
||||
List<Map<String, String>> goods_template_elements = (List<Map<String, String>>)body.get("goods_template_elements");
|
||||
|
||||
if (biz_group_id == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
if (goods_template_id != 0) {
|
||||
result = goodsService.removeGoodsTemplate(goods_template_id);
|
||||
}
|
||||
|
||||
result = goodsService.addGoodsTemplate(biz_group_id, goods_template_name, goods_template_inventory, goods_template_elements);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(value="/remove-goods-template.do", method = RequestMethod.POST)
|
||||
public CtResponse removeGoodsTemplate(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long goods_template_id = _AG.toLong((Integer)body.get("goods_template_id"));
|
||||
|
||||
if (goods_template_id == null) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
result = goodsService.removeGoodsTemplate(goods_template_id);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.mapper.LocationMapper;
|
||||
import com.handong.smartservice.service.LocationService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class LocationController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final LocationService locationService;
|
||||
|
||||
|
||||
public LocationController(LocationService locationService) {
|
||||
this.locationService = locationService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-location.do", method = RequestMethod.POST)
|
||||
public CtResponse getLocationList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
String name = body.get("name");
|
||||
String description = body.get("description");
|
||||
String address = body.get("address");
|
||||
|
||||
Map<String, Object> mapResult = locationService.getLocationList(offset, limit, date_start, date_end, name, description, address);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public CtResponse addOrModifyLocation(boolean isModify, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long location_id = _AG.toLong(body.get("location_id"));
|
||||
Long pid = _AG.toLong(body.get("pid"));
|
||||
String name = body.get("name");
|
||||
String description = body.get("description");
|
||||
String address = body.get("address");
|
||||
|
||||
if (name == null || name.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = locationService.addOrModifyLocation(isModify, location_id, pid, name, description, address);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add-location.do", method = RequestMethod.POST)
|
||||
public CtResponse addLocation(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyLocation(false, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/modify-location.do", method = RequestMethod.POST)
|
||||
public CtResponse modifyLocation(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyLocation(true, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/remove-location.do", method = RequestMethod.POST)
|
||||
public CtResponse removeLocation(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
String ids = body.get("ids");
|
||||
|
||||
CtResponse result = locationService.removeLocation(ids);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// ver 2
|
||||
@RequestMapping(value = "/get-location2.do", method = RequestMethod.POST)
|
||||
public CtResponse getLocation2(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
Boolean isRoot = _AG.toBoolean(body.get("isRoot"));
|
||||
Long pid = _AG.toLong(body.get("id"));
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
String name = body.get("name");
|
||||
String description = body.get("description");
|
||||
String address = body.get("address");
|
||||
|
||||
return locationService.getLocation2(isRoot, pid, date_start, date_end, name, description, address);
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.service.NoticeService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class NoticeController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final NoticeService noticeService;
|
||||
|
||||
|
||||
public NoticeController(NoticeService noticeService) {
|
||||
this.noticeService = noticeService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-notice-detail.do", method = RequestMethod.POST)
|
||||
public CtResponse getNoticeDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
String notice_id = body.get("id");
|
||||
|
||||
CtResponse result = noticeService.getNoticeDetail(notice_id);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-notice.do", method = RequestMethod.POST)
|
||||
public CtResponse getNoticeList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
String title = body.get("title");
|
||||
String content = body.get("content");
|
||||
|
||||
Map<String, Object> mapResult = noticeService.getNoticeList(offset, limit, date_start, date_end, title, content);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public CtResponse addOrModifyNotice(boolean isModify, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
String notice_id = body.get("notice_id");
|
||||
String title = body.get("title");
|
||||
String content = body.get("content");
|
||||
|
||||
if (title == null || title.isEmpty() || content == null || content.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = noticeService.addOrModifyNotice(isModify, notice_id, title, content);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add-notice.do", method = RequestMethod.POST)
|
||||
public CtResponse addNotice(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyNotice(false, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/modify-notice.do", method = RequestMethod.POST)
|
||||
public CtResponse modifyNotice(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyNotice(true, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/remove-notice.do", method = RequestMethod.POST)
|
||||
public CtResponse removeNotice(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
String ids = body.get("ids");
|
||||
|
||||
CtResponse result = noticeService.removeNotice(ids);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.service.OperatingHistoryService;
|
||||
import com.handong.smartservice.service.VocService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class OperatingHistoryController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final OperatingHistoryService operatingHistoryService;
|
||||
|
||||
|
||||
public OperatingHistoryController(OperatingHistoryService operatingHistoryService) {
|
||||
this.operatingHistoryService = operatingHistoryService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-operating-history.do", method = RequestMethod.POST)
|
||||
public CtResponse getOperatingHistory(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
Long type = _AG.toLong(body.get("type"));
|
||||
String action = body.get("action");
|
||||
|
||||
Map<String, Object> mapResult = operatingHistoryService.getOperatingHistoryList(is_excel, offset, limit, date_start, date_end, type, action);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.service.ResourceBoardService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class ResourceBoardController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final ResourceBoardService resourceBoardService;
|
||||
|
||||
|
||||
public ResourceBoardController(ResourceBoardService resourceBoardService) {
|
||||
this.resourceBoardService = resourceBoardService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-resource-board-detail.do", method = RequestMethod.POST)
|
||||
public CtResponse getResourceBoardDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
String resource_board_id = body.get("id");
|
||||
|
||||
CtResponse result = resourceBoardService.getResourceBoardDetail(resource_board_id);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-resource-board.do", method = RequestMethod.POST)
|
||||
public CtResponse getResourceBoardList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
String title = body.get("title");
|
||||
String content = body.get("content");
|
||||
|
||||
Map<String, Object> mapResult = resourceBoardService.getResourceBoardList(offset, limit, date_start, date_end, title, content);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public CtResponse addOrModifyResourceBoard(boolean isModify, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
String resource_board_id = body.get("resource_board_id");
|
||||
String title = body.get("title");
|
||||
String content = body.get("content");
|
||||
|
||||
if (title == null || title.isEmpty() || content == null || content.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = resourceBoardService.addOrModifyResourceBoard(isModify, resource_board_id, title, content);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add-resource-board.do", method = RequestMethod.POST)
|
||||
public CtResponse addResourceBoard(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyResourceBoard(false, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/modify-resource-board.do", method = RequestMethod.POST)
|
||||
public CtResponse modifyResourceBoard(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyResourceBoard(true, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/remove-resource-board.do", method = RequestMethod.POST)
|
||||
public CtResponse removeResourceBoard(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
String ids = body.get("ids");
|
||||
|
||||
CtResponse result = resourceBoardService.removeResourceBoard(ids);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtExcelMaker;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.service.SalesService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class SalesController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final SalesService salesService;
|
||||
|
||||
|
||||
public SalesController(SalesService salesService) {
|
||||
this.salesService = salesService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-sales.do", method = RequestMethod.POST)
|
||||
public CtResponse getSalesList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
Boolean is_group_access = _AG.toBoolean(body.get("is_group_access"));
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
String uid1 = body.get("uid1");
|
||||
String device_name = body.get("device_name");
|
||||
Long approval_type = _AG.toLong(body.get("approval_type"));
|
||||
Long date_type = _AG.toLong(body.get("date_type"));
|
||||
|
||||
Map<String, Object> mapResult = salesService.getSalesList(is_excel, offset, limit, is_group_access, biz_group_id, date_start, date_end,
|
||||
uid1, device_name, approval_type, date_type);
|
||||
|
||||
if (is_excel) {
|
||||
List<Map<String, String>> list = (List<Map<String, String>>)mapResult.get("list");
|
||||
|
||||
String[] arrHeader = {"날짜", "무인기기명", "단말기TID", "카드건수", "카드금액", "현금건수", "현금금액", "T머니건수", "T머니금액", "캐시비건수", "캐시비금액", "합계"};
|
||||
String[] arrColumn = {"date", "device_name", "uid1", "card_count", "card_amount", "cash_count", "cash_amount", "tmoney_count", "tmoney_amount", "cbee_count", "cbee_amount", "total"};
|
||||
|
||||
CtExcelMaker.makeExcelResponse(request, response, "매출집계", arrHeader, arrColumn, list, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtExcelMaker;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.service.TerminalService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class TerminalController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final TerminalService terminalService;
|
||||
|
||||
|
||||
public TerminalController(TerminalService terminalService) {
|
||||
this.terminalService = terminalService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-terminal.do", method = RequestMethod.POST)
|
||||
public CtResponse getTerminalList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
Boolean is_group_access = _AG.toBoolean(body.get("is_group_access"));
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
Long state = _AG.toLong(body.get("state"));
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
|
||||
Map<String, Object> mapResult = terminalService.getTerminalList(is_excel, offset, limit, is_group_access, biz_group_id, state, date_start, date_end);
|
||||
|
||||
if (is_excel) {
|
||||
List<Map<String, String>> list = (List<Map<String, String>>)mapResult.get("list");
|
||||
|
||||
for (Map<String, String> item : list) {
|
||||
item.replace("reg_time", _AG.timestampToStr(item.get("reg_time")));
|
||||
}
|
||||
|
||||
String[] arrHeader = {"등록일", "사업자", "기기명", "단말기 TID", "무인기기 장착 여부"};
|
||||
String[] arrColumn = {"reg_time", "biz_group_name", "name", "uid1", "state"};
|
||||
|
||||
CtExcelMaker.makeExcelResponse(request, response, "카드단말기목록", arrHeader, arrColumn, list, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public CtResponse addOrModifyTerminal(boolean isModify, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long addType = _AG.toLong(body.get("addType"));
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
Long terminal_id = _AG.toLong(body.get("terminal_id"));
|
||||
String name = body.get("name");
|
||||
String uid1 = body.get("uid1");
|
||||
Long type = _AG.toLong(body.get("type"));
|
||||
|
||||
if (name == null || name.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
return terminalService.addOrModifyTerminal(isModify, addType, biz_group_id, terminal_id, name, uid1, type);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add-terminal.do", method = RequestMethod.POST)
|
||||
public CtResponse addTerminal(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyTerminal(false, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/modify-terminal.do", method = RequestMethod.POST)
|
||||
public CtResponse modifyTerminal(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyTerminal(true, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/remove-terminal.do", method = RequestMethod.POST)
|
||||
public CtResponse removeTerminal(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
//String ids = body.get("ids");
|
||||
//CtResult result = terminalService.removeTerminal(ids);
|
||||
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
Long terminal_id = _AG.toLong(body.get("terminal_id"));
|
||||
|
||||
return terminalService.removeTerminal(biz_group_id, terminal_id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/terminal-state.do", method = RequestMethod.POST)
|
||||
public CtResponse terminalState(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
String uid1 = body.get("uid1");
|
||||
Long type = _AG.toLong(body.get("type"));
|
||||
Long state = _AG.toLong(body.get("state"));
|
||||
|
||||
return terminalService.terminalState(uid1, type, state);
|
||||
}
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtExcelMaker;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.mapper.TransactionMapper;
|
||||
import com.handong.smartservice.service.TransactionService;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class TransactionController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final TransactionService transactionService;
|
||||
|
||||
|
||||
public TransactionController(TransactionService transactionService) {
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-transaction.do", method = RequestMethod.POST)
|
||||
public CtResponse getTransactionList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
Boolean is_group_access = _AG.toBoolean(body.get("is_group_access"));
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
Long biz_group_id = _AG.toLong(body.get("biz_group_id"));
|
||||
String uid1 = body.get("uid1");
|
||||
Long uid1_type = _AG.toLong(body.get("uid1_type"));
|
||||
String type = body.get("type");
|
||||
Long amount = _AG.toLong(body.get("amount"));
|
||||
String approval = body.get("approval");
|
||||
String pay_name = body.get("pay_name");
|
||||
String pay_vendor = body.get("pay_vendor");
|
||||
String slot = body.get("slot");
|
||||
String code = body.get("code");
|
||||
String goods_name = body.get("goods_name");
|
||||
|
||||
Map<String, Object> mapResult = transactionService.getTransactionList(is_excel, offset, limit, is_group_access, biz_group_id, date_start, date_end,
|
||||
uid1, uid1_type, type, amount, approval, pay_name, pay_vendor, slot, code, goods_name);
|
||||
|
||||
if (is_excel) {
|
||||
List<Map<String, String>> list = (List<Map<String, String>>)mapResult.get("list");
|
||||
|
||||
for (Map<String, String> item : list) {
|
||||
item.replace("order_time", _AG.timestampToStr(item.get("order_time")));
|
||||
}
|
||||
|
||||
String[] arrHeader = {"거래시간", "단말기 TID", "금액", "결제유형", "승인번호", "컬럼번호", "상품코드", "상품명", "결제서비스업체"};
|
||||
String[] arrColumn = {"order_time", "uid1", "amount", "type", "approval", "slot", "code", "goods_name", "pay_vendor"};
|
||||
|
||||
CtExcelMaker.makeExcelResponse(request, response, "거래내역목록", arrHeader, arrColumn, list, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-u-transaction.do", method = RequestMethod.POST)
|
||||
public CtResponse getUndefinedTransactionList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Boolean is_excel = _AG.toBoolean(body.get("is_excel"));
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
String uid1 = body.get("uid1");
|
||||
Long uid1_type = _AG.toLong(body.get("uid1_type"));
|
||||
String type = body.get("type");
|
||||
Long amount = _AG.toLong(body.get("amount"));
|
||||
String approval = body.get("approval");
|
||||
String pay_name = body.get("pay_name");
|
||||
String pay_vendor = body.get("pay_vendor");
|
||||
String slot = body.get("slot");
|
||||
String code = body.get("code");
|
||||
String goods_name = body.get("goods_name");
|
||||
|
||||
Map<String, Object> mapResult = transactionService.getUndefinedTransactionList(is_excel, offset, limit, date_start, date_end,
|
||||
uid1, uid1_type, type, amount, approval, pay_name, pay_vendor, slot, code, goods_name);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add-transaction.do", method = RequestMethod.POST)
|
||||
public CtResponse addTransaction(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
/*
|
||||
curl -X POST http://localhost:18080/api/add-transaction.do \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"uid1": "123",
|
||||
"uid1_type": "1",
|
||||
"type": "D1",
|
||||
"amount": "900",
|
||||
"approval": "33",
|
||||
"pay_name": " HANA",
|
||||
"pay_vendor": "HANA",
|
||||
"slot": "01"
|
||||
}'
|
||||
*/
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
String uid1 = body.get("uid1");
|
||||
Long uid1_type = _AG.toLong(body.get("uid1_type"));
|
||||
String type = body.get("type");
|
||||
Long amount = _AG.toLong(body.get("amount"));
|
||||
String approval = body.get("approval");
|
||||
String pay_name = body.get("pay_name");
|
||||
String pay_vendor = body.get("pay_vendor");
|
||||
String slot = body.get("slot");
|
||||
//String code = body.get("code");
|
||||
//String goods_name = body.get("goods_name");
|
||||
String pay_unique_num = body.get("pay_unique_num");
|
||||
String pay_order_time = body.get("pay_order_time");
|
||||
|
||||
if (uid1 == null || uid1_type == null || type == null || amount == null || slot == null) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = transactionService.addTransaction(uid1, uid1_type, type, amount, approval, pay_name, pay_vendor, slot, pay_unique_num, pay_order_time);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
package com.handong.smartservice.controller.api;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.service.VocService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class VocController {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final VocService vocService;
|
||||
|
||||
|
||||
public VocController(VocService vocService) {
|
||||
this.vocService = vocService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-voc-detail.do", method = RequestMethod.POST)
|
||||
public CtResponse getVocDetail(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
String voc_id = body.get("id");
|
||||
|
||||
CtResponse result = vocService.getVocDetail(voc_id);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get-voc.do", method = RequestMethod.POST)
|
||||
public CtResponse getVocList(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Long offset= _AG.toLong(body.get("offset"));
|
||||
Long limit = _AG.toLong(body.get("limit"));
|
||||
if (limit > 100)
|
||||
limit = 100L;
|
||||
|
||||
String date_start = body.get("date_start");
|
||||
String date_end = body.get("date_end");
|
||||
String title = body.get("title");
|
||||
String content = body.get("content");
|
||||
String process = body.get("process");
|
||||
|
||||
Map<String, Object> mapResult = vocService.getVocList(offset, limit, date_start, date_end, title, content, process);
|
||||
result.put("result", mapResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public CtResponse addOrModifyVoc(boolean isModify, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
String voc_id = body.get("voc_id");
|
||||
String title = body.get("title");
|
||||
String content = body.get("content");
|
||||
|
||||
if (title == null || title.isEmpty() || content == null || content.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = vocService.addOrModifyVoc(isModify, voc_id, title, content);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add-voc.do", method = RequestMethod.POST)
|
||||
public CtResponse addVoc(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyVoc(false, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/modify-voc.do", method = RequestMethod.POST)
|
||||
public CtResponse modifyVoc(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
return addOrModifyVoc(true, request, response, body);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/remove-voc.do", method = RequestMethod.POST)
|
||||
public CtResponse removeVoc(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, String> body) {
|
||||
logger.info("req: " + request.getRequestURI());
|
||||
|
||||
String ids = body.get("ids");
|
||||
|
||||
CtResponse result = vocService.removeVoc(ids);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface AccountMapper {
|
||||
|
||||
List<Map<String, Object>> selectAccount(Boolean isCount, Boolean is_excel, Long offset, Long limit,
|
||||
String date_start, String date_end, Long gid, String user_id, String email, String nick_name, Long biz_group_id);
|
||||
|
||||
List<Map<String, Object>> selectAccount2(Boolean isCount, Long offset, Long limit,
|
||||
String date_start, String date_end, Boolean is_excel, Long gid, String user_id, String email, String nick_name, Long biz_group_id);
|
||||
|
||||
int insertAccount(Map<String, Object> params);
|
||||
|
||||
int updateAccount(Long gid, String user_pw, String nick_name, String email, Long state, Long biz_group_id);
|
||||
|
||||
int changeState(List<Long> ids, int state);
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface BizGroupMapper {
|
||||
List<Map<String, Object>> selectBizGroup(Long biz_group_id, Boolean isCount, Long offset, Long limit,
|
||||
String date_start, String date_end,
|
||||
String name, String biz_reg_num, String email,
|
||||
String phone, String address);
|
||||
|
||||
Map<String, Object> selectExistBizGroup(Long biz_group_id, String biz_reg_num);
|
||||
|
||||
Map<String, Object> selectBizGroupByDeviceId(Long device_id);
|
||||
Map<String, Object> selectBizGroupByTerminalId(Long terminal_id);
|
||||
|
||||
//int insertBizGroup(Long pid, String name, String biz_reg_num, Long gid, String email,
|
||||
// String phone, String ceo, String address);
|
||||
int insertBizGroup(Map<String, Object> params);
|
||||
|
||||
int updateBizGroup(Long biz_group_id, Long pid, String name, String biz_reg_num, String email,
|
||||
String phone, String ceo, String address);
|
||||
|
||||
//int deleteBizGroup(List<Long> ids);
|
||||
int changeStateBizGroup(List<Long> ids, int state);
|
||||
|
||||
int changePidBizGroup(List<Long> pids, Long new_pid);
|
||||
|
||||
List<Map<String, Object>> selectBizGroupParentTree(List<Long> ids);
|
||||
|
||||
// ver2
|
||||
List<Map<String, Object>> selectRootNode(boolean isDbRoot, Long top_group_id, String date_start, String date_end,
|
||||
String name, String biz_reg_num);
|
||||
|
||||
List<Map<String, Object>> selectBizGroupChildTree(boolean queryAll, Long pid, Long top_group_id, String date_start, String date_end,
|
||||
String name, String biz_reg_num);
|
||||
|
||||
List<Map<String, Object>> selectBizGroupTree(boolean queryAll, Long biz_group_id, String date_start, String date_end,
|
||||
String name, String biz_reg_num);
|
||||
|
||||
// get ids
|
||||
List<Long> selectBizGroupDownwardIds(Long biz_group_id);
|
||||
List<Long> selectBizGroupDownwardIdsByTerminalId(Long terminal_id);
|
||||
List<Long> selectBizGroupDownwardIdsByDeviceId(Long device_id);
|
||||
|
||||
List<Long> selectBizGroupUpwardIds(Long biz_group_id);
|
||||
List<Long> selectBizGroupUpwardIdsByTerminalId(Long terminal_id);
|
||||
List<Long> selectBizGroupUpwardIdsByDeviceId(Long device_id);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceMapper {
|
||||
List<Map<String, Object>> selectDevice(Boolean isCount, boolean is_excel, Long offset, Long limit, Boolean is_group_access,
|
||||
Long biz_group_id, String name, String date_start, String date_end);
|
||||
|
||||
List<Map<String, Object>> selectDevice2(Boolean isCount, boolean is_excel, Long offset, Long limit,
|
||||
Long biz_group_id, String name, String date_start, String date_end);
|
||||
|
||||
Map<String, Object> selectDeviceById(Long device_id);
|
||||
|
||||
Map<String, Object> selectExistDevice(Long device_id, String name);
|
||||
|
||||
int insertDevice(Map<String, Object> params);
|
||||
|
||||
int updateDevice(Long device_id, Long terminal_id, String name, String uid1, String manager_name, Long gid);
|
||||
|
||||
int updateDeviceTerminalTime(Long device_id, LocalDateTime connect_time, LocalDateTime disconnect_time);
|
||||
|
||||
int changeStateDevice(List<Long> ids, int state);
|
||||
|
||||
//int deleteDevice(List<Long> ids);
|
||||
int deleteDevice(Long device_id);
|
||||
|
||||
//
|
||||
int insertDeviceBizGroup(Long biz_group_id, Long device_id);
|
||||
|
||||
int deleteDeviceBizGroup(Long biz_group_id, Long device_id);
|
||||
|
||||
List<Map<String, Object>> selectDeviceByError(Long biz_group_id);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface ErrorHistoryMapper {
|
||||
List<Map<String, Object>> selectErrorHistory(Boolean isCount, Boolean is_excel, Long offset, Long limit,
|
||||
String date_start, String date_end, String uid1, Long uid1_type, String slot);
|
||||
|
||||
List<Map<String, Object>> selectErrorHistoryByState(Long state);
|
||||
|
||||
int insertErrorHistory(String uid1, Long uid1_type, String slot);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface GoodsMapper {
|
||||
List<Map<String, Object>> selectGoods(Boolean isCount, Boolean is_excel, Long offset, Long limit, Boolean is_group_access, Long biz_group_id, Long device_id,
|
||||
Long state, String code, String name, String vendor, String date_start, String date_end);
|
||||
|
||||
List<Map<String, Object>> selectGoodsByBizGroupId(Long biz_group_id);
|
||||
List<Map<String, Object>> selectGoodsByDevice(Boolean is_group_access, Long device_id);
|
||||
|
||||
Map<String, Object> selectExistGoods(Long biz_group_id, String code, String name);
|
||||
|
||||
Map<String, Object> selectGoodsByUid1(String uid1, Long uid1_type, String slot);
|
||||
|
||||
int insertGoods(Map<String, Object> params);
|
||||
|
||||
int updateGoods(Long biz_group_id, Long goods_id, String code, String name, Long price, Long inventory, String vendor, Long gid);
|
||||
|
||||
int deleteGoods(List<Long> ids);
|
||||
|
||||
//
|
||||
List<Map<String, Object>> selectDeviceGoods(Long device_id, String slot, Long goods_id);
|
||||
int insertDeviceGoods(Long device_id, List<Map<String, String>> device_goods);
|
||||
int updateDeviceGoodsPlusInventory(String approval);
|
||||
int updateDeviceGoodsMinusInventory(Long device_id, String slot);
|
||||
int deleteDeviceGoods(Long device_id, List<Map<String, String>> device_goods);
|
||||
|
||||
List<Map<String, Object>> selectGoodsTemplateByBizGroupId(Long biz_group_id);
|
||||
List<Map<String, Object>> selectGoodsTemplateById(Long goods_template_id);
|
||||
|
||||
Long selectGoodsTemplateCount(Long biz_group_id);
|
||||
int insertGoodsTemplate(Map<String, Object> params);
|
||||
int insertGoodsTemplateElements(Long goods_template_id, List<Map<String, String>> goods_template_elements);
|
||||
|
||||
int updateGoodsTemplate(Long goods_template_id, String name);
|
||||
int deleteGoodsTemplateElements(Long goods_template_id);
|
||||
int deleteGoodsTemplate(Long goods_template_id);
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface LocationMapper {
|
||||
List<Map<String, Object>> selectLocation(Boolean isCount, Long offset, Long limit,
|
||||
String date_start, String date_end, String name, String description, String address);
|
||||
|
||||
int insertLocation(Map<String, Object> params);
|
||||
|
||||
int updateLocation(Long location_id, Long pid, String name,
|
||||
String description, String address);
|
||||
|
||||
int changeStateLocation(List<Long> ids, int state);
|
||||
|
||||
int changePidLocation(List<Long> pids, Long new_pid);
|
||||
|
||||
List<Map<String, Object>> selectLocationParentTree(List<Long> ids);
|
||||
|
||||
// ver2
|
||||
List<Map<String, Object>> selectRootNode(boolean isDbRoot, String date_start, String date_end,
|
||||
String name, String description, String address);
|
||||
|
||||
List<Map<String, Object>> selectLocationChildTree(boolean queryAll, Long pid, String date_start, String date_end,
|
||||
String name, String description, String address);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface NoticeMapper {
|
||||
Map<String, Object> selectDetailNotice(String notice_id);
|
||||
|
||||
List<Map<String, Object>> selectNotice(Boolean isCount, Long offset, Long limit,
|
||||
String date_start, String date_end, String title, String content);
|
||||
|
||||
int insertNotice(String title, String content, Long gid);
|
||||
|
||||
int updateNotice(Long biz_group_id, String title, String content);
|
||||
|
||||
//int deleteNotice(List<Long> ids);
|
||||
int changeStateNotice(List<Long> ids, int state);
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface OperatingHistoryMapper {
|
||||
List<Map<String, Object>> selectOperatingHistory(Boolean isCount, Boolean is_excel, Long offset, Long limit,
|
||||
String date_start, String date_end, Long type, String action);
|
||||
|
||||
int insertOperatingHistory(Long type, String action, Long gid);
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface ResourceBoardMapper {
|
||||
Map<String, Object> selectDetailResourceBoard(String resource_board_id);
|
||||
|
||||
List<Map<String, Object>> selectResourceBoard(Boolean isCount, Long offset, Long limit,
|
||||
String date_start, String date_end,
|
||||
String title, String content);
|
||||
|
||||
int insertResourceBoard(String title, String content, Long gid);
|
||||
|
||||
int updateResourceBoard(Long resource_board_id, String title, String content);
|
||||
|
||||
//int deleteResourceBoard(List<Long> ids);
|
||||
int changeStateResourceBoard(List<Long> ids, int state);
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface TerminalMapper {
|
||||
List<Map<String, Object>> selectTerminal(Boolean isCount, Boolean is_excel, Long offset, Long limit, Boolean is_group_access,
|
||||
Long biz_group_id, String name, Long state, String date_start, String date_end);
|
||||
|
||||
Map<String, Object> selectTerminalById(Long terminal_id);
|
||||
|
||||
Map<String, Object> selectTerminalByDeviceId(Long device_id);
|
||||
|
||||
Map<String, Object> selectTerminal3(String uid1, Long type);
|
||||
|
||||
Map<String, Object> selectExistTerminal(String name, String uid1, Long type);
|
||||
|
||||
int insertTerminal(Map<String, Object> params);
|
||||
|
||||
int updateTerminal(Long terminal_id, String name, String uid1, Long type, String manager_name, Long gid);
|
||||
|
||||
int updateTerminalChangeDevice(Long terminal_id, Long device_id, Long state, String name);
|
||||
int updateTerminalRemoveDevice(Long device_id);
|
||||
|
||||
int changeStateTerminal(Long terminal_id, int state);
|
||||
int changeStateTerminals(List<Long> ids, int state);
|
||||
|
||||
int changeStateDeviceTerminal(Long device_id, int state);
|
||||
|
||||
//int deleteTerminal(List<Long> ids);
|
||||
int deleteTerminal(Long terminal_id);
|
||||
|
||||
//
|
||||
int insertTerminalBizGroup(Long biz_group_id, Long terminal_id);
|
||||
|
||||
int deleteTerminalBizGroup(Long biz_group_id, Long terminal_id);
|
||||
|
||||
//
|
||||
int terminalState(String uid1, Long type, Long state);
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface TransactionMapper {
|
||||
|
||||
List<Map<String, Object>> selectTransaction(Boolean isCount, Boolean is_excel, Long offset, Long limit, Boolean is_group_access,
|
||||
Long biz_group_id, String date_start, String date_end, String uid1, Long uid1_type, String type, Long amount,
|
||||
String approval, String pay_name, String pay_vendor, String slot, String code, String goods_name);
|
||||
|
||||
List<Map<String, Object>> selectTransactionBizGroup0(Boolean isCount, Boolean is_excel, Long offset, Long limit,
|
||||
String date_start, String date_end, String uid1, Long uid1_type, String type, Long amount, String approval,
|
||||
String pay_name, String pay_vendor, String slot, String code, String goods_name);
|
||||
|
||||
List<Map<String, Object>> selectTransaction2(Boolean isCount, Boolean is_excel, Long offset, Long limit, Boolean is_group_access,
|
||||
Long biz_group_id, String date_start, String date_end, String uid1);
|
||||
|
||||
List<Map<String, Object>> selectTransaction3(Boolean isCount, Boolean is_excel, Long offset, Long limit, Boolean is_group_access,
|
||||
Long biz_group_id, String date_start, String date_end, String uid1, String device_name, Long approval_type, Long date_type);
|
||||
|
||||
int insertTransaction(Map<String, Object> params);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.handong.smartservice.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface VocMapper {
|
||||
Map<String, Object> selectDetailVoc(String voc_id);
|
||||
|
||||
List<Map<String, Object>> selectVoc(Boolean isCount, Long offset, Long limit,
|
||||
String date_start, String date_end, String title, String content, String process);
|
||||
|
||||
int insertVoc(String title, String content, Long gid);
|
||||
|
||||
int updateVoc(Long biz_group_id, String title, String content);
|
||||
|
||||
//int deleteVoc(List<Long> ids);
|
||||
int changeStateVoc(List<Long> ids, int state);
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.DbLogger;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.component.UserInfo;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.handong.smartservice.mapper.AccountMapper;
|
||||
|
||||
|
||||
@Service
|
||||
public class AccountService {
|
||||
private final AccountMapper accountMapper;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
public AccountService(AccountMapper accountMapper, PasswordEncoder passwordEncoder) {
|
||||
this.accountMapper = accountMapper;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public CtResponse getAccount(Long gid, String user_id) {
|
||||
CtResponse result = new CtResponse();
|
||||
if (gid != 0L && user_id != null && user_id.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)accountMapper.selectAccount(false, false, 0L, 1L,
|
||||
null, null, gid, user_id, null, null, 0L);
|
||||
|
||||
if (listMap.size() == 0)
|
||||
result.put("result", null);
|
||||
else
|
||||
result.put("result", listMap.get(0));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> getAccountList(Long offset, Long limit, String date_start, String date_end, Boolean is_excel, Boolean is_group_access, String user_id, String email, String nick_name, Long biz_group_id) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
//if (is_group_access) {
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)accountMapper.selectAccount2(false, offset, limit,
|
||||
date_start, date_end, is_excel, 0L, user_id, email, nick_name, biz_group_id);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", accountMapper.selectAccount2(true, offset, limit,
|
||||
date_start, date_end, is_excel, 0L, user_id, email, nick_name, biz_group_id));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse addOrModifyAccount(boolean isModify, Long gid, String user_id, String user_pw, String email, String nick_name, Long state, Long biz_group_id, Long new_biz_group_id) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
UserInfo userInfo = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
|
||||
String enc_pw = passwordEncoder.encode(user_pw);
|
||||
|
||||
if (new_biz_group_id != 0 && new_biz_group_id != biz_group_id)
|
||||
biz_group_id = new_biz_group_id;
|
||||
|
||||
if (isModify) {
|
||||
if (gid == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
//accountMapper.updateAccount(gid, user_pw, nick_name, email, state, biz_group_id);
|
||||
accountMapper.updateAccount(gid, enc_pw, nick_name, email, state, biz_group_id);
|
||||
DbLogger.insert(2L, "계정정보 수정", userInfo.getGid());
|
||||
}
|
||||
else {
|
||||
if (user_id == null || user_id.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("user_id", user_id);
|
||||
//params.put("user_pw", user_pw);
|
||||
params.put("user_pw", enc_pw);
|
||||
params.put("nick_name", nick_name);
|
||||
params.put("email", email);
|
||||
params.put("state", state);
|
||||
params.put("biz_group_id", biz_group_id);
|
||||
|
||||
if (biz_group_id == 667) //TempCode
|
||||
params.put("permission", 1L);
|
||||
else
|
||||
params.put("permission", 2L);
|
||||
|
||||
if (accountMapper.insertAccount(params) == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
else {
|
||||
DbLogger.insert(2L, "신규 계정 추가, id: " + user_id, userInfo.getGid());
|
||||
//result.put("result", Map.of("gid", params.get("gid")));
|
||||
Map<String, Object> ret = new HashMap<String, Object>();
|
||||
ret.put("gid", params.get("gid"));
|
||||
result.put("result", ret);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse removeAccount(String ids) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
List<Long> arrId = Arrays.stream(ids.split(","))
|
||||
.map(Long::parseLong)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int changed = accountMapper.changeState(arrId, 2);
|
||||
if (changed == 0) {
|
||||
result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
}
|
||||
DbLogger.insert(2L, "계정 삭제, id: " + ids, 2L);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.DbLogger;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.component.RcTreeBizGroup;
|
||||
import com.handong.smartservice.mapper.BizGroupMapper;
|
||||
import com.handong.smartservice.mapper.OperatingHistoryMapper;
|
||||
|
||||
|
||||
@Service
|
||||
public class BizGroupService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired BizGroupMapper bizGroupMapper;
|
||||
|
||||
|
||||
public Map<String, Object> getBizGroupList(Long offset, Long limit, String date_start, String date_end,
|
||||
String name, String biz_reg_num, String email, String phone, String address) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)bizGroupMapper.selectBizGroup(0L, false, offset, limit,
|
||||
date_start, date_end, name, biz_reg_num, email, phone, address);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", bizGroupMapper.selectBizGroup(0L, true, offset, limit,
|
||||
date_start, date_end, name, biz_reg_num, email, phone, address));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
|
||||
if (listMap.size() == 0)
|
||||
return mapResult;
|
||||
|
||||
// get BizGroup Tree part
|
||||
//
|
||||
List<Long> listBizGroupId = listMap.stream()
|
||||
.map(item -> (Long)item.get("biz_group_id"))
|
||||
.filter(Objects::nonNull)
|
||||
.map(Long::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
List<Map<String, Object>> listTreeDb = bizGroupMapper.selectBizGroupParentTree(listBizGroupId);
|
||||
|
||||
// Covert for react rc-tree
|
||||
List<Map<String, Object>> listRcTree = RcTreeBizGroup.convertDb2RcTree(listTreeDb);
|
||||
|
||||
mapResult.put("tree", listRcTree);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse addOrModifyBizGroup(boolean isModify, Long biz_group_id, Long pid, Long top_group_id, String name, String biz_reg_num, String email, String phone, String ceo, String address) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
//if (bizGroupMapper.selectExistBizGroup(biz_group_id, biz_reg_num) != null) {
|
||||
// result.setErrCode(ErrorCode.ALREADY_EXIST);
|
||||
// return result;
|
||||
//}
|
||||
|
||||
if (isModify) {
|
||||
if (biz_group_id == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
bizGroupMapper.updateBizGroup(biz_group_id, pid, name, biz_reg_num, email, phone, ceo, address);
|
||||
DbLogger.insert(2L, "사업자그룹정보 수정", 2L);
|
||||
}
|
||||
else {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("pid", pid);
|
||||
params.put("name", name);
|
||||
params.put("biz_reg_num", biz_reg_num);
|
||||
params.put("gid", 2L); //TempCode
|
||||
params.put("email", email);
|
||||
params.put("phone", phone);
|
||||
params.put("ceo", ceo);
|
||||
params.put("address", address);
|
||||
|
||||
if (bizGroupMapper.insertBizGroup(params) == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
else {
|
||||
DbLogger.insert(2L, "사업자그룹 추가, 사업자명: " + name + ", 사업자번호: " + biz_reg_num, 2L);
|
||||
result.put("result", Map.of("biz_group_id", params.get("biz_group_id")));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public CtResponse removeBizGroup(String ids) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
List<Long> arrId = Arrays.stream(ids.split(","))
|
||||
.map(Long::parseLong)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int changed = bizGroupMapper.changeStateBizGroup(arrId, 2);
|
||||
//result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
if (changed > 0) {
|
||||
bizGroupMapper.changePidBizGroup(arrId, null);
|
||||
}
|
||||
DbLogger.insert(2L, "사업자그룹 삭제, 사업자명: " + ids, 2L);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ver2
|
||||
public CtResponse getBizGroup2(boolean isDbRoot, Long pid, Long top_group_id, String date_start, String date_end, String name, String biz_reg_num) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
if (isDbRoot == true) {
|
||||
List<Map<String, Object>> listTreeDb = (List<Map<String, Object>>)bizGroupMapper.selectRootNode(isDbRoot, top_group_id, date_start, date_end, name, biz_reg_num);
|
||||
|
||||
// Covert for react rc-tree
|
||||
List<Map<String, Object>> listRcTree = RcTreeBizGroup.convertDb2RcTree(listTreeDb);
|
||||
result.put("result", Map.of("tree", listRcTree));
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> listTreeDb = (List<Map<String, Object>>)bizGroupMapper.selectBizGroupChildTree(true, pid, top_group_id, date_start, date_end, name, biz_reg_num);
|
||||
|
||||
// Covert for react rc-tree
|
||||
List<Map<String, Object>> listRcTree = RcTreeBizGroup.convertDb2RcTree(listTreeDb);
|
||||
result.put("result", Map.of("tree", listRcTree));
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse getBizGroup3(Long biz_group_id) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
// get BizGroup Tree part
|
||||
List<Map<String, Object>> listTreeDb = bizGroupMapper.selectBizGroupTree(true, biz_group_id, null, null, null, null);
|
||||
|
||||
// Covert for react rc-tree
|
||||
List<Map<String, Object>> listRcTree = RcTreeBizGroup.convertDb2RcTree(listTreeDb);
|
||||
|
||||
result.put("result", Map.of("tree", listRcTree));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import com.handong.smartservice.mapper.AccountMapper;
|
||||
import org.springframework.security.core.userdetails.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CustomUserDetailsService implements UserDetailsService {
|
||||
|
||||
private final AccountMapper accountMapper;
|
||||
|
||||
public CustomUserDetailsService(AccountMapper accountMapper) {
|
||||
this.accountMapper = accountMapper;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String userId) throws UsernameNotFoundException {
|
||||
/*
|
||||
var account = accountMapper.selectById(userId);
|
||||
if (account == null) {
|
||||
throw new UsernameNotFoundException("error");
|
||||
}
|
||||
|
||||
|
||||
return new User(
|
||||
(String) account.get("user_id"),
|
||||
(String) account.get("user_pw"),
|
||||
List.of() // 권한이 없으면 빈 리스트
|
||||
);
|
||||
*/
|
||||
return new User(
|
||||
"user_id",
|
||||
"user_pw",
|
||||
List.of() // 권한이 없으면 빈 리스트
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
+224
@@ -0,0 +1,224 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.DbLogger;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.component.UserInfo;
|
||||
import com.handong.smartservice.mapper.BizGroupMapper;
|
||||
import com.handong.smartservice.mapper.DeviceMapper;
|
||||
import com.handong.smartservice.mapper.TerminalMapper;
|
||||
|
||||
|
||||
@Service
|
||||
public class DeviceService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired DeviceMapper deviceMapper;
|
||||
@Autowired TerminalMapper terminalMapper;
|
||||
@Autowired BizGroupMapper bizGroupMapper;
|
||||
|
||||
|
||||
public DeviceService(DeviceMapper deviceMapper) {
|
||||
this.deviceMapper = deviceMapper;
|
||||
}
|
||||
|
||||
public Map<String, Object> getDeviceList(Boolean is_excel, Long offset, Long limit, Boolean is_group_access, Long biz_group_id, String name, String date_start, String date_end) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
//OldVer
|
||||
//if (is_group_access == false) {
|
||||
// List<Map<String, Object>> listForTopId = bizGroupMapper.selectBizGroup(biz_group_id, false, 0L, 1L, null, null, null, null, null, null, null);
|
||||
// if (listForTopId.size() >= 0) {
|
||||
// biz_group_id = (Long)listForTopId.get(0).get("top_group_id");
|
||||
// if (biz_group_id == null)
|
||||
// biz_group_id = (Long)listForTopId.get(0).get("biz_group_id");
|
||||
// }
|
||||
//}
|
||||
if (is_group_access) {
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)deviceMapper.selectDevice(false, is_excel, offset, limit, is_group_access,
|
||||
biz_group_id, name, date_start, date_end);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
if (is_excel == false) {
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", deviceMapper.selectDevice(true, is_excel, offset, limit, is_group_access,
|
||||
biz_group_id, name, date_start, date_end));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)deviceMapper.selectDevice2(false, is_excel, offset, limit,
|
||||
biz_group_id, name, date_start, date_end);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
if (is_excel == false) {
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", deviceMapper.selectDevice2(true, is_excel, offset, limit,
|
||||
biz_group_id, name, date_start, date_end));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
}
|
||||
}
|
||||
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse addOrModifyDevice(boolean isModify, Long biz_group_id, Long new_biz_group_id, Long device_id, Long terminal_id, String name, String uid1, String manager_name) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
UserInfo userInfo = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
|
||||
if (isModify) {
|
||||
if (device_id == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
//OldVer
|
||||
//if (terminal_id != 0) {
|
||||
// terminalMapper.updateTerminalRemoveDevice(device_id);
|
||||
// terminalMapper.updateTerminalChangeDevice(terminal_id, device_id);
|
||||
//}
|
||||
Map<String, Object> mapTerminal = null;
|
||||
if (terminal_id != 0) {
|
||||
mapTerminal = terminalMapper.selectTerminalByDeviceId(device_id);
|
||||
if (mapTerminal != null) {
|
||||
Long curr_terminal_id = (Long)mapTerminal.get("terminal_id"); // current terminal
|
||||
|
||||
Map<String, Object> mapNewTerminal = terminalMapper.selectTerminalById(terminal_id);
|
||||
if (mapNewTerminal != null) {
|
||||
Long new_device_id = (Long)mapNewTerminal.get("device_id"); // new device
|
||||
|
||||
Map<String, Object> mapNewDevice = deviceMapper.selectDeviceById(new_device_id);
|
||||
if (mapNewDevice != null) {
|
||||
String new_device_name = (String)mapNewDevice.get("name");
|
||||
terminalMapper.updateTerminalChangeDevice(curr_terminal_id, new_device_id, 5L, new_device_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
terminalMapper.updateTerminalChangeDevice(terminal_id, device_id, 1L, name);
|
||||
}
|
||||
|
||||
if (new_biz_group_id != 0 && new_biz_group_id != biz_group_id) {
|
||||
deviceMapper.deleteDeviceBizGroup(biz_group_id, device_id); // delete n:n relation
|
||||
deviceMapper.insertDeviceBizGroup(new_biz_group_id, device_id);
|
||||
|
||||
if (mapTerminal != null)
|
||||
mapTerminal = terminalMapper.selectTerminalByDeviceId(device_id);
|
||||
|
||||
if (mapTerminal != null) {
|
||||
terminal_id = (Long)mapTerminal.get("terminal_id"); // old terminal
|
||||
if (terminal_id != null) {
|
||||
terminalMapper.deleteTerminalBizGroup(biz_group_id, terminal_id);
|
||||
terminalMapper.insertTerminalBizGroup(new_biz_group_id, terminal_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deviceMapper.updateDevice(device_id, terminal_id, name, uid1, manager_name, userInfo.getGid());
|
||||
DbLogger.insert(2L, "무인기기 정보 수정, device_id: " + device_id, userInfo.getGid());
|
||||
}
|
||||
else {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("name", name);
|
||||
params.put("uid1", uid1);
|
||||
params.put("manager_name", manager_name);
|
||||
params.put("gid", 2L); //TempCode
|
||||
|
||||
if (terminal_id != 0) {
|
||||
params.put("terminal_id", terminal_id);
|
||||
}
|
||||
|
||||
if (deviceMapper.insertDevice(params) == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
DbLogger.insert(2L, "무인기기 추가, 기기명: " + name + "TID: " + uid1, userInfo.getGid());
|
||||
|
||||
Long new_device_id = _AG.toLong((BigInteger)params.get("device_id"));
|
||||
|
||||
if (deviceMapper.insertDeviceBizGroup(biz_group_id, new_device_id) == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
else {
|
||||
result.put("result", Map.of("biz_group_id", params.get("biz_group_id")));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
//public CtResponse removeDevice(String ids) {
|
||||
public CtResponse removeDevice(Long biz_group_id, Long device_id) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
UserInfo userInfo = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
|
||||
//terminalMapper.updateTerminalRemoveDevice(device_id);
|
||||
Map<String, Object> mapTerminal = terminalMapper.selectTerminalByDeviceId(device_id);
|
||||
if (mapTerminal != null) {
|
||||
Long terminal_id = (Long)mapTerminal.get("terminal_id");
|
||||
if (terminal_id != null) {
|
||||
int changed = terminalMapper.deleteTerminal(terminal_id);
|
||||
changed = terminalMapper.deleteTerminalBizGroup(biz_group_id, terminal_id); // delete n:n relation
|
||||
}
|
||||
}
|
||||
|
||||
//List<Long> arrId = Arrays.stream(ids.split(","))
|
||||
// .map(Long::parseLong)
|
||||
// .collect(Collectors.toList());
|
||||
//int changed = terminalMapper.changeStateTerminals(arrId, 2);
|
||||
int changed = deviceMapper.deleteDevice(device_id);
|
||||
if (changed == 0) {
|
||||
result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
}
|
||||
DbLogger.insert(2L, "무인기기 삭제, device_id: " + device_id, userInfo.getGid());
|
||||
|
||||
changed = deviceMapper.deleteDeviceBizGroup(biz_group_id, device_id); // delete n:n relation
|
||||
if (changed == 0) {
|
||||
result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse configDevice(Long device_id) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
int changed = deviceMapper.updateDeviceTerminalTime(device_id, null, null);
|
||||
if (changed == 0) {
|
||||
result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> selectDeviceByError(Long biz_group_id) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)deviceMapper.selectDeviceByError(biz_group_id);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
return mapResult;
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.DbLogger;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.mapper.ErrorHistoryMapper;
|
||||
import com.handong.smartservice.mapper.VocMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
public class ErrorHistoryService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final ErrorHistoryMapper errorHistoryMapper;
|
||||
|
||||
|
||||
public ErrorHistoryService(ErrorHistoryMapper errorHistoryMapper) {
|
||||
this.errorHistoryMapper = errorHistoryMapper;
|
||||
}
|
||||
|
||||
public Map<String, Object> getErrorHistoryList(Boolean is_excel, Long offset, Long limit, String date_start, String date_end,
|
||||
String uid1, Long uid1_type, String slot) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)errorHistoryMapper.selectErrorHistory(false, is_excel, offset, limit,
|
||||
date_start, date_end, uid1, uid1_type, slot);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", errorHistoryMapper.selectErrorHistory(true, is_excel, offset, limit,
|
||||
date_start, date_end, uid1, uid1_type, slot));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public Map<String, Object> getMiss(Long state) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> listMap = errorHistoryMapper.selectErrorHistoryByState(1L);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse missSlot(String uid1, Long uid1_type, String slot) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
errorHistoryMapper.insertErrorHistory(uid1, uid1_type, slot);
|
||||
DbLogger.insert(1L, "물품 미투출 TID: " + uid1 + ", 컬럼번호: " + slot, 2L);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+282
@@ -0,0 +1,282 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.DbLogger;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.component.UserInfo;
|
||||
import com.handong.smartservice.mapper.BizGroupMapper;
|
||||
import com.handong.smartservice.mapper.DeviceMapper;
|
||||
import com.handong.smartservice.mapper.GoodsMapper;
|
||||
|
||||
|
||||
@Service
|
||||
public class GoodsService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final GoodsMapper goodsMapper;
|
||||
private final BizGroupMapper bizGroupMapper;
|
||||
private final DeviceMapper deviceMapper;
|
||||
|
||||
|
||||
public GoodsService(GoodsMapper goodsMapper, BizGroupMapper bizGroupMapper, DeviceMapper deviceMapper) {
|
||||
this.goodsMapper = goodsMapper;
|
||||
this.bizGroupMapper = bizGroupMapper;
|
||||
this.deviceMapper = deviceMapper;
|
||||
}
|
||||
|
||||
public Map<String, Object> getGoodsList(Boolean is_excel, Long offset, Long limit, Boolean is_group_access, Long biz_group_id, Long device_id, Long state,
|
||||
String code, String name, String vendor, String date_start, String date_end) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
if (is_group_access == false) {
|
||||
List<Map<String, Object>> listForTopId = bizGroupMapper.selectBizGroup(biz_group_id, false, 0L, 1L, null, null, null, null, null, null, null);
|
||||
if (listForTopId != null && listForTopId.size() > 0) {
|
||||
biz_group_id = (Long)listForTopId.get(0).get("top_group_id");
|
||||
if (biz_group_id == null)
|
||||
biz_group_id = (Long)listForTopId.get(0).get("biz_group_id");
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)goodsMapper.selectGoods(false, is_excel, offset, limit, is_group_access,
|
||||
biz_group_id, device_id, state, code, name, vendor, date_start, date_end);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", goodsMapper.selectGoods(true, is_excel, offset, limit, is_group_access,
|
||||
biz_group_id, device_id, state, code, name, vendor, date_start, date_end));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse addOrModifyGoods(boolean isModify, Long biz_group_id, Long goods_id, String code, String name, Long price, Long inventory, String vendor) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
UserInfo userInfo = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
|
||||
if (isModify) {
|
||||
if (goods_id == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
goodsMapper.updateGoods(biz_group_id, goods_id, code, name, price, inventory, vendor, userInfo.getGid());
|
||||
DbLogger.insert(2L, "상품정보 수정, goods_id: " + goods_id, 2L);
|
||||
}
|
||||
else {
|
||||
if (goodsMapper.selectExistGoods(biz_group_id, code, name) != null) {
|
||||
result.setErrCode(ErrorCode.ALREADY_EXIST);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (price == null)
|
||||
price = 0L;
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("biz_group_id", biz_group_id);
|
||||
params.put("code", code);
|
||||
params.put("name", name);
|
||||
params.put("price", price);
|
||||
params.put("inventory", inventory);
|
||||
params.put("vendor", vendor);
|
||||
params.put("gid", 2L); //TempCode
|
||||
|
||||
goodsMapper.insertGoods(params);
|
||||
DbLogger.insert(2L, "상품정보 추가, code: " + code + ", name: " + name, userInfo.getGid());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse removeGoods(String ids) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
List<Long> arrId = Arrays.stream(ids.split(","))
|
||||
.map(Long::parseLong)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int changed = goodsMapper.deleteGoods(arrId);
|
||||
//if (changed == 0) {
|
||||
//result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
//}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
public Map<String, Object> getDeviceGoodsList(Long device_id, String slot, Long goods_id) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
Map<String, Object> mapDevice = deviceMapper.selectDeviceById(device_id);
|
||||
mapResult.put("device_name", mapDevice.get("name"));
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)goodsMapper.selectGoodsByDevice(false, device_id);
|
||||
mapResult.put("goods_list", listMap);
|
||||
|
||||
List<Map<String, Object>> listMap2 = (List<Map<String, Object>>)goodsMapper.selectDeviceGoods(device_id, slot, goods_id);
|
||||
mapResult.put("device_goods_list", listMap2);
|
||||
|
||||
if (listMap.size() > 0) {
|
||||
Map<String, Object> mapTemplate = getGoodsTemplateByBizGroupId((Long)listMap.get(0).get("biz_group_id"));
|
||||
mapResult.put("goods_template_list", mapTemplate.get("goods_template_list"));
|
||||
}
|
||||
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse addDeviceGoods(Long device_id, List<Map<String, String>> device_goods) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
UserInfo userInfo = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
|
||||
if (goodsMapper.insertDeviceGoods(device_id, device_goods) == 0) {
|
||||
result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
}
|
||||
DbLogger.insert(2L, "무인기기 상품 추가, device_id: " + device_id, userInfo.getGid());
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse deleteDeviceGoods(Long device_id, List<Map<String, String>> device_goods) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
UserInfo userInfo = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
|
||||
//for (Map<String, Object> item : device_goods) {
|
||||
// item.put("device_id", device_id);
|
||||
//}
|
||||
if (goodsMapper.deleteDeviceGoods(device_id, device_goods) == 0) {
|
||||
result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
}
|
||||
DbLogger.insert(2L, "무인기기 상품 삭제, device_id: " + device_id, userInfo.getGid());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> getGoodsTemplateByBizGroupId(Long biz_group_id) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)goodsMapper.selectGoodsTemplateByBizGroupId(biz_group_id);
|
||||
|
||||
Map<Object, Map<String, Object>> templateMap = new HashMap<>();
|
||||
|
||||
for (Map<String, Object> item : listMap) {
|
||||
Object templateId = item.get("goods_template_id");
|
||||
|
||||
if (!templateMap.containsKey(templateId)) {
|
||||
Map<String, Object> template = new HashMap<>();
|
||||
template.put("goods_template_id", templateId);
|
||||
template.put("template_name", item.get("template_name"));
|
||||
template.put("template_reg_time", item.get("template_reg_time"));
|
||||
template.put("goods_template_elements", new ArrayList<Map<String, Object>>());
|
||||
template.put("template_inventory", item.get("template_inventory"));
|
||||
template.put("template_inventory_max", item.get("template_inventory_max"));
|
||||
template.put("template_inventory_alarm", item.get("template_inventory_alarm"));
|
||||
templateMap.put(templateId, template);
|
||||
}
|
||||
|
||||
Map<String, Object> element = new HashMap<>();
|
||||
element.put("goods_template_element_id", item.get("goods_template_element_id"));
|
||||
element.put("slot", item.get("slot"));
|
||||
element.put("goods_id", item.get("goods_id"));
|
||||
element.put("inventory", item.get("inventory"));
|
||||
element.put("idx", item.get("idx"));
|
||||
element.put("inventory_max", item.get("inventory_max"));
|
||||
element.put("inventory_alarm", item.get("inventory_alarm"));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map<String, Object>> elements = (List<Map<String, Object>>)templateMap.get(templateId).get("goods_template_elements");
|
||||
elements.add(element);
|
||||
}
|
||||
|
||||
List<Map<String, Object>> groupedList = new ArrayList<>(templateMap.values());
|
||||
mapResult.put("goods_template_list", groupedList);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public Map<String, Object> getGoodsTemplateById(Long goods_template_id) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> templateElements = goodsMapper.selectGoodsTemplateById(goods_template_id);
|
||||
mapResult.put("goods_template_elements", templateElements);
|
||||
|
||||
List<Map<String, Object>> goodsList = goodsMapper.selectGoodsByBizGroupId((Long)templateElements.get(0).get("biz_group_id"));
|
||||
mapResult.put("goods_list", goodsList);
|
||||
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse addGoodsTemplate(Long biz_group_id, String goods_template_name, Map<String, Object> goods_template_inventory, List<Map<String, String>> goods_template_elements) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
if (biz_group_id == null) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("biz_group_id", biz_group_id);
|
||||
params.put("name", goods_template_name);
|
||||
params.put("inventory", (Integer)goods_template_inventory.get("inventory"));
|
||||
params.put("inventory_max", (Integer)goods_template_inventory.get("inventory_max"));
|
||||
params.put("inventory_alarm", (Integer)goods_template_inventory.get("inventory_alarm"));
|
||||
|
||||
goodsMapper.insertGoodsTemplate(params);
|
||||
|
||||
Long goods_template_id = _AG.toLong((BigInteger)params.get("goods_template_id"));
|
||||
|
||||
if (goods_template_id == null || goods_template_id == 0) {
|
||||
result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (goods_template_elements != null && goods_template_elements.size() > 0) {
|
||||
if (goodsMapper.insertGoodsTemplateElements(goods_template_id, goods_template_elements) == 0) {
|
||||
result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse removeGoodsTemplate(Long goods_template_id) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
if (goods_template_id == null || goods_template_id == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
goodsMapper.deleteGoodsTemplateElements(goods_template_id);
|
||||
goodsMapper.deleteGoodsTemplate(goods_template_id);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.component.RcTreeLocation;
|
||||
import com.handong.smartservice.mapper.LocationMapper;
|
||||
|
||||
|
||||
@Service
|
||||
public class LocationService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final LocationMapper locationMapper;
|
||||
|
||||
public LocationService(LocationMapper locationMapper) {
|
||||
this.locationMapper = locationMapper;
|
||||
}
|
||||
|
||||
public Map<String, Object> getLocationList(Long offset, Long limit, String date_start, String date_end,
|
||||
String name, String description, String address) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)locationMapper.selectLocation(false, offset, limit,
|
||||
date_start, date_end, name, description, address);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", locationMapper.selectLocation(true, offset, limit,
|
||||
date_start, date_end, name, description, address));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
|
||||
if (listMap.size() == 0)
|
||||
return mapResult;
|
||||
|
||||
// get Location Tree part
|
||||
//
|
||||
List<Long> listLocationId = listMap.stream()
|
||||
.map(item -> (Long)item.get("location_id"))
|
||||
.filter(Objects::nonNull)
|
||||
.map(Long::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
List<Map<String, Object>> listTreeDb = locationMapper.selectLocationParentTree(listLocationId);
|
||||
|
||||
// Covert for react rc-tree
|
||||
List<Map<String, Object>> listRcTree = RcTreeLocation.convertDb2RcTree(listTreeDb);
|
||||
|
||||
mapResult.put("tree", listRcTree);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse addOrModifyLocation(boolean isModify, Long location_id, Long pid, String name, String description, String address) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
if (isModify) {
|
||||
if (location_id == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
locationMapper.updateLocation(location_id, pid, name, description, address);
|
||||
}
|
||||
else {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("pid", pid);
|
||||
params.put("name", name);
|
||||
params.put("gid", 2L); //TempCode
|
||||
params.put("description", description);
|
||||
params.put("address", address);
|
||||
|
||||
if (locationMapper.insertLocation(params) == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
}
|
||||
else {
|
||||
result.put("result", Map.of("location_id", params.get("location_id")));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse removeLocation(String ids) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
List<Long> arrId = Arrays.stream(ids.split(","))
|
||||
.map(Long::parseLong)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int changed = locationMapper.changeStateLocation(arrId, 2);
|
||||
//result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
if (changed > 0) {
|
||||
locationMapper.changePidLocation(arrId, null);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ver2
|
||||
public CtResponse getLocation2(boolean isDbRoot, Long pid, String date_start, String date_end, String name, String description, String address) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
if (isDbRoot == true) {
|
||||
List<Map<String, Object>> listTreeDb = (List<Map<String, Object>>)locationMapper.selectRootNode(isDbRoot, date_start, date_end, name, description, address);
|
||||
|
||||
// Covert for react rc-tree
|
||||
List<Map<String, Object>> listRcTree = RcTreeLocation.convertDb2RcTree(listTreeDb);
|
||||
result.put("result", Map.of("tree", listRcTree));
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> listTreeDb = (List<Map<String, Object>>)locationMapper.selectLocationChildTree(true, pid, date_start, date_end, name, description, address);
|
||||
|
||||
// Covert for react rc-tree
|
||||
List<Map<String, Object>> listRcTree = RcTreeLocation.convertDb2RcTree(listTreeDb);
|
||||
result.put("result", Map.of("tree", listRcTree));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.mapper.NoticeMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
public class NoticeService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final NoticeMapper noticeMapper;
|
||||
|
||||
|
||||
public NoticeService(NoticeMapper noticeMapper) {
|
||||
this.noticeMapper = noticeMapper;
|
||||
}
|
||||
|
||||
public CtResponse getNoticeDetail(String notice_id) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Map<String, Object> detail = noticeMapper.selectDetailNotice(notice_id);
|
||||
|
||||
if (notice_id == null || notice_id.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result.put("result", detail);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> getNoticeList(Long offset, Long limit, String date_start, String date_end,
|
||||
String title, String content) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)noticeMapper.selectNotice(false, offset, limit,
|
||||
date_start, date_end, title, content);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
//Long totalCount = _AG.getTotalCount(noticeMapper.selectNotice(true, offset, limit,
|
||||
// date_start, date_end, title, content));
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", noticeMapper.selectNotice(true, offset, limit,
|
||||
date_start, date_end, title, content));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse addOrModifyNotice(boolean isModify, String notice_id, String title, String content) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
if (isModify) {
|
||||
if (notice_id == null || notice_id.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
noticeMapper.updateNotice(_AG.toLong(notice_id), title, content);
|
||||
}
|
||||
else {
|
||||
noticeMapper.insertNotice(title, content, 2L);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse removeNotice(String ids) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
List<Long> arrId = Arrays.stream(ids.split(","))
|
||||
.map(Long::parseLong)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int changed = noticeMapper.changeStateNotice(arrId, 2);
|
||||
//if (changed == 0) {
|
||||
//result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
//}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.mapper.OperatingHistoryMapper;
|
||||
import com.handong.smartservice.mapper.VocMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
public class OperatingHistoryService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final OperatingHistoryMapper operatingHistoryMapper;
|
||||
|
||||
|
||||
public OperatingHistoryService(OperatingHistoryMapper operatingHistoryMapper) {
|
||||
this.operatingHistoryMapper = operatingHistoryMapper;
|
||||
}
|
||||
|
||||
public Map<String, Object> getOperatingHistoryList(Boolean is_excel, Long offset, Long limit, String date_start, String date_end,
|
||||
Long type, String action) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)operatingHistoryMapper.selectOperatingHistory(false, is_excel, offset, limit,
|
||||
date_start, date_end, type, action);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", operatingHistoryMapper.selectOperatingHistory(true, is_excel, offset, limit,
|
||||
date_start, date_end, type, action));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse add(Long type, String action, Long gid) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
operatingHistoryMapper.insertOperatingHistory(type, action, gid);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
public @interface RequiredArgsConstructor {
|
||||
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.mapper.ResourceBoardMapper;
|
||||
|
||||
|
||||
@Service
|
||||
public class ResourceBoardService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final ResourceBoardMapper resourceBoardMapper;
|
||||
|
||||
|
||||
public ResourceBoardService(ResourceBoardMapper resourceBoardMapper) {
|
||||
this.resourceBoardMapper = resourceBoardMapper;
|
||||
}
|
||||
|
||||
public CtResponse getResourceBoardDetail(String resource_board_id) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Map<String, Object> detail = resourceBoardMapper.selectDetailResourceBoard(resource_board_id);
|
||||
|
||||
if (resource_board_id == null || resource_board_id.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result.put("result", detail);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> getResourceBoardList(Long offset, Long limit, String date_start, String date_end,
|
||||
String title, String content) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)resourceBoardMapper.selectResourceBoard(false, offset, limit,
|
||||
date_start, date_end, title, content);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
//Long totalCount = _AG.getTotalCount(resourceBoardMapper.selectResourceBoard(true, offset, limit,
|
||||
// date_start, date_end, title, content));
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", resourceBoardMapper.selectResourceBoard(true, offset, limit,
|
||||
date_start, date_end, title, content));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse addOrModifyResourceBoard(boolean isModify, String resource_board_id, String title, String content) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
if (isModify) {
|
||||
if (resource_board_id == null || resource_board_id.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
resourceBoardMapper.updateResourceBoard(_AG.toLong(resource_board_id), title, content);
|
||||
}
|
||||
else {
|
||||
resourceBoardMapper.insertResourceBoard(title, content, 2L);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse removeResourceBoard(String ids) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
List<Long> arrId = Arrays.stream(ids.split(","))
|
||||
.map(Long::parseLong)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int changed = resourceBoardMapper.changeStateResourceBoard(arrId, 2);
|
||||
//if (changed == 0) {
|
||||
//result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
//}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.handong.smartservice.mapper.TransactionMapper;
|
||||
import com.handong.smartservice.mapper.BizGroupMapper;
|
||||
import com.handong.smartservice.mapper.GoodsMapper;
|
||||
|
||||
@Service
|
||||
public class SalesService {
|
||||
|
||||
private final TransactionMapper transactionMapper;
|
||||
private final BizGroupMapper bizGroupMapper;
|
||||
|
||||
public SalesService(TransactionMapper transactionMapper, BizGroupMapper bizGroupMapper) {
|
||||
this.transactionMapper = transactionMapper;
|
||||
this.bizGroupMapper = bizGroupMapper;
|
||||
}
|
||||
|
||||
public Map<String, Object> getSalesList(Boolean is_excel, Long offset, Long limit, Boolean is_group_access, Long biz_group_id, String date_start, String date_end,
|
||||
String uid1, String device_name, Long approval_type, Long date_type) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
if (is_group_access == false) {
|
||||
List<Map<String, Object>> listForTopId = bizGroupMapper.selectBizGroup(biz_group_id, false, 0L, 1L, null, null, null, null, null, null, null);
|
||||
if (listForTopId != null && listForTopId.size() > 0) {
|
||||
biz_group_id = (Long)listForTopId.get(0).get("top_group_id");
|
||||
if (biz_group_id == null)
|
||||
biz_group_id = (Long)listForTopId.get(0).get("biz_group_id");
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)transactionMapper.selectTransaction3(false, is_excel, offset, limit, is_group_access,
|
||||
biz_group_id, date_start, date_end, uid1, device_name, approval_type, date_type);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", transactionMapper.selectTransaction3(true, is_excel, offset, limit, is_group_access,
|
||||
biz_group_id, date_start, date_end, uid1, device_name, approval_type, date_type));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
return mapResult;
|
||||
}
|
||||
}
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.DbLogger;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.mapper.BizGroupMapper;
|
||||
import com.handong.smartservice.mapper.DeviceMapper;
|
||||
import com.handong.smartservice.mapper.GoodsMapper;
|
||||
import com.handong.smartservice.mapper.TerminalMapper;
|
||||
|
||||
|
||||
@Service
|
||||
public class TerminalService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final TerminalMapper terminalMapper;
|
||||
private final DeviceMapper deviceMapper;
|
||||
private final BizGroupMapper bizGroupMapper;
|
||||
|
||||
|
||||
public TerminalService(TerminalMapper terminalMapper, DeviceMapper deviceMapper, BizGroupMapper bizGroupMapper) {
|
||||
this.terminalMapper = terminalMapper;
|
||||
this.deviceMapper = deviceMapper;
|
||||
this.bizGroupMapper = bizGroupMapper;
|
||||
}
|
||||
|
||||
public Map<String, Object> getTerminalList(Boolean is_excel, Long offset, Long limit, Boolean is_group_access, Long biz_group_id, Long state, String date_start, String date_end) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
if (is_group_access == false) {
|
||||
List<Map<String, Object>> listForTopId = bizGroupMapper.selectBizGroup(biz_group_id, false, 0L, 1L, null, null, null, null, null, null, null);
|
||||
if (listForTopId != null && listForTopId.size() > 0) {
|
||||
biz_group_id = (Long)listForTopId.get(0).get("top_group_id");
|
||||
if (biz_group_id == null)
|
||||
biz_group_id = (Long)listForTopId.get(0).get("biz_group_id");
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)terminalMapper.selectTerminal(false, is_excel, offset, limit, is_group_access,
|
||||
biz_group_id, null, state, date_start, date_end);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", terminalMapper.selectTerminal(true, is_excel, offset, limit, is_group_access,
|
||||
biz_group_id, null, state, date_start, date_end));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public CtResponse addOrModifyTerminal(boolean isModify, Long addType, Long biz_group_id, Long terminal_id, String name, String uid1, Long type) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
if (isModify) {
|
||||
if (terminal_id == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
terminalMapper.updateTerminal(terminal_id, name, uid1, type, null, 2L);
|
||||
DbLogger.insert(2L, "카드단말기 정보변경, terminal_id: " + terminal_id, 2L);
|
||||
}
|
||||
else {
|
||||
if (terminalMapper.selectExistTerminal(name, uid1, type) != null) {
|
||||
result.setErrCode(ErrorCode.ALREADY_EXIST);
|
||||
return result;
|
||||
}
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("name", name);
|
||||
params.put("gid", 2L); //TempCode
|
||||
|
||||
logger.info("addType = " + addType);
|
||||
/* oldVer
|
||||
if (addType == 1L) {
|
||||
logger.info("addType2 = " + addType);
|
||||
if (deviceMapper.insertDevice(params) == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
Long new_device_id = _AG.toLong((BigInteger)params.get("device_id"));
|
||||
|
||||
if (deviceMapper.insertDeviceBizGroup(biz_group_id, new_device_id) == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (addType != 1L)
|
||||
params.put("state", 5L);
|
||||
else
|
||||
params.put("state", 1L);
|
||||
|
||||
if (deviceMapper.insertDevice(params) == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
Long new_device_id = _AG.toLong((BigInteger)params.get("device_id"));
|
||||
|
||||
if (deviceMapper.insertDeviceBizGroup(biz_group_id, new_device_id) == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
//
|
||||
|
||||
params.put("uid1", uid1);
|
||||
params.put("type", type);
|
||||
params.put("gid", 2L); //TempCode
|
||||
|
||||
if (terminalMapper.insertTerminal(params) == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
DbLogger.insert(2L, "카드단말기 추가, TID: " + uid1, 2L);
|
||||
|
||||
Long new_terminal_id = _AG.toLong((BigInteger)params.get("terminal_id"));
|
||||
|
||||
if (terminalMapper.insertTerminalBizGroup(biz_group_id, new_terminal_id) == 0) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result.put("result", Map.of("terminal_id", new_terminal_id));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
//public CtResponse removeTerminal(String ids) {
|
||||
public CtResponse removeTerminal(Long biz_group_id, Long terminal_id) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Map<String, Object> mapTerminal = terminalMapper.selectTerminalById(terminal_id);
|
||||
if (mapTerminal != null) {
|
||||
Long device_id = (Long)mapTerminal.get("device_id");
|
||||
if (device_id != null) {
|
||||
int changed = deviceMapper.deleteDevice(device_id);
|
||||
changed = deviceMapper.deleteDeviceBizGroup(biz_group_id, device_id); // delete n:n relation
|
||||
}
|
||||
}
|
||||
|
||||
//List<Long> arrId = Arrays.stream(ids.split(","))
|
||||
// .map(Long::parseLong)
|
||||
// .collect(Collectors.toList());
|
||||
//int changed = terminalMapper.changeStateTerminals(arrId, 2);
|
||||
int changed = terminalMapper.deleteTerminal(terminal_id);
|
||||
if (changed == 0) {
|
||||
result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
}
|
||||
DbLogger.insert(2L, "카드단말기 삭제, terminal_id: " + terminal_id, 2L);
|
||||
|
||||
changed = terminalMapper.deleteTerminalBizGroup(biz_group_id, terminal_id); // delete n:n relation
|
||||
if (changed == 0) {
|
||||
result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse terminalState(String uid1, Long type, Long state) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
if (terminalMapper.terminalState(uid1, type, state) == 0) {
|
||||
result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
}
|
||||
DbLogger.insert(1L, "카드단말기 상태 변경, TID: " + uid1 + ", state: " + state, 2L);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.handong.smartservice.mapper.TransactionMapper;
|
||||
import com.handong.smartservice.mapper.BizGroupMapper;
|
||||
import com.handong.smartservice.mapper.GoodsMapper;
|
||||
import com.handong.smartservice.mapper.TerminalMapper;
|
||||
|
||||
@Service
|
||||
public class TransactionService {
|
||||
|
||||
private final TransactionMapper transactionMapper;
|
||||
private final GoodsMapper goodsMapper;
|
||||
private final BizGroupMapper bizGroupMapper;
|
||||
private final TerminalMapper terminalMapper;
|
||||
|
||||
public TransactionService(TransactionMapper transactionMapper, GoodsMapper goodsMapper, BizGroupMapper bizGroupMapper, TerminalMapper terminalMapper) {
|
||||
this.transactionMapper = transactionMapper;
|
||||
this.goodsMapper = goodsMapper;
|
||||
this.bizGroupMapper = bizGroupMapper;
|
||||
this.terminalMapper = terminalMapper;
|
||||
}
|
||||
|
||||
public Map<String, Object> getTransactionList(Boolean is_excel, Long offset, Long limit, Boolean is_group_access, Long biz_group_id, String date_start, String date_end,
|
||||
String uid1, Long uid1_type, String type, Long amount, String approval, String pay_name, String pay_vendor, String slot, String code, String goods_name) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
/*
|
||||
if (is_group_access == false) {
|
||||
List<Map<String, Object>> listForTopId = bizGroupMapper.selectBizGroup(biz_group_id, false, 0L, 1L, null, null, null, null, null, null, null);
|
||||
if (listForTopId != null && listForTopId.size() > 0) {
|
||||
biz_group_id = (Long)listForTopId.get(0).get("top_group_id");
|
||||
if (biz_group_id == null)
|
||||
biz_group_id = (Long)listForTopId.get(0).get("biz_group_id");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)transactionMapper.selectTransaction(false, is_excel, offset, limit, is_group_access,
|
||||
biz_group_id, date_start, date_end, uid1, uid1_type, type, amount, approval, pay_name, pay_vendor, slot, code, goods_name);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", transactionMapper.selectTransaction(true, is_excel, offset, limit, is_group_access,
|
||||
biz_group_id, date_start, date_end, uid1, uid1_type, type, amount, approval, pay_name, pay_vendor, slot, code, goods_name));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public Map<String, Object> getUndefinedTransactionList(Boolean is_excel, Long offset, Long limit, String date_start, String date_end,
|
||||
String uid1, Long uid1_type, String type, Long amount, String approval, String pay_name, String pay_vendor, String slot, String code, String goods_name) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)transactionMapper.selectTransactionBizGroup0(
|
||||
false, is_excel, offset, limit, date_start, date_end, uid1, uid1_type, type, amount, approval, pay_name, pay_vendor, slot, code, goods_name);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", transactionMapper.selectTransactionBizGroup0(
|
||||
true, is_excel, offset, limit, date_start, date_end, uid1, uid1_type, type, amount, approval, pay_name, pay_vendor, slot, code, goods_name));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse addTransaction(String uid1, Long uid1_type, String type, Long amount, String approval, String pay_name, String pay_vendor, String slot, String pay_unique_num, String pay_order_time) {
|
||||
CtResponse result = new CtResponse();
|
||||
Long biz_group_id = 0L;
|
||||
Long device_id = 0L;
|
||||
|
||||
Map<String, Object> terminal = terminalMapper.selectTerminal3(uid1, uid1_type);
|
||||
if (terminal != null) {
|
||||
device_id = (Long)terminal.get("device_id");
|
||||
Map<String, Object> mapBizGroup = bizGroupMapper.selectBizGroupByDeviceId(device_id);
|
||||
if (mapBizGroup != null) {
|
||||
biz_group_id = (Long)mapBizGroup.get("biz_group_id");
|
||||
}
|
||||
else {
|
||||
Long terminal_id = (Long)terminal.get("terminal_id");
|
||||
Map<String, Object> mapBizGroup2 = bizGroupMapper.selectBizGroupByTerminalId(terminal_id);
|
||||
if (mapBizGroup2 != null) {
|
||||
biz_group_id = (Long)mapBizGroup2.get("biz_group_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//select uid1, uid1_type -> device_id ->device_goods (slot) -> goods_id
|
||||
Map<String, Object> goods = goodsMapper.selectGoodsByUid1(uid1, uid1_type, slot);
|
||||
if (goods != null) {
|
||||
device_id = (Long)goods.get("device_id");
|
||||
}
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("uid1", uid1);
|
||||
params.put("uid1_type", uid1_type);
|
||||
params.put("order_time", pay_order_time);
|
||||
params.put("type", type);
|
||||
params.put("amount", amount);
|
||||
params.put("approval", approval);
|
||||
params.put("pay_unique_num", pay_unique_num);
|
||||
params.put("pay_name", pay_name);
|
||||
params.put("pay_vendor", pay_vendor);
|
||||
params.put("slot", slot);
|
||||
params.put("biz_group_id", biz_group_id);
|
||||
params.put("device_id", device_id);
|
||||
|
||||
if (type.compareTo("D4") == 0) {
|
||||
goodsMapper.updateDeviceGoodsPlusInventory(approval);
|
||||
}
|
||||
else if (goods != null) {
|
||||
params.put("goods_name", goods.get("name"));
|
||||
params.put("code", goods.get("code"));
|
||||
params.put("price", goods.get("price"));
|
||||
|
||||
goodsMapper.updateDeviceGoodsMinusInventory((Long)goods.get("device_id"), slot);
|
||||
}
|
||||
|
||||
transactionMapper.insertTransaction(params);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.handong.smartservice.service;
|
||||
|
||||
import com.handong.smartservice._AG;
|
||||
import com.handong.smartservice.component.CtResponse;
|
||||
import com.handong.smartservice.component.ErrorCode;
|
||||
import com.handong.smartservice.mapper.VocMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
public class VocService {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final VocMapper vocMapper;
|
||||
|
||||
|
||||
public VocService(VocMapper vocMapper) {
|
||||
this.vocMapper = vocMapper;
|
||||
}
|
||||
|
||||
public CtResponse getVocDetail(String voc_id) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
Map<String, Object> detail = vocMapper.selectDetailVoc(voc_id);
|
||||
|
||||
if (voc_id == null || voc_id.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
result.put("result", detail);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> getVocList(Long offset, Long limit, String date_start, String date_end,
|
||||
String title, String content, String process) {
|
||||
Map<String, Object> mapResult = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> listMap = (List<Map<String, Object>>)vocMapper.selectVoc(false, offset, limit,
|
||||
date_start, date_end, title, content, process);
|
||||
mapResult.put("list", listMap);
|
||||
|
||||
//Long totalCount = _AG.getTotalCount(vocMapper.selectVoc(true, offset, limit,
|
||||
// date_start, date_end, title, content, process));
|
||||
Long totalCount = _AG.getNumberFromQuery("COUNT(*)", vocMapper.selectVoc(true, offset, limit,
|
||||
date_start, date_end, title, content, process));
|
||||
mapResult.put("totalCount", totalCount);
|
||||
mapResult.put("offset", offset);
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public CtResponse addOrModifyVoc(boolean isModify, String voc_id, String title, String content) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
if (isModify) {
|
||||
if (voc_id == null || voc_id.isEmpty()) {
|
||||
result.setErrCode(ErrorCode.INVALID_PARAMETER);
|
||||
return result;
|
||||
}
|
||||
|
||||
vocMapper.updateVoc(_AG.toLong(voc_id), title, content);
|
||||
}
|
||||
else {
|
||||
vocMapper.insertVoc(title, content, 2L);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public CtResponse removeVoc(String ids) {
|
||||
CtResponse result = new CtResponse();
|
||||
|
||||
List<Long> arrId = Arrays.stream(ids.split(","))
|
||||
.map(Long::parseLong)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int changed = vocMapper.changeStateVoc(arrId, 2);
|
||||
//if (changed == 0) {
|
||||
//result.setErrCode(ErrorCode.QUERY_ERROR);
|
||||
//}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
spring:
|
||||
application:
|
||||
name: "smartservice"
|
||||
project: "smartservice"
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
view:
|
||||
prefix: /WEB-INF/
|
||||
suffix: .jsp
|
||||
data:
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
password: secret
|
||||
datasource:
|
||||
#url: jdbc:mysql://localhost:3306/smartservice?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull
|
||||
url: jdbc:mysql://sensemeka.ddns.net:19106/hdsmartsvc?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull
|
||||
username: smartsvc2
|
||||
password: Gknehd!@wjdqhxhdtls
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
session:
|
||||
jdbc:
|
||||
initialize-schema: always
|
||||
|
||||
|
||||
mybatis:
|
||||
type-aliases-package: com.handong.smartservice.mapper
|
||||
mapper-locations: classpath:mapper/**/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
jwt:
|
||||
secret: c2VjcmV0L12AAsWtleS12ZXJ5LXN232DSJDSKDJWNsllY3VyZS1zZWNyZXQta2V5LXZlcnktc2VjdXJl
|
||||
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
hibernate: info
|
||||
springframework:
|
||||
security: debug
|
||||
com:
|
||||
handong: debug
|
||||
|
||||
server:
|
||||
port:
|
||||
18080
|
||||
error:
|
||||
whitelabel:
|
||||
enabled: FALSE
|
||||
@@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.AccountMapper">
|
||||
|
||||
<select id="selectAccount" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
AC.gid, AC.user_id, AC.reg_time, AC.user_pw, AC.biz_group_id, AC.user_pw_time, AC.nick_name, AC.email, AC.state, AC.permission
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM account AS AC
|
||||
WHERE state != 2
|
||||
<if test="biz_group_id != 0">
|
||||
AND AC.biz_group_id = #{biz_group_id}
|
||||
</if>
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(AC.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(AC.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="gid != 0">
|
||||
AND AC.gid = #{gid}
|
||||
</if>
|
||||
<if test="user_id != null and user_id != ''">
|
||||
AND AC.user_id = #{user_id}
|
||||
</if>
|
||||
<if test="email != null and email != ''">
|
||||
AND AC.email like CONCAT(#{email}, '%')
|
||||
</if>
|
||||
<if test="nick_name != null and nick_name != ''">
|
||||
AND AC.nick_name like CONCAT(#{nick_name}, '%')
|
||||
</if>
|
||||
<if test="isCount == false and is_excel == false">
|
||||
ORDER BY gid DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectAccount2" resultType="map">
|
||||
WITH RECURSIVE group_tree AS (
|
||||
SELECT
|
||||
biz_group_id,
|
||||
name,
|
||||
pid
|
||||
FROM biz_group
|
||||
WHERE biz_group_id = #{biz_group_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
bg.biz_group_id,
|
||||
bg.name,
|
||||
bg.pid
|
||||
FROM biz_group bg
|
||||
INNER JOIN group_tree gt ON bg.pid = gt.biz_group_id
|
||||
)
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
AC.gid, AC.user_id, AC.reg_time, AC.user_pw, AC.biz_group_id, GT.name AS biz_group_name, AC.user_pw_time, AC.nick_name, AC.email, AC.state, AC.permission
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM account AS AC
|
||||
JOIN group_tree GT ON GT.biz_group_id = AC.biz_group_id
|
||||
WHERE state != 2
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(AC.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(AC.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="gid != 0">
|
||||
AND AC.gid = #{gid}
|
||||
</if>
|
||||
<if test="user_id != null and user_id != ''">
|
||||
AND AC.user_id = #{user_id}
|
||||
</if>
|
||||
<if test="email != null and email != ''">
|
||||
AND AC.email like CONCAT(#{email}, '%')
|
||||
</if>
|
||||
<if test="nick_name != null and nick_name != ''">
|
||||
AND AC.nick_name like CONCAT(#{nick_name}, '%')
|
||||
</if>
|
||||
<if test="isCount == false and is_excel == false">
|
||||
ORDER BY gid DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertAccount">
|
||||
INSERT INTO account
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
user_id, user_pw,
|
||||
<if test="nick_name != null and nick_name != ''">nick_name,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
<if test="state != 0">state,</if>
|
||||
<if test="biz_group_id != 0">biz_group_id,</if>
|
||||
<if test="permission != 0">permission,</if>
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{user_id}, #{user_pw},
|
||||
<if test="nick_name != null and nick_name != ''">#{nick_name},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="state != 0">#{state},</if>
|
||||
<if test="biz_group_id != 0">#{biz_group_id},</if>
|
||||
<if test="permission != 0">#{permission},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateAccount">
|
||||
UPDATE account
|
||||
<set>
|
||||
<if test="user_pw != null and user_pw != ''">user_pw = #{user_pw},</if>
|
||||
<if test="nick_name != null and nick_name != ''">nick_name = #{nick_name},</if>
|
||||
<if test="email != null and email != ''">email = #{email},</if>
|
||||
<if test="state != 0">state = #{state},</if>
|
||||
<if test="biz_group_id != 0">biz_group_id = #{biz_group_id},</if>
|
||||
</set>
|
||||
WHERE gid = #{gid}
|
||||
</update>
|
||||
|
||||
<update id="changeState">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
UPDATE account
|
||||
SET state=#{state}
|
||||
WHERE gid IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,493 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.BizGroupMapper">
|
||||
|
||||
<select id="selectBizGroup" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
BG.biz_group_id, BG.reg_time, BG.name, BG.biz_reg_num, BG.email, BG.phone, BG.address, BG.top_group_id
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM biz_group AS BG
|
||||
WHERE state != 2
|
||||
<if test="name != null and name != ''">
|
||||
AND name like CONCAT(#{name}, '%')
|
||||
</if>
|
||||
<if test="biz_group_id != 0">
|
||||
AND biz_group_id = #{biz_group_id}
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND name like CONCAT(#{name}, '%')
|
||||
</if>
|
||||
<if test="biz_reg_num != null and biz_reg_num != ''">
|
||||
AND biz_reg_num like CONCAT(#{biz_reg_num}, '%')
|
||||
</if>
|
||||
<if test="email != null and email != ''">
|
||||
AND email like CONCAT(#{email}, '%')
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">
|
||||
AND phone like CONCAT(#{phone}, '%')
|
||||
</if>
|
||||
<if test="address != null and address != ''">
|
||||
AND address like CONCAT(#{address}, '%')
|
||||
</if>
|
||||
<if test="isCount == false">
|
||||
ORDER BY biz_group_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectExistBizGroup" resultType="map">
|
||||
SELECT biz_group_id
|
||||
FROM biz_group
|
||||
WHERE state != 2 AND biz_reg_num = #{biz_reg_num}
|
||||
<if test="biz_group_id != 0">
|
||||
AND biz_group_id != #{biz_group_id}
|
||||
</if>
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectBizGroupByDeviceId" resultType="map">
|
||||
SELECT biz_group_id
|
||||
FROM device_biz_group
|
||||
WHERE device_id = #{device_id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectBizGroupByTerminalId" resultType="map">
|
||||
SELECT biz_group_id
|
||||
FROM terminal_biz_group
|
||||
WHERE terminal_id = #{terminal_id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!--<insert id="insertBizGroup">-->
|
||||
<!--<insert id="insertBizGroup" parameterType="map">
|
||||
<selectKey keyProperty="biz_group_id" resultType="long" order="AFTER">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
-->
|
||||
<insert id="insertBizGroup" parameterType="map" useGeneratedKeys="true" keyProperty="biz_group_id">
|
||||
INSERT INTO biz_group
|
||||
<choose>
|
||||
<when test="pid == 0">
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
name, biz_reg_num, gid
|
||||
<if test="email != null and email != ''">, email</if>
|
||||
<if test="phone != null and phone != ''">, phone</if>
|
||||
<if test="ceo != null and ceo != ''">, ceo</if>
|
||||
<if test="address != null and address != ''">, address</if>
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{name}, #{biz_reg_num}, #{gid}
|
||||
<if test="email != null and email != ''">, #{email}</if>
|
||||
<if test="phone != null and phone != ''">, #{phone}</if>
|
||||
<if test="ceo != null and ceo != ''">, #{ceo}</if>
|
||||
<if test="address != null and address != ''">, #{address}</if>
|
||||
</trim>
|
||||
</when>
|
||||
<otherwise>
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
top_group_id, pid, name, biz_reg_num, gid
|
||||
<if test="email != null and email != ''">, email</if>
|
||||
<if test="phone != null and phone != ''">, phone</if>
|
||||
<if test="ceo != null and ceo != ''">, ceo</if>
|
||||
<if test="address != null and address != ''">, address</if>
|
||||
</trim>
|
||||
SELECT
|
||||
COALESCE(TGI.top_group_id, #{pid}) AS top_group_id,
|
||||
#{pid}, #{name}, #{biz_reg_num}, #{gid}
|
||||
<if test="email != null and email != ''">, #{email}</if>
|
||||
<if test="phone != null and phone != ''">, #{phone}</if>
|
||||
<if test="ceo != null and ceo != ''">, #{ceo}</if>
|
||||
<if test="address != null and address != ''">, #{address}</if>
|
||||
FROM (
|
||||
SELECT top_group_id
|
||||
FROM biz_group
|
||||
WHERE biz_group_id = #{pid}
|
||||
LIMIT 1
|
||||
) AS TGI;
|
||||
</otherwise>
|
||||
</choose>
|
||||
</insert>
|
||||
|
||||
<update id="updateBizGroup">
|
||||
UPDATE biz_group
|
||||
<set>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="biz_reg_num != null and biz_reg_num != ''">biz_reg_num = #{biz_reg_num},</if>
|
||||
<if test="email != null and email != ''">email = #{email},</if>
|
||||
<if test="phone != null and phone != ''">phone = #{phone},</if>
|
||||
<if test="ceo != null and ceo != ''">ceo = #{ceo},</if>
|
||||
<if test="address != null and address != ''">address = #{address},</if>
|
||||
<if test="pid != 0">pid = #{pid},</if>
|
||||
</set>
|
||||
WHERE biz_group_id = #{biz_group_id}
|
||||
</update>
|
||||
|
||||
<update id="changeStateBizGroup">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
UPDATE biz_group
|
||||
SET state = #{state}
|
||||
WHERE biz_group_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
<!--
|
||||
<delete id="deleteBizGroup">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
DELETE FROM biz_group
|
||||
WHERE biz_group_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
-->
|
||||
|
||||
<update id="changePidBizGroup">
|
||||
UPDATE biz_group
|
||||
<choose>
|
||||
<when test="new_pid != null">
|
||||
SET pid = #{new_pid}
|
||||
</when>
|
||||
<otherwise>
|
||||
SET pid = NULL
|
||||
</otherwise>
|
||||
</choose>
|
||||
WHERE pid IN
|
||||
<foreach collection="pids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="changeState">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
UPDATE biz_group
|
||||
SET state = #{state}
|
||||
WHERE biz_group_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<select id="selectBizGroupParentTree" resultType="map">
|
||||
WITH RECURSIVE group_start AS (
|
||||
SELECT biz_group_id
|
||||
FROM biz_group
|
||||
WHERE biz_group_id IN
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
),
|
||||
group_path AS (
|
||||
SELECT
|
||||
g.biz_group_id,
|
||||
g.name,
|
||||
g.biz_reg_num,
|
||||
g.pid,
|
||||
g.top_group_id,
|
||||
g.biz_group_id AS start_biz_group_id
|
||||
FROM biz_group g
|
||||
INNER JOIN group_start gs ON g.biz_group_id = gs.biz_group_id
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
g.biz_group_id,
|
||||
g.name,
|
||||
g.biz_reg_num,
|
||||
g.pid,
|
||||
g.top_group_id,
|
||||
gp.start_biz_group_id
|
||||
FROM biz_group g
|
||||
INNER JOIN group_path gp ON gp.pid = g.biz_group_id
|
||||
)
|
||||
SELECT DISTINCT
|
||||
biz_group_id,
|
||||
name,
|
||||
biz_reg_num,
|
||||
pid,
|
||||
top_group_id
|
||||
FROM
|
||||
group_path
|
||||
ORDER BY pid ASC, biz_group_id ASC;
|
||||
</select>
|
||||
|
||||
<select id="selectRootNode" resultType="map">
|
||||
SELECT BG.biz_group_id, BG.reg_time, BG.name, BG.biz_reg_num, BG.email, BG.phone, BG.ceo, BG.address, BG.top_group_id,
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM biz_group BG2
|
||||
WHERE BG2.pid = BG.biz_group_id
|
||||
AND BG2.state != 2
|
||||
) AS hasChildren
|
||||
FROM biz_group BG
|
||||
WHERE BG.state != 2 AND BG.pid is null
|
||||
<if test="top_group_id != 0">
|
||||
AND (BG.biz_group_id = #{top_group_id} OR BG.top_group_id = #{top_group_id})
|
||||
</if>
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(BG.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(BG.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND BG.name like CONCAT(#{name}, '%')
|
||||
</if>
|
||||
<if test="biz_reg_num != null and biz_reg_num != ''">
|
||||
AND BG.biz_reg_num like CONCAT(#{biz_reg_num}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectBizGroupChildTree" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="queryAll == true">
|
||||
BG.biz_group_id, BG.top_group_id, BG.reg_time, BG.name, BG.biz_reg_num, BG.email, BG.phone, BG.ceo, BG.address,
|
||||
</when>
|
||||
<otherwise>
|
||||
BG.biz_group_id, BG.name, BG.biz_reg_num,
|
||||
</otherwise>
|
||||
</choose>
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM biz_group BG2
|
||||
WHERE BG2.pid = BG.biz_group_id
|
||||
AND BG2.state != 2
|
||||
) AS hasChildren
|
||||
FROM biz_group BG
|
||||
WHERE BG.state != 2 AND BG.pid = #{pid}
|
||||
<if test="top_group_id != 0">
|
||||
AND BG.top_group_id = #{top_group_id}
|
||||
</if>
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(BG.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(BG.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND BG.name like CONCAT(#{name}, '%')
|
||||
</if>
|
||||
<if test="biz_reg_num != null and biz_reg_num != ''">
|
||||
AND BG.biz_reg_num like CONCAT(#{biz_reg_num}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectBizGroupTree" resultType="map">
|
||||
WITH RECURSIVE group_tree AS (
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="queryAll == true">
|
||||
BG.biz_group_id, BG.pid, BG.top_group_id, BG.reg_time, BG.name, BG.biz_reg_num, BG.email, BG.phone, BG.ceo, BG.address,
|
||||
</when>
|
||||
<otherwise>
|
||||
BG.biz_group_id, BG.pid, BG.top_group_id, BG.name, BG.biz_reg_num,
|
||||
</otherwise>
|
||||
</choose>
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM biz_group BG2
|
||||
WHERE BG2.pid = BG.biz_group_id
|
||||
AND BG2.state != 2
|
||||
) AS hasChildren
|
||||
FROM biz_group BG
|
||||
WHERE BG.state != 2
|
||||
<if test="biz_group_id != 0">
|
||||
AND BG.biz_group_id = #{biz_group_id}
|
||||
</if>
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(BG.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(BG.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND BG.name like CONCAT(#{name}, '%')
|
||||
</if>
|
||||
<if test="biz_reg_num != null and biz_reg_num != ''">
|
||||
AND BG.biz_reg_num like CONCAT(#{biz_reg_num}, '%')
|
||||
</if>
|
||||
|
||||
<choose>
|
||||
<when test="biz_group_id != 0">
|
||||
UNION ALL
|
||||
</when>
|
||||
<otherwise>
|
||||
UNION
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="queryAll == true">
|
||||
BG.biz_group_id, BG.pid, BG.top_group_id, BG.reg_time, BG.name, BG.biz_reg_num, BG.email, BG.phone, BG.ceo, BG.address,
|
||||
</when>
|
||||
<otherwise>
|
||||
BG.biz_group_id, BG.pid, BG.top_group_id, BG.name, BG.biz_reg_num,
|
||||
</otherwise>
|
||||
</choose>
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM biz_group BG2
|
||||
WHERE BG2.pid = BG.biz_group_id
|
||||
AND BG2.state != 2
|
||||
) AS hasChildren
|
||||
FROM biz_group BG
|
||||
INNER JOIN group_tree gt ON BG.pid = gt.biz_group_id
|
||||
WHERE BG.state != 2
|
||||
)
|
||||
SELECT *
|
||||
FROM group_tree;
|
||||
</select>
|
||||
|
||||
<select id="selectBizGroupDownwardIds" resultType="list">
|
||||
WITH RECURSIVE group_tree AS (
|
||||
SELECT
|
||||
BG1.biz_group_id,
|
||||
1 AS depth
|
||||
FROM biz_group BG1
|
||||
WHERE BG1.state != 2 AND BG1.biz_group_id = #{biz_group_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
BG2.biz_group_id,
|
||||
GT.depth + 1
|
||||
FROM biz_group BG2
|
||||
INNER JOIN group_tree GT ON BG2.pid = GT.biz_group_id
|
||||
WHERE BG2.state != 2 AND GT.depth < 10
|
||||
)
|
||||
SELECT biz_group_id
|
||||
FROM group_tree;
|
||||
</select>
|
||||
|
||||
<select id="selectBizGroupDownwardIdsByTerminalId" resultType="list">
|
||||
WITH RECURSIVE group_tree AS (
|
||||
SELECT
|
||||
BG1.biz_group_id,
|
||||
1 AS depth
|
||||
FROM biz_group BG1
|
||||
JOIN terminal_biz_group TBG ON TBG.biz_group_id = BG1.biz_group_id
|
||||
WHERE BG1.state != 2 AND TBG.terminal_id = #{terminal_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
BG2.biz_group_id,
|
||||
GT.depth + 1
|
||||
FROM biz_group BG2
|
||||
INNER JOIN group_tree GT ON BG2.pid = GT.biz_group_id
|
||||
WHERE BG2.state != 2 AND GT.depth < 10
|
||||
)
|
||||
SELECT biz_group_id
|
||||
FROM group_tree;
|
||||
</select>
|
||||
|
||||
<select id="selectBizGroupDownwardIdsByDeviceId" resultType="list">
|
||||
WITH RECURSIVE group_tree AS (
|
||||
SELECT
|
||||
BG1.biz_group_id,
|
||||
1 AS depth
|
||||
FROM biz_group BG1
|
||||
JOIN device_biz_group DBG ON DBG.biz_group_id = BG1.biz_group_id
|
||||
WHERE BG1.state != 2 AND DBG.device_id = #{device_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
BG2.biz_group_id,
|
||||
GT.depth + 1
|
||||
FROM biz_group BG2
|
||||
INNER JOIN group_tree GT ON BG2.pid = GT.biz_group_id
|
||||
WHERE BG2.state != 2 AND GT.depth < 10
|
||||
)
|
||||
SELECT biz_group_id
|
||||
FROM group_tree;
|
||||
</select>
|
||||
|
||||
<select id="selectBizGroupUpwardIds" resultType="list">
|
||||
WITH RECURSIVE parent_tree AS (
|
||||
SELECT
|
||||
BG1.biz_group_id,
|
||||
BG1.pid,
|
||||
1 AS depth
|
||||
FROM biz_group BG1
|
||||
WHERE BG1.state != 2 AND BG1.biz_group_id = #{biz_group_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
BG2.biz_group_id,
|
||||
BG2.pid,
|
||||
PT.depth + 1
|
||||
FROM biz_group BG2
|
||||
INNER JOIN parent_tree PT ON PT.pid = BG2.biz_group_id
|
||||
WHERE BG2.state != 2 AND PT.depth < 10
|
||||
)
|
||||
SELECT biz_group_id
|
||||
FROM parent_tree;
|
||||
</select>
|
||||
|
||||
<select id="selectBizGroupUpwardIdsByTerminalId" resultType="list">
|
||||
WITH RECURSIVE parent_tree AS (
|
||||
SELECT
|
||||
BG1.biz_group_id,
|
||||
BG1.pid,
|
||||
1 AS depth
|
||||
FROM biz_group BG1
|
||||
JOIN terminal_biz_group TBG ON TBG.biz_group_id = BG1.biz_group_id
|
||||
WHERE BG1.state != 2 AND TBG.terminal_id = #{terminal_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
BG2.biz_group_id,
|
||||
BG2.pid,
|
||||
PT.depth + 1
|
||||
FROM biz_group BG2
|
||||
INNER JOIN parent_tree PT ON PT.pid = BG2.biz_group_id
|
||||
WHERE BG2.state != 2 AND PT.depth < 10
|
||||
)
|
||||
SELECT biz_group_id
|
||||
FROM parent_tree;
|
||||
</select>
|
||||
|
||||
<select id="selectBizGroupUpwardIdsDeviceId" resultType="list">
|
||||
WITH RECURSIVE parent_tree AS (
|
||||
SELECT
|
||||
BG1.biz_group_id,
|
||||
BG1.pid,
|
||||
1 AS depth
|
||||
FROM biz_group BG1
|
||||
JOIN device_biz_group DBG ON DBG.biz_group_id = BG1.biz_group_id
|
||||
WHERE BG1.state != 2 AND DBG.device_id = #{device_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
BG2.biz_group_id,
|
||||
BG2.pid,
|
||||
PT.depth + 1
|
||||
FROM biz_group BG2
|
||||
INNER JOIN parent_tree PT ON PT.pid = BG2.biz_group_id
|
||||
WHERE BG2.state != 2 AND PT.depth < 10
|
||||
)
|
||||
SELECT biz_group_id
|
||||
FROM parent_tree;
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,276 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.DeviceMapper">
|
||||
|
||||
<!--
|
||||
<select id="selectDevice" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
D.device_id, T.terminal_id, BG.biz_group_id, BG.name AS biz_group_name, D.reg_time, D.name, T.uid1, T.type, D.manager_name, D.state
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM device AS D
|
||||
JOIN device_biz_group AS DBG ON DBG.device_id = D.device_id
|
||||
JOIN biz_group AS BG ON BG.biz_group_id = DBG.biz_group_id
|
||||
LEFT JOIN terminal AS T ON T.device_id = D.device_id
|
||||
WHERE D.state != 2 AND ( BG.biz_group_id = #{biz_group_id}
|
||||
<if test="is_group_access == false">
|
||||
OR BG.top_group_id = #{biz_group_id}
|
||||
</if>
|
||||
)
|
||||
<if test="name != null and name != ''">
|
||||
AND D.name = #{name}
|
||||
</if>
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(D.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(D.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="isCount == false and is_excel == false">
|
||||
ORDER BY D.device_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
-->
|
||||
<select id="selectDevice" resultType="map">
|
||||
<if test="is_group_access == false">
|
||||
WITH target_group AS (
|
||||
WITH RECURSIVE group_tree AS (
|
||||
SELECT
|
||||
BG1.biz_group_id,
|
||||
1 AS depth
|
||||
FROM biz_group BG1
|
||||
WHERE BG1.state != 2 AND BG1.biz_group_id = #{biz_group_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
BG2.biz_group_id,
|
||||
GT.depth + 1
|
||||
FROM biz_group BG2
|
||||
INNER JOIN group_tree GT ON BG2.pid = GT.biz_group_id
|
||||
WHERE BG2.state != 2 AND GT.depth < 10
|
||||
)
|
||||
SELECT biz_group_id
|
||||
FROM group_tree
|
||||
)
|
||||
</if>
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
D.device_id, T.terminal_id, BG.biz_group_id, BG.name AS biz_group_name, D.reg_time, D.name, T.uid1, T.type, D.manager_name, D.state, T.connect_time, T.disconnect_time
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM device AS D
|
||||
JOIN device_biz_group AS DBG ON DBG.device_id = D.device_id
|
||||
JOIN biz_group AS BG ON BG.biz_group_id = DBG.biz_group_id
|
||||
LEFT JOIN terminal AS T ON T.device_id = D.device_id
|
||||
WHERE D.state != 2 AND
|
||||
<choose>
|
||||
<when test="is_group_access == false">
|
||||
DBG.biz_group_id IN ( SELECT biz_group_id FROM target_group )
|
||||
</when>
|
||||
<otherwise>
|
||||
DBG.biz_group_id = #{biz_group_id}
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="name != null and name != ''">
|
||||
AND D.name = #{name}
|
||||
</if>
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(D.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(D.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="isCount == false and is_excel == false">
|
||||
ORDER BY D.device_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectDevice2" resultType="map">
|
||||
WITH RECURSIVE group_tree AS (
|
||||
SELECT
|
||||
biz_group_id,
|
||||
name,
|
||||
pid
|
||||
FROM biz_group
|
||||
WHERE biz_group_id = #{biz_group_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
bg.biz_group_id,
|
||||
bg.name,
|
||||
bg.pid
|
||||
FROM biz_group bg
|
||||
INNER JOIN group_tree gt ON bg.pid = gt.biz_group_id
|
||||
)
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
D.device_id, T.terminal_id, GT.biz_group_id, GT.name AS biz_group_name, D.reg_time, D.name, T.uid1, T.type, D.manager_name, D.state, T.connect_time, T.disconnect_time
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM device AS D
|
||||
JOIN device_biz_group AS DBG ON DBG.device_id = D.device_id
|
||||
JOIN group_tree GT ON DBG.biz_group_id = GT.biz_group_id
|
||||
LEFT JOIN terminal AS T ON T.device_id = D.device_id
|
||||
WHERE D.state != 2
|
||||
<if test="name != null and name != ''">
|
||||
AND D.name = #{name}
|
||||
</if>
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(D.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(D.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="isCount == false and is_excel == false">
|
||||
ORDER BY D.device_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceByError" resultType="map">
|
||||
WITH RECURSIVE group_tree AS (
|
||||
SELECT
|
||||
biz_group_id,
|
||||
name,
|
||||
pid
|
||||
FROM biz_group
|
||||
WHERE biz_group_id = #{biz_group_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
bg.biz_group_id,
|
||||
bg.name,
|
||||
bg.pid
|
||||
FROM biz_group bg
|
||||
INNER JOIN group_tree gt ON bg.pid = gt.biz_group_id
|
||||
)
|
||||
SELECT
|
||||
D.device_id, T.terminal_id, GT.biz_group_id, GT.name AS biz_group_name, D.reg_time, D.name, T.uid1, T.type, D.manager_name, D.state, T.connect_time, T.disconnect_time
|
||||
FROM device AS D
|
||||
JOIN device_biz_group AS DBG ON DBG.device_id = D.device_id
|
||||
JOIN group_tree GT ON DBG.biz_group_id = GT.biz_group_id
|
||||
LEFT JOIN terminal AS T ON T.device_id = D.device_id
|
||||
WHERE D.state != 2
|
||||
AND T.connect_time IS NOT NULL
|
||||
AND T.disconnect_time IS NOT NULL
|
||||
AND T.disconnect_time > T.connect_time
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceById" resultType="map">
|
||||
SELECT
|
||||
device_id, name
|
||||
FROM device
|
||||
WHERE state != 2 AND device_id = #{device_id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectExistDevice" resultType="map">
|
||||
SELECT
|
||||
device_id, name, uid1
|
||||
FROM device
|
||||
WHERE state != 2
|
||||
<if test="device_id != 0">
|
||||
AND device_id != #{device_id}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND name = #{name}
|
||||
</if>
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insertDevice"
|
||||
parameterType="map"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="device_id">
|
||||
INSERT INTO device
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
name, gid, state,
|
||||
<if test="manager_name != null and manager_name != ''">manager_name,</if>
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{name}, #{gid}, #{state},
|
||||
<if test="manager_name != null and manager_name != ''">#{manager_name},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateDevice">
|
||||
UPDATE device
|
||||
<set>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="uid1 != null and uid1 != ''">uid1 = #{uid1},</if>
|
||||
<if test="manager_name != null and manager_name != ''">manager_name = #{manager_name},</if>
|
||||
<if test="gid != null and gid != ''">gid = #{gid},</if>
|
||||
</set>
|
||||
WHERE device_id = #{device_id}
|
||||
</update>
|
||||
|
||||
<update id="updateDeviceTerminalTime">
|
||||
UPDATE terminal T
|
||||
JOIN device D ON D.device_id = T.device_id
|
||||
<set>
|
||||
T.connect_time = #{connect_time},
|
||||
T.disconnect_time = #{disconnect_time}
|
||||
</set>
|
||||
WHERE D.device_id = #{device_id}
|
||||
</update>
|
||||
|
||||
<update id="changeStateDevice">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
UPDATE device
|
||||
SET state = #{state}
|
||||
WHERE device_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<delete id="deleteDevice">
|
||||
<!--
|
||||
<if test="ids != null and ids.size > 0">
|
||||
DELETE FROM device
|
||||
WHERE device_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
-->
|
||||
DELETE FROM device
|
||||
WHERE device_id = #{device_id}
|
||||
</delete>
|
||||
|
||||
|
||||
<insert id="insertDeviceBizGroup">
|
||||
INSERT INTO device_biz_group
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
biz_group_id, device_id,
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{biz_group_id}, #{device_id},
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteDeviceBizGroup">
|
||||
DELETE FROM device_biz_group
|
||||
WHERE device_id = #{device_id} AND biz_group_id = #{biz_group_id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.ErrorHistoryMapper">
|
||||
|
||||
<select id="selectErrorHistory" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
EH.error_history_id, EH.reg_time, EH.uid1, EH.uid1_type, EH.slot
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM error_history EH
|
||||
WHERE 1=1
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(EH.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(EH.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="uid1 != null and uid1 != ''">
|
||||
AND EH.uid1 like CONCAT('%', #{uid1}, '%')
|
||||
</if>
|
||||
<if test="isCount == false and is_excel == false">
|
||||
ORDER BY EH.error_history_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectErrorHistoryByState" resultType="map">
|
||||
SELECT
|
||||
EH.error_history_id, EH.reg_time, EH.uid1, EH.uid1_type, EH.slot
|
||||
FROM error_history EH
|
||||
WHERE EH.state = #{state}
|
||||
</select>
|
||||
|
||||
<insert id="insertErrorHistory">
|
||||
INSERT INTO error_history
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
uid1, uid1_type, slot,
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{uid1}, #{uid1_type}, #{slot},
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,359 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.GoodsMapper">
|
||||
|
||||
<select id="selectGoods" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
G.goods_id, BG.biz_group_id, BG.name AS biz_group_name, G.reg_time, G.name, G.code, G.price, G.vendor, G.state
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM goods AS G
|
||||
JOIN biz_group AS BG ON BG.biz_group_id = G.biz_group_id
|
||||
WHERE G.state != 2 AND ( BG.biz_group_id = #{biz_group_id}
|
||||
<if test="is_group_access == false">
|
||||
OR BG.top_group_id = #{biz_group_id}
|
||||
</if>
|
||||
)
|
||||
<if test="code != null and code != ''">
|
||||
AND G.code = #{code}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND G.name = #{name}
|
||||
</if>
|
||||
<if test="state != 0">
|
||||
AND G.state = #{state}
|
||||
</if>
|
||||
<if test="vendor != null and vendor != ''">
|
||||
AND G.vendor = #{vendor}
|
||||
</if>
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(G.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(G.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="isCount == false and is_excel == false">
|
||||
ORDER BY G.goods_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectGoodsByBizGroupId" resultType="map">
|
||||
SELECT *
|
||||
FROM goods
|
||||
WHERE biz_group_id = #{biz_group_id}
|
||||
ORDER BY goods_id DESC
|
||||
</select>
|
||||
|
||||
<!--<select id="selectGoodsByDevice" resultType="map">
|
||||
WITH target_group AS (
|
||||
SELECT DBG.biz_group_id
|
||||
FROM device AS D
|
||||
JOIN device_biz_group AS DBG
|
||||
ON DBG.device_id = D.device_id
|
||||
WHERE D.device_id = #{device_id}
|
||||
)
|
||||
SELECT
|
||||
G.goods_id,
|
||||
BG.biz_group_id,
|
||||
BG.name AS biz_group_name,
|
||||
BG.biz_reg_num,
|
||||
G.reg_time,
|
||||
G.name,
|
||||
G.code,
|
||||
G.price,
|
||||
G.vendor,
|
||||
G.state
|
||||
FROM goods AS G
|
||||
JOIN biz_group AS BG
|
||||
ON BG.biz_group_id = G.biz_group_id
|
||||
WHERE G.state != 2 AND (
|
||||
BG.biz_group_id = (SELECT biz_group_id FROM target_group)
|
||||
<if test="is_group_access == false">
|
||||
OR BG.top_group_id = (SELECT biz_group_id FROM target_group)
|
||||
</if>
|
||||
)
|
||||
ORDER BY G.goods_id DESC;
|
||||
</select>-->
|
||||
<select id="selectGoodsByDevice" resultType="map">
|
||||
WITH target_group AS (
|
||||
WITH RECURSIVE parent_tree AS (
|
||||
SELECT
|
||||
BG1.biz_group_id,
|
||||
BG1.pid,
|
||||
1 AS depth
|
||||
FROM biz_group BG1
|
||||
JOIN device_biz_group DBG ON DBG.biz_group_id = BG1.biz_group_id
|
||||
WHERE BG1.state != 2 AND DBG.device_id = #{device_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
BG2.biz_group_id,
|
||||
BG2.pid,
|
||||
PT.depth + 1
|
||||
FROM biz_group BG2
|
||||
INNER JOIN parent_tree PT ON PT.pid = BG2.biz_group_id
|
||||
WHERE BG2.state != 2 AND PT.depth < 10
|
||||
)
|
||||
SELECT biz_group_id
|
||||
FROM parent_tree
|
||||
)
|
||||
SELECT
|
||||
G.goods_id, BG.biz_group_id, BG.name AS biz_group_name, BG.biz_reg_num, G.reg_time, G.name, G.code, G.price, G.vendor, G.state
|
||||
FROM goods G
|
||||
JOIN biz_group BG ON BG.biz_group_id = G.biz_group_id
|
||||
WHERE G.state != 2 AND BG.biz_group_id IN ( SELECT biz_group_id FROM target_group )
|
||||
ORDER BY G.goods_id DESC
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectExistGoods" resultType="map">
|
||||
SELECT goods_id
|
||||
FROM goods
|
||||
WHERE 1=1
|
||||
<if test="biz_group_id != 0">
|
||||
AND biz_group_id = #{biz_group_id}
|
||||
</if>
|
||||
AND ( false
|
||||
<if test="code != null and code != ''">
|
||||
OR code = #{code}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
OR name = #{name}
|
||||
</if>
|
||||
)
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectGoodsByUid1" resultType="map">
|
||||
SELECT
|
||||
G.goods_id,
|
||||
G.reg_time,
|
||||
G.code,
|
||||
G.name,
|
||||
G.state,
|
||||
G.gid,
|
||||
G.biz_group_id,
|
||||
G.price,
|
||||
DG.inventory,
|
||||
G.vendor,
|
||||
G.opt,
|
||||
DG.device_id,
|
||||
DG.slot,
|
||||
DG.price AS device_goods_price,
|
||||
DG.inventory AS device_goods_inventory
|
||||
FROM terminal AS T
|
||||
JOIN device AS D ON D.device_id = T.device_id
|
||||
JOIN device_goods AS DG ON DG.device_id = D.device_id
|
||||
JOIN goods AS G ON G.goods_id = DG.goods_id
|
||||
WHERE T.uid1 = #{uid1}
|
||||
AND T.type = #{uid1_type}
|
||||
AND DG.slot = #{slot}
|
||||
AND T.state != 2
|
||||
AND D.state != 2
|
||||
AND G.state != 2
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insertGoods" parameterType="map" useGeneratedKeys="true" keyProperty="terminal_id">
|
||||
INSERT INTO goods
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
biz_group_id, code, name, price, inventory, gid,
|
||||
<if test="vendor != null and vendor != ''">vendor,</if>
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{biz_group_id}, #{code}, #{name}, #{price}, #{inventory}, #{gid},
|
||||
<if test="vendor != null and vendor != ''">#{vendor},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateGoods">
|
||||
UPDATE goods
|
||||
<set>
|
||||
<if test="code != null and code != ''">code = #{code},</if>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="price != null">price = #{price},</if>
|
||||
<if test="inventory != null">inventory = #{inventory},</if>
|
||||
<if test="vendor != null and vendor != ''">vendor = #{vendor},</if>
|
||||
<if test="gid != 0">gid = #{gid},</if>
|
||||
</set>
|
||||
WHERE goods_id = #{goods_id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteGoods">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
DELETE FROM goods
|
||||
WHERE goods_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<select id="selectDeviceGoods" resultType="map">
|
||||
SELECT
|
||||
DG.device_id, DG.slot, G.goods_id, DG.idx, DG.inventory, G.reg_time, G.name, G.code, G.price, G.vendor, G.state, DG.inventory_max, DG.inventory_alarm
|
||||
FROM goods AS G
|
||||
JOIN device_goods AS DG ON DG.goods_id = G.goods_id
|
||||
WHERE G.state != 2 AND DG.device_id = #{device_id}
|
||||
ORDER BY DG.slot ASC
|
||||
</select>
|
||||
|
||||
<insert id="insertDeviceGoods">
|
||||
<if test="device_goods != null and device_goods.size > 0">
|
||||
INSERT INTO device_goods (
|
||||
device_id, slot, goods_id, price, inventory, idx, inventory_max, inventory_alarm
|
||||
) VALUES
|
||||
<foreach collection="device_goods" item="item" separator=",">
|
||||
(
|
||||
#{device_id}, #{item.slot}, #{item.goods_id}, #{item.price}, #{item.inventory}, #{item.idx}, #{item.inventory_max}, #{item.inventory_alarm}
|
||||
)
|
||||
</foreach>
|
||||
</if>
|
||||
</insert>
|
||||
|
||||
<update id="updateDeviceGoodsPlusInventory">
|
||||
UPDATE device_goods dg
|
||||
JOIN transactions t
|
||||
ON dg.device_id = t.device_id
|
||||
AND dg.slot = t.slot
|
||||
SET dg.inventory = dg.inventory + 1
|
||||
WHERE t.approval = #{approval}
|
||||
</update>
|
||||
|
||||
<update id="updateDeviceGoodsMinusInventory">
|
||||
UPDATE device_goods
|
||||
<set>
|
||||
inventory = inventory - 1
|
||||
</set>
|
||||
WHERE device_id = #{device_id} AND slot = #{slot}
|
||||
</update>
|
||||
|
||||
<update id="updateDeviceGoodsInventory">
|
||||
<choose>
|
||||
<when test="type == 'D4'">
|
||||
UPDATE device_goods dg
|
||||
JOIN transactions t
|
||||
ON dg.device_id = t.device_id
|
||||
AND dg.slot = t.slot
|
||||
SET dg.inventory = dg.inventory + 1
|
||||
WHERE t.approval = #{approval}
|
||||
</when>
|
||||
<otherwise>
|
||||
UPDATE device_goods
|
||||
<set>
|
||||
inventory = inventory - 1
|
||||
</set>
|
||||
WHERE device_id = #{device_id} AND slot = #{slot}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</update>
|
||||
|
||||
<delete id="deleteDeviceGoods">
|
||||
<if test="device_goods != null and device_goods.size > 0">
|
||||
DELETE FROM device_goods
|
||||
WHERE device_id = #{device_id} AND slot IN
|
||||
<foreach collection="device_goods" item="item" open="(" separator="," close=")">
|
||||
#{item.slot}
|
||||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
|
||||
<select id="selectGoodsTemplateByBizGroupId" resultType="map">
|
||||
SELECT
|
||||
GTE.goods_template_element_id,
|
||||
GTE.slot,
|
||||
GTE.goods_id,
|
||||
GTE.inventory,
|
||||
GTE.inventory_max,
|
||||
GTE.inventory_alarm,
|
||||
GTE.goods_template_id,
|
||||
GTE.idx,
|
||||
GT.reg_time AS template_reg_time,
|
||||
GT.name AS template_name,
|
||||
GT.opt AS template_opt,
|
||||
GT.inventory AS template_inventory,
|
||||
GT.inventory_max AS template_inventory_max,
|
||||
GT.inventory_alarm AS template_inventory_alarm
|
||||
FROM goods_template AS GT
|
||||
JOIN goods_template_element AS GTE ON GT.goods_template_id = GTE.goods_template_id
|
||||
WHERE GT.biz_group_id = #{biz_group_id}
|
||||
ORDER BY GT.goods_template_id, GTE.idx ASC
|
||||
</select>
|
||||
|
||||
<select id="selectGoodsTemplateById" resultType="map">
|
||||
SELECT
|
||||
GTE.goods_template_element_id,
|
||||
GTE.slot,
|
||||
GTE.goods_id,
|
||||
GTE.inventory,
|
||||
GTE.inventory_max,
|
||||
GTE.inventory_alarm,
|
||||
GTE.goods_template_id,
|
||||
GTE.idx,
|
||||
GT.reg_time AS template_reg_time,
|
||||
GT.name AS template_name,
|
||||
GT.opt AS template_opt,
|
||||
GT.biz_group_id,
|
||||
GT.inventory AS template_inventory,
|
||||
GT.inventory_max AS template_inventory_max,
|
||||
GT.inventory_alarm AS template_inventory_alarm
|
||||
FROM goods_template AS GT
|
||||
JOIN goods_template_element AS GTE ON GT.goods_template_id = GTE.goods_template_id
|
||||
WHERE GT.goods_template_id = #{goods_template_id}
|
||||
ORDER BY GT.goods_template_id, GTE.idx ASC
|
||||
</select>
|
||||
|
||||
<select id="selectGoodsTemplateCount" resultType="long">
|
||||
SELECT COUNT(*)
|
||||
FROM goods_template
|
||||
WHERE biz_group_id = #{biz_group_id}
|
||||
</select>
|
||||
|
||||
<insert id="insertGoodsTemplate" parameterType="map" useGeneratedKeys="true" keyProperty="goods_template_id">
|
||||
INSERT INTO goods_template (
|
||||
biz_group_id, name, inventory, inventory_max, inventory_alarm
|
||||
) VALUES (
|
||||
#{biz_group_id}, #{name}, #{inventory}, #{inventory_max}, #{inventory_alarm}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertGoodsTemplateElements">
|
||||
<if test="goods_template_elements != null and goods_template_elements.size > 0">
|
||||
INSERT INTO goods_template_element (
|
||||
slot, goods_id, inventory, goods_template_id,idx,inventory_max,inventory_alarm
|
||||
) VALUES
|
||||
<foreach collection="goods_template_elements" item="item" separator=",">
|
||||
(
|
||||
#{item.slot}, #{item.goods_id}, #{item.inventory}, #{goods_template_id}, #{item.idx}, #{item.inventory_max}, #{item.inventory_alarm}
|
||||
)
|
||||
</foreach>
|
||||
</if>
|
||||
</insert>
|
||||
|
||||
<update id="updateGoodsTemplate">
|
||||
UPDATE goods_template
|
||||
<set>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
</set>
|
||||
WHERE goods_template_id = #{goods_template_id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteGoodsTemplateElements">
|
||||
DELETE FROM goods_template_element
|
||||
WHERE goods_template_id = #{goods_template_id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteGoodsTemplate">
|
||||
DELETE FROM goods_template
|
||||
WHERE goods_template_id = #{goods_template_id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,212 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.LocationMapper">
|
||||
|
||||
<select id="selectLocation" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
BG.location_id, BG.reg_time, BG.name, BG.description, BG.address
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM location AS BG
|
||||
WHERE state != 2
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND name like CONCAT(#{name}, '%')
|
||||
</if>
|
||||
<if test="description != null and description != ''">
|
||||
AND description like CONCAT(#{description}, '%')
|
||||
</if>
|
||||
<if test="address != null and address != ''">
|
||||
AND address like CONCAT(#{address}, '%')
|
||||
</if>
|
||||
<if test="isCount == false">
|
||||
ORDER BY location_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--<insert id="insertLocation">-->
|
||||
<!--<insert id="insertLocation" parameterType="map">
|
||||
<selectKey keyProperty="location_id" resultType="long" order="AFTER">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
-->
|
||||
<insert id="insertLocation"
|
||||
parameterType="map"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="location_id"
|
||||
>
|
||||
INSERT INTO location
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
name, gid,
|
||||
<if test="description != null and description != ''">description,</if>
|
||||
<if test="address != null and address != ''">address,</if>
|
||||
<if test="pid != 0">pid,</if>
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{name}, #{gid},
|
||||
<if test="description != null and description != ''">#{description},</if>
|
||||
<if test="address != null and address != ''">#{address},</if>
|
||||
<if test="pid != 0">#{pid},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateLocation">
|
||||
UPDATE location
|
||||
<set>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="description != null and description != ''">description = #{description},</if>
|
||||
<if test="address != null and address != ''">address = #{address},</if>
|
||||
<if test="pid != 0">pid = #{pid},</if>
|
||||
</set>
|
||||
WHERE location_id = #{location_id}
|
||||
</update>
|
||||
|
||||
<update id="changeStateLocation">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
UPDATE location
|
||||
SET state = #{state}
|
||||
WHERE location_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<update id="changePidLocation">
|
||||
UPDATE location
|
||||
<choose>
|
||||
<when test="new_pid != null">
|
||||
SET pid = #{new_pid}
|
||||
</when>
|
||||
<otherwise>
|
||||
SET pid = NULL
|
||||
</otherwise>
|
||||
</choose>
|
||||
WHERE pid IN
|
||||
<foreach collection="pids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="changeState">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
UPDATE location
|
||||
SET state=#{state}
|
||||
WHERE location_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<select id="selectLocationParentTree" resultType="map">
|
||||
WITH RECURSIVE group_start AS (
|
||||
SELECT location_id
|
||||
FROM location
|
||||
WHERE location_id IN
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
),
|
||||
group_path AS (
|
||||
SELECT
|
||||
g.location_id,
|
||||
g.name,
|
||||
g.description,
|
||||
g.pid,
|
||||
g.location_id AS start_location_id
|
||||
FROM
|
||||
location g
|
||||
INNER JOIN
|
||||
group_start gs ON g.location_id = gs.location_id
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
g.location_id,
|
||||
g.name,
|
||||
g.description,
|
||||
g.pid,
|
||||
gp.start_location_id
|
||||
FROM
|
||||
location g
|
||||
INNER JOIN
|
||||
group_path gp ON gp.pid = g.location_id
|
||||
)
|
||||
SELECT DISTINCT
|
||||
location_id,
|
||||
name,
|
||||
description,
|
||||
pid
|
||||
FROM
|
||||
group_path
|
||||
ORDER BY pid ASC, location_id ASC;
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectRootNode" resultType="map">
|
||||
SELECT location_id, reg_time, name, description, address
|
||||
FROM location
|
||||
WHERE state != 2
|
||||
<if test="(name == null || name == '') and (description == null || description == '')">
|
||||
AND pid is null
|
||||
</if>
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND name like CONCAT(#{name}, '%')
|
||||
</if>
|
||||
<if test="description != null and description != ''">
|
||||
AND description like CONCAT(#{description}, '%')
|
||||
</if>
|
||||
<if test="address != null and address != ''">
|
||||
AND address like CONCAT(#{address}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectLocationChildTree" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="queryAll == true">
|
||||
location_id, reg_time, name, description, address
|
||||
</when>
|
||||
<otherwise>
|
||||
location_id, name, description
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM location
|
||||
WHERE state != 2 AND pid = #{pid}
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND name like CONCAT(#{name}, '%')
|
||||
</if>
|
||||
<if test="description != null and description != ''">
|
||||
AND description like CONCAT(#{description}, '%')
|
||||
</if>
|
||||
<if test="address != null and address != ''">
|
||||
AND address like CONCAT(#{address}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.NoticeMapper">
|
||||
|
||||
<select id="selectDetailNotice" resultType="map">
|
||||
SELECT notice_id, title, content
|
||||
FROM notice
|
||||
WHERE notice_id = #{notice_id}
|
||||
</select>
|
||||
|
||||
<select id="selectNotice" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
RB.notice_id, RB.reg_time, RB.title, '임시' as submitter
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM notice AS RB
|
||||
WHERE state != 2
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="title != null and title != ''">
|
||||
AND title like CONCAT(#{title}, '%')
|
||||
</if>
|
||||
<if test="content != null and content != ''">
|
||||
AND content like CONCAT(#{content}, '%')
|
||||
</if>
|
||||
<if test="isCount == false">
|
||||
ORDER BY notice_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertNotice">
|
||||
INSERT INTO notice
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
title, content, gid,
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{title}, #{content}, #{gid},
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateNotice">
|
||||
UPDATE notice
|
||||
<set>
|
||||
<if test="title != null and title != ''">title = #{title},</if>
|
||||
<if test="content != null and content != ''">content = #{content},</if>
|
||||
</set>
|
||||
WHERE notice_id = #{notice_id}
|
||||
</update>
|
||||
|
||||
<update id="changeStateNotice">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
UPDATE notice
|
||||
SET state = #{state}
|
||||
WHERE notice_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
<!--
|
||||
<delete id="deleteNotice">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
DELETE FROM resource_board
|
||||
WHERE resource_board_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.OperatingHistoryMapper">
|
||||
|
||||
<select id="selectOperatingHistory" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
OH.operating_history_id, OH.reg_time, OH.type, OH.action, A.gid, A.user_id, A.nick_name
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM operating_history OH
|
||||
JOIN account A ON A.gid = OH.gid
|
||||
WHERE 1=1
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(OH.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(OH.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="action != null and action != ''">
|
||||
AND OH.action like CONCAT('%', #{action}, '%')
|
||||
</if>
|
||||
<if test="isCount == false and is_excel == false">
|
||||
ORDER BY OH.operating_history_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertOperatingHistory">
|
||||
INSERT INTO operating_history
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
type, action, gid,
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{type}, #{action}, #{gid},
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,174 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.handong.smartservice.mapper.OrdersMapper">
|
||||
|
||||
<sql id="ordersWhere">
|
||||
<where>
|
||||
AND o.state != 2
|
||||
<if test="param.order_id != null and param.order_id != ''">
|
||||
AND o.order_id = #{param.order_id}
|
||||
</if>
|
||||
|
||||
<if test="param.biz_group_name != null and param.biz_group_name != ''">
|
||||
AND b.name LIKE CONCAT('%', #{param.biz_group_name}, '%')
|
||||
</if>
|
||||
|
||||
<if test="param.name != null and param.name != ''">
|
||||
AND CONCAT(a.last_name, a.first_name)
|
||||
LIKE CONCAT('%', #{param.name}, '%')
|
||||
</if>
|
||||
|
||||
<if test="param.date_start != null and param.date_start != ''">
|
||||
AND o.reg_time >= #{param.date_start}
|
||||
</if>
|
||||
|
||||
<if test="param.date_end != null and param.date_end != ''">
|
||||
AND o.reg_time <= #{param.date_end}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="selectOrders" parameterType="map" resultType="map">
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
SELECT
|
||||
o.*,
|
||||
CONCAT(a.last_name, a.first_name) AS submitter,
|
||||
b.name AS biz_group_name
|
||||
FROM orders o
|
||||
LEFT JOIN account a ON o.gid = a.gid
|
||||
LEFT JOIN biz_group b ON o.biz_group_id = b.biz_group_id
|
||||
<include refid="ordersWhere"/>
|
||||
ORDER BY o.order_id DESC
|
||||
LIMIT #{param.limit} OFFSET #{param.offset}
|
||||
</when>
|
||||
<otherwise>
|
||||
SELECT COUNT(*)
|
||||
FROM orders o
|
||||
LEFT JOIN account a ON o.gid = a.gid
|
||||
LEFT JOIN biz_group b ON o.biz_group_id = b.biz_group_id
|
||||
<include refid="ordersWhere"/>
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<insert id="insertOrders"
|
||||
parameterType="map"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="order_id">
|
||||
INSERT INTO orders
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
biz_group_id,
|
||||
<if test="state != null and state != ''">state,</if>
|
||||
<if test="is_doc_accept != null">is_doc_accept,</if>
|
||||
<if test="is_tid != null">is_tid,</if>
|
||||
<if test="is_card != null">is_card,</if>
|
||||
<if test="is_samchip != null">is_samchip,</if>
|
||||
<if test="is_comm_open != null">is_comm_open,</if>
|
||||
<if test="is_shipping != null">is_shipping,</if>
|
||||
<if test="is_tested != null">is_tested,</if>
|
||||
<if test="is_parcel != null">is_parcel,</if>
|
||||
<if test="order_time != null and order_time != ''">order_time,</if>
|
||||
<if test="goods_list_id != null and goods_list_id != ''">goods_list_id,</if>
|
||||
<if test="delivery_address != null and delivery_address != ''">delivery_address,</if>
|
||||
<if test="delivery_recv_name != null and delivery_recv_name != ''">delivery_recv_name,</if>
|
||||
<if test="delivery_recv_phone != null and delivery_recv_phone != ''">delivery_recv_phone,</if>
|
||||
<if test="delivery_invoice_no != null and delivery_invoice_no != ''">delivery_invoice_no,</if>
|
||||
<if test="delivery_company != null and delivery_company != ''">delivery_company,</if>
|
||||
<if test="delivery_req_time != null and delivery_req_time != ''">delivery_req_time,</if>
|
||||
<if test="gid != null and gid != ''">gid</if>
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{biz_group_id},
|
||||
<if test="state != null and state != ''">#{state},</if>
|
||||
<if test="is_doc_accept != null">#{is_doc_accept},</if>
|
||||
<if test="is_tid != null">#{is_tid},</if>
|
||||
<if test="is_card != null">#{is_card},</if>
|
||||
<if test="is_samchip != null">#{is_samchip},</if>
|
||||
<if test="is_comm_open != null">#{is_comm_open},</if>
|
||||
<if test="is_shipping != null">#{is_shipping},</if>
|
||||
<if test="is_tested != null">#{is_tested},</if>
|
||||
<if test="is_parcel != null">#{is_parcel},</if>
|
||||
<if test="order_time != null and order_time != ''">#{order_time},</if>
|
||||
<if test="goods_list_id != null and goods_list_id != ''">#{goods_list_id},</if>
|
||||
<if test="delivery_address != null and delivery_address != ''">#{delivery_address},</if>
|
||||
<if test="delivery_recv_name != null and delivery_recv_name != ''">#{delivery_recv_name},</if>
|
||||
<if test="delivery_recv_phone != null and delivery_recv_phone != ''">#{delivery_recv_phone},</if>
|
||||
<if test="delivery_invoice_no != null and delivery_invoice_no != ''">#{delivery_invoice_no},</if>
|
||||
<if test="delivery_company != null and delivery_company != ''">#{delivery_company},</if>
|
||||
<if test="delivery_req_time != null and delivery_req_time != ''">#{delivery_req_time},</if>
|
||||
<if test="gid != null and gid != ''">#{gid}</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateOrders" parameterType="map">
|
||||
UPDATE orders
|
||||
<set>
|
||||
<if test="biz_group_id != null and biz_group_id != ''">biz_group_id = #{biz_group_id},</if>
|
||||
<if test="state != null and state != ''">state = #{state},</if>
|
||||
<if test="is_doc_accept != null">is_doc_accept = #{is_doc_accept},</if>
|
||||
<if test="is_tid != null">is_tid = #{is_tid},</if>
|
||||
<if test="is_card != null">is_card = #{is_card},</if>
|
||||
<if test="is_samchip != null">is_samchip = #{is_samchip},</if>
|
||||
<if test="is_comm_open != null">is_comm_open = #{is_comm_open},</if>
|
||||
<if test="is_shipping != null">is_shipping = #{is_shipping},</if>
|
||||
<if test="is_tested != null">is_tested = #{is_tested},</if>
|
||||
<if test="is_parcel != null">is_parcel = #{is_parcel},</if>
|
||||
<if test="goods_list_id != null and goods_list_id != ''">goods_list_id = #{goods_list_id},</if>
|
||||
<if test="delivery_address != null and delivery_address != ''">delivery_address = #{delivery_address},</if>
|
||||
<if test="delivery_recv_name != null and delivery_recv_name != ''">delivery_recv_name = #{delivery_recv_name},</if>
|
||||
<if test="delivery_recv_phone != null and delivery_recv_phone != ''">delivery_recv_phone = #{delivery_recv_phone},</if>
|
||||
<if test="delivery_invoice_no != null and delivery_invoice_no != ''">delivery_invoice_no = #{delivery_invoice_no},</if>
|
||||
<if test="delivery_company != null and delivery_company != ''">delivery_company = #{delivery_company},</if>
|
||||
<!-- <if test="delivery_req_time != null and delivery_req_time != ''">delivery_req_time = #{delivery_req_time},</if> -->
|
||||
</set>
|
||||
WHERE order_id = #{order_id}
|
||||
</update>
|
||||
|
||||
<update id="changeStateOrders" parameterType="map">
|
||||
UPDATE orders
|
||||
SET state = #{state}
|
||||
WHERE order_id = #{order_id}
|
||||
</update>
|
||||
|
||||
<update id="updateSingleOrdersField">
|
||||
UPDATE orders
|
||||
SET ${statusKey} = #{statusValue}
|
||||
WHERE order_id = #{order_id}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="selectOrderDetail" resultType="map">
|
||||
SELECT
|
||||
o.*,
|
||||
CONCAT(a.last_name, a.first_name) AS submitter,
|
||||
|
||||
b.biz_group_id AS bg_biz_group_id,
|
||||
b.name AS bg_name,
|
||||
b.gid AS bg_gid,
|
||||
b.reg_time AS bg_reg_time,
|
||||
b.state AS bg_state,
|
||||
b.description AS bg_description,
|
||||
b.pid AS bg_pid,
|
||||
b.biz_reg_num AS bg_biz_reg_num,
|
||||
b.ceo AS bg_ceo,
|
||||
b.code1 AS bg_code1,
|
||||
b.code2 AS bg_code2,
|
||||
b.phone AS bg_phone,
|
||||
b.email AS bg_email,
|
||||
b.address AS bg_address,
|
||||
b.opt AS bg_opt,
|
||||
|
||||
g.*
|
||||
|
||||
FROM orders o
|
||||
LEFT JOIN account a ON o.gid = a.gid
|
||||
LEFT JOIN biz_group b ON o.biz_group_id = b.biz_group_id
|
||||
LEFT JOIN goods_list g ON o.goods_list_id = g.goods_list_id
|
||||
WHERE o.order_id = #{order_id}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.ResourceBoardMapper">
|
||||
|
||||
<select id="selectDetailResourceBoard" resultType="map">
|
||||
SELECT resource_board_id, title, content
|
||||
FROM resource_board
|
||||
WHERE resource_board_id = #{resource_board_id}
|
||||
</select>
|
||||
|
||||
<select id="selectResourceBoard" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
RB.resource_board_id, RB.reg_time, RB.title, '임시' as submitter
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM resource_board AS RB
|
||||
WHERE state != 2
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="title != null and title != ''">
|
||||
AND title like CONCAT(#{title}, '%')
|
||||
</if>
|
||||
<if test="content != null and content != ''">
|
||||
AND content like CONCAT(#{content}, '%')
|
||||
</if>
|
||||
<if test="isCount == false">
|
||||
ORDER BY resource_board_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertResourceBoard">
|
||||
INSERT INTO resource_board
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
title, content, gid,
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{title}, #{content}, #{gid},
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateResourceBoard">
|
||||
UPDATE resource_board
|
||||
<set>
|
||||
<if test="title != null and title != ''">title = #{title},</if>
|
||||
<if test="content != null and content != ''">content = #{content},</if>
|
||||
</set>
|
||||
WHERE resource_board_id = #{resource_board_id}
|
||||
</update>
|
||||
|
||||
<update id="changeStateResourceBoard">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
UPDATE resource_board
|
||||
SET state = #{state}
|
||||
WHERE resource_board_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
<!--
|
||||
<delete id="deleteResourceBoard">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
DELETE FROM resource_board
|
||||
WHERE resource_board_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,200 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.TerminalMapper">
|
||||
|
||||
<select id="selectTerminal" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
T.terminal_id, BG.biz_group_id, BG.name AS biz_group_name, T.reg_time, T.name, T.uid1, T.type, T.manager_name, T.state
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM terminal AS T
|
||||
JOIN terminal_biz_group AS TBG ON TBG.terminal_id = T.terminal_id
|
||||
JOIN biz_group AS BG ON BG.biz_group_id = TBG.biz_group_id
|
||||
WHERE T.state != 2 AND ( BG.biz_group_id = #{biz_group_id}
|
||||
<if test="is_group_access == false">
|
||||
OR BG.top_group_id = #{biz_group_id}
|
||||
</if>
|
||||
)
|
||||
<if test="name != null and name != ''">
|
||||
AND T.name = #{name}
|
||||
</if>
|
||||
<if test="state != 0">
|
||||
AND T.state = #{state}
|
||||
</if>
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(T.reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(T.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="isCount == false and is_excel == false">
|
||||
ORDER BY T.terminal_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectTerminalById" resultType="map">
|
||||
SELECT T.terminal_id, T.device_id, T.reg_time, T.name, T.uid1, T.type, T.manager_name, T.state
|
||||
FROM terminal AS T
|
||||
WHERE T.terminal_id = #{terminal_id} LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectTerminalByDeviceId" resultType="map">
|
||||
SELECT
|
||||
terminal_id, device_id, name, uid1
|
||||
FROM terminal
|
||||
WHERE state != 2 AND device_id = #{device_id}
|
||||
ORDER BY terminal_id DESC LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectTerminal3" resultType="map">
|
||||
SELECT
|
||||
terminal_id, device_id, name, uid1, type
|
||||
FROM terminal
|
||||
WHERE state != 2 AND uid1 = #{uid1} AND type = #{type}
|
||||
ORDER BY terminal_id DESC LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectExistTerminal" resultType="map">
|
||||
SELECT
|
||||
terminal_id
|
||||
FROM terminal
|
||||
WHERE state != 2
|
||||
AND ( false
|
||||
<if test="name != null and name != ''">
|
||||
OR name = #{name}
|
||||
</if>
|
||||
<if test="uid1 != null and uid1 != ''">
|
||||
OR uid1 = #{uid1}
|
||||
</if>
|
||||
)
|
||||
<if test="type != 0">
|
||||
AND type = #{type}
|
||||
</if>
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<insert id="insertTerminal" parameterType="map" useGeneratedKeys="true" keyProperty="terminal_id">
|
||||
INSERT INTO terminal
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
name, uid1, gid,
|
||||
<if test="state != null and state != 0">state,</if>
|
||||
<if test="type != null and type != 0">type,</if>
|
||||
<if test="manager_name != null and manager_name != ''">manager_name,</if>
|
||||
<if test="device_id != null and device_id != 0">device_id,</if>
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{name}, #{uid1}, #{gid},
|
||||
<if test="state != null and state != 0">#{state},</if>
|
||||
<if test="type != null and type != 0">#{type},</if>
|
||||
<if test="manager_name != null and manager_name != ''">#{manager_name},</if>
|
||||
<if test="device_id != null and device_id != 0">#{device_id},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateTerminal">
|
||||
UPDATE terminal
|
||||
<set>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="uid1 != null and uid1 != ''">uid1 = #{uid1},</if>
|
||||
<if test="type != 0">type = #{type},</if>
|
||||
<if test="manager_name != null and manager_name != ''">manager_name = #{manager_name},</if>
|
||||
<if test="gid != 0">gid = #{gid},</if>
|
||||
</set>
|
||||
WHERE terminal_id = #{terminal_id}
|
||||
</update>
|
||||
|
||||
<update id="changeStateDeviceTerminal">
|
||||
UPDATE terminal
|
||||
SET state = #{state}
|
||||
WHERE terminal_id = (
|
||||
SELECT terminal_id
|
||||
FROM device
|
||||
WHERE device_id = #{device_id}
|
||||
)
|
||||
</update>
|
||||
|
||||
<update id="changeStateTerminal">
|
||||
UPDATE terminal
|
||||
SET state = #{state}
|
||||
WHERE terminal_id = #{terminal_id}
|
||||
</update>
|
||||
|
||||
<update id="changeStateTerminals">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
UPDATE terminal
|
||||
SET state = #{state}
|
||||
WHERE terminal_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<delete id="deleteTerminal">
|
||||
<!--
|
||||
<if test="ids != null and ids.size > 0">
|
||||
DELETE FROM terminal
|
||||
WHERE terminal_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
-->
|
||||
DELETE FROM terminal
|
||||
WHERE terminal_id = #{terminal_id}
|
||||
</delete>
|
||||
|
||||
|
||||
<update id="updateTerminalChangeDevice">
|
||||
UPDATE terminal
|
||||
<set>
|
||||
device_id = #{device_id}, state = #{state}, name = #{name}
|
||||
</set>
|
||||
WHERE terminal_id = #{terminal_id}
|
||||
</update>
|
||||
|
||||
<update id="updateTerminalRemoveDevice">
|
||||
UPDATE terminal
|
||||
<set>
|
||||
device_id = NULL, state = 5
|
||||
</set>
|
||||
WHERE device_id = #{device_id}
|
||||
</update>
|
||||
|
||||
<insert id="insertTerminalBizGroup">
|
||||
INSERT INTO terminal_biz_group
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
biz_group_id, terminal_id,
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{biz_group_id}, #{terminal_id},
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteTerminalBizGroup">
|
||||
DELETE FROM terminal_biz_group
|
||||
WHERE terminal_id = #{terminal_id} AND biz_group_id = #{biz_group_id}
|
||||
</delete>
|
||||
|
||||
<update id="terminalState">
|
||||
UPDATE terminal
|
||||
<set>
|
||||
<if test="state == 1">
|
||||
connect_time = NOW(),
|
||||
</if>
|
||||
<if test="state == 2">
|
||||
disconnect_time = NOW(),
|
||||
</if>
|
||||
</set>
|
||||
WHERE uid1 = #{uid1} AND type = #{type}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,353 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.TransactionMapper">
|
||||
|
||||
<!--
|
||||
<select id="selectTransaction" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
T.reg_time, T.order_time, T.amount, T.type, T.approval, T.uid1, T.pay_name, T.pay_vendor, T.slot, T.code, T.goods_name, T.pay_unique_num, T.order_time
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM transactions AS T
|
||||
JOIN terminal T2 ON T.uid1 = T2.uid1 AND T.uid1_type = T2.type
|
||||
JOIN terminal_biz_group TBG ON TBG.terminal_id = T2.terminal_id
|
||||
JOIN biz_group AS BG ON BG.biz_group_id = TBG.biz_group_id
|
||||
WHERE ( TBG.biz_group_id = #{biz_group_id}
|
||||
<if test="is_group_access == false">
|
||||
OR BG.top_group_id = #{biz_group_id}
|
||||
</if>
|
||||
)
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(T.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="uid1 != null and uid1 != ''">
|
||||
AND T.uid1 = #{uid1}
|
||||
</if>
|
||||
<if test="isCount == false">
|
||||
ORDER BY T.transaction_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
-->
|
||||
<select id="selectTransaction" resultType="map">
|
||||
<if test="is_group_access == false">
|
||||
WITH target_group AS (
|
||||
WITH RECURSIVE group_tree AS (
|
||||
SELECT
|
||||
BG1.biz_group_id,
|
||||
1 AS depth
|
||||
FROM biz_group BG1
|
||||
WHERE BG1.state != 2 AND BG1.biz_group_id = #{biz_group_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
BG2.biz_group_id,
|
||||
GT.depth + 1
|
||||
FROM biz_group BG2
|
||||
INNER JOIN group_tree GT ON BG2.pid = GT.biz_group_id
|
||||
WHERE BG2.state != 2 AND GT.depth < 10
|
||||
)
|
||||
SELECT biz_group_id
|
||||
FROM group_tree
|
||||
)
|
||||
</if>
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
T.reg_time, T.order_time, T.amount, T.type, T.approval, T.uid1, T.pay_name, T.pay_vendor, T.slot, T.code, T.goods_name, T.pay_unique_num, T.order_time
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM transactions AS T
|
||||
WHERE
|
||||
<choose>
|
||||
<when test="is_group_access == false">
|
||||
T.biz_group_id IN ( SELECT biz_group_id FROM target_group )
|
||||
</when>
|
||||
<otherwise>
|
||||
T.biz_group_id = #{biz_group_id}
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="date_start != null and date_start != ''">AND #{date_start} <= DATE(T.reg_time)</if>
|
||||
<if test="date_end != null and date_end != ''">AND DATE(T.reg_time) <= #{date_end}</if>
|
||||
<if test="uid1 != null and uid1 != ''">AND T.uid1 = #{uid1}</if>
|
||||
<if test="uid1_type != null and uid1_type != 0">AND T.uid1_type = #{uid1_type}</if>
|
||||
<if test="type != null and type != ''">AND T.type = #{type}</if>
|
||||
<if test="amount != null and amount != 0">AND T.amount = #{amount}</if>
|
||||
<if test="approval != null and approval != ''">AND T.approval = #{approval}</if>
|
||||
<if test="slot != null and slot != ''">AND T.slot = #{slot}</if>
|
||||
<if test="code != null and code != ''">AND T.code = #{code}</if>
|
||||
<if test="goods_name != null and goods_name != ''">AND T.goods_name = #{goods_name}</if>
|
||||
<if test="pay_vendor != null and pay_vendor != ''">AND T.pay_vendor = #{pay_vendor}</if>
|
||||
<if test="isCount == false and is_excel == false">
|
||||
ORDER BY T.transaction_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectTransactionBizGroup0" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
T.reg_time, T.order_time, T.amount, T.type, T.approval, T.uid1, T.pay_name, T.pay_vendor, T.slot, T.code, T.goods_name, T.pay_unique_num, T.order_time
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM transactions AS T
|
||||
WHERE biz_group_id = 0
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(T.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="date_start != null and date_start != ''">AND #{date_start} <= DATE(T.reg_time)</if>
|
||||
<if test="date_end != null and date_end != ''">AND DATE(T.reg_time) <= #{date_end}</if>
|
||||
<if test="uid1 != null and uid1 != ''">AND T.uid1 = #{uid1}</if>
|
||||
<if test="uid1_type != null and uid1_type != 0">AND T.uid1_type = #{uid1_type}</if>
|
||||
<if test="type != null and type != ''">AND T.type = #{type}</if>
|
||||
<if test="amount != null and amount != 0">AND T.amount = #{amount}</if>
|
||||
<if test="approval != null and approval != ''">AND T.approval = #{approval}</if>
|
||||
<if test="slot != null and slot != ''">AND T.slot = #{slot}</if>
|
||||
<if test="code != null and code != ''">AND T.code = #{code}</if>
|
||||
<if test="goods_name != null and goods_name != ''">AND T.goods_name = #{goods_name}</if>
|
||||
<if test="pay_vendor != null and pay_vendor != ''">AND T.pay_vendor = #{pay_vendor}</if>
|
||||
<if test="isCount == false and is_excel == false">
|
||||
ORDER BY T.transaction_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--
|
||||
<select id="selectTransaction3" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
DATE_FORMAT(STR_TO_DATE(T.order_time, '%y%m%d%H%i%s'), '%Y-%m-%d') AS date,
|
||||
D.name AS device_name,
|
||||
TER.uid1,
|
||||
|
||||
SUM(CASE WHEN T.type = 'D1' THEN 1 ELSE 0 END) AS card_count,
|
||||
SUM(CASE WHEN T.type = 'D1' THEN T.amount ELSE 0 END) AS card_amount,
|
||||
SUM(CASE WHEN T.type = 'I1' THEN 1 ELSE 0 END) AS cash_count,
|
||||
SUM(CASE WHEN T.type = 'I1' THEN T.amount ELSE 0 END) AS cash_amount,
|
||||
SUM(CASE WHEN T.type = 'TM1' THEN 1 ELSE 0 END) AS tmoney_count,
|
||||
SUM(CASE WHEN T.type = 'TM1' THEN T.amount ELSE 0 END) AS tmoney_amount,
|
||||
SUM(CASE WHEN T.type = 'EB1' THEN 1 ELSE 0 END) AS cashb_count,
|
||||
SUM(CASE WHEN T.type = 'EB1' THEN T.amount ELSE 0 END) AS cashb_amount,
|
||||
SUM(T.amount) AS total
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM transactions AS T
|
||||
JOIN device D ON T.device_id = D.device_id
|
||||
JOIN terminal TER ON TER.device_id = D.device_id
|
||||
JOIN device_biz_group DBG ON DBG.device_id = D.device_id
|
||||
JOIN biz_group AS BG ON BG.biz_group_id = DBG.biz_group_id
|
||||
WHERE ( DBG.biz_group_id = #{biz_group_id}
|
||||
<if test="is_group_access == false">
|
||||
OR BG.top_group_id = #{biz_group_id}
|
||||
</if>
|
||||
)
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(T.reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="uid1 != null and uid1 != ''">
|
||||
AND TER.uid1 = #{uid1}
|
||||
</if>
|
||||
GROUP BY DATE_FORMAT(STR_TO_DATE(T.order_time, '%y%m%d%H%i%s'), '%Y-%m-%d'), D.name, TER.uid1
|
||||
<if test="isCount == false">
|
||||
ORDER BY date, D.name;
|
||||
</if>
|
||||
</select>
|
||||
-->
|
||||
<select id="selectTransaction3" resultType="map">
|
||||
<if test="is_group_access == false">
|
||||
WITH target_group AS (
|
||||
WITH RECURSIVE group_tree AS (
|
||||
SELECT
|
||||
BG1.biz_group_id,
|
||||
1 AS depth
|
||||
FROM biz_group BG1
|
||||
WHERE BG1.state != 2 AND BG1.biz_group_id = #{biz_group_id}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
BG2.biz_group_id,
|
||||
GT.depth + 1
|
||||
FROM biz_group BG2
|
||||
INNER JOIN group_tree GT ON BG2.pid = GT.biz_group_id
|
||||
WHERE BG2.state != 2 AND GT.depth < 10
|
||||
)
|
||||
SELECT biz_group_id
|
||||
FROM group_tree
|
||||
)
|
||||
</if>
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="date_type == 2">DATE_FORMAT(T.reg_time, '%Y-%m')</when>
|
||||
<otherwise>DATE_FORMAT(T.reg_time, '%Y-%m-%d')</otherwise>
|
||||
</choose> AS date,
|
||||
D.name AS device_name,
|
||||
T.uid1 AS uid1,
|
||||
|
||||
/* 카드 */
|
||||
COUNT(CASE
|
||||
WHEN
|
||||
<choose>
|
||||
<when test="approval_type == 0">T.type IN ('D1','D4','I1','I4')</when>
|
||||
<when test="approval_type == 1">T.type IN ('D1','I1')</when>
|
||||
<when test="approval_type == 2">T.type IN ('D4','I4')</when>
|
||||
</choose>
|
||||
THEN 1 END) AS card_count,
|
||||
|
||||
SUM(CASE
|
||||
WHEN
|
||||
<choose>
|
||||
<when test="approval_type == 0">T.type IN ('D1','D4','I1','I4')</when>
|
||||
<when test="approval_type == 1">T.type IN ('D1','I1')</when>
|
||||
<when test="approval_type == 2">T.type IN ('D4','I4')</when>
|
||||
</choose>
|
||||
THEN T.amount ELSE 0 END) AS card_amount,
|
||||
|
||||
/* 현금 */
|
||||
COUNT(CASE
|
||||
WHEN
|
||||
<choose>
|
||||
<when test="approval_type == 0">T.type IN ('B1','B4')</when>
|
||||
<when test="approval_type == 1">T.type IN ('B1')</when>
|
||||
<when test="approval_type == 2">T.type IN ('B4')</when>
|
||||
</choose>
|
||||
THEN 1 END) AS cash_count,
|
||||
|
||||
SUM(CASE
|
||||
WHEN
|
||||
<choose>
|
||||
<when test="approval_type == 0">T.type IN ('B1','B4')</when>
|
||||
<when test="approval_type == 1">T.type IN ('B1')</when>
|
||||
<when test="approval_type == 2">T.type IN ('B4')</when>
|
||||
</choose>
|
||||
THEN T.amount ELSE 0 END) AS cash_amount,
|
||||
|
||||
/* T머니 */
|
||||
COUNT(CASE
|
||||
WHEN
|
||||
<choose>
|
||||
<when test="approval_type == 0">T.type IN ('TM1','TM4')</when>
|
||||
<when test="approval_type == 1">T.type IN ('TM1')</when>
|
||||
<when test="approval_type == 2">T.type IN ('TM4')</when>
|
||||
</choose>
|
||||
THEN 1 END) AS tmoney_count,
|
||||
|
||||
SUM(CASE
|
||||
WHEN
|
||||
<choose>
|
||||
<when test="approval_type == 0">T.type IN ('TM1','TM4')</when>
|
||||
<when test="approval_type == 1">T.type IN ('TM1')</when>
|
||||
<when test="approval_type == 2">T.type IN ('TM4')</when>
|
||||
</choose>
|
||||
THEN T.amount ELSE 0 END) AS tmoney_amount,
|
||||
|
||||
/* 캐시비 */
|
||||
COUNT(CASE
|
||||
WHEN
|
||||
<choose>
|
||||
<when test="approval_type == 0">T.type IN ('EB1','EB4')</when>
|
||||
<when test="approval_type == 1">T.type IN ('EB1')</when>
|
||||
<when test="approval_type == 2">T.type IN ('EB4')</when>
|
||||
</choose>
|
||||
THEN 1 END) AS cbee_count,
|
||||
|
||||
SUM(CASE
|
||||
WHEN
|
||||
<choose>
|
||||
<when test="approval_type == 0">T.type IN ('EB1','EB4')</when>
|
||||
<when test="approval_type == 1">T.type IN ('EB1')</when>
|
||||
<when test="approval_type == 2">T.type IN ('EB4')</when>
|
||||
</choose>
|
||||
THEN T.amount ELSE 0 END) AS cbee_amount,
|
||||
|
||||
/* 합계 */
|
||||
(
|
||||
SUM(CASE WHEN T.type IN ('D1','D4','I1','I4') THEN T.amount ELSE 0 END) +
|
||||
SUM(CASE WHEN T.type IN ('B1','B4') THEN T.amount ELSE 0 END) +
|
||||
SUM(CASE WHEN T.type IN ('TM1','TM4') THEN T.amount ELSE 0 END) +
|
||||
SUM(CASE WHEN T.type IN ('EB1','EB4') THEN T.amount ELSE 0 END)
|
||||
) AS total
|
||||
FROM transactions AS T
|
||||
JOIN device D ON D.device_id = T.device_id
|
||||
WHERE
|
||||
<choose>
|
||||
<when test="is_group_access == false">
|
||||
T.biz_group_id IN ( SELECT biz_group_id FROM target_group )
|
||||
</when>
|
||||
<otherwise>
|
||||
T.biz_group_id = #{biz_group_id}
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="date_start != null and date_start != ''">AND #{date_start} <= DATE(T.reg_time)</if>
|
||||
<if test="date_end != null and date_end != ''">AND DATE(T.reg_time) <= #{date_end}</if>
|
||||
|
||||
GROUP BY
|
||||
<choose>
|
||||
<when test="date_type == 2">DATE_FORMAT(T.reg_time, '%Y-%m')</when>
|
||||
<otherwise>DATE_FORMAT(T.reg_time, '%Y-%m-%d')</otherwise>
|
||||
</choose>,
|
||||
D.name,
|
||||
T.uid1
|
||||
|
||||
HAVING card_count != 0 OR cash_count != 0 OR tmoney_count != 0 OR cbee_count != 0
|
||||
|
||||
ORDER BY
|
||||
date DESC
|
||||
</select>
|
||||
|
||||
<insert id="insertTransaction">
|
||||
INSERT INTO transactions
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
reg_time, process,
|
||||
<if test="biz_group_id != null">biz_group_id,</if>
|
||||
<if test="device_id != null">device_id,</if>
|
||||
<if test="uid1 != null and uid1 != ''">uid1,</if>
|
||||
<if test="uid1_type != null and uid1_type != 0">uid1_type,</if>
|
||||
<if test="order_time != null and order_time != ''">order_time,</if>
|
||||
<if test="type != null and type != ''">type,</if>
|
||||
<if test="amount != null and amount != 0">amount,</if>
|
||||
<if test="approval != null and approval != ''">approval,</if>
|
||||
<if test="pay_unique_num != null and pay_unique_num != ''">pay_unique_num,</if>
|
||||
<if test="slot != null and slot != ''">slot,</if>
|
||||
<if test="code != null and code != ''">code,</if>
|
||||
<if test="goods_name != null and goods_name != ''">goods_name,</if>
|
||||
<if test="price != null and price != 0">price,</if>
|
||||
<if test="pay_name != null and pay_name != ''">pay_name,</if>
|
||||
<if test="pay_vendor != null and pay_vendor != ''">pay_vendor</if>
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
NOW(), 1,
|
||||
<if test="biz_group_id != null">#{biz_group_id},</if>
|
||||
<if test="device_id != null">#{device_id},</if>
|
||||
<if test="uid1 != null and uid1 != ''">#{uid1},</if>
|
||||
<if test="uid1_type != null and uid1_type != 0">#{uid1_type},</if>
|
||||
<if test="order_time != null and order_time != ''">#{order_time},</if>
|
||||
<if test="type != null and type != ''">#{type},</if>
|
||||
<if test="amount != null and amount != 0">#{amount},</if>
|
||||
<if test="approval != null and approval != ''">#{approval},</if>
|
||||
<if test="pay_unique_num != null and pay_unique_num != ''">#{pay_unique_num},</if>
|
||||
<if test="slot != null and slot != ''">#{slot},</if>
|
||||
<if test="code != null and code != ''">#{code},</if>
|
||||
<if test="goods_name != null and goods_name != ''">#{goods_name},</if>
|
||||
<if test="price != null and price != 0">#{price},</if>
|
||||
<if test="pay_name != null and pay_name != ''">#{pay_name},</if>
|
||||
<if test="pay_vendor != null and pay_vendor != ''">#{pay_vendor}</if>
|
||||
</trim>
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.handong.smartservice.mapper.VocMapper">
|
||||
|
||||
<select id="selectDetailVoc" resultType="map">
|
||||
SELECT voc_id, title, content
|
||||
FROM voc
|
||||
WHERE voc_id = #{voc_id}
|
||||
</select>
|
||||
|
||||
<select id="selectVoc" resultType="map">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="isCount == true">
|
||||
COUNT(*)
|
||||
</when>
|
||||
<otherwise>
|
||||
RB.voc_id, RB.reg_time, RB.title, '임시' as submitter, RB.update_time, RB.process
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM voc AS RB
|
||||
WHERE state != 2
|
||||
<if test="date_start != null and date_start != ''">
|
||||
AND #{date_start} <= DATE(reg_time)
|
||||
</if>
|
||||
<if test="date_end != null and date_end != ''">
|
||||
AND DATE(reg_time) <= #{date_end}
|
||||
</if>
|
||||
<if test="title != null and title != ''">
|
||||
AND title like CONCAT(#{title}, '%')
|
||||
</if>
|
||||
<if test="content != null and content != ''">
|
||||
AND content like CONCAT(#{content}, '%')
|
||||
</if>
|
||||
<if test="isCount == false">
|
||||
ORDER BY voc_id DESC LIMIT #{limit} OFFSET #{offset}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertVoc">
|
||||
INSERT INTO voc
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
title, content, gid,
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{title}, #{content}, #{gid},
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateVoc">
|
||||
UPDATE voc
|
||||
<set>
|
||||
<if test="title != null and title != ''">title = #{title},</if>
|
||||
<if test="content != null and content != ''">content = #{content},</if>
|
||||
</set>
|
||||
WHERE voc_id = #{voc_id}
|
||||
</update>
|
||||
|
||||
<update id="changeStateVoc">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
UPDATE voc
|
||||
SET state = #{state}
|
||||
WHERE voc_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
<!--
|
||||
<delete id="deleteVoc">
|
||||
<if test="ids != null and ids.size > 0">
|
||||
DELETE FROM voc
|
||||
WHERE voc IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</delete>
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,237 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.4.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
index.jsp<br><br>
|
||||
CRUD example<br><br><br><br>
|
||||
---------------------------------------<br>
|
||||
<button id="h_insert_1">insert</button><br>
|
||||
---------------------------------------<br>
|
||||
<div id="h_select_1">select1</div>
|
||||
<div id="h_select_2">select2</div>
|
||||
<div id="h_select_3">select3</div>
|
||||
<div id="h_select_4">select4</div>
|
||||
<div id="h_select_5">select5</div>
|
||||
---------------------------------------<br>
|
||||
<span id="h_update_1">update</span><br>
|
||||
---------------------------------------<br>
|
||||
<p id="h_delete_1">delete</p>
|
||||
</body>
|
||||
<script>
|
||||
|
||||
var add_data = function(test_data) {
|
||||
var data = {
|
||||
test_data: test_data
|
||||
}
|
||||
|
||||
//var url = "/api/add_data.do";
|
||||
var url = "https://apis.naver.com/cafe-web/cafe-home/v2/popular/section/home";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: data,
|
||||
success: function (resp) {
|
||||
if (resp.errCode != 0) {
|
||||
alert("Error : " + resp.errCode);
|
||||
return;
|
||||
}
|
||||
|
||||
//...
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
alert("<Request Error>\nstatus = " + request.status + "\nresponseText = " + request.responseText + "\nerror = " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
//th code
|
||||
var account_data = function() {
|
||||
|
||||
var url = "/api/get-all-account.do";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
success: function (resp) {
|
||||
if (resp.errCode != 0) {
|
||||
alert("Error : " + resp.errCode);
|
||||
return;
|
||||
}
|
||||
|
||||
alert("data = " + JSON.stringify(resp.data));
|
||||
|
||||
//...
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
alert("<Request Error>\nstatus = " + request.status + "\nresponseText = " + request.responseText + "\nerror = " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var add_account_data = function() {
|
||||
var params = {
|
||||
userId: "testId",
|
||||
userName: "test123",
|
||||
userPw: "1234",
|
||||
email: "testEmail@naver.com",
|
||||
firstName : "test_first_name",
|
||||
lastName : "test_last_name",
|
||||
nickName : "test_nick_name"
|
||||
|
||||
};
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/api/add-account.do",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify(params),
|
||||
success: function(resp) {
|
||||
if (resp.errCode != 0) {
|
||||
alert("Error : " + resp.errCode);
|
||||
return;
|
||||
}
|
||||
|
||||
alert("테스트 계정 추가 성공!\n" + JSON.stringify(resp.data));
|
||||
console.log("서버 응답:", resp);
|
||||
},
|
||||
error: function(request, status, error) {
|
||||
alert("<Request Error>\nstatus = " + request.status +
|
||||
"\nresponseText = " + request.responseText +
|
||||
"\nerror = " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var get_data = function(id, url) {
|
||||
var data = {
|
||||
id: id
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: data,
|
||||
success: function (resp) {
|
||||
if (resp.errCode != 0) {
|
||||
alert("Error : " + resp.errCode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (resp.data == null || resp.data.length == 0) {
|
||||
alert("no data");
|
||||
return;
|
||||
}
|
||||
|
||||
alert("data = " + JSON.stringify(resp.data));
|
||||
//...
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
alert("<Request Error>\nstatus = " + request.status + "\nresponseText = " + request.responseText + "\nerror = " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var modify_data = function() {
|
||||
var params = {
|
||||
gid: 36,
|
||||
userPw: "9999",
|
||||
firstName: "길동",
|
||||
lastName: "홍",
|
||||
nickName: "수정된닉",
|
||||
email: "update@test.com",
|
||||
state: 1
|
||||
};
|
||||
|
||||
var url = "/api/modify-account.do";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify(params),
|
||||
success: function (resp) {
|
||||
if (resp.errCode != 0) {
|
||||
alert("Error : " + resp.errCode);
|
||||
return;
|
||||
}
|
||||
alert("성공: " + resp.data.message);
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
alert("<Request Error>\nstatus = " + request.status + "\nresponseText = " + request.responseText + "\nerror = " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var delete_data = function() {
|
||||
var params = {
|
||||
userId: "testId"
|
||||
}
|
||||
|
||||
var url = "/api/remove-account.do";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify(params),
|
||||
success: function (resp) {
|
||||
if (resp.errCode != 0) {
|
||||
alert("Error : " + resp.errCode);
|
||||
return;
|
||||
}
|
||||
|
||||
alert("데이터 삭제 성공 " + resp.data.message);
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
alert("<Request Error>\nstatus = " + request.status + "\nresponseText = " + request.responseText + "\nerror = " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("#h_insert_1").click(function(){
|
||||
alert("h_insert_1");
|
||||
add_data(Math.random());
|
||||
});
|
||||
|
||||
$("#h_select_1").click(function(){
|
||||
alert("account_data");
|
||||
account_data();
|
||||
});
|
||||
|
||||
$("#h_select_2").click(function(){
|
||||
alert("add_account_data");
|
||||
add_account_data();
|
||||
});
|
||||
|
||||
$("#h_select_3").click(function(){
|
||||
alert("modify_data");
|
||||
modify_data();
|
||||
});
|
||||
|
||||
$("#h_select_4").click(function(){
|
||||
alert("h_select_4");
|
||||
get_data('1', "/api/get_data4.do");
|
||||
});
|
||||
|
||||
$("#h_select_5").click(function(){
|
||||
alert("h_select_5");
|
||||
get_data('1', "/api/get_data5.do");
|
||||
});
|
||||
|
||||
$("#h_update_1").click(function(){
|
||||
alert("h_update_1");
|
||||
modify_data(1, Math.random());
|
||||
});
|
||||
|
||||
$("#h_delete_1").click(function(){
|
||||
alert("h_delete_1");
|
||||
delete_data();
|
||||
});
|
||||
</script>
|
||||
|
||||
</html>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.handong.smartservice;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class SmartServiceApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user