问题:redis序列化和cache问题

This commit is contained in:
wangiegie@gmail.com 2017-10-29 18:37:09 +08:00
parent a065e34309
commit dbdc947b3f
21 changed files with 956 additions and 14 deletions

View File

@ -11,7 +11,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
*/
@SpringBootApplication
@EnableDiscoveryClient
public class PigAdminApplication extends BaseController {
public class PigAdminApplication {
public static void main(String[] args) {
SpringApplication.run(PigAdminApplication.class, args);
}

View File

@ -1,4 +1,4 @@
package com.github.pig.common.web.config;
package com.github.pig.auth.config;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
@ -10,7 +10,7 @@ import org.springframework.context.annotation.Configuration;
* @date 2017/10/29
*/
@Configuration
@MapperScan("com.github.pig")
@MapperScan("com.github.pig.auth.mapper")
public class MybatisPlusConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {

View File

@ -1,16 +1,23 @@
package com.github.pig.auth.config;
import com.github.pig.common.web.constant.CommonConstant;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pig.common.constant.CommonConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
import org.springframework.security.oauth2.provider.token.store.InMemoryTokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
@ -47,7 +54,7 @@ public class PigAuthorizationConfig extends AuthorizationServerConfigurerAdapter
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints
.tokenStore(new RedisTokenStore(redisConnectionFactory))
.tokenStore(new InMemoryTokenStore())
.accessTokenConverter(jwtAccessTokenConverter())
.authenticationManager(authenticationManager)
.userDetailsService(userDetailsService);
@ -59,4 +66,5 @@ public class PigAuthorizationConfig extends AuthorizationServerConfigurerAdapter
jwtAccessTokenConverter.setSigningKey(CommonConstant.SIGN_KEY);
return jwtAccessTokenConverter;
}
}

View File

@ -0,0 +1,172 @@
package com.github.pig.auth.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import java.io.Serializable;
/**
* <p>
* 菜单权限表
* </p>
*
* @author lengleng
* @since 2017-10-29
*/
@TableName("sys_menu")
public class SysMenu extends Model<SysMenu> {
private static final long serialVersionUID = 1L;
/**
* 菜单ID
*/
@TableId(value="menu_id", type= IdType.AUTO)
private Integer menuId;
/**
* 菜单名称
*/
@TableField("menu_name")
private String menuName;
/**
* 菜单描述
*/
@TableField("menu_desc")
private String menuDesc;
private String url;
/**
* 父菜单ID
*/
@TableField("parent_id")
private Integer parentId;
/**
* 排序值
*/
private Integer sort;
/**
* 菜单类型 0菜单 1按钮
*/
private String type;
/**
* 创建时间
*/
@TableField("create_time")
private Date createTime;
/**
* 更新时间
*/
@TableField("update_time")
private Date updateTime;
/**
* 0--正常 1--删除
*/
@TableField("del_flag")
private String delFlag;
public Integer getMenuId() {
return menuId;
}
public void setMenuId(Integer menuId) {
this.menuId = menuId;
}
public String getMenuName() {
return menuName;
}
public void setMenuName(String menuName) {
this.menuName = menuName;
}
public String getMenuDesc() {
return menuDesc;
}
public void setMenuDesc(String menuDesc) {
this.menuDesc = menuDesc;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
@Override
protected Serializable pkVal() {
return this.menuId;
}
@Override
public String toString() {
return "SysMenu{" +
", menuId=" + menuId +
", menuName=" + menuName +
", menuDesc=" + menuDesc +
", url=" + url +
", parentId=" + parentId +
", sort=" + sort +
", type=" + type +
", createTime=" + createTime +
", updateTime=" + updateTime +
", delFlag=" + delFlag +
"}";
}
}

View File

@ -0,0 +1,118 @@
package com.github.pig.auth.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
/**
* <p>
* <p>
* </p>
*
* @author lengleng
* @since 2017-10-29
*/
@TableName("sys_role")
public class SysRole extends Model<SysRole> {
private static final long serialVersionUID = 1L;
@TableId(value = "role_id", type = IdType.AUTO)
private Integer roleId;
@TableField("role_name")
private String roleName;
@TableField("role_code")
private String roleCode;
@TableField("role_desc")
private String roleDesc;
@TableField("create_time")
private Date createTime;
@TableField("update_time")
private Date updateTime;
/**
* 删除标识0-正常,1-删除
*/
@TableField("del_flag")
private String delFlag;
public Integer getRoleId() {
return roleId;
}
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getRoleCode() {
return roleCode;
}
public void setRoleCode(String roleCode) {
this.roleCode = roleCode;
}
public String getRoleDesc() {
return roleDesc;
}
public void setRoleDesc(String roleDesc) {
this.roleDesc = roleDesc;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
@Override
protected Serializable pkVal() {
return this.roleId;
}
@Override
public String toString() {
return "SysRole{" +
", roleId=" + roleId +
", roleName=" + roleName +
", roleCode=" + roleCode +
", roleDesc=" + roleDesc +
", createTime=" + createTime +
", updateTime=" + updateTime +
", delFlag=" + delFlag +
"}";
}
}

View File

@ -0,0 +1,130 @@
package com.github.pig.auth.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import java.io.Serializable;
/**
* <p>
* 用户表
* </p>
*
* @author lengleng
* @since 2017-10-29
*/
@TableName("sys_user")
public class SysUser extends Model<SysUser> {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@TableId(value="user_id", type= IdType.AUTO)
private Integer userId;
/**
* 用户名
*/
private String username;
private String password;
/**
* 随机盐
*/
private String salt;
/**
* 创建时间
*/
@TableField("create_time")
private Date createTime;
/**
* 修改时间
*/
@TableField("update_time")
private Date updateTime;
/**
* 0-正常1-删除
*/
@TableField("del_flag")
private String delFlag;
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
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 getSalt() {
return salt;
}
public void setSalt(String salt) {
this.salt = salt;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
@Override
protected Serializable pkVal() {
return this.userId;
}
@Override
public String toString() {
return "SysUser{" +
", userId=" + userId +
", username=" + username +
", password=" + password +
", salt=" + salt +
", createTime=" + createTime +
", updateTime=" + updateTime +
", delFlag=" + delFlag +
"}";
}
}

View File

@ -0,0 +1,16 @@
package com.github.pig.auth.mapper;
import com.github.pig.auth.entity.SysMenu;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* <p>
* 菜单权限表 Mapper 接口
* </p>
*
* @author lengleng
* @since 2017-10-29
*/
public interface SysMenuMapper extends BaseMapper<SysMenu> {
}

View File

@ -0,0 +1,16 @@
package com.github.pig.auth.mapper;
import com.github.pig.auth.entity.SysRole;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author lengleng
* @since 2017-10-29
*/
public interface SysRoleMapper extends BaseMapper<SysRole> {
}

View File

@ -0,0 +1,23 @@
package com.github.pig.auth.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.github.pig.auth.entity.SysUser;
import com.github.pig.common.vo.UserVo;
/**
* <p>
* 用户表 Mapper 接口
* </p>
*
* @author lengleng
* @since 2017-10-29
*/
public interface SysUserMapper extends BaseMapper<SysUser> {
/**
* 通过用户名查询用户信息含有角色信息
*
* @param username 用户名
* @return userVo
*/
UserVo selectUserVoByUsername(String username);
}

View File

@ -4,6 +4,7 @@ import com.github.pig.auth.mapper.SysUserMapper;
import com.github.pig.common.vo.SysRole;
import com.github.pig.common.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

View File

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 从高到地低 OFF 、 FATAL 、 ERROR 、 WARN 、 INFO 、 DEBUG 、 TRACE 、 ALL -->
<!-- 日志输出规则 根据当前ROOT 级别日志输出时级别高于root默认的级别时 会输出 -->
<!-- 以下 每个配置的 filter 是过滤掉输出文件里面会出现高级别文件依然出现低级别的日志信息通过filter 过滤只记录本级别的日志-->
<!-- 属性描述 scan性设置为true时配置文件如果发生改变将会被重新加载默认值为true scanPeriod:设置监测配置文件是否有修改的时间间隔如果没有给出时间单位默认单位是毫秒。当scan为true时此属性生效。默认的时间间隔为1分钟。
debug:当此属性设置为true时将打印出logback内部日志信息实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 定义日志文件 输入位置 -->
<property name="log_dir" value="logs/ev_cmdb" />
<!-- 日志最大的历史 30天 -->
<property name="maxHistory" value="30"/>
<!-- ConsoleAppender 控制台输出日志 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- 对日志进行格式化 -->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger -%msg%n</pattern>
</encoder>
</appender>
<!-- ERROR级别日志 -->
<!-- 滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 RollingFileAppender-->
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 过滤器只记录WARN级别的日志 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责出发滚动 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志输出位置 可相对、和绝对路径 -->
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/error-log.log</fileNamePattern>
<!-- 可选节点,控制保留的归档文件的最大数量,超出数量就删除旧文件假设设置每个月滚动,且<maxHistory>是6
则只保存最近6个月的文件删除之前的旧文件。注意删除旧文件是那些为了归档而创建的目录也会被删除-->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
<!-- 按照固定窗口模式生成日志文件当文件大于20MB时生成新的日志文件。窗口大小是1到3当保存了3个归档文件后将覆盖最早的日志。
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/.log.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>3</maxIndex>
</rollingPolicy> -->
<!-- 查看当前活动文件的大小如果超过指定大小会告知RollingFileAppender 触发当前活动文件滚动
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>5MB</maxFileSize>
</triggeringPolicy> -->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<!-- WARN级别日志 appender -->
<appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 过滤器只记录WARN级别的日志 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/warn-log.log
</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<!-- INFO级别日志 appender -->
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 过滤器只记录INFO级别的日志 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/info-log.log
</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<!-- DEBUG级别日志 appender -->
<appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 过滤器只记录DEBUG级别的日志 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/debug-log.log
</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<!-- TRACE级别日志 appender -->
<appender name="TRACE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 过滤器只记录ERROR级别的日志 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>TRACE</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/trace-log.log
</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<!--<logger name="java.sql.PreparedStatement" value="DEBUG" />-->
<!--<logger name="java.sql.Connection" value="DEBUG" />-->
<!--<logger name="java.sql.Statement" value="DEBUG" />-->
<!--<logger name="com.ibatis" value="DEBUG" />-->
<!--<logger name="com.ibatis.common.jdbc.SimpleDataSource" value="DEBUG" />-->
<!--<logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG"/>-->
<!--<logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="DEBUG" />-->
<logger name="com.example.sbmp.mapper" level="DEBUG" additivity="true">
<appender-ref ref="STDOUT"/>
</logger>
<!-- root级别 DEBUG -->
<root level="DEBUG">
<!-- 控制台输出 -->
<appender-ref ref="STDOUT" />
<!-- 文件输出 -->
<appender-ref ref="ERROR" />
<appender-ref ref="INFO" />
<appender-ref ref="WARN" />
<appender-ref ref="DEBUG" />
<appender-ref ref="TRACE" />
</root>
</configuration>

View File

@ -0,0 +1,19 @@
<?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.github.pig.auth.mapper.SysMenuMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.github.pig.auth.entity.SysMenu">
<id column="menu_id" property="menuId" />
<result column="menu_name" property="menuName" />
<result column="menu_desc" property="menuDesc" />
<result column="url" property="url" />
<result column="parent_id" property="parentId" />
<result column="sort" property="sort" />
<result column="type" property="type" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="del_flag" property="delFlag" />
</resultMap>
</mapper>

View File

@ -0,0 +1,16 @@
<?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.github.pig.auth.mapper.SysRoleMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.github.pig.auth.entity.SysRole">
<id column="role_id" property="roleId" />
<result column="role_name" property="roleName" />
<result column="role_code" property="roleCode" />
<result column="role_desc" property="roleDesc" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="del_flag" property="delFlag" />
</resultMap>
</mapper>

View File

@ -0,0 +1,57 @@
<?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.github.pig.auth.mapper.SysUserMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.github.pig.auth.entity.SysUser">
<id column="user_id" property="userId"/>
<result column="username" property="username"/>
<result column="password" property="password"/>
<result column="salt" property="salt"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="del_flag" property="delFlag"/>
</resultMap>
<!-- userVo结果集 -->
<resultMap id="userVoResultMap" type="com.github.pig.common.vo.UserVo">
<id column="user_id" property="userId"/>
<result column="username" property="username"/>
<result column="password" property="password"/>
<result column="salt" property="salt"/>
<result column="ucreate_time" property="createTime"/>
<result column="uupdate_time" property="updateTime"/>
<collection property="roleList" ofType="com.github.pig.common.vo.SysRole">
<id column="role_id" property="roleId" />
<result column="role_name" property="roleName" />
<result column="role_code" property="roleCode" />
<result column="role_desc" property="roleDesc" />
<result column="rcreate_time" property="createTime" />
<result column="rupdate_time" property="updateTime" />
</collection>
</resultMap>
<select id="selectUserVoByUsername" resultMap="userVoResultMap">
SELECT
`user`.user_id,
`user`.username,
`user`.`password`,
`user`.salt,
`user`.create_time AS ucreate_time,
`user`.update_time AS uupdate_time,
r.role_id,
r.role_name,
r.role_code,
r.role_desc,
r.create_time AS rcreate_time,
r.update_time AS rupdate_time
FROM
sys_user AS `user`
LEFT JOIN sys_user_role AS ur ON ur.user_id = `user`.user_id
LEFT JOIN sys_role AS r ON r.role_id = ur.role_id
WHERE
`user`.del_flag = 0
AND r.del_flag = 0
AND `user`.username = #{username}
</select>
</mapper>

View File

@ -52,10 +52,6 @@
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

View File

@ -1,4 +1,4 @@
package com.github.pig.common.web.constant;
package com.github.pig.common.constant;
/**
* @author lengleng

View File

@ -1,4 +1,4 @@
package com.github.pig.common.web.util;
package com.github.pig.common.util;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
@ -39,13 +39,13 @@ public class MybatisPlusGenerator {
// 策略配置
StrategyConfig strategy = new StrategyConfig();
// strategy.setCapitalMode(true);// 全局大写命名 ORACLE 注意
strategy.setTablePrefix(new String[]{"tlog_", "tsys_"});// 此处可以修改为您的表前缀
//strategy.setTablePrefix(new String[]{"tlog_", "tsys_"});// 此处可以修改为您的表前缀
strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
mpg.setStrategy(strategy);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setParent("com.example.sbmp");
pc.setParent("com.github.pig.auth");
mpg.setPackageInfo(pc);
mpg.execute();

View File

@ -0,0 +1,94 @@
package com.github.pig.common.vo;
import java.util.Date;
/**
* <p>
* <p>
* </p>
*
* @author lengleng
* @since 2017-10-29
*/
public class SysRole {
private static final long serialVersionUID = 1L;
private Integer roleId;
private String roleName;
private String roleCode;
private String roleDesc;
private Date createTime;
private Date updateTime;
private String delFlag;
public Integer getRoleId() {
return roleId;
}
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getRoleCode() {
return roleCode;
}
public void setRoleCode(String roleCode) {
this.roleCode = roleCode;
}
public String getRoleDesc() {
return roleDesc;
}
public void setRoleDesc(String roleDesc) {
this.roleDesc = roleDesc;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
@Override
public String toString() {
return "SysRole{" +
", roleId=" + roleId +
", roleName=" + roleName +
", roleCode=" + roleCode +
", roleDesc=" + roleDesc +
", createTime=" + createTime +
", updateTime=" + updateTime +
", delFlag=" + delFlag +
"}";
}
}

View File

@ -0,0 +1,111 @@
package com.github.pig.common.vo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author lengleng
* @date 2017/10/29
*/
public class UserVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Integer userId;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 随机盐
*/
private String salt;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
/**
* 0-正常1-删除
*/
private String delFlag;
/**
* 角色列表
*/
private List<SysRole> roleList = new ArrayList<>();
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
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 getSalt() {
return salt;
}
public void setSalt(String salt) {
this.salt = salt;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public List<SysRole> getRoleList() {
return roleList;
}
public void setRoleList(List<SysRole> roleList) {
this.roleList = roleList;
}
}

View File

@ -1,6 +1,6 @@
package com.github.pig.common.web;
import com.github.pig.common.web.constant.CommonConstant;
import com.github.pig.common.constant.CommonConstant;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import org.apache.commons.lang.StringUtils;

View File

@ -2,6 +2,7 @@ package com.github.pig.gateway.service.impl;
import com.github.pig.gateway.service.PermissionService;
import org.apache.commons.lang.StringUtils;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;
import org.springframework.util.AntPathMatcher;