Commit 920dcc33 authored by 扫地僧's avatar 扫地僧

Merge branch 'master' of gitlab.fqyxa.com:luoyangfei/store-system

parents daedd3f4 06aad3f4
/target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/build/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
\ No newline at end of file
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://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.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
wget "$jarUrl" -O "$wrapperJarPath"
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
curl -o "$wrapperJarPath" "$jarUrl"
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
echo Found %WRAPPER_JAR%
) else (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
echo Finished downloading %WRAPPER_JAR%
)
@REM End of extension
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.com.fqy</groupId>
<artifactId>store-system</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>store-system</name>
<description>store-system project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.4</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
<!-- MyBatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
<!-- MySQL 连接驱动依赖 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<!-- log4j.-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
<version>1.3.8.RELEASE</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package cn.com.fqy;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import java.io.IOException;
@Component
public class CorsFilter implements Filter {
final static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CorsFilter.class);
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
System.out.println("*********************************过滤器被使用**************************");
chain.doFilter(req, res);
}
public void init(FilterConfig filterConfig) {}
public void destroy() {}
}
\ No newline at end of file
package cn.com.fqy;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(StoreMgtApplication.class);
}
}
package cn.com.fqy;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan(basePackages = "cn.com.fqy.core.dao")
public class StoreMgtApplication {
public static void main(String[] args) {
SpringApplication.run(StoreMgtApplication.class, args);
}
}
package cn.com.fqy.common;
import java.io.Serializable;
/**
* 基础实体类
* @author fqy
*
* @param <PK>
*/
public abstract class Entity<PK extends Serializable> implements Serializable {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 1L;
/**
* 得到主键
* @return
*/
public PK getPK(){
return null;
}
}
package cn.com.fqy.common;
import java.io.Serializable;
/**
* 通用操作人(泛指一切操作人,包括平台人员、商家人员、买家会员、系统自动操作等)对象
*
*/
public class Operator implements Serializable {
private static final long serialVersionUID = 7829098448116216661L;
private Integer operatorType; //操作人类型(0、系统自动操作,1、平台人员操作,2、商家人员操作,3、会员操作)
private String operatorId; //操作人id(根据操作人类型会对应不同的表记录)
private String operatorUserName; //操作人用户名(根据操作人类型,会对应不同的字段,一般对应登录名字段,如会员注册无登录名时,可能是邮箱或手机号等)
private String operatorRealName; //操作人的真实名称(根据操作人类型,会对应不同的字段,某些情况下不一定有该值)
private String operatorEmail; //操作人邮箱(某些情况下不一定有该值)
private String operatorMobile; //操作人手机号(某些情况下不一定有该值)
public Operator() {
}
public Operator(Integer operatorType, String operatorId, String operatorUserName, String operatorRealName,String operatorMobile) {
super();
this.operatorType = operatorType;
this.operatorId = operatorId;
this.operatorUserName = operatorUserName;
this.operatorRealName = operatorRealName;
this.operatorMobile = operatorMobile;
}
public Integer getOperatorType() {
return operatorType;
}
public void setOperatorType(Integer operatorType) {
this.operatorType = operatorType;
}
public String getOperatorId() {
return operatorId;
}
public void setOperatorId(String operatorId) {
this.operatorId = operatorId;
}
public String getOperatorUserName() {
return operatorUserName;
}
public void setOperatorUserName(String operatorUserName) {
this.operatorUserName = operatorUserName;
}
public String getOperatorRealName() {
return operatorRealName;
}
public void setOperatorRealName(String operatorRealName) {
this.operatorRealName = operatorRealName;
}
public String getOperatorEmail() {
return operatorEmail;
}
public void setOperatorEmail(String operatorEmail) {
this.operatorEmail = operatorEmail;
}
public String getOperatorMobile() {
return operatorMobile;
}
public void setOperatorMobile(String operatorMobile) {
this.operatorMobile = operatorMobile;
}
@Override
public String toString() {
return "Operator [operatorType=" + operatorType + ", operatorId=" + operatorId + ", operatorUserName="
+ operatorUserName + ", operatorRealName=" + operatorRealName + ", operatorEmail=" + operatorEmail
+ ", operatorMobile=" + operatorMobile + "]";
}
}
package cn.com.fqy.common;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.com.fqy.core.model.SysPermission;
//懒汉式单例类.在第一次调用的时候实例化自己
public class PermissionListSingleton {
private List<SysPermission> perList;
private Map<String,String> perUrlMap;
private static Map<String,PermissionListSingleton> map = new HashMap<String,PermissionListSingleton>();
static{
PermissionListSingleton single = new PermissionListSingleton();
map.put(single.getClass().getName(), single);
}
//保护的默认构造子
protected PermissionListSingleton(){}
//静态工厂方法,返还此类惟一的实例
public static PermissionListSingleton getInstance(String name) {
if(name == null) {
name = PermissionListSingleton.class.getName();
System.out.println("name == null"+"--->name="+name);
}
if(map.get(name) == null) {
try {
map.put(name, (PermissionListSingleton) Class.forName(PermissionListSingleton.class.getName()).newInstance());
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
return map.get(name);
}
public List<SysPermission> getPerList() {
return perList;
}
public void setPerList(List<SysPermission> perList) {
this.perList = perList;
}
public Map<String, String> getPerUrlMap() {
return perUrlMap;
}
public void setPerUrlMap(Map<String, String> perUrlMap) {
this.perUrlMap = perUrlMap;
}
public void setPerUrlMap(List<SysPermission> perList) {
Map<String,String> newMap = new HashMap<String,String>();
if(perList != null && perList.size() > 0){
for(SysPermission per : perList){
newMap.put(per.getPermName(), per.getPermResource());
}
}
this.perUrlMap = newMap;
}
}
package cn.com.fqy.common;
/**
* 网络请求接口返回通用
* @author fqy
*
*/
public class ResultInfo<T extends Object> {
private String code;//网络请求结果 成功1,失败0
private String msg;//网络请求返回结果信息
private String business_code;//业务状态code值 根据不同业务而定
private T data;//业务数据
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public String getBusiness_code() {
return business_code;
}
public void setBusiness_code(String business_code) {
this.business_code = business_code;
}
}
package cn.com.fqy.common;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import cn.com.fqy.core.common.ECMgtConstant;
import cn.com.fqy.core.model.SysUser;
/**
* SESSION 操作
*
* @ClassName: SessionUtil
* @Description: TODO
*
*/
public class SessionUtil {
/**
* 取HttpSession对象
* @return
*/
public static HttpSession getSession(HttpServletRequest request) {
return request.getSession();
}
/**
* 设置用户的登录信息
* @Title: setLoginSysUser
* @Description: TODO
* @param request
* @param sysUser
* @return
*/
public static boolean setLoginSysUser(HttpServletRequest request,SysUser sysUser){
try{
request.getSession().setAttribute(ECMgtConstant.SESSION_KEY_OF_LOGIN_SYS_USER, sysUser);
return true;
}catch(Exception e){
e.printStackTrace();
}
return false;
}
/**
* 取已登录的系统人员用户对象(数据来自session)
* @return
*/
public static SysUser getLoginSysUser(HttpServletRequest request) {
SysUser sysUser = null;
HttpSession session = getSession(request);
if(session != null) {
sysUser = (SysUser)session.getAttribute(ECMgtConstant.SESSION_KEY_OF_LOGIN_SYS_USER); //从session中取已登录的系统人员用户对象
}
return sysUser;
}
/**
* 移除登陆用户
* @Title: removeSessionAttribut
* @Description: TODO
* @param request
* @param key
*/
public static void removeSessionUser(HttpServletRequest request){
removeSessionAttribut(request,ECMgtConstant.SESSION_KEY_OF_LOGIN_SYS_USER);
}
/**
* 保存信息到SESSION
*
* @Title: setBaseInfo
* @Description: 保存信息到SESSION
* @param @param request
* @param @param key
* @param @param value
* @return void
* @throws
* @author: fqy
* @date: 2018-6-19 下午08:31:57
*/
public static void setDataToSession(HttpServletRequest request, String key, Object value) {
request.getSession().setAttribute(key, value);
}
/**
* 获取session信息
*
* @Title: getBaseInfo
* @Description: TODO
* @param request
* @param key
* @return
* @author: fqy
* @date: 2018-6-19 下午08:31:57
*/
@SuppressWarnings("unchecked")
public static <T> T getDataFromSession(HttpServletRequest request, String key, Class<T> clazz) {
return (T) request.getSession().getAttribute(key);
}
/**
* 移除session 属性
*
* @param request
* @param key
*/
public static void removeSessionAttribut(HttpServletRequest request, String key) {
request.getSession().removeAttribute(key);
}
/**
* 保存访问路径
*
* @Title: setLocationUrl
* @Description: 设置访问URL
* @param request
* @author: fqy
* @date: 2018-6-19 下午08:31:57
*/
public static void setLocationUrl(HttpServletRequest request) {
request.getSession().removeAttribute("locationUrl");
String inurl = request.getServletPath();
String p = request.getQueryString();
if("".equals(p) || null ==p || "null".equals(p)){
p="";
}else{
p="?"+p;
}
request.getSession().setAttribute("locationUrl", inurl+p);
}
/**
* 得到访问路径
*
* @Title: getLocationUrl
* @Description: 得到访问URl
* @param request
* @author: fqy
* @date: 2018-6-19 下午08:31:57
*/
public static String getLocationUrl(HttpServletRequest request) {
return (String) request.getSession().getAttribute("locationUrl");
}
/**
* 得到重定向路径
*
* @Title: getRedicectURL
* @param request
* @param path
* 跳转相对路径
* @author: fqy
* @date: 2018-6-19 下午08:31:57
*/
public static String getRedicectURL(HttpServletRequest request, String path) {
String returnUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + path;
return returnUrl;
}
/**
* 重置sessionid,原session中的数据自动转存到新session中
* @param request
*/
public static void reGenerateSessionId(HttpServletRequest request, HttpServletResponse response){
HttpSession session = request.getSession();
//首先将原session中的数据转移至一临时map中
Map<String,Object> tempMap = new HashMap<String,Object>();
@SuppressWarnings("unchecked")
Enumeration<String> sessionNames = session.getAttributeNames();
while(sessionNames.hasMoreElements()){
String sessionName = sessionNames.nextElement();
tempMap.put(sessionName, session.getAttribute(sessionName));
}
System.out.println("=#############################session="+session.getId());
//注销原session,为的是重置sessionId
session.invalidate();
System.out.println("=#############################session="+session);
//将临时map中的数据转移至新session
session = request.getSession(true);
System.out.println("=#############################session="+session.getId());
for(Map.Entry<String, Object> entry : tempMap.entrySet()){
session.setAttribute(entry.getKey(), entry.getValue());
}
}
}
package cn.com.fqy.common.constants;
/**
* 开发框架基础架构的公共常量设置类(行知网络使用此基础框架的项目均可使用此常量类)
* @author fqy
*
*/
public class Constant {
/**整个应用0表示失败*/
public static final String FAIL="0";
/**整个应用1表示成功*/
public static final String SUCCESS="1";
/**未登录*/
public static final String NO_LOGIN = "0";
/**未授权*/
public static final String NO_AUTHORITY = "0";
/**整个应用0表示否*/
public static final int NO = 0;
/**整个应用1表示是*/
public static final int YES = 1;
/**待审核*/
public static final int CENSORED_STATE_NO = 0;
/**审核通过*/
public static final int CENSORED_STATE_PASS = 1;
/**审核不通过*/
public static final int CENSORED_STATE_NOPASS = 2;
/**禁用*/
public static final int DISABLED = 0;
/**启用*/
public static final int ENABLED = 1;
/**不删除*/
public static final int DEL_STATE_NO = 0;
/**已删除*/
public static final int DEL_STATE_YES = 1;
/**默认的分页每页记录数*/
public static final int DEFAULT_PAGE_SIZE = 10;
/**错误信息,参数无效或不合要求*/
public static final String ERR_MSG_INVALID_ARG = "Invalid argument.";
/**错误信息,捕获到异常*/
public static final String ERR_MSG_EXCEPTION_CATCHED = "Exception catched.";
/**错误信息,数据不存在*/
public static final String ERR_MSG_DATA_NOT_EXISTS = "Data not exists.";
}
package cn.com.fqy.common.timedTask;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.scheduling.annotation.Scheduled;
import cn.com.fqy.common.Operator;
import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.common.constants.Constant;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.Store;
import cn.com.fqy.core.service.StoreService;
public class StoreTimeTask {
private static final Log log = LogFactory.getLog(StoreTimeTask.class);
@Resource
private StoreService storeService;
@Scheduled(cron = "* 0/30 * * * ?")
public void store() {
log.info("+++++++++++++++++++++++++++++++++++++++每分钟执行一次。开始。");
Store store=new Store();
store.setIsAvailable(1);
store.setIsAuditing(1);
store.setIsDeleted(0);
List<Store> storeList=storeService.getStoreList(new Query(store));
if(storeList.size()>0 && storeList != null) {
Date date = new Date();
for(Store list:storeList) {
if(date.getTime()>list.getMatureTime().getTime()) {
list.setIsAvailable(0);
Operator op = new Operator();
ResultInfo<Store> result=storeService.updateStore(list, op);
if(result.getCode().equals("1")){
result.setCode(Constant.SUCCESS);
}else{
result.setCode(Constant.FAIL);
}
}
}
}else{
log.info("++++++++++++++++++++++++++++++++++++++++没有值。");
}
log.info("++++++++++++++++++++++++++++++++++++++++每30分钟执行一次。结束。");
}
}
package cn.com.fqy.common.util;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ConnectException;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CommonUtil {
private static Logger log = LoggerFactory.getLogger(CommonUtil.class);
/**
* 发送https请求
* @param requestUrl 请求地址
* @param requestMethod 请求方式(GET、POST)
* @param outputStr 提交的数据
* @return 返回微信服务器响应的信息
*/
public static String httpsRequest(String requestUrl, String requestMethod, String outputStr) {
try {
// 创建SSLContext对象,并使用我们指定的信任管理器初始化
MyX509TrustManager[] tm = { new MyX509TrustManager() };
SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
sslContext.init(null, tm, new java.security.SecureRandom());
// 从上述SSLContext对象中得到SSLSocketFactory对象
javax.net.ssl.SSLSocketFactory ssf = sslContext.getSocketFactory();
URL url = new URL(requestUrl);
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setSSLSocketFactory(ssf);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
// 设置请求方式(GET/POST)
conn.setRequestMethod(requestMethod);
conn.setRequestProperty("content-type", "application/x-www-form-urlencoded");
// 当outputStr不为null时向输出流写数据
if (null != outputStr) {
OutputStream outputStream = conn.getOutputStream();
// 注意编码格式
outputStream.write(outputStr.getBytes("UTF-8"));
outputStream.close();
}
// 从输入流读取返回内容
InputStream inputStream = conn.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String str = null;
StringBuffer buffer = new StringBuffer();
while ((str = bufferedReader.readLine()) != null) {
buffer.append(str);
}
// 释放资源
bufferedReader.close();
inputStreamReader.close();
inputStream.close();
inputStream = null;
conn.disconnect();
return buffer.toString();
} catch (ConnectException ce) {
log.error("连接超时:{}", ce);
} catch (Exception e) {
log.error("https请求异常:{}", e);
}
return null;
}
/**
* 获取接口访问凭证
*
* @param appid 凭证
* @param appsecret 密钥
* @return
*//*
public static Token getToken(String appid, String appsecret) {
Token token = null;
String requestUrl = ConfigUtil.TOKEN_URL.replace("APPID", appid).replace("APPSECRET", appsecret);
// 发起GET请求获取凭证
JSONObject jsonObject = JSONObject.fromObject(httpsRequest(requestUrl, "GET", null));
if (null != jsonObject) {
try {
token = new Token();
token.setAccessToken(jsonObject.getString("access_token"));
token.setExpiresIn(jsonObject.getInt("expires_in"));
} catch (JSONException e) {
token = null;
// 获取token失败
log.error("获取token失败 errcode:{} errmsg:{}", jsonObject.getInt("errcode"), jsonObject.getString("errmsg"));
}
}
return token;
}
public static String urlEncodeUTF8(String source){
String result = source;
try {
result = java.net.URLEncoder.encode(source,"utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}*/
}
package cn.com.fqy.common.util;
public class ECByteUtils {
/**
* 私有构造函数,不允许本类生成实例
*/
private ECByteUtils() {
}
private final static String[] hexDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D",
"E", "F" };
/**
* 转换字节数组为16进制字串
*
* @param b
* 字节数组
* @return 16进制字串
*/
public static String byteArrayToHexString(byte[] b) {
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < b.length; i++) {
resultSb.append(byteToHexString(b[i]));
}
return resultSb.toString();
}
/**
* 字节转为16进制串
*
* @param b
* @return
*/
public static String byteToHexString(byte b) {
int n = b;
if (n < 0)
n = 256 + n;
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
}
}
package cn.com.fqy.common.util;
import java.math.BigDecimal;
/**
* 工具类 - double类型运算帮助类
*
* @ClassName: CalculateUtils
* @Description: TODO
* @author: MyLife
* @date 2012-12-12 上午11:30:13
*
*/
public class ECCalculateUtils {
/**
* 默认除法运算精度
*/
private static final int DEF_DIV_SCALE = 10;
/**
* 提供精确的加法运算。
*
* @param v1
* 被加数
* @param v2
* 加数
* @return 两个参数的和
*/
public static double add(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue();
}
/**
* 提供精确的减法运算。
*
* @param v1
* 被减数
* @param v2
* 减数
* @return 两个参数的差
*/
public static double sub(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.subtract(b2).doubleValue();
}
/**
* 提供精确的乘法运算。
*
* @param v1
* 被乘数
* @param v2
* 乘数
* @return 两个参数的积
*/
public static double mul(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.multiply(b2).doubleValue();
}
/**
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。
*
* @param v1
* 被除数
* @param v2
* 除数
* @return 两个参数的商
*/
public static double div(double v1, double v2) {
return div(v1, v2, DEF_DIV_SCALE);
}
/**
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。
*
* @param v1
* 被除数
* @param v2
* 除数
* @param scale
* 表示表示需要精确到小数点以后几位。
* @return 两个参数的商
*/
public static double div(double v1, double v2, int scale) {
if (scale < 0) {
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
* 提供精确的小数位四舍五入处理。
*
* @param v
* 需要四舍五入的数字
* @param scale
* 小数点后保留几位
* @return 四舍五入后的结果
*/
public static double round(double v, int scale) {
if (scale < 0) {
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b = new BigDecimal(Double.toString(v));
BigDecimal one = new BigDecimal("1");
return b.divide(one, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
* 保留两位小数,四舍五入结果
* @param v
* @return
*/
public static String round(double v){
return String.format("%.2f", v);
}
/**
* 提供精确的类型转换(Float)
*
* @param v
* 需要被转换的数字
* @return 返回转换结果
*/
public static float convertsToFloat(double v) {
BigDecimal b = new BigDecimal(v);
return b.floatValue();
}
/**
* 提供精确的类型转换(Int)不进行四舍五入
*
* @param v
* 需要被转换的数字
* @return 返回转换结果
*/
public static int convertsToInt(double v) {
BigDecimal b = new BigDecimal(v);
return b.intValue();
}
/**
* 提供精确的类型转换(Long)
*
* @param v
* 需要被转换的数字
* @return 返回转换结果
*/
public static long convertsToLong(double v) {
BigDecimal b = new BigDecimal(v);
return b.longValue();
}
/**
* 返回两个数中大的一个值
*
* @param v1
* 需要被对比的第一个数
* @param v2
* 需要被对比的第二个数
* @return 返回两个数中大的一个值
*/
public static double returnMax(double v1, double v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.max(b2).doubleValue();
}
/**
* 返回两个数中小的一个值
*
* @param v1
* 需要被对比的第一个数
* @param v2
* 需要被对比的第二个数
* @return 返回两个数中小的一个值
*/
public static double returnMin(double v1, double v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.min(b2).doubleValue();
}
/**
* 精确对比两个数字
*
* @param v1
* 需要被对比的第一个数
* @param v2
* 需要被对比的第二个数
* @return 如果两个数一样则返回0,如果第一个数比第二个数大则返回1,反之返回-1
*/
public static int compareTo(double v1, double v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.compareTo(b2);
}
/**
* 精确对比两个数字:大于等于
*
* @param v1
* @param v2
* @return
*/
public static boolean ge(double v1, double v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.compareTo(b2) == 0 || b1.compareTo(b2) == 1 ? true : false;
}
/**
* 精确对比两个数字:小于等于
*
* @param v1
* @param v2
* @return
*/
public static boolean le(double v1, double v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.compareTo(b2) == 0 || b1.compareTo(b2) == -1 ? true : false;
}
/**
* 精确对比两个数字:大于
*
* @param v1
* @param v2
* @return
*/
public static boolean gt(double v1, double v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.compareTo(b2) == 1 ? true : false;
}
/**
* 精确对比两个数字:小于
*
* @param v1
* @param v2
* @return
*/
public static boolean lt(double v1, double v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.compareTo(b2) == -1 ? true : false;
}
/**
* 精确对比两个数字:等于
*
* @param v1
* @param v2
* @return
*/
public static boolean eq(double v1, double v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.compareTo(b2) == 0 ? true : false;
}
/**
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字全部舍弃。
* @param v1 被除数
* @param v2 除数
* @param scale 表示表示需要精确到小数点以后几位。
* @return 两个参数的商
*/
public static double divDOWN(double v1, double v2, int scale) {
if (scale < 0) {
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.divide(b2, scale, BigDecimal.ROUND_HALF_DOWN).doubleValue();
}
}
package cn.com.fqy.common.util;
import java.beans.PropertyEditorSupport;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* 自定义日期转换
*
*/
public class ECCustomerDateEditor extends PropertyEditorSupport {
private static final Log log = LogFactory.getLog(ECCustomerDateEditor.class);
// private final boolean allowEmpty;
//
// public ECCutomerDateEditor(boolean allowEmpty) {
// this.allowEmpty = allowEmpty;
// }
public String getAsText() {
Date value = (Date) getValue();
if (null == value) {
return "";
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
return df.format(value);
}
public void setAsText(String text) throws IllegalArgumentException {
Date value = null;
if (null != text && (text = text.trim()).length() != 0) {
if (text.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$")) {
value = parseDate(text, "yyyy-MM-dd");
} else if (text.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}$")) {
value = parseDate(text, "yyyy-MM-dd hh:mm");
} else if (text.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}:\\d{1,2}$")) {
value = parseDate(text, "yyyy-MM-dd hh:mm:ss");
}
}
setValue(value);
}
/**
* 功能描述:格式化日期
*
* @param dateStr
* String 字符型日期
* @param format
* String 格式
* @return Date 日期
*/
public Date parseDate(String dateStr, String format) {
Date date = null;
try {
DateFormat dateFormat = new SimpleDateFormat(format);
date = (Date) dateFormat.parse(dateStr);
} catch (Exception e) {
log.error(e.getMessage() + ", dateStr=" + dateStr + ",format=" + format);
}
return date;
}
}
package cn.com.fqy.common.util;
import java.io.File;
import java.io.FileOutputStream;
/**
* 文件上传工具类服务方法
* @author fqy
*
*/
public class ECFileUtil{
public static void uploadFile(byte[] file, String filePath, String fileName) throws Exception{
File targetFile = new File(filePath);
if(!targetFile.exists()){
targetFile.mkdirs();
}
FileOutputStream out = new FileOutputStream(filePath+fileName);
out.write(file);
out.flush();
out.close();
}
}
\ No newline at end of file
package cn.com.fqy.common.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Formatter;
public class ECMd5Utils {
/**
* 私有构造函数,不允许本类生成实例
*/
private ECMd5Utils(){
}
private static final String sv = "Ix4c$S732nqix*cH";
/**
* 用MD5算法进行加密
* @param pStrPW
* @return
*/
public static String crypt(String pStrPW) {
String strCrypt = hash(pStrPW);
if(strCrypt.length() > 0) {
strCrypt += sv;
strCrypt = hash(strCrypt);
}
return strCrypt;
}
/**
* 用MD5算法进行加密(16位)
* @param strPW
* @return
*/
public static String encryptMD5(String strPW) {
String strCrypt = hash(strPW);
if(strCrypt.length() > 0) {
strCrypt += sv;
strCrypt = hash(strCrypt);
}
return strCrypt.substring(8,24);
}
/**
* MD5算法进行散列
* @param str
* @return
*/
public static String hash(String str) {
String result = "";
if (str == null || str.equals("")) { // 如果传入参数为空,则返回空字符串
return result;
}
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] data = str.getBytes();
int l = data.length;
for (int i = 0; i < l; i++)
md.update(data[i]);
byte[] digest = md.digest();
result = ECByteUtils.byteArrayToHexString(digest);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e.getMessage(),e);
}
return result;
}
/**
* MD5算法进行散列
* @param str
* @return
*/
public static String hash16(String str) {
String result = "";
if (str == null || str.equals("")) { // 如果传入参数为空,则返回空字符串
return result;
}
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] data = str.getBytes();
int l = data.length;
for (int i = 0; i < l; i++)
md.update(data[i]);
byte[] digest = md.digest();
result = ECByteUtils.byteArrayToHexString(digest);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e.getMessage(),e);
}
return result;
}
public static void main(String args[]) {
String pwd = "123456";
if (args != null && args.length > 0) {
pwd = args[0];
}
try {
System.out.println(ECMd5Utils.hash(pwd));
System.out.println(ECMd5Utils.crypt(pwd));
System.out.println(ECMd5Utils.encryptMD5(pwd));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取 md5 加密字符串
*
* @param str
* @return
* @throws Exception
*/
public static String md5(String str) throws Exception {
return getSign(str, "MD5");
}
/**
* 获取加密签名
*
* @param str 字符
* @param type 加密类型
* @return
* @throws Exception
*/
public static String getSign(String str, String type) throws Exception {
MessageDigest crypt = MessageDigest.getInstance(type);
crypt.reset();
crypt.update(str.getBytes("UTF-8"));
return str = byteToHex(crypt.digest());
}
/**
* 字节转换 16 进制
*
* @param hash
* @return
*/
private static String byteToHex(final byte[] hash) {
Formatter formatter = new Formatter();
for (byte b : hash) {
formatter.format("%02x", b);
}
String result = formatter.toString();
formatter.close();
return result;
}
/**
* 用MD5算法进行加密
* @param pStrPW
* @return
*/
public static String cryptTJFS(String pStrPW) {
String strCrypt = hash(pStrPW);
/*if(strCrypt.length() > 0) {
strCrypt += sv;
strCrypt = hash(strCrypt);
}
*/
return strCrypt;
}
}
package cn.com.fqy.common.util;
import java.util.Random;
/**
* 随机数、随机字符串工具类
*
*/
public final class ECRandomUtils {
/**
* 获得特定长度的一串随机数字
* @param length
* @return
* @throws
*/
public static String getRandomNumberStr(int length){
StringBuilder builder = new StringBuilder();
Random random = new Random();
for(int i = 0 ; i < length; i++){
builder.append(random.nextInt(10));
}
return builder.toString();
}
/**
* 获得特定长度的一个随机字母数字混编字符串(所包含的字符包括0-9A-Z)
* @param length
* @return
*/
public static String getRandomAlphamericStr(int length) {
StringBuilder builder = new StringBuilder();
Random random = new Random();
for(int i = 0 ; i < length; i++) {
int n = random.nextInt(36);
if(n < 10)
builder.append(n);
else
builder.append((char)(n + 55));
}
return builder.toString();
}
/**
* 获得特定长度的一个随机十六进制数字字母混编字符串(所包含的字符包括0-9A-F)
* @param length
* @return
*/
public static String getRandomHexStr(int length) {
StringBuilder builder = new StringBuilder();
Random random = new Random();
for(int i = 0 ; i < length; i++) {
int n = random.nextInt(16);
if(n < 10)
builder.append(n);
else
builder.append((char)(n + 55));
}
return builder.toString();
}
}
package cn.com.fqy.common.util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
/**
* SESSION 操作
*
* @ClassName: SessionUtil
* @Description: TODO
* @author: fqy
* @date 2012-12-30 下午08:33:30
*
*/
public class ECSessionUtil {
/**
* 保存信息到SESSION
*
* @Title: setBaseInfo
* @Description: 保存信息到SESSION
* @param @param request
* @param @param key
* @param @param value
* @return void
* @throws
* @author: fqy
* @date: 2018-6-19 下午08:31:57
*/
public static void setDataToSession(HttpServletRequest request, String key,Object value) {
request.getSession().setAttribute(key, value);
}
/**
* 获取session信息
*
* @Title: getBaseInfo
* @Description: TODO
* @param request
* @param key
* @return
* @author: fqy
* @date: 2018-6-19 下午08:31:57
*/
@SuppressWarnings("unchecked")
public static <T> T getDataFromSession(HttpServletRequest request,String key, Class<T> clazz) {
return (T) request.getSession().getAttribute(key);
}
@SuppressWarnings("unchecked")
public static <T> T getDataFromSession(String key, Class<T> clazz) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest();
return (T) request.getSession().getAttribute(key);
}
public static HttpSession getSession() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest();
return request.getSession();
}
/**
* 移除session 属性
*
* @param request
* @param key
*/
public static void removeSessionAttribut(HttpServletRequest request,String key) {
request.getSession().removeAttribute(key);
}
/**
* 得到重定向路径
*
* @Title: getRedicectURL
* @param request
* @param path
* 跳转相对路径
* @author: fqy
* @date: 2018-6-19 下午08:31:57
*/
public static String getRedicectURL(HttpServletRequest request, String path) {
String returnUrl = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ request.getContextPath() + path;
return returnUrl;
}
}
package cn.com.fqy.common.util;
import java.util.UUID;
/**
* UUID生成工具
*
*/
public final class ECUuidGenUtils {
/**
* 生成一个UUID串(32个字符,其中的字母为小写)
* @return
* @throws
*/
public static String genUUID() {
return UUID.randomUUID().toString().replaceAll("-", "");
}
}
package cn.com.fqy.common.util;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.imageio.ImageIO;
public class GetImageSizeUtil {
public static Map<String,Integer> getImageSize(String filePath) {
Map<String,Integer> imageInfoMap = new HashMap<String, Integer>();
InputStream is = null;
try {
File file = new File(filePath);
is = new FileInputStream(file);
BufferedImage image = ImageIO.read(is);
imageInfoMap.put("width", image.getWidth());
imageInfoMap.put("height", image.getHeight());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (is != null) {
try {
is.close(); // 关闭流
} catch (IOException e) {
e.printStackTrace();
}
}
}
return imageInfoMap;
}
}
package cn.com.fqy.common.util;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.util.HashMap;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
/**
* Http�ͻ��˹�����<br/>
* �����ڲ������࣬�벻Ҫ���ⲿ���á�
* @author miklchen
*
*/
public class HttpClientUtil {
public static final String SunX509 = "SunX509";
public static final String JKS = "JKS";
public static final String PKCS12 = "PKCS12";
public static final String TLS = "TLS";
/**
* get HttpURLConnection
* @param strUrl url��ַ
* @return HttpURLConnection
* @throws IOException
*/
public static HttpURLConnection getHttpURLConnection(String strUrl)
throws IOException {
URL url = new URL(strUrl);
HttpURLConnection httpURLConnection = (HttpURLConnection) url
.openConnection();
return httpURLConnection;
}
/**
* get HttpsURLConnection
* @param strUrl url��ַ
* @return HttpsURLConnection
* @throws IOException
*/
public static HttpsURLConnection getHttpsURLConnection(String strUrl)
throws IOException {
URL url = new URL(strUrl);
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url
.openConnection();
return httpsURLConnection;
}
/**
* ��ȡ������ѯ����url
* @param strUrl
* @return String
*/
public static String getURL(String strUrl) {
if(null != strUrl) {
int indexOf = strUrl.indexOf("?");
if(-1 != indexOf) {
return strUrl.substring(0, indexOf);
}
return strUrl;
}
return strUrl;
}
/**
* ��ȡ��ѯ��
* @param strUrl
* @return String
*/
public static String getQueryString(String strUrl) {
if(null != strUrl) {
int indexOf = strUrl.indexOf("?");
if(-1 != indexOf) {
return strUrl.substring(indexOf+1, strUrl.length());
}
return "";
}
return strUrl;
}
/**
* ��ѯ�ַ���ת����Map<br/>
* name1=key1&name2=key2&...
* @param queryString
* @return
*/
public static Map queryString2Map(String queryString) {
if(null == queryString || "".equals(queryString)) {
return null;
}
Map m = new HashMap();
String[] strArray = queryString.split("&");
for(int index = 0; index < strArray.length; index++) {
String pair = strArray[index];
HttpClientUtil.putMapByPair(pair, m);
}
return m;
}
/**
* �Ѽ�ֵ�����Map<br/>
* pair:name=value
* @param pair name=value
* @param m
*/
public static void putMapByPair(String pair, Map m) {
if(null == pair || "".equals(pair)) {
return;
}
int indexOf = pair.indexOf("=");
if(-1 != indexOf) {
String k = pair.substring(0, indexOf);
String v = pair.substring(indexOf+1, pair.length());
if(null != k && !"".equals(k)) {
m.put(k, v);
}
} else {
m.put(pair, "");
}
}
/**
* BufferedReaderת����String<br/>
* ע��:���ر���Ҫ���д���
* @param reader
* @return String
* @throws IOException
*/
public static String bufferedReader2String(BufferedReader reader) throws IOException {
StringBuffer buf = new StringBuffer();
String line = null;
while( (line = reader.readLine()) != null) {
buf.append(line);
buf.append("\r\n");
}
return buf.toString();
}
/**
* �������<br/>
* ע��:���ر���Ҫ���д���
* @param out
* @param data
* @param len
* @throws IOException
*/
public static void doOutput(OutputStream out, byte[] data, int len)
throws IOException {
int dataLen = data.length;
int off = 0;
while (off < data.length) {
if (len >= dataLen) {
out.write(data, off, dataLen);
off += dataLen;
} else {
out.write(data, off, len);
off += len;
dataLen -= len;
}
// ˢ�»�����
out.flush();
}
}
/**
* ��ȡSSLContext
* @param trustFile
* @param trustPasswd
* @param keyFile
* @param keyPasswd
* @return
* @throws NoSuchAlgorithmException
* @throws KeyStoreException
* @throws IOException
* @throws CertificateException
* @throws UnrecoverableKeyException
* @throws KeyManagementException
*/
public static SSLContext getSSLContext(
FileInputStream trustFileInputStream, String trustPasswd,
FileInputStream keyFileInputStream, String keyPasswd)
throws NoSuchAlgorithmException, KeyStoreException,
CertificateException, IOException, UnrecoverableKeyException,
KeyManagementException {
// ca
TrustManagerFactory tmf = TrustManagerFactory.getInstance(HttpClientUtil.SunX509);
KeyStore trustKeyStore = KeyStore.getInstance(HttpClientUtil.JKS);
trustKeyStore.load(trustFileInputStream, HttpClientUtil
.str2CharArray(trustPasswd));
tmf.init(trustKeyStore);
final char[] kp = HttpClientUtil.str2CharArray(keyPasswd);
KeyManagerFactory kmf = KeyManagerFactory.getInstance(HttpClientUtil.SunX509);
KeyStore ks = KeyStore.getInstance(HttpClientUtil.PKCS12);
ks.load(keyFileInputStream, kp);
kmf.init(ks, kp);
SecureRandom rand = new SecureRandom();
SSLContext ctx = SSLContext.getInstance(HttpClientUtil.TLS);
ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), rand);
return ctx;
}
/**
* ��ȡCA֤����Ϣ
* @param cafile CA֤���ļ�
* @return Certificate
* @throws CertificateException
* @throws IOException
*/
public static Certificate getCertificate(File cafile)
throws CertificateException, IOException {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
FileInputStream in = new FileInputStream(cafile);
Certificate cert = cf.generateCertificate(in);
in.close();
return cert;
}
/**
* �ַ���ת����char����
* @param str
* @return char[]
*/
public static char[] str2CharArray(String str) {
if(null == str) return null;
return str.toCharArray();
}
/**
* �洢ca֤���JKS��ʽ
* @param cert
* @param alias
* @param password
* @param out
* @throws KeyStoreException
* @throws NoSuchAlgorithmException
* @throws CertificateException
* @throws IOException
*/
public static void storeCACert(Certificate cert, String alias,
String password, OutputStream out) throws KeyStoreException,
NoSuchAlgorithmException, CertificateException, IOException {
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(null, null);
ks.setCertificateEntry(alias, cert);
// store keystore
ks.store(out, HttpClientUtil.str2CharArray(password));
}
public static InputStream String2Inputstream(String str) {
return new ByteArrayInputStream(str.getBytes());
}
/**
* InputStreamת����Byte
* ע��:���ر���Ҫ���д���
* @param in
* @return byte
* @throws Exception
*/
public static byte[] InputStreamTOByte(InputStream in) throws IOException{
int BUFFER_SIZE = 4096;
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] data = new byte[BUFFER_SIZE];
int count = -1;
while((count = in.read(data,0,BUFFER_SIZE)) != -1)
outStream.write(data, 0, count);
data = null;
byte[] outByte = outStream.toByteArray();
outStream.close();
return outByte;
}
/**
* InputStreamת����String
* ע��:���ر���Ҫ���д���
* @param in
* @param encoding ����
* @return String
* @throws Exception
*/
public static String InputStreamTOString(InputStream in,String encoding) throws IOException{
return new String(InputStreamTOByte(in),encoding);
}
}
package cn.com.fqy.common.util;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.SignatureException;
import org.apache.commons.codec.digest.DigestUtils;
/**
* 功能:支付宝MD5签名处理核心文件,不需要修改
* 版本:3.3
* 修改日期:2012-08-17
* 说明:
* 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
* 该代码仅供学习和研究支付宝接口使用,只是提供一个
* */
public class MD5 {
/**
* 签名字符串
* @param text 需要签名的字符串
* @param key 密钥
* @param input_charset 编码格式
* @return 签名结果
*/
public static String sign(String text, String key, String input_charset) {
text = text + key;
return DigestUtils.md5Hex(getContentBytes(text, input_charset));
}
/**
* 签名字符串
* @param text 需要签名的字符串
* @param sign 签名结果
* @param key 密钥
* @param input_charset 编码格式
* @return 签名结果
*/
public static boolean verify(String text, String sign, String key, String input_charset) {
text = text + key;
String mysign = DigestUtils.md5Hex(getContentBytes(text, input_charset));
if(mysign.equals(sign)) {
return true;
}
else {
return false;
}
}
/**
* @param content
* @param charset
* @return
* @throws SignatureException
* @throws UnsupportedEncodingException
*/
private static byte[] getContentBytes(String content, String charset) {
if (charset == null || "".equals(charset)) {
return content.getBytes();
}
try {
return content.getBytes(charset);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset);
}
}
}
\ No newline at end of file
package cn.com.fqy.common.util;
import java.security.MessageDigest;
public class MD5Util {
public static String byteArrayToHexString(byte b[]) {
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < b.length; i++)
resultSb.append(byteToHexString(b[i]));
return resultSb.toString();
}
private static String byteToHexString(byte b) {
int n = b;
if (n < 0)
n += 256;
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
}
public static String MD5Encode(String origin, String charsetname) {
String resultString = null;
try {
resultString = new String(origin);
MessageDigest md = MessageDigest.getInstance("MD5");
if (charsetname == null || "".equals(charsetname))
resultString = byteArrayToHexString(md.digest(resultString
.getBytes()));
else
resultString = byteArrayToHexString(md.digest(resultString
.getBytes(charsetname)));
} catch (Exception exception) {
}
return resultString;
}
private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
}
package cn.com.fqy.common.util;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import org.apache.http.conn.ssl.SSLSocketFactory;
@SuppressWarnings("deprecation")
public class MySSLSocketFactory extends SSLSocketFactory{
static{
mySSLSocketFactory = new MySSLSocketFactory(createSContext());
}
private static MySSLSocketFactory mySSLSocketFactory = null;
private static SSLContext createSContext(){
SSLContext sslcontext = null;
try {
sslcontext = SSLContext.getInstance("SSL");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
/*try {
sslcontext.init(null, new TrustManager[]{new TrustAnyTrustManager()}, null);
} catch (KeyManagementException e) {
e.printStackTrace();
return null;
}*/
return sslcontext;
}
private MySSLSocketFactory(SSLContext sslContext) {
super(sslContext);
this.setHostnameVerifier(ALLOW_ALL_HOSTNAME_VERIFIER);
}
public static MySSLSocketFactory getInstance(){
if(mySSLSocketFactory != null){
return mySSLSocketFactory;
}else{
return mySSLSocketFactory = new MySSLSocketFactory(createSContext());
}
}
}
\ No newline at end of file
package cn.com.fqy.common.util;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.X509TrustManager;
public class MyX509TrustManager implements X509TrustManager{
@Override
public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
// TODO Auto-generated method stub
}
@Override
public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
// TODO Auto-generated method stub
}
@Override
public X509Certificate[] getAcceptedIssuers() {
// TODO Auto-generated method stub
return null;
}
}
package cn.com.fqy.controller.mapi;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("hello")
public class hello {
@RequestMapping("fqy")
@ResponseBody
public String fqy (){
return "fqy";
}
}
package cn.com.fqy.controller.mgt;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.fqy.common.Operator;
import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.core.common.BaseController;
import cn.com.fqy.core.common.PageFinder;
import cn.com.fqy.core.model.Administrators;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.service.AdministratorsService;
@Controller
@RequestMapping("administrators")
public class AdministratorsController extends BaseController{
@Resource
private AdministratorsService administratorsService;
/*
* 分页展示店铺管理员信息
*/
@RequestMapping("getAdministratorsList")
@ResponseBody
public PageFinder<Administrators> getAdministratorsList(Administrators administrators,Query query) {
administrators.setIsDeleted(0);
Query q = new Query(query.getPageNo(),query.getPageSize(),administrators);
return administratorsService.getAdministratorsPagedList(q);
}
/**
* 添加或修改店铺管理员信息
* @param CarPreiod
* @return
*/
@RequestMapping("addOrEditAdministrators")
@ResponseBody
public ResultInfo<Administrators> addOrEditAdministrators(Administrators administrators) {
ResultInfo<Administrators> resultInfo = new ResultInfo<>();
//操作人
Operator op = getOperator();
if (administrators!=null&&administrators.getAdministratorsId()!=null&&!"".equals(administrators.getAdministratorsId())) {
resultInfo = administratorsService.updateAdministrators(administrators, op);
}else {
resultInfo = administratorsService.addAdministrators(administrators, op);
}
return resultInfo;
}
/**
* 店铺管理员删除
* @param workerId
* @return
*/
@RequestMapping("delAdministrators")
@ResponseBody
public ResultInfo<Administrators> delAdministrators(String administratorsId ) {
ResultInfo<Administrators> resultInfo = new ResultInfo<>();
if(administratorsId == null || "".equals(administratorsId)) {
resultInfo.setCode("0");
resultInfo.setMsg("店铺管理员ID参数为空");
return resultInfo;
}
Administrators administrators = new Administrators();
administrators.setIsDeleted(1);
administrators.setAdministratorsId(administratorsId);
return administratorsService.updateAdministrators(administrators, getOperator());
}
}
package cn.com.fqy.controller.mgt;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.common.util.ECFileUtil;
import cn.com.fqy.core.common.BaseController;
import cn.com.fqy.core.common.PageFinder;
import cn.com.fqy.core.model.Advert;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.service.AdvertService;
/**
* 内容
* @author fqy
*
*/
@Controller
@RequestMapping("advert")
public class AdvertController extends BaseController{
@Resource
private AdvertService advertService;
@Value("${image_path}")
private String imagePath;
@Value("${res_file_path}")
private String storeFilePath;
@Value("${file_path}")
private String fileServer;
/**
* 分页展示广告
*/
@RequestMapping("getAdvertList")
@ResponseBody
public PageFinder<Advert> getAdvertList(@ModelAttribute("advert") Advert advert,Query query) {
Query q = new Query(query.getPageNo(),query.getPageSize(),advert);
return advertService.getAdvertPagedList(q);
}
/**
* 添加编辑广告
* @param Advert
* @return
* @throws Exception
*/
@RequestMapping("addOrEditAdvert")
@ResponseBody
public ResultInfo<Advert> addOrEditreAdvert(Advert advert) throws Exception{
ResultInfo<Advert> result = new ResultInfo<>();
if (advert.getAdvertContent()!=null&&!"".equals(advert.getAdvertContent())) {
String advertContent = advert.getAdvertContent();
advertContent = advertContent.replaceAll("src=\"image-server/", "src=\""+imagePath);
advert.setAdvertContent(advertContent);
}
if (advert!=null&&advert.getAdvertId()!=null&&!"".equals(advert.getAdvertId())) {
Advert advertQuery = advertService.getAdvertQuery(advert.getUsageSubclass());//判断使用指南子类是否已存在
if(advertQuery != null &&!advertQuery.getAdvertId().equals(advert.getAdvertId())) {
result.setCode("0");
result.setMsg("该子类已存在,请重新添加");
return result;
}
String html = "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><meta content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\" name=\"viewport\"><title>"+advert.getAdvertTitle()+"</title></head><body>" + advert.getAdvertContent() + "</body></html>";
ECFileUtil.uploadFile(html.getBytes("UTF-8"), storeFilePath, advert.getAdvertId()+".html");
advert.setLinkUrl(fileServer+advert.getAdvertId()+".html");
result = advertService.updateAdvert(advert, getOperator());
}else {
if (advert.getAdvertType()==4||advert.getAdvertType()==6) {
Advert advertQuery = new Advert();
advertQuery.setAdvertType(advert.getAdvertType());
List<Advert> advertList = advertService.getAdvertList(new Query(advertQuery));
if (advertList.size()>=1) {
result.setCode("0");
return result;
}
}
if(advert.getUsageSubclass() != null && !"".equals(advert.getUsageSubclass())) {
Advert advertQuery = advertService.getAdvertQuery(advert.getUsageSubclass());//判断使用指南子类是否已存在
if(advertQuery !=null) {
result.setCode("0");
result.setMsg("该子类已存在,请重新添加");
return result;
}
}
advert.setAdvertId(advertService.generatePK());
if (advert!=null&&advert.getAdvertContent()!=null&&!"".equals(advert.getAdvertContent())) {
String html = "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><meta content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\" name=\"viewport\"><title>"+advert.getAdvertTitle()+"</title></head><body>" + advert.getAdvertContent() + "</body></html>";
ECFileUtil.uploadFile(html.getBytes("UTF-8"), storeFilePath, advert.getAdvertId()+".html");
}
advert.setLinkUrl(fileServer+advert.getAdvertId()+".html");
result = advertService.addAdvert(advert, getOperator());
}
return result;
}
}
package cn.com.fqy.controller.mgt;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.fqy.common.PermissionListSingleton;
import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.common.SessionUtil;
import cn.com.fqy.common.constants.Constant;
import cn.com.fqy.common.util.ECMd5Utils;
import cn.com.fqy.core.common.BaseController;
import cn.com.fqy.core.common.ECMgtConstant;
import cn.com.fqy.core.model.SysPermission;
import cn.com.fqy.core.model.SysRole;
import cn.com.fqy.core.model.SysUser;
import cn.com.fqy.core.model.SysUserRoleRel;
import cn.com.fqy.core.service.SysPermissionService;
import cn.com.fqy.core.service.SysRolePermRelService;
import cn.com.fqy.core.service.SysRoleService;
import cn.com.fqy.core.service.SysUserRoleRelService;
import cn.com.fqy.core.service.SysUserService;
import cn.com.fqy.vo.SysUserVo;
@Controller
@RequestMapping
public class HomeController extends BaseController {
@Resource
public SysUserService sysUserService;
@Resource
public SysRoleService sysRoleService;
@Resource
private SysUserRoleRelService sysUserRoleRelService;
@Resource
private SysPermissionService sysPermissionService;
@Resource
private SysRolePermRelService sysRolePermRelService;
@RequestMapping("index")
public String main() {
return "index";
}
@RequestMapping("login")
@ResponseBody
public ResultInfo<SysUserVo> login(String loginName, String loginPassword, HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) {
ResultInfo<SysUserVo> result = new ResultInfo<>();
if (loginPassword != null) {
loginPassword = ECMd5Utils.crypt(loginPassword);
}
// 查询用户是否存在
SysUser sysUser = sysUserService.getSysUser(loginName, loginPassword);
// 用户被删除则不让登录
if (sysUser != null && Constant.DEL_STATE_YES != sysUser.getIsDeleted() && sysUser.getIsAvailable() != 0) {// 0:不可用
// sysUser保存到session
setLoginSysUser(request, sysUser);
setLoginSysUserRoleAdmin(request, sysUser);
// 加载资源(权限)
if (sysUser.getSysRole() != null && sysUser.getSysRole().size() > 0) {
List<SysRole> role = sysUser.getSysRole();
// role保存到session
SessionUtil.setDataToSession(request, ECMgtConstant.SESSION_KEY_OF_LOGIN_SYS_ROLE, role);
// roleId保存到session
SessionUtil.setDataToSession(request, ECMgtConstant.SESSION_KEY_OF_LOGIN_SYS_ROLEID, role);
PermissionListSingleton perListSlt = null;
String[] roleIds = new String[role.size()];
for (int i = 0; i < role.size(); i++) {
roleIds[i] = role.get(i).getRoleId();
// 存单例模式
perListSlt = PermissionListSingleton.getInstance(roleIds[i].toString());
List<SysPermission> perList = sysRolePermRelService.getAllRolePermissions(roleIds);
// 保存角色权限列表
perListSlt.setPerList(perList);
perListSlt.setPerUrlMap(perList);
sysUser.getSysRole().get(i).setPermissionIds(roleIds);
sysUser.getSysRole().get(i).setPerList(perList);
}
List<Map<String, Object>> menuList = getMenuList(roleIds, request);
SysUserVo sysUserVo = new SysUserVo();
sysUserVo.setPermissionTree(menuList);
sysUserVo.setRoleName(role.get(0).getRoleName());
sysUserVo.setUserName(sysUser.getRealName());
sysUserVo.setUserId(sysUser.getUserId());
sysUserVo.setIsAdmin(sysUser.getFlag());
result.setCode(Constant.SUCCESS);
result.setData(sysUserVo);
}else {
result.setCode(Constant.FAIL);
result.setMsg("用户身份信息无法识别");
}
return result;
} else {
result.setCode(Constant.FAIL);
result.setMsg("用户名或者密码错误");
return result;
}
}
/**
* 左菜单
*
* @param response
* @param request
* @param model
* @return
* @throws Exception
*/
@RequestMapping(value = "/leftPage")
@ResponseBody
public List<Map<String, Object>> leftPage(HttpServletResponse response, HttpServletRequest request, ModelMap model)
throws Exception {
SysUser sysUser = getLoginSysUser(request.getParameter("userId"));
if (sysUser == null) {
return null;
}
// 加载资源(权限)
List<SysUserRoleRel> sysUserRoleRel = sysUserRoleRelService.getByUserId(sysUser.getUserId());
String[] roleIds = new String[sysUserRoleRel.size()];
for (int i = 0; i < sysUserRoleRel.size(); i++) {
roleIds[i] = sysUserRoleRel.get(i).getRoleId();
}
return getMenuList(roleIds, request);
}
@RequestMapping("loginOut")
@ResponseBody
public ResultInfo<String> loginOut(HttpServletRequest request) {
ResultInfo<String> result = new ResultInfo<>();
HttpSession session = request.getSession();
removeSessionUser(request);
if (session != null) {
session.invalidate();
}
result.setCode(Constant.SUCCESS);
return result;
}
public List<Map<String, Object>> getMenuList(String[] roleId, HttpServletRequest request) {
List<SysPermission> sysPermissionList = sysRolePermRelService.getMenuList(roleId);
List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
// 资源根据层级分组
List<SysPermission> superResourceList = new ArrayList<SysPermission>();
List<SysPermission> seResourceList = new ArrayList<SysPermission>();
List<SysPermission> thResourceList = new ArrayList<SysPermission>();
if (sysPermissionList != null && sysPermissionList.size() > 0) {
Collections.sort(sysPermissionList, new ComparatorSysPermission());
for (SysPermission temp : sysPermissionList) {
if (temp.getLevel() == 1) {
superResourceList.add(temp);
} else if (temp.getLevel() == 2) {
seResourceList.add(temp);
} else {
thResourceList.add(temp);
}
}
}
// 一级菜单
for (SysPermission one : superResourceList) {
Map<String, Object> viewSysPermission = new HashMap<String, Object>();
viewSysPermission.put("path", "/"+one.getPermResource());
// 二级菜单
List<Map<String, Object>> twoList = new ArrayList<Map<String, Object>>();
for (SysPermission two : seResourceList) {
Map<String, Object> towMap = new HashMap<String, Object>();
if (two.getParentId().equals(one.getPermId())) {
towMap.put("path",two.getPermResource());
twoList.add(towMap);
}
// 三级菜单
List<Map<String, Object>> thrList = new ArrayList<Map<String, Object>>();
for (SysPermission thr : thResourceList) {
Map<String, Object> thrMap = new HashMap<String, Object>();
if (thr.getParentId().equals(two.getPermId())) {
thrMap.put("path", thr.getPermResource());
}
}
towMap.put("children", thrList);
}
viewSysPermission.put("children", twoList);
resultList.add(viewSysPermission);
}
return resultList;
}
/*
* 类型排序
*/
class ComparatorSysPermission implements Comparator<SysPermission> {
@Override
public int compare(SysPermission obj1, SysPermission obj2) {
if (obj1.getRanking() != null && obj2.getRanking() != null) {
return obj1.getRanking().compareTo(obj2.getRanking());
} else {
return 1;
}
}
}
}
\ No newline at end of file
package cn.com.fqy.controller.mgt;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.fqy.common.Operator;
import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.core.common.BaseController;
import cn.com.fqy.core.common.PageFinder;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.Store;
import cn.com.fqy.core.service.StoreService;
@Controller
@RequestMapping("store")
public class StoreController extends BaseController {
@Resource
private StoreService storeService;
/*
* 分页展示店铺信息
*/
@RequestMapping("getStoreList")
@ResponseBody
public PageFinder<Store> getStoreList(Store store,Query query) {
store.setIsDeleted(0);
Query q = new Query(query.getPageNo(),query.getPageSize(),store);
return storeService.getStorePagedList(q);
}
/**
* 添加或修改店铺信息
* @param CarPreiod
* @return
*/
@RequestMapping("addOrEditStore")
@ResponseBody
public ResultInfo<Store> addOrEditStore(Store store) {
ResultInfo<Store> resultInfo = new ResultInfo<>();
//操作人
Operator op = getOperator();
if (store!=null&&store.getStoreId()!=null&&!"".equals(store.getStoreId())) {
resultInfo = storeService.updateStore(store, op);
}else {
resultInfo = storeService.addStore(store, op);
}
return resultInfo;
}
/**
* 店铺删除
* @param workerId
* @return
*/
@RequestMapping("delStore")
@ResponseBody
public ResultInfo<Store> delStore(String storeId ) {
ResultInfo<Store> resultInfo = new ResultInfo<>();
if(storeId == null || "".equals(storeId)) {
resultInfo.setCode("0");
resultInfo.setMsg("店铺ID参数为空");
return resultInfo;
}
Store store = new Store();
store.setIsDeleted(1);
store.setStoreId(storeId);
return storeService.updateStore(store, getOperator());
}
}
package cn.com.fqy.controller.mgt;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.fqy.common.Operator;
import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.core.common.BaseController;
import cn.com.fqy.core.common.PageFinder;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.SysParam;
import cn.com.fqy.core.service.SysParamService;
@Controller
@RequestMapping("sysParam")
public class SysParamController extends BaseController {
@Resource
private SysParamService sysParamService;
/*
* 根据参数名查找一条信息
*/
@RequestMapping("getByParamName")
@ResponseBody
public ResultInfo<SysParam> getByParamName(String paramName) {
ResultInfo<SysParam> resultInfo = new ResultInfo<SysParam>();
SysParam sysParam = sysParamService.getByParamName(paramName);
if (sysParam == null) {
resultInfo.setCode("2");
} else {
resultInfo.setCode("1");
}
return resultInfo;
}
/*
* 添加或修改系统参数
*/
@RequestMapping("addOrEditSysParam")
@ResponseBody
public ResultInfo<SysParam> addOrEditSysParam(SysParam sysParam) {
// 操作人
Operator op = getOperator();
if (op != null) {
sysParam.setOperatorId(op.getOperatorId());
sysParam.setOperatorType(op.getOperatorType());
}
ResultInfo<SysParam> resultInfo = sysParamService.addOrEditSysParam(sysParam);
return resultInfo;
}
/*
* 删除系统参数
*/
@RequestMapping("deleteSysParam")
@ResponseBody
public ResultInfo<SysParam> deleteSysParam(@RequestParam("sysParamId") String sysParamId) {
return sysParamService.delete(sysParamId, getOperator());
}
/*
* 分页展示系统参数
*/
@RequestMapping("getSysParamList")
@ResponseBody
public PageFinder<SysParam> getSysParamList(@ModelAttribute("sysParam") SysParam sysParam, Query query) {
Query q = new Query(query.getPageNo(), query.getPageSize(), sysParam);
return sysParamService.pageList(q);
}
/*
* 批量删除系统参数组
*/
@RequestMapping("batchDelete")
@ResponseBody
public ResultInfo<SysParam> batchDelete(@RequestParam("sysParamIds") String[] sysParamIds) {
return sysParamService.batchDelete(sysParamIds, getOperator());
}
}
package cn.com.fqy.controller.mgt;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.fqy.common.Operator;
import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.core.common.BaseController;
import cn.com.fqy.core.common.PageFinder;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.SysPermission;
import cn.com.fqy.core.service.SysPermissionService;
import cn.com.fqy.core.service.SysRolePermRelService;
@Controller
@RequestMapping("/sysPermission")
public class SysPermissionController extends BaseController {
@Resource
public SysPermissionService sysPermissionService;
@Resource
public SysRolePermRelService sysRolePermRelService;
/*
* 添加或修改系统权限
*/
@RequestMapping("/addOrEditSysPermission")
@ResponseBody
public ResultInfo<SysPermission> addOrEditSysPermission(SysPermission sysPermission) {
//操作人
Operator op = getOperator();
if(op != null){
sysPermission.setOperatorId(op.getOperatorId());
sysPermission.setOperatorType(op.getOperatorType());
}
if (sysPermission.getPermType()==null) {
sysPermission.setPermType(0);
}
ResultInfo<SysPermission> resultInfo = sysPermissionService.addOrEditSysPermission(sysPermission);
return resultInfo;
}
/*
* 删除系统权限
*/
@RequestMapping("deleteSysPermission")
@ResponseBody
public ResultInfo<SysPermission> deleteSysPermission(@RequestParam("permissionId") String permissionId) {
return sysPermissionService.delete(permissionId);
}
/*
* 分页展示系统权限
*/
@RequestMapping("getSysPermissionList")
@ResponseBody
public PageFinder<SysPermission> getSysUserList(@ModelAttribute("sysPermission") SysPermission sysPermission,
Query query) {
Query q = new Query(query.getPageNo(),query.getPageSize(),sysPermission);
return sysPermissionService.pageList(q);
}
/*
* 批量删除系统权限
*/
@RequestMapping("batchDelete")
@ResponseBody
public ResultInfo<SysPermission> batchDelete(@RequestParam("sysPermissionIds") String [] sysPermissionIds) {
return sysPermissionService.batchDelete(sysPermissionIds);
}
/**
* 内部url权限
*
* @param roleId
* @param request
* @return
*/
@RequestMapping("getSysPermssionTree")
@ResponseBody
public List<Map<String, Object>> getSysPermssionTree(HttpServletRequest request) {
String basePath = request.getParameter("appPath");
if (basePath == null) {
basePath = "";
}
SysPermission sysPermissin = new SysPermission();
sysPermissin.setIsAvailable(1);
Query q = new Query(sysPermissin);
List<SysPermission> sysPermissionList = sysPermissionService.list(q);
List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
// 资源根据层级分组
List<SysPermission> superResourceList = new ArrayList<SysPermission>();
List<SysPermission> seResourceList = new ArrayList<SysPermission>();
List<SysPermission> thResourceList = new ArrayList<SysPermission>();
if (sysPermissionList != null && sysPermissionList.size() > 0) {
Collections.sort(sysPermissionList, new ComparatorSysPermission());
for (SysPermission temp : sysPermissionList) {
if (temp.getLevel() == 1) {
superResourceList.add(temp);
} else if (temp.getLevel() == 2) {
seResourceList.add(temp);
} else {
thResourceList.add(temp);
}
}
}
// 一级菜单
for (SysPermission one : superResourceList) {
Map<String, Object> viewSysPermission = new HashMap<String, Object>();
viewSysPermission.put("id", one.getPermId());
viewSysPermission.put("name", one.getMenuName());
viewSysPermission.put("iconName", one.getIconName());
viewSysPermission.put("link", basePath + one.getPermResource());
viewSysPermission.put("sort", one.getRanking());
viewSysPermission.put("parentId", "#");
// 二级菜单
List<Map<String, Object>> twoList = new ArrayList<Map<String, Object>>();
for (SysPermission two : seResourceList) {
Map<String, Object> towMap = new HashMap<String, Object>();
if (two.getParentId().equals(one.getPermId())) {
towMap.put("id", two.getPermId());
towMap.put("name", two.getMenuName());
towMap.put("iconName", two.getIconName());
towMap.put("link", basePath + two.getPermResource());
towMap.put("sort", two.getRanking());
towMap.put("parentId", two.getParentId());
twoList.add(towMap);
}
// 三级菜单
List<Map<String, Object>> thrList = new ArrayList<Map<String, Object>>();
for (SysPermission thr : thResourceList) {
Map<String, Object> thrMap = new HashMap<String, Object>();
if (thr.getParentId().equals(two.getPermId())) {
thrMap.put("id", thr.getPermId());
thrMap.put("name", thr.getMenuName());
thrMap.put("iconName", thr.getIconName());
thrMap.put("link", thr.getPermResource());
thrMap.put("sort", thr.getRanking());
thrMap.put("parentId", thr.getParentId());
thrList.add(thrMap);
}
}
towMap.put("children", thrList);
}
viewSysPermission.put("children", twoList);
resultList.add(viewSysPermission);
}
return resultList;
}
/*
* 根据角色id获取权限列表
*
*/
@RequestMapping("getSysPermissionByRoleId")
@ResponseBody
public String[] getSysPermissionByRoleId(String[] roleIds) {
List<SysPermission> list = sysRolePermRelService.getAllRolePermissions(roleIds);
String[] permids = new String[list.size()];
for(int i=0;i<list.size();i++) {
permids[i] = list.get(i).getPermId();
}
return permids;
}
/*
* 类型排序
*/
class ComparatorSysPermission implements Comparator<SysPermission> {
@Override
public int compare(SysPermission obj1, SysPermission obj2) {
if (obj1.getRanking() != null && obj2.getRanking() != null) {
return obj1.getRanking().compareTo(obj2.getRanking());
} else {
return 1;
}
}
}
/*
* 详情
*/
@RequestMapping("detail")
@ResponseBody
public SysPermission detail(@RequestParam("permId") String permId) {
return sysPermissionService.detail(permId);
}
}
package cn.com.fqy.controller.mgt;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.fqy.common.Operator;
import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.common.constants.Constant;
import cn.com.fqy.core.common.BaseController;
import cn.com.fqy.core.common.PageFinder;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.SysRole;
import cn.com.fqy.core.service.SysRoleService;
@Controller
@RequestMapping("/sysRole")
public class SysRoleController extends BaseController {
@Resource
public SysRoleService sysRoleService;
/*
* 添加或修改系统用户
*/
@RequestMapping("/addOrEditSysRole")
@ResponseBody
public synchronized ResultInfo<SysRole> addOrEditSysRole(SysRole sysRole) {
ResultInfo<SysRole> resultInfo = new ResultInfo<>();
if (sysRole.getRoleId() == null || "".equals(sysRole.getRoleId())) {
SysRole querySysRole = sysRoleService.getRoleByName(sysRole.getRoleName());
if(querySysRole != null){
resultInfo.setMsg("角色已经存在");
resultInfo.setCode(Constant.FAIL);
return resultInfo;
}
}
//操作人
Operator op = getOperator();
if(op != null){
sysRole.setOperatorId(op.getOperatorId());
sysRole.setOperatorType(op.getOperatorType());
}
try{
sysRoleService.addOrUpdateSysRole(sysRole);
resultInfo.setCode(Constant.SUCCESS);
}catch (Exception e){
resultInfo.setMsg(e.getMessage());
resultInfo.setCode(Constant.FAIL);
}
return resultInfo;
}
/*
* 删除系统角色
*/
@RequestMapping("deleteSysRole")
@ResponseBody
public ResultInfo<SysRole> deleteSysRole(@RequestParam("roleId") String roleId) {
return sysRoleService.delete(roleId,getOperator());
}
/*
* 分页展示系统角色
*/
@RequestMapping("getSysRoleList")
@ResponseBody
public PageFinder<SysRole> getSysRoleList(@ModelAttribute("SysRole") SysRole sysRole,Query query) {
sysRole.setIsDeleted(0);
Query q = new Query(query.getPageNo(),query.getPageSize(),sysRole);
return sysRoleService.pageList(q);
}
/*
* 查询角色列表
*/
@RequestMapping("queryAllSysRole")
@ResponseBody
public List<SysRole> queryAllSysRole() {
SysRole sysRole = new SysRole();
sysRole.setIsDeleted(0);
Query q = new Query(sysRole);
return sysRoleService.queryAll(q);
}
/*
* 批量删除系统角色
*/
@RequestMapping("batchDelete")
@ResponseBody
public ResultInfo<SysRole> batchDelete(@RequestParam("sysRoleIds") String [] sysRoleIds) {
return sysRoleService.batchDelete(sysRoleIds,getOperator());
}
/*
* 详情
*/
@RequestMapping("detail")
@ResponseBody
public SysRole detail(@RequestParam("roleId") String roleId) {
return sysRoleService.detail(roleId);
}
}
package cn.com.fqy.controller.mgt;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.fqy.common.Operator;
import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.common.constants.Constant;
import cn.com.fqy.common.util.ECMd5Utils;
import cn.com.fqy.core.common.BaseController;
import cn.com.fqy.core.common.PageFinder;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.SysRole;
import cn.com.fqy.core.model.SysUser;
import cn.com.fqy.core.model.SysUserRoleIds;
import cn.com.fqy.core.service.SysRoleService;
import cn.com.fqy.core.service.SysUserRoleRelService;
import cn.com.fqy.core.service.SysUserService;
@Controller
@RequestMapping("sysUser")
public class SysUserController extends BaseController {
@Resource
public SysUserService sysUserService;
@Resource
public SysRoleService sysRoleService;
@Resource
public SysUserRoleRelService sysUserRoleRelService;
/*
* 修改密码操作
*/
@RequestMapping("updatePassword")
@ResponseBody
public ResultInfo<SysUser> editPassword(SysUser sysUser,String oldPassword,HttpServletRequest request) {
ResultInfo<SysUser> resultInfo=new ResultInfo<SysUser>();
if(getLoginSysUser(request.getParameter("userId"))!=null){
SysUser user=sysUserService.detail(sysUser.getUserId());
if(user.getPassword().equals(ECMd5Utils.crypt(oldPassword))){
user.setPassword(sysUser.getPassword());
resultInfo=sysUserService.addOrEditSysUser(user);
}else{
resultInfo.setCode("3");
resultInfo.setMsg("原密码输入不正确,请重新输入!");
}
}else{
resultInfo.setCode("2");
resultInfo.setMsg("登录超时,请重新登录!");
}
return resultInfo;
}
/*
* 添加或修改系统用户
*/
@RequestMapping("addOrEditSysUser")
@ResponseBody
public ResultInfo<SysUser> addOrEditSysUser(SysUserRoleIds sysUserRoleIds) {
ResultInfo<SysUser> resultInfo = new ResultInfo<>();
//操作人
Operator op = getOperator();
SysUser sysUser = new SysUser();
sysUser.setUserId(sysUserRoleIds.getUserId());
sysUser.setUserName(sysUserRoleIds.getUserName());
sysUser.setRealName(sysUserRoleIds.getRealName());
sysUser.setIsAvailable(sysUserRoleIds.getIsAvailable());
sysUser.setMemo(sysUserRoleIds.getMemo());
sysUser.setPassword(sysUserRoleIds.getPassword());
sysUser.setMobilePhone(sysUserRoleIds.getMobilePhone());
sysUser.setSex(sysUserRoleIds.getSex());
sysUser.setDeptId(sysUserRoleIds.getDeptId());
if (sysUserRoleIds.getSysRole()!=null) {
String[] roleIds = sysUserRoleIds.getSysRole();
List<SysRole> sysRoles = new ArrayList<SysRole>();
for(int i=0;i<roleIds.length;i++){
SysRole sysRole = new SysRole();
sysRole.setRoleId(roleIds[i]);
sysRoles.add(sysRole);
}
sysUser.setSysRole(sysRoles);
}else {
resultInfo.setCode(Constant.FAIL);
resultInfo.setMsg("请先选择角色");
return resultInfo;
}
if(op != null){
sysUser.setOperatorId(op.getOperatorId());
sysUser.setOperatorType(op.getOperatorType());
}
resultInfo = sysUserService.addOrEditSysUser(sysUser);
return resultInfo;
}
/*
* 删除系统用户
*/
@RequestMapping("deleteSysUser")
@ResponseBody
public ResultInfo<SysUser> deleteSysUser(@RequestParam("userId") String userId) {
return sysUserService.delete(userId,getOperator());
}
/*
* 分页展示系统用户
*/
@RequestMapping("getSysUserList")
@ResponseBody
public PageFinder<SysUser> getSysUserList(@ModelAttribute("sysUser") SysUser sysUser,Query query) {
sysUser.setIsDeleted(0);
sysUser.setUserId(null);
Query q = new Query(query.getPageNo(),query.getPageSize(),sysUser);
return sysUserService.pageList2(q);
}
/*
* 根据角色获取用户列表
*/
@RequestMapping("getSysUserListByRole")
@ResponseBody
public List<SysUser> getSysUserListByRole(@RequestParam("roleName") String roleName) {
SysRole sysRole=sysRoleService.getRoleByName(roleName);
return sysUserRoleRelService.getAllUser(sysRole.getRoleId());
}
/*
* 批量删除系统参数组
*/
@RequestMapping("batchDelete")
@ResponseBody
public ResultInfo<SysUser> batchDelete(@RequestParam("sysUserIds") String [] sysUserIds) {
return sysUserService.batchDelete(sysUserIds,getOperator());
}
/*
* 详情
*/
@RequestMapping("detail")
@ResponseBody
public SysUser detail(@RequestParam("userId") String userId) {
return sysUserService.detail(userId);
}
}
package cn.com.fqy.controller.mgt;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.fqy.common.Operator;
import cn.com.fqy.common.ResultInfo;
import cn.com.fqy.core.common.BaseController;
import cn.com.fqy.core.common.PageFinder;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.Worker;
import cn.com.fqy.core.service.WorkerService;
@Controller
@RequestMapping("worker")
public class WorkerController extends BaseController {
@Resource
private WorkerService workerService;
/*
* 分页展示员工信息
*/
@RequestMapping("getWorkerList")
@ResponseBody
public PageFinder<Worker> getWorkerList(Worker worker,Query query) {
worker.setIsDeleted(0);
Query q = new Query(query.getPageNo(),query.getPageSize(),worker);
return workerService.getWorkerPagedList(q);
}
/**
* 添加或修改员工信息
* @param CarPreiod
* @return
*/
@RequestMapping("addOrEditWorker")
@ResponseBody
public ResultInfo<Worker> addOrEditWorker(Worker worker) {
ResultInfo<Worker> resultInfo = new ResultInfo<>();
//操作人
Operator op = getOperator();
if (worker!=null&&worker.getWorkerId()!=null&&!"".equals(worker.getWorkerId())) {
resultInfo = workerService.updateWorker(worker, op);
}else {
resultInfo = workerService.addWorker(worker, op);
}
return resultInfo;
}
/**
* 员工删除
* @param workerId
* @return
*/
@RequestMapping("delWorker")
@ResponseBody
public ResultInfo<Worker> delWorker(String workerId ) {
ResultInfo<Worker> resultInfo = new ResultInfo<>();
if(workerId == null || "".equals(workerId)) {
resultInfo.setCode("0");
resultInfo.setMsg("员工ID参数为空");
return resultInfo;
}
Worker worker = new Worker();
worker.setIsDeleted(1);
worker.setWorkerId(workerId);
return workerService.updateWorker(worker,getOperator());
}
}
package cn.com.fqy.core.common;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import cn.com.fqy.common.Operator;
import cn.com.fqy.common.util.ECCustomerDateEditor;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.SysRole;
import cn.com.fqy.core.model.SysUser;
import cn.com.fqy.core.model.SysUserRoleRel;
import cn.com.fqy.core.service.SysParamService;
import cn.com.fqy.core.service.SysRoleService;
import cn.com.fqy.core.service.SysUserRoleRelService;
public class BaseController {
@Resource
HttpServletRequest request;
@Resource
private SysParamService sysParamService;
@Resource
private SysUserRoleRelService sysUserRoleRelService;
@Resource
private SysRoleService sysRoleService;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(Date.class, new ECCustomerDateEditor());
}
/**
* 取HttpSession对象
*
* @return
*/
public HttpSession getSession() {
return request.getSession();
}
/**
* 设置用户的登录信息
*
* @Title: setLoginSysUser
* @Description: TODO
* @param request
* @param sysUser
* @return
*/
public static boolean setLoginSysUser(HttpServletRequest request, SysUser sysUser) {
try {
// request.getSession().setAttribute(ECMgtConstant.SESSION_KEY_OF_LOGIN_SYS_USER, sysUser);
SysUserMapSingleton.getInstance().saveUser(sysUser.getUserId(), sysUser);
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 取已登录的系统人员用户对象(数据来自session)
*
* @return
*/
public SysUser getLoginSysUser(String userId) {
SysUser sysUser = null;
HttpSession session = getSession();
if (session != null) {
// sysUser = (SysUser) session.getAttribute(ECMgtConstant.SESSION_KEY_OF_LOGIN_SYS_USER); // 从session中取已登录的系统人员用户对象
sysUser = (SysUser) SysUserMapSingleton.getInstance().getSysUserByUserId(userId);
}
return sysUser;
}
/**
* 设置用户的角色是否含系统管理员的标识信息
*
* @Title: setLoginSysUser
* @Description: TODO
* @param request
* @param sysUser
* @return
*/
public boolean setLoginSysUserRoleAdmin(HttpServletRequest request,SysUser sysUser) {
try {
Integer roleAdminTag=0;
//判断当前登录用户的角色是不是系统管理员
if(sysUser!=null){
List<SysUserRoleRel> list=sysUserRoleRelService.getByUserId(sysUser.getUserId());
if(list!=null&&list.size()>0){
SysRole sysRole=new SysRole();
sysRole.setRoleName("系统管理员");
List<SysRole> roleList=sysRoleService.queryAll(new Query(sysRole));
if(roleList!=null&&roleList.size()>0){
sysRole=roleList.get(0);
for(SysUserRoleRel surr:list){
if(surr.getRoleId().equals(sysRole.getRoleId())){
roleAdminTag=1;
}
}
}
}
}
request.getSession().setAttribute(ECMgtConstant.SESSION_KEY_OF_LOGIN_SYS_ROLE_ADMIN_TAG, roleAdminTag);
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 取已登录的系统人员用户角色是否含系统管理员的标识信息(数据来自session)
*
* @return
*/
public Integer getLoginSysUserRoleAdmin() {
Integer roleAdminTag=0;
HttpSession session = getSession();
if (session != null) {
roleAdminTag = (Integer) session.getAttribute(ECMgtConstant.SESSION_KEY_OF_LOGIN_SYS_ROLE_ADMIN_TAG); // 从session中取已登录的系统人员用户对象
}
return roleAdminTag;
}
/**
* 移除session 属性
*
* @Title: removeSessionAttribut
* @Description: TODO
* @param request
* @param key
*/
public static void removeSessionAttribut(HttpServletRequest request, String key) {
request.getSession().removeAttribute(key);
}
/**
* 移除登陆用户
*
* @Title: removeSessionAttribut
* @Description: TODO
* @param request
* @param key
*/
public static void removeSessionUser(HttpServletRequest request) {
removeSessionAttribut(request, ECMgtConstant.SESSION_KEY_OF_LOGIN_SYS_USER);
}
/**
* 将系统平台人员用户对象,转为通用操作员对象
*
* @param sysUser
* @return
*/
public Operator convertSysUser2Operator(SysUser sysUser) {
Operator op = null;
if (sysUser != null) {
op = new Operator(ECCoreConstant.OPERATOR_TYPE_SYS_USER, sysUser.getUserId(), sysUser.getUserName(),sysUser.getRealName(),sysUser.getMobilePhone());
}
return op;
}
/**
* 取通用操作员对象(数据来自session中的SysUser对象,并转为Operator对象)
*
* @return
*/
public Operator getOperator() {
return convertSysUser2Operator(getLoginSysUser(request.getParameter("userId")));
}
public HttpServletRequest getRequest() {
return request;
}
}
package cn.com.fqy.core.common;
import java.io.Serializable;
import java.util.List;
import cn.com.fqy.core.model.Query;
/**
* 数据对象基础操作类
* @author fqy
*
*/
public interface BaseDao<T,PK extends Serializable> {
/**
* 增加对象
* @param obj
*/
public int add(T obj);
/**
* 修改对象
* @param obj
*/
public int update(T obj);
/**
* 根据主键删除对象
* @param pk
*/
public int delete(PK pk);
/**
* 根据主键得到某个对象
* @param pk
*/
public T get(PK pk);
/**
* 根据一组主键(数组),得到多个对象,以列表形式返回
* @param pks
* @return
*/
public List<T> getByIds(PK[] pks);
/**
* 根据条件查询数据条件
* @param q
* @return
*/
public Long count(Query q);
/**
* 根据条件查询数据
* @param q
* @return
*/
public List<T> queryAll(Query q);
/**
* 根据条件查询数据
* @param q
* @return
*/
public List<T> queryOrderInfo(Query q);
/**
* 根据条件查询数据
* @param q
* @return
*/
public List<T> pageList(Query q);
}
package cn.com.fqy.core.common;
/**
* 数据对象基础服务类
* @author fqy
*
*/
public interface BaseService {
}
package cn.com.fqy.core.common;
/**
* 电商核心业务-公共常量设置类
* @author fqy
*
*/
public class ECCoreConstant {
/**业务操作人员类型-系统自动操作(如定时任务等)*/
public static final int OPERATOR_TYPE_SYS_AUTO = 0;
/**业务操作人员类型-系统平台人员*/
public static final int OPERATOR_TYPE_SYS_USER = 1;
/**业务操作人员类型-商家用户(建议以后不使用此类型,均改为用OPERATOR_TYPE_MEMBER_USER//0610,lule)*/
@Deprecated
public static final int OPERATOR_TYPE_SELLER_USER = 2;
/**业务操作人员类型-买家会员(建议以后不使用此类型,均改为用OPERATOR_TYPE_MEMBER_USER//0610,lule)*/
@Deprecated
public static final int OPERATOR_TYPE_BUYER_MEMBER = 3;
/**业务操作人员类型-客户会员用户*/
public static final int OPERATOR_TYPE_MEMBER_USER = 4;
/**邮箱验证*/
public static final String SIGNATURE = "one|health";
/**修改邮箱请求地址 */
public static final String CHANGEEMAILURL = "reviewRequestUrl.do?key=";
}
package cn.com.fqy.core.common;
/**
* b2b-mgt工程(web工程)的公共常量类
*
*/
public class ECMgtConstant {
/**
* Session中的键,其值为已登录系统操作人用户对象
*/
public static final String SESSION_KEY_OF_LOGIN_SYS_USER = "SESSION_KEY_OF_LOGIN_SYS_USER";
/**
* Session中的键,其值为已登录系统操作人角色id
*/
public static final String SESSION_KEY_OF_LOGIN_SYS_ROLEID = "SESSION_KEY_OF_LOGIN_SYS_ROLEID";
/**
* Session中的键,其值为已登录系统操作人角色
*/
public static final String SESSION_KEY_OF_LOGIN_SYS_ROLE = "SESSION_KEY_OF_LOGIN_SYS_ROLE";
/**
* Session中的键,其值为已登录系统操作人角色
*/
public static final String SESSION_KEY_OF_LOGIN_SYS_ROLE_ADMIN_TAG = "SESSION_KEY_OF_LOGIN_SYS_ROLE_ADMIN_TAG";
}
package cn.com.fqy.core.common;
import java.io.Serializable;
import java.util.List;
import cn.com.fqy.common.constants.Constant;
/**
* 分页对象. 包含当前页数据及分页信息
*
*/
@SuppressWarnings("serial")
public class PageFinder<T> implements Serializable {
/**
* 每页的记录数
*/
private long pageSize = Constant.DEFAULT_PAGE_SIZE;
/**
* 当前页中存放的数据
*/
private List<T> data;
/**
* 总记录数
*/
private long rowCount;
/**
* 总页数
*/
private long pageCount;
/**
* 当前第几页
*/
private long pageNo;
/**
* 是否有上一页
*/
private boolean hasPrevious = false;
/**
* 是否有下一页
*/
private boolean hasNext = false;
public PageFinder() {
refresh();
}
public PageFinder(long pageNo, long rowCount) {
this.pageNo = pageNo;
this.rowCount = rowCount;
this.pageCount = getTotalPageCount();
refresh();
}
/**
* 构造方法
*/
public PageFinder(long pageNo, long pageSize, long rowCount) {
this.pageNo = pageNo;
this.pageSize = pageSize;
this.rowCount = rowCount;
this.pageCount = getTotalPageCount();
refresh();
}
/**
*
*/
public PageFinder(long pageNo, long pageSize, long rowCount, List<T> data) {
this.pageNo = pageNo;
this.pageSize = pageSize;
this.rowCount = rowCount;
this.pageCount = getTotalPageCount();
this.data = data;
refresh();
}
/**
* 取总页数
*/
private final long getTotalPageCount() {
if (rowCount % pageSize == 0)
return rowCount / pageSize;
else
return rowCount / pageSize + 1;
}
/**
* 刷新当前分页对象数据
*/
private void refresh() {
if (pageCount <= 1) {
hasPrevious = false;
hasNext = false;
} else if (pageNo == 1) {
hasPrevious = false;
hasNext = true;
} else if (pageNo == pageCount) {
hasPrevious = true;
hasNext = false;
} else {
hasPrevious = true;
hasNext = true;
}
}
/**
* 取每页数据数
*/
public long getPageSize() {
return pageSize;
}
/**
* 取当前页中的记录.
*/
public Object getResult() {
return data;
}
public List<T> getData() {
return data;
}
public void setData(List<T> data) {
this.data = data;
}
public long getRowCount() {
return rowCount;
}
public void setRowCount(long rowCount) {
this.rowCount = rowCount;
}
public long getPageCount() {
return pageCount;
}
public void setPageCount(long pageCount) {
this.pageCount = pageCount;
}
public long getPageNo() {
return pageNo;
}
public void setPageNo(long pageNo) {
this.pageNo = pageNo;
}
public boolean isHasPrevious() {
return hasPrevious;
}
public void setHasPrevious(boolean hasPrevious) {
this.hasPrevious = hasPrevious;
}
public boolean isHasNext() {
return hasNext;
}
public void setHasNext(boolean hasNext) {
this.hasNext = hasNext;
}
public void setPageSize(long pageSize) {
this.pageSize = pageSize;
}
/**
* 获取跳转页第一条数据在数据集的位置
*/
public long getStartOfPage() {
return (pageNo - 1) * pageSize;
}
}
\ No newline at end of file
package cn.com.fqy.core.common;
import java.util.concurrent.ConcurrentHashMap;
/**
* 设备序列号及其签名数据的持有类
*
*/
public class SysUserMapSingleton {
private ConcurrentHashMap<String, Object> sysUserMap = new ConcurrentHashMap<String, Object>();
private static SysUserMapSingleton instance = new SysUserMapSingleton(); //单例
private SysUserMapSingleton() { //单例,私有构造函数
}
/**
* 返回SysUserMapSingleton的实例(单例)
* @return
*/
public static SysUserMapSingleton getInstance() {
return instance;
}
/**
* 存入user对象,键是userId
* @param userId
* @param obj
*/
public void saveUser(String userId,Object obj) {
if(userId == null || userId.length() == 0 ) {
return;
}
sysUserMap.put(userId, obj);
}
/**
* 根据userId,取回user对象
* @param sign
* @return
*/
public Object getSysUserByUserId(String userId) {
if(userId == null || userId.length() == 0 ) {
return null;
}
return sysUserMap.get(userId);
}
}
package cn.com.fqy.core.common;
import java.util.UUID;
public class TokenGeneratorUtil {
/**
* 生成一个UUID串(32个字符,其中的字母为小写)
* @return
* @throws
*/
public static String genUUID() {
return UUID.randomUUID().toString().replaceAll("-", "");
}
public static String tokenGenerator(){
return genUUID();
}
public static void main(String[] args) {
System.out.println(TokenGeneratorUtil.tokenGenerator());;
}
}
package cn.com.fqy.core.dao;
import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.Administrators;
/**
* Administrators 数据库处理类
*/
public interface AdministratorsDao extends BaseDao<Administrators,String> {
}
package cn.com.fqy.core.dao;
import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.Advert;
/**
* Advert 数据库处理类
*/
public interface AdvertDao extends BaseDao<Advert,String> {
/**
* 根据条件查询返回一个对象
* @param usageSubclass
* @return
*/
public Advert getAdvertQuery(String usageSubclass);
}
package cn.com.fqy.core.dao;
import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.Store;
/**
* Store 数据库处理类
*/
public interface StoreDao extends BaseDao<Store,String> {
}
package cn.com.fqy.core.dao;
import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.SysParam;
/**
* SysParam 数据库处理类
*/
public interface SysParamDao extends BaseDao<SysParam,String> {
/**
* 根据key得到参数
*/
public SysParam getByParamKey(String key);
/**
* 根据参数名查找一条信息
*/
public SysParam getByParamName(String paramNames);
}
package cn.com.fqy.core.dao;
import java.util.List;
import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.SysPermission;
/**
* SysPermission 数据库处理类
*/
public interface SysPermissionDao extends BaseDao<SysPermission,String>{
public Long count1(Query q);
public List<SysPermission> pageList1(Query q);
//根据二级菜单ID获取父ID
List<String> getParentIdByChildrenIds(String[] ids);
}
package cn.com.fqy.core.dao;
import org.apache.ibatis.annotations.Param;
import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.SysRole;
/**
* SysRole 数据库处理类
*/
public interface SysRoleDao extends BaseDao<SysRole,String> {
public SysRole getRoleByName(@Param("roleName") String roleName);
}
package cn.com.fqy.core.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.SysPermission;
import cn.com.fqy.core.model.SysRolePermRel;
/**
* SysRolePermRel 数据库处理类
*/
public interface SysRolePermRelDao extends BaseDao<SysRolePermRel,String>{
/**
* 查询对应角色下所有权限
*/
public List<SysPermission> getAllRolePermissions(@Param("roleIds")String[] roleIds);
/**
* 查询对应角色下所有菜单
*/
public List<SysPermission> getMenuList(@Param("roleIds") String[] roleId);
/**
* 查询对应角色下所有Url
*/
public List<SysPermission> getMenuList2(@Param("roleIds") String[] roleId);
/**
* 根据角色id删除角色权限关联表记录
* @param roleId
*/
public int deleteByRoleId(String roleId);
/**
* 删除该权限关联的角色关系
* @param permId
*/
public int deleteByPermId(String permId);
/**
* 根据模块名获取操作权限
* @param roleId
* @param record
* @return
*/
public List<SysPermission> selectHandleByModel(@Param("roleIds") String[] roleId, @Param("record") SysPermission record);
}
package cn.com.fqy.core.dao;
import java.util.List;
import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.Query;
import cn.com.fqy.core.model.SysUser;
/**
* SysUser 数据库处理类
*/
public interface SysUserDao extends BaseDao<SysUser,String>{
public SysUser getSysUser(String loginName, String loginPassword);
public Long count2(Query q);
public List<SysUser> pageList2(Query q);
Long getCheckExistsByName(String name);
/**
* 根据一组主键(数组),得到多个对象,以列表形式返回
* @param pks
* @return
*/
public List<SysUser> getByIds(String[] ids);
}
package cn.com.fqy.core.dao;
import java.util.List;
import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.SysRole;
import cn.com.fqy.core.model.SysUser;
import cn.com.fqy.core.model.SysUserRoleRel;
/**
* SysUserRoleRel 数据库处理类
*/
public interface SysUserRoleRelDao extends BaseDao<SysUserRoleRel,String>{
/**
* 删除对象(组合主键)
* @param roleId,userId
*/
public int delete(String roleId,String userId);
/**
* 得到某个对象(组合主键)
* @param roleId,userId
*/
public SysUserRoleRel get(String roleId,String userId);
/**
* 得到某个对象
* @param userId
*/
public List<SysUserRoleRel> getByUserId(String userId);
/**
* 根据角色id删除角色用户关联表记录
* @param roleId
*/
public int deleteByRoleId(String roleId);
/**
* 根据用户id删除角色用户关联表记录
* @param userId
*/
public int deleteByUserId(String userId);
/**
* 根据用户id得到角色列表
* @param userId
*/
public List<SysRole> getAllUserRole(String userId);
/**
* 根据角色id获取用户列表*/
public List<SysUser> getAllUser(String roleId);
}
package cn.com.fqy.core.dao;
import cn.com.fqy.core.common.BaseDao;
import cn.com.fqy.core.model.Worker;
/**
* Worker 数据库处理类
*/
public interface WorkerDao extends BaseDao<Worker,String> {
}
package cn.com.fqy.core.model;
import java.util.Date;
import cn.com.fqy.common.Entity;
/**
* Administrators 数据实体类
*/
public class Administrators extends Entity<String> {
private static final long serialVersionUID = 1l;
/*Auto generated properties start*/
//管理员编号
private String administratorsId;
//所管店铺
private String managementShops;
//联系电话
private String contactNumber;
//微信
private String wechat;
//QQ
private String qq;
//二维码
private String qrCode;
//是否审核
private Integer isAuditing;
//权限
private String power;
//系统管理员编号
private String systemId;
//创建时间
private Date createTime;
//创建时间 时间范围起(查询用)
private Date createTimeStart;
//创建时间 时间范围止(查询用)
private Date createTimeEnd;
//修改时间
private Date updateTime;
//修改时间 时间范围起(查询用)
private Date updateTimeStart;
//修改时间 时间范围止(查询用)
private Date updateTimeEnd;
//操作人ID
private String operatorId;
//操作人类型
private Integer operatorType;
//管理员名称
private String administratorsName;
//是否删除(0未删除 1 删除)
private Integer isDeleted;
/*Auto generated properties end*/
/*Customized properties start*/
/*Customized properties end*/
/*Auto generated methods start*/
public Integer getIsDeleted() {
return isDeleted;
}
public void setIsDeleted(Integer isDeleted) {
this.isDeleted = isDeleted;
}
@Override
public String getPK(){
return administratorsId;
}
public String getAdministratorsName() {
return administratorsName;
}
public void setAdministratorsName(String administratorsName) {
this.administratorsName = administratorsName;
}
public String getAdministratorsId(){
return administratorsId;
}
public void setAdministratorsId(String administratorsId){
this.administratorsId = administratorsId;
}
public String getManagementShops(){
return managementShops;
}
public void setManagementShops(String managementShops){
this.managementShops = managementShops;
}
public String getContactNumber(){
return contactNumber;
}
public void setContactNumber(String contactNumber){
this.contactNumber = contactNumber;
}
public String getWechat(){
return wechat;
}
public void setWechat(String wechat){
this.wechat = wechat;
}
public String getQq(){
return qq;
}
public void setQq(String qq){
this.qq = qq;
}
public String getQrCode(){
return qrCode;
}
public void setQrCode(String qrCode){
this.qrCode = qrCode;
}
public Integer getIsAuditing(){
return isAuditing;
}
public void setIsAuditing(Integer isAuditing){
this.isAuditing = isAuditing;
}
public String getPower(){
return power;
}
public void setPower(String power){
this.power = power;
}
public String getSystemId(){
return systemId;
}
public void setSystemId(String systemId){
this.systemId = systemId;
}
public Date getCreateTime(){
return createTime;
}
public void setCreateTime(Date createTime){
this.createTime = createTime;
}
public Date getCreateTimeStart(){
return createTimeStart;
}
public void setCreateTimeStart(Date createTimeStart){
this.createTimeStart = createTimeStart;
}
public Date getCreateTimeEnd(){
return createTimeEnd;
}
public void setCreateTimeEnd(Date createTimeEnd){
this.createTimeEnd = createTimeEnd;
}
public Date getUpdateTime(){
return updateTime;
}
public void setUpdateTime(Date updateTime){
this.updateTime = updateTime;
}
public Date getUpdateTimeStart(){
return updateTimeStart;
}
public void setUpdateTimeStart(Date updateTimeStart){
this.updateTimeStart = updateTimeStart;
}
public Date getUpdateTimeEnd(){
return updateTimeEnd;
}
public void setUpdateTimeEnd(Date updateTimeEnd){
this.updateTimeEnd = updateTimeEnd;
}
public String getOperatorId(){
return operatorId;
}
public void setOperatorId(String operatorId){
this.operatorId = operatorId;
}
public Integer getOperatorType(){
return operatorType;
}
public void setOperatorType(Integer operatorType){
this.operatorType = operatorType;
}
/*Auto generated methods end*/
/*Customized methods start*/
/*Customized methods end*/
@Override
public String toString() {
return "Administrators [administratorsId=" + administratorsId + ", managementShops=" + managementShops
+ ", contactNumber=" + contactNumber + ", wechat=" + wechat + ", qq=" + qq + ", qrCode=" + qrCode
+ ", isAuditing=" + isAuditing + ", power=" + power + ", systemId=" + systemId + ", createTime="
+ createTime + ", createTimeStart=" + createTimeStart + ", createTimeEnd=" + createTimeEnd
+ ", updateTime=" + updateTime + ", updateTimeStart=" + updateTimeStart + ", updateTimeEnd="
+ updateTimeEnd + ", operatorId=" + operatorId + ", operatorType=" + operatorType
+ ", administratorsName=" + administratorsName + ", isDeleted=" + isDeleted + "]";
}
}
package cn.com.fqy.core.model;
import java.util.Date;
import cn.com.fqy.common.Entity;
/**
* Advert 数据实体类
*/
public class Advert extends Entity<String> {
private static final long serialVersionUID = 1l;
/*Auto generated properties start*/
//广告id
private String advertId;
//广告类型广告类型(1、活动广告 2、系统公告 3、新闻资讯4、使用指南5、关于我们 )
private Integer advertType;
//广告标题
private String advertTitle;
//广告副标题
private String advertSubTitle;
//广告内容
private String advertContent;
//链接地址
private String linkUrl;
//是否启用(1、可用,0、不可用,默认0)
private Integer isAvailable;
//广告图片url
private String advertPicUrl;
//创建时间
private Date createTime;
//创建时间 时间范围起(查询用)
private Date createTimeStart;
//创建时间 时间范围止(查询用)
private Date createTimeEnd;
//修改时间
private Date updateTime;
//修改时间 时间范围起(查询用)
private Date updateTimeStart;
//修改时间 时间范围止(查询用)
private Date updateTimeEnd;
//操作人id
private String operatorId;
//操作人类型
private Integer operatorType;
private Integer type;
//使用指南子类
private String usageSubclass;
/*Auto generated properties end*/
/*Customized properties start*/
/*Customized properties end*/
/*Auto generated methods start*/
public String getUsageSubclass() {
return usageSubclass;
}
public void setUsageSubclass(String usageSubclass) {
this.usageSubclass = usageSubclass;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
@Override
public String getPK(){
return advertId;
}
public String getAdvertId(){
return advertId;
}
public void setAdvertId(String advertId){
this.advertId = advertId;
}
public Integer getAdvertType(){
return advertType;
}
public void setAdvertType(Integer advertType){
this.advertType = advertType;
}
public String getAdvertTitle(){
return advertTitle;
}
public void setAdvertTitle(String advertTitle){
this.advertTitle = advertTitle;
}
public String getAdvertSubTitle(){
return advertSubTitle;
}
public void setAdvertSubTitle(String advertSubTitle){
this.advertSubTitle = advertSubTitle;
}
public String getAdvertContent(){
return advertContent;
}
public void setAdvertContent(String advertContent){
this.advertContent = advertContent;
}
public String getLinkUrl(){
return linkUrl;
}
public void setLinkUrl(String linkUrl){
this.linkUrl = linkUrl;
}
public Integer getIsAvailable(){
return isAvailable;
}
public void setIsAvailable(Integer isAvailable){
this.isAvailable = isAvailable;
}
public String getAdvertPicUrl(){
return advertPicUrl;
}
public void setAdvertPicUrl(String advertPicUrl){
this.advertPicUrl = advertPicUrl;
}
public Date getCreateTime(){
return createTime;
}
public void setCreateTime(Date createTime){
this.createTime = createTime;
}
public Date getCreateTimeStart(){
return createTimeStart;
}
public void setCreateTimeStart(Date createTimeStart){
this.createTimeStart = createTimeStart;
}
public Date getCreateTimeEnd(){
return createTimeEnd;
}
public void setCreateTimeEnd(Date createTimeEnd){
this.createTimeEnd = createTimeEnd;
}
public Date getUpdateTime(){
return updateTime;
}
public void setUpdateTime(Date updateTime){
this.updateTime = updateTime;
}
public Date getUpdateTimeStart(){
return updateTimeStart;
}
public void setUpdateTimeStart(Date updateTimeStart){
this.updateTimeStart = updateTimeStart;
}
public Date getUpdateTimeEnd(){
return updateTimeEnd;
}
public void setUpdateTimeEnd(Date updateTimeEnd){
this.updateTimeEnd = updateTimeEnd;
}
public String getOperatorId(){
return operatorId;
}
public void setOperatorId(String operatorId){
this.operatorId = operatorId;
}
public Integer getOperatorType(){
return operatorType;
}
public void setOperatorType(Integer operatorType){
this.operatorType = operatorType;
}
/*Auto generated methods end*/
/*Customized methods start*/
/*Customized methods end*/
@Override
public String toString() {
return "Advert [advertId=" + advertId + ", advertType=" + advertType + ", advertTitle=" + advertTitle
+ ", advertSubTitle=" + advertSubTitle + ", advertContent=" + advertContent + ", linkUrl=" + linkUrl
+ ", isAvailable=" + isAvailable + ", advertPicUrl=" + advertPicUrl + ", createTime=" + createTime
+ ", createTimeStart=" + createTimeStart + ", createTimeEnd=" + createTimeEnd + ", updateTime="
+ updateTime + ", updateTimeStart=" + updateTimeStart + ", updateTimeEnd=" + updateTimeEnd
+ ", operatorId=" + operatorId + ", operatorType=" + operatorType + ", type=" + type
+ ", usageSubclass=" + usageSubclass + "]";
}
}
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