tao.mo

Merge remote-tracking branch 'origin/master'

Showing 78 changed files with 9487 additions and 18 deletions
package com.fedex.connect.common.dao.log;
import com.fedex.connect.common.model.log.UserLoginInfo;
import com.fedex.connect.common.model.log.UserLoginInfoExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface UserLoginInfoMapper {
long countByExample(UserLoginInfoExample example);
int deleteByExample(UserLoginInfoExample example);
int deleteByPrimaryKey(Long id);
int insert(UserLoginInfo record);
int insertSelective(UserLoginInfo record);
List<UserLoginInfo> selectByExample(UserLoginInfoExample example);
UserLoginInfo selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") UserLoginInfo record, @Param("example") UserLoginInfoExample example);
int updateByExample(@Param("record") UserLoginInfo record, @Param("example") UserLoginInfoExample example);
int updateByPrimaryKeySelective(UserLoginInfo record);
int updateByPrimaryKey(UserLoginInfo record);
}
\ No newline at end of file
package com.fedex.connect.common.dao.log;
\ No newline at end of file
package com.fedex.connect.common.dao.sys;
import com.fedex.connect.common.model.sys.RedisSlab;
import com.fedex.connect.common.model.sys.RedisSlabExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface RedisSlabMapper {
long countByExample(RedisSlabExample example);
int deleteByExample(RedisSlabExample example);
int deleteByPrimaryKey(Long id);
int insert(RedisSlab record);
int insertSelective(RedisSlab record);
List<RedisSlab> selectByExample(RedisSlabExample example);
RedisSlab selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") RedisSlab record, @Param("example") RedisSlabExample example);
int updateByExample(@Param("record") RedisSlab record, @Param("example") RedisSlabExample example);
int updateByPrimaryKeySelective(RedisSlab record);
int updateByPrimaryKey(RedisSlab record);
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fedex.connect.common.dao.log.UserLoginInfoMapper">
<resultMap id="BaseResultMap" type="com.fedex.connect.common.model.log.UserLoginInfo">
<id column="ID" jdbcType="NUMERIC" property="id" />
<result column="USER_ID" jdbcType="NUMERIC" property="userId" />
<result column="OPER_TYPE_ID" jdbcType="NUMERIC" property="operTypeId" />
<result column="OPER_TYPE_NAME" jdbcType="VARCHAR" property="operTypeName" />
<result column="OPER_DESC" jdbcType="VARCHAR" property="operDesc" />
<result column="IP" jdbcType="VARCHAR" property="ip" />
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
<result column="CREATE_USER_ID" jdbcType="NUMERIC" property="createUserId" />
<result column="CREATE_USER_NAME" jdbcType="VARCHAR" property="createUserName" />
<result column="MODIFY_TIME" jdbcType="TIMESTAMP" property="modifyTime" />
<result column="MODIFY_USER_ID" jdbcType="NUMERIC" property="modifyUserId" />
<result column="MODIFY_USER_NAME" jdbcType="VARCHAR" property="modifyUserName" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
ID, USER_ID, OPER_TYPE_ID, OPER_TYPE_NAME, OPER_DESC, IP, CREATE_TIME, CREATE_USER_ID,
CREATE_USER_NAME, MODIFY_TIME, MODIFY_USER_ID, MODIFY_USER_NAME
</sql>
<select id="selectByExample" parameterType="com.fedex.connect.common.model.log.UserLoginInfoExample" resultMap="BaseResultMap">
<include refid="OracleDialectPrefix" />
select
<if test="distinct">
distinct
</if>
'true' as QUERYID,
<include refid="Base_Column_List" />
from T_LOG_USER_LOGIN_INFO
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<include refid="OracleDialectSuffix" />
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from T_LOG_USER_LOGIN_INFO
where ID = #{id,jdbcType=NUMERIC}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from T_LOG_USER_LOGIN_INFO
where ID = #{id,jdbcType=NUMERIC}
</delete>
<delete id="deleteByExample" parameterType="com.fedex.connect.common.model.log.UserLoginInfoExample">
delete from T_LOG_USER_LOGIN_INFO
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.fedex.connect.common.model.log.UserLoginInfo">
<selectKey keyProperty="id" order="BEFORE" resultType="java.lang.Long">
SELECT SEQ_T_LOG_USER_LOGIN_INFO.NEXTVAL FROM DUAL
</selectKey>
insert into T_LOG_USER_LOGIN_INFO (ID, USER_ID, OPER_TYPE_ID,
OPER_TYPE_NAME, OPER_DESC, IP,
CREATE_TIME, CREATE_USER_ID, CREATE_USER_NAME,
MODIFY_TIME, MODIFY_USER_ID, MODIFY_USER_NAME
)
values (#{id,jdbcType=NUMERIC}, #{userId,jdbcType=NUMERIC}, #{operTypeId,jdbcType=NUMERIC},
#{operTypeName,jdbcType=VARCHAR}, #{operDesc,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=NUMERIC}, #{createUserName,jdbcType=VARCHAR},
#{modifyTime,jdbcType=TIMESTAMP}, #{modifyUserId,jdbcType=NUMERIC}, #{modifyUserName,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.fedex.connect.common.model.log.UserLoginInfo">
<selectKey keyProperty="id" order="BEFORE" resultType="java.lang.Long">
SELECT SEQ_T_LOG_USER_LOGIN_INFO.NEXTVAL FROM DUAL
</selectKey>
insert into T_LOG_USER_LOGIN_INFO
<trim prefix="(" suffix=")" suffixOverrides=",">
ID,
<if test="userId != null">
USER_ID,
</if>
<if test="operTypeId != null">
OPER_TYPE_ID,
</if>
<if test="operTypeName != null">
OPER_TYPE_NAME,
</if>
<if test="operDesc != null">
OPER_DESC,
</if>
<if test="ip != null">
IP,
</if>
<if test="createTime != null">
CREATE_TIME,
</if>
<if test="createUserId != null">
CREATE_USER_ID,
</if>
<if test="createUserName != null">
CREATE_USER_NAME,
</if>
<if test="modifyTime != null">
MODIFY_TIME,
</if>
<if test="modifyUserId != null">
MODIFY_USER_ID,
</if>
<if test="modifyUserName != null">
MODIFY_USER_NAME,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{id,jdbcType=NUMERIC},
<if test="userId != null">
#{userId,jdbcType=NUMERIC},
</if>
<if test="operTypeId != null">
#{operTypeId,jdbcType=NUMERIC},
</if>
<if test="operTypeName != null">
#{operTypeName,jdbcType=VARCHAR},
</if>
<if test="operDesc != null">
#{operDesc,jdbcType=VARCHAR},
</if>
<if test="ip != null">
#{ip,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null">
#{createUserId,jdbcType=NUMERIC},
</if>
<if test="createUserName != null">
#{createUserName,jdbcType=VARCHAR},
</if>
<if test="modifyTime != null">
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyUserId != null">
#{modifyUserId,jdbcType=NUMERIC},
</if>
<if test="modifyUserName != null">
#{modifyUserName,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.fedex.connect.common.model.log.UserLoginInfoExample" resultType="java.lang.Long">
select count(*) from T_LOG_USER_LOGIN_INFO
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update T_LOG_USER_LOGIN_INFO
<set>
<if test="record.id != null">
ID = #{record.id,jdbcType=NUMERIC},
</if>
<if test="record.userId != null">
USER_ID = #{record.userId,jdbcType=NUMERIC},
</if>
<if test="record.operTypeId != null">
OPER_TYPE_ID = #{record.operTypeId,jdbcType=NUMERIC},
</if>
<if test="record.operTypeName != null">
OPER_TYPE_NAME = #{record.operTypeName,jdbcType=VARCHAR},
</if>
<if test="record.operDesc != null">
OPER_DESC = #{record.operDesc,jdbcType=VARCHAR},
</if>
<if test="record.ip != null">
IP = #{record.ip,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
CREATE_TIME = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.createUserId != null">
CREATE_USER_ID = #{record.createUserId,jdbcType=NUMERIC},
</if>
<if test="record.createUserName != null">
CREATE_USER_NAME = #{record.createUserName,jdbcType=VARCHAR},
</if>
<if test="record.modifyTime != null">
MODIFY_TIME = #{record.modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="record.modifyUserId != null">
MODIFY_USER_ID = #{record.modifyUserId,jdbcType=NUMERIC},
</if>
<if test="record.modifyUserName != null">
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update T_LOG_USER_LOGIN_INFO
set ID = #{record.id,jdbcType=NUMERIC},
USER_ID = #{record.userId,jdbcType=NUMERIC},
OPER_TYPE_ID = #{record.operTypeId,jdbcType=NUMERIC},
OPER_TYPE_NAME = #{record.operTypeName,jdbcType=VARCHAR},
OPER_DESC = #{record.operDesc,jdbcType=VARCHAR},
IP = #{record.ip,jdbcType=VARCHAR},
CREATE_TIME = #{record.createTime,jdbcType=TIMESTAMP},
CREATE_USER_ID = #{record.createUserId,jdbcType=NUMERIC},
CREATE_USER_NAME = #{record.createUserName,jdbcType=VARCHAR},
MODIFY_TIME = #{record.modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{record.modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.fedex.connect.common.model.log.UserLoginInfo">
update T_LOG_USER_LOGIN_INFO
<set>
<if test="userId != null">
USER_ID = #{userId,jdbcType=NUMERIC},
</if>
<if test="operTypeId != null">
OPER_TYPE_ID = #{operTypeId,jdbcType=NUMERIC},
</if>
<if test="operTypeName != null">
OPER_TYPE_NAME = #{operTypeName,jdbcType=VARCHAR},
</if>
<if test="operDesc != null">
OPER_DESC = #{operDesc,jdbcType=VARCHAR},
</if>
<if test="ip != null">
IP = #{ip,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null">
CREATE_USER_ID = #{createUserId,jdbcType=NUMERIC},
</if>
<if test="createUserName != null">
CREATE_USER_NAME = #{createUserName,jdbcType=VARCHAR},
</if>
<if test="modifyTime != null">
MODIFY_TIME = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyUserId != null">
MODIFY_USER_ID = #{modifyUserId,jdbcType=NUMERIC},
</if>
<if test="modifyUserName != null">
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR},
</if>
</set>
where ID = #{id,jdbcType=NUMERIC}
</update>
<update id="updateByPrimaryKey" parameterType="com.fedex.connect.common.model.log.UserLoginInfo">
update T_LOG_USER_LOGIN_INFO
set USER_ID = #{userId,jdbcType=NUMERIC},
OPER_TYPE_ID = #{operTypeId,jdbcType=NUMERIC},
OPER_TYPE_NAME = #{operTypeName,jdbcType=VARCHAR},
OPER_DESC = #{operDesc,jdbcType=VARCHAR},
IP = #{ip,jdbcType=VARCHAR},
CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
CREATE_USER_ID = #{createUserId,jdbcType=NUMERIC},
CREATE_USER_NAME = #{createUserName,jdbcType=VARCHAR},
MODIFY_TIME = #{modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR}
where ID = #{id,jdbcType=NUMERIC}
</update>
<sql id="OracleDialectPrefix">
<if test="limitStart != null and limitStart>=0">
select * from ( select row_.*, rownum rownum_ from (
</if>
</sql>
<sql id="OracleDialectSuffix">
<if test="limitStart != null and limitStart>=0">
<![CDATA[ ) row_ ) where rownum_ > #{limitStart} and rownum_ <= #{limitStart}+#{limitSize} ]]>
</if>
</sql>
</mapper>
\ No newline at end of file
package com.fedex.connect.common.mapper.log;
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fedex.connect.common.dao.sys.RedisSlabMapper">
<resultMap id="BaseResultMap" type="com.fedex.connect.common.model.sys.RedisSlab">
<id column="ID" jdbcType="NUMERIC" property="id" />
<result column="REDIS_KEY" jdbcType="VARCHAR" property="redisKey" />
<result column="REDIS_MSG" jdbcType="VARCHAR" property="redisMsg" />
<result column="VALID_DURATION" jdbcType="NUMERIC" property="validDuration" />
<result column="DIS_TIME" jdbcType="TIMESTAMP" property="disTime" />
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
<result column="CREATE_USER_ID" jdbcType="NUMERIC" property="createUserId" />
<result column="CREATE_USER_NAME" jdbcType="VARCHAR" property="createUserName" />
<result column="MODIFY_TIME" jdbcType="TIMESTAMP" property="modifyTime" />
<result column="MODIFY_USER_ID" jdbcType="NUMERIC" property="modifyUserId" />
<result column="MODIFY_USER_NAME" jdbcType="VARCHAR" property="modifyUserName" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
ID, REDIS_KEY, REDIS_MSG, VALID_DURATION, DIS_TIME, CREATE_TIME, CREATE_USER_ID,
CREATE_USER_NAME, MODIFY_TIME, MODIFY_USER_ID, MODIFY_USER_NAME
</sql>
<select id="selectByExample" parameterType="com.fedex.connect.common.model.sys.RedisSlabExample" resultMap="BaseResultMap">
<include refid="OracleDialectPrefix" />
select
<if test="distinct">
distinct
</if>
'true' as QUERYID,
<include refid="Base_Column_List" />
from T_SYS_REDIS_SLAB
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<include refid="OracleDialectSuffix" />
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from T_SYS_REDIS_SLAB
where ID = #{id,jdbcType=NUMERIC}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from T_SYS_REDIS_SLAB
where ID = #{id,jdbcType=NUMERIC}
</delete>
<delete id="deleteByExample" parameterType="com.fedex.connect.common.model.sys.RedisSlabExample">
delete from T_SYS_REDIS_SLAB
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.fedex.connect.common.model.sys.RedisSlab">
<selectKey keyProperty="id" order="BEFORE" resultType="java.lang.Long">
SELECT SEQ_T_SYS_REDIS_SLAB.NEXTVAL FROM DUAL
</selectKey>
insert into T_SYS_REDIS_SLAB (ID, REDIS_KEY, REDIS_MSG,
VALID_DURATION, DIS_TIME, CREATE_TIME,
CREATE_USER_ID, CREATE_USER_NAME, MODIFY_TIME,
MODIFY_USER_ID, MODIFY_USER_NAME)
values (#{id,jdbcType=NUMERIC}, #{redisKey,jdbcType=VARCHAR}, #{redisMsg,jdbcType=VARCHAR},
#{validDuration,jdbcType=NUMERIC}, #{disTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
#{createUserId,jdbcType=NUMERIC}, #{createUserName,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP},
#{modifyUserId,jdbcType=NUMERIC}, #{modifyUserName,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.fedex.connect.common.model.sys.RedisSlab">
<selectKey keyProperty="id" order="BEFORE" resultType="java.lang.Long">
SELECT SEQ_T_SYS_REDIS_SLAB.NEXTVAL FROM DUAL
</selectKey>
insert into T_SYS_REDIS_SLAB
<trim prefix="(" suffix=")" suffixOverrides=",">
ID,
<if test="redisKey != null">
REDIS_KEY,
</if>
<if test="redisMsg != null">
REDIS_MSG,
</if>
<if test="validDuration != null">
VALID_DURATION,
</if>
<if test="disTime != null">
DIS_TIME,
</if>
<if test="createTime != null">
CREATE_TIME,
</if>
<if test="createUserId != null">
CREATE_USER_ID,
</if>
<if test="createUserName != null">
CREATE_USER_NAME,
</if>
<if test="modifyTime != null">
MODIFY_TIME,
</if>
<if test="modifyUserId != null">
MODIFY_USER_ID,
</if>
<if test="modifyUserName != null">
MODIFY_USER_NAME,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{id,jdbcType=NUMERIC},
<if test="redisKey != null">
#{redisKey,jdbcType=VARCHAR},
</if>
<if test="redisMsg != null">
#{redisMsg,jdbcType=VARCHAR},
</if>
<if test="validDuration != null">
#{validDuration,jdbcType=NUMERIC},
</if>
<if test="disTime != null">
#{disTime,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null">
#{createUserId,jdbcType=NUMERIC},
</if>
<if test="createUserName != null">
#{createUserName,jdbcType=VARCHAR},
</if>
<if test="modifyTime != null">
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyUserId != null">
#{modifyUserId,jdbcType=NUMERIC},
</if>
<if test="modifyUserName != null">
#{modifyUserName,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.fedex.connect.common.model.sys.RedisSlabExample" resultType="java.lang.Long">
select count(*) from T_SYS_REDIS_SLAB
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update T_SYS_REDIS_SLAB
<set>
<if test="record.id != null">
ID = #{record.id,jdbcType=NUMERIC},
</if>
<if test="record.redisKey != null">
REDIS_KEY = #{record.redisKey,jdbcType=VARCHAR},
</if>
<if test="record.redisMsg != null">
REDIS_MSG = #{record.redisMsg,jdbcType=VARCHAR},
</if>
<if test="record.validDuration != null">
VALID_DURATION = #{record.validDuration,jdbcType=NUMERIC},
</if>
<if test="record.disTime != null">
DIS_TIME = #{record.disTime,jdbcType=TIMESTAMP},
</if>
<if test="record.createTime != null">
CREATE_TIME = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.createUserId != null">
CREATE_USER_ID = #{record.createUserId,jdbcType=NUMERIC},
</if>
<if test="record.createUserName != null">
CREATE_USER_NAME = #{record.createUserName,jdbcType=VARCHAR},
</if>
<if test="record.modifyTime != null">
MODIFY_TIME = #{record.modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="record.modifyUserId != null">
MODIFY_USER_ID = #{record.modifyUserId,jdbcType=NUMERIC},
</if>
<if test="record.modifyUserName != null">
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update T_SYS_REDIS_SLAB
set ID = #{record.id,jdbcType=NUMERIC},
REDIS_KEY = #{record.redisKey,jdbcType=VARCHAR},
REDIS_MSG = #{record.redisMsg,jdbcType=VARCHAR},
VALID_DURATION = #{record.validDuration,jdbcType=NUMERIC},
DIS_TIME = #{record.disTime,jdbcType=TIMESTAMP},
CREATE_TIME = #{record.createTime,jdbcType=TIMESTAMP},
CREATE_USER_ID = #{record.createUserId,jdbcType=NUMERIC},
CREATE_USER_NAME = #{record.createUserName,jdbcType=VARCHAR},
MODIFY_TIME = #{record.modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{record.modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.fedex.connect.common.model.sys.RedisSlab">
update T_SYS_REDIS_SLAB
<set>
<if test="redisKey != null">
REDIS_KEY = #{redisKey,jdbcType=VARCHAR},
</if>
<if test="redisMsg != null">
REDIS_MSG = #{redisMsg,jdbcType=VARCHAR},
</if>
<if test="validDuration != null">
VALID_DURATION = #{validDuration,jdbcType=NUMERIC},
</if>
<if test="disTime != null">
DIS_TIME = #{disTime,jdbcType=TIMESTAMP},
</if>
<if test="createTime != null">
CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="createUserId != null">
CREATE_USER_ID = #{createUserId,jdbcType=NUMERIC},
</if>
<if test="createUserName != null">
CREATE_USER_NAME = #{createUserName,jdbcType=VARCHAR},
</if>
<if test="modifyTime != null">
MODIFY_TIME = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyUserId != null">
MODIFY_USER_ID = #{modifyUserId,jdbcType=NUMERIC},
</if>
<if test="modifyUserName != null">
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR},
</if>
</set>
where ID = #{id,jdbcType=NUMERIC}
</update>
<update id="updateByPrimaryKey" parameterType="com.fedex.connect.common.model.sys.RedisSlab">
update T_SYS_REDIS_SLAB
set REDIS_KEY = #{redisKey,jdbcType=VARCHAR},
REDIS_MSG = #{redisMsg,jdbcType=VARCHAR},
VALID_DURATION = #{validDuration,jdbcType=NUMERIC},
DIS_TIME = #{disTime,jdbcType=TIMESTAMP},
CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
CREATE_USER_ID = #{createUserId,jdbcType=NUMERIC},
CREATE_USER_NAME = #{createUserName,jdbcType=VARCHAR},
MODIFY_TIME = #{modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR}
where ID = #{id,jdbcType=NUMERIC}
</update>
<sql id="OracleDialectPrefix">
<if test="limitStart != null and limitStart>=0">
select * from ( select row_.*, rownum rownum_ from (
</if>
</sql>
<sql id="OracleDialectSuffix">
<if test="limitStart != null and limitStart>=0">
<![CDATA[ ) row_ ) where rownum_ > #{limitStart} and rownum_ <= #{limitStart}+#{limitSize} ]]>
</if>
</sql>
</mapper>
\ No newline at end of file
package com.fedex.connect.common.model.log;
import java.io.Serializable;
import java.util.Date;
/**
* DESC: 用户登录日志表
* TABLE: T_LOG_USER_LOGIN_INFO
*/
public class UserLoginInfo implements Serializable {
/**
* ID,主键自增
*/
private Long id;
/**
* 操作人用户ID,关联用户表ID
*/
private Long userId;
/**
* 操作类型ID。
关联数据字典表。指定字典目录CODE:USER_LOGIN_TYPE
*/
private Long operTypeId;
/**
* 操作类型名称(登录、退出、修改密码、FCL登录注册,、停用、启用)
*/
private String operTypeName;
/**
* 操作描述
*/
private String operDesc;
/**
* 操作IP
*/
private String ip;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人ID,关联用户表ID
*/
private Long createUserId;
/**
* 创建人名称
*/
private String createUserName;
/**
* 修改时间
*/
private Date modifyTime;
/**
* 修改人ID,关联用户表ID
*/
private Long modifyUserId;
/**
* 修改人名称
*/
private String modifyUserName;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getOperTypeId() {
return operTypeId;
}
public void setOperTypeId(Long operTypeId) {
this.operTypeId = operTypeId;
}
public String getOperTypeName() {
return operTypeName;
}
public void setOperTypeName(String operTypeName) {
this.operTypeName = operTypeName == null ? null : operTypeName.trim();
}
public String getOperDesc() {
return operDesc;
}
public void setOperDesc(String operDesc) {
this.operDesc = operDesc == null ? null : operDesc.trim();
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip == null ? null : ip.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Long getCreateUserId() {
return createUserId;
}
public void setCreateUserId(Long createUserId) {
this.createUserId = createUserId;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName == null ? null : createUserName.trim();
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Long getModifyUserId() {
return modifyUserId;
}
public void setModifyUserId(Long modifyUserId) {
this.modifyUserId = modifyUserId;
}
public String getModifyUserName() {
return modifyUserName;
}
public void setModifyUserName(String modifyUserName) {
this.modifyUserName = modifyUserName == null ? null : modifyUserName.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", userId=").append(userId);
sb.append(", operTypeId=").append(operTypeId);
sb.append(", operTypeName=").append(operTypeName);
sb.append(", operDesc=").append(operDesc);
sb.append(", ip=").append(ip);
sb.append(", createTime=").append(createTime);
sb.append(", createUserId=").append(createUserId);
sb.append(", createUserName=").append(createUserName);
sb.append(", modifyTime=").append(modifyTime);
sb.append(", modifyUserId=").append(modifyUserId);
sb.append(", modifyUserName=").append(modifyUserName);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file
package com.fedex.connect.common.model.log;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class UserLoginInfoExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
protected Integer limitStart;
protected Integer limitSize;
public UserLoginInfoExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
public void setLimitStart(Integer limitStart) {
this.limitStart=limitStart;
}
public Integer getLimitStart() {
return limitStart;
}
public void setLimitSize(Integer limitSize) {
this.limitSize=limitSize;
}
public Integer getLimitSize() {
return limitSize;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("ID is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("ID is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("ID =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("ID <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("ID >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("ID >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("ID <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("ID <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("ID in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("ID not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("ID between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("ID not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andUserIdIsNull() {
addCriterion("USER_ID is null");
return (Criteria) this;
}
public Criteria andUserIdIsNotNull() {
addCriterion("USER_ID is not null");
return (Criteria) this;
}
public Criteria andUserIdEqualTo(Long value) {
addCriterion("USER_ID =", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotEqualTo(Long value) {
addCriterion("USER_ID <>", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThan(Long value) {
addCriterion("USER_ID >", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThanOrEqualTo(Long value) {
addCriterion("USER_ID >=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThan(Long value) {
addCriterion("USER_ID <", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThanOrEqualTo(Long value) {
addCriterion("USER_ID <=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdIn(List<Long> values) {
addCriterion("USER_ID in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotIn(List<Long> values) {
addCriterion("USER_ID not in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdBetween(Long value1, Long value2) {
addCriterion("USER_ID between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotBetween(Long value1, Long value2) {
addCriterion("USER_ID not between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andOperTypeIdIsNull() {
addCriterion("OPER_TYPE_ID is null");
return (Criteria) this;
}
public Criteria andOperTypeIdIsNotNull() {
addCriterion("OPER_TYPE_ID is not null");
return (Criteria) this;
}
public Criteria andOperTypeIdEqualTo(Long value) {
addCriterion("OPER_TYPE_ID =", value, "operTypeId");
return (Criteria) this;
}
public Criteria andOperTypeIdNotEqualTo(Long value) {
addCriterion("OPER_TYPE_ID <>", value, "operTypeId");
return (Criteria) this;
}
public Criteria andOperTypeIdGreaterThan(Long value) {
addCriterion("OPER_TYPE_ID >", value, "operTypeId");
return (Criteria) this;
}
public Criteria andOperTypeIdGreaterThanOrEqualTo(Long value) {
addCriterion("OPER_TYPE_ID >=", value, "operTypeId");
return (Criteria) this;
}
public Criteria andOperTypeIdLessThan(Long value) {
addCriterion("OPER_TYPE_ID <", value, "operTypeId");
return (Criteria) this;
}
public Criteria andOperTypeIdLessThanOrEqualTo(Long value) {
addCriterion("OPER_TYPE_ID <=", value, "operTypeId");
return (Criteria) this;
}
public Criteria andOperTypeIdIn(List<Long> values) {
addCriterion("OPER_TYPE_ID in", values, "operTypeId");
return (Criteria) this;
}
public Criteria andOperTypeIdNotIn(List<Long> values) {
addCriterion("OPER_TYPE_ID not in", values, "operTypeId");
return (Criteria) this;
}
public Criteria andOperTypeIdBetween(Long value1, Long value2) {
addCriterion("OPER_TYPE_ID between", value1, value2, "operTypeId");
return (Criteria) this;
}
public Criteria andOperTypeIdNotBetween(Long value1, Long value2) {
addCriterion("OPER_TYPE_ID not between", value1, value2, "operTypeId");
return (Criteria) this;
}
public Criteria andOperTypeNameIsNull() {
addCriterion("OPER_TYPE_NAME is null");
return (Criteria) this;
}
public Criteria andOperTypeNameIsNotNull() {
addCriterion("OPER_TYPE_NAME is not null");
return (Criteria) this;
}
public Criteria andOperTypeNameEqualTo(String value) {
addCriterion("OPER_TYPE_NAME =", value, "operTypeName");
return (Criteria) this;
}
public Criteria andOperTypeNameNotEqualTo(String value) {
addCriterion("OPER_TYPE_NAME <>", value, "operTypeName");
return (Criteria) this;
}
public Criteria andOperTypeNameGreaterThan(String value) {
addCriterion("OPER_TYPE_NAME >", value, "operTypeName");
return (Criteria) this;
}
public Criteria andOperTypeNameGreaterThanOrEqualTo(String value) {
addCriterion("OPER_TYPE_NAME >=", value, "operTypeName");
return (Criteria) this;
}
public Criteria andOperTypeNameLessThan(String value) {
addCriterion("OPER_TYPE_NAME <", value, "operTypeName");
return (Criteria) this;
}
public Criteria andOperTypeNameLessThanOrEqualTo(String value) {
addCriterion("OPER_TYPE_NAME <=", value, "operTypeName");
return (Criteria) this;
}
public Criteria andOperTypeNameLike(String value) {
addCriterion("OPER_TYPE_NAME like", value, "operTypeName");
return (Criteria) this;
}
public Criteria andOperTypeNameNotLike(String value) {
addCriterion("OPER_TYPE_NAME not like", value, "operTypeName");
return (Criteria) this;
}
public Criteria andOperTypeNameIn(List<String> values) {
addCriterion("OPER_TYPE_NAME in", values, "operTypeName");
return (Criteria) this;
}
public Criteria andOperTypeNameNotIn(List<String> values) {
addCriterion("OPER_TYPE_NAME not in", values, "operTypeName");
return (Criteria) this;
}
public Criteria andOperTypeNameBetween(String value1, String value2) {
addCriterion("OPER_TYPE_NAME between", value1, value2, "operTypeName");
return (Criteria) this;
}
public Criteria andOperTypeNameNotBetween(String value1, String value2) {
addCriterion("OPER_TYPE_NAME not between", value1, value2, "operTypeName");
return (Criteria) this;
}
public Criteria andOperDescIsNull() {
addCriterion("OPER_DESC is null");
return (Criteria) this;
}
public Criteria andOperDescIsNotNull() {
addCriterion("OPER_DESC is not null");
return (Criteria) this;
}
public Criteria andOperDescEqualTo(String value) {
addCriterion("OPER_DESC =", value, "operDesc");
return (Criteria) this;
}
public Criteria andOperDescNotEqualTo(String value) {
addCriterion("OPER_DESC <>", value, "operDesc");
return (Criteria) this;
}
public Criteria andOperDescGreaterThan(String value) {
addCriterion("OPER_DESC >", value, "operDesc");
return (Criteria) this;
}
public Criteria andOperDescGreaterThanOrEqualTo(String value) {
addCriterion("OPER_DESC >=", value, "operDesc");
return (Criteria) this;
}
public Criteria andOperDescLessThan(String value) {
addCriterion("OPER_DESC <", value, "operDesc");
return (Criteria) this;
}
public Criteria andOperDescLessThanOrEqualTo(String value) {
addCriterion("OPER_DESC <=", value, "operDesc");
return (Criteria) this;
}
public Criteria andOperDescLike(String value) {
addCriterion("OPER_DESC like", value, "operDesc");
return (Criteria) this;
}
public Criteria andOperDescNotLike(String value) {
addCriterion("OPER_DESC not like", value, "operDesc");
return (Criteria) this;
}
public Criteria andOperDescIn(List<String> values) {
addCriterion("OPER_DESC in", values, "operDesc");
return (Criteria) this;
}
public Criteria andOperDescNotIn(List<String> values) {
addCriterion("OPER_DESC not in", values, "operDesc");
return (Criteria) this;
}
public Criteria andOperDescBetween(String value1, String value2) {
addCriterion("OPER_DESC between", value1, value2, "operDesc");
return (Criteria) this;
}
public Criteria andOperDescNotBetween(String value1, String value2) {
addCriterion("OPER_DESC not between", value1, value2, "operDesc");
return (Criteria) this;
}
public Criteria andIpIsNull() {
addCriterion("IP is null");
return (Criteria) this;
}
public Criteria andIpIsNotNull() {
addCriterion("IP is not null");
return (Criteria) this;
}
public Criteria andIpEqualTo(String value) {
addCriterion("IP =", value, "ip");
return (Criteria) this;
}
public Criteria andIpNotEqualTo(String value) {
addCriterion("IP <>", value, "ip");
return (Criteria) this;
}
public Criteria andIpGreaterThan(String value) {
addCriterion("IP >", value, "ip");
return (Criteria) this;
}
public Criteria andIpGreaterThanOrEqualTo(String value) {
addCriterion("IP >=", value, "ip");
return (Criteria) this;
}
public Criteria andIpLessThan(String value) {
addCriterion("IP <", value, "ip");
return (Criteria) this;
}
public Criteria andIpLessThanOrEqualTo(String value) {
addCriterion("IP <=", value, "ip");
return (Criteria) this;
}
public Criteria andIpLike(String value) {
addCriterion("IP like", value, "ip");
return (Criteria) this;
}
public Criteria andIpNotLike(String value) {
addCriterion("IP not like", value, "ip");
return (Criteria) this;
}
public Criteria andIpIn(List<String> values) {
addCriterion("IP in", values, "ip");
return (Criteria) this;
}
public Criteria andIpNotIn(List<String> values) {
addCriterion("IP not in", values, "ip");
return (Criteria) this;
}
public Criteria andIpBetween(String value1, String value2) {
addCriterion("IP between", value1, value2, "ip");
return (Criteria) this;
}
public Criteria andIpNotBetween(String value1, String value2) {
addCriterion("IP not between", value1, value2, "ip");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("CREATE_TIME is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("CREATE_TIME is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("CREATE_TIME =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("CREATE_TIME <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("CREATE_TIME >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("CREATE_TIME >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("CREATE_TIME <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("CREATE_TIME <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("CREATE_TIME in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("CREATE_TIME not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("CREATE_TIME between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("CREATE_TIME not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateUserIdIsNull() {
addCriterion("CREATE_USER_ID is null");
return (Criteria) this;
}
public Criteria andCreateUserIdIsNotNull() {
addCriterion("CREATE_USER_ID is not null");
return (Criteria) this;
}
public Criteria andCreateUserIdEqualTo(Long value) {
addCriterion("CREATE_USER_ID =", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdNotEqualTo(Long value) {
addCriterion("CREATE_USER_ID <>", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdGreaterThan(Long value) {
addCriterion("CREATE_USER_ID >", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdGreaterThanOrEqualTo(Long value) {
addCriterion("CREATE_USER_ID >=", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdLessThan(Long value) {
addCriterion("CREATE_USER_ID <", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdLessThanOrEqualTo(Long value) {
addCriterion("CREATE_USER_ID <=", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdIn(List<Long> values) {
addCriterion("CREATE_USER_ID in", values, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdNotIn(List<Long> values) {
addCriterion("CREATE_USER_ID not in", values, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdBetween(Long value1, Long value2) {
addCriterion("CREATE_USER_ID between", value1, value2, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdNotBetween(Long value1, Long value2) {
addCriterion("CREATE_USER_ID not between", value1, value2, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserNameIsNull() {
addCriterion("CREATE_USER_NAME is null");
return (Criteria) this;
}
public Criteria andCreateUserNameIsNotNull() {
addCriterion("CREATE_USER_NAME is not null");
return (Criteria) this;
}
public Criteria andCreateUserNameEqualTo(String value) {
addCriterion("CREATE_USER_NAME =", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameNotEqualTo(String value) {
addCriterion("CREATE_USER_NAME <>", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameGreaterThan(String value) {
addCriterion("CREATE_USER_NAME >", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameGreaterThanOrEqualTo(String value) {
addCriterion("CREATE_USER_NAME >=", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameLessThan(String value) {
addCriterion("CREATE_USER_NAME <", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameLessThanOrEqualTo(String value) {
addCriterion("CREATE_USER_NAME <=", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameLike(String value) {
addCriterion("CREATE_USER_NAME like", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameNotLike(String value) {
addCriterion("CREATE_USER_NAME not like", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameIn(List<String> values) {
addCriterion("CREATE_USER_NAME in", values, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameNotIn(List<String> values) {
addCriterion("CREATE_USER_NAME not in", values, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameBetween(String value1, String value2) {
addCriterion("CREATE_USER_NAME between", value1, value2, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameNotBetween(String value1, String value2) {
addCriterion("CREATE_USER_NAME not between", value1, value2, "createUserName");
return (Criteria) this;
}
public Criteria andModifyTimeIsNull() {
addCriterion("MODIFY_TIME is null");
return (Criteria) this;
}
public Criteria andModifyTimeIsNotNull() {
addCriterion("MODIFY_TIME is not null");
return (Criteria) this;
}
public Criteria andModifyTimeEqualTo(Date value) {
addCriterion("MODIFY_TIME =", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeNotEqualTo(Date value) {
addCriterion("MODIFY_TIME <>", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeGreaterThan(Date value) {
addCriterion("MODIFY_TIME >", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeGreaterThanOrEqualTo(Date value) {
addCriterion("MODIFY_TIME >=", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeLessThan(Date value) {
addCriterion("MODIFY_TIME <", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeLessThanOrEqualTo(Date value) {
addCriterion("MODIFY_TIME <=", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeIn(List<Date> values) {
addCriterion("MODIFY_TIME in", values, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeNotIn(List<Date> values) {
addCriterion("MODIFY_TIME not in", values, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeBetween(Date value1, Date value2) {
addCriterion("MODIFY_TIME between", value1, value2, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeNotBetween(Date value1, Date value2) {
addCriterion("MODIFY_TIME not between", value1, value2, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyUserIdIsNull() {
addCriterion("MODIFY_USER_ID is null");
return (Criteria) this;
}
public Criteria andModifyUserIdIsNotNull() {
addCriterion("MODIFY_USER_ID is not null");
return (Criteria) this;
}
public Criteria andModifyUserIdEqualTo(Long value) {
addCriterion("MODIFY_USER_ID =", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdNotEqualTo(Long value) {
addCriterion("MODIFY_USER_ID <>", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdGreaterThan(Long value) {
addCriterion("MODIFY_USER_ID >", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdGreaterThanOrEqualTo(Long value) {
addCriterion("MODIFY_USER_ID >=", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdLessThan(Long value) {
addCriterion("MODIFY_USER_ID <", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdLessThanOrEqualTo(Long value) {
addCriterion("MODIFY_USER_ID <=", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdIn(List<Long> values) {
addCriterion("MODIFY_USER_ID in", values, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdNotIn(List<Long> values) {
addCriterion("MODIFY_USER_ID not in", values, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdBetween(Long value1, Long value2) {
addCriterion("MODIFY_USER_ID between", value1, value2, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdNotBetween(Long value1, Long value2) {
addCriterion("MODIFY_USER_ID not between", value1, value2, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserNameIsNull() {
addCriterion("MODIFY_USER_NAME is null");
return (Criteria) this;
}
public Criteria andModifyUserNameIsNotNull() {
addCriterion("MODIFY_USER_NAME is not null");
return (Criteria) this;
}
public Criteria andModifyUserNameEqualTo(String value) {
addCriterion("MODIFY_USER_NAME =", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameNotEqualTo(String value) {
addCriterion("MODIFY_USER_NAME <>", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameGreaterThan(String value) {
addCriterion("MODIFY_USER_NAME >", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameGreaterThanOrEqualTo(String value) {
addCriterion("MODIFY_USER_NAME >=", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameLessThan(String value) {
addCriterion("MODIFY_USER_NAME <", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameLessThanOrEqualTo(String value) {
addCriterion("MODIFY_USER_NAME <=", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameLike(String value) {
addCriterion("MODIFY_USER_NAME like", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameNotLike(String value) {
addCriterion("MODIFY_USER_NAME not like", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameIn(List<String> values) {
addCriterion("MODIFY_USER_NAME in", values, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameNotIn(List<String> values) {
addCriterion("MODIFY_USER_NAME not in", values, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameBetween(String value1, String value2) {
addCriterion("MODIFY_USER_NAME between", value1, value2, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameNotBetween(String value1, String value2) {
addCriterion("MODIFY_USER_NAME not between", value1, value2, "modifyUserName");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}
\ No newline at end of file
package com.fedex.connect.common.model.log;
\ No newline at end of file
package com.fedex.connect.common.model.sys;
import java.io.Serializable;
import java.util.Date;
/**
* DESC: 用户登录信息token表
* TABLE: T_SYS_REDIS_SLAB
*/
public class RedisSlab implements Serializable {
/**
* ID,自动增加
*/
private Long id;
/**
* Redis key
*/
private String redisKey;
/**
* Redis信息
*/
private String redisMsg;
/**
* 有效时长
*/
private Long validDuration;
/**
* 失效时间
*/
private Date disTime;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人ID,关联用户表ID
*/
private Long createUserId;
/**
* 创建人名称
*/
private String createUserName;
/**
* 修改时间
*/
private Date modifyTime;
/**
* 修改人ID,关联用户表ID
*/
private Long modifyUserId;
/**
* 修改人名称
*/
private String modifyUserName;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRedisKey() {
return redisKey;
}
public void setRedisKey(String redisKey) {
this.redisKey = redisKey == null ? null : redisKey.trim();
}
public String getRedisMsg() {
return redisMsg;
}
public void setRedisMsg(String redisMsg) {
this.redisMsg = redisMsg == null ? null : redisMsg.trim();
}
public Long getValidDuration() {
return validDuration;
}
public void setValidDuration(Long validDuration) {
this.validDuration = validDuration;
}
public Date getDisTime() {
return disTime;
}
public void setDisTime(Date disTime) {
this.disTime = disTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Long getCreateUserId() {
return createUserId;
}
public void setCreateUserId(Long createUserId) {
this.createUserId = createUserId;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName == null ? null : createUserName.trim();
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Long getModifyUserId() {
return modifyUserId;
}
public void setModifyUserId(Long modifyUserId) {
this.modifyUserId = modifyUserId;
}
public String getModifyUserName() {
return modifyUserName;
}
public void setModifyUserName(String modifyUserName) {
this.modifyUserName = modifyUserName == null ? null : modifyUserName.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", redisKey=").append(redisKey);
sb.append(", redisMsg=").append(redisMsg);
sb.append(", validDuration=").append(validDuration);
sb.append(", disTime=").append(disTime);
sb.append(", createTime=").append(createTime);
sb.append(", createUserId=").append(createUserId);
sb.append(", createUserName=").append(createUserName);
sb.append(", modifyTime=").append(modifyTime);
sb.append(", modifyUserId=").append(modifyUserId);
sb.append(", modifyUserName=").append(modifyUserName);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file
package com.fedex.connect.common.model.sys;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class RedisSlabExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
protected Integer limitStart;
protected Integer limitSize;
public RedisSlabExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
public void setLimitStart(Integer limitStart) {
this.limitStart=limitStart;
}
public Integer getLimitStart() {
return limitStart;
}
public void setLimitSize(Integer limitSize) {
this.limitSize=limitSize;
}
public Integer getLimitSize() {
return limitSize;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("ID is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("ID is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("ID =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("ID <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("ID >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("ID >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("ID <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("ID <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("ID in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("ID not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("ID between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("ID not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andRedisKeyIsNull() {
addCriterion("REDIS_KEY is null");
return (Criteria) this;
}
public Criteria andRedisKeyIsNotNull() {
addCriterion("REDIS_KEY is not null");
return (Criteria) this;
}
public Criteria andRedisKeyEqualTo(String value) {
addCriterion("REDIS_KEY =", value, "redisKey");
return (Criteria) this;
}
public Criteria andRedisKeyNotEqualTo(String value) {
addCriterion("REDIS_KEY <>", value, "redisKey");
return (Criteria) this;
}
public Criteria andRedisKeyGreaterThan(String value) {
addCriterion("REDIS_KEY >", value, "redisKey");
return (Criteria) this;
}
public Criteria andRedisKeyGreaterThanOrEqualTo(String value) {
addCriterion("REDIS_KEY >=", value, "redisKey");
return (Criteria) this;
}
public Criteria andRedisKeyLessThan(String value) {
addCriterion("REDIS_KEY <", value, "redisKey");
return (Criteria) this;
}
public Criteria andRedisKeyLessThanOrEqualTo(String value) {
addCriterion("REDIS_KEY <=", value, "redisKey");
return (Criteria) this;
}
public Criteria andRedisKeyLike(String value) {
addCriterion("REDIS_KEY like", value, "redisKey");
return (Criteria) this;
}
public Criteria andRedisKeyNotLike(String value) {
addCriterion("REDIS_KEY not like", value, "redisKey");
return (Criteria) this;
}
public Criteria andRedisKeyIn(List<String> values) {
addCriterion("REDIS_KEY in", values, "redisKey");
return (Criteria) this;
}
public Criteria andRedisKeyNotIn(List<String> values) {
addCriterion("REDIS_KEY not in", values, "redisKey");
return (Criteria) this;
}
public Criteria andRedisKeyBetween(String value1, String value2) {
addCriterion("REDIS_KEY between", value1, value2, "redisKey");
return (Criteria) this;
}
public Criteria andRedisKeyNotBetween(String value1, String value2) {
addCriterion("REDIS_KEY not between", value1, value2, "redisKey");
return (Criteria) this;
}
public Criteria andRedisMsgIsNull() {
addCriterion("REDIS_MSG is null");
return (Criteria) this;
}
public Criteria andRedisMsgIsNotNull() {
addCriterion("REDIS_MSG is not null");
return (Criteria) this;
}
public Criteria andRedisMsgEqualTo(String value) {
addCriterion("REDIS_MSG =", value, "redisMsg");
return (Criteria) this;
}
public Criteria andRedisMsgNotEqualTo(String value) {
addCriterion("REDIS_MSG <>", value, "redisMsg");
return (Criteria) this;
}
public Criteria andRedisMsgGreaterThan(String value) {
addCriterion("REDIS_MSG >", value, "redisMsg");
return (Criteria) this;
}
public Criteria andRedisMsgGreaterThanOrEqualTo(String value) {
addCriterion("REDIS_MSG >=", value, "redisMsg");
return (Criteria) this;
}
public Criteria andRedisMsgLessThan(String value) {
addCriterion("REDIS_MSG <", value, "redisMsg");
return (Criteria) this;
}
public Criteria andRedisMsgLessThanOrEqualTo(String value) {
addCriterion("REDIS_MSG <=", value, "redisMsg");
return (Criteria) this;
}
public Criteria andRedisMsgLike(String value) {
addCriterion("REDIS_MSG like", value, "redisMsg");
return (Criteria) this;
}
public Criteria andRedisMsgNotLike(String value) {
addCriterion("REDIS_MSG not like", value, "redisMsg");
return (Criteria) this;
}
public Criteria andRedisMsgIn(List<String> values) {
addCriterion("REDIS_MSG in", values, "redisMsg");
return (Criteria) this;
}
public Criteria andRedisMsgNotIn(List<String> values) {
addCriterion("REDIS_MSG not in", values, "redisMsg");
return (Criteria) this;
}
public Criteria andRedisMsgBetween(String value1, String value2) {
addCriterion("REDIS_MSG between", value1, value2, "redisMsg");
return (Criteria) this;
}
public Criteria andRedisMsgNotBetween(String value1, String value2) {
addCriterion("REDIS_MSG not between", value1, value2, "redisMsg");
return (Criteria) this;
}
public Criteria andValidDurationIsNull() {
addCriterion("VALID_DURATION is null");
return (Criteria) this;
}
public Criteria andValidDurationIsNotNull() {
addCriterion("VALID_DURATION is not null");
return (Criteria) this;
}
public Criteria andValidDurationEqualTo(Long value) {
addCriterion("VALID_DURATION =", value, "validDuration");
return (Criteria) this;
}
public Criteria andValidDurationNotEqualTo(Long value) {
addCriterion("VALID_DURATION <>", value, "validDuration");
return (Criteria) this;
}
public Criteria andValidDurationGreaterThan(Long value) {
addCriterion("VALID_DURATION >", value, "validDuration");
return (Criteria) this;
}
public Criteria andValidDurationGreaterThanOrEqualTo(Long value) {
addCriterion("VALID_DURATION >=", value, "validDuration");
return (Criteria) this;
}
public Criteria andValidDurationLessThan(Long value) {
addCriterion("VALID_DURATION <", value, "validDuration");
return (Criteria) this;
}
public Criteria andValidDurationLessThanOrEqualTo(Long value) {
addCriterion("VALID_DURATION <=", value, "validDuration");
return (Criteria) this;
}
public Criteria andValidDurationIn(List<Long> values) {
addCriterion("VALID_DURATION in", values, "validDuration");
return (Criteria) this;
}
public Criteria andValidDurationNotIn(List<Long> values) {
addCriterion("VALID_DURATION not in", values, "validDuration");
return (Criteria) this;
}
public Criteria andValidDurationBetween(Long value1, Long value2) {
addCriterion("VALID_DURATION between", value1, value2, "validDuration");
return (Criteria) this;
}
public Criteria andValidDurationNotBetween(Long value1, Long value2) {
addCriterion("VALID_DURATION not between", value1, value2, "validDuration");
return (Criteria) this;
}
public Criteria andDisTimeIsNull() {
addCriterion("DIS_TIME is null");
return (Criteria) this;
}
public Criteria andDisTimeIsNotNull() {
addCriterion("DIS_TIME is not null");
return (Criteria) this;
}
public Criteria andDisTimeEqualTo(Date value) {
addCriterion("DIS_TIME =", value, "disTime");
return (Criteria) this;
}
public Criteria andDisTimeNotEqualTo(Date value) {
addCriterion("DIS_TIME <>", value, "disTime");
return (Criteria) this;
}
public Criteria andDisTimeGreaterThan(Date value) {
addCriterion("DIS_TIME >", value, "disTime");
return (Criteria) this;
}
public Criteria andDisTimeGreaterThanOrEqualTo(Date value) {
addCriterion("DIS_TIME >=", value, "disTime");
return (Criteria) this;
}
public Criteria andDisTimeLessThan(Date value) {
addCriterion("DIS_TIME <", value, "disTime");
return (Criteria) this;
}
public Criteria andDisTimeLessThanOrEqualTo(Date value) {
addCriterion("DIS_TIME <=", value, "disTime");
return (Criteria) this;
}
public Criteria andDisTimeIn(List<Date> values) {
addCriterion("DIS_TIME in", values, "disTime");
return (Criteria) this;
}
public Criteria andDisTimeNotIn(List<Date> values) {
addCriterion("DIS_TIME not in", values, "disTime");
return (Criteria) this;
}
public Criteria andDisTimeBetween(Date value1, Date value2) {
addCriterion("DIS_TIME between", value1, value2, "disTime");
return (Criteria) this;
}
public Criteria andDisTimeNotBetween(Date value1, Date value2) {
addCriterion("DIS_TIME not between", value1, value2, "disTime");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("CREATE_TIME is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("CREATE_TIME is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("CREATE_TIME =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("CREATE_TIME <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("CREATE_TIME >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("CREATE_TIME >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("CREATE_TIME <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("CREATE_TIME <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("CREATE_TIME in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("CREATE_TIME not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("CREATE_TIME between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("CREATE_TIME not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateUserIdIsNull() {
addCriterion("CREATE_USER_ID is null");
return (Criteria) this;
}
public Criteria andCreateUserIdIsNotNull() {
addCriterion("CREATE_USER_ID is not null");
return (Criteria) this;
}
public Criteria andCreateUserIdEqualTo(Long value) {
addCriterion("CREATE_USER_ID =", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdNotEqualTo(Long value) {
addCriterion("CREATE_USER_ID <>", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdGreaterThan(Long value) {
addCriterion("CREATE_USER_ID >", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdGreaterThanOrEqualTo(Long value) {
addCriterion("CREATE_USER_ID >=", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdLessThan(Long value) {
addCriterion("CREATE_USER_ID <", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdLessThanOrEqualTo(Long value) {
addCriterion("CREATE_USER_ID <=", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdIn(List<Long> values) {
addCriterion("CREATE_USER_ID in", values, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdNotIn(List<Long> values) {
addCriterion("CREATE_USER_ID not in", values, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdBetween(Long value1, Long value2) {
addCriterion("CREATE_USER_ID between", value1, value2, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdNotBetween(Long value1, Long value2) {
addCriterion("CREATE_USER_ID not between", value1, value2, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserNameIsNull() {
addCriterion("CREATE_USER_NAME is null");
return (Criteria) this;
}
public Criteria andCreateUserNameIsNotNull() {
addCriterion("CREATE_USER_NAME is not null");
return (Criteria) this;
}
public Criteria andCreateUserNameEqualTo(String value) {
addCriterion("CREATE_USER_NAME =", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameNotEqualTo(String value) {
addCriterion("CREATE_USER_NAME <>", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameGreaterThan(String value) {
addCriterion("CREATE_USER_NAME >", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameGreaterThanOrEqualTo(String value) {
addCriterion("CREATE_USER_NAME >=", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameLessThan(String value) {
addCriterion("CREATE_USER_NAME <", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameLessThanOrEqualTo(String value) {
addCriterion("CREATE_USER_NAME <=", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameLike(String value) {
addCriterion("CREATE_USER_NAME like", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameNotLike(String value) {
addCriterion("CREATE_USER_NAME not like", value, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameIn(List<String> values) {
addCriterion("CREATE_USER_NAME in", values, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameNotIn(List<String> values) {
addCriterion("CREATE_USER_NAME not in", values, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameBetween(String value1, String value2) {
addCriterion("CREATE_USER_NAME between", value1, value2, "createUserName");
return (Criteria) this;
}
public Criteria andCreateUserNameNotBetween(String value1, String value2) {
addCriterion("CREATE_USER_NAME not between", value1, value2, "createUserName");
return (Criteria) this;
}
public Criteria andModifyTimeIsNull() {
addCriterion("MODIFY_TIME is null");
return (Criteria) this;
}
public Criteria andModifyTimeIsNotNull() {
addCriterion("MODIFY_TIME is not null");
return (Criteria) this;
}
public Criteria andModifyTimeEqualTo(Date value) {
addCriterion("MODIFY_TIME =", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeNotEqualTo(Date value) {
addCriterion("MODIFY_TIME <>", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeGreaterThan(Date value) {
addCriterion("MODIFY_TIME >", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeGreaterThanOrEqualTo(Date value) {
addCriterion("MODIFY_TIME >=", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeLessThan(Date value) {
addCriterion("MODIFY_TIME <", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeLessThanOrEqualTo(Date value) {
addCriterion("MODIFY_TIME <=", value, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeIn(List<Date> values) {
addCriterion("MODIFY_TIME in", values, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeNotIn(List<Date> values) {
addCriterion("MODIFY_TIME not in", values, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeBetween(Date value1, Date value2) {
addCriterion("MODIFY_TIME between", value1, value2, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyTimeNotBetween(Date value1, Date value2) {
addCriterion("MODIFY_TIME not between", value1, value2, "modifyTime");
return (Criteria) this;
}
public Criteria andModifyUserIdIsNull() {
addCriterion("MODIFY_USER_ID is null");
return (Criteria) this;
}
public Criteria andModifyUserIdIsNotNull() {
addCriterion("MODIFY_USER_ID is not null");
return (Criteria) this;
}
public Criteria andModifyUserIdEqualTo(Long value) {
addCriterion("MODIFY_USER_ID =", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdNotEqualTo(Long value) {
addCriterion("MODIFY_USER_ID <>", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdGreaterThan(Long value) {
addCriterion("MODIFY_USER_ID >", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdGreaterThanOrEqualTo(Long value) {
addCriterion("MODIFY_USER_ID >=", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdLessThan(Long value) {
addCriterion("MODIFY_USER_ID <", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdLessThanOrEqualTo(Long value) {
addCriterion("MODIFY_USER_ID <=", value, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdIn(List<Long> values) {
addCriterion("MODIFY_USER_ID in", values, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdNotIn(List<Long> values) {
addCriterion("MODIFY_USER_ID not in", values, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdBetween(Long value1, Long value2) {
addCriterion("MODIFY_USER_ID between", value1, value2, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserIdNotBetween(Long value1, Long value2) {
addCriterion("MODIFY_USER_ID not between", value1, value2, "modifyUserId");
return (Criteria) this;
}
public Criteria andModifyUserNameIsNull() {
addCriterion("MODIFY_USER_NAME is null");
return (Criteria) this;
}
public Criteria andModifyUserNameIsNotNull() {
addCriterion("MODIFY_USER_NAME is not null");
return (Criteria) this;
}
public Criteria andModifyUserNameEqualTo(String value) {
addCriterion("MODIFY_USER_NAME =", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameNotEqualTo(String value) {
addCriterion("MODIFY_USER_NAME <>", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameGreaterThan(String value) {
addCriterion("MODIFY_USER_NAME >", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameGreaterThanOrEqualTo(String value) {
addCriterion("MODIFY_USER_NAME >=", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameLessThan(String value) {
addCriterion("MODIFY_USER_NAME <", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameLessThanOrEqualTo(String value) {
addCriterion("MODIFY_USER_NAME <=", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameLike(String value) {
addCriterion("MODIFY_USER_NAME like", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameNotLike(String value) {
addCriterion("MODIFY_USER_NAME not like", value, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameIn(List<String> values) {
addCriterion("MODIFY_USER_NAME in", values, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameNotIn(List<String> values) {
addCriterion("MODIFY_USER_NAME not in", values, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameBetween(String value1, String value2) {
addCriterion("MODIFY_USER_NAME between", value1, value2, "modifyUserName");
return (Criteria) this;
}
public Criteria andModifyUserNameNotBetween(String value1, String value2) {
addCriterion("MODIFY_USER_NAME not between", value1, value2, "modifyUserName");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}
\ No newline at end of file
......@@ -40,7 +40,7 @@
sys:系统 系统相关表,例如kafka表
log: 日志 日志记录表,例如邮件发送日志表
-->
<javaModelGenerator targetPackage="com.fedex.connect.common.model.base" targetProject="src/main/java">
<javaModelGenerator targetPackage="com.fedex.connect.common.model.sys" targetProject="src/main/java">
<!---enableSubPackages:如果true,MBG会根据catalog和schema来生成子包。如果false就会直接用targetPackage属性-->
<property name="enableSubPackages" value="false"/>
<!--该属性只对MyBatis3有效,如果true就会使用构造方法入参,如果false就会使用setter方式。默认为false-->
......@@ -52,13 +52,13 @@
</javaModelGenerator>
<!-- 生成映射文件*.xml的位置-->
<sqlMapGenerator targetPackage="mapper.base" targetProject="src/main/java/com/fedex/connect/common">
<sqlMapGenerator targetPackage="mapper.sys" targetProject="src/main/java/com/fedex/connect/common">
<!--如果true,MBG会根据catalog和schema来生成子包。如果false就会直接用targetPackage属性。默认为false-->
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.fedex.connect.common.dao.base" targetProject="src/main/java">
<javaClientGenerator type="XMLMAPPER" targetPackage="com.fedex.connect.common.dao.sys" targetProject="src/main/java">
<!--如果true,MBG会根据catalog和schema来生成子包。如果false就会直接用targetPackage属性。默认为false-->
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
......@@ -73,6 +73,13 @@
generatedKey 指定KEY,Oracle需要指定序列。
sqlStatement 指定序列名称
-->
<table tableName="T_SYS_REDIS_SLAB" domainObjectName="redisSlab"
enableCountByExample="true" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
<generatedKey column="ID" sqlStatement="SELECT SEQ_T_SYS_REDIS_SLAB.NEXTVAL FROM DUAL" />
</table>
<!-- <table tableName="T_KAFKA_TEMPORARY_STORAGE" domainObjectName="KafkaTemporaryStorage"-->
<!-- enableCountByExample="true" enableUpdateByExample="true"-->
<!-- enableDeleteByExample="true" enableSelectByExample="true"-->
......@@ -123,18 +130,18 @@
<!-- </table>-->
<table tableName="T_BI_DICTIONARY_ENTRIES" domainObjectName="DictionaryEntries"
enableCountByExample="true" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
<generatedKey column="ID" sqlStatement="SELECT SEQ_T_BI_DICTIONARY_ENTRIES.NEXTVAL FROM DUAL" />
</table>
<table tableName="T_BI_DICTIONARY" domainObjectName="Dictionary"
enableCountByExample="true" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
<generatedKey column="ID" sqlStatement="SELECT SEQ_T_BI_DICTIONARY.NEXTVAL FROM DUAL" />
</table>
<!-- <table tableName="T_BI_DICTIONARY_ENTRIES" domainObjectName="DictionaryEntries"-->
<!-- enableCountByExample="true" enableUpdateByExample="true"-->
<!-- enableDeleteByExample="true" enableSelectByExample="true"-->
<!-- selectByExampleQueryId="true">-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_BI_DICTIONARY_ENTRIES.NEXTVAL FROM DUAL" />-->
<!-- </table>-->
<!-- <table tableName="T_BI_DICTIONARY" domainObjectName="Dictionary"-->
<!-- enableCountByExample="true" enableUpdateByExample="true"-->
<!-- enableDeleteByExample="true" enableSelectByExample="true"-->
<!-- selectByExampleQueryId="true">-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_BI_DICTIONARY.NEXTVAL FROM DUAL" />-->
<!-- </table>-->
<!-- <table tableName="T_TASK_MANAGEMENT" domainObjectName="TaskManagement"-->
......
package com.fedex.connect.common.dependencies.arithmetic;
/**
* 密钥的长度
*/
public enum AESType {
AES_128(128),
AES_192(192),
AES_256(256);
public int value;
private AESType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}
package com.fedex.connect.common.dependencies.arithmetic;
import com.fedex.export.common.util.BytesUtils;
import org.apache.commons.lang3.StringUtils;
import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
/**
* AES加密解密工具里
*/
public class AESUtil {
/**
* 指定编码格式
*/
public static final String CHARSET = "UTF-8";
/**
* 设定秘钥
*/
public static final String key = "com123fedex456export789tw0";
public static void main(String[] args) throws Exception{
String content = "测试加密界面字符串";
byte[] encryptByte;
byte[] decodeByte;
String encodeStr;
String decodeStr;
encryptByte = encode_SysDefault(content);
encodeStr = BytesUtils.bytesToHexString(encryptByte);
System.out.println("加密后:" + encodeStr);
//数据库存储值转换后解密
byte[] dataColumnValue = BytesUtils.hexStringToBytes(encodeStr);
decodeByte = decode_SysDefault(dataColumnValue);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("系统默认解密后:" + decodeStr);
/**
* AES不指定模式和填充,默认为 ECB/PKCS5Padding
* AES/ECB
* AES/ECB/NoPadding
* AES/ECB/PKCS5Padding
* AES/ECB/ISO10126Padding
*/
/* System.out.println("AES ECB 128");
encryptByte = encode_AES_ECB_128(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_ECB_128(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);
System.out.println("AES ECB 192");
encryptByte = encode_AES_ECB_192(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_ECB_192(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);
System.out.println("AES ECB 256");
encryptByte = encode_AES_ECB_256(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_ECB_256(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);*/
/**
* AES/CBC
* AES/CBC/NoPadding
* AES/CBC/PKCS5Padding
* AES/CBC/ISO10126Padding
*/
/*System.out.println("AES CBC 128");
content = "必须十六必须十六必须十六必须十六";
encryptByte = encode_AES_CBC_128(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_CBC_128(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);
System.out.println("AES CBC 192");
content = "不是必须十六";
encryptByte = encode_AES_CBC_192(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_CBC_192(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);
System.out.println("AES CBC 256");
content = "不是必须十六";
encryptByte = encode_AES_CBC_256(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_CBC_256(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);
*/
/**
* AES/CFB
* AES/CBC/NoPadding
* AES/CBC/PKCS5Padding
* AES/CBC/ISO10126Padding
*/
/*System.out.println("AES CFB 128");
encryptByte = encode_AES_CFB_128(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_CFB_128(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);
System.out.println("AES CFB 192");
encryptByte = encode_AES_CFB_192(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_CFB_192(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);
System.out.println("AES CFB 256");
encryptByte = encode_AES_CFB_256(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_CFB_256(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);*/
/**
* AES/OFB
* AES/OFB/NoPadding
* AES/OFB/PKCS5Padding
* AES/OFB/ISO10126Padding
*/
/*System.out.println("AES OFB 128");
encryptByte = encode_AES_OFB_128(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_OFB_128(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);
System.out.println("AES OFB 192");
encryptByte = encode_AES_OFB_192(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_OFB_192(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);
System.out.println("AES OFB 256");
encryptByte = encode_AES_OFB_256(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_OFB_256(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);*/
/**
* 1.5 AES/PCBC
* AES/PCBC/NoPadding
* AES/PCBC/PKCS5Padding
* AES/PCBC/ISO10126Padding
*/
/*System.out.println("AES PCBC 128");
encryptByte = encode_AES_PCBC_128(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_PCBC_128(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);
System.out.println("AES PCBC 192");
encryptByte = encode_AES_PCBC_192(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_PCBC_192(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);
System.out.println("AES PCBC 256");
encryptByte = encode_AES_PCBC_256(content);
encodeStr = TypeConvert.bytesToHexString(encryptByte);
System.out.println("加密后为:" + encodeStr);
decodeByte = decode_AES_PCBC_256(encryptByte);
decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后:" + decodeStr);*/
}
/**
* 默认加密封装
* @param eVal 待加密字符串
* @return 加密后字符串
*/
public static String encode_default(String eVal){
if (StringUtils.isBlank(eVal)){
return null;
}
try{
byte[] encode_valByte = encode_SysDefault(StringUtils.trimToEmpty(eVal));
return BytesUtils.bytesToHexString(encode_valByte);
} catch (Exception e){
return null;
}
}
/**
* 默认解密封装
* @param dVal 待解密字符串
* @return 解密后字符串
*/
public static String decode_default(String dVal){
if (StringUtils.isBlank(dVal)){
return null;
}
try{
byte[] valByte = BytesUtils.hexStringToBytes(dVal);
byte[] decode_valByte = decode_SysDefault(valByte);
return new String(decode_valByte, CHARSET);
} catch (Exception e){
return null;
}
}
/**
* 判断入参值。是否已经加密。
* @param val
* @return
*/
public static boolean checkIsEncode(String val){
//加密的绝对很长
if (val.length() < 3){
return false;
}
try{
//尝试解密
byte[] dataColumnValue = BytesUtils.hexStringToBytes(val);
byte[] decodeByte = decode_SysDefault(dataColumnValue);
String decodeStr = new String(decodeByte, CHARSET);
//如果解密后和原数据一样。可能是没有加密
if (val.equals(decodeStr)){
return false;
}
//如果解密后和原数据不一致,说明加密过了。
return true;
}catch (Exception e){
//如果异常,说明没有加密
return false;
}
}
/**
* 系统默认采用加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_SysDefault(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_256,EncodeType.AES_CBC_ISO10126PADDING);
}
/**
* 系统默认采用解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_SysDefault(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_256,EncodeType.AES_CBC_ISO10126PADDING);
}
/**
* AES_PCBC_128加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_PCBC_128(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_128,EncodeType.AES_PCBC_PKCS5PADDING);
}
/**
* AES_PCBC_128 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_PCBC_128(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_128,EncodeType.AES_PCBC_PKCS5PADDING);
}
/**
* AES_PCBC_192加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_PCBC_192(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_192,EncodeType.AES_PCBC_PKCS5PADDING);
}
/**
* AES_PCBC_192 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_PCBC_192(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_192,EncodeType.AES_PCBC_PKCS5PADDING);
}
/**
* AES_PCBC_256加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_PCBC_256(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_256,EncodeType.AES_PCBC_PKCS5PADDING);
}
/**
* AES_PCBC_256 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_PCBC_256(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_256,EncodeType.AES_PCBC_PKCS5PADDING);
}
/**
* AES_OFB_128加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_OFB_128(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_128,EncodeType.AES_OFB_PKCS5PADDING);
}
/**
* AES_OFB_128 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_OFB_128(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_128,EncodeType.AES_OFB_PKCS5PADDING);
}
/**
* AES_OFB_192加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_OFB_192(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_192,EncodeType.AES_OFB_PKCS5PADDING);
}
/**
* AES_OFB_192 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_OFB_192(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_192,EncodeType.AES_OFB_PKCS5PADDING);
}
/**
* AES_OFB_256加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_OFB_256(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_256,EncodeType.AES_OFB_PKCS5PADDING);
}
/**
* AES_OFB_256 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_OFB_256(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_256,EncodeType.AES_OFB_PKCS5PADDING);
}
/**
* AES_CFB_128加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_CFB_128(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_128,EncodeType.AES_CFB_PKCS5PADDING);
}
/**
* AES_CFB_128 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_CFB_128(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_128,EncodeType.AES_CFB_PKCS5PADDING);
}
/**
* AES_CFB_192加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_CFB_192(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_192,EncodeType.AES_CFB_PKCS5PADDING);
}
/**
* AES_CFB_192 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_CFB_192(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_192,EncodeType.AES_CFB_PKCS5PADDING);
}
/**
* AES_CFB_256加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_CFB_256(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_256,EncodeType.AES_CFB_PKCS5PADDING);
}
/**
* AES_CFB_256 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_CFB_256(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_256,EncodeType.AES_CFB_PKCS5PADDING);
}
/**
* AES_CBC_128加密
* 输入必须是16字节,不然报错 javax.crypto.IllegalBlockSizeException: Input length not multiple of 16 bytes
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_CBC_128(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_128,EncodeType.AES_CBC_NOPADDING);
}
/**
* AES_CBC_128 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_CBC_128(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_128,EncodeType.AES_CBC_NOPADDING);
}
/**
* AES_CBC_192加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_CBC_192(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_192,EncodeType.AES_CBC_PKCS5PADDING);
}
/**
* AES_CBC_192 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_CBC_192(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_192,EncodeType.AES_CBC_PKCS5PADDING);
}
/**
* AES_CBC_256加密
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_CBC_256(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,getIV(),AESType.AES_256,EncodeType.AES_CBC_ISO10126PADDING);
}
/**
* AES_CBC_256 解密
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_CBC_256(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,getIV(),AESType.AES_256,EncodeType.AES_CBC_ISO10126PADDING);
}
/**
* AES_ECB_128加密(默认使用AES/ECB/PKCS5Padding)
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_ECB_128(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,null,AESType.AES_128,EncodeType.AES_DEFAULT);
}
/**
* AES_ECB_128 解密(默认使用AES/ECB/PKCS5Padding)
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_ECB_128(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,null,AESType.AES_128,EncodeType.AES_DEFAULT);
}
/**
* AES_ECB_192加密(默认使用AES/ECB/PKCS5Padding)
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_ECB_192(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,null,AESType.AES_192,EncodeType.AES_DEFAULT);
}
/**
* AES_ECB_192 解密(默认使用AES/ECB/PKCS5Padding)
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_ECB_192(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,null,AESType.AES_192,EncodeType.AES_DEFAULT);
}
/**
* AES_ECB_256加密(默认使用AES/ECB/PKCS5Padding)
* @param content 加密的字符串
* @return 加密后的字节
*/
public static byte[] encode_AES_ECB_256(String content) throws Exception{
return encryptOrdecrypt(true,content.getBytes(CHARSET),key,null,AESType.AES_256,EncodeType.AES_DEFAULT);
}
/**
* AES_ECB_256 解密(默认使用AES/ECB/PKCS5Padding)
* @param encrypt 加密后的字节
* @return 解密后的字节
*/
public static byte[] decode_AES_ECB_256(byte[] encrypt) throws Exception{
return encryptOrdecrypt(false,encrypt,key,null,AESType.AES_256,EncodeType.AES_DEFAULT);
}
/**
* 加密解密方法
* @param isEncrypt true:加密。false:解密
* @param source 源
* @param key 秘钥
* @param type 算法类型
* @param encodeType 算法/模式/填充
*/
public static byte[] encryptOrdecrypt(boolean isEncrypt, byte[] source, String key, byte[] iv, AESType type, String encodeType) throws UnsupportedEncodingException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchPaddingException, BadPaddingException, IllegalBlockSizeException, InvalidKeyException {
if (isEncrypt) {
byte[] encodeByte = encryptOrDecrypt(Cipher.ENCRYPT_MODE, source, key, iv, type, encodeType);
/* String encodeStr = TypeConvert.bytesToHexString(encodeByte);
System.out.println("加密后为:" + encodeStr);*/
return encodeByte;
} else {
byte[] decodeByte = encryptOrDecrypt(Cipher.DECRYPT_MODE, source, key, iv, type, encodeType);
/*String decodeStr = new String(decodeByte, CHARSET);
System.out.println("解密后为:" + decodeStr);*/
return decodeByte;
}
}
private static byte[] encryptOrDecrypt(int mode, byte[] byteContent, String key, byte[] iv, AESType type, String modeAndPadding) throws InvalidKeyException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchPaddingException, BadPaddingException, IllegalBlockSizeException {
KeyGenerator kgen = KeyGenerator.getInstance("AES");
//此处解决mac,linux报错
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
random.setSeed(key.getBytes());
kgen.init(type.value, random);
SecretKey secretKey = kgen.generateKey();
byte[] enCodeFormat = secretKey.getEncoded();
SecretKeySpec keySpec = new SecretKeySpec(enCodeFormat, "AES");
Cipher cipher = Cipher.getInstance(modeAndPadding);// 创建密码器
if (null != iv) {
//指定一个初始化向量 (Initialization vector,IV), IV 必须是16位
cipher.init(mode, keySpec, new IvParameterSpec(iv));
} else {
cipher.init(mode, keySpec);
}
byte[] result = cipher.doFinal(byteContent);
return result;
}
/**
* 指定一个初始化向量 (Initialization vector,IV),IV 必须是16位
*/
public static final byte[] getIV() throws Exception {
return "1234567812345678".getBytes(CHARSET);
}
}
\ No newline at end of file
package com.fedex.connect.common.dependencies.arithmetic;
/**
*
*/
public class EncodeType {
/**
算法/模式/填充 字节加密后数据长度 不满16字节加密后长度
AES/CBC/NoPadding 16 不支持
AES/CBC/PKCS5Padding 32 16
AES/CBC/ISO10126Padding 32 16
AES/CFB/NoPadding 16 原始数据长度
AES/CFB/PKCS5Padding 32 16
AES/CFB/ISO10126Padding 32 16
AES/ECB/NoPadding 16 不支持
AES/ECB/PKCS5Padding 32 16
AES/ECB/ISO10126Padding 32 16
AES/OFB/NoPadding 16 原始数据长度
AES/OFB/PKCS5Padding 32 16
AES/OFB/ISO10126Padding 32 16
AES/PCBC/NoPadding 16 不支持
AES/PCBC/PKCS5Padding 32 16
AES/PCBC/ISO10126Padding 32 16
*/
//默认为 AES_CBC_PKCS5PADDING
public final static String AES_DEFAULT = "AES";
public final static String AES_CBC_NOPADDING = "AES/CBC/NoPadding";
public final static String AES_CBC_PKCS5PADDING = "AES/CBC/PKCS5Padding";
public final static String AES_CBC_ISO10126PADDING = "AES/CBC/ISO10126Padding";
public final static String AES_CFB_NOPADDING = "AES/CFB/NoPadding";
public final static String AES_CFB_PKCS5PADDING = "AES/CFB/PKCS5Padding";
public final static String AES_CFB_ISO10126PADDING = "AES/CFB/ISO10126Padding";
public final static String AES_ECB_NOPADDING = "AES/ECB/NoPadding";
public final static String AES_ECB_PKCS5PADDING = "AES/ECB/PKCS5Padding";
public final static String AES_ECB_ISO10126PADDING = "AES/ECB/ISO10126Padding";
public final static String AES_OFB_NOPADDING = "AES/OFB/NoPadding";
public final static String AES_OFB_PKCS5PADDING = "AES/OFB/PKCS5Padding";
public final static String AES_OFB_ISO10126PADDING = "AES/OFB/ISO10126Padding";
public final static String AES_PCBC_NOPADDING = "AES/PCBC/NoPadding";
public final static String AES_PCBC_PKCS5PADDING = "AES/PCBC/PKCS5Padding";
public final static String AES_PCBC_ISO10126PADDING = "AES/PCBC/ISO10126Padding";
}
package com.fedex.connect.common.dependencies.authentication;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.password.StandardPasswordEncoder;
/**
* @author Administrator
*/
public class EncryptProvider {
//加密密钥
private static final PasswordEncoder ENCODER = new StandardPasswordEncoder("exportTw");
/**
* Spring-security-crypto加密方式
*
* @param pwd 需要加密的密码
*/
public static String encrypt(String pwd) {
return ENCODER.encode(pwd);
}
/**
* 校验原密码和加密后的密码是否一致
*
* @param pwd 原密码
* @param encodedPassword 加密后的密码
* @return
*/
public static boolean match(String pwd, String encodedPassword) {
return ENCODER.matches(pwd, encodedPassword);
}
}
package com.fedex.connect.common.dependencies.authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.util.UrlUtils;
import org.springframework.util.Assert;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 登录失败处理器
* @author Administrator
*/
public class MyAuthenticationFailureHandler implements AuthenticationFailureHandler {
private final String forwardUrl;
public MyAuthenticationFailureHandler(String forwardUrl) {
Assert.isTrue(UrlUtils.isValidRedirectUrl(forwardUrl), () -> {
return "'" + forwardUrl + "' is not a valid forward URL";
});
this.forwardUrl = forwardUrl;
}
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
request.setAttribute("SPRING_SECURITY_LAST_EXCEPTION", exception);
response.sendRedirect(forwardUrl);
}
}
package com.fedex.connect.common.dependencies.authentication;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 自定义认证成功处理器
* @author Administrator
*/
public class MyAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
private final String forwardUrl;
public MyAuthenticationSuccessHandler(String forwardUrl) {
this.forwardUrl = forwardUrl;
}
@Override
public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
httpServletResponse.sendRedirect(forwardUrl);
}
}
package com.fedex.connect.common.dependencies.authentication;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* 读取配置文件
* @author Administrator
*/
@ConfigurationProperties(prefix = "export.jwt")
public class SecurityConstants {
/**
* 定义鉴权使用常量
*/
public static final String TOKEN_HEADER = "Authorization";
public static final String REFLUSH_TOKEN= "ReflushToken";
public static final String TOKEN_PREFIX = "Bearer ";
public static final String TOKEN_TYPE = "JWT";
public static final String ROLE_CLAIMS = "rol";
public static long expire_1H;
public static long expire_1D;
/**
* JWT 的 秘钥
*/
public static String securitykey;
public static String[] urlWhiteList;
public static String[] uriWhiteList;
public static long getExpire_1H() {
return expire_1H;
}
public void setExpire_1H(long expire_1H) {
SecurityConstants.expire_1H = expire_1H;
}
public static long getExpire_1D() {
return expire_1D;
}
public void setExpire_1D(long expire_1D) {
SecurityConstants.expire_1D = expire_1D;
}
public static String getSecuritykey() {
return securitykey;
}
public void setSecuritykey(String securitykey) {
SecurityConstants.securitykey = securitykey;
}
public static String[] getUrlWhiteList() {
return urlWhiteList;
}
public void setUrlWhiteList(String[] urlWhiteList) {
SecurityConstants.urlWhiteList = urlWhiteList;
}
public static String[] getUriWhiteList() {
return uriWhiteList;
}
public void setUriWhiteList(String[] uriWhiteList) {
SecurityConstants.uriWhiteList = uriWhiteList;
}
}
package com.fedex.connect.common.dependencies.authentication;
import com.fedex.export.authentication.exception.JwtAccessDeniedHandler;
import com.fedex.export.authentication.exception.JwtAuthenticationEntryPoint;
import com.fedex.export.authentication.filter.JwtAuthorizationFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
* Spring-Security 配置
* @author Administrator
*/
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
/**
* 配置安全过滤器
* @param http
* @throws Exception
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
//放行白名单(这个配置会比读取配置文件优先进行,别问我怎么知道的)
String[] whiteList = {"/icleartw/login.html","/icleartw/auth/login","/icleartw/auth/addUser",
"/icleartw/oss/ossLogin", "/icleartw/sysUser/logout","/icleartw/auth/getUser","/icleartw/static/*",
"/icleartw/swagger-ui.html","/icleartw/swagger-resources","/icleartw/webjars","/icleartw/swagger-ui/*", "/icleartw/v2/api-docs","/**"};
//formLogin配置登录页面和成功/失败的响应
http.formLogin()
.loginPage("/icleartw/login.html").permitAll()
//.successHandler(new MyAuthenticationSuccessHandler("/main"))
//.failureHandler(new MyAuthenticationFailureHandler("/403.html"))
.and()
//authorizeRequests方法配置访问控制规则
.authorizeRequests()
.antMatchers(whiteList).permitAll()
.anyRequest().authenticated() //其他未定义的 URL 需要进行身份认证才能访问
//添加JWT
.and()
//配置过滤器
.addFilter(new JwtAuthorizationFilter(super.authenticationManager()))
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) //禁用Session
.and().exceptionHandling()
.authenticationEntryPoint(new JwtAuthenticationEntryPoint()) //拒绝访问处理
.accessDeniedHandler(new JwtAccessDeniedHandler()) //无权访问处理
.and().logout().permitAll()
.and().csrf().disable();
}
@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
//添加BC加密算法
return new BCryptPasswordEncoder();
}
}
package com.fedex.connect.common.dependencies.authentication.exception;
import com.fedex.export.common.i18n.LocaleMessageUtil;
import com.fedex.export.common.util.SpringBeanUtil;
import com.fedex.export.data.vo.JsonResult;
import com.google.gson.Gson;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author Administrator
*
*/
public class JwtAccessDeniedHandler implements AccessDeniedHandler {
/**
* 没有访问权限:当用户通过认证,但没有足够的权限对指定资源操作,返回403
*/
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException {
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
JsonResult result = new JsonResult();
result.setCode(HttpServletResponse.SC_FORBIDDEN);
//使用context手动注入
LocaleMessageUtil localeMessageUtil = SpringBeanUtil.getBean(LocaleMessageUtil.class);
result.setMsg(localeMessageUtil.getMessage("auth_exc_no_auth"));
Gson gson = new Gson();
response.getWriter().println(gson.toJson(result));
response.getWriter().flush();
}
}
package com.fedex.connect.common.dependencies.authentication.exception;
import com.fedex.export.common.i18n.LocaleMessageUtil;
import com.fedex.export.common.util.SpringBeanUtil;
import com.fedex.export.data.vo.JsonResult;
import com.google.gson.Gson;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* 拒绝访问:当用户没有通过认证,返回401
* @author Administrator
*/
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
@Override
public void commence(HttpServletRequest request,
HttpServletResponse response,
AuthenticationException authException) throws IOException {
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
JsonResult result = new JsonResult();
result.setCode(HttpServletResponse.SC_UNAUTHORIZED);
//使用context手动注入
LocaleMessageUtil localeMessageUtil = SpringBeanUtil.getBean(LocaleMessageUtil.class);
result.setMsg(localeMessageUtil.getMessage("auth_exc_no_pass_auth"));
Gson gson = new Gson();
response.getWriter().println(gson.toJson(result));
response.getWriter().flush();
}
}
package com.fedex.connect.common.dependencies.authentication.filter;
import com.fedex.export.authentication.SecurityConstants;
import com.fedex.export.common.contants.RedisConstants;
import com.fedex.export.common.i18n.LocaleMessageUtil;
import com.fedex.export.common.util.JsonUtils;
import com.fedex.export.common.util.JwtTokenUtils;
import com.fedex.export.common.util.SpringBeanUtil;
import com.fedex.export.common.util.Utils;
import com.fedex.export.repository.entity.RedisSlab;
import com.fedex.export.service.system.RedisUtilService;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.ExpiredJwtException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
/**
* Spring Security实际 上是基于Filter实现的
* 写一个过滤器,继承BasicAuthenticationFilter
* @author EDY
*/
public class JwtAuthorizationFilter extends BasicAuthenticationFilter {
private Logger logger = LoggerFactory.getLogger(JwtAuthorizationFilter.class);
public JwtAuthorizationFilter(AuthenticationManager authenticationManager) {
super(authenticationManager);
}
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain) throws IOException, ServletException {
String token = request.getHeader(SecurityConstants.TOKEN_HEADER);
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", "POST");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "x-requested-with, authorization, Content-Type, Authorization, credential, X-XSRF-TOKEN,Token,userName,client,OBLIX_UID");
response.setHeader("Access-Control-Expose-Headers", "Token");
//放行白名单
List<String> urlWhiteList = Arrays.asList(SecurityConstants.urlWhiteList);
List<String> uriWhiteList = Arrays.asList(SecurityConstants.uriWhiteList);
//返回请求行中的资源名部分
String requestUri = request.getRequestURI();
//返回客户端发出请求完整URL
String reqeustUrl = request.getRequestURL().toString();
logger.info("------------- FROM NETWORK :{}", requestUri);
if (reqeustUrl.indexOf("/sysUser/logout") > 0) {
//退出登录接口,不验token
chain.doFilter(request, response);
return;
}
//使用context手动注入
LocaleMessageUtil localeMessageUtil = SpringBeanUtil.getBean(LocaleMessageUtil.class);
RedisUtilService redisUtilService = SpringBeanUtil.getBean(RedisUtilService.class);
if (token == null || !token.startsWith(SecurityConstants.TOKEN_PREFIX)) {
SecurityContextHolder.clearContext();
if(Utils.listOf(urlWhiteList).stream().filter(Objects::nonNull).anyMatch(urlW -> reqeustUrl.indexOf(urlW) > 0)
|| Utils.listOf(uriWhiteList).stream().filter(Objects::nonNull).anyMatch(uriW -> requestUri.equals(uriW))
|| Utils.listOf(uriWhiteList).stream().filter(Objects::nonNull).filter(u -> u.indexOf("*") > 0).anyMatch(uriW -> requestUri.startsWith(uriW.replace("*","")))
|| "/".equals(requestUri)
|| "OPTIONS".equals(request.getMethod())){
logger.info("--------------- 登录白名单无需验证");
chain.doFilter(request, response);
return;
}
Map<String, Object> result = new HashMap<>();
result.put("code", 301);
result.put("msg", localeMessageUtil.getMessage("auth_filter_user_error"));
logger.info("CODE_301 requestURL:{} ,reason:{}" , request.getRequestURL()," 非白名单url路径登录");
ServletOutputStream out = response.getOutputStream();
out.write(JsonUtils.mapToJson(result).getBytes());
out.flush();
return;
}
UsernamePasswordAuthenticationToken authentication = null;
//判断accessToken是否过期
String tokenValue = token.replace(SecurityConstants.TOKEN_PREFIX, "");
try {
Date expiredTime = JwtTokenUtils.getAccessTokenExpiredTime(tokenValue);
logger.debug("TOKEN 过期时间为 :{}", expiredTime);
String id = JwtTokenUtils.getId(tokenValue);
String redisKey = RedisConstants.REDIS_KEY_TOKEN + id;
RedisSlab redisSlab = redisUtilService.get(redisKey);
String tokenRedis = redisSlab != null ? Optional.ofNullable(redisSlab.getRedisMsg()).orElse(null): null;
/*String tokenRedis = redisUtilService.get(redisKey);*/
if (StringUtils.isEmpty(tokenRedis)) {
//redis没有,超过8小时,踢出去
Map<String, Object> result = new HashMap<>();
result.put("code", 301);
result.put("msg", localeMessageUtil.getMessage("auth_filter_timeout"));
logger.info("CODE_301 requestURL:{} ,reason:{}" , request.getRequestURL() ,"tokenRedis is empty");
ServletOutputStream out = response.getOutputStream();
out.write(JsonUtils.mapToJson(result).getBytes());
out.flush();
return;
}
/*//更新token
String tokenRedisValue = tokenRedis.replace(SecurityConstants.TOKEN_PREFIX, "");
String userName = JwtTokenUtils.getUserName(tokenRedisValue);
List<String> role = JwtTokenUtils.getRoleList(tokenRedisValue);
//返回前端的新token
String newToken = JwtTokenUtils.createReflushToken(userName, id, role);
logger.info("REFRESH TOKEN ");
response.setHeader("Token", newToken);*/
} catch (ExpiredJwtException ee) {
//已经过期了,直接踢
logger.info("CODE_301 requestURL:{},reason:{}" , request.getRequestURL(),"ExpiredJwtException ",ee);
Claims claims = ee.getClaims();
String id = claims.getId();
Map<String, Object> result = new HashMap<>();
result.put("code", 301);
result.put("msg", localeMessageUtil.getMessage("auth_filter_stale_dated"));
ServletOutputStream out = response.getOutputStream();
out.write(JsonUtils.mapToJson(result).getBytes());
out.flush();
return;
} catch (Exception e) {
logger.error("*********************token 异常 : *******************************", e);
Map<String, Object> result = new HashMap<>();
result.put("code", 301);
result.put("msg", localeMessageUtil.getMessage("auth_filter_user_error"));
ServletOutputStream out = response.getOutputStream();
out.write(JsonUtils.mapToJson(result).getBytes());
out.flush();
return;
}
authentication = JwtTokenUtils.getAuthentication(tokenValue);
SecurityContextHolder.getContext().setAuthentication(authentication);
chain.doFilter(request, response);
return;
}
}
package com.fedex.connect.common.dependencies.config;
import com.fedex.connect.common.dependencies.contants.DatabaseConstants;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.common.model.base.DictionaryEntries;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* 预先数据的加载
* 有兴趣了解搜索:CommandLineRunner详解
* @author EDY
*/
@Component
@Order(1)
public class CacheSystem implements CommandLineRunner {
private static final Logger log = LoggerFactory.getLogger(CacheSystem.class);
// 从 DictionaryProvider 获取字典数据
List<DictionaryEntries> dictionaryData = DictionaryProvider.getDictionaryData();
// 静态缓存数据
public static List<DictionaryEntries> dictionaryListAll = new ArrayList<>();
public static Map<String, List<DictionaryEntries>> dictionaryMap = new HashMap<>();
public static Map<String, String> declarationTypeMap = new HashMap<>();
public static Map<String, String> deliveryStatusMap = new HashMap<>();
public static Map<String, String> operStatusMap = new HashMap<>();
public static List<DictionaryEntries> currencyCdList = new ArrayList<>();
@Override
public void run(String... args) {
if (dictionaryData == null) {
log.warn("SysDictionaryService not set, skipping cache initialization.");
return;
}
log.info("System init load to cache in memory start");
try{
CacheSystem.dictionaryListAll = dictionaryData;
if (CollectionUtils.isEmpty(CacheSystem.dictionaryListAll)){
return;
}
CacheSystem.dictionaryMap = Utils.listOf(CacheSystem.dictionaryListAll).stream().filter(Objects::nonNull)
.collect(Collectors.groupingBy(DictionaryEntries::getDictCode));
List<DictionaryEntries> declarationTypeList = CacheSystem.dictionaryMap.get(DatabaseConstants.DICT_CUSTOMS_DECLARATION_TYPE_CODE);
CacheSystem.declarationTypeMap = Utils.listOf(declarationTypeList).stream()
.collect(Collectors.toMap(DictionaryEntries::getCode, DictionaryEntries::getEnglishName));
List<DictionaryEntries> deliveryStatusList = CacheSystem.dictionaryMap.get(DatabaseConstants.DICT_DELIVERY_STATUS_CODE);
CacheSystem.deliveryStatusMap = Utils.listOf(deliveryStatusList).stream()
.collect(Collectors.toMap(DictionaryEntries::getCode, DictionaryEntries::getEnglishName));
List<DictionaryEntries> operStatusList = CacheSystem.dictionaryMap.get(DatabaseConstants.DICT_OPER_STATUS_CODE);
CacheSystem.operStatusMap = Utils.listOf(operStatusList).stream()
.collect(Collectors.toMap(DictionaryEntries::getCode, DictionaryEntries::getEnglishName));
CacheSystem.currencyCdList = CacheSystem.dictionaryMap.get(DatabaseConstants.DICT_CURRENCY_CD_CODE);
} catch (Exception e){
log.error("load cache error:{}",e);
} log.info("System init load to cache in memory end");
}
}
package com.fedex.connect.common.dependencies.config;
import com.fedex.connect.common.model.base.DictionaryEntries;
import java.util.List;
public class DictionaryProvider {
// 用于存储字典数据的静态列表
private static List<DictionaryEntries> dictionaryData;
// 设置字典数据的方法
public static void setDictionaryData(List<DictionaryEntries> data) {
dictionaryData = data;
}
// 获取字典数据的方法
public static List<DictionaryEntries> getDictionaryData() {
return dictionaryData;
}
}
package com.fedex.connect.common.dependencies.contants;
/**
* 定义数据库同样常量
*/
public class DatabaseConstants {
/**
* 定义通用状态常量。
* 1:有效[true]。0:无效[false]
*/
public static final Long GLOBAL_STATUS_VALID = 1L;
public static final Long GLOBAL_STATUS_DEL = 0L;
/**
* 定义操作状态常量
* 1: 已提交 2:正在录入
*/
public static final Long GLOBAL_OPER_STATUS_SAVE = 1L;
public static final Long GLOBAL_OPER_STATUS_DRAFT = 2L;
/**
* 定义申报信息提单状态
* 0:未发送 (冗余)
* 1:已发送(异步成功状态)
* 2:已接收。(回执成功状态)
* 3:发送失败。(提交后异步发送失败状态。定时任务补偿机制读取此状态数据)
* 4:接收失败。
* (4-1:3次重发邮件都失败。
* 4-2:回执3次重试读取仍失败为此状态。
* 4-3:超过1小时为此状态。
* 4-4:3次匹配不到为此状态。
* 4-5:其他失败)
*/
public static final Long DELIVERY_STATUS_UNSENT = 0L;
public static final Long DELIVERY_STATUS_SENT = 1L;
public static final Long DELIVERY_STATUS_RECEIVE = 2L;
public static final Long DELIVERY_STATUS_SENT_FAIL = 3L;
public static final Long DELIVERY_STATUS_RECEIVE_FAIL = 4L;
/**
* 定义文件来源常量
* 1:上传。2:系统生成。3:图案商标
*/
public static final Long FILE_SOURCE_UPDATE = 1L;
public static final Long FILE_SOURCE_SYS_CREATE = 2L;
public static final Long FILE_SOURCE_SYS_BRAND = 3L;
/**
* 定义信息录入状态
* 1:已校验过数据。2:数据未校验
*/
public static final Long DECLARE_CHECK = 1L;
public static final Long DECLARE_SAVE = 2L;
/**
* 定义邮件发送状态
* (0:未发送。1:发送成功。2:发送失败)
*/
public static final Long MAIL_SEND_UNSENT = 0L;
public static final Long MAIL_SEND_SUCC = 1L;
public static final Long MAIL_SEND_FAIL = 2L;
public static final Long USER_SOURCE_TW = 1L;
public static final Long USER_SOURCE_FCL = 2L;
/**
* 定义用户操作类型常量
* 1:登录 2:退出 3:修改密码4:FCL登录注册。5:停用,6:启用
*/
public static final Long USER_OPER_LOGIN = 1L;
public static final Long USER_OPER_LOGOUT = 2L;
public static final Long USER_OPER_UPD_PWD = 3L;
public static final Long USER_OPER_FCL_REGISTER = 4L;
public static final Long USER_OPER_STOP = 5L;
public static final Long USER_OPER_INIT = 6L;
/**
* 定义申报信息文件生成选择常量
* 1: 立即制作 2:使用已制作
*/
public static final Long FILE_SELECT_MAKE = 1L;
public static final Long FILE_SELECT_EXISTS = 2L;
/**
* 菜单类型
* M:主菜单 C:分支菜单 B:按钮
*/
public static final String SYS_MENU_TYPE_MAIN = "M";
public static final String SYS_MENU_TYPE_BRANCH = "C";
public static final String SYS_MENU_TYPE_BUTTON = "B";
/**
* 用户类型
* 在线申报平台账号
*/
public static final String DICT_USER_GOOUP_CODE = "user_type";
public static final String DICT_USER_DEFAULT_CODE = "default";
public static final String DICT_USER_FEDEX_CODE = "fedex";
/**
* 角色类型
* admin
*/
public static final String DICT_ROLE_GOOUP_CODE = "role_type";
public static final String DICT_ROLE_DEFAULT_CODE = "admin";
/**
* 报关类别
*/
public static final String DICT_CUSTOMS_DECLARATION_TYPE_CODE = "customs_declaration_type";
/**
* 报关类别 -> 其它
*/
public static final String DICT_CUSTOMS_DECLARATION_TYPE_CODE_OTHER = "OTHER";
/**
* 出口统计方式
*/
public static final String DICT_EXPORT_STATISTICS_METHOD_CODE = "export_statistics_method";
/**
* 币种
*/
public static final String DICT_CURRENCY_CD_CODE = "currency_cd";
/**
* 商标
*/
public static final String DICT_BRAND_CODE = "brand";
/**
* 产证
*/
public static final String DICT_PROPERTY_CERTIFICATE_CODE = "property_certificate";
/**
* ECFA产证
*/
public static final String DICT_ECFA_PROPERTY_CERTIFICATE_CODE = "ecfa_property_certificate";
/**
* 申请
*/
public static final String DICT_APPLY_FOR_CODE = "apply_for";
/**
* 提单状态
*/
public static final String DICT_DELIVERY_STATUS_CODE = "delivery_status";
/**
* 操作状态
*/
public static final String DICT_OPER_STATUS_CODE = "oper_status";
/**
* 提单状态
*/
public static final String DICT_FILE_SOURCE_CODE = "file_source";
/**
* 提单状态
*/
public static final String DICT_LOGIN_TYPE_CODE = "login_type";
/**
* 邮件发送状态
*/
public static final String DICT_MAIL_SEND_STATUS_CODE = "mail_send_status";
/**
* 任务默认节点
*/
public static final Long TASK_DEFAULT_NODE = 1L;
/**
* 任务默认执行类型
*/
public static final Long TASK_EXEC_TYPE = 1L;
/**
* 任务类型。
* 1:执行程序操作(增删改查)数据。
* 2:邮件发送。
* 3:读取消息系统数据(MQ、Kafka、redis等)
* 4:写入消息系统数据(MQ、Kafka、redis等)
* 5:请求外部系统获取数据。
* 6:推送数据到外部系统。
*/
public static final Long TASK_TYPE_EXEC = 1L;
public static final Long TASK_TYPE_MAIL = 2L;
public static final Long TASK_TYPE_READ_MQ = 3L;
public static final Long TASK_TYPE_WRITE_MQ = 4L;
public static final Long TASK_TYPE_READ_SERVER = 5L;
public static final Long TASK_TYPE_WRITE_SERVER = 6L;
/**
* 任务状态
* 0:待执行(初始状态)。
* 1:执行成功。
* 2:执行中待获取结果。
* 3:执行失败
*/
public static final Long TASK_STATUS_INIT = 0L;
public static final Long TASK_STATUS_SUCC = 1L;
public static final Long TASK_STATUS_IN_EXEC = 2L;
public static final Long TASK_STATUS_FAIL = 3L;
/**
* 申报信息在任务管理中的分组CODE
*/
public static final String TASK_GROUP_CODE_DECLARE = "DECLARE_INFO";
/**
* 重置密码在邮件日志里面的分组
*/
public static final String MAIL_GROUP_CODE_RESETPWD = "RESULT_PASSWORD";
public static final String FCL_PREFIX = "FCL";
/**
* 有无商标
* 1:无商标
*/
public static final Long BRAND_NO = 1L;
/**
* 是否为电子冲退税报单
* 0:否
* 1:是
*/
public static final Long TAX_FLAG_NO = 0L;
public static final Long TAX_FLAG_YES = 1L;
/**
* 定义保存操作步骤
* 1:申报信息 2:核检信息 3:文件上传
*/
public static final Long DEC_SAVE_INFO = 1L;
public static final Long DEC_SAVE_CHECK_INFO = 2L;
public static final Long DEC_SAVE_FILE = 3L;
/**
* 报关类别
*/
public static final String DT_G5 = "G5";
public static final String DT_G3 = "G3";
public static final String DT_B9 = "B9";
public static final String DT_B8 = "B8";
public static final String DT_D5 = "D5";
public static final String DT_F5 = "F5";
/**
* 出口统计方式
*/
public static final String ESM_02 = "02";
public static final String ESM_81 = "81";
public static final String ESM_04 = "04";
public static final String ESM_82 = "82";
public static final String ESM_9E = "9E"; //del
public static final String ESM_9L = "9L";
public static final String ESM_91 = "91";
public static final String ESM_9S = "9S";
public static final String ESM_94 = "94";
public static final String ESM_92 = "92";
public static final String ESM_9M = "9M";
public static final String ESM_96 = "96";
public static final String ESM_53 = "53";
public static final String ESM_OTHER = "OTHER";
/**
* 产证
*/
public static final String PC_NO = "pc_no";
public static final String PC_YES = "pc_yes";
public static final String PC_RANDOM = "pc_random";
public static final String PC_NI_RANDOM = "pc_niRandom";
/**
* ECFA产证
*/
public static final String ECFA_NO = "ecfa_no";
public static final String ECFA_YES = "ecfa_yes";
public static final String ECFA_APPLY = "ecfa_apply";
/**
* 申请
*/
public static final String AF_CT = "ct";
public static final String AF_TN = "tn";
public static final String AF_CK = "ck";
/**
* 提单失败类型
* 1:超时失败(提单状态=4,超时情况。提示联系清关部门)
* 2:三次发送邮件失败(提单状态=4,三次重发邮件失败。显示操作:重发)
* 3:读取回执为失败(提单状态=4,读取失败,重试次数耗尽。浮框显示FAILED_MSG失败原因。)
* 4:其他情况失败(3次匹配。其他情况等。显示:联系清关部门)
*/
public static final Long RECEIPT_FAIL_TYPE_TIMEOUT = 1L;
public static final Long RECEIPT_FAIL_TYPE_RESEND = 2L;
public static final Long RECEIPT_FAIL_TYPE_RECEIPT = 3L;
public static final Long RECEIPT_FAIL_TYPE_OTHER = 4L;
/**
* 获取系统配置参数中邮件人员信息配置
*/
public static final String SEND_MAIL_GROUP_DECLARE = "DECLARE_SEND_MAIL";
public static final String SEND_MAIL_GROUP_RESETPWD = "RESETPWD_SEND_MAIL";
public static final String MAIL_FROM = "FROM";
public static final String MAIL_PWD = "PWD";
public static final String MAIL_TO = "TO";
public static final String MAIL_CC = "CC";
/**
* VIP清关组
*/
public static final Long VIP_CC_TYPE = 1L;
public static final Long VIP_CC_LIST_TYPE_WHITE = 1L;
public static final Long VIP_CC_LIST_TYPE_BLACK = 2L;
public static final String VIP_CC_ADD_CC_MAIL = "ADD_CC_MAIL";
}
package com.fedex.connect.common.dependencies.contants;
/**
* Redis使用常量。鉴权和redis都使用
*/
public class RedisConstants {
public static final String REDIS_KEY_TOKEN = "tw_user:token:";
public static final int REDIS_EXPIRE_TIME_2H = 7200;
public static final int REDIS_EXPIRE_TIME_8H = 28800;
public static final int REDIS_EXPRIE_TIME_1D = 86400;
public static final int REDIS_EXPRIE_TIME_1W = 604800;
}
package com.fedex.connect.common.dependencies.enums;
/**
* @author erry
*/
public enum ResponseCode {
/**
* 200=操作成功
* 201=操作失败
* 202=API接口请求异常
* 203=后台程序发生异常
* 204=请求方式错误
* 205=api接口请求错误
* 206=api接口请求结果为空
* 207=系统异常!
*
* 301=登录身份异常
* 302=登录已过期
* 303=用户不存在
* 304=用户已禁用,不能登录!
* 305=登录token过期,请重新登录!
* 306=该角色下有用户存在,是否确认删除?
*
* 601=数据被占用
* 602=记录已存在,请勿重复添加
* 603=导出数据量过大,请不要超过10W条
*
* 604=请求参数为空
* 605=ID为空
* 606=数据不存在
* 607=请求参数值不合理
*/
SUCCESS_CODE(200,"enum_res_code_200"),
FAIL_CODE(201,"enum_res_code_201"),
API_EXCEPTION(202, "enum_res_code_202"),
PROGRAM_ERROR(203,"enum_res_code_203"),
METHOD_EXCEPTION_CODE(204, "enum_res_code_204"),
HTTP_CLIENT_ERROR(205, "enum_res_code_205"),
HTTP_CLIENT_EMPTY(206, "enum_res_code_206"),
SYSTEM_EXECEPTION_CODE(207,"enum_res_code_207"),
TOKEN_FORMAT_ERROR(301, "enum_res_code_301"),
TOKEN_EXPIRE(302, "enum_res_code_302"),
USER_IS_NULL(303, "enum_res_code_303"),
USER_DISABLED(304, "enum_res_code_304"),
OVERDUE_TOKEN_CODE(305,"enum_res_code_305"),
ROLE_CONFIRM_DEL(306, "enum_res_code_306"),
INSERT_EXCEPITON(601,"enum_res_code_601"),
RECORD_EXIST(602, "enum_res_code_602"),
EXPORT_TOO_LARGE(603, "enum_res_code_603"),
REQUEST_PARAM_NULL(604, "enum_res_code_604"),
REQUEST_ID_NULL(605, "enum_res_code_605"),
REQUEST_OBJECT_NULL(606, "enum_res_code_606"),
REQUEST_PARAM_UNREASONABLE(606, "enum_res_code_607");
private Integer code;
private String msg;
ResponseCode(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
package com.fedex.connect.common.dependencies.i18n;
import org.springframework.context.MessageSourceResolvable;
import java.io.Serializable;
/**
* @author EDY
*/
public class DefaultMessageSourceResolvable implements MessageSourceResolvable, Serializable {
private final String[] codes;
private final Object[] arguments;
private final String defaultMessage;
/**
* 创建一个新的DefaultMessageSourceResolvable.
* @param code 用来解析消息的码
*/
public DefaultMessageSourceResolvable(String code) {
this(new String[] {code}, null, null);
}
/**
* 创建一个新的DefaultMessageSourceResolvable.
* @param codes 用来解析消息的码
*/
public DefaultMessageSourceResolvable(String[] codes) {
this(codes, null, null);
}
/**
* 创建一个新的DefaultMessageSourceResolvable.
* @param codes 用来解析消息的码
* @param defaultMessage 用来解析消息的默认消息
*/
public DefaultMessageSourceResolvable(String[] codes, String defaultMessage) {
this(codes, null, defaultMessage);
}
/**
* 创建一个新的DefaultMessageSourceResolvable.
* @param codes 用来解析消息的码
* @param arguments 用来解析消息的参数数组
*/
public DefaultMessageSourceResolvable(String[] codes, Object[] arguments) {
this(codes, arguments, null);
}
/**
* 创建一个新的DefaultMessageSourceResolvable.
* @param codes 用来解析消息的码
* @param arguments 用来解析消息的参数数组
* @param defaultMessage 用来解析消息的默认消息
*/
public DefaultMessageSourceResolvable(
String[] codes,Object[] arguments, String defaultMessage) {
this.codes = codes;
this.arguments = arguments;
this.defaultMessage = defaultMessage;
}
/**
* Copy constructor: Create a new instance from another resolvable.
* @param resolvable the resolvable to copy from
*/
public DefaultMessageSourceResolvable(MessageSourceResolvable resolvable) {
this(resolvable.getCodes(), resolvable.getArguments(), resolvable.getDefaultMessage());
}
/**
* Return the default code of this resolvable, that is,
* the last one in the codes array.
*/
public String getCode() {
return (this.codes != null && this.codes.length > 0 ? this.codes[this.codes.length - 1] : null);
}
@Override
public String[] getCodes() {
return this.codes;
}
@Override
public Object[] getArguments() {
return this.arguments;
}
@Override
public String getDefaultMessage() {
return this.defaultMessage;
}
/**
* 表示指定默认的消息是否需要获取,来替换占位符and/or MessageFormat
* return true:如果默认的消息可能包含参数占位符
* return false:如果它明确没有包含占位符或者自定义逃逸并且当前可以被简单暴露
* @see #getDefaultMessage()
* @see #getArguments()
*/
public boolean shouldRenderDefaultMessage() {
return true;
}
}
package com.fedex.connect.common.dependencies.i18n;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class I18nConfig implements WebMvcConfigurer {
@Bean
public LocaleResolver localeResolver() {
return new MessageLocaleResolver();
}
}
package com.fedex.connect.common.dependencies.i18n;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceResolvable;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* 根据语言编码查询内容
*/
@Component
public class LocaleMessageUtil {
@Resource
private MessageSource messageSource;
public LocaleMessageUtil() {
}
public String getMessage(String code) {
return this.getConnectorMessage(code, null);
}
public String getMessage(String code,String defaultMessage) {
return this.getConnectorMessage(code, null, defaultMessage);
}
public String getMessage(String code, Object[] args) {
return this.getConnectorMessage(code, args);
}
public String getMessage(String code, Object[] args,String defaultMessage) {
return this.getConnectorMessage(code, args,defaultMessage);
}
/**
* 解析code对应的信息进行返回,如果对应的code不能被解析则抛出异常NoSuchMessageException
* @param code 需要进行解析的code,对应资源文件中的一个属性名
* @param args 需要用来替换code对应的信息中包含参数的内容,如:{0},{1,date},{2,time}
* @return
*/
private String getConnectorMessage(String code, Object[] args){
return this.messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
}
/**
* 解析code对应的信息进行返回,如果对应的code不能被解析则返回默认信息defaultMessage。
* @param code 需要进行解析的code,对应资源文件中的一个属性名
* @param args 需要用来替换code对应的信息中包含参数的内容,如:{0},{1,date},{2,time}
* @param defaultMessage 当对应code对应的信息不存在时需要返回的默认值
* @return
*/
private String getConnectorMessage(String code, Object[] args, String defaultMessage){
return this.messageSource.getMessage(code, args, defaultMessage, LocaleContextHolder.getLocale());
}
/**
* 根据封装对象,获取
* @param resolvable 封装对象
* @return
*/
private String getConnectorMessage(MessageSourceResolvable resolvable){
return this.messageSource.getMessage(resolvable, LocaleContextHolder.getLocale());
}
}
package com.fedex.connect.common.dependencies.i18n;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;
/**
* 根据请求头中携带的请求语言内容,生成会话,解析内容
* @author EDY
*/
public class MessageLocaleResolver implements LocaleResolver {
@Value("${export.language}")
private String exportTwLanguage;
/*private static final String I18N_LANGUAGE = "i18n_language";
private static final String I18N_LANGUAGE_SESSION = "i18n_language_session";*/
private Logger logger = LoggerFactory.getLogger(MessageLocaleResolver.class);
@Override
public Locale resolveLocale(HttpServletRequest request) {
Locale locale;
// String language = request.getParameter("I18N_LANGUAGE");
if (StringUtils.isNotEmpty(exportTwLanguage)) {
//获取知道配置文件中的语言为: exportTwLanguage;
locale = new Locale(exportTwLanguage);
/*//将国际化语言保存到session
HttpSession session = req.getSession();
session.setAttribute(I18N_LANGUAGE_SESSION, locale);*/
} else {
//如果没有带国际化参数,则判断session有没有保存,有保存,则使用保存的,也就是之前设置的,避免之后的请求不带国际化参数造成语言显示不对
/*HttpSession session = req.getSession();
Locale localeInSession = (Locale) session.getAttribute(I18N_LANGUAGE_SESSION);*/
//读取不到指定语言文件,采用默认中文。即默认的message.properties
locale = Locale.getDefault();
}
return locale;
}
@Override
public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
}
}
package com.fedex.connect.common.dependencies.util;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import java.nio.charset.StandardCharsets;
/**
* 类型转换
*/
public class BytesUtils {
/**
* 获取字符串UTF-8的字节数
* @param str
* @return
*/
public static int getStrUTF8ByteLength(String str){
if (StringUtils.isBlank(str)){
return 0;
}
return str.getBytes(StandardCharsets.UTF_8).length;
}
/**
* 字符串转换成十六进制字符串
*/
public static String str2HexStr(String str) {
char[] chars = "0123456789ABCDEF".toCharArray();
StringBuilder sb = new StringBuilder("");
byte[] bs = str.getBytes();
int bit;
for (int i = 0; i < bs.length; i++) {
bit = (bs[i] & 0x0f0) >> 4;
sb.append(chars[bit]);
bit = bs[i] & 0x0f;
sb.append(chars[bit]);
}
return sb.toString();
}
/**
* 十六进制字符串转换为 byte[]
*
* @param hexString the hex string
* @return byte[]
*/
public static byte[] hexStringToBytes(String hexString) {
if (hexString == null || hexString.equals("")) {
return null;
}
hexString = hexString.toUpperCase();
int length = hexString.length() / 2;
char[] hexChars = hexString.toCharArray();
byte[] d = new byte[length];
for (int i = 0; i < length; i++) {
int pos = i * 2;
d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
}
return d;
}
/**
* char to byte
*
* @param c char
* @return byte
*/
private static byte charToByte(char c) {
return (byte) "0123456789ABCDEF".indexOf(c);
}
/**
* 数组转换成十六进制字符串
*
* @param bArray byte[]
* @return HexString
*/
public static final String bytesToHexString(byte[] bArray) {
if (bArray == null || bArray.length == 0) {
return null;
}
StringBuffer sb = new StringBuffer(bArray.length);
String sTemp;
for (int i = 0; i < bArray.length; i++) {
sTemp = Integer.toHexString(0xFF & bArray[i]);
if (sTemp.length() < 2) {
sb.append(0);
}
sb.append(sTemp.toUpperCase());
}
return sb.toString();
}
/**
* 十六进制字符串转换成字符串
*
* @param hexStr
* @return String
*/
public static String hexStr2Str(String hexStr) {
String str = "0123456789ABCDEF";
char[] hexs = hexStr.toCharArray();
byte[] bytes = new byte[hexStr.length() / 2];
int n;
for (int i = 0; i < bytes.length; i++) {
n = str.indexOf(hexs[2 * i]) * 16;
n += str.indexOf(hexs[2 * i + 1]);
bytes[i] = (byte) (n & 0xff);
}
return new String(bytes);
}
/**
* @param hexString String str = "000AB"
* @return
*/
public static int hexString2Int(String hexString) {
Integer num = Integer.valueOf(hexString, 16);
return num;
}
/**
* 把byte转为字符串的bit
*/
public static String byteToBitString(byte b) {
return ""
+ (byte) ((b >> 7) & 0x1) + (byte) ((b >> 6) & 0x1)
+ (byte) ((b >> 5) & 0x1) + (byte) ((b >> 4) & 0x1)
+ (byte) ((b >> 3) & 0x1) + (byte) ((b >> 2) & 0x1)
+ (byte) ((b >> 1) & 0x1) + (byte) ((b >> 0) & 0x1);
}
/**
* 把byte转为字符串数组的bit
*/
public static String[] byteToBitStrings(byte b) {
String[] bit = new String[8];
bit[0] = "" + (byte) ((b >> 7) & 0x1);
bit[1] = "" + (byte) ((b >> 6) & 0x1);
bit[2] = "" + (byte) ((b >> 5) & 0x1);
bit[3] = "" + (byte) ((b >> 4) & 0x1);
bit[4] = "" + (byte) ((b >> 3) & 0x1);
bit[5] = "" + (byte) ((b >> 2) & 0x1);
bit[6] = "" + (byte) ((b >> 1) & 0x1);
bit[7] = "" + (byte) ((b >> 0) & 0x1);
return bit;
}
//base64字符串转byte[]
public static byte[] base64String2ByteFun(String base64Str) {
return Base64.decodeBase64(base64Str);
}
//byte[]转base64
public static String byte2Base64StringFun(byte[] b) {
return Base64.encodeBase64String(b);
}
public static void main(String[] args) {
String hexString = "3A60432A5C01211F291E0F4E0C132825";
byte[] result = hexStringToBytes(hexString);
System.out.println(new String(result));
System.out.println(bytesToHexString(result));
}
}
package com.fedex.connect.common.dependencies.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
public class DateUtil {
private static final Logger logger = LoggerFactory.getLogger(DateUtil.class);
public static final String SIMPLE_PATTERN = "yyMMdd";
public static final String PATTERN_DATE = "yyyy-MM-dd";
public static final String PATTERN_DATE_TIME = "yyyy-MM-dd HH:mm:ss";
public static final String PATTERN_DATE_TIME_ORACLE = "yyyy-MM-dd hh:mi:ss";
public static final String PATTERN_DATE_TIME_MS = "yyyy-mm-dd hh24:mi:ss";
private static SimpleDateFormat dateFormat = new SimpleDateFormat();
/**
* 用默认格式格式化日期
*
* @param date
* @return
*/
public static String format(Date date) {
dateFormat.applyPattern(PATTERN_DATE);
return dateFormat.format(date);
}
public static String simpleFormat(Date date) {
dateFormat.applyPattern(SIMPLE_PATTERN);
return dateFormat.format(date);
}
public static String timeFormat(Date date) {
dateFormat.applyPattern(PATTERN_DATE_TIME);
return dateFormat.format(date);
}
/**
* 用指定格式格式化日期
*
* @param date
* @param pattern
* @return
*/
public static String format(Date date, String pattern) {
dateFormat.applyPattern(pattern);
return dateFormat.format(date);
}
/**
* Format a Time object to a String. Now use the Medium format of Locale
* CHINA. The format is YYYYMMDDHHmmss
*/
public static String formatTimeWithoutSlash(Date date) {
dateFormat.applyPattern("yyyyMMddHHmmss");
return dateFormat.format(date);
}
public static String formatTimeWithoutSecond(Date date) {
dateFormat.applyPattern("yyyy-MM-dd HH:mm");
return dateFormat.format(date);
}
/**
* 判断字符串是否为日期。
* @param str
* @param format
* @return
*/
public static boolean isDate(String str, String format) {
SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA);
if (str == null) {
return false;
}
try {
Date d = sdf.parse(str);
String s = sdf.format(d);
return str.equals(s);
} catch (ParseException e) {
return false;
}
}
/**
* 用默认格式解析日期
*
* @param str
* @return 解析出错时返回null
*/
public static Date parse(String str) {
Date date = null;
dateFormat.applyPattern(PATTERN_DATE);
dateFormat.setLenient(false);// 精确匹配,不支持2014-13-33
try {
date = dateFormat.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
* 用指定格式解析日期
*
* @param str
* @param pattern
* @return 解析出错时返回null
*/
public static Date parse(String str, String pattern) {
Date date = null;
dateFormat.applyPattern(pattern);
dateFormat.setLenient(false);// 精确匹配,不支持2014-13-33
try {
date = dateFormat.parse(str);
} catch (ParseException e) {
e.printStackTrace();
return null;
}
return date;
}
public static void main(String[] args){
String prematchFltDate = "2019-06-11 15:52:52";
prematchFltDate = prematchFltDate.length()>10 ? prematchFltDate.substring(10): prematchFltDate;
logger.info(prematchFltDate);
}
/**
* 用指定格式格式化日期
*
* @param date
* @param pattern
* @param locale
* @return
*/
public static String format(Date date, String pattern,Locale locale) {
dateFormat = new SimpleDateFormat(pattern,locale);
return dateFormat.format(date);
}
/**
* 取得两个日期之间的天数
*
* @param fDate
* @param tDate
* @return
*/
public static int getIntervalDays(Date fDate, Date tDate) {
fDate = roundDate(fDate);
tDate = roundDate(tDate);
long intervalMilli = tDate.getTime() - fDate.getTime();
return (int) (intervalMilli / (24 * 60 * 60 * 1000));
}
/**
* 取得两个时间之间的分钟数
*
* @param fDate
* @param tDate
* @return
*/
public static int getIntervalMinutes(Date fDate, Date tDate) {
BigDecimal interval = new BigDecimal(tDate.getTime() - fDate.getTime());
BigDecimal pmin = new BigDecimal(60 * 1000);
BigDecimal min = interval.divide(pmin, 2, BigDecimal.ROUND_HALF_UP);
return (new BigDecimal(Math.ceil(min.doubleValue()))).intValue();
}
/**
* 将日期时、分、秒清零
*
* @param d
* @return
*/
public static Date roundDate(Date d) {
Calendar c = Calendar.getInstance();
c.setTime(d);
return roundCalendar(c).getTime();
}
/**
* 将日历时、分、秒清零
*
* @param c
* @return
*/
public static Calendar roundCalendar(Calendar c) {
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
return c;
}
/**
* 计算两个日期之间的时间间隔
*
* @param startDate 起始时间
* @param endDate 截止时间
* @param flag 1:月;3:季度;6:半年
* @return
*/
public static int distanceForTwoDate(Date startDate, Date endDate, int flag) {
if (startDate.after(endDate)) {
return -1;
}
int distance = 0;
Calendar startCal = Calendar.getInstance();
startCal.setTime(startDate);
Calendar endCal = Calendar.getInstance();
endCal.setTime(endDate);
int startYear = startCal.get(Calendar.YEAR);
int startMonth = startCal.get(Calendar.MONTH) + 1;
int endYear = endCal.get(Calendar.YEAR);
int endMonth = endCal.get(Calendar.MONTH) + 1;
if (endYear - startYear == 0) {
distance = (endMonth - 1) / flag - (startMonth - 1) / flag + 1;
} else if (endYear - startYear > 0) {
distance = 11 / flag - (startMonth - 1) / flag + 1;
while (endYear - startYear > 1) {
distance += 12 / flag;
endYear--;
}
distance += (endMonth - 1) / flag + 1;
}
return distance;
}
/**
* 获取日期对应的年
*
* @param date
* @return
*/
public static int getYear(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal.get(Calendar.YEAR);
}
/**
* 获取车龄货这驾龄 前十年所有的年份
*
* @return
*/
public static List<Integer> getCarYearList() {
List<Integer> carYearList = new ArrayList<Integer>();
int currentYear = getYear(new Date());
for (int i = currentYear - 9; i <= currentYear; i++) {
carYearList.add(i);
}
return carYearList;
}
/**
* 获取日期对应的月
*
* @param date
* @return
*/
public static int getMonth(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal.get(Calendar.MONTH) + 1;
}
/**
* 获取日期对应的日
*
* @param date
* @return
*/
public static int getDate(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal.get(Calendar.DATE);
}
/**
* 将日期增加若干天
*
* @param date 日期
* @param dayNum 天数
* @return
*/
public static Date addDays(Date date, int dayNum) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DATE, dayNum);
return c.getTime();
}
/**
* String类型日期 加减若干天 返回String日期 先将String日期转换Date日期 再调用addDays方法将日期增加或减若干天
* 最后转换String日期结果
*
* @param date String类型日期
* @param dayNum 天数
* @return
*/
public static String addDays(String date, int dayNum) {
return format(addDays(parse(date), dayNum));
}
/**
* 取得本月的月初日期
*
* @param date
* @return
*/
public static Date getMonthStartDate(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.DAY_OF_MONTH, c.getActualMinimum(Calendar.DAY_OF_MONTH));
return c.getTime();
}
/**
* 取得本月的月末日期
*
* @param date
* @return
*/
public static Date getMonthEndDate(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
return c.getTime();
}
/**
* 根据传入的年份和月份获得这个月的最大天数
*
* @param year
* @param month
* @return
*/
public static int getMaxDaybyYearAndMonth(int year, int month) {
int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if (2 == month && 0 == (year % 4)
&& (0 != (year % 100) || 0 == (year % 400))) {
days[1] = 29;
}
return (days[month - 1]);
}
/**
* 根据输入的数字月份返回对应的英文月份
*
* @param str 输入的数字月份
* @return
*/
public static String formatMonth(String str) {
SimpleDateFormat sdf = new SimpleDateFormat("MM");
Date date = null;
try {
date = sdf.parse(str);
} catch (ParseException e) {
e.printStackTrace();
return null;
}
sdf = new SimpleDateFormat("MMMMM", Locale.US);
return sdf.format(date);
}
/**
* 根据输入的数字月份返回对应的英文月份
*
* @param month 输入的数字月份
* @return
*/
public static String formatMonth(Integer month) {
if (month == null) {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat("MM");
Date date = null;
try {
date = sdf.parse(String.valueOf(month));
} catch (ParseException e) {
e.printStackTrace();
return null;
}
sdf = new SimpleDateFormat("MMMMM", Locale.US);
return sdf.format(date);
}
/**
* 获取月份对应第几季度
*
* @param month
* @return
*/
private static Integer getQuarterByMonth(Integer month) {
Integer quarter = 1;
switch (month) {
case 1:
case 2:
case 3:
quarter = 1;
break;
case 4:
case 5:
case 6:
quarter = 2;
break;
case 7:
case 8:
case 9:
quarter = 3;
break;
case 10:
case 11:
case 12:
quarter = 4;
break;
default:
}
return quarter;
}
/**
* 获取两个月份之间的月份集合 不允许跨年
*
* @param startMonth
* @param endMonth
* @return
*/
private static List<Integer> getMonthList(Integer startMonth, Integer endMonth) {
List<Integer> monthList = new ArrayList<>();
if (endMonth == null || startMonth == null || endMonth > 12 || endMonth < 1 ||
startMonth > 12 || startMonth < 1 || endMonth < startMonth) {
return monthList;
}
for (int i = startMonth; i <= endMonth; i++) {
monthList.add(i);
}
return monthList;
}
/**
* 获取两个月份之间对应的季度集合
*
* @param startMonth
* @param endMonth
* @return
*/
public static Set<Integer> getQuarterByMonth(Integer startMonth, Integer endMonth) {
Set<Integer> set = new HashSet<>();
List<Integer> monthList = getMonthList(startMonth, endMonth);
for (Integer month : monthList) {
set.add(getQuarterByMonth(month));
}
return set;
}
/**
* 根据季度获取本季度的第一天
*
* @param quarter
* @return Format 01-01
*/
public static String getDateByQuarter(Integer quarter) {
String result = "";
switch (quarter) {
case 1:
result = "01-01 00:00:00";
break;
case 2:
result = "04-01 00:00:00";
break;
case 3:
result = "07-01 00:00:00";
break;
case 4:
result = "12-01 00:00:00";
break;
default:
break;
}
return result;
}
/**
* 根据开始和结束日期返回年月日的时间间隔
* @param startDate
* @param endDate
* @return
*/
public static String getTimeInterval(Date startDate ,Date endDate){
String timeInterval="";
Instant startInstant = startDate.toInstant();
Instant endInstant = endDate.toInstant();
ZoneId zoneId = ZoneId.systemDefault();
// atZone()方法返回在指定时区从此Instant生成的ZonedDateTime。
LocalDate localDateS = startInstant.atZone(zoneId).toLocalDate();
LocalDate localDateE = endInstant.atZone(zoneId).toLocalDate();
Period p = Period.between(localDateS, localDateE);
timeInterval=p.getYears()+"年"+p.getMonths()+"月"+p.getDays()+"天";
return timeInterval;
}
/**
* 获取目标日期 加减年月日的日期
* @param date
* @param year
* @param month
* @param day
* @return
*/
public static Date getDateByAddYmd(Date date,Integer year,Integer month,Integer day) {
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(date);
rightNow.add(Calendar.YEAR,year);//日期加year年
rightNow.add(Calendar.MONTH,month);//日期加month月
rightNow.add(Calendar.DAY_OF_YEAR,day);//日期加day天
return rightNow.getTime();
}
/**
* 获取当前日期是星期几<br>
*
* @param dt
* @return 当前日期是星期几
*/
public static String getWeekOfDate(Date dt) throws Exception{
String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (w < 0){
w = 0;
}
return weekDays[w];
}
public static String getDayOfWeek(Date dt) throws Exception{
String[] weekDays = {"day7","day1", "day2", "day3", "day4", "day5", "day6"};
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
int w = cal.get(Calendar.DAY_OF_WEEK)-1;
if (w < 0){
w = 0;
}
return weekDays[w];
}
public static Date getToday() {
Calendar curDate = Calendar.getInstance();
curDate.set(11, 0);
curDate.set(12, 0);
curDate.set(13, 0);
curDate.set(14, 0);
return curDate.getTime();
}
/**
* 获取两个日期之间的日期
*
* @param start 开始日期
* @param end 结束日期
* @return 日期集合
*/
public static List<Date> getDateList(Date start, Date end) {
List<Date> result = new ArrayList<>();
result.add(start);
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start);
tempStart.add(Calendar.DAY_OF_YEAR, 1);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
while (tempStart.before(tempEnd)) {
result.add(tempStart.getTime());
tempStart.add(Calendar.DAY_OF_YEAR, 1);
}
if (start.getTime() != end.getTime()) {
result.add(end);
}
return result;
}
public static List<String> getStrDateList(String start,String end){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<Date> dateList= DateUtil.getDateList(DateUtil.parse(start),DateUtil.parse(end));
if(dateList!=null && !dateList.isEmpty()){
return dateList.stream().map(simpleDateFormat::format).collect(Collectors.toList());
}
return new ArrayList<>();
}
public static String getYesterDay(){
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
String yesterday = new SimpleDateFormat( "yyyy-MM-dd ").format(cal.getTime());
return yesterday;
}
/**
* 获取当前时间的后几个小时
*/
public static Date getHoursAgoTime(int i) {
//获取当前时间
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
// 几个小时之前
calendar.add(Calendar.HOUR, i);
//获取到完整的时间
return calendar.getTime();
}
}
package com.fedex.connect.common.dependencies.util;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class GsonUtils {
private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
public static String toJsonString(Object object) {
return object == null ? null : gson.toJson(object);
}
/**
* 转成json
*/
public static String beanToString(Object object) {
String gsonString = null;
if (gson != null) {
gsonString = gson.toJson(object);
}
return gsonString;
}
/**
* 转成bean
*/
public static <T> T stringToBean(String gsonString, Class<T> cls) {
T t = null;
if (gson != null) {
t = gson.fromJson(gsonString, cls);
}
return t;
}
/**
* 转成list
*/
public static <T> List<T> stringToList(String gsonString, Class<T> cls) {
List<T> list = new ArrayList<>();
if (gson != null) {
JsonArray array = new JsonParser().parse(gsonString).getAsJsonArray();
for (final JsonElement elem : array) {
list.add(gson.fromJson(elem, cls));
}
}
return list;
}
/**
* 转成list, 有可能造成类型擦除
*/
public static <T> ArrayList<T> stringToList(String gsonString) {
ArrayList<T> list = null;
if (gson != null) {
list = gson.fromJson(gsonString, new TypeToken<ArrayList<T>>() {
}.getType());
}
return list;
}
/**
* 转成map的
*/
public static <T> Map<String, T> stringToMaps(String gsonString, Class<T> cls) {
Map<String, T> map = null;
if (gson != null) {
map = gson.fromJson(gsonString, new TypeToken<Map<String, T>>() {
}.getType());
}
return map;
}
}
package com.fedex.connect.common.dependencies.util;
import com.fedex.connect.common.dependencies.authentication.SecurityConstants;
import com.fedex.connect.common.dependencies.contants.RedisConstants;
import com.fedex.export.data.dto.SecurityUserDetails;
import com.fedex.export.repository.dao.SysUserMapperExt;
import com.fedex.export.repository.entity.SysUser;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.security.Keys;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import javax.crypto.SecretKey;
import javax.xml.bind.DatatypeConverter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author Administrator
*/
public class JwtTokenUtils {
private static final SysUserMapperExt sysUserMapper = com.fedex.export.common.util.SpringBeanUtil.getBean(SysUserMapperExt.class);
/**
* 生成足够的安全随机密钥,以适合符合规范的签名
*/
private static final byte[] API_KEY_SECRET_BYTES = DatatypeConverter.parseBase64Binary(SecurityConstants.getSecuritykey());
private static final SecretKey SECRET_KEY = Keys.hmacShaKeyFor(API_KEY_SECRET_BYTES);
public static String createAccessToken(String username, String id, List<String> roles, boolean isRememberMe) {
long expiration = isRememberMe ? SecurityConstants.getExpire_1D() : RedisConstants.REDIS_EXPIRE_TIME_8H;
final Date createdDate = new Date();
final Date expirationDate = new Date(createdDate.getTime() + expiration * 1000);
String tokenPrefix = Jwts.builder()
.setHeaderParam("type", SecurityConstants.TOKEN_TYPE)
.signWith(SECRET_KEY, SignatureAlgorithm.HS256)
.claim(SecurityConstants.ROLE_CLAIMS, String.join(",", roles))
.setId(id)
.setIssuer("EXPORT_TW") //证书发行者
.setIssuedAt(createdDate)
.setSubject(username)
.setExpiration(expirationDate)
.compact();
return SecurityConstants.TOKEN_PREFIX + tokenPrefix;
}
public static String createReflushToken(String username, String id, List<String> roles) {
//默认保留1小时
long expiration = 3600L;
Date createdDate = new Date();
Date expirationDate = new Date(createdDate.getTime() + expiration * 1000);
String tokenPrefix = Jwts.builder()
.setHeaderParam("type", SecurityConstants.TOKEN_TYPE)
.signWith(SECRET_KEY, SignatureAlgorithm.HS256)
.claim(SecurityConstants.ROLE_CLAIMS, String.join(",", roles))
.setId(id)
.setIssuer("EXPORT_TW")
.setIssuedAt(createdDate)
.setSubject(username)
.setExpiration(expirationDate)
.compact();
return SecurityConstants.TOKEN_PREFIX + tokenPrefix;
}
/**
* 从token中获取用户id
* @param token
* @return
*/
public static String getId(String token) {
Claims claims = getClaims(token);
return claims.getId();
}
/**
* 从token中获取用户id
* @param token
* @return
*/
public static String getUserName(String token) {
Claims claims = getClaims(token);
return claims.getSubject();
}
/**
* 获取token的过期时间
* @param token
* @return
*/
public static Date getAccessTokenExpiredTime(String token){
Claims claims = getClaims(token);
return claims.getExpiration();
}
/**
* 从token中获取权限
* @param token
* @return
*/
public static UsernamePasswordAuthenticationToken getAuthentication(String token) {
Claims claims = getClaims(token);
List<SimpleGrantedAuthority> authorities = getAuthorities(claims);
String userName = claims.getSubject();
String id = claims.getId();
SecurityUserDetails userDetails = new SecurityUserDetails();
userDetails.setId(Long.parseLong(id));
userDetails.setUsername(userName);
SysUser user = sysUserMapper.findOne(Long.parseLong(id));
userDetails.setUser(user);
return new UsernamePasswordAuthenticationToken(userDetails, token, authorities);
}
private static List<SimpleGrantedAuthority> getAuthorities(Claims claims) {
String role = (String) claims.get(SecurityConstants.ROLE_CLAIMS);
if (!"".equals(role)) {
return Arrays.stream(role.split(","))
.map(SimpleGrantedAuthority::new)
.collect(Collectors.toList());
}else {
return new ArrayList<>();
}
}
private static Claims getClaims(String token) {
return Jwts.parser()
.setSigningKey(SECRET_KEY)
.parseClaimsJws(token)
.getBody();
}
public static List<String> getRoleList(String token){
Claims claims = getClaims(token);
String roleStr = (String) claims.get(SecurityConstants.ROLE_CLAIMS);
return Arrays.asList(roleStr.split(","));
}
}
package com.fedex.connect.common.dependencies.util;
import org.apache.commons.lang3.StringUtils;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* String扩展工具类。
* 在long3的中StringUtil无法满足要求情况下,添加
*/
public class StringExtUtil {
/**
* 正则表达式:验证邮箱
*/
private static final String REGEX_EMAIL = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
/**
* 正则表达式:验证数字
*/
private static final String REGEX_NUBMER = "\\d+\\.\\d+$|-\\d+\\.\\d+$";
/**
* 正则表达式:验证联络电话
*/
private static final String REGEX_TEL = "[\\u4e00-\\u9fa5a-zA-Z、;‘’]";
/**
* 正则表达式:验证联络人 中文英文空格
*/
private static final String REGEX_EN_CHN_SPA = "[\\u4E00-\\u9FA5a-zA-Z\\s]+";
/**
* 正则表达式:验证英文大写和数字
*/
private static final String REGEX_CAPITAL_NUMBER = "[A-Z0-9]+";
/**
* 正则表达式:验证英文和数字和空格
*/
private static final String REGEX_CAPITAL_NUMBER_SPACE = "[a-zA-Z0-9\\s]+";
/**
* 正则表达式:验证英文和数字和空格和中文
*/
private static final String REGEX_SPECIAL_SYMBOLS = "[、;‘’]";
/**
* 正则表达式:中文
*/
private static final String REGEX_CHINESE = "[\\u4E00-\\u9FA5,。、!?《》¥——;‘’:“”【】]+";
/**
* 正则表达式:非中文
*/
private static final String REGEX_NON_CHINESE = "[^\\u4E00-\\u9FA5,。、!?《》¥——;‘’:“”【】]+";
public static boolean validateSpecialSymbols(String s) {
Pattern pattern = Pattern.compile(REGEX_SPECIAL_SYMBOLS);
Matcher matcher = pattern.matcher(s);
return !matcher.find();
}
public static boolean validateCapAndNoAndSpace(String s) {
return Pattern.matches(REGEX_CAPITAL_NUMBER_SPACE, s);
}
public static boolean validateCapitalAndNumber(String s) {
return Pattern.matches(REGEX_CAPITAL_NUMBER, s);
}
public static boolean validateLEnAndChnAndSpa(String s) {
return Pattern.matches(REGEX_EN_CHN_SPA, s);
}
public static boolean validateTel(String s) {
Pattern pattern = Pattern.compile(REGEX_TEL);
Matcher matcher = pattern.matcher(s);
return !matcher.find();
}
/**
* 把一个字符串提取成一个中文字符串和非中文字符串
* @param s String
* @return String[] 0:中文;1:非中文
*/
public static String[] extractString(String s) {
Pattern patternChinese = Pattern.compile(REGEX_CHINESE);
Pattern patternNonChinese = Pattern.compile(REGEX_NON_CHINESE);
Matcher matcherChinese = patternChinese.matcher(s);
Matcher matcherNonChinese = patternNonChinese.matcher(s);
StringBuilder chineseStringBuilder = new StringBuilder();
while (matcherChinese.find()) {
chineseStringBuilder.append(matcherChinese.group());
}
String chineseString = chineseStringBuilder.toString();
StringBuilder nonChineseStringBuilder = new StringBuilder();
while (matcherNonChinese.find()) {
nonChineseStringBuilder.append(matcherNonChinese.group());
}
String nonChineseString = nonChineseStringBuilder.toString();
return new String[]{chineseString, nonChineseString};
}
/**
* 多数组合并
* @param first
* @param rest
* @param <T>
* @return
*/
public static <T> T[] concatAll(T[] first, T[]... rest) {
int totalLength = first.length;
for (T[] array : rest) {
totalLength += array.length;
}
T[] result = Arrays.copyOf(first, totalLength);
int offset = first.length;
for (T[] array : rest) {
System.arraycopy(array, 0, result, offset, array.length);
offset += array.length;
}
return result;
}
/**
* 字符串按照指定分割后去重,然后重新拼接
* @param str
* @param splitChar
* @return
*/
public static String isRepetitionCheck(String str,String splitChar) {
return Arrays.stream(str.split(splitChar)).distinct().collect(Collectors.joining(splitChar));
}
/**
* 将字符串中的小写改成大写
*
* @param str 字符串
* @return
*/
public static String isCapitalAndSmall(String str) {
str = str.toUpperCase();
return str;
}
/**
* 将字符串中的空格去除
*
* @param str
* @return
*/
public static String isBlankCheck(String str) {
str = str.replace(" ", "");
return str;
}
/**
* 是:将回车符转换成英文分号; 不是:返回null
* \r:回车符
* \n:换行符
*/
public static String isCarriageChar(String str) {
char zh = '\r';
int w = str.indexOf(zh);
if (w != -1) {
str = str.replace("\r", ";");
}
char ch = '\n';
int c = str.indexOf(ch);
if (c != -1) {
str = str.replace("\n", ";");
}
//中间不能为空
return str;
}
/**
* 字符串四重处理。依次是:1:转大写 2:去除空格 3:将回车符转换成英文分号; 4:字符串;去重
* @param str
* @return
*/
public static String stringQuadrupleConduct(String str){
str = isCapitalAndSmall(str);
str = isBlankCheck(str);
str = isCarriageChar(str);
str = isRepetitionCheck(str,";");
return str;
}
/**
* 将首字母大写
*
* @param str
* @return
*/
public static String upcaseFirstLetter(String str) {
if (str == null) {
return null;
}
String firstChar = str.substring(0, 1);
return firstChar.toUpperCase() + str.substring(1, str.length());
}
/**
* 判断字符串是否为半角英文或数字
*
* @param str
* @return
*/
public static boolean isAllHalfWidth(String str) {
char[] chars = str.toCharArray();
for (int i = 0; i < chars.length; i++) {
int ascii = chars[i];
if ((ascii >= 48 && ascii <= 57) //0-9
|| (ascii >= 65 && ascii <= 90) //A-Z
|| (ascii >= 97 && ascii <= 122)) { //a-z
} else {
return false;
}
}
return true;
}
public static String toString(String str) {
return str == null ? "" : str;
}
public static String toString(Object obj) {
return obj == null ? "" : obj.toString();
}
/**
* 将字符串数组按指定分隔符转为字符串
*
* @param arr
* @param seperator
* @return
*/
public static String convertArrayToString(String[] arr, String seperator) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < arr.length; i++) {
sb.append(seperator + arr[i]);
}
if (sb.length() > 0) {
sb.deleteCharAt(0);
}
return sb.toString();
}
/**
* 获取字符串被特定字符分割后的最后一个元素
*/
public static String getLastSperator(String str, String sperator) {
String[] ss = StringUtils.split(str, sperator);
return ss[ss.length - 1];
}
/**
* 截取字符串中以除某个字符串结尾的所有字符
*/
public static String cutSperatorLast(String s, String sperator) {
if (s == null || s.length() == 0) {
return s;
}
if (s.substring(s.length() - sperator.length()).equals(sperator)) {
return cutSperatorLast(s.substring(0, s.length() - 1), sperator);
}
return s;
}
public static String toUtf8String(String s) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c >= 0 && c <= 255) {
sb.append(c);
} else {
byte[] b;
try {
b = Character.toString(c).getBytes("utf-8");
} catch (Exception ex) {
ex.printStackTrace();
b = new byte[0];
}
for (int j = 0; j < b.length; j++) {
int k = b[j];
if (k < 0) {
k += 256;
}
sb.append("%" + Integer.toHexString(k).toUpperCase());
}
}
}
return sb.toString();
}
/**
* 把Json字符串中属性值为空字符串的值替换成null
* 例如:"bespeakTakeTime": "", 替换成 "bespeakTakeTime": null,
*
* @param sourceString
* @param properties
* @return
*/
public static String replaceByProperties(String sourceString, String properties) {
String targetString = "";
String[] stringArray = properties.split(",");
for (int i = 0; i < stringArray.length; i++) {
String s = stringArray[i];
String sourceSubStr = "\"" + s + "\":\"\",";
String targetSubStr = "\"" + s + "\": null,";
targetString = sourceString.replace(sourceSubStr, targetSubStr);
}
return targetString;
}
/**
* 把String List转成逗号分隔的String
*
* @param stringList
* @return
*/
public static String listToString(List<String> stringList) {
if (stringList == null) {
return null;
}
StringBuilder result = new StringBuilder();
boolean flag = false;
for (String string : stringList) {
if (flag) {
result.append(",");
} else {
flag = true;
}
result.append(string);
}
return result.toString();
}
/**
* 校验邮箱
*
* @param email
* @return 校验通过返回true,否则返回false
*/
public static boolean isEmail(String email) {
return Pattern.matches(REGEX_EMAIL, email);
}
/**
* 校验邮箱
*
* @param emailMulti
* @return 逗号分隔的多个邮件地址都校验通过返回true,否则返回false
*/
public static boolean isEmailMulti(String emailMulti) {
String[] emailAttr = emailMulti.split(",");
boolean isEmail = true;
for (String email : emailAttr) {
if (!isEmail(email)) {
isEmail = false;
}
}
return isEmail;
}
/**
* List<Long> 转String 用于sql
*
* @param lists
* @return
*/
public static String listLongToStr(List<Long> lists) {
StringBuffer str = new StringBuffer("");
for (Long value : lists) {
str.append(value).append(",");
}
return str.toString().substring(0, str.toString().lastIndexOf(","));
}
/**
* List<Integer> 转String 用于sql
*
* @param lists
* @return
*/
public String listIntegerToStr(List<Integer> lists) {
StringBuffer str = new StringBuffer("");
for (Integer value : lists) {
str.append(value).append(",");
}
return str.toString().substring(0, str.toString().lastIndexOf(","));
}
/**
* List<String> 转String 用于sql
*
* @param lists
* @return
*/
public String listStringToStr(List<String> lists) {
StringBuffer srt = new StringBuffer("");
for (String value : lists) {
srt.append("'").append(value).append("'").append(",");
}
return srt.toString().substring(0, srt.toString().lastIndexOf(","));
}
/**
* 字符串分割,并去除""
*
* @param str
* @param regex
* @return
*/
public static String[] splitForList(String str, String regex) {
ArrayList resultStr = new ArrayList();
if (!StringUtils.isBlank(str)) {
String[] strs = str.split(regex);
for (String s : strs) {
if (!StringUtils.isBlank(s)) {
resultStr.add(s.trim());
}
}
}
return (String[]) resultStr.toArray(new String[resultStr.size()]);
}
/**
* 字符串分割,并去除""
*
* @param str
* @param regex
* @return
*/
public static String[] splitForList1(String str, String regex) {
ArrayList resultStr = new ArrayList();
if (!StringUtils.isBlank(str)) {
String[] strs = str.split(regex);
for (String s : strs) {
if (!StringUtils.isBlank(s)) {
resultStr.add(s.trim());
}
}
} else {
resultStr.add("");
}
return (String[]) resultStr.toArray(new String[resultStr.size()]);
}
public static String getUUID(){
String uuid = UUID.randomUUID().toString();
//去掉“-”符号
return uuid.replaceAll("-", "");
}
public static String emailSuffixDispose(String email){
if (email == null || email.length() == 0){
return email;
}
int index = email.indexOf("@");
if (index > 0){
String prefix = email.substring(0, index);
String suffix = email.substring(index + 1).toLowerCase();
return prefix + "@" + suffix;
} else {
return email;
}
}
/**
* 将ID转指定位数的字符串,位数不足前面补0
* @param val ID值
* @return
*/
public static String idLeftPadStr(Long val){
if (val == null){
return null;
}
if (val == 0){
return "0";
}
String valStr = val.toString();
int len = valStr.length();
if (valStr.length() <= 10){
return StringUtils.leftPad(valStr,10,"0");
} else {
return valStr;
}
}
/**
* 将用0补足的字符串转回ID
* @param val
* @return
*/
public static Long idLeftPadLong(String val){
if (StringUtils.isBlank(val)){
return 0L;
}
Long valLong = Long.valueOf(val.trim());
return valLong;
}
public static List<String> splitByLength(String str, int length) {
List<String> result = new ArrayList<>();
for (int i = 0; i < str.length(); i += length) {
if (i + length <= str.length()) {
String subStr = str.substring(i, i + length);
result.add(subStr);
} else {
String remainingSubStr = str.substring(i);
result.add(remainingSubStr);
}
}
return result;
}
public static String formatWithCommas(String s) {
try {
if (StringUtils.isBlank(s)) {
return null;
}
double number = Double.parseDouble(s);
DecimalFormat decimalFormat = new DecimalFormat("#,###.##");
return decimalFormat.format(number);
} catch (NumberFormatException e) {
return null;
}
}
}
package com.fedex.connect.common.dependencies.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.GZIPOutputStream;
public class Utils {
/**
* 是否在
*/
@SafeVarargs
public static <T> boolean in(T t, T... set) {
return Arrays.asList(set).contains(t);
}
/**
* 是否在
*/
public static <T> boolean in(T t, List<T> list) {
return list.contains(t);
}
/**
* 对象转数组
*/
@SafeVarargs
public static <T> T[] array(T... e) {
return e;
}
/**
* 初始化set/防止NULL异常
*/
public static <T> Set<T> setOf(Set<T> set) {
return (Set)(set != null ? set : new HashSet());
}
/**
* 初始化list/防止NULL异常
*/
public static <T> List<T> listOf(List<T> list) {
return (List)(list != null ? list : new ArrayList());
}
/**
* 追加
*/
@SafeVarargs
public static <T> ArrayList<T> listOf(T t, T... ts) {
ArrayList<T> list = new ArrayList();
list.add(t);
if (ts.length > 0) {
list.addAll(Arrays.asList(ts));
}
return list;
}
/**
* 初始化Map
*/
public static <K, V> HashMap<K, V> mapOf(K k, V v) {
HashMap<K, V> map = new HashMap();
map.put(k, v);
return map;
}
/**
* 初始化Collection
*/
public static <T> Collection<T> collectionOf(Collection<T> collection) {
return (Collection)(collection != null ? collection : new ArrayList());
}
/**
* 追加
*/
@SafeVarargs
public static <T> List<T> append(List<T> list, T... ts) {
List<T> ret = listOf(list);
ret.addAll(Arrays.asList(ts));
return ret;
}
/**
* 合并
*/
public static <T> ArrayList<T> concat(List<T> list1, List<T>... lists) {
ArrayList<T> list = new ArrayList();
if (list1 != null) {
list.addAll(list1);
}
List[] var3 = lists;
int var4 = lists.length;
for(int var5 = 0; var5 < var4; ++var5) {
List<T> list2 = var3[var5];
if (list2 != null) {
list.addAll(list2);
}
}
return list;
}
/**
* 截取
*/
public static <T> List<T> subList(List<T> list, int fromIndex) {
return subList(list, fromIndex, list.size());
}
/**
* 截取
*/
public static <T> List<T> subList(List<T> list, int fromIndex, int toIndex) {
int to = toIndex < 0 ? list.size() + toIndex : toIndex;
return (List)(fromIndex < to ? list.subList(fromIndex, to) : new ArrayList());
}
/**
* 按指定大小,分隔集合,将集合按规定个数分为n个部分
*
* @param list
* @param subListSize
* @return
*/
public static <T> List<List<T>> splitList(List<T> list, int subListSize) {
if (list == null || list.isEmpty() || subListSize < 1) {
return Collections.emptyList();
}
List<List<T>> result = new ArrayList<>();
int size = list.size();
int subListNum = (size + subListSize - 1) / subListSize;
for (int i = 0; i < subListNum; i++) {
List<T> subList = list.subList(i * subListSize, ((i + 1) * subListSize > size ? size : subListSize * (i + 1)));
result.add(subList);
}
return result;
}
/**
* 追加
*/
@SafeVarargs
public static <T> Set<T> append(Set<T> set, T... ts) {
Set<T> ret = setOf(set);
ret.addAll(Arrays.asList(ts));
return ret;
}
/**
* 追加
*/
public static <K, V> Map<K, V> append(Map<K, V> map, K k, V v) {
Map<K, V> ret = mapOf(map);
ret.put(k, v);
return ret;
}
/**
* 追加
*/
public static <K, V> Map<K, V> append(Map<K, V> map, K k1, V v1, K k2, V v2) {
Map<K, V> ret = mapOf(map);
ret.put(k1, v1);
ret.put(k2, v2);
return ret;
}
/**
* 追加
*/
public static <K, V> HashMap<K, V> concat(Map<K, V> map1, Map<K, V> map2) {
HashMap<K, V> ret = new HashMap();
ret.putAll(map1);
ret.putAll(map2);
return ret;
}
/**
* 初始化
*/
public static <K, V> Map<K, V> mapOf(Map<K, V> map) {
return (Map)(map != null ? map : new HashMap());
}
/**
* 初始化
*/
public static <T> Set<T> concurrentSet() {
return ConcurrentHashMap.newKeySet();
}
public static boolean isTrue(Boolean b) {
return Boolean.TRUE.equals(b);
}
public static int integer(Number i) {
return intValue(i);
}
public static int intValue(Number i) {
return i != null ? i.intValue() : 0;
}
public static long longValue(Number i) {
return i != null ? i.longValue() : 0L;
}
public static byte byteValue(Number i) {
return i != null ? i.byteValue() : 0;
}
public static short shortValue(Number i) {
return i != null ? i.shortValue() : 0;
}
public static float floatValue(Number i) {
return i != null ? i.floatValue() : 0.0F;
}
public static double doubleValue(Number i) {
return i != null ? i.doubleValue() : 0.0D;
}
public static boolean equals(Byte i, Byte j) {
return byteValue(i) == byteValue(j);
}
public static boolean equals(Short i, Short j) {
return shortValue(i) == shortValue(j);
}
public static boolean equals(Integer i, Integer j) {
return integer(i) == integer(j);
}
public static boolean equals(Long i, Long j) {
return longValue(i) == longValue(j);
}
public static boolean equals(String s1, String s2) {
if (Objects.equals(s1, s2)) {
return true;
} else if (s1 == null) {
return s2.length() == 0;
} else if (s2 == null) {
return s1.length() == 0;
} else {
return false;
}
}
public static boolean emptyOrEquals(String s, String another) {
return s == null || s.isEmpty() || s.equals(another);
}
public static boolean isEmpty(String s) {
return s == null || s.length() == 0;
}
public static boolean isNotEmpty(String s) {
return !isEmpty(s);
}
/**
* 不为空执行操作consumer
*
* 示例:
* Utils.consumeIfValid(s,n -> { System.out.println(n); })
*/
public static void consumeIfValid(String s, Consumer<String> consumer) {
ofEmpty(s).ifPresent(consumer);
}
public static void consumeIfValid(Long v, Consumer<Long> consumer) {
ofValid(v).ifPresent(consumer);
}
public static void consumeIfValid(Integer v, Consumer<Integer> consumer) {
ofValid(v).ifPresent(consumer);
}
public static boolean isEmpty(byte[] bytes) {
return bytes == null || bytes.length == 0;
}
public static boolean isNotEmpty(byte[] bytes) {
return !isEmpty(bytes);
}
public static <T> boolean isEmpty(T[] a) {
return a == null || a.length == 0;
}
public static <T> boolean isNotEmpty(T[] a) {
return !isEmpty(a);
}
public static boolean isEmpty(Collection<?> collection) {
return collection == null || collection.isEmpty();
}
public static boolean isNotEmpty(Collection<?> collection) {
return !isEmpty(collection);
}
public static boolean isEmpty(Map<?, ?> map) {
return map == null || map.isEmpty();
}
public static boolean isNotEmpty(Map<?, ?> map) {
return !isEmpty(map);
}
public static int length(String s) {
return s != null ? s.length() : 0;
}
public static <T> int length(T[] a) {
return a != null ? a.length : 0;
}
public static String trim(String s) {
return s != null ? s.trim() : "";
}
public static String string(Object v) {
return v != null ? v.toString() : "";
}
/**
* 不为空返回 否则直接返回空
*/
public static Optional<String> ofEmpty(String s) {
return Optional.ofNullable(s != null && s.length() > 0 ? s : null);
}
/**
* 满足条件则返回Optional
* Optional自行搜
* */
public static Optional<Long> ofValid(Long v) {
return Optional.ofNullable(v).filter((i) -> {
return i > 0L;
});
}
public static Optional<Long> ofValid0(Long v) {
return Optional.ofNullable(v).filter((i) -> {
return i >= 0L;
});
}
public static Optional<Integer> ofValid0(Integer v) {
return Optional.ofNullable(v).filter((i) -> {
return i >= 0;
});
}
public static Optional<Integer> ofValid(Integer v) {
return Optional.ofNullable(v).filter((i) -> {
return i > 0;
});
}
public static <K, V> Optional<Map<K, V>> ofEmpty(Map<K, V> map) {
return Optional.ofNullable(map != null && !map.isEmpty() ? map : null);
}
public static <T> Optional<List<T>> ofEmpty(List<T> list) {
return Optional.ofNullable(list != null && !list.isEmpty() ? list : null);
}
public static <T> T first(List<T> list) {
return isEmpty((Collection)list) ? null : list.get(0);
}
public static <T> T last(List<T> list) {
return isEmpty((Collection)list) ? null : list.get(list.size() - 1);
}
public static <T> T first(T[] array) {
return array != null && array.length > 0 ? array[0] : null;
}
public static <T> T last(T[] array) {
return array != null && array.length > 0 ? array[array.length - 1] : null;
}
public static String trim(String[] a, int index) {
return a != null && a.length > index ? trim(a[index]) : "";
}
public static String trim(List<String> list, int index) {
return list != null && list.size() > index ? trim((String)list.get(index)) : "";
}
public static String defaultIfEmpty(String s, String defaultStr) {
return isEmpty(s) ? defaultStr : s;
}
public static boolean isDigit(String s) {
return isEmpty(s) ? false : s.chars().allMatch((c) -> {
return c <= 57 && c >= 48;
});
}
public static List<String> split(String s) {
return split(s, ",");
}
public static List<String> split(String s, String regex) {
s = trim(s);
return s.isEmpty() ? Arrays.asList() : (List)Stream.of(s.split(regex)).map(String::trim).collect(Collectors.toList());
}
public static String join(CharSequence delimiter, Object... elements) {
return String.join(delimiter, (CharSequence[])Arrays.stream(elements).map(Utils::string).toArray((x$0) -> {
return new String[x$0];
}));
}
public static int bytesToInt(byte[] bs) {
if (bs != null && bs.length != 0) {
if (bs.length < 4) {
byte[] bytes = new byte[4];
System.arraycopy(bs, 0, bytes, 4 - bs.length, bs.length);
bs = bytes;
}
return bs[3] & 255 | (bs[2] & 255) << 8 | (bs[1] & 255) << 16 | (bs[0] & 255) << 24;
} else {
return 0;
}
}
public static byte[] intToBytes(int i) {
return new byte[]{(byte)(i >> 24 & 255), (byte)(i >> 16 & 255), (byte)(i >> 8 & 255), (byte)(i & 255)};
}
public static byte[] longToBytes(long l) {
ByteBuffer buffer = ByteBuffer.allocate(8);
buffer.putLong(0, l);
return buffer.array();
}
public static long bytesToLong(byte[] bs) {
if (bs != null && bs.length != 0) {
if (bs.length < 8) {
byte[] bytes = new byte[8];
System.arraycopy(bs, 0, bytes, 8 - bs.length, bs.length);
bs = bytes;
}
ByteBuffer buffer = ByteBuffer.allocate(8);
buffer.put(bs, 0, 8);
buffer.flip();
return buffer.getLong();
} else {
return 0L;
}
}
public static String utf8String(byte[] bytes) {
return bytes != null ? new String(bytes, StandardCharsets.UTF_8) : "";
}
public static boolean writeBytes(OutputStream outputStream, byte[] bytes) {
try {
if (bytes != null) {
outputStream.write(bytes);
return true;
}
} catch (IOException var3) {
var3.printStackTrace();
}
return false;
}
/**
* gzip压缩
* */
public static byte[] gzip(byte[] bytes) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
if (bytes != null && bytes.length > 0) {
try {
GZIPOutputStream gos = new GZIPOutputStream(os);
try {
gos.write(bytes);
} catch (Throwable var6) {
try {
gos.close();
} catch (Throwable var5) {
var6.addSuppressed(var5);
}
throw var6;
}
gos.close();
} catch (Throwable var7) {
}
}
return os.toByteArray();
}
public static String newUuid() {
return UUID.randomUUID().toString();
}
public static UUID toUuidObject(String name) {
try {
switch(length(name)) {
case 32:
return UUID.fromString(String.format("%s-%s-%s-%s-%s", name.substring(0, 8), name.substring(8, 12), name.substring(12, 16), name.substring(16, 20), name.substring(20, 32)));
case 36:
return UUID.fromString(name);
}
} catch (Exception var2) {
}
return null;
}
public static boolean isUuid(String name) {
return toUuidObject(name) != null;
}
public static String newUuidCompact() {
return newUuid().replace("-", "");
}
public static String uuidCompact(String uuid) {
return string(uuid).replace("-", "");
}
public static String uuidCompact(UUID uuid) {
return string(uuid).replace("-", "");
}
public static <K, V> void forEach(Map<K, V> map, BiConsumer<? super K, ? super V> action) {
if (map != null && !map.isEmpty()) {
map.forEach(action);
}
}
public static <T> void forEach(Collection<T> collection, Consumer<? super T> action) {
if (collection != null && !collection.isEmpty()) {
collection.forEach(action);
}
}
}
......@@ -51,6 +51,12 @@
<version>12.2.0.1</version>
<scope>${install.scope}</scope>
</dependency>
<dependency>
<groupId>com.fedex.connect</groupId>
<artifactId>common-dependencies</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
......
package com.fedex.connect.manager.common.enums;
import java.util.ArrayList;
import java.util.List;
/**
* FCL登录Session信息
*/
public enum FCLSessionInfoEnum {
FDX_LOGIN("fdx_login","FCL登录SESSION信息"),
FCL_UUID("fcl_uuid","FCL-UUID信息"),
FCL_CONTACTNAME("fcl_contactname","FCL联系人信息");
FCLSessionInfoEnum(String code, String name){
this.code = code;
this.name = name;
}
private String code;
private String name;
public String getCode() {
return code;
}
public String getName() {
return name;
}
public static List<String> getCodeList() {
List<String> codeList = new ArrayList<>();
for(FCLSessionInfoEnum fclSessionInfoEnum : FCLSessionInfoEnum.values()){
codeList.add(fclSessionInfoEnum.getCode());
}
return codeList;
}
}
package com.fedex.connect.manager.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
public class PropertiesConfig {
@Value("${fcl.login.url}")
private String fclLoginUrl;
@Value("${fcl.twidx.url}")
private String twIdxUrl;
@Value("${fcl.login.redjrectLogin}")
private String redjrectLogin;
}
package com.fedex.connect.manager.controller;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.manager.config.PropertiesConfig;
import com.fedex.connect.manager.controller.log.ILogLoginService;
import com.fedex.connect.manager.data.vo.JsonResult;
import com.fedex.connect.manager.service.system.ISysAuthService;
import com.fedex.connect.manager.service.system.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import javax.annotation.Resource;
import java.net.URI;
import java.util.Objects;
/**
* @author EDY
*/
public class AbstractEtController {
@Resource
protected LocaleMessageUtil localeMessageUtil;
@Autowired
protected PropertiesConfig propertiesConfig;
@Autowired
protected ISysUserService sysUserService;
@Autowired
protected ISysAuthService sysAuthService;
@Autowired
protected ILogLoginService logLoginService;
public <T> ResponseEntity<T> seeOther(String url) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(URI.create(url));
return result(HttpStatus.SEE_OTHER, httpHeaders);
}
public <T> ResponseEntity<T> temporaryRedirect(String url) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(URI.create(url));
return result(HttpStatus.TEMPORARY_REDIRECT, httpHeaders);
}
public <T> ResponseEntity<T> permanentRedirect(String url) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(URI.create(url));
return result(HttpStatus.PERMANENT_REDIRECT, httpHeaders);
}
public <T> ResponseEntity<T> result(HttpStatus status, T data) {
return new ResponseEntity<>(data, status);
}
public <T> ResponseEntity<T> result(HttpStatus status, HttpHeaders headers) {
return new ResponseEntity<>(headers, status);
}
public <T> ResponseEntity<T> ok(T data) {
return new ResponseEntity<>(data, HttpStatus.OK);
}
public <T> ResponseEntity<T> ok(MultiValueMap<String, String> headers, T data) {
return new ResponseEntity<>(data, headers, HttpStatus.OK);
}
public <T> ResponseEntity<T> error(HttpStatus code) {
return new ResponseEntity<>(code);
}
public <T> ResponseEntity<T> error(HttpStatus code, MultiValueMap<String, String> headers) {
return new ResponseEntity<>(headers, code);
}
/**
* 通过自定义的错误码,转换为对应的HttpStatus
* @param response
* @return
*/
public HttpStatus errorMappingStatus(JsonResult response) {
if (Objects.isNull(response)) {
return HttpStatus.BAD_REQUEST; //400
}
return HttpStatus.BAD_REQUEST; //400
}
/**
* 判定是否返回成功
* @param responseEntity
* @param <T>
* @return
*/
public <T> boolean isSuccess(ResponseEntity<JsonResult<T>> responseEntity) {
return responseEntity != null && responseEntity.getBody() != null && responseEntity.getBody().isSuccess();
}
/**
* 判定是否返回成功
* @param response
* @param <T>
* @return
*/
public <T> boolean isSuccess(JsonResult<T> response) {
return response != null && response.isSuccess();
}
}
package com.fedex.connect.manager.controller.log;
import com.fedex.connect.manager.data.dto.LogLoginDto;
public interface ILogLoginService {
int saveLoginLog(LogLoginDto dto);
}
package com.fedex.connect.manager.controller.log.impl;
import com.fedex.connect.manager.controller.log.ILogLoginService;
import com.fedex.connect.manager.data.dto.LogLoginDto;
import com.fedex.connect.manager.data.model.LogShowModel;
import com.fedex.connect.manager.service.AbstractEtService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 日志相关service
* @author EDY
*/
@Service
public class LogLoginServiceImpl extends AbstractEtService implements ILogLoginService {
private Logger logger = LoggerFactory.getLogger(LogLoginServiceImpl.class);
/**
* 保存登录日志
* @param dto
* @return
*/
@Transactional(rollbackFor = Exception.class)
public int saveLoginLog(LogLoginDto dto){
try{
return userLoginLogRepository.insert(LogLoginDto.dtoToDao(dto));
} catch (Exception e){
logger.error(LogShowModel.showException("Exception",e));
throw e;
}
}
}
package com.fedex.connect.manager.controller.system;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public interface ISysAuthController {
void wlgnLogin(HttpServletRequest request, HttpServletResponse res);
void wlgnForward(HttpServletRequest request, HttpServletResponse res);
}
package com.fedex.connect.manager.controller.system.impl;
import com.fedex.connect.common.dependencies.contants.DatabaseConstants;
import com.fedex.connect.common.dependencies.util.GsonUtils;
import com.fedex.connect.common.dependencies.util.StringExtUtil;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.manager.common.enums.FCLSessionInfoEnum;
import com.fedex.connect.manager.controller.AbstractEtController;
import com.fedex.connect.manager.controller.system.ISysAuthController;
import com.fedex.connect.manager.data.dto.LogLoginDto;
import com.fedex.connect.manager.data.dto.LoginRequest;
import com.fedex.connect.manager.data.dto.SysUserDto;
import com.fedex.connect.manager.data.vo.JsonResult;
import com.google.gson.JsonObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.*;
@RestController
@RequestMapping(value = "/auth", name = "权鉴操作相关请求")
@Api(value="SysAuthController",tags={"用户相关请求(无需token)"})
public class SysAuthControllerImpl extends AbstractEtController implements ISysAuthController {
private static final Logger logger = LoggerFactory.getLogger(SysAuthControllerImpl.class);
@Value("${fcl.interface.logurl}")
private String fclIndexLoginUrl;
@PostMapping("/init")
@ApiOperation(value = "初始化进入首页获取FCL登录地址")
public JsonResult init(){
return JsonResult.succ(fclIndexLoginUrl);
}
@RequestMapping(value = "/wlgnForward")
@ApiOperation(value = "FCL中转Cookie地址")
public void wlgnForward(HttpServletRequest request, HttpServletResponse res){
printRequestInfo(request);
try {
boolean equals = true;
if (!equals){
return;
}
Cookie[] cookies = request.getCookies();
if (Utils.isEmpty(cookies)){
return;
}
List<String> saveKeyList = FCLSessionInfoEnum.getCodeList();
List<String> cookiesList = new ArrayList();
for (int i = 0, max = cookies.length; i < max; i++) {
Cookie cookie = cookies[i];
if(saveKeyList.contains(cookie.getName())){
cookiesList.add("'"+cookie.getName()+"':'"+cookie.getValue()+"'");
if(cookiesList.size() == saveKeyList.size()){
break;
}
}
}
if (cookiesList.size() > 0 && cookiesList.size() == saveKeyList.size()){
JsonObject jsonObject = GsonUtils.stringToBean("{"+String.join(",",cookiesList)+"}",JsonObject.class);
//set cookie by fcl_key
JsonResult tokenResult = sysAuthService.createFclToken(jsonObject);
if (tokenResult.isSuccess()){
String fcl_token_key = String.valueOf(tokenResult.getData());
String redirectUrl = String.format("%s?token=%s", propertiesConfig.getFclLoginUrl(), fcl_token_key);
res.sendRedirect(redirectUrl);
}
}else {
res.sendRedirect(propertiesConfig.getTwIdxUrl());
}
} catch (IOException e) {
logger.error(e.getMessage(),e);
}
}
@GetMapping(value = "/wlgnLogin")
@ApiOperation(value = "FCL登录")
public void wlgnLogin(HttpServletRequest request, HttpServletResponse res) {
logger.info("wlgnLogin____________________start");
String fcl_token_key = request.getParameter("token");
if (StringUtils.isBlank(fcl_token_key)){
return;
}
JsonObject jsonObject = sysAuthService.getFclToken(fcl_token_key);
String fcl_uuid = jsonObject.get(FCLSessionInfoEnum.FCL_UUID.getCode()).getAsString();
String fcl_contactname = jsonObject.get(FCLSessionInfoEnum.FCL_CONTACTNAME.getCode()).getAsString().replaceAll("\"","");
User loginUser = sysUserService.findUserByFcl(fcl_uuid);
if (loginUser == null){
//如果用户不存在,则创建FCL用户信息
SysUserDto dto = new SysUserDto(fcl_uuid, fcl_contactname);
loginUser = sysUserService.save(dto);
} else {
//首先对用户中的姓名进行解密
if (StringUtils.isNotBlank(loginUser.getUserName())){
String decode_userName = loginUser.getUserName();
if (StringUtils.isNotBlank(decode_userName)){
loginUser.setUserName(decode_userName);
}
}
//如果名称和原来不一样,则更新
if(StringUtils.isNotBlank(fcl_contactname) && !fcl_contactname.equals(loginUser.getUserName())){
String encode_fcl_contactname = StringUtils.trimToEmpty(fcl_contactname);
if (StringUtils.isNotBlank(encode_fcl_contactname)){
loginUser.setUserName(encode_fcl_contactname);
} else {
loginUser.setUserName(StringUtils.trimToEmpty(fcl_contactname));
}
loginUser.setUpdateTime(new Date());
sysUserService.update(loginUser);
}
}
//创建token
LoginRequest loginRequest = new LoginRequest();
loginRequest.setRememberMe(true);
JsonResult tokenResult = sysAuthService.createAccessToken(loginRequest, loginUser);
//记录日志
LogLoginDto dto = new LogLoginDto(loginUser.getId(), DatabaseConstants.USER_OPER_FCL_REGISTER,
localeMessageUtil.getMessage("auth_login_desc"));
logLoginService.saveLoginLog(dto);
try{
if (tokenResult.isSuccess()){
String redirectUrl = String.format("%s?token=%s&uid=%s", propertiesConfig.getRedjrectLogin(), tokenResult.getData(), loginUser.getId());
res.sendRedirect(redirectUrl);
logger.info("wlgnLogin____________________finish");
}else {
res.sendRedirect(propertiesConfig.getTwIdxUrl());
}
} catch (IOException e) {
logger.error("FCL客户登录初始化 | 发生异常 | 异常如下:",e);
throw new RuntimeException(e);
}
}
private void printRequestInfo(HttpServletRequest request) {
logger.info("wlgnForward____________________headerNames");
Enumeration<String> headerNames = request.getHeaderNames();
if(Objects.nonNull(headerNames)) {
while (headerNames.hasMoreElements()) {
String s = headerNames.nextElement();
String header = request.getHeader(s);
logger.info(s + ":" + header);
}
}
logger.info("wlgnForward____________________parameterNames");
Enumeration<String> parameterNames = request.getParameterNames();
if(Objects.nonNull(parameterNames)){
while(parameterNames.hasMoreElements()){
String s = parameterNames.nextElement();
String parameter = request.getHeader(s);
logger.info(s+":"+parameter);
}
}
logger.info("wlgnForward____________________parameterMap");
Map<String, String[]> parameterMap = request.getParameterMap();
if(Objects.nonNull(parameterMap)) {
Set<String> strings = parameterMap.keySet();
Iterator<String> iterator = strings.iterator();
while (iterator.hasNext()) {
String next = iterator.next();
String[] strings1 = parameterMap.get(next);
logger.info(next + ":" + StringExtUtil.convertArrayToString(strings1, ","));
}
}
logger.info("wlgnForward____________________cookies");
Cookie[] cookies = request.getCookies();
if(Objects.nonNull(cookies)) {
for (int i = 0, max = cookies.length; i < max; i++) {
Cookie cookie = cookies[i];
logger.info(cookie.getName() + ":" + cookie.getValue());
}
}
logger.info("wlgnForward____________________Session");
HttpSession session = request.getSession();
Enumeration<String> attributeNames = session.getAttributeNames();
while(attributeNames.hasMoreElements()){
String s = attributeNames.nextElement();
String parameter = (String)request.getAttribute(s);
logger.info(s+":"+parameter);
}
}
}
package com.fedex.connect.manager.dao.base;
import com.fedex.connect.common.dao.base.DictionaryEntriesMapper;
import com.fedex.connect.common.dao.log.UserLoginInfoMapper;
import com.fedex.connect.common.dao.sys.RedisSlabMapper;
import com.fedex.connect.common.dao.sys.RoleMapper;
import com.fedex.connect.common.dao.sys.UserMapper;
import com.fedex.connect.common.dao.sys.UserRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
public class BaseDao {
@Autowired
public UserLoginInfoMapper userLoginInfoMapper;
@Autowired
public RedisSlabMapper redisSlabMapper;
@Autowired
public RoleMapper roleMapper;
@Autowired
public UserRoleMapper userRoleMapper;
@Autowired
public UserMapper userMapper;
@Autowired
public DictionaryEntriesMapper dictionaryEntriesMapper;
}
package com.fedex.connect.manager.dao.repository.log;
import com.fedex.connect.common.model.log.UserLoginInfo;
public interface IUserLoginLogRepository {
int insert(UserLoginInfo userLoginInfo);
}
package com.fedex.connect.manager.dao.repository.log.impl;
import com.fedex.connect.common.model.log.UserLoginInfo;
import com.fedex.connect.manager.dao.base.BaseDao;
import com.fedex.connect.manager.dao.repository.log.IUserLoginLogRepository;
import org.springframework.stereotype.Repository;
@Repository
public class UserLoginLogRepositoryImpl extends BaseDao implements IUserLoginLogRepository {
@Override
public int insert(UserLoginInfo userLoginInfo) {
return userLoginInfoMapper.insert(userLoginInfo);
}
}
package com.fedex.connect.manager.dao.repository.sys;
import com.fedex.connect.common.model.base.DictionaryEntries;
import com.fedex.connect.common.model.base.DictionaryEntriesExample;
import java.util.List;
public interface IDictionaryEntriesRepository {
List<DictionaryEntries> selectByExample(DictionaryEntriesExample example);
}
package com.fedex.connect.manager.dao.repository.sys;
import com.fedex.connect.common.model.sys.RedisSlab;
import com.fedex.connect.common.model.sys.RedisSlabExample;
import java.util.List;
public interface IRedisSlabRepository {
int insert(RedisSlab record);
List<RedisSlab> selectByExample(RedisSlabExample example);
int deleteByPrimaryKey(Long id);
}
package com.fedex.connect.manager.dao.repository.sys;
import com.fedex.connect.common.model.sys.Role;
import com.fedex.connect.common.model.sys.RoleExample;
import java.util.List;
public interface IRoleRepository {
List<Role> selectByExample(RoleExample example);
Role selectByPrimaryKey(Long id);
int insert(Role record);
}
package com.fedex.connect.manager.dao.repository.sys;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.common.model.sys.UserExample;
import java.util.List;
public interface IUserRepository {
List<User> selectByExample(UserExample example);
int insert(User record);
int updateByPrimaryKeySelective(User record);
}
package com.fedex.connect.manager.dao.repository.sys;
import com.fedex.connect.common.model.sys.UserRole;
import com.fedex.connect.common.model.sys.UserRoleExample;
import java.util.List;
public interface IUserRoleRepository {
List<UserRole> selectByExample(UserRoleExample example);
int insert(UserRole record);
}
package com.fedex.connect.manager.dao.repository.sys.impl;
import com.fedex.connect.common.model.base.DictionaryEntries;
import com.fedex.connect.common.model.base.DictionaryEntriesExample;
import com.fedex.connect.manager.dao.base.BaseDao;
import com.fedex.connect.manager.dao.repository.sys.IDictionaryEntriesRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class DictionaryEntriesImpl extends BaseDao implements IDictionaryEntriesRepository {
@Override
public List<DictionaryEntries> selectByExample(DictionaryEntriesExample example) {
return dictionaryEntriesMapper.selectByExample(example);
}
}
package com.fedex.connect.manager.dao.repository.sys.impl;
import com.fedex.connect.common.model.sys.RedisSlab;
import com.fedex.connect.common.model.sys.RedisSlabExample;
import com.fedex.connect.manager.dao.base.BaseDao;
import com.fedex.connect.manager.dao.repository.sys.IRedisSlabRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class RedisSlabRepositoryImpl extends BaseDao implements IRedisSlabRepository {
@Override
public int insert(RedisSlab record) {
return redisSlabMapper.insert(record);
}
@Override
public List<RedisSlab> selectByExample(RedisSlabExample example) {
return redisSlabMapper.selectByExample(example);
}
@Override
public int deleteByPrimaryKey(Long id) {
return redisSlabMapper.deleteByPrimaryKey(id);
}
}
package com.fedex.connect.manager.dao.repository.sys.impl;
import com.fedex.connect.common.model.sys.Role;
import com.fedex.connect.common.model.sys.RoleExample;
import com.fedex.connect.manager.dao.base.BaseDao;
import com.fedex.connect.manager.dao.repository.sys.IRoleRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class RoleRepositoryImpl extends BaseDao implements IRoleRepository {
@Override
public List<Role> selectByExample(RoleExample example) {
return roleMapper.selectByExample(example);
}
@Override
public Role selectByPrimaryKey(Long id) {
return roleMapper.selectByPrimaryKey(id);
}
@Override
public int insert(Role record) {
return roleMapper.insert(record);
}
}
package com.fedex.connect.manager.dao.repository.sys.impl;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.common.model.sys.UserExample;
import com.fedex.connect.manager.dao.base.BaseDao;
import com.fedex.connect.manager.dao.repository.sys.IUserRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class UserRepositoryImpl extends BaseDao implements IUserRepository {
@Override
public List<User> selectByExample(UserExample example) {
return userMapper.selectByExample(example);
}
@Override
public int insert(User record) {
return userMapper.insert(record);
}
@Override
public int updateByPrimaryKeySelective(User record) {
return userMapper.updateByPrimaryKeySelective(record);
}
}
package com.fedex.connect.manager.dao.repository.sys.impl;
import com.fedex.connect.common.model.sys.UserRole;
import com.fedex.connect.common.model.sys.UserRoleExample;
import com.fedex.connect.manager.dao.base.BaseDao;
import com.fedex.connect.manager.dao.repository.sys.IUserRoleRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class UserRoleRepositoryImpl extends BaseDao implements IUserRoleRepository {
@Override
public List<UserRole> selectByExample(UserRoleExample example) {
return userRoleMapper.selectByExample(example);
}
@Override
public int insert(UserRole record) {
return userRoleMapper.insert(record);
}
}
package com.fedex.connect.manager.data.bo;
import com.fedex.connect.common.dependencies.util.DateUtil;
import com.fedex.connect.common.model.sys.RedisSlab;
import java.util.Date;
public class RedisSlabBo {
public static RedisSlab toDao(String key, String value, int validDuration){
RedisSlab dao = new RedisSlab();
dao.setRedisKey(key);
dao.setRedisMsg(value);
dao.setValidDuration(validDuration != 0 ? Long.valueOf(validDuration) : 0L);
dao.setDisTime(DateUtil.getHoursAgoTime(validDuration));
dao.setCreateTime(new Date());
return dao;
}
/**
* ID自增
*/
private Long id;
/**
* Redis key
*/
private String redisKey;
/**
* Redis信息
*/
private String redisMsg;
/**
* 有效时长
*/
private Long validDuration;
/**
* 失效时间
*/
private Date disTime;
/**
* 创建时间
*/
private Date createTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRedisKey() {
return redisKey;
}
public void setRedisKey(String redisKey) {
this.redisKey = redisKey;
}
public String getRedisMsg() {
return redisMsg;
}
public void setRedisMsg(String redisMsg) {
this.redisMsg = redisMsg;
}
public Long getValidDuration() {
return validDuration;
}
public void setValidDuration(Long validDuration) {
this.validDuration = validDuration;
}
public Date getDisTime() {
return disTime;
}
public void setDisTime(Date disTime) {
this.disTime = disTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public RedisSlabBo() {
}
public RedisSlabBo(Long id, String redisKey, String redisMsg, Long validDuration, Date disTime, Date createTime) {
this.id = id;
this.redisKey = redisKey;
this.redisMsg = redisMsg;
this.validDuration = validDuration;
this.disTime = disTime;
this.createTime = createTime;
}
}
package com.fedex.connect.manager.data.dto;
import com.fedex.connect.common.model.log.UserLoginInfo;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;
/**
* Dto对象用于记录登录操作日志
* 不建议继承:含义不同,不要混淆
* 不建议反射:数据量上来反射copy很慢。set最快
* dao 转dto 看业务是否需要了。
*/
public class LogLoginDto {
/**
* 重载构造函数
*/
public LogLoginDto(Long userId, Long operType, String operDesc){
this.userId = userId;
this.operTime = new Date();
this.operType = operType;
this.operDesc = operDesc;
try{
this.ip = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e){
this.ip = "127.0.01";
}
}
/**
* dto转dao
* @param dto
* @return
*/
public static UserLoginInfo dtoToDao(LogLoginDto dto){
UserLoginInfo log = new UserLoginInfo();
if (dto == null){
return log;
}
if (dto.getId() != null && dto.getId() != 0){
log.setId(dto.getId());
}
log.setUserId(dto.getUserId());
log.setOperDesc(dto.getOperDesc());
log.setIp(dto.getIp());
return log;
}
//InetAddress.getLocalHost().getHostAddress()
/**
* ID
*/
private Long id;
/**
* 用户id
*/
private Long userId;
/**
* 操作时间
*/
private Date operTime;
/**
* 操作类型
1:登录 2:退出 3:修改密码4:FCL登录注册
*/
private Long operType;
/**
* 操作描述
*/
private String operDesc;
/**
* IP
*/
private String ip;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Date getOperTime() {
return operTime;
}
public void setOperTime(Date operTime) {
this.operTime = operTime;
}
public Long getOperType() {
return operType;
}
public void setOperType(Long operType) {
this.operType = operType;
}
public String getOperDesc() {
return operDesc;
}
public void setOperDesc(String operDesc) {
this.operDesc = operDesc;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public LogLoginDto() {
}
public LogLoginDto(Long id, Long userId, Date operTime, Long operType, String operDesc, String ip) {
this.id = id;
this.userId = userId;
this.operTime = operTime;
this.operType = operType;
this.operDesc = operDesc;
this.ip = ip;
}
}
package com.fedex.connect.manager.data.dto;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.manager.data.vo.JsonResult;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
/**
* 用户登录请求DTO
* @author Administrator
*/
public class LoginRequest implements Serializable {
public static LoginRequest dataProcessing(LoginRequest dto){
dto.setAccNo(Utils.trim(dto.getAccNo()));
dto.setPassword(Utils.trim(dto.getPassword()));
return dto;
}
/**
* 验证用户登录信息
* @param dto
* @return
*/
public static JsonResult validate(LoginRequest dto){
if (dto == null){
JsonResult.fail(ResponseCode.REQUEST_PARAM_NULL.getMsg());
}
if (StringUtils.isBlank(dto.getAccNo())){
JsonResult.fail("auth_login_accno_null");
}
if (StringUtils.isBlank(dto.getPassword())){
JsonResult.fail("auth_login_pwd_null");
}
return JsonResult.succ(null);
}
/**
* 用户账号
*/
private String accNo;
/**
* 用户密码
*/
private String password;
/**
* 记住用户号
*/
private Boolean rememberMe;
public String getAccNo() {
return accNo;
}
public void setAccNo(String accNo) {
this.accNo = accNo;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Boolean getRememberMe() {
return rememberMe;
}
public void setRememberMe(Boolean rememberMe) {
this.rememberMe = rememberMe;
}
}
package com.fedex.connect.manager.data.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fedex.connect.common.dependencies.contants.DatabaseConstants;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.util.BytesUtils;
import com.fedex.connect.common.dependencies.util.StringExtUtil;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.manager.data.vo.JsonResult;
import io.swagger.annotations.ApiModel;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import java.util.Date;
/**
* 用户相关DTO
*/
@ApiModel(value = "用户相关DTO")
public class SysUserDto {
public static SysUserDto dataProcessing(SysUserDto dto){
dto.setAccNo(Utils.trim(dto.getAccNo()));
dto.setUserName(Utils.trim(dto.getUserName()));
dto.setPassword(Utils.trim(dto.getPassword()));
dto.setPassword2(Utils.trim(dto.getPassword2()));
dto.setFedexAccNo(Utils.trim(dto.getFedexAccNo()));
dto.setFedexAccNo2(Utils.trim(dto.getFedexAccNo2()));
//邮箱@后面转小写处理
dto.setEmail(StringExtUtil.emailSuffixDispose(Utils.trim(dto.getEmail())));
dto.setPhone(Utils.trim(dto.getPhone()));
dto.setCompanyName(Utils.trim(dto.getCompanyName()));
dto.setUnifiedBusinessNum(Utils.trim(dto.getUnifiedBusinessNum()));
dto.setCustomsSerialNum(Utils.trim(dto.getCustomsSerialNum()));
dto.setUserSource(DatabaseConstants.USER_SOURCE_TW);
dto.setTypeCode(DatabaseConstants.DICT_USER_DEFAULT_CODE);
return dto;
}
/**
* dto的校验方法
* @param dto
* @return
*/
public static JsonResult validatedDto(SysUserDto dto){
if (dto == null){
JsonResult.fail(ResponseCode.REQUEST_PARAM_NULL.getMsg());
}
//必填校验
if (StringUtils.isBlank(dto.getAccNo())){
JsonResult.fail("dto_vali_user_accno_null");
}
if (BytesUtils.getStrUTF8ByteLength(dto.getAccNo()) > 200){
JsonResult.fail("dto_vali_user_accno_max");
}
if (StringUtils.isBlank(dto.getUserName())){
JsonResult.fail("dto_vali_user_name_null");
}
if (BytesUtils.getStrUTF8ByteLength(dto.getUserName()) > 200){
JsonResult.fail("dto_vali_user_name_max");
}
if (StringUtils.isBlank(dto.getPassword())){
JsonResult.fail("dto_vali_user_pwd_null");
}
if (BytesUtils.getStrUTF8ByteLength(dto.getPassword()) > 255){
JsonResult.fail("dto_vali_user_pwd_max");
}
if (StringUtils.isBlank(dto.getPassword2())){
JsonResult.fail("dto_vali_user_pwd2_null");
}
if (StringUtils.equals(dto.getPassword(),dto.getPassword2())){
JsonResult.fail("dto_vali_user_pwd3_null");
}
if (StringUtils.isBlank(dto.getFedexAccNo())){
JsonResult.fail("dto_vali_user_fed_no_null");
}
if (BytesUtils.getStrUTF8ByteLength(dto.getFedexAccNo()) > 200){
JsonResult.fail("dto_vali_user_fed_no_max");
}
if (!NumberUtils.isDigits(dto.getFedexAccNo()) || dto.getFedexAccNo().length() != 9){
JsonResult.fail("dto_vali_user_fed_no_num");
}
if (StringUtils.isBlank(dto.getFedexAccNo2())){
JsonResult.fail("dto_vali_user_fed_no_null");
}
if (!NumberUtils.isDigits(dto.getFedexAccNo2()) || dto.getFedexAccNo2().length() != 9){
JsonResult.fail("dto_vali_user_fed_no_num");
}
if (StringUtils.equals(dto.getFedexAccNo(),dto.getFedexAccNo2())){
JsonResult.fail("dto_vali_user_fed_no3_null");
}
if (StringUtils.isBlank(dto.getEmail())){
JsonResult.fail("dto_vali_user_email_null");
}
if (BytesUtils.getStrUTF8ByteLength(dto.getEmail()) > 100){
JsonResult.fail("dto_vali_user_email_max");
}
if (!StringExtUtil.isEmail(dto.getEmail())){
JsonResult.fail("dto_vali_user_email_final");
}
if (StringUtils.isBlank(dto.getPhone())){
JsonResult.fail("dto_vali_user_phone_null");
}
if (BytesUtils.getStrUTF8ByteLength(dto.getPhone()) > 20){
JsonResult.fail("dto_vali_user_phone_max");
}
if (StringUtils.isBlank(dto.getCompanyName())){
JsonResult.fail("dto_vali_user_com_name_null");
}
if (BytesUtils.getStrUTF8ByteLength(dto.getCompanyName()) > 255){
JsonResult.fail("dto_vali_user_com_name_max");
}
if (StringUtils.isBlank(dto.getUnifiedBusinessNum())){
JsonResult.fail("dto_vali_user_no_null");
}
if (BytesUtils.getStrUTF8ByteLength(dto.getUnifiedBusinessNum()) > 30){
JsonResult.fail("dto_vali_user_no_max");
}
if (!StringUtils.isBlank(dto.getCustomsSerialNum()) &&
BytesUtils.getStrUTF8ByteLength(dto.getUnifiedBusinessNum()) > 30){
JsonResult.fail("dto_vali_serlai_max");
}
if (!NumberUtils.isDigits(dto.getUnifiedBusinessNum())){
JsonResult.fail("dto_vali_user_no_final");
}
if (!dto.isPolicyFlag()){
JsonResult.fail("dto_vali_user_no_policy");
}
if (!dto.isClauseFlag()){
JsonResult.fail("dto_vali_user_no_clause");
}
return JsonResult.succ(null);
}
/**
* dto 转 dao
* @return
*/
public static User dtoToDao(SysUserDto dto){
User user = new User();
if (dto == null){
return user;
}
if (dto.getId() != null && dto.getId() != 0){
user.setId(dto.getId());
}
user.setAccNo(dto.getAccNo());
user.setUserName(dto.getUserName());
user.setPassword(dto.getPassword());
user.setFedexAccNo(dto.getFedexAccNo());
user.setEmail(dto.getEmail());
user.setPhone(dto.getPhone());
user.setCompanyName(dto.getCompanyName());
user.setUnifiedBusinessNum(dto.getUnifiedBusinessNum());
user.setCustomsSerialNum(dto.getCustomsSerialNum());
user.setCreateTime(new Date());
user.setUpdateTime(new Date());
user.setPwdLastUpdTime(null);
user.setTypeId(0L);
user.setStatus(DatabaseConstants.GLOBAL_STATUS_VALID);
user.setRemark(dto.getRemark());
user.setUserSource(dto.getUserSource());
return user;
}
public SysUserDto(String uuid, String contactname){
String fcl_acc_no = DatabaseConstants.FCL_PREFIX + "_" + uuid;
String fcl_pwd = DatabaseConstants.FCL_PREFIX + "_" + uuid + "_pwd";
this.accNo = uuid;
if (Utils.isNotEmpty(contactname)){
this.userName = StringUtils.trimToEmpty(contactname);
} else {
this.userName = fcl_acc_no;
}
this.password = fcl_pwd;
this.fedexAccNo = uuid;
this.email = null;
this.phone = null;
this.companyName = null;
this.unifiedBusinessNum = null;
this.customsSerialNum = null;
this.userSource = DatabaseConstants.USER_SOURCE_FCL;
this.typeCode = DatabaseConstants.DICT_USER_FEDEX_CODE;
}
/**
* ID
*/
private Long id;
/**
* 用户账号
*/
private String accNo;
/**
* 姓名
*/
private String userName;
/**
* 密码
*/
private String password;
/**
* 密码
*/
private String password2;
/**
* FedEx账户
*/
private String fedexAccNo;
/**
* FedEx账户
*/
private String fedexAccNo2;
/**
* 邮箱
*/
private String email;
/**
* 联系电话
*/
private String phone;
/**
* 公司名称
*/
private String companyName;
/**
* 营利事业统一编号
*/
private String unifiedBusinessNum;
/**
* 海关编号
*/
private String customsSerialNum;
/**
* 用户类型ID。
关联数据字典表。指定KEY为:user_type
*/
@JsonIgnore
private Long typeId;
/**
* 用户类型在数据字典中的code
*/
@JsonIgnore
private String typeCode;
/**
* 是否有效(1:有效[true]。0:无效[false]。)
*/
@JsonIgnore
private Long status;
/**
* 勾选:我已阅读并同意接受《联邦快递个人信息保护政策》勾选框。点击《联邦快递个人信息保护政策》
*/
private boolean policyFlag;
/**
* 勾选:我同意使用FedEx 在线申报工具如是上传资料完成电子申报,每票货件均受到《国际空运提单》条款和《联邦快递标准货运条款》
*/
private boolean clauseFlag;
@JsonIgnore
private String remark;
/**
* 用户信息来源。1:台湾项目注册。2:FCL
*/
@JsonIgnore
private Long userSource;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAccNo() {
return accNo;
}
public void setAccNo(String accNo) {
this.accNo = accNo;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getFedexAccNo() {
return fedexAccNo;
}
public void setFedexAccNo(String fedexAccNo) {
this.fedexAccNo = fedexAccNo;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getUnifiedBusinessNum() {
return unifiedBusinessNum;
}
public void setUnifiedBusinessNum(String unifiedBusinessNum) {
this.unifiedBusinessNum = unifiedBusinessNum;
}
public String getCustomsSerialNum() {
return customsSerialNum;
}
public void setCustomsSerialNum(String customsSerialNum) {
this.customsSerialNum = customsSerialNum;
}
public Long getTypeId() {
return typeId;
}
public void setTypeId(Long typeId) {
this.typeId = typeId;
}
public Long getStatus() {
return status;
}
public void setStatus(Long status) {
this.status = status;
}
public String getPassword2() {
return password2;
}
public void setPassword2(String password2) {
this.password2 = password2;
}
public String getFedexAccNo2() {
return fedexAccNo2;
}
public void setFedexAccNo2(String fedexAccNo2) {
this.fedexAccNo2 = fedexAccNo2;
}
public boolean isPolicyFlag() {
return policyFlag;
}
public void setPolicyFlag(boolean policyFlag) {
this.policyFlag = policyFlag;
}
public boolean isClauseFlag() {
return clauseFlag;
}
public void setClauseFlag(boolean clauseFlag) {
this.clauseFlag = clauseFlag;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Long getUserSource() {
return userSource;
}
public void setUserSource(Long userSource) {
this.userSource = userSource;
}
public String getTypeCode() {
return typeCode;
}
public void setTypeCode(String typeCode) {
this.typeCode = typeCode;
}
public SysUserDto() {
}
public SysUserDto(Long id, String accNo, String userName, String password, String password2, String fedexAccNo, String fedexAccNo2, String email, String phone, String companyName, String unifiedBusinessNum, String customsSerialNum, Long typeId, String typeCode, Long status, boolean policyFlag, boolean clauseFlag, String remark, Long userSource) {
this.id = id;
this.accNo = accNo;
this.userName = userName;
this.password = password;
this.password2 = password2;
this.fedexAccNo = fedexAccNo;
this.fedexAccNo2 = fedexAccNo2;
this.email = email;
this.phone = phone;
this.companyName = companyName;
this.unifiedBusinessNum = unifiedBusinessNum;
this.customsSerialNum = customsSerialNum;
this.typeId = typeId;
this.typeCode = typeCode;
this.status = status;
this.policyFlag = policyFlag;
this.clauseFlag = clauseFlag;
this.remark = remark;
this.userSource = userSource;
}
}
package com.fedex.connect.manager.data.model;
import com.google.gson.Gson;
/**
* 用于打印日志的Model。
* 为了将来打印的日志,转换语言
* @author EDY
*/
public class LogShowModel {
/**
* 方法
*/
private String method;
/**
* 参数
*/
private Object param;
/**
* 返回
*/
private Object result;
/**
* 异常
*/
private Exception e;
/**
* 错误
*/
private String msg;
public static String showRequest(String methodName, Object param){
LogShowModel lsm = new LogShowModel();
lsm.setMethod(methodName);
lsm.setParam(param);
return lsm.toString();
}
public static String showResponse(String methodName, Object result){
LogShowModel lsm = new LogShowModel();
lsm.setMethod(methodName);
lsm.setResult(result);
return lsm.toString();
}
public static String showException(String methodName, Exception e){
LogShowModel lsm = new LogShowModel();
lsm.setMethod(methodName);
lsm.setE(e);
return lsm.toString();
}
public static String showMsg(String methodName, String msg){
LogShowModel lsm = new LogShowModel();
lsm.setMethod(methodName);
lsm.setMsg(msg);
return lsm.toString();
}
@Override
public String toString() {
Gson gson = new Gson();
StringBuilder show = new StringBuilder("方法:" + method);
if (param != null){
show.append(",请求参数:"+gson.toJson(param));
}
if (result != null){
show.append(",响应:"+gson.toJson(result));
}
if (e != null){
show.append(",异常:"+ e.toString());
}
if (msg != null){
show.append(","+ msg);
}
return show.toString();
}
public LogShowModel(String method, Object param, Object result, Exception e, String msg) {
this.method = method;
this.param = param;
this.result = result;
this.e = e;
this.msg = msg;
}
public LogShowModel() {
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public Object getParam() {
return param;
}
public void setParam(Object param) {
this.param = param;
}
public Object getResult() {
return result;
}
public void setResult(Object result) {
this.result = result;
}
public Exception getE() {
return e;
}
public void setE(Exception e) {
this.e = e;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.fedex.connect.manager.data.vo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import javax.servlet.http.HttpServletResponse;
public class JsonResult<T> {
private int code = HttpServletResponse.SC_BAD_REQUEST;;
private String msg;
private boolean success;
private T data;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public static JsonResult succ(Object data,String message) {
return succ(ResponseCode.SUCCESS_CODE.getCode(), message, data);
}
public static JsonResult succ(Object data) {
return succ(ResponseCode.SUCCESS_CODE.getCode(), "SUCCESS", data);
}
public static JsonResult succ(int code, String msg, Object data) {
JsonResult r = new JsonResult();
r.setCode(code);
r.setMsg(msg);
r.setSuccess(true);
r.setData(data);
return r;
}
public static JsonResult fail(String msg) {
return fail(ResponseCode.FAIL_CODE.getCode(), msg,null);
}
public static JsonResult fail(int code, String msg,Object data) {
JsonResult r = new JsonResult();
r.setCode(code);
r.setMsg(msg);
r.setSuccess(false);
r.setData(data);
return r;
}
public static JsonResult fail(ResponseCode resultCode) {
return fail(resultCode.getCode(), resultCode.getMsg(), null);
}
public static JsonResult fail(ResponseCode resultCode, Object data) {
return fail(resultCode.getCode(), resultCode.getMsg(), data);
}
}
package com.fedex.connect.manager.service;
import com.fedex.connect.common.dao.log.UserLoginInfoMapper;
import com.fedex.connect.common.dao.sys.RoleMapper;
import com.fedex.connect.common.dao.sys.UserMapper;
import com.fedex.connect.common.dao.sys.UserRoleMapper;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.manager.dao.repository.log.IUserLoginLogRepository;
import com.fedex.connect.manager.dao.repository.sys.*;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
public class AbstractEtService {
@Resource
protected LocaleMessageUtil localeMessageUtil;
/**
* repository
*/
@Autowired
public IUserLoginLogRepository userLoginLogRepository;
@Autowired
public IRedisSlabRepository redisSlabRepository;
@Autowired
public IRoleRepository roleRepository;
@Autowired
public IUserRoleRepository userRoleRepository;
@Autowired
public IUserRepository userRepository;
@Autowired
public IDictionaryEntriesRepository dictionaryEntriesRepository;
/**
* Mapper---------------------------------------------
*/
@Autowired
protected UserMapper userMapper;
@Autowired
protected UserRoleMapper userRoleMapper;
@Autowired
protected RoleMapper roleMapper;
@Autowired
protected UserLoginInfoMapper userLoginInfoMapper;
/**
* MapperExt---------------------------------------------
*/
}
package com.fedex.connect.manager.service.base;
import com.fedex.connect.common.model.base.DictionaryEntries;
import java.util.List;
public interface IInitDictionaryEntriesService {
List<DictionaryEntries> findAll();
void initializeDictionary();
}
package com.fedex.connect.manager.service.base.impl;
import com.fedex.connect.common.dependencies.config.DictionaryProvider;
import com.fedex.connect.common.dependencies.contants.DatabaseConstants;
import com.fedex.connect.common.model.base.DictionaryEntries;
import com.fedex.connect.common.model.base.DictionaryEntriesExample;
import com.fedex.connect.manager.data.model.LogShowModel;
import com.fedex.connect.manager.service.AbstractEtService;
import com.fedex.connect.manager.service.base.IInitDictionaryEntriesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Order(value = 1)
public class InitInitDictionaryEntriesServiceImpl extends AbstractEtService implements IInitDictionaryEntriesService {
private static Logger log = LoggerFactory.getLogger(InitInitDictionaryEntriesServiceImpl.class);
public List<DictionaryEntries> findAll() {
try{
DictionaryEntriesExample example = new DictionaryEntriesExample();
DictionaryEntriesExample.Criteria criteria = example.createCriteria();
criteria.andStatusEqualTo(DatabaseConstants.GLOBAL_STATUS_VALID);
example.setOrderByClause("CREATE_TIME DESC");
return dictionaryEntriesRepository.selectByExample(example);
} catch (Exception e){
log.error(LogShowModel.showException("Exception",e));
return null;
}
}
public void initializeDictionary() {
List<DictionaryEntries> data = findAll(); // 获取字典数据
DictionaryProvider.setDictionaryData(data); // 将数据设置到字典提供者中
}
}
package com.fedex.connect.manager.service.system;
import com.fedex.connect.common.model.sys.RedisSlab;
public interface IRedisUtilService {
Boolean set(String key, String value,int expireTimeH);
Boolean set(String key, String value);
RedisSlab get(String key, String value);
RedisSlab get(String key);
<T> T get(String key, Class<T> clazz);
int del(String key);
}
package com.fedex.connect.manager.service.system;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.manager.data.dto.LoginRequest;
import com.fedex.connect.manager.data.vo.JsonResult;
import com.google.gson.JsonObject;
public interface ISysAuthService {
JsonResult createAccessToken(LoginRequest loginRequest, User user);
JsonResult createFclToken(JsonObject token);
JsonObject getFclToken(String tokenKey);
}
package com.fedex.connect.manager.service.system;
import com.fedex.connect.common.model.sys.Role;
public interface ISysRoleService {
Role findRoleByCode(String roleCode);
}
package com.fedex.connect.manager.service.system;
public interface ISysUserRoleService {
int save(Long userId,Long roleId);
}
package com.fedex.connect.manager.service.system;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.manager.data.dto.SysUserDto;
public interface ISysUserService {
User findUserByFcl(String fclUuid);
User save(SysUserDto dto);
int update(User dao);
}
package com.fedex.connect.manager.service.system.impl;
import com.fedex.connect.common.dependencies.util.GsonUtils;
import com.fedex.connect.common.model.sys.RedisSlab;
import com.fedex.connect.common.model.sys.RedisSlabExample;
import com.fedex.connect.manager.data.bo.RedisSlabBo;
import com.fedex.connect.manager.service.AbstractEtService;
import com.fedex.connect.manager.service.system.IRedisUtilService;
import com.google.gson.Gson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Optional;
@Service
public class RedisUtilServiceImpl extends AbstractEtService implements IRedisUtilService {
private static Logger logger = LoggerFactory.getLogger(RedisUtilServiceImpl.class);
@Transactional(rollbackFor = Exception.class)
public Boolean set(String key, String value,int expireTimeH) {
RedisSlab dao = RedisSlabBo.toDao(key,value, expireTimeH);
RedisSlab redisSlab = get(key);
if (redisSlab != null){
del(key);
}
try {
int ct = redisSlabRepository.insert(dao);
if (ct > 0) {
return true;
}
return false;
} catch (Exception e) {
logger.error("REDIS SLAB 异常 [SET]: " + e);
throw e;
}
}
public Boolean set(String key, String value) {
return set(key,value, 1);
}
public RedisSlab get(String key,String value){
try {
RedisSlabExample example = new RedisSlabExample();
RedisSlabExample.Criteria criteria = example.createCriteria();
criteria.andRedisKeyEqualTo(key);
criteria.andRedisMsgEqualTo(value);
return CollectionUtils.firstElement(redisSlabRepository.selectByExample(example));
}catch (Exception e){
logger.error("REDIS SLAB 异常 [GET]: " + e);
throw e;
}
}
public RedisSlab get(String key){
try {
RedisSlabExample example = new RedisSlabExample();
RedisSlabExample.Criteria criteria = example.createCriteria();
criteria.andRedisKeyEqualTo(key);
return CollectionUtils.firstElement(redisSlabRepository.selectByExample(example));
}catch (Exception e){
logger.error("REDIS SLAB 异常 [GET]: " + e);
throw e;
}
}
public <T> T get(String key, Class<T> clazz) {
try {
RedisSlab redisSlab = get(key);
String str = redisSlab != null ? Optional.ofNullable(redisSlab.getRedisMsg()).orElse(null): null;
T t = GsonUtils.stringToBean(str, clazz);
return t;
}catch (Exception e){
logger.error("REDIS SLAB 异常 [GET]: " + e);
throw e;
}
}
@Transactional(rollbackFor = Exception.class)
public int del(String key){
try {
logger.info("del db redis key:{}",key);
RedisSlab redisSlab = get(key);
logger.info("del db redis key get info:{}", new Gson().toJson(redisSlab));
if (redisSlab != null){
logger.info("get info not null");
int delct = redisSlabRepository.deleteByPrimaryKey(redisSlab.getId());
logger.info("redisSlabRepository.deleteByPrimaryKey result :{}", delct);
return delct;
}
return 0;
}catch (Exception e){
logger.error("REDIS SLAB 异常 [DEL]: " + e);
throw e;
}
}
}
package com.fedex.connect.manager.service.system.impl;
import com.fedex.connect.common.dependencies.contants.DatabaseConstants;
import com.fedex.connect.common.dependencies.contants.RedisConstants;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.util.GsonUtils;
import com.fedex.connect.common.dependencies.util.JwtTokenUtils;
import com.fedex.connect.common.model.sys.RedisSlab;
import com.fedex.connect.common.model.sys.Role;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.manager.data.dto.LoginRequest;
import com.fedex.connect.manager.data.vo.JsonResult;
import com.fedex.connect.manager.service.AbstractEtService;
import com.fedex.connect.manager.service.system.IRedisUtilService;
import com.fedex.connect.manager.service.system.ISysAuthService;
import com.google.gson.JsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
/**
* 处理用户相关Service
* 包括创建用户token,用户的角色设置,角色的菜单设置
* @author EDY
*/
@Service
public class SysAuthServiceImpl extends AbstractEtService implements ISysAuthService {
private Logger logger = LoggerFactory.getLogger(SysAuthServiceImpl.class);
@Autowired
private SysRoleServiceImpl sysRoleInfoService;
@Autowired
private IRedisUtilService redisUtilService;
/**
* 根据用户登录信息创建token
* @param loginRequest
* @param user
* @return
*/
public JsonResult createAccessToken(LoginRequest loginRequest, User user) {
//2、创建token
List<String> roleCodeList = new ArrayList<>();
Role roleInfo = sysRoleInfoService.findRoleByUserId(user.getId());
if (roleInfo != null && roleInfo.getStatus() != null
&& DatabaseConstants.GLOBAL_STATUS_VALID.equals(roleInfo)){
roleCodeList.add("ROLE_" + roleInfo.getCode() + roleInfo.getCode());
}else{
roleCodeList.add("ROLE_" + UUID.randomUUID().toString());
}
//存进redis的token,8小时有效期
String token = JwtTokenUtils.createAccessToken(user.getAccNo(), user.getId().toString(), roleCodeList, loginRequest.getRememberMe());
try {
int redisExpireTime = loginRequest.getRememberMe() ? 8 : 2;
redisUtilService.set(RedisConstants.REDIS_KEY_TOKEN + user.getId(), token, redisExpireTime);
} catch (NullPointerException e) {
logger.error("***************** redis 异常:{} *********************", e);
return JsonResult.fail(ResponseCode.SYSTEM_EXECEPTION_CODE.getCode(), localeMessageUtil.getMessage("service_auth_token_reeids"), null);
}
return JsonResult.succ(token);
}
/**
* 根据用户登录信息创建token
* @param token token信息
* @return token key
*/
public JsonResult createFclToken(JsonObject token) {
String tokenKey = DatabaseConstants.FCL_PREFIX + UUID.randomUUID();
try {
/*redisUtilService.set(RedisConstants.REDIS_KEY_TOKEN + tokenKey, GsonUtils.beanToString(token), RedisConstants.REDIS_EXPRIE_TIME_1W);*/
redisUtilService.set(RedisConstants.REDIS_KEY_TOKEN + tokenKey, GsonUtils.beanToString(token), 1);
} catch (NullPointerException e) {
logger.error("***************** redis 异常:{} *********************", e);
return JsonResult.fail(ResponseCode.SYSTEM_EXECEPTION_CODE.getCode(), localeMessageUtil.getMessage("service_auth_token_reeids"), null);
}
return JsonResult.succ(tokenKey);
}
/**
* 根据token key 获取token
* @param tokenKey tokenkey
* @return token
*/
public JsonObject getFclToken(String tokenKey) {
RedisSlab redisSlab = redisUtilService.get(RedisConstants.REDIS_KEY_TOKEN + tokenKey);
String token = redisSlab != null ? Optional.ofNullable(redisSlab.getRedisMsg()).orElse(null): null;
//清除登录记录
if (token != null){
redisUtilService.del(RedisConstants.REDIS_KEY_TOKEN + tokenKey);
}
return GsonUtils.stringToBean(token, JsonObject.class);
}
}
package com.fedex.connect.manager.service.system.impl;
import com.fedex.connect.common.dependencies.config.CacheSystem;
import com.fedex.connect.common.dependencies.contants.DatabaseConstants;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.common.model.base.DictionaryEntries;
import com.fedex.connect.common.model.sys.Role;
import com.fedex.connect.common.model.sys.RoleExample;
import com.fedex.connect.common.model.sys.UserRole;
import com.fedex.connect.common.model.sys.UserRoleExample;
import com.fedex.connect.manager.data.model.LogShowModel;
import com.fedex.connect.manager.service.AbstractEtService;
import com.fedex.connect.manager.service.system.ISysRoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 处理角色相关Service
* @author EDY
*/
@Service
public class SysRoleServiceImpl extends AbstractEtService implements ISysRoleService {
private static Logger log = LoggerFactory.getLogger(SysRoleServiceImpl.class);
/**
* 根据用户ID获取用户角色
* @param userId
* @return
*/
public Role findRoleByUserId(Long userId){
try{
UserRole userRole = findUserRoleByUserId(userId);
if (userRole == null || userRole.getRoleId() == null || userRole.getRoleId() == 0){
return null;
}
return findById(userRole.getRoleId());
} catch (Exception e){
log.error(LogShowModel.showException("Exception",e));
return null;
}
}
/**
* 根据用户ID获取用户角色对应关系(一个用户只允许存在一个角色)
* @param userId
* @return
*/
public UserRole findUserRoleByUserId(Long userId){
try{
UserRoleExample example = new UserRoleExample();
UserRoleExample.Criteria criteria = example.createCriteria();
criteria.andStatusEqualTo(DatabaseConstants.GLOBAL_STATUS_VALID);
criteria.andUserIdEqualTo(userId);
example.setOrderByClause("CREATE_TIME DESC");
return Utils.first(userRoleRepository.selectByExample(example));
} catch (Exception e){
log.error(LogShowModel.showException("Exception",e));
return null;
}
}
/**
* 根据ID获取角色对象
* @param id
* @return
*/
public Role findById(Long id){
try{
return roleRepository.selectByPrimaryKey(id);
} catch (Exception e){
log.error(LogShowModel.showException("Exception",e));
return null;
}
}
/**
* 根据code获取角色信息(当前阶段,如果不存在,则创建默认角色)
* @param roleCode
* @return
*/
public Role findRoleByCode(String roleCode){
try{
RoleExample example = new RoleExample();
RoleExample.Criteria criteria = example.createCriteria();
criteria.andStatusEqualTo(DatabaseConstants.GLOBAL_STATUS_VALID);
criteria.andCodeEqualTo(roleCode);
List<Role> roleInfoList = roleRepository.selectByExample(example);
//如果不存在,创建默认角色
if (roleInfoList == null || roleInfoList.isEmpty()){
Role defaultRole = new Role();
defaultRole.setCode(DatabaseConstants.DICT_ROLE_DEFAULT_CODE);
defaultRole.setName(DatabaseConstants.DICT_ROLE_DEFAULT_CODE.toUpperCase());
defaultRole.setRoleDesc(DatabaseConstants.DICT_ROLE_DEFAULT_CODE.toUpperCase());
//从数据字典获取角色类型
List<DictionaryEntries> userTypeList = CacheSystem.dictionaryMap.get(DatabaseConstants.DICT_ROLE_GOOUP_CODE);
if (userTypeList != null && !userTypeList.isEmpty()){
Map<String,DictionaryEntries> userTypeDictMap = Utils.listOf(userTypeList).stream().filter(Objects::nonNull)
.collect(Collectors.toMap(DictionaryEntries::getCode, d -> d));
DictionaryEntries dictionary = userTypeDictMap.get(DatabaseConstants.DICT_ROLE_DEFAULT_CODE);
defaultRole.setTypeId(dictionary == null ? 0 : dictionary.getId());
} else {
defaultRole.setTypeId(0L);
}
defaultRole.setStatus(DatabaseConstants.GLOBAL_STATUS_VALID);
defaultRole.setCreateTime(new Date());
save(defaultRole);
return defaultRole;
} else {
return roleInfoList.get(0);
}
} catch (Exception e){
log.error(LogShowModel.showException("Exception",e));
return null;
}
}
/**
* 保存角色
* @param dao
* @return
*/
@Transactional(rollbackFor = Exception.class)
public int save(Role dao){
try{
return roleRepository.insert(dao);
} catch (Exception e){
log.error(LogShowModel.showException("Exception",e));
throw e;
}
}
}
package com.fedex.connect.manager.service.system.impl;
import com.fedex.connect.common.dependencies.contants.DatabaseConstants;
import com.fedex.connect.common.model.sys.UserRole;
import com.fedex.connect.manager.data.model.LogShowModel;
import com.fedex.connect.manager.service.AbstractEtService;
import com.fedex.connect.manager.service.system.ISysUserRoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
/**
* 处理用户角色Service
* @author EDY
*/
@Service
public class SysUserRoleServiceImpl extends AbstractEtService implements ISysUserRoleService {
private static Logger log = LoggerFactory.getLogger(SysUserRoleServiceImpl.class);
/**
* 保存用户角色关系
* @param userId
* @param roleId
* @return
*/
@Transactional(rollbackFor = Exception.class)
public int save(Long userId,Long roleId){
try{
UserRole userRole = new UserRole();
userRole.setUserId(userId);
userRole.setRoleId(roleId);
userRole.setStatus(DatabaseConstants.GLOBAL_STATUS_VALID);
userRole.setCreateTime(new Date());
userRole.setUpdateTime(new Date());
return userRoleRepository.insert(userRole);
} catch (Exception e){
log.error(LogShowModel.showException("Exception",e));
throw e;
}
}
}
package com.fedex.connect.manager.service.system.impl;
import com.fedex.connect.common.dependencies.arithmetic.AESUtil;
import com.fedex.connect.common.dependencies.authentication.EncryptProvider;
import com.fedex.connect.common.dependencies.config.CacheSystem;
import com.fedex.connect.common.dependencies.contants.DatabaseConstants;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.common.model.base.DictionaryEntries;
import com.fedex.connect.common.model.sys.Role;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.common.model.sys.UserExample;
import com.fedex.connect.manager.data.dto.SysUserDto;
import com.fedex.connect.manager.data.model.LogShowModel;
import com.fedex.connect.manager.service.AbstractEtService;
import com.fedex.connect.manager.service.system.ISysRoleService;
import com.fedex.connect.manager.service.system.ISysUserRoleService;
import com.fedex.connect.manager.service.system.ISysUserService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 用户相关操作
*/
@Service
public class SysUserServiceImpl extends AbstractEtService implements ISysUserService {
private static Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
@Autowired
private ISysRoleService sysRoleService;
@Autowired
private ISysUserRoleService sysUserRoleService;
/**
* 邮件过期时间
*/
@Value("${export.emailActiveTime}")
private String emailActiveTime ;
/**
* 根据FCL查询FCL用户信息
* @param fclUuid
* @return
*/
public User findUserByFcl(String fclUuid){
try{
String fcl_pwd = DatabaseConstants.FCL_PREFIX + "_" + fclUuid + "_pwd";
UserExample example = new UserExample();
UserExample.Criteria criteria = example.createCriteria();
criteria.andStatusEqualTo(DatabaseConstants.GLOBAL_STATUS_VALID);
criteria.andUserSourceEqualTo(DatabaseConstants.USER_SOURCE_FCL);
criteria.andAccNoEqualTo(fclUuid);
//criteria.andFedexAccNoEqualTo(fclUuid);
example.setOrderByClause("ID DESC");
//根据账号 Fedex账户,备注查询用户信息
List<User> userList = userRepository.selectByExample(example);
//查询出来的用户信息进行密码匹配
List<User> resultUserList = Utils.listOf(userList).stream().filter(Objects::nonNull)
.filter(u -> EncryptProvider.match(fcl_pwd, u.getPassword()))
.collect(Collectors.toList());
//返回匹配出来第一个账户信息
return Utils.first(resultUserList);
} catch (Exception e){
log.error(LogShowModel.showException("Exception",e));
return null;
}
}
/**
* 保存
* @param dto
* @return
*/
public User save(SysUserDto dto){
try{
User user = SysUserDto.dtoToDao(dto);
//从数据字典获取用户类型
List<DictionaryEntries> userTypeList = CacheSystem.dictionaryMap.get(DatabaseConstants.DICT_USER_GOOUP_CODE);
if (Utils.isNotEmpty(userTypeList)){
//从数据字典中获取用户类型
Map<String,DictionaryEntries> userTypeDictMap = Utils.listOf(userTypeList).stream().filter(Objects::nonNull)
.collect(Collectors.toMap(DictionaryEntries::getCode, d -> d));
DictionaryEntries dictionary = userTypeDictMap.get(dto.getTypeCode());
user.setTypeId(dictionary == null ? 0 : dictionary.getId());
} else{
user.setTypeId(0L);
}
//对新增账户的密码进行加密
user.setPassword(EncryptProvider.encrypt(user.getPassword()));
//对手机号进行可逆加密
if (!StringUtils.isBlank(user.getPhone())){
user.setPhone(AESUtil.encode_default(user.getPhone()));
}
//对用户姓名进行可逆加密
if (StringUtils.isNotBlank(user.getUserName())){
user.setUserName(user.getUserName());
}
int saveUserCt = saveSysUser(user);
//当前阶段,权限采用默认权限
if (saveUserCt > 0){
Role roleInfo = sysRoleService.findRoleByCode(DatabaseConstants.DICT_ROLE_DEFAULT_CODE);
//创建用户角色对应关系
sysUserRoleService.save(user.getId(), roleInfo.getId());
}
return user;
} catch (Exception e){
log.error(LogShowModel.showException("Exception",e));
return null;
}
}
@Transactional(rollbackFor = Exception.class)
public int saveSysUser(User user){
try{
return userRepository.insert(user);
} catch (Exception e){
log.error(LogShowModel.showException("Exception",e));
throw e;
}
}
/**
* 修改
* @param dao
* @return
*/
@Transactional(rollbackFor = Exception.class)
public int update(User dao){
try{
return userRepository.updateByPrimaryKeySelective(dao);
} catch (Exception e){
log.error(LogShowModel.showException("Exception",e));
throw e;
}
}
}