Commit 561106d1 by 焦凯

Merge branch 'develop' of gitlab.beecode.cn:kunlun/xyst_dinas/xyst_dinas_backend into develop

# Conflicts:
#	backend/inz.basis/src/main/resources/META-INF/spring.factories
parents 356e9721 028c9c76
...@@ -4,7 +4,12 @@ build/ ...@@ -4,7 +4,12 @@ build/
target/ target/
.gradle/ .gradle/
.settings/ .settings/
.idea/
.project .project
.classpath .classpath
*.bak *.bak
.DS_Store .DS_Store
.idea/
*.iml
*.ipr
*.iws
...@@ -19,6 +19,7 @@ buildscript { ...@@ -19,6 +19,7 @@ buildscript {
} }
apply plugin: "eclipse" apply plugin: "eclipse"
apply plugin: "idea"
configure(subprojects) { project -> configure(subprojects) { project ->
apply from: "../common.gradle" apply from: "../common.gradle"
......
...@@ -121,7 +121,7 @@ dependencies { ...@@ -121,7 +121,7 @@ dependencies {
compile lib.bap2_sysconfig compile lib.bap2_sysconfig
compile lib.bap2_system compile lib.bap2_system
compile lib.hibernate_common_annotations compile lib.hibernate_common_annotations
compile lib.net_byte_buddy
compile lib.bcp_authc compile lib.bcp_authc
compile lib.bcp_import compile lib.bcp_import
compile lib.json compile lib.json
...@@ -135,6 +135,7 @@ dependencies { ...@@ -135,6 +135,7 @@ dependencies {
compile "com.beecode:inz.message:${inzVersion}" compile "com.beecode:inz.message:${inzVersion}"
compile "com.beecode:inz.enterprisesetting:${inzVersion}" compile "com.beecode:inz.enterprisesetting:${inzVersion}"
compile "com.beecode:xyst.dinas.oa:${inzVersion}" compile "com.beecode:xyst.dinas.oa:${inzVersion}"
compile "com.beecode:xyst.dinas.biz:${inzVersion}"
providedRuntime lib.spring_boot_starter_tomcat providedRuntime lib.spring_boot_starter_tomcat
} }
......
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$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 "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# 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
;;
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" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
@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
rootProject.name = "inz.plateform.war" rootProject.name = "inz.platform.war"
includeBuild("../") { includeBuild("../") {
dependencySubstitution { dependencySubstitution {
...@@ -12,5 +12,8 @@ includeBuild("../") { ...@@ -12,5 +12,8 @@ includeBuild("../") {
substitute module('com.beecode:inz.workflow') with project(':inz.workflow') substitute module('com.beecode:inz.workflow') with project(':inz.workflow')
substitute module('com.beecode:inz.enterprisesetting') with project(':inz.enterprisesetting') substitute module('com.beecode:inz.enterprisesetting') with project(':inz.enterprisesetting')
substitute module('com.beecode:xyst.dinas.oa') with project(':xyst.dinas.oa') substitute module('com.beecode:xyst.dinas.oa') with project(':xyst.dinas.oa')
substitute module('com.beecode:xyst.dinas.biz') with project(':xyst.dinas.biz')
} }
} }
...@@ -52,9 +52,13 @@ import com.beecode.inz.authentication.handler.RESTAppAuthenticationSuccessHandle ...@@ -52,9 +52,13 @@ import com.beecode.inz.authentication.handler.RESTAppAuthenticationSuccessHandle
import com.beecode.inz.authentication.handler.RESTAuthenticationEntryPoint; import com.beecode.inz.authentication.handler.RESTAuthenticationEntryPoint;
import com.beecode.inz.authentication.handler.RESTAuthenticationFailureHandler; import com.beecode.inz.authentication.handler.RESTAuthenticationFailureHandler;
import com.beecode.inz.authentication.handler.RESTAuthenticationSuccessHandler; import com.beecode.inz.authentication.handler.RESTAuthenticationSuccessHandler;
import com.beecode.inz.authentication.handler.RESTWarehouseUserAuthenticationSuccessHandler;
import com.beecode.inz.authentication.provider.AppUserAuthenticationProvider; import com.beecode.inz.authentication.provider.AppUserAuthenticationProvider;
import com.beecode.inz.authentication.provider.UserAuthenticationProvider; import com.beecode.inz.authentication.provider.UserAuthenticationProvider;
import com.beecode.inz.authentication.provider.WarehouseUserAuthenticationProvider;
import com.beecode.inz.basis.context.customer.CustomerContextRepository; import com.beecode.inz.basis.context.customer.CustomerContextRepository;
import com.beecode.inz.basis.context.warehouse.WarehouseUserContextPersistenceFilter;
import com.beecode.inz.basis.context.warehouse.WarehouseUserContextRepository;
/** /**
* @author Joe Grandja * @author Joe Grandja
...@@ -104,6 +108,14 @@ public class SecurityConfig { ...@@ -104,6 +108,14 @@ public class SecurityConfig {
@Autowired @Autowired
private UserAuthenticationProvider userAuthenticationProvider; private UserAuthenticationProvider userAuthenticationProvider;
@Autowired
private RESTWarehouseUserAuthenticationSuccessHandler warehouseUserAuthenticationSuccessHandler;
@Autowired
private WarehouseUserAuthenticationProvider warehouseUserAuthenticationProvider;
@Autowired
private WarehouseUserContextRepository warehouseUserContextRepository;
@Autowired @Autowired
private RestLogoutHandler CLogoutHandler; private RestLogoutHandler CLogoutHandler;
...@@ -126,10 +138,6 @@ public class SecurityConfig { ...@@ -126,10 +138,6 @@ public class SecurityConfig {
@Autowired @Autowired
private AminoContextRepository repository; private AminoContextRepository repository;
@Autowired
private CustomerContextRepository customerContextRepository;
@Configuration @Configuration
@Order(1) @Order(1)
...@@ -174,11 +182,89 @@ public class SecurityConfig { ...@@ -174,11 +182,89 @@ public class SecurityConfig {
protected AuthenticationManager authenticationManager() throws Exception { protected AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager(); return super.authenticationManager();
} }
}
@Configuration
@Order(2)
public class WarehouseUserSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
List<SessionAuthenticationStrategy> delegateStrategies = new ArrayList<SessionAuthenticationStrategy>();
delegateStrategies.add(concurrentSessionControlAuthenticationStrategy);
http.sessionManagement().maximumSessions(1);
http.csrf().disable();
http.cors().disable();
http.antMatcher("/warehouse/user/login").authorizeRequests().anyRequest().authenticated();
http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint);
InzWebAuthenticationFilter filter = new InzWebAuthenticationFilter();
filter.setAuthenticationSuccessHandler(warehouseUserAuthenticationSuccessHandler);
filter.setAuthenticationFailureHandler(authenticationFailureHandler);
filter.setAuthenticationManager(authenticationManager());
filter.setSessionAuthenticationStrategy(new CompositeSessionAuthenticationStrategy(delegateStrategies));
RequestMatcher requestMatcher = new AntPathRequestMatcher("/warehouse/user/login", "POST");
filter.setRequiresAuthenticationRequestMatcher(requestMatcher);
http.addFilterAt(filter, UsernamePasswordAuthenticationFilter.class);
InzConcurrentSessionFilter inzConcurrentSessionFilter = new InzConcurrentSessionFilter(sessionRegistry) ;
http.addFilterAt(inzConcurrentSessionFilter, ConcurrentSessionFilter.class);
WarehouseUserContextPersistenceFilter contextPersistenceFilter = new WarehouseUserContextPersistenceFilter(metadataRuntime, warehouseUserContextRepository);
http.addFilterAfter(contextPersistenceFilter, SecurityContextPersistenceFilter.class);
http.addFilterAfter(new INZTenantAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(warehouseUserAuthenticationProvider);
}
@Override
protected AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager();
}
} }
@Configuration @Configuration
@Order(3) @Order(3)
public class WarehouseApiConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
List<SessionAuthenticationStrategy> delegateStrategies = new ArrayList<SessionAuthenticationStrategy>();
delegateStrategies.add(concurrentSessionControlAuthenticationStrategy);
http.sessionManagement().maximumSessions(1);
http.csrf().disable();
http.cors().disable();
http.antMatcher("/warehouse/**").authorizeRequests().anyRequest().authenticated();
http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint);
InzConcurrentSessionFilter inzConcurrentSessionFilter = new InzConcurrentSessionFilter(sessionRegistry) ;
http.addFilterAt(inzConcurrentSessionFilter, ConcurrentSessionFilter.class);
WarehouseUserContextPersistenceFilter contextPersistenceFilter = new WarehouseUserContextPersistenceFilter(metadataRuntime, warehouseUserContextRepository);
http.addFilterAfter(contextPersistenceFilter, SecurityContextPersistenceFilter.class);
http.addFilterAfter(new INZTenantAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
http.logout().logoutUrl("/logout")
.addLogoutHandler(logoutHandler).invalidateHttpSession(true)
.permitAll();
}
@Override
protected AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager();
}
}
@Configuration
@Order(4)
public class WebSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter { public class WebSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
...@@ -226,6 +312,7 @@ public class SecurityConfig { ...@@ -226,6 +312,7 @@ public class SecurityConfig {
.antMatchers("/crm/load/publicity/byAssetPackage/**").permitAll() .antMatchers("/crm/load/publicity/byAssetPackage/**").permitAll()
.antMatchers("/workflow/api/**").permitAll() .antMatchers("/workflow/api/**").permitAll()
.antMatchers("/dnaserver/**").permitAll() .antMatchers("/dnaserver/**").permitAll()
.antMatchers("/warehouseuser/**").permitAll()
.anyRequest().authenticated();//listAll,modifySelfPassword,loadAuctionByAsset临时开放 .anyRequest().authenticated();//listAll,modifySelfPassword,loadAuctionByAsset临时开放
http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint); http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint);
InzWebAuthenticationFilter filter = new InzWebAuthenticationFilter(); InzWebAuthenticationFilter filter = new InzWebAuthenticationFilter();
...@@ -257,7 +344,6 @@ public class SecurityConfig { ...@@ -257,7 +344,6 @@ public class SecurityConfig {
protected AuthenticationManager authenticationManager() throws Exception { protected AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager(); return super.authenticationManager();
} }
} }
} }
...@@ -247,7 +247,9 @@ ext { ...@@ -247,7 +247,9 @@ ext {
javax_persistence_api: "javax.persistence:javax.persistence-api:2.2", javax_persistence_api: "javax.persistence:javax.persistence-api:2.2",
jboss_javax_transaction_api: "org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.1.1.Final", jboss_javax_transaction_api: "org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.1.1.Final",
hibernate_common_annotations: "org.hibernate.common:hibernate-commons-annotations:5.0.4.Final" hibernate_common_annotations: "org.hibernate.common:hibernate-commons-annotations:5.0.4.Final",
net_byte_buddy: "net.bytebuddy:byte-buddy:1.8.15"
] ]
} }
...@@ -401,7 +403,13 @@ configurations.all { ...@@ -401,7 +403,13 @@ configurations.all {
force lib.poi force lib.poi
force lib.poi_ooxml force lib.poi_ooxml
force lib.poi_ooxml_schemas force lib.poi_ooxml_schemas
force lib.javax_persistence_api
force lib.hibernate_common_annotations
force lib.jboss_javax_transaction_api
force lib.net_byte_buddy
exclude group: "c3p0", module: "c3p0" exclude group: "c3p0", module: "c3p0"
exclude group: "dom4j", module: "dom4j" exclude group: "dom4j", module: "dom4j"
exclude group: "com.vaadin.external.google", module: "android-json" exclude group: "com.vaadin.external.google", module: "android-json"
......
...@@ -19,9 +19,11 @@ import com.beecode.inz.authentication.handler.RESTAppAuthenticationSuccessHandle ...@@ -19,9 +19,11 @@ import com.beecode.inz.authentication.handler.RESTAppAuthenticationSuccessHandle
import com.beecode.inz.authentication.handler.RESTAuthenticationEntryPoint; import com.beecode.inz.authentication.handler.RESTAuthenticationEntryPoint;
import com.beecode.inz.authentication.handler.RESTAuthenticationFailureHandler; import com.beecode.inz.authentication.handler.RESTAuthenticationFailureHandler;
import com.beecode.inz.authentication.handler.RESTAuthenticationSuccessHandler; import com.beecode.inz.authentication.handler.RESTAuthenticationSuccessHandler;
import com.beecode.inz.authentication.handler.RESTWarehouseUserAuthenticationSuccessHandler;
import com.beecode.inz.authentication.internal.service.SMSsendingCustomerServiceImpl; import com.beecode.inz.authentication.internal.service.SMSsendingCustomerServiceImpl;
import com.beecode.inz.authentication.internal.service.SMSsendingServiceImpl; import com.beecode.inz.authentication.internal.service.SMSsendingServiceImpl;
import com.beecode.inz.authentication.provider.AppUserAuthenticationProvider; import com.beecode.inz.authentication.provider.AppUserAuthenticationProvider;
import com.beecode.inz.authentication.provider.WarehouseUserAuthenticationProvider;
import com.beecode.inz.authentication.service.SMSsendingCustomerService; import com.beecode.inz.authentication.service.SMSsendingCustomerService;
import com.beecode.inz.authentication.service.SMSsendingService; import com.beecode.inz.authentication.service.SMSsendingService;
import com.beecode.inz.authentication.session.InzConcurrentSessionControlAuthenticationStrategy; import com.beecode.inz.authentication.session.InzConcurrentSessionControlAuthenticationStrategy;
...@@ -68,6 +70,11 @@ public class AuthenticationConfiguration { ...@@ -68,6 +70,11 @@ public class AuthenticationConfiguration {
return new RESTAppAuthenticationSuccessHandler(); return new RESTAppAuthenticationSuccessHandler();
} }
@Bean
public RESTWarehouseUserAuthenticationSuccessHandler warehouseUserAuthenticationSuccessHandler() {
return new RESTWarehouseUserAuthenticationSuccessHandler();
}
@Bean("com.beecode.inz.authentication.config.RedisConfiguration.redisTemplate") @Bean("com.beecode.inz.authentication.config.RedisConfiguration.redisTemplate")
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory redisConnectionFactory) { public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate< String, String> redisTemplate = new RedisTemplate<String,String>(); RedisTemplate< String, String> redisTemplate = new RedisTemplate<String,String>();
...@@ -110,4 +117,9 @@ public class AuthenticationConfiguration { ...@@ -110,4 +117,9 @@ public class AuthenticationConfiguration {
return new AppUserAuthenticationProvider(); return new AppUserAuthenticationProvider();
} }
@Bean
public WarehouseUserAuthenticationProvider warehouseUserAuthenticationProvider() {
return new WarehouseUserAuthenticationProvider();
}
} }
...@@ -55,8 +55,7 @@ public class InzWebAuthenticationFilter extends AbstractAuthenticationProcessing ...@@ -55,8 +55,7 @@ public class InzWebAuthenticationFilter extends AbstractAuthenticationProcessing
username = username.trim(); username = username.trim();
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken( UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);
username, password);
// Allow subclasses to set the "details" property // Allow subclasses to set the "details" property
setDetails(request, authRequest); setDetails(request, authRequest);
......
package com.beecode.inz.authentication.handler;
import java.io.IOException;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.beecode.inz.authentication.constants.AuthcConstants;
import com.beecode.inz.authentication.constants.LoginLogConstants;
import com.beecode.inz.authentication.constants.TenantUserConstants;
import com.beecode.inz.authentication.datamodel.LoginLog;
import com.beecode.inz.authentication.enumeration.LoginModeEnum;
import com.beecode.inz.authentication.enumeration.LoginStateEnum;
import com.beecode.inz.authentication.enumeration.LoginTerminalEnum;
import com.beecode.inz.authentication.service.LoginLogService;
import com.beecode.inz.authentication.util.LoginLogUtil;
import com.beecode.inz.basis.pojo.WarehouseUser;
/**
* 处理砂厂用户登录成功后的返回
*
* @author pengwufeng
*
*/
@Component
public class RESTWarehouseUserAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
@Autowired
private LoginLogService loginLogService;
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
clearAuthenticationAttributes(request);
LoginLog loginLog = getLoginLog(request);
try {
String tenant = request.getParameter(AuthcConstants.TENANT);
WarehouseUser warehouseUser = (WarehouseUser) authentication.getPrincipal();
if (warehouseUser != null) {
JSONObject returnJson = new JSONObject();
request.getSession().setAttribute(AuthcConstants.SESSION_TENANTID, tenant);
request.getSession().setAttribute(AuthcConstants.USERID, warehouseUser.getId());
request.getSession().setAttribute(AuthcConstants.USERNAME, warehouseUser.getUsername());
request.getSession().setAttribute(AuthcConstants.TELEPHONE, warehouseUser.getTelephone());
request.getSession().setAttribute("mobile", true);
request.getSession().setMaxInactiveInterval(30 * 24 * 60 * 60);
loginLog.setTenantId(tenant);
loginLog.setDescription("warehouseUser login");
loginLogService.insert(loginLog);
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
returnJson.put(AuthcConstants.USERID, warehouseUser.getId());
returnJson.put(AuthcConstants.USERNAME, warehouseUser.getUsername());
returnJson.put(AuthcConstants.TELEPHONE, warehouseUser.getTelephone());
returnJson.put(AuthcConstants.MESSAGE, "success");
returnJson.put(AuthcConstants.TOKEN, attr.getSessionId());
returnJson.put(AuthcConstants.TENANT, tenant);
response.getWriter().append(returnJson.toString());
}
} catch (IOException e) {
e.printStackTrace();
} finally {
}
}
public LoginLog getLoginLog(HttpServletRequest request) {
LoginLog loginLog = new LoginLog();
String userAgent = request.getHeader(LoginLogConstants.USER_AGENT);
if (userAgent.contains(LoginLogConstants.WINDOWS)) {
loginLog.setLoginTerminal(LoginTerminalEnum.WEB.getValue());
} else if (userAgent.contains(LoginLogConstants.ANDROID)) {
loginLog.setLoginTerminal(LoginTerminalEnum.ANDROID.getValue());
} else if (userAgent.contains(LoginLogConstants.IOS)) {
loginLog.setLoginTerminal(LoginTerminalEnum.ISO.getValue());
} else {
loginLog.setLoginTerminal(LoginTerminalEnum.WEB.getValue());
}
loginLog.setAccountNumber(request.getParameter(TenantUserConstants.USERNAME));
loginLog.setLoginMode(request.getParameter(TenantUserConstants.USERNAME) == null
? LoginModeEnum.QRCODELODIN.getValue() : LoginModeEnum.USERNAMEPASSWORD.getValue());
loginLog.setIp(LoginLogUtil.getClientIp(request));
loginLog.setLoginTime(new Date());
loginLog.setLoginState(LoginStateEnum.SUCCESS.getValue());
return loginLog;
}
}
package com.beecode.inz.authentication.provider;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.crypto.password.PasswordEncoder;
import com.beecode.inz.basis.pojo.WarehouseUser;
import com.beecode.inz.basis.service.WarehouseUserService;
/**
* 砂厂用户验证器
* @author pengwufeng
*
*/
public class WarehouseUserAuthenticationProvider implements AuthenticationProvider {
@Autowired
WarehouseUserService warehouseUserService;
@Autowired
private PasswordEncoder passwordEncoder;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
String username = authentication.getName();
String passWord = (String) authentication.getCredentials();
WarehouseUser warehouseUser = warehouseUserService.getByUsername(username);
if(null == warehouseUser) {
throw new BadCredentialsException("用户名或密码错误!");
}
String pwd = warehouseUser.getPassword();
if (!passwordEncoder.matches(passWord, pwd)) {
throw new BadCredentialsException("用户名或密码错误!");
}
List<SimpleGrantedAuthority> roleList = new ArrayList<SimpleGrantedAuthority>();
return new UsernamePasswordAuthenticationToken(warehouseUser, passWord, roleList);
}
@Override
public boolean supports(Class<?> authentication) {
return authentication != null && authentication == UsernamePasswordAuthenticationToken.class;
}
}
...@@ -5,12 +5,17 @@ import org.springframework.context.annotation.Bean; ...@@ -5,12 +5,17 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import com.beecode.inz.basis.dao.CustomerDao; import com.beecode.inz.basis.dao.CustomerDao;
import com.beecode.inz.basis.dao.WarehouseUserDao;
import com.beecode.inz.basis.handler.SMSsnedHandlers; import com.beecode.inz.basis.handler.SMSsnedHandlers;
import com.beecode.inz.basis.internal.dao.CustomerDaoImpl; import com.beecode.inz.basis.internal.dao.CustomerDaoImpl;
import com.beecode.inz.basis.internal.dao.WarehouseUserDaoImpl;
import com.beecode.inz.basis.internal.service.CustomerServiceImpl; import com.beecode.inz.basis.internal.service.CustomerServiceImpl;
import com.beecode.inz.basis.internal.service.WarehouseUserServiceImpl;
import com.beecode.inz.basis.service.CustomerService; import com.beecode.inz.basis.service.CustomerService;
import com.beecode.inz.basis.service.WarehouseUserService;
import com.beecode.inz.basis.sms.internal.SMSsendingServiceImpl; import com.beecode.inz.basis.sms.internal.SMSsendingServiceImpl;
import com.beecode.inz.basis.sms.service.SMSsendingService; import com.beecode.inz.basis.sms.service.SMSsendingService;
import com.beecode.inz.basis.web.WarehouseUserController;
@Configuration @Configuration
public class CommonConfig { public class CommonConfig {
...@@ -35,4 +40,21 @@ public class CommonConfig { ...@@ -35,4 +40,21 @@ public class CommonConfig {
public CustomerDao customerDao() { public CustomerDao customerDao() {
return new CustomerDaoImpl(); return new CustomerDaoImpl();
} }
@Bean
public WarehouseUserService warehouseUserService() {
return new WarehouseUserServiceImpl();
}
@Bean
public WarehouseUserDao warehouseUserDao() {
return new WarehouseUserDaoImpl();
}
@Bean
public WarehouseUserController warehouseUserController() {
return new WarehouseUserController();
}
} }
...@@ -5,13 +5,20 @@ import org.springframework.context.annotation.Configuration; ...@@ -5,13 +5,20 @@ import org.springframework.context.annotation.Configuration;
import com.beecode.inz.basis.context.customer.CustomerContextRepository; import com.beecode.inz.basis.context.customer.CustomerContextRepository;
import com.beecode.inz.basis.context.customer.HttpSessionCustomerContextRepository; import com.beecode.inz.basis.context.customer.HttpSessionCustomerContextRepository;
import com.beecode.inz.basis.context.warehouse.HttpSessionWarehouseUserContextRepository;
import com.beecode.inz.basis.context.warehouse.WarehouseUserContextRepository;
@Configuration @Configuration
public class CustomerContextConfiguration { public class ContextConfiguration {
@Bean @Bean
public CustomerContextRepository customerContextRepository() { public CustomerContextRepository customerContextRepository() {
return new HttpSessionCustomerContextRepository(); return new HttpSessionCustomerContextRepository();
} }
@Bean
public WarehouseUserContextRepository warehouseUserContextRepository() {
return new HttpSessionWarehouseUserContextRepository();
}
} }
package com.beecode.inz.basis.config.constants;
public interface WarehouseUserConstants extends CommonConstants{
String ENTITY = "com.beecode.inz.basis.datamodel.WarehouseUser";
String USERNAME = "username";
String PASSWORD = "password";
String TYPE = "type";
String ORG = "org";
String PATH = "path";
String ROLE = "role";
String CONFIG = "config";
String DESCRIPTION = "description";
String TELEPHONE = "telephone";
String ENABLED = "enabled";
}
...@@ -95,7 +95,7 @@ public class HttpSessionCustomerContextRepository implements CustomerContextRepo ...@@ -95,7 +95,7 @@ public class HttpSessionCustomerContextRepository implements CustomerContextRepo
Customer customer = null; Customer customer = null;
String customerObj = (String)httpSession.getAttribute(CustomerContextConstants.CURRENT_CUSTOMER); String customerObj = (String)httpSession.getAttribute(CustomerContextConstants.CURRENT_CUSTOMER);
if (StringUtils.isEmpty(customer)) { if (StringUtils.isEmpty(customerObj)) {
try { try {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if(null == authentication) { if(null == authentication) {
......
package com.beecode.inz.basis.context.warehouse;
import javax.servlet.AsyncContext;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationTrustResolver;
import org.springframework.security.authentication.AuthenticationTrustResolverImpl;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.context.HttpRequestResponseHolder;
import org.springframework.security.web.util.OnCommittedResponseWrapper;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import com.beecode.inz.basis.exception.NotFoundWarehouseUserException;
import com.beecode.inz.basis.pojo.WarehouseUser;
import com.beecode.inz.basis.service.WarehouseUserService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class HttpSessionWarehouseUserContextRepository implements WarehouseUserContextRepository {
@Autowired
private WarehouseUserService warehouseUserService;
@Autowired
private ObjectMapper objectMapper;
public static final String WAREHOUSE_USER_CONTEXT_KEY = "WAREHOUSE_USER_CONTEXT";
protected final Log logger = LogFactory.getLog(this.getClass());
private final Object contextObject = WarehouseUserContextHolder.createEmptyContext();
private boolean isServlet3 = ClassUtils.hasMethod(ServletRequest.class, "startAsync");
private AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
@Override
@Transactional(readOnly=true)
public WarehouseUserContext loadContext(HttpRequestResponseHolder requestResponseHolder) {
HttpServletRequest request = requestResponseHolder.getRequest();
HttpServletResponse response = requestResponseHolder.getResponse();
HttpSession httpSession = request.getSession(false);
WarehouseUserContext context = generateNewContext(httpSession);
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null && !trustResolver.isAnonymous(authentication)) {
WarehouseUserContextImpl contextImpl = (WarehouseUserContextImpl)context;
if(contextImpl.getWarehouseUser() == null) {
loadContext(httpSession, contextImpl);
}
}
SaveToSessionResponseWrapper wrappedResponse = new SaveToSessionResponseWrapper(response, request, httpSession != null, context);
requestResponseHolder.setResponse(wrappedResponse);
if (isServlet3) {
requestResponseHolder.setRequest(new Servlet3SaveToSessionRequestWrapper(request, wrappedResponse));
}
return context;
}
@Override
public boolean containsContext(HttpServletRequest request) {
HttpSession session = request.getSession(false);
if (session == null) {
return false;
}
return session.getAttribute(WAREHOUSE_USER_CONTEXT_KEY) != null;
}
protected WarehouseUserContext generateNewContext(HttpSession httpSession) {
return WarehouseUserContextHolder.createEmptyContext();
}
/**
* 获取当前用户context
* @throws Exception
*/
private void loadContext(HttpSession httpSession, WarehouseUserContextImpl contextImpl) {
if (null == httpSession) {
return;
}
WarehouseUser warehouseUser = null;
String warehouseUserJsonObj = (String)httpSession.getAttribute(WarehouseUserContextConstants.CURRENT_WAREHOUSE_USER);
if (StringUtils.isEmpty(warehouseUserJsonObj)) {
try {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if(null == authentication) {
return;
}
String userName = authentication.getName();
if(StringUtils.isEmpty(userName)) {
return;
}
warehouseUser = warehouseUserService.getByUsername(userName);
if(null == warehouseUser) {
throw new NotFoundWarehouseUserException("not found warehouseUser#" + userName);
}
httpSession.setAttribute(WarehouseUserContextConstants.CURRENT_WAREHOUSE_USER, objectMapper.writeValueAsString(warehouseUser));
} catch (JsonProcessingException e) {
e.printStackTrace();
}
} else if (warehouseUserJsonObj instanceof String) {
try {
warehouseUser = objectMapper.readValue(warehouseUserJsonObj, WarehouseUser.class);
}catch(Exception e) {
e.printStackTrace();
httpSession.removeAttribute(WarehouseUserContextConstants.CURRENT_WAREHOUSE_USER);
}
}
contextImpl.setWarehouseUser(warehouseUser);
}
//~ Inner Classes ==================================================================================================
private static class Servlet3SaveToSessionRequestWrapper extends HttpServletRequestWrapper {
private final SaveToSessionResponseWrapper response;
public Servlet3SaveToSessionRequestWrapper(HttpServletRequest request, SaveToSessionResponseWrapper response) {
super(request);
this.response = response;
}
@Override
public AsyncContext startAsync() {
response.disableSaveOnResponseCommitted();
return super.startAsync();
}
@Override
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse)
throws IllegalStateException {
response.disableSaveOnResponseCommitted();
return super.startAsync(servletRequest, servletResponse);
}
}
final class SaveToSessionResponseWrapper extends OnCommittedResponseWrapper {
private final HttpServletRequest request;
private final boolean httpSessionExistedAtStartOfRequest;
public SaveToSessionResponseWrapper(HttpServletResponse response, HttpServletRequest request,
boolean httpSessionExistedAtStartOfRequest, WarehouseUserContext context) {
super(response);
this.request = request;
this.httpSessionExistedAtStartOfRequest = httpSessionExistedAtStartOfRequest;
// this.contextBeforeExecution = context;
// this.authBeforeExecution = context.getAuthentication();
}
public void disableSaveOnResponseCommitted() {
disableOnResponseCommitted();
}
protected void saveContext(WarehouseUserContext context) {
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
HttpSession httpSession = request.getSession(false);
// See SEC-776
if (authentication == null || trustResolver.isAnonymous(authentication)) {
if (logger.isDebugEnabled()) {
logger.debug(
"WarehouseUserContext is empty or contents are anonymous - context will not be stored in HttpSession.");
}
if (httpSession != null) {
// SEC-1587 A non-anonymous context may still be in the
// session
// SEC-1735 remove if the contextBeforeExecution was not
// anonymous
httpSession.removeAttribute(WAREHOUSE_USER_CONTEXT_KEY);
}
return;
}
if (httpSession == null) {
httpSession = createNewSessionIfAllowed(context);
}
// If HttpSession exists, store current CustomerContext but only if
// it has
// actually changed in this thread (see SEC-37, SEC-1307, SEC-1528)
if (httpSession != null) {
// We may have a new session, so check also whether the context
// attribute
// is set SEC-1561
if (contextChanged(context) || httpSession.getAttribute(WAREHOUSE_USER_CONTEXT_KEY) == null) {
// httpSession.setAttribute(customerContextKey, context);
if (logger.isDebugEnabled()) {
logger.debug("WarehouseUserContext '" + context + "' stored to HttpSession: '" + httpSession);
}
}
}
}
private boolean contextChanged(WarehouseUserContext context) {
return true;
}
private HttpSession createNewSessionIfAllowed(WarehouseUserContext context) {
if (httpSessionExistedAtStartOfRequest) {
return null;
}
// Generate a HttpSession only if we need to
if (contextObject.equals(context)) {
return null;
}
try {
return request.getSession(true);
} catch (IllegalStateException e) {
logger.warn("Failed to create a session, as response has been committed. Unable to store"
+ " WarehouseUserContext.");
}
return null;
}
@Override
protected void onResponseCommitted() {
saveContext(WarehouseUserContextHolder.getContext());
}
@Override
public final String encodeRedirectUrl(String url) {
return super.encodeURL(url);
}
}
}
package com.beecode.inz.basis.context.warehouse;
import java.io.Serializable;
import com.beecode.inz.basis.pojo.WarehouseUser;
public interface WarehouseUserContext extends Serializable {
public WarehouseUser getWarehouseUser();
}
package com.beecode.inz.basis.context.warehouse;
public interface WarehouseUserContextConstants {
/**
* 当前用户
*/
public String CURRENT_WAREHOUSE_USER = "currentWarehouseUser";
}
package com.beecode.inz.basis.context.warehouse;
import org.springframework.util.Assert;
public class WarehouseUserContextHolder {
private static final ThreadLocal<WarehouseUserContext> contextHolder = new ThreadLocal<WarehouseUserContext>();
/**
* Explicitly clears the context value from the current thread.
*/
public static void clearContext() {
contextHolder.remove();
}
/**
* Obtain the current <code>SecurityContext</code>.
*
* @return the security context (never <code>null</code>)
*/
public static WarehouseUserContext getContext() {
WarehouseUserContext ctx = contextHolder.get();
if (ctx == null) {
ctx = createEmptyContext();
contextHolder.set(ctx);
}
return ctx;
}
/**
* Associates a new <code>SecurityContext</code> with the current thread of
* execution.
*
* @param context
* the new <code>SecurityContext</code> (may not be
* <code>null</code>)
*/
public static void setContext(WarehouseUserContext context) {
Assert.notNull(context, "Only non-null AminoContext instances are permitted");
contextHolder.set(context);
}
/**
* Delegates the creation of a new, empty context to the configured
* strategy.
*/
public static WarehouseUserContext createEmptyContext() {
return new WarehouseUserContextImpl();
}
}
package com.beecode.inz.basis.context.warehouse;
import com.beecode.inz.basis.pojo.WarehouseUser;
public class WarehouseUserContextImpl implements WarehouseUserContext {
/**
*
*/
private static final long serialVersionUID = 7659762847744346459L;
private WarehouseUser warehouseUser;
@Override
public WarehouseUser getWarehouseUser() {
return warehouseUser;
}
public void setWarehouseUser(WarehouseUser warehouseUser) {
this.warehouseUser = warehouseUser;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((warehouseUser == null) ? 0 : warehouseUser.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
WarehouseUserContextImpl other = (WarehouseUserContextImpl) obj;
if (warehouseUser == null) {
if (other.warehouseUser != null) {
return false;
}
} else if (!warehouseUser.equals(other.warehouseUser)) {
return false;
}
return true;
}
@Override
public String toString() {
return "WarehouseUserContextImpl [warehouseUser=" + warehouseUser + "]";
}
}
package com.beecode.inz.basis.context.warehouse;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.security.web.context.HttpRequestResponseHolder;
import org.springframework.web.filter.GenericFilterBean;
import com.beecode.amino.metadata.runtime.MetadataRuntime;
public class WarehouseUserContextPersistenceFilter extends GenericFilterBean {
static final String FILTER_APPLIED = "__warehouse_user_acpf_applied";
private final MetadataRuntime metadataRuntime;
private final WarehouseUserContextRepository repo;
private boolean forceEagerSessionCreation = false;
public WarehouseUserContextPersistenceFilter(MetadataRuntime metadataRuntime) {
this(metadataRuntime, new HttpSessionWarehouseUserContextRepository());
}
public WarehouseUserContextPersistenceFilter(MetadataRuntime metadataRuntime, WarehouseUserContextRepository repo) {
this.metadataRuntime = metadataRuntime;
this.repo = repo;
}
/* (non-Javadoc)
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
if (request.getAttribute(FILTER_APPLIED) != null) {
// ensure that filter is only applied once per request
chain.doFilter(request, response);
return;
}
if (!metadataRuntime.isActive()) {
// TODO 元数据服务还没有启动好
return;
}
final boolean debug = logger.isDebugEnabled();
request.setAttribute(FILTER_APPLIED, Boolean.TRUE);
if (forceEagerSessionCreation) {
HttpSession session = request.getSession();
if (debug && session.isNew()) {
logger.debug("Eagerly created session: " + session.getId());
}
}
HttpRequestResponseHolder holder = new HttpRequestResponseHolder(request, response);
try {
WarehouseUserContext contextBeforeChainExecution = repo.loadContext(holder);
WarehouseUserContextHolder.setContext(contextBeforeChainExecution);
chain.doFilter(holder.getRequest(), holder.getResponse());
}
finally {
// Crucial removal of SecurityContextHolder contents - do this before anything
// else.
WarehouseUserContextHolder.clearContext();
request.removeAttribute(FILTER_APPLIED);
if (debug) {
logger.debug("WarehouseUserContextHolder now cleared, as request processing completed");
}
}
}
public void setForceEagerSessionCreation(boolean forceEagerSessionCreation) {
this.forceEagerSessionCreation = forceEagerSessionCreation;
}
}
package com.beecode.inz.basis.context.warehouse;
import javax.servlet.http.HttpServletRequest;
import org.springframework.security.web.context.HttpRequestResponseHolder;
public interface WarehouseUserContextRepository {
WarehouseUserContext loadContext(HttpRequestResponseHolder requestResponseHolder);
/**
* Allows the repository to be queried as to whether it contains a security context
* for the current request.
*
* @param request the current request
* @return true if a context is found for the request, false otherwise
*/
boolean containsContext(HttpServletRequest request);
}
package com.beecode.inz.basis.dao;
import java.util.List;
import com.beecode.bcp.type.KObject;
public interface WarehouseUserDao extends BaseDao {
List<KObject> listByUserName(String username);
List<KObject> listByTelephone(String telephone);
KObject findByUsernameOrTelephone(String username);
}
package com.beecode.inz.basis.exception;
/**
* 无法找到指定用户 异常
* @author pengwufeng
*
*/
public class NotFoundWarehouseUserException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = 3670197963486023974L;
public NotFoundWarehouseUserException() {
super();
}
public NotFoundWarehouseUserException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public NotFoundWarehouseUserException(String message, Throwable cause) {
super(message, cause);
}
public NotFoundWarehouseUserException(String message) {
super(message);
}
public NotFoundWarehouseUserException(Throwable cause) {
super(cause);
}
}
...@@ -156,9 +156,9 @@ public abstract class AbstractBaseDao { ...@@ -156,9 +156,9 @@ public abstract class AbstractBaseDao {
if(whereAttributes != null && whereAttributes.size() > 0) { if(whereAttributes != null && whereAttributes.size() > 0) {
StringBuffer where = new StringBuffer(); StringBuffer where = new StringBuffer();
whereAttributes.keySet().forEach(key -> { whereAttributes.keySet().forEach(key -> {
where.append(String.format("AND %s=:%s", key, key)); where.append(String.format(" AND %s=:%s", key, key));
}); });
where.replace(0, 3, " WHERE "); where.replace(0, 4, " WHERE ");
sql.append(where); sql.append(where);
} }
......
package com.beecode.inz.basis.internal.dao;
import java.util.List;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.config.constants.WarehouseUserConstants;
import com.beecode.inz.basis.dao.WarehouseUserDao;
@Repository
public class WarehouseUserDaoImpl extends AbstractBaseDao implements WarehouseUserDao {
@Autowired
private HibernateTemplate template;
public WarehouseUserDaoImpl(){
}
@Override
protected HibernateTemplate getHibernateTemplate() {
return template;
}
@Override
protected String getModelName() {
return WarehouseUserConstants.ENTITY;
}
@Override
public KObject findByUsernameOrTelephone(String username) {
return getHibernateTemplate().execute(session -> {
StringBuffer sql = new StringBuffer("FROM " + getModelName() + " WHERE username = :username OR telephone = :username ");
//创建查询
Query<KObject> query = session.createQuery(sql.toString(), KObject.class);
query.setParameter("username", username);
List<KObject> result = query.getResultList();
if(result != null && result.size() > 0) {
return result.get(0);
}
return null;
});
}
@Override
public List<KObject> listByUserName(String username) {
return listByAttributes(buildSingleMap(WarehouseUserConstants.USERNAME, username));
}
@Override
public List<KObject> listByTelephone(String telephone) {
return listByAttributes(buildSingleMap(WarehouseUserConstants.TELEPHONE, telephone));
}
}
package com.beecode.inz.basis.internal.service;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import javax.transaction.Transactional;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.util.Assert;
import com.beecode.amino.core.Amino;
import com.beecode.bcp.core.context.AminoContextHolder;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.config.constants.WarehouseUserConstants;
import com.beecode.inz.basis.dao.WarehouseUserDao;
import com.beecode.inz.basis.pojo.WarehouseUser;
import com.beecode.inz.basis.service.WarehouseUserService;
/**
* 砂场用户 service
* @author pengwufeng
*
*/
public class WarehouseUserServiceImpl implements WarehouseUserService {
//spring 密码加密工具类
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private WarehouseUserDao dao;
@Override
public WarehouseUser getById(UUID id) {
Assert.notNull(id, "'id' must be not null!");
KObject entity = dao.findById(id);
return WarehouseUser.fromCustomerKObject(entity);
}
@Override
public WarehouseUser getByUsernameOrTelephone(String userame) {
Assert.notNull(userame, "'userName' must be not null!");
KObject object = dao.findByUsernameOrTelephone(userame);
if (object != null) {
return WarehouseUser.fromCustomerKObject(object);
}
return null;
}
@Override
public WarehouseUser getByUsername(String userame) {
Assert.notNull(userame, "'userName' must be not null!");
List<KObject> list = dao.listByUserName(userame);
if (list != null && list.size() > 0) {
return WarehouseUser.fromCustomerKObject(list.get(0));
}
return null;
}
@Transactional
@Override
public WarehouseUser getByTelephone(String telephone) {
Assert.notNull(telephone, "'telephone' must be not null!");
List<KObject> list = dao.listByTelephone(telephone);
if (list != null && list.size() > 0) {
return WarehouseUser.fromCustomerKObject(list.get(0));
}
return null;
}
@Transactional
@Override
public UUID create(WarehouseUser warehouseUser) {
Assert.notNull(warehouseUser, "'warehouseUser' must be not null!");
Assert.notNull(warehouseUser.getUsername(), "'username' must be not null!");
Assert.notNull(warehouseUser.getTitle(), "'title' must be not null!");
Assert.notNull(warehouseUser.getPassword(), "'password' must be not null!");
if(warehouseUser.getId() == null) {
warehouseUser.setId(UUID.randomUUID());
}
warehouseUser.setState("NORMAL");
warehouseUser.setEnabled(true);
warehouseUser.setCreator(AminoContextHolder.getContext().getStaff());
if (warehouseUser.getCreateTime() == null) {
warehouseUser.setCreateTime(new Date());
}
//密码加密
warehouseUser.setPassword(passwordEncoder.encode(warehouseUser.getPassword()));
return dao.insert(beanToObject(warehouseUser));
}
public KObject beanToObject(WarehouseUser warehouseUser){
KClass kclass = Amino.getApplicationMetadataContext().getBean(WarehouseUserConstants.ENTITY, KClass.class);
KObject obj = kclass.newInstance();
obj.set(WarehouseUserConstants.ID, warehouseUser.getId());
obj.set(WarehouseUserConstants.USERNAME, warehouseUser.getUsername());
obj.set(WarehouseUserConstants.PASSWORD, warehouseUser.getPassword());
obj.set(WarehouseUserConstants.TITLE, warehouseUser.getTitle());
obj.set(WarehouseUserConstants.CODE, warehouseUser.getCode());
obj.set(WarehouseUserConstants.TYPE, warehouseUser.getType());
obj.set(WarehouseUserConstants.TELEPHONE, warehouseUser.getTelephone());
obj.set(WarehouseUserConstants.ORG, warehouseUser.getOrg());
obj.set(WarehouseUserConstants.PATH, warehouseUser.getPath());
obj.set(WarehouseUserConstants.ROLE, warehouseUser.getRole());
obj.set(WarehouseUserConstants.CONFIG, warehouseUser.getConfig());
obj.set(WarehouseUserConstants.DESCRIPTION, warehouseUser.getDescription());
obj.set(WarehouseUserConstants.STATE, warehouseUser.getState());
obj.set(WarehouseUserConstants.ENABLED, warehouseUser.isEnabled());
obj.set(WarehouseUserConstants.CREATOR, warehouseUser.getCreator());
obj.set(WarehouseUserConstants.CREATE_TIME, warehouseUser.getCreateTime());
obj.set(WarehouseUserConstants.MODIFIER, warehouseUser.getModifier());
obj.set(WarehouseUserConstants.MODIFY_TIME, warehouseUser.getModifyTime());
obj.set(WarehouseUserConstants.VERSION, warehouseUser.getVersion());
return obj;
}
@Transactional
@Override
public void modify(WarehouseUser warehouseUser) {
Assert.notNull(warehouseUser, "'warehouseUser' must be not null!");
Assert.notNull(warehouseUser.getId(), "'warehouseUser.id' must be not null!");
Assert.notNull(warehouseUser.getUsername(), "'warehouseUser.userName' must be not null!");
Assert.notNull(warehouseUser.getTitle(), "'warehouseUser.title' must be not null!");
Assert.notNull(warehouseUser.getCreateTime(), "'warehouseUser.createTime' must be not null!");
KObject entity = dao.findById(warehouseUser.getId());
if(entity != null) {
//赋值,更新
if(StringUtils.isNotBlank(warehouseUser.getUsername())) {
entity.set(WarehouseUserConstants.USERNAME, warehouseUser.getUsername());
}
if(StringUtils.isNotBlank(warehouseUser.getTitle())) {
entity.set(WarehouseUserConstants.TITLE, warehouseUser.getTitle());
}
if(StringUtils.isNotBlank(warehouseUser.getTelephone())) {
entity.set(WarehouseUserConstants.TELEPHONE, warehouseUser.getTelephone());
}
if(StringUtils.isNotBlank(warehouseUser.getOrg())) {
entity.set(WarehouseUserConstants.ORG, warehouseUser.getOrg());
}
if(StringUtils.isNotBlank(warehouseUser.getPath())) {
entity.set(WarehouseUserConstants.PATH, warehouseUser.getPath());
}
if(StringUtils.isNotBlank(warehouseUser.getRole())) {
entity.set(WarehouseUserConstants.ROLE, warehouseUser.getRole());
}
if(StringUtils.isNotBlank(warehouseUser.getDescription())) {
entity.set(WarehouseUserConstants.DESCRIPTION, warehouseUser.getDescription());
}
if(StringUtils.isNotBlank(warehouseUser.getState())) {
entity.set(WarehouseUserConstants.STATE, warehouseUser.getState());
}
if(StringUtils.isNotBlank(warehouseUser.getConfig())) {
entity.set(WarehouseUserConstants.CONFIG, warehouseUser.getConfig());
}
if(warehouseUser.getModifier() != null) {
entity.set(WarehouseUserConstants.MODIFIER, warehouseUser.getModifier());
}
entity.set(WarehouseUserConstants.MODIFY_TIME, warehouseUser.getModifyTime());
dao.update(entity);
}
}
@Transactional
@Override
public void updatePassword(UUID id, String newPassword) {
Assert.notNull(id, "'id' must be not null!");
Assert.notNull(newPassword, "'newPassword' must be not null!");
KObject entity = dao.findById(id);
if(entity != null) {
//密码加密
entity.set(WarehouseUserConstants.PASSWORD, passwordEncoder.encode(newPassword));
dao.update(entity);
}
}
}
package com.beecode.inz.basis.pojo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.UUID;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.config.constants.WarehouseUserConstants;
/**
* @author pengwufeng
*
*/
public class WarehouseUser implements UserDetails, Serializable {
/**
*
*/
private static final long serialVersionUID = -553263854279399734L;
/**
* 用户ID
*/
private UUID id;
/**
* 版本号
*/
private Long version;
/**
* 登录名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 用户名称
*/
private String title;
/**
* 客户编码
*/
private String code;
/**
* 客户类型
*/
private String type;
/**
* 手机号
*/
private String telephone;
/**
* 所属组织
*/
private String org;
/**
* 组织路径
*/
private String path;
/**
* 所属角色
*/
private String role;
/**
* 用户配置
*/
private String config;
/**
* 描述
*/
private String description;
/**
* 状态
*/
private String state;
/**
* 是否可用
*/
private Boolean enabled;
/**
* 创建人
*/
private KObject creator;
/**
* 创建日期
*/
private Date createTime;
/**
* 修改日期
*/
private Date modifyTime;
/**
* 修改人
*/
private KObject modifier;
public WarehouseUser() {
}
public static WarehouseUser fromCustomerKObject(KObject object) {
try {
WarehouseUser model = new WarehouseUser();
model.setId(object.getUuid(WarehouseUserConstants.ID));
model.setVersion(object.getLong(WarehouseUserConstants.VERSION));
model.setUsername(object.getString(WarehouseUserConstants.USERNAME));
model.setPassword(object.getString(WarehouseUserConstants.PASSWORD));
model.setTitle(object.getString(WarehouseUserConstants.TITLE));
model.setCode(object.getString(WarehouseUserConstants.CODE));
model.setType(object.getString(WarehouseUserConstants.TYPE));
model.setTelephone(object.getString(WarehouseUserConstants.TELEPHONE));
model.setOrg(object.getString(WarehouseUserConstants.ORG));
model.setPath(object.getString(WarehouseUserConstants.PATH));
model.setRole(object.getString(WarehouseUserConstants.ROLE));
model.setDescription(object.getString(WarehouseUserConstants.DESCRIPTION));
model.setState(object.getString(WarehouseUserConstants.STATE));
model.setConfig(object.getString(WarehouseUserConstants.CONFIG));
model.setEnabled(object.getBoolean(WarehouseUserConstants.ENABLED));
model.setCreateTime(object.getDate(WarehouseUserConstants.CREATE_TIME));
model.setCreator(object.get(WarehouseUserConstants.MODIFIER).isNull() ? null : object.get(WarehouseUserConstants.CREATOR));
model.setModifyTime(object.getDate(WarehouseUserConstants.MODIFY_TIME));
model.setModifier(object.get(WarehouseUserConstants.MODIFIER).isNull() ? null : object.get(WarehouseUserConstants.MODIFIER));
return model;
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return new ArrayList<SimpleGrantedAuthority>();
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return !getEnabled();
}
@Override
public boolean isCredentialsNonExpired() {
return false;
}
@Override
public boolean isEnabled() {
return this.enabled != null ? this.enabled : false ;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getOrg() {
return org;
}
public void setOrg(String org) {
this.org = org;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getConfig() {
return config;
}
public void setConfig(String config) {
this.config = config;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public Boolean getEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public KObject getCreator() {
return creator;
}
public void setCreator(KObject creator) {
this.creator = creator;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public KObject getModifier() {
return modifier;
}
public void setModifier(KObject modifier) {
this.modifier = modifier;
}
}
package com.beecode.inz.basis.service;
import java.util.UUID;
import com.beecode.inz.basis.pojo.WarehouseUser;
/**
* Service
* @author pengwufeng
*
*/
public interface WarehouseUserService {
/**
* 创建客户
* @param warehouseUser
* @return
*/
UUID create(WarehouseUser warehouseUser);
/**
* 根据电话获取客户
* @param telephone
* @return
*/
WarehouseUser getByTelephone(String telephone);
/**
* 根据用户名获取客户
* @param userame
* @return
*/
WarehouseUser getByUsername(String userame);
/**
* 根据id获取客户
* @param userame
* @return
*/
WarehouseUser getById(UUID id);
WarehouseUser getByUsernameOrTelephone(String userame);
/**
* 根据传参对每个字段进行识别更新,不包含id,code,createtime,version等字段
* @param warehouseUser
*/
void modify(WarehouseUser warehouseUser);
/**
* 更新指定客户的密码
* @param id
* @param newPassword
*/
void updatePassword(UUID id, String newPassword);
}
package com.beecode.inz.basis.util;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonUtil {
private static final Logger log = LoggerFactory.getLogger(JsonUtil.class);
private static ObjectMapper objectMapper = new ObjectMapper();
static {
// //该属性设置主要是将对象的所有字段全部列入,若有特殊需求,可以进入JsonSerialize.Inclusion该枚举类查看
// objectMapper.setSerializationInclusion(JsonSerialize.Inclusion.ALWAYS);
//
// //该属性设置主要是取消将对象的时间默认转换timesstamps(时间戳)形式
// objectMapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,
// false);
//
// //该属性设置主要是将忽略空bean转json错误
// objectMapper.configure(MapperFeature.Feature.FAIL_ON_EMPTY_BEANS,
// false);
// 。
// 忽略在json字符串中存在,在java类中不存在字段,防止错误
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// 设置转时间的格式
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
}
public static <T> String beanToJson(T obj) {
if (obj == null) {
return null;
}
try {
return obj instanceof String ? (String) obj : objectMapper.writeValueAsString(obj);
} catch (Exception e) {
log.warn("obj To json is error", e);
return null;
}
}
public static <T> T jsonToBean(String json, Class<T> clazz) {
if (StringUtils.isEmpty(json) || clazz == null) {
return null;
}
try {
return objectMapper.readValue(json, clazz);
} catch (Exception e) {
log.warn("json To obj is error", e);
return null;
}
}
public static <T, E> Map<T, E> jsonToMap(String json, Class<T> clazz, Class<E> claze) {
Map<T, E> map = null;
if (StringUtils.isNotEmpty(json)) {
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(Map.class, clazz, claze);
try {
map = objectMapper.readValue(json, javaType);
} catch (Exception e) {
log.warn("{}", e);
}
}
return map != null ? map : new ConcurrentHashMap<>();
}
public static <T> List<T> jsonToList(String jsonArray, Class<T> clazz) {
List<T> list = null;
if (StringUtils.isNotEmpty(jsonArray)) {
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(ArrayList.class, clazz);
try {
list = objectMapper.readValue(jsonArray, javaType);
} catch (Exception e) {
log.warn("{}", e);
}
}
return list != null ? list : new ArrayList<>();
}
}
\ No newline at end of file
package com.beecode.inz.basis.web;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.beecode.bcp.core.context.AminoContextHolder;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.context.warehouse.WarehouseUserContextHolder;
import com.beecode.inz.basis.pojo.WarehouseUser;
import com.beecode.inz.basis.service.WarehouseUserService;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.inz.basis.util.JsonUtil;
import com.beecode.xlib.utils.StringUtil;
/**
* 场站用户controller
* @author pengwufeng
*
*/
@RestController
@RequestMapping("/warehouse/user")
public class WarehouseUserController {
private static final Logger logger = LoggerFactory.getLogger(WarehouseUserController.class);
@Autowired
private WarehouseUserService warehouseUserService;
/**
* 创建场站用户
*
* @param obj
* @return
*/
@PostMapping
public Object create(@RequestBody String body) {
if(StringUtil.isEmpty(body)) {
return ResponseObj.error("参数不能为空");
}
WarehouseUser warehouseUser = JsonUtil.jsonToBean(body, WarehouseUser.class);
if(warehouseUser == null) {
return ResponseObj.error("参数无法识别");
}
try {
warehouseUserService.create(warehouseUser);
} catch(Exception e) {
logger.error("", e);
return ResponseObj.error(e.getMessage());
}
return ResponseObj.success("操作成功",null);
}
/**
* 创建场站用户
*
* @param obj
* @return
*/
@PostMapping(value="test")
public Object test(@RequestBody String body) {
WarehouseUser user = WarehouseUserContextHolder.getContext().getWarehouseUser();
KObject staff = AminoContextHolder.getContext().getStaff();
return ResponseObj.success("操作成功",null);
}
}
<model>
<header>
<type>bcp.type.DataModel</type>
<package>com.beecode.inz.basis.datamodel</package>
<title>场站用户</title>
<name>WarehouseUser</name>
<tags></tags>
<description></description>
<templateName>mk.ide.ui.editor.data.model.template.common</templateName>
<tablePrefix>xyst_dinas_</tablePrefix>
</header>
<content>
<dataModel id='2ea32765-853e-11eb-b258-54ee750ba9b2' multiVersion='undefined' domainInherit='undefined' tableName='xyst_dinas_basis_warehouse_user'>
<attribute id='2ea327a9-853e-11eb-b258-54ee750ba9b2' name='id' columnName='id' title='id' type='uuid' default='' precision='' isArray='false'>
<annotation id='2ea327ad-853e-11eb-b258-54ee750ba9b2' attributeId='2ea327b1-853e-11eb-b258-54ee750ba9b2' name='length' value='undefined'></annotation>
<annotation id='2ea327b2-853e-11eb-b258-54ee750ba9b2' attributeId='2ea327b4-853e-11eb-b258-54ee750ba9b2' name='unique' value='false'></annotation>
</attribute>
<attribute id='49a99e2e-853e-11eb-b258-54ee750ba9b2' name='username' columnName='username' title='用户名' type='string' default='' precision='' isArray='false'>
<annotation id='49a99e31-853e-11eb-b258-54ee750ba9b2' attributeId='49a99e35-853e-11eb-b258-54ee750ba9b2' name='length' value='50'></annotation>
</attribute>
<attribute id='49a99e36-853e-11eb-b258-54ee750ba9b2' name='password' columnName='password' title='密码' type='string' default='' precision='' isArray='false'>
<annotation id='49a99e39-853e-11eb-b258-54ee750ba9b2' attributeId='49a99e3a-853e-11eb-b258-54ee750ba9b2' name='length' value='100'></annotation>
</attribute>
<attribute id='6294310a-853e-11eb-b258-54ee750ba9b2' name='title' columnName='title' title='称呼' type='string' default='' precision='' isArray='false'>
<annotation id='62943111-853e-11eb-b258-54ee750ba9b2' attributeId='62943112-853e-11eb-b258-54ee750ba9b2' name='length' value='100'></annotation>
</attribute>
<attribute id='62943115-853e-11eb-b258-54ee750ba9b2' name='code' columnName='code' title='编号' type='string' default='' precision='' isArray='false'>
<annotation id='62943119-853e-11eb-b258-54ee750ba9b2' attributeId='6294311a-853e-11eb-b258-54ee750ba9b2' name='length' value='100'></annotation>
</attribute>
<attribute id='77aa55cb-853e-11eb-b258-54ee750ba9b2' name='type' columnName='type' title='用户类型' type='string' default='' precision='' isArray='false'>
<annotation id='77aa55d2-853e-11eb-b258-54ee750ba9b2' attributeId='77aa55d3-853e-11eb-b258-54ee750ba9b2' name='length' value='100'></annotation>
</attribute>
<attribute id='77aa55d6-853e-11eb-b258-54ee750ba9b2' name='telephone' columnName='telephone' title='手机号' type='string' default='' precision='' isArray='false'>
<annotation id='77aa55d7-853e-11eb-b258-54ee750ba9b2' attributeId='77aa55d8-853e-11eb-b258-54ee750ba9b2' name='length' value='20'></annotation>
</attribute>
<attribute id='8f8ad8b3-853e-11eb-b258-54ee750ba9b2' name='org' columnName='org' title='所属组织' type='string' default='' precision='' isArray='false'>
<annotation id='8f8ad8b7-853e-11eb-b258-54ee750ba9b2' attributeId='8f8ad8bb-853e-11eb-b258-54ee750ba9b2' name='length' value='100'></annotation>
</attribute>
<attribute id="8f8ad8bc-853e-11eb-b258-54ee750ba9b2" name="path" columnName='path' title="组织路径" type="string" default="" precision="" isArray="false">
<annotation name="length" value="300" id="8f8ad8be-853e-11eb-b258-54ee750ba9b2" attributeId="8f8ad8bf-853e-11eb-b258-54ee750ba9b2"/>
</attribute>
<attribute id='a4f104b3-853e-11eb-b258-54ee750ba9b2' name='role' columnName='role' title='所属角色' type='string' default='' precision='' isArray='false'>
<annotation id='a4f104be-853e-11eb-b258-54ee750ba9b2' attributeId='a4f104bf-853e-11eb-b258-54ee750ba9b2' name='length' value='100'></annotation>
</attribute>
<attribute id='a4f104c2-853e-11eb-b258-54ee750ba9b2' name='config' columnName='config' title='用户配置' type='string' default='' precision='' isArray='false'>
<annotation id='a4f104c3-853e-11eb-b258-54ee750ba9b2' attributeId='a4f104c4-853e-11eb-b258-54ee750ba9b2' name='length' value='1000'></annotation>
</attribute>
<attribute id='ba5bb842-853e-11eb-b258-54ee750ba9b2' name='description' columnName='description' title='描述' type='string' default='' precision='' isArray='false'>
<annotation id='ba5bb84a-853e-11eb-b258-54ee750ba9b2' attributeId='ba5bb84e-853e-11eb-b258-54ee750ba9b2' name='length' value='1000'></annotation>
</attribute>
<attribute id='ba5bb84f-853e-11eb-b258-54ee750ba9b2' name='state' columnName='state' title='状态' type='string' default='' precision='' isArray='false'>
<annotation id='ba5bb850-853e-11eb-b258-54ee750ba9b2' attributeId='ba5bb851-853e-11eb-b258-54ee750ba9b2' name='length' value='50'></annotation>
</attribute>
<attribute id="d2e9cc29-853e-11eb-b258-54ee750ba9b2" name="discard" title="是否废弃" type="boolean" default="false" precision="" isArray="false">
<annotation name="length" value="undefined" id="d2e9cc35-853e-11eb-b258-54ee750ba9b2" attributeId="d2e9cc36-853e-11eb-b258-54ee750ba9b2"/>
</attribute>
<attribute id="11c46718-8540-11eb-b258-54ee750ba9b2" name="enabled" title="是否启用" type="boolean" default="false" precision="" isArray="false">
<annotation name="length" value="undefined" id="11c46720-8540-11eb-b258-54ee750ba9b2" attributeId="11c46721-8540-11eb-b258-54ee750ba9b2"/>
</attribute>
<attribute id="d2e9cc39-853e-11eb-b258-54ee750ba9b2" name="version" title="version" type="int" default="" precision="" isArray="false">
<annotation name="length" value="undefined" id="d2e9cc3c-853e-11eb-b258-54ee750ba9b2" attributeId="d2e9cc40-853e-11eb-b258-54ee750ba9b2"/>
</attribute>
<attribute id="e955bd08-853e-11eb-b258-54ee750ba9b2" name="creator" title="创建人" type="com.beecode.bap.staff.datamodel.Staff" default="" precision="" isArray="false">
<annotation name="length" value="undefined" id="e955bd14-853e-11eb-b258-54ee750ba9b2" attributeId="e955bd15-853e-11eb-b258-54ee750ba9b2"/>
</attribute>
<attribute id="e955bd18-853e-11eb-b258-54ee750ba9b2" name="createTime" columnName='create_time' title="创建时间" type="datetime" default="" precision="" isArray="false">
<annotation name="length" value="undefined" id="e955bd19-853e-11eb-b258-54ee750ba9b2" attributeId="e955bd1b-853e-11eb-b258-54ee750ba9b2"/>
</attribute>
<attribute id="fd8dbf78-853e-11eb-b258-54ee750ba9b2" name="modifyTime" columnName='modify_time' title="最后修改时间" type="datetime" default="" precision="" isArray="false">
<annotation name="length" value="undefined" id="fd8dbf80-853e-11eb-b258-54ee750ba9b2" attributeId="fd8dbf81-853e-11eb-b258-54ee750ba9b2"/>
</attribute>
<attribute id="fd8dbf84-853e-11eb-b258-54ee750ba9b2" name="modifier" title="修改人" type="com.beecode.bap.staff.datamodel.Staff" default="" precision="" isArray="false">
<annotation name="length" value="undefined" id="fd8dbf85-853e-11eb-b258-54ee750ba9b2" attributeId="fd8dbf87-853e-11eb-b258-54ee750ba9b2"/>
</attribute>
<hibernate>/inz.basis/src/main/resources/config/WarehouseUser.hbm.xml</hibernate>
</dataModel>
</content>
</model>
\ No newline at end of file
...@@ -13,4 +13,5 @@ com.beecode.inz.basis.config.CommonConfig,\ ...@@ -13,4 +13,5 @@ com.beecode.inz.basis.config.CommonConfig,\
com.beecode.inz.basis.config.MessageI18NConfiguration,\ com.beecode.inz.basis.config.MessageI18NConfiguration,\
com.beecode.inz.basis.config.OperationTeamConfig,\ com.beecode.inz.basis.config.OperationTeamConfig,\
com.beecode.inz.basis.config.FunctionTreeConfiguration,\ com.beecode.inz.basis.config.FunctionTreeConfiguration,\
com.beecode.inz.basis.config.CustomerContextConfiguration com.beecode.inz.basis.config.CustomerContextConfiguration,\
com.beecode.inz.basis.config.ContextConfiguration
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.beecode.cn/schema/amino-metadata" xmlns:m="http://www.beecode.cn/schema/bcp-type">
<specification>1.0</specification>
<id>2ea32765-853e-11eb-b258-54ee750ba9b2</id>
<name>com.beecode.inz.basis.datamodel.WarehouseUser</name>
<title>场站用户</title>
<define>bcp.type.Class</define>
<define-version>1.0</define-version>
<dependency>bcp.type.constraint.StringLength</dependency>
<dependency>com.beecode.bap.staff.datamodel.Staff</dependency>
<content>
<m:class>
<m:parents/>
<m:attributes>
<m:attribute>
<m:annotations/>
<m:id>2ea327a9-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>id</m:name>
<m:title>id</m:title>
<m:type>uuid</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>50</m:value>
</m:annotation>
</m:annotations>
<m:id>49a99e2e-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>username</m:name>
<m:title>用户名</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>100</m:value>
</m:annotation>
</m:annotations>
<m:id>49a99e36-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>password</m:name>
<m:title>密码</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>100</m:value>
</m:annotation>
</m:annotations>
<m:id>6294310a-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>title</m:name>
<m:title>称呼</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>100</m:value>
</m:annotation>
</m:annotations>
<m:id>62943115-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>code</m:name>
<m:title>编号</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>100</m:value>
</m:annotation>
</m:annotations>
<m:id>77aa55cb-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>type</m:name>
<m:title>用户类型</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>20</m:value>
</m:annotation>
</m:annotations>
<m:id>77aa55d6-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>telephone</m:name>
<m:title>手机号</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>100</m:value>
</m:annotation>
</m:annotations>
<m:id>8f8ad8b3-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>org</m:name>
<m:title>所属组织</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>300</m:value>
</m:annotation>
</m:annotations>
<m:id>8f8ad8bc-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>path</m:name>
<m:title>组织路径</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>100</m:value>
</m:annotation>
</m:annotations>
<m:id>a4f104b3-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>role</m:name>
<m:title>所属角色</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>1000</m:value>
</m:annotation>
</m:annotations>
<m:id>a4f104c2-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>config</m:name>
<m:title>用户配置</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>1000</m:value>
</m:annotation>
</m:annotations>
<m:id>ba5bb842-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>description</m:name>
<m:title>描述</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>50</m:value>
</m:annotation>
</m:annotations>
<m:id>ba5bb84f-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>state</m:name>
<m:title>状态</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>d2e9cc29-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>discard</m:name>
<m:title>是否废弃</m:title>
<m:type>boolean</m:type>
<m:description></m:description>
<m:default>false</m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>11c46718-8540-11eb-b258-54ee750ba9b2</m:id>
<m:name>enabled</m:name>
<m:title>是否启用</m:title>
<m:type>boolean</m:type>
<m:description></m:description>
<m:default>false</m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>d2e9cc39-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>version</m:name>
<m:title>version</m:title>
<m:type>int</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>e955bd08-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>creator</m:name>
<m:title>创建人</m:title>
<m:type>com.beecode.bap.staff.datamodel.Staff</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>e955bd18-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>createTime</m:name>
<m:title>创建时间</m:title>
<m:type>datetime</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>fd8dbf78-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>modifyTime</m:name>
<m:title>最后修改时间</m:title>
<m:type>datetime</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>fd8dbf84-853e-11eb-b258-54ee750ba9b2</m:id>
<m:name>modifier</m:name>
<m:title>修改人</m:title>
<m:type>com.beecode.bap.staff.datamodel.Staff</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
</m:attributes>
</m:class>
</content>
</metadata>
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping
http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd">
<class entity-name="com.beecode.inz.basis.datamodel.WarehouseUser" table="xyst_dinas_basis_warehouse_user" optimistic-lock="version">
<tuplizer entity-mode="dynamic-map" class="com.beecode.bcp.store.hibernate.KObjectEntityTuplizer"/>
<id name="id" type="uuid-binary">
<column name="id" length="16"/>
<generator class="uuid2" />
</id>
<version name="version" type="long" column="version"></version>
<property name="username" type="string" >
<column name="username" length="50" unique="true"></column>
</property>
<property name="password" type="string" >
<column name="password" length="100"></column>
</property>
<property name="title" type="string" >
<column name="title" length="100"></column>
</property>
<property name="code" type="string" >
<column name="code" length="100" unique="true"></column>
</property>
<property name="type" type="string" >
<column name="type" length="100"></column>
</property>
<property name="telephone" type="string" >
<column name="telephone" length="20"></column>
</property>
<property name="org" type="string" >
<column name="org" length="100"></column>
</property>
<property name="path" type="string" >
<column name="path" length="100"></column>
</property>
<property name="role" type="string" >
<column name="role" length="100"></column>
</property>
<property name="config" type="text" >
<column name="config"></column>
</property>
<property name="description" type="text">
<column name="description" />
</property>
<property name="state" type="string" >
<column name="state" length="50"></column>
</property>
<property name="discard" type="boolean" >
<column name="discard" />
</property>
<property name="enabled" type="boolean" >
<column name="enabled" />
</property>
<property name="createTime" type="timestamp">
<column name="create_time" />
</property>
<many-to-one name="creator" entity-name="com.beecode.bap.staff.datamodel.Staff" fetch="select">
<column name="creator_id" not-null="false"/>
</many-to-one>
<property name="modifyTime" type="timestamp">
<column name="modify_time" />
</property>
<many-to-one name="modifier" entity-name="com.beecode.bap.staff.datamodel.Staff" fetch="select">
<column name="modifier_id" not-null="false"/>
</many-to-one>
</class>
</hibernate-mapping>
\ No newline at end of file
...@@ -24,15 +24,15 @@ public class ApiSecurityHandle { ...@@ -24,15 +24,15 @@ public class ApiSecurityHandle {
private final Logger log = LoggerFactory.getLogger(ApiSecurityHandle.class); private final Logger log = LoggerFactory.getLogger(ApiSecurityHandle.class);
//签名 //签名
@Value("${rongtong.api.apiSecret:null}") // @Value("${rongtong.api.apiSecret:null}")
private String API_SECRET; private String API_SECRET;
//请求超时时间,单位:分钟 //请求超时时间,单位:分钟
@Value("${rongtong.api.timestampExpire:0}") // @Value("${rongtong.api.timestampExpire:0}")
private Integer TIMESTAMP_TIME_OUT_MINUTE; private Integer TIMESTAMP_TIME_OUT_MINUTE;
//开启签名验证 //开启签名验证
@Value("${rongtong.api.signVerify:false}") // @Value("${rongtong.api.signVerify:false}")
private boolean SIGN_VERIFY; private boolean SIGN_VERIFY;
//请求头签名 //请求头签名
......
package com.beecode.inz.common.util; package com.beecode.inz.common.util;
import com.google.gson.Gson; import java.text.SimpleDateFormat;
import com.google.gson.GsonBuilder; import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonUtil { public class JsonUtil {
private static final Logger log = LoggerFactory.getLogger(JsonUtil.class);
public static final Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd HH:mm:ss") private static ObjectMapper objectMapper = new ObjectMapper();
.create();
static {
/** // //该属性设置主要是将对象的所有字段全部列入,若有特殊需求,可以进入JsonSerialize.Inclusion该枚举类查看
* json字符串转成对应的class object // objectMapper.setSerializationInclusion(JsonSerialize.Inclusion.ALWAYS);
* @param jsonText //
* @param classz // //该属性设置主要是取消将对象的时间默认转换timesstamps(时间戳)形式
* @return // objectMapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,
*/ // false);
public static <T> T jsonToBean(String jsonText, Class<T> classz) { //
return gson.fromJson(jsonText, classz); // //该属性设置主要是将忽略空bean转json错误
// objectMapper.configure(MapperFeature.Feature.FAIL_ON_EMPTY_BEANS,
// false);
// 。
// 忽略在json字符串中存在,在java类中不存在字段,防止错误
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// 设置转时间的格式
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
}
public static <T> String beanToJson(T obj) {
if (obj == null) {
return null;
}
try {
return obj instanceof String ? (String) obj : objectMapper.writeValueAsString(obj);
} catch (Exception e) {
log.warn("obj To json is error", e);
return null;
}
}
public static <T> T jsonToBean(String json, Class<T> clazz) {
if (StringUtils.isEmpty(json) || clazz == null) {
return null;
}
try {
return objectMapper.readValue(json, clazz);
} catch (Exception e) {
log.warn("json To obj is error", e);
return null;
}
}
public static <T, E> Map<T, E> jsonToMap(String json, Class<T> clazz, Class<E> claze) {
Map<T, E> map = null;
if (StringUtils.isNotEmpty(json)) {
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(Map.class, clazz, claze);
try {
map = objectMapper.readValue(json, javaType);
} catch (Exception e) {
log.warn("{}", e);
}
}
return map != null ? map : new ConcurrentHashMap<>();
} }
/** public static <T> List<T> jsonToList(String jsonArray, Class<T> clazz) {
* 对象to json字符串 List<T> list = null;
* @param t if (StringUtils.isNotEmpty(jsonArray)) {
* @return JavaType javaType = objectMapper.getTypeFactory().constructParametricType(ArrayList.class, clazz);
*/ try {
public static String toJsonString(Object obj) { list = objectMapper.readValue(jsonArray, javaType);
return gson.toJson(obj); } catch (Exception e) {
log.warn("{}", e);
}
}
return list != null ? list : new ArrayList<>();
} }
} }
\ No newline at end of file
...@@ -32,32 +32,32 @@ import com.google.gson.JsonSyntaxException; ...@@ -32,32 +32,32 @@ import com.google.gson.JsonSyntaxException;
@RestController @RestController
@RequestMapping(value ="/common/",consumes="application/json") @RequestMapping(value ="/common/",consumes="application/json")
public class MessageInfoController { public class MessageInfoController {
@Autowired @Autowired
private MessageInfoService messageInfoService; private MessageInfoService messageInfoService;
@Autowired @Autowired
private HttpServletRequest request; private HttpServletRequest request;
@Value("${rongtong.customer}") // @Value("${rongtong.customer}")
private boolean isCustomer; private boolean isCustomer;
private Logger logger=LoggerFactory.getLogger(MessageInfoController.class); private Logger logger=LoggerFactory.getLogger(MessageInfoController.class);
private final static String READ = "read"; private final static String READ = "read";
private final static String TYPE = "type"; private final static String TYPE = "type";
private final static String READ_COUNT = "readCount"; private final static String READ_COUNT = "readCount";
private final static String NO_READ_COUNT = "noreadCount"; private final static String NO_READ_COUNT = "noreadCount";
private final static String IS_QUERY = "isQuery"; private final static String IS_QUERY = "isQuery";
/** /**
* 根据用户的id和消息类型来获取提醒消息 * 根据用户的id和消息类型来获取提醒消息
* @param partId * @param partId
* @return * @return
* @throws Exception * @throws Exception
*/ */
// @RequestMapping(value ="message/query/{type}",method = RequestMethod.GET) // @RequestMapping(value ="message/query/{type}",method = RequestMethod.GET)
// public Object ListRemindMessageInfoByUserId(@PathVariable("type") String type) throws Exception { // public Object ListRemindMessageInfoByUserId(@PathVariable("type") String type) throws Exception {
...@@ -69,10 +69,10 @@ public class MessageInfoController { ...@@ -69,10 +69,10 @@ public class MessageInfoController {
// List<KObject> list = messageInfoService.ListMessagesByUserIdAndType(userId, type); // List<KObject> list = messageInfoService.ListMessagesByUserIdAndType(userId, type);
// return list.stream().map(KObject::toValueMap).collect(Collectors.toList()); // return list.stream().map(KObject::toValueMap).collect(Collectors.toList());
// } // }
/** /**
* 获取所有消息类型及对应未读消息数量(当前用户) * 获取所有消息类型及对应未读消息数量(当前用户)
* @throws Exception * @throws Exception
*/ */
@RequestMapping(value = "message/types",method = RequestMethod.GET) @RequestMapping(value = "message/types",method = RequestMethod.GET)
public Object getTypesAndNoreadCount() throws Exception{ public Object getTypesAndNoreadCount() throws Exception{
...@@ -94,7 +94,7 @@ public class MessageInfoController { ...@@ -94,7 +94,7 @@ public class MessageInfoController {
}; };
return new JSONArray(types).toString(); return new JSONArray(types).toString();
} }
private void add(List<Map<String,Object>> list,Map<String,Object> e){ private void add(List<Map<String,Object>> list,Map<String,Object> e){
if(!(boolean)e.get(IS_QUERY)){ if(!(boolean)e.get(IS_QUERY)){
e.remove(IS_QUERY); e.remove(IS_QUERY);
...@@ -110,13 +110,13 @@ public class MessageInfoController { ...@@ -110,13 +110,13 @@ public class MessageInfoController {
e.remove(IS_QUERY); e.remove(IS_QUERY);
list.add(e); list.add(e);
} }
/** /**
* 根据当前用户的id和消息类型获取未读消息数量 * 根据当前用户的id和消息类型获取未读消息数量
* @param partId * @param partId
* @return * @return
* @throws Exception * @throws Exception
*/ */
@RequestMapping(value ="message/noread/count",method = RequestMethod.GET) @RequestMapping(value ="message/noread/count",method = RequestMethod.GET)
public Object countNoReadByUserIdAndType(@RequestParam String type) throws Exception { public Object countNoReadByUserIdAndType(@RequestParam String type) throws Exception {
...@@ -124,7 +124,7 @@ public class MessageInfoController { ...@@ -124,7 +124,7 @@ public class MessageInfoController {
String count = messageInfoService.countNoReadByUserIdAndType(userId, type); String count = messageInfoService.countNoReadByUserIdAndType(userId, type);
return count; return count;
} }
/** /**
* 一键已读 * 一键已读
*/ */
...@@ -133,8 +133,8 @@ public class MessageInfoController { ...@@ -133,8 +133,8 @@ public class MessageInfoController {
String userId = MessageUtils.gerCurrentUserId(isCustomer); String userId = MessageUtils.gerCurrentUserId(isCustomer);
messageInfoService.readAll(userId, type); messageInfoService.readAll(userId, type);
} }
/** /**
* 根据消息的id更改消息的状态为已读 * 根据消息的id更改消息的状态为已读
* @param partId * @param partId
...@@ -150,12 +150,12 @@ public class MessageInfoController { ...@@ -150,12 +150,12 @@ public class MessageInfoController {
default: default:
throw new UnsupportedOperationException("operation: " + operation); throw new UnsupportedOperationException("operation: " + operation);
} }
} }
/** /**
* 获取指定消息类型指定页的消息-已读未读都包含,未读在前面 * 获取指定消息类型指定页的消息-已读未读都包含,未读在前面
* @throws Exception * @throws Exception
*/ */
@RequestMapping(value ="messages/query",method = RequestMethod.POST) @RequestMapping(value ="messages/query",method = RequestMethod.POST)
public Object queryByPaging(@RequestBody String body) throws Exception{ public Object queryByPaging(@RequestBody String body) throws Exception{
...@@ -179,7 +179,7 @@ public class MessageInfoController { ...@@ -179,7 +179,7 @@ public class MessageInfoController {
} }
return messageInfos; return messageInfos;
} }
/** /**
* 通过角色,消息要素,发送消息 * 通过角色,消息要素,发送消息
*/ */
......
...@@ -10,4 +10,5 @@ include "inz.message" ...@@ -10,4 +10,5 @@ include "inz.message"
include "inz.query" include "inz.query"
include "inz.workflow" include "inz.workflow"
include "xyst.dinas.oa" include "xyst.dinas.oa"
include "xyst.dinas.biz"
dependencies {
compile lib.bcp_import
compile lib.bcp_type
compile lib.bcp_store
compile lib.hibernate_core
compile lib.spring_web
compile lib.spring_boot_autoconfigure
compile lib.jackson_datatype_jdk8
compile lib.jackson_datatype_jsr310
compile lib.json
compile "com.beecode:bap2.participant:${aminoVersion}"
compile "com.beecode:bcp.org:${aminoVersion}"
compile "com.beecode:bap2.department:${aminoVersion}"
compile "com.beecode:bap2.staff:${aminoVersion}"
compile 'com.deepoove:poi-tl:1.5.0'
compile project(":inz.common")
compile project(":inz.query")
compile project(":inz.workflow")
compile project(":inz.basis")
testCompile lib.amino_boot_web
testCompile lib.mysql_connector
}
package com.xyst.dinas.biz.config;
import com.beecode.amino.metadata.runtime.MetadataMech;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.TypeConstants;
import com.xyst.dinas.biz.constant.StationConstant;
import com.xyst.dinas.biz.internal.StationInfoQueryProcessor;
import com.xyst.dinas.biz.internal.dao.StationDaoImpl;
import com.xyst.dinas.biz.internal.service.StationServiceImpl;
import com.xyst.dinas.biz.web.StationController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import com.xyst.dinas.biz.dao.PositionDao;
import com.xyst.dinas.biz.internal.StationInfoQueryProcessor;
import com.xyst.dinas.biz.internal.dao.PositionDaoImpl;
import com.xyst.dinas.biz.internal.service.PositionServiceImpl;
import com.xyst.dinas.biz.service.PositionService;
import com.xyst.dinas.biz.web.PositionController;
import org.springframework.core.io.ClassPathResource;
public class StationConfiguration {
@Bean
public PositionController positionController() {
return new PositionController();
}
@Bean
public PositionService positionService() {
return new PositionServiceImpl();
}
@Bean
public PositionDao positionDao() {
return new PositionDaoImpl();
}
@Bean("com.xyst.dinas.biz.internal.StationInfoQueryProcessor")
public StationInfoQueryProcessor createStationInfoQueryProcessor() {
return new StationInfoQueryProcessor();
}
@Autowired
@Qualifier(TypeConstants.CLASS_MECH)
private MetadataMech<KClass> typeMech;
//StationDaoImpl相关bean配置
@Bean
public StationDaoImpl stationDaoImpl() {
return new StationDaoImpl();
}
@Bean
public StationServiceImpl stationServiceImpl(){
return new StationServiceImpl();
}
@Bean
public StationController stationController(){
return new StationController();
}
@Bean(StationConstant.ENTITY)
public KClass stationInfoEntity() {
return typeMech.createStaticBeanByResource(
new ClassPathResource("/com/xyst/dinas/biz/datamodel/Station.jmx", KClass.class));
}
}
package com.xyst.dinas.biz.constant;
public interface PositionConstant {
/**
* 实体名
*/
String ENTITY = "com.xyst.dinas.biz.datamodel.Position";
String STAFF = "com.beecode.bap.staff.datamodel.Staff";
}
package com.xyst.dinas.biz.constant;
public interface StationConstant {
/**
*
*/
String STATION = "com.xyst.dinas.biz.datamodel.Station";
/**
* 业务类型名称
*/
String BIZ_TYPE = "Station";
/**
* 业务类型标题
*/
String BIZ_TITLE = "场站管理";
/**
* 实体名
*/
String ENTITY = "com.xyst.dinas.biz.datamodel.Station";
}
package com.xyst.dinas.biz.dao;
import java.util.List;
import java.util.UUID;
import com.beecode.bcp.type.KObject;
public interface PositionDao {
void save(KObject kObject);
KObject load(UUID fromString);
void update(KObject kObject);
List<KObject> queryPositionByDept(UUID uuid);
List<KObject> queryStaffByPosition(String name, UUID uuid);
List<KObject> queryPositionByName(String name, UUID uuid);
}
package com.xyst.dinas.biz.dao;
import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.dao.BaseDao;
import java.util.List;
import java.util.UUID;
public interface StationDao extends BaseDao {
KObject load(UUID id);
Page<KObject> listStationInfoPaging(Page<KObject> page);
UUID create(KObject kObject);
int selectCountByName(String stationName);
void deleteById(UUID id);
List<KObject> getByName(String name, UUID id);
void modify(KObject kobject);
}
package com.xyst.dinas.biz.entity;
import java.io.Serializable;
import java.util.Date;
/**
* xyst_dinas_biz_station
* @author scol 2021-03-15
*/
public class Station implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private String id;
/**
* version
*/
private Integer version;
/**
* create_time
*/
private Date createTime;
/**
* creator_id
*/
private String creatorId;
/**
* modify_time
*/
private Date modifyTime;
/**
* modifier_id
*/
private String modifierId;
/**
* del
*/
private String del;
/**
* department
*/
private String department;
/**
* station_name
*/
private String stationName;
/**
* station_address
*/
private String stationAddress;
/**
* station_status
*/
private Integer stationStatus;
/**
* station_coordinate
*/
private String stationCoordinate;
/**
* link_man
*/
private String linkMan;
/**
* opening_date
*/
private Date openingDate;
/**
* telephone
*/
private String telephone;
/**
* reason
*/
private String reason;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreatorId() {
return creatorId;
}
public void setCreatorId(String creatorId) {
this.creatorId = creatorId;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getModifierId() {
return modifierId;
}
public void setModifierId(String modifierId) {
this.modifierId = modifierId;
}
public String getDel() {
return del;
}
public void setDel(String del) {
this.del = del;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getStationName() {
return stationName;
}
public void setStationName(String stationName) {
this.stationName = stationName;
}
public String getStationAddress() {
return stationAddress;
}
public void setStationAddress(String stationAddress) {
this.stationAddress = stationAddress;
}
public Integer getStationStatus() {
return stationStatus;
}
public void setStationStatus(Integer stationStatus) {
this.stationStatus = stationStatus;
}
public String getStationCoordinate() {
return stationCoordinate;
}
public void setStationCoordinate(String stationCoordinate) {
this.stationCoordinate = stationCoordinate;
}
public String getLinkMan() {
return linkMan;
}
public void setLinkMan(String linkMan) {
this.linkMan = linkMan;
}
public Date getOpeningDate() {
return openingDate;
}
public void setOpeningDate(Date openingDate) {
this.openingDate = openingDate;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
}
package com.xyst.dinas.biz.enumeration;
import com.beecode.inz.common.ErrorCode;
public enum BizErrorCodeEnum implements ErrorCode{
POSTITION_NAME_REPEATED("007019001", "岗位名称重复");
private String code;
private String description;
BizErrorCodeEnum(String code, String description) {
this.code = code;
this.description = description;
}
@Override
public String getCode() {
return code;
}
@Override
public String getDescription() {
return description;
}
}
package com.xyst.dinas.biz.internal;
import com.beecode.inz.query.entity.RowData;
import com.beecode.inz.query.processor.DataProcessor;
import com.beecode.inz.query.processor.DataProcessorContext;
import java.util.List;
/**
* @author scol
*/
public class StationInfoQueryProcessor implements DataProcessor {
@Override
public void process(DataProcessorContext context) {
List<RowData> rowDatas = context.getRowDatas();
for (RowData rowData : rowDatas) {
Object stationStatus = rowData.get("stationStatus");
String stationStatusShowName = "";
if("0".equals(stationStatus)){
stationStatusShowName="已停业";
}else if ("1".equals(stationStatus)){
stationStatusShowName="经营中";
}
rowData.put("stationStatusShowName",stationStatusShowName);
}
}
}
package com.xyst.dinas.biz.internal.dao;
import java.util.List;
import java.util.UUID;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateCallback;
import org.springframework.orm.hibernate5.HibernateOperations;
import com.beecode.bcp.type.KObject;
import com.xyst.dinas.biz.constant.PositionConstant;
import com.xyst.dinas.biz.dao.PositionDao;
public class PositionDaoImpl implements PositionDao, PositionConstant {
@Autowired
private HibernateOperations template;
@Override
public void save(KObject kObject) {
template.save(kObject);
}
@Override
public KObject load(UUID id) {
return (KObject) template.get(ENTITY, id);
}
@Override
public void update(KObject kObject) {
template.update(kObject);
}
@Override
public List<KObject> queryPositionByDept(UUID id) {
return (List<KObject>)template.execute(new HibernateCallback<List<KObject>>() {
@SuppressWarnings("unchecked")
@Override
public List<KObject> doInHibernate(Session session) throws HibernateException {
Query<KObject> query = session.createQuery("from "+ ENTITY + " where (discard is null or discard = 0) and regionalCompany.id =:id", KObject.class);
query.setParameter("id", id);
return query.getResultList();
}
});
}
@Override
public List<KObject> queryStaffByPosition(String name, UUID departmentId) {
return (List<KObject>)template.execute(new HibernateCallback<List<KObject>>() {
@SuppressWarnings("unchecked")
@Override
public List<KObject> doInHibernate(Session session) throws HibernateException {
Query<KObject> query = session.createQuery("from " + STAFF + " where duty =:name and department.id=:departmentId ", KObject.class);
query.setParameter("name", name);
query.setParameter("departmentId", departmentId);
return query.getResultList();
}
});
}
@Override
public List<KObject> queryPositionByName(String name, UUID deptId) {
return (List<KObject>)template.execute(new HibernateCallback<List<KObject>>() {
@SuppressWarnings("unchecked")
@Override
public List<KObject> doInHibernate(Session session) throws HibernateException {
Query<KObject> query = session.createQuery("from " + ENTITY + " where (discard is null or discard = 0) and name =:name and regionalCompany.id = :deptId ", KObject.class);
query.setParameter("name", name);
query.setParameter("deptId", deptId);
return query.getResultList();
}
});
}
}
package com.xyst.dinas.biz.internal.dao;
import com.beecode.amino.core.Amino;
import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.core.context.AminoContextHolder;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.internal.dao.AbstractBaseDao;
import com.xyst.dinas.biz.constant.StationConstant;
import com.xyst.dinas.biz.dao.StationDao;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateOperations;
import org.springframework.orm.hibernate5.HibernateTemplate;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class StationDaoImpl extends AbstractBaseDao implements StationDao, StationConstant {
@Autowired
private HibernateOperations operations;
@Autowired
private HibernateTemplate template;
@Override
public KObject load(UUID id) {
return (KObject) template.load(ENTITY, id);
}
@Override
public Page<KObject> listStationInfoPaging(Page<KObject> page) {
UUID departmentId = AminoContextHolder.getContext().getStaff().get("department").getUuid("id");
KClass bean = Amino.getStaticMetadataContext().getBean(StationConstant.ENTITY, KClass.class);
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
detachedCriteria.add(Restrictions.eq("department.id", departmentId));
detachedCriteria.add(Restrictions.eq("del", false));
int offset = page.getPageSize() * (page.getPageNo() - 1);
List<KObject> list = (List<KObject>) template.findByCriteria(detachedCriteria,offset,page.getPageSize());
page.setDatas(list);
page.setTotal(template.findByCriteria(detachedCriteria).size());
return page;
}
@Override
public List<KObject> getByName(String name, UUID id) {
UUID departmentId = AminoContextHolder.getContext().getStaff().get("department").getUuid("id");
KClass bean = Amino.getStaticMetadataContext().getBean(StationConstant.ENTITY, KClass.class);
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
detachedCriteria.add(Restrictions.eq("department.id", departmentId));
detachedCriteria.add(Restrictions.eq("del", false));
detachedCriteria.add(Restrictions.eq("stationName", name));
if(id!=null){
detachedCriteria.add(Restrictions.ne("id", id));
}
return (List<KObject>) template.findByCriteria(detachedCriteria);
}
@Override
public void modify(KObject kobject) {
KObject id = load(kobject.getUuid("id"));
kobject.set("creator",id.get("creator"));
kobject.set("createTime",id.getDate("createTime"));
KObject staff = AminoContextHolder.getContext().getStaff();
kobject.set("modifyTime",new Date());
kobject.set("modifier",staff.getUuid("id"));
kobject.set("del",true);
template.merge(kobject);
}
@Override
public UUID create(KObject kObject) {
KObject staff = AminoContextHolder.getContext().getStaff();
kObject.set("department", staff.get("department"));
kObject.set("id",UUID.randomUUID());
kObject.set("creator",staff);
kObject.set("createTime", new Date());
kObject.set("del",false);
return ((UUID)template.save(kObject));
}
@Override
public int selectCountByName(String stationName) {
String departmentId = AminoContextHolder.getContext().getStaff().get("department").getUuid("id").toString();
return 0;
}
@Override
public void deleteById(UUID id) {
KObject staff = AminoContextHolder.getContext().getStaff();
KObject kobject = (KObject) template.load(STATION, id);
kobject.set("modifyTime",new Date());
kobject.set("modifier.id",staff.getUuid("id"));
kobject.set("del",true);
template.update(kobject);
}
/**
* 抽象方法,需要实现类提供HibernateTemplate
*
* @return HibernateTemplate
*/
@Override
protected HibernateTemplate getHibernateTemplate() {
return template;
}
/**
* 抽象方法,需要实现类提供当前ModelName
*
* @return String
*/
@Override
protected String getModelName() {
return StationConstant.ENTITY;
}
}
package com.xyst.dinas.biz.internal.service;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.beecode.amino.core.Amino;
import com.beecode.bap.staff.service.StaffService;
import com.beecode.bcp.core.context.AminoContextHolder;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.xyst.dinas.biz.constant.PositionConstant;
import com.xyst.dinas.biz.dao.PositionDao;
import com.xyst.dinas.biz.service.PositionService;
public class PositionServiceImpl implements PositionService, PositionConstant {
@Autowired
private PositionDao positionDao;
@Autowired
private StaffService staffService;
@Override
@Transactional
public Object saveAndUpdate(JSONObject jsonObject) {
try{
KObject staff = AminoContextHolder.getContext().getStaff();
//当前登录人所在区域公司
KObject department = staff.get("department");
if (jsonObject.isNull("id") || StringUtils.isEmpty(jsonObject.getString("id"))) {
//新建
KClass kClass = Amino.getApplicationMetadataContext().getBean(ENTITY, KClass.class);
KObject kObject = JSONObjectUtils.toObject(jsonObject.toString(), kClass);
kObject.set("id", UUID.randomUUID());
kObject.set("creator", staff);
kObject.set("createTime", new Date());
kObject.set("regionalCompany", department);
positionDao.save(kObject);
} else {
//编辑
KObject kObject = positionDao.load(UUID.fromString(jsonObject.getString("id")));
//如果岗位名称更改,更改已经关联的岗位名称
if (!kObject.getString("name").equals(jsonObject.getString("name"))) {
List<KObject> allStaffByDeptList = staffService.getAllByDept(department.getUuid("id"));
if (allStaffByDeptList.size() > 0 && allStaffByDeptList != null) {
for (int i = 0; i < allStaffByDeptList.size(); i++) {
KObject staffByDept = allStaffByDeptList.get(i);
//如果岗位不为空
if (StringUtils.isNotEmpty(staffByDept.getString("name"))) {
if (kObject.getString("name").equals(staffByDept.getString("duty"))) {
//编辑员工岗位
staffByDept.set("duty", jsonObject.getString("name"));
staffService.modify(staffByDept);
}
}
}
}
}
kObject.set("modifyTime", new Date());
kObject.set("modifier", staff);
kObject.set("name", jsonObject.getString("name"));
kObject.set("description", jsonObject.isNull("description") ? "" : jsonObject.getString("description"));
positionDao.update(kObject);
}
return ResponseObj.success();
} catch(Exception e){
e.printStackTrace();
return ResponseObj.error(e.getMessage());
}
}
@Override
public Object queryPositionByDept() {
KObject staff = AminoContextHolder.getContext().getStaff();
KObject department = staff.get("department");
List<KObject> positionList = positionDao.queryPositionByDept(department.getUuid("id"));
return ResponseObj.success("操作成功", positionList);
}
@Override
public Object queryPositionIsUse(String name) {
KObject staff = AminoContextHolder.getContext().getStaff();
List<KObject> staffList = positionDao.queryStaffByPosition(name, staff.get("department").getUuid("id"));
if (staffList != null && staffList.size() > 0) {
return ResponseObj.error("该岗位已经被使用,不支持删除操作");
}
return ResponseObj.success();
}
@Override
public Boolean verifyPositionName(String name) {
KObject staff = AminoContextHolder.getContext().getStaff();
//当前登录人所在区域公司
KObject department = staff.get("department");
List<KObject> list = positionDao.queryPositionByName(name, department.getUuid("id"));
Boolean flag = false;
if (list != null && list.size() > 0 ) {
flag = true;
}
return flag;
}
}
package com.xyst.dinas.biz.internal.service;
import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.type.KObject;
import com.xyst.dinas.biz.dao.StationDao;
import com.xyst.dinas.biz.service.StationService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.UUID;
@Transactional(rollbackFor = Exception.class)
public class StationServiceImpl implements StationService {
@Autowired
private StationDao stationDao;
@Override
public Page<KObject> queryByPaging(Page<KObject> page) throws Exception {
if(page.getPageNo()==0||page.getPageSize()==0) {
throw new Exception("pageSize or offset is null");
}
return stationDao.listStationInfoPaging(page);
}
@Override
public UUID addStation(KObject kObject) {
return stationDao.create(kObject);
}
@Override
public KObject getById(UUID id) {
return stationDao.load(id);
}
@Override
public int selectCountByName(String stationName) {
return stationDao.selectCountByName(stationName);
}
@Override
public KObject getByName(String name, UUID id) {
List<KObject> kObjects = stationDao.getByName(name,id);
if(CollectionUtils.isEmpty(kObjects)){
return null;
}
return kObjects.get(0);
}
@Override
public void update(KObject kobject) {
stationDao.modify(kobject);
}
@Override
public void deleteById(UUID id) {
stationDao.deleteById(id);
}
}
package com.xyst.dinas.biz.service;
import java.util.UUID;
import org.json.JSONObject;
public interface PositionService {
Object saveAndUpdate(JSONObject jsonObject);
Object queryPositionByDept();
Object queryPositionIsUse(String name);
Boolean verifyPositionName(String name);
}
package com.xyst.dinas.biz.service;
import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.type.KObject;
import java.util.UUID;
public interface StationService {
Page<KObject> queryByPaging(Page<KObject> page) throws Exception;
UUID addStation(KObject kObject);
KObject getById(UUID id);
int selectCountByName(String stationName);
KObject getByName(String name, UUID id);
void update(KObject kobject);
void deleteById(UUID id);
}
package com.xyst.dinas.biz.web;
import java.util.UUID;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.inz.common.exception.BusinessException;
import com.xyst.dinas.biz.enumeration.BizErrorCodeEnum;
import com.xyst.dinas.biz.service.PositionService;
@RestController
public class PositionController {
@Autowired
private PositionService positionService;
@ResponseBody
@RequestMapping(value = "/biz/position/saveAndUpdate", method = RequestMethod.POST, consumes = "application/json")
public Object saveAndUpdate(@RequestBody String body) {
return positionService.saveAndUpdate(new JSONObject(body));
}
/**
* @Description: 根据当前登录人部门查询岗位
* @param id
* @return return_type
* @throws
*/
@ResponseBody
@RequestMapping(value = "/biz/position/queryPositionByDept", method = RequestMethod.GET)
public Object queryPositionByDept() {
return positionService.queryPositionByDept();
}
/**
* @Description: 根据id查询员工是否关联该岗位
* @param id
* @return return_type
* @throws
*/
@ResponseBody
@RequestMapping(value = "/biz/position/queryPositionIsUse/{name}", method = RequestMethod.GET)
public Object queryPositionIsUse(@PathVariable("name") String name) {
return positionService.queryPositionIsUse(name);
}
/**
* @Description: 岗位名称校验重复
* @param id
* @return return_type
* @throws
*/
@ResponseBody
@RequestMapping(value = "/biz/position/verifyPositionName", method = RequestMethod.GET)
public Object verifyPositionName(@RequestParam("name") String name) {
Boolean flag = positionService.verifyPositionName(name);
if (flag) {
//throw new BusinessException("岗位名称重复", BizErrorCodeEnum.POSTITION_NAME_REPEATED);
//throw new RuntimeException("岗位名称重复");
return ResponseObj.error("岗位名称重复");
}
return null;
}
}
package com.xyst.dinas.biz.web;
import com.beecode.amino.core.Amino;
import com.beecode.bap.attachment.common.Page;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.basis.team.entity.OperationTeam;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.inz.message.internal.QueryParam;
import com.beecode.inz.message.remind.RemindSettingsInfo;
import com.beecode.inz.workflow.constants.InzWorkflowDefinitionConstants;
import com.beecode.nlib.utils.StringUtils;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.xyst.dinas.biz.constant.StationConstant;
import com.xyst.dinas.biz.entity.Station;
import com.xyst.dinas.biz.service.StationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.UUID;
/**
* @author scol
*/
@RestController()
@RequestMapping(value="/biz/stationInfo")
public class StationController {
private static final Logger logger = LoggerFactory.getLogger(StationController.class);
@Autowired
private StationService stationService;
@RequestMapping(value = "list/page", method = RequestMethod.GET)
public Page<KObject> getStaffByRole(
@RequestParam(name = "pageNo", required = false) Integer pageNo,
@RequestParam(name = "pageSize", required = false) Integer pageSize) throws Exception {
Page<KObject> objectPage = new Page<>();
objectPage.setPageNo(pageNo);
objectPage.setPageSize(pageSize);
return stationService.queryByPaging(objectPage);
}
/**
* 新建场站
* @param body
* @return ResponseObj
*/
@PostMapping
public ResponseObj create(@RequestBody String body){
KObject kobject = JSONObjectUtils.toObject(body,Amino.getApplicationMetadataContext().getBean(StationConstant.ENTITY, KClass.class));
if(StringUtils.isEmpty(kobject.getString("stationName"))){
return ResponseObj.error(400,"场站名称不能为空");
}
if(StringUtils.isEmpty(kobject.getString("stationAddress"))){
return ResponseObj.error(400,"场站地址不能为空");
}
if(StringUtils.isEmpty(kobject.getString("stationCoordinate"))){
return ResponseObj.error(400,"坐标点不能为空");
}
if(StringUtils.isEmpty(kobject.getString("linkMan"))){
return ResponseObj.error(400,"联系人不能为空");
}
if(StringUtils.isEmpty(kobject.getString("telephone"))){
return ResponseObj.error(400,"联系人电话不能为空");
}
UUID id = stationService.addStation(kobject);
return ResponseObj.success("保存成功", id);
}
/**
* 修改场站
* @param body 场站json
* @return
*/
@PutMapping
public ResponseObj update(@RequestBody String body){
KObject kobject = JSONObjectUtils.toObject(body,Amino.getApplicationMetadataContext().getBean(StationConstant.ENTITY, KClass.class));
if(StringUtils.isEmpty(kobject.getString("stationName"))){
return ResponseObj.error(400,"场站名称不能为空");
}
if(StringUtils.isEmpty(kobject.getString("stationAddress"))){
return ResponseObj.error(400,"场站地址不能为空");
}
if(StringUtils.isEmpty(kobject.getString("stationCoordinate"))){
return ResponseObj.error(400,"坐标点不能为空");
}
if(StringUtils.isEmpty(kobject.getString("linkMan"))){
return ResponseObj.error(400,"联系人不能为空");
}
if(StringUtils.isEmpty(kobject.getString("telephone"))){
return ResponseObj.error(400,"联系人电话不能为空");
}
if(kobject.getUuid("id") == null){
return ResponseObj.error(400,"'id' must be not null!");
}
stationService.update(kobject);
return ResponseObj.success("修改成功");
}
/**
* 根据id获取场站
* @param id
* @return
*/
@GetMapping("/{id}")
public ResponseObj<Object> getById(@PathVariable("id") UUID id){
if(id == null){
return ResponseObj.error(400,"'id' must be not null!");
}
KObject station = stationService.getById(id);
return ResponseObj.success("修改成功",station);
}
/**
* 根据Id删除场站
* @param id
* @return
*/
@DeleteMapping("/{id}")
public ResponseObj<Object> deleteMemberByStaffId(@PathVariable("id") UUID id){
if(id == null){
return ResponseObj.error(400,"'id' must be not null!");
}
stationService.deleteById(id);
return ResponseObj.success("删除成功");
}
/**
* 查询是否有重名
* @param name
* @return
*/
@GetMapping("/validateName")
public ResponseObj<Object> validateName(@RequestParam("name") String name,@RequestParam("id") UUID id){
if(StringUtils.isEmpty(name)){
return ResponseObj.error(400,"场站名称不能为空");
}
KObject kObject = stationService.getByName(name,id);
if(kObject != null){
return ResponseObj.error("场站名称已存在!");
}
return ResponseObj.success();
}
}
\ No newline at end of file
<model>
<header>
<type>bcp.biz.Bill</type>
<package>com.xyst.dinas.biz.bill</package>
<title>岗位</title>
<name>Position</name>
<description>岗位</description>
</header>
<content>
<bill>
<data>
{"baseData":{"name":"Position","title":"岗位","billModel":"com.beecode.bap.biztrait.BasicBillBiztrait","functionLibrarys":[],"description":"岗位","dataModel":"com.xyst.dinas.biz.datamodel.Position"},"serial":{"serialData":[{"segment":"literal","segmentData":"EM"},{"segment":"sequence","segmentData":{"start-with":0,"increment":1,"min":0,"max":99999,"length":5,"cycle":true,"cut-direction":"left","pad-string":"0","pad-direction":"left","cache-size":10}}],"buildTime":"add"},"formula":[],"workflow":{"workflow":"","processParamConfig":[]},"print":[],"authority":[]}
</data>
</bill>
</content>
</model>
\ No newline at end of file
<model>
<header>
<type>bcp.type.DataModel</type>
<package>com.xyst.dinas.biz.datamodel</package>
<title>岗位</title>
<name>Position</name>
<tags></tags>
<description>岗位</description>
<templateName>mk.ide.ui.editor.data.model.template.bill</templateName>
<tablePrefix>xyst_dinas_</tablePrefix>
</header>
<content>
<dataModel id='235230b3-0e48-46b9-bc48-07e750f16722' multiVersion='' domainInherit='undefined' tableName='xyst_dinas_position'>
<parent>com.beecode.bap.biztrait.datamodel.BasicBillRequirement</parent>
<parent>com.beecode.inz.common.datamodel.BaseInfo</parent>
<attribute id='c4154a1b-f727-48cf-9ef0-ad1bee512504' name='regionalCompany' columnName='regional_company' title='区域公司' type='com.beecode.bap.department.datamodel.Department' default='' precision='' isArray='false'>
<annotation id='00caecc1-35aa-4342-90c8-250f84609fe4' attributeId='55efd3f5-036a-4ac4-83c9-14e22cf5465a' name='length' value='undefined'>
</annotation>
<annotation id='95a6dd6d-c676-4265-9c8b-d115c13b472f' attributeId='43768653-e259-4b0f-8c9d-8739f030675b' name='mappingType' value='many-to-one'>
</annotation>
</attribute>
<attribute id='cbb5b983-299b-4259-97d9-6470651bb18b' name='name' columnName='name' title='岗位名称' type='string' default='' precision='' isArray='false'>
<annotation id='ea154cb8-f939-4e9f-9793-9673d984161f' attributeId='ffc0a199-4038-4ebf-a94f-a0f12bfc76dd' name='length' value='50'>
</annotation>
</attribute>
<attribute id='0933ceb1-f327-4372-a316-cffa1c80991a' name='description' columnName='description' title='描述' type='string' default='' precision='' isArray='false'>
<annotation id='6f08f4ca-1f77-4ed4-a627-0fb8843959fa' attributeId='dfbeaa83-63dc-4638-b55a-8dda62d74dd4' name='length' value='500'>
</annotation>
</attribute>
<hibernate>/xyst.dinas.biz/src/main/resources/config/Position.hbm.xml</hibernate>
</dataModel>
</content>
</model>
\ No newline at end of file
<model>
<header>
<type>inz.query.Query</type>
<package>com.xyst.dinas.biz.query</package>
<name>Position</name>
<title>岗位</title>
<tags></tags>
<description>岗位</description>
</header>
<content>
<customQuery id='241a1768-8db1-4ebe-a299-f07a2a69cca3'>
<kclass>com.xyst.dinas.biz.datamodel.Position</kclass>
<authorityItem>com.xyst.dinas.biz.auth.PositionList</authorityItem>
<innerScene title='全部'>
<id>ff924d2d-ce4b-4acb-a123-211a923a03d8</id>
<javaImplement>com.beecode.inz.common.scene.CommonAllScene</javaImplement>
<defaultExecute></defaultExecute>
<hide></hide>
</innerScene>
<innerScene title='已废弃'>
<id>15aa9bba-a2a7-4fb4-ac74-4477e3429cee</id>
<javaImplement>com.beecode.inz.common.scene.DefaultDiscardScene</javaImplement>
<defaultExecute></defaultExecute>
<hide></hide>
</innerScene>
<field title='id'>
<name>id</name>
<type>uuid</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='区域公司id'>
<name>department.id</name>
<type>uuid</type>
<ref>
<type></type>
<name>com.beecode.bap.department.datamodel.Department</name>
</ref>
<description></description>
</field>
<field title='区域公司名称'>
<name>department.name</name>
<type>string</type>
<ref>
<type></type>
<name>com.beecode.bap.department.datamodel.Department</name>
</ref>
<description></description>
</field>
<field title='创建时间'>
<name>createTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='创建人'>
<name>creator.name</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='修改时间'>
<name>modifyTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='修改人'>
<name>modifier.name</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='废弃'>
<name>discard</name>
<type>boolean</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='名称'>
<name>name</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='描述'>
<name>description</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
</customQuery>
</content>
</model>
\ No newline at end of file
# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.xyst.dinas.biz.config.StationConfiguration
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.beecode.cn/schema/amino-metadata" xmlns:m="http://www.beecode.cn/schema/bcp-sequence">
<specification>1.0</specification>
<id>12eab197-5cc0-4dbf-96ab-eecd0b13232c</id>
<name>com.xyst.dinas.biz.bill.Position$sequence</name>
<title>岗位$sequence</title>
<description>岗位</description>
<define>bcp.sequence</define>
<define-version>1.0</define-version>
<content>
<m:sequence>
<m:start-with>0</m:start-with>
<m:increment>1</m:increment>
<m:max>99999</m:max>
<m:min>0</m:min>
<m:cycle>true</m:cycle>
<m:cache-size>10</m:cache-size>
</m:sequence>
</content>
</metadata>
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.beecode.cn/schema/amino-metadata" xmlns:m="http://www.beecode.cn/schema/bcp-serial">
<specification>1.0</specification>
<id>e54c3a90-a21c-489b-ab55-cda37706e8e5</id>
<name>com.xyst.dinas.biz.bill.Position$serial</name>
<title>岗位$serial</title>
<description>岗位</description>
<define>bcp.serial</define>
<define-version>1.0</define-version>
<dependency>com.xyst.dinas.biz.datamodel.Position</dependency>
<dependency>com.xyst.dinas.biz.bill.Position$sequence</dependency>
<content>
<m:serial>
<m:input>com.xyst.dinas.biz.datamodel.Position</m:input>
<m:functionLibrarys/>
<m:segments>
<m:literal>
<m:value>EM</m:value>
</m:literal>
<m:sequence>
<m:length>5</m:length>
<m:pad-direction>left</m:pad-direction>
<m:pad-string>0</m:pad-string>
<m:key>com.xyst.dinas.biz.bill.Position$serial</m:key>
<m:sequenceName>com.xyst.dinas.biz.bill.Position$sequence</m:sequenceName>
</m:sequence>
</m:segments>
</m:serial>
</content>
</metadata>
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.beecode.cn/schema/amino-metadata" xmlns:m="http://www.beecode.cn/schema/bcp-biztype">
<specification>1.0</specification>
<id>5cd3ab7c-6fab-41f9-9921-780195eb24a2</id>
<name>com.xyst.dinas.biz.bill.Position</name>
<title>岗位</title>
<description>岗位</description>
<define>bcp.biz.Biztype</define>
<define-version>1.0</define-version>
<dependency>com.xyst.dinas.biz.bill.Position$serial</dependency>
<dependency>com.xyst.dinas.biz.datamodel.Position</dependency>
<dependency>com.beecode.bap.biztrait.BasicBillBiztrait</dependency>
<content>
<m:biztype>
<m:type>com.xyst.dinas.biz.datamodel.Position</m:type>
<m:inheritances>
<m:inheritance>
<m:biztrait>com.beecode.bap.biztrait.BasicBillBiztrait</m:biztrait>
<m:config type="xml">
<m:content>&lt;billBasictraitConfig&gt;&lt;formulas/&gt;&lt;parents&gt;&lt;parent&gt;&lt;billCodeConfig&gt;&lt;serialName&gt;com.xyst.dinas.biz.bill.Position$serial&lt;/serialName&gt;&lt;buildTime&gt;add&lt;/buildTime&gt;&lt;/billCodeConfig&gt;&lt;/parent&gt;&lt;parent&gt;&lt;workflowConfig&gt;&lt;workflow&gt;&lt;/workflow&gt;&lt;/workflowConfig&gt;&lt;/parent&gt;&lt;parent&gt;&lt;printConfig&gt;&lt;templates/&gt;&lt;/printConfig&gt;&lt;/parent&gt;&lt;/parents&gt;&lt;functionLibrarys/&gt;&lt;/billBasictraitConfig&gt;</m:content>
</m:config>
</m:inheritance>
</m:inheritances>
<m:methodAuthorityItems/>
</m:biztype>
</content>
</metadata>
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.beecode.cn/schema/amino-metadata" xmlns:m="http://www.beecode.cn/schema/bcp-type">
<specification>1.0</specification>
<id>235230b3-0e48-46b9-bc48-07e750f16722</id>
<name>com.xyst.dinas.biz.datamodel.Position</name>
<title>岗位</title>
<description>岗位</description>
<define>bcp.type.Class</define>
<define-version>1.0</define-version>
<dependency>bcp.type.constraint.StringLength</dependency>
<dependency>com.beecode.inz.common.datamodel.BaseInfo</dependency>
<dependency>com.beecode.bap.biztrait.datamodel.BasicBillRequirement</dependency>
<dependency>com.beecode.bap.department.datamodel.Department</dependency>
<content>
<m:class>
<m:parents>
<m:parent>com.beecode.bap.biztrait.datamodel.BasicBillRequirement</m:parent>
<m:parent>com.beecode.inz.common.datamodel.BaseInfo</m:parent>
</m:parents>
<m:attributes>
<m:attribute>
<m:annotations/>
<m:id>c4154a1b-f727-48cf-9ef0-ad1bee512504</m:id>
<m:name>regionalCompany</m:name>
<m:title>区域公司</m:title>
<m:type>com.beecode.bap.department.datamodel.Department</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>50</m:value>
</m:annotation>
</m:annotations>
<m:id>cbb5b983-299b-4259-97d9-6470651bb18b</m:id>
<m:name>name</m:name>
<m:title>岗位名称</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>500</m:value>
</m:annotation>
</m:annotations>
<m:id>0933ceb1-f327-4372-a316-cffa1c80991a</m:id>
<m:name>description</m:name>
<m:title>描述</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
</m:attributes>
</m:class>
</content>
</metadata>
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.beecode.cn/schema/amino-metadata" xmlns:m="http://www.beecode.cn/schema/bcp-type">
<specification>1.0</specification>
<id>4ce6ac23-0efc-48fd-be06-9f5d284e1ecd</id>
<name>com.xyst.dinas.biz.datamodel.Station</name>
<title>场站管理</title>
<description>场站管理</description>
<define>bcp.type.Class</define>
<define-version>1.0</define-version>
<dependency>bcp.type.constraint.StringLength</dependency>
<dependency>com.beecode.bap.staff.datamodel.Staff</dependency>
<dependency>com.beecode.inz.common.datamodel.BaseInfo</dependency>
<dependency>com.beecode.bap.department.datamodel.Department</dependency>
<dependency>com.beecode.bap.biztrait.datamodel.BasicBillRequirement</dependency>
<content>
<m:class>
<m:parents>
<m:parent>com.beecode.inz.common.datamodel.BaseInfo</m:parent>
<m:parent>com.beecode.bap.biztrait.datamodel.BasicBillRequirement</m:parent>
</m:parents>
<m:attributes>
<m:attribute>
<m:annotations/>
<m:id>454f133a-ec58-46d0-bdc5-2857efac8ee6</m:id>
<m:name>stationName</m:name>
<m:title>场站名称</m:title>
<m:type>string</m:type>
<m:description>场站名称</m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>f4427592-4ea6-4c6c-ab0b-834792e0828f</m:id>
<m:name>stationAddress</m:name>
<m:title>场站地址</m:title>
<m:type>string</m:type>
<m:description>场站地址</m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>19f58e91-61b8-4a8d-a5e0-d530fdf38cf8</m:id>
<m:name>department</m:name>
<m:title>所属部门</m:title>
<m:type>com.beecode.bap.department.datamodel.Department</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>c7e790b4-efc8-4cc4-99f1-324ca09579e7</m:id>
<m:name>stationStatus</m:name>
<m:title>场站状态</m:title>
<m:type>int</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>4957fc36-a43a-48d5-b0b2-4c551d677778</m:id>
<m:name>stationCoordinate</m:name>
<m:title>场站坐标</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>50</m:value>
</m:annotation>
</m:annotations>
<m:id>77d699e5-fb54-417c-98c2-9a950a14b662</m:id>
<m:name>linkMan</m:name>
<m:title>联系人</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>b4211477-b5b7-4036-9814-7e5affff7ea0</m:id>
<m:name>openingDate</m:name>
<m:title>开业时间</m:title>
<m:type>datetime</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>20</m:value>
</m:annotation>
</m:annotations>
<m:id>f77a03a0-6fdb-43a1-9be9-93c8857aae1c</m:id>
<m:name>telephone</m:name>
<m:title>联系电话</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.constraint.StringLength</m:type>
<m:value>300</m:value>
</m:annotation>
</m:annotations>
<m:id>07df337f-d640-4873-8bd7-e0878d56c187</m:id>
<m:name>reason</m:name>
<m:title>备注</m:title>
<m:type>string</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations></m:annotations>
<m:id>bd60d3ff-9308-4f15-aa1e-67d2923192f2</m:id>
<m:name>sort_order</m:name>
<m:title>排序</m:title>
<m:type>int</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
</m:attributes>
</m:class>
</content>
</metadata>
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.beecode.cn/schema/amino-metadata" xmlns:m="http://www.beecode.cn/schema/inz-query">
<specification>1.0</specification>
<id>241a1768-8db1-4ebe-a299-f07a2a69cca3</id>
<name>com.xyst.dinas.biz.query.Position</name>
<title>岗位</title>
<description>岗位</description>
<define>inz.query.Query</define>
<define-version>1.0</define-version>
<dependency>com.xyst.dinas.biz.datamodel.Position</dependency>
<content>
<m:query>
<m:type>com.xyst.dinas.biz.datamodel.Position</m:type>
<m:dataProcessor></m:dataProcessor>
<m:authorityItem>com.xyst.dinas.biz.auth.PositionList</m:authorityItem>
<m:innerScenes>
<m:innerScene>
<m:id>ff924d2d-ce4b-4acb-a123-211a923a03d8</m:id>
<m:title>全部</m:title>
<m:javaImplement>com.beecode.inz.common.scene.CommonAllScene</m:javaImplement>
<m:defaultExecute></m:defaultExecute>
<m:hide></m:hide>
</m:innerScene>
<m:innerScene>
<m:id>15aa9bba-a2a7-4fb4-ac74-4477e3429cee</m:id>
<m:title>已废弃</m:title>
<m:javaImplement>com.beecode.inz.common.scene.DefaultDiscardScene</m:javaImplement>
<m:defaultExecute></m:defaultExecute>
<m:hide></m:hide>
</m:innerScene>
</m:innerScenes>
<m:fields>
<m:field>
<m:name>id</m:name>
<m:title>id</m:title>
<m:type>uuid</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>department.id</m:name>
<m:title>区域公司id</m:title>
<m:type>uuid</m:type>
<m:ref>
<m:name>com.beecode.bap.department.datamodel.Department</m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>department.name</m:name>
<m:title>区域公司名称</m:title>
<m:type>string</m:type>
<m:ref>
<m:name>com.beecode.bap.department.datamodel.Department</m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>createTime</m:name>
<m:title>创建时间</m:title>
<m:type>datetime</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>creator.name</m:name>
<m:title>创建人</m:title>
<m:type>string</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>modifyTime</m:name>
<m:title>修改时间</m:title>
<m:type>datetime</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>modifier.name</m:name>
<m:title>修改人</m:title>
<m:type>string</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>discard</m:name>
<m:title>废弃</m:title>
<m:type>boolean</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>name</m:name>
<m:title>名称</m:title>
<m:type>string</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>description</m:name>
<m:title>描述</m:title>
<m:type>string</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
</m:fields>
</m:query>
</content>
</metadata>
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.beecode.cn/schema/amino-metadata" xmlns:m="http://www.beecode.cn/schema/inz-query">
<specification>1.0</specification>
<id>17949029-14df-48e6-8b8b-383e44383095</id>
<name>com.xyst.dinas.biz.query.StationInfoApply</name>
<title>场站管理</title>
<description>场站管理</description>
<define>inz.query.Query</define>
<define-version>1.0</define-version>
<dependency>com.xyst.dinas.biz.datamodel.Station</dependency>
<content>
<m:query>
<m:type>com.xyst.dinas.biz.datamodel.Station</m:type>
<m:dataProcessor>com.xyst.dinas.biz.internal.StationInfoQueryProcessor</m:dataProcessor>
<m:authorityItem></m:authorityItem>
<m:innerScenes>
<m:innerScene>
<m:id>054ad121-1501-4047-9574-0268bd08ba1b</m:id>
<m:title>全部</m:title>
<m:javaImplement>com.beecode.inz.common.scene.CommonAllScene</m:javaImplement>
<m:defaultExecute></m:defaultExecute>
<m:hide></m:hide>
</m:innerScene>
<m:innerScene>
<m:id>d40d3b3b-5f67-4c96-bed3-3bc186d6433b</m:id>
<m:title>已废弃</m:title>
<m:javaImplement>com.beecode.inz.common.scene.DefaultDiscardScene</m:javaImplement>
<m:defaultExecute></m:defaultExecute>
<m:hide></m:hide>
</m:innerScene>
</m:innerScenes>
<m:fields>
<m:field>
<m:name>id</m:name>
<m:title>id</m:title>
<m:type>uuid</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>stationName</m:name>
<m:title>场站名称</m:title>
<m:type>string</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>stationAddress</m:name>
<m:title>场站地址</m:title>
<m:type>string</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>department.id</m:name>
<m:title>所属部门id</m:title>
<m:type>uuid</m:type>
<m:ref>
<m:name>com.beecode.bap.department.datamodel.Department</m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>department.name</m:name>
<m:title>所属部门名称</m:title>
<m:type>string</m:type>
<m:ref>
<m:name>com.beecode.bap.department.datamodel.Department</m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>createTime</m:name>
<m:title>创建时间</m:title>
<m:type>datetime</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>creator.id</m:name>
<m:title>创建人id</m:title>
<m:type>uuid</m:type>
<m:ref>
<m:name>com.beecode.bap.staff.datamodel.Staff</m:name>
<m:type>数据字典</m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>creator.name</m:name>
<m:title>创建人</m:title>
<m:type>string</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>modifyTime</m:name>
<m:title>修改时间</m:title>
<m:type>datetime</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>modifier.name</m:name>
<m:title>修改人</m:title>
<m:type>string</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>modifier.id</m:name>
<m:title>修改人id</m:title>
<m:type>uuid</m:type>
<m:ref>
<m:name>com.beecode.bap.staff.datamodel.Staff</m:name>
<m:type>数据字典</m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>stationStatus</m:name>
<m:title>场站状态</m:title>
<m:type>int</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
</m:ref>
<m:desc></m:desc>
</m:field>
</m:fields>
</m:query>
</content>
</metadata>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping
http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd">
<class entity-name="com.xyst.dinas.biz.datamodel.Position" table="xyst_dinas_position" optimistic-lock="version">
<tuplizer entity-mode="dynamic-map" class="com.beecode.bcp.store.hibernate.KObjectEntityTuplizer"/>
<id name="id" type="uuid-binary" column="id" length="16">
<generator class="assigned" />
</id>
<version name="version" type="int" column="version"/>
<property name="createTime" type="timestamp" not-null="false">
<column name="create_time"></column>
</property>
<many-to-one name="creator" entity-name="com.beecode.bap.staff.datamodel.Staff" fetch="select">
<column name="creator_id" not-null="false"/>
</many-to-one>
<property name="modifyTime" type="timestamp" not-null="false">
<column name="modify_time"></column>
</property>
<many-to-one name="modifier" entity-name="com.beecode.bap.staff.datamodel.Staff" fetch="select">
<column name="modifier_id" not-null="false"/>
</many-to-one>
<property name="billState" type="nstring" not-null="false">
<column name="bill_state" length="100"></column>
</property>
<many-to-one name="bizProcess" entity-name="com.beecode.bap.workflow.datamodel.BizProcess" fetch="select">
<column name="biz_process_id" not-null="false"/>
</many-to-one>
<property name="billCode" type="nstring" not-null="false">
<column name="bill_code" length="200"></column>
</property>
<property name="discard" type="boolean" not-null="false">
<column name="discard"></column>
</property>
<property name="del" type="boolean" not-null="false">
<column name="del"></column>
</property>
<property name="approveState" type="integer" not-null="false">
<column name="approve_state"></column>
</property>
<property name="name" type="nstring" not-null="false">
<column name="name" length="50"></column>
</property>
<many-to-one name="regionalCompany" entity-name="com.beecode.bap.department.datamodel.Department" fetch="select">
<column name="regional_company" not-null="false"/>
</many-to-one>
<property name="description" type="nstring" not-null="false">
<column name="description" length="500"></column>
</property>
</class>
</hibernate-mapping>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping
http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd">
<class entity-name="com.xyst.dinas.biz.datamodel.Station" table="xyst_dinas_biz_station" optimistic-lock="version">
<tuplizer entity-mode="dynamic-map" class="com.beecode.bcp.store.hibernate.KObjectEntityTuplizer"/>
<id name="id" type="uuid-binary" column="id" length="16">
<generator class="assigned" />
</id>
<version name="version" type="int" column="version"/>
<property name="createTime" type="timestamp" not-null="false">
<column name="create_time"/>
</property>
<many-to-one name="creator" entity-name="com.beecode.bap.staff.datamodel.Staff" fetch="select">
<column name="creator_id" not-null="false"/>
</many-to-one>
<property name="modifyTime" type="timestamp" not-null="false">
<column name="modify_time"/>
</property>
<many-to-one name="modifier" entity-name="com.beecode.bap.staff.datamodel.Staff" fetch="select">
<column name="modifier_id" not-null="false"/>
</many-to-one>
<property name="del" type="boolean" not-null="false">
<column name="del" default="false"/>
</property>
<property name="discard" type="boolean" not-null="false">
<column name="discard" default="false" />
</property>
<many-to-one name="department" entity-name="com.beecode.bap.department.datamodel.Department" fetch="select">
<column name="department" not-null="false">
<comment>所属部门</comment>
</column>
</many-to-one>
<property name="stationName" type="nstring" not-null="true">
<column name="station_name" length="30" >
<comment>场站名称</comment>
</column>
</property>
<property name="stationAddress" type="nstring" length="80" not-null="false">
<column name="station_address">
<comment>场站地址</comment>
</column>
</property>
<property name="stationStatus" type="integer" not-null="true">
<column name="station_status" >
<comment>场站状态,0已停业1经营中</comment>
</column>
</property>
<property name="stationCoordinate" type="nstring" not-null="false">
<column name="station_coordinate">
<comment>场站的坐标按照逗号分隔</comment>
</column>
</property>
<property name="linkMan" type="nstring" not-null="false">
<column name="link_man">
<comment>联系人</comment>
</column>
</property>
<property name="openingDate" type="timestamp" not-null="false">
<column name="opening_date">
<comment>开业时间</comment>
</column>
</property>
<property name="telephone" type="nstring" not-null="false">
<column name="telephone" length="50">
<comment>联系方式</comment>
</column>
</property>
<property name="reason" type="nstring" not-null="false">
<column name="reason" length="300" >
<comment>备注</comment>
</column>
</property>
<property name="sort_order" type="int" not-null="true" unique="true" update="false" insert="false" index="station_sort_index" >
<column name="sort_order" length="10">
<comment >排序</comment>
</column>
</property>
</class>
</hibernate-mapping>
\ No newline at end of file
File mode changed from 100644 to 100755
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment