From dbdc947b3fd02f21a66eda7229036a58da401694 Mon Sep 17 00:00:00 2001 From: "wangiegie@gmail.com" Date: Sun, 29 Oct 2017 18:37:09 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9Aredis=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E5=92=8Ccache=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/pig/admin/PigAdminApplication.java | 2 +- .../pig/auth}/config/MybatisPlusConfig.java | 4 +- .../auth/config/PigAuthorizationConfig.java | 12 +- .../com/github/pig/auth/entity/SysMenu.java | 172 ++++++++++++++++++ .../com/github/pig/auth/entity/SysRole.java | 118 ++++++++++++ .../com/github/pig/auth/entity/SysUser.java | 130 +++++++++++++ .../github/pig/auth/mapper/SysMenuMapper.java | 16 ++ .../github/pig/auth/mapper/SysRoleMapper.java | 16 ++ .../github/pig/auth/mapper/SysUserMapper.java | 23 +++ .../auth/serivce/UserDetailServiceImpl.java | 1 + .../src/main/resources/logback.xml | 164 +++++++++++++++++ .../main/resources/mapper/SysMenuMapper.xml | 19 ++ .../main/resources/mapper/SysRoleMapper.xml | 16 ++ .../main/resources/mapper/SysUserMapper.xml | 57 ++++++ pig-common/pom.xml | 4 - .../{web => }/constant/CommonConstant.java | 2 +- .../{web => }/util/MybatisPlusGenerator.java | 6 +- .../com/github/pig/common/vo/SysRole.java | 94 ++++++++++ .../java/com/github/pig/common/vo/UserVo.java | 111 +++++++++++ .../github/pig/common/web/BaseController.java | 2 +- .../service/impl/PermissionServiceImpl.java | 1 + 21 files changed, 956 insertions(+), 14 deletions(-) rename {pig-common/src/main/java/com/github/pig/common/web => pig-auth-service/src/main/java/com/github/pig/auth}/config/MybatisPlusConfig.java (84%) create mode 100644 pig-auth-service/src/main/java/com/github/pig/auth/entity/SysMenu.java create mode 100644 pig-auth-service/src/main/java/com/github/pig/auth/entity/SysRole.java create mode 100644 pig-auth-service/src/main/java/com/github/pig/auth/entity/SysUser.java create mode 100644 pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysMenuMapper.java create mode 100644 pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysRoleMapper.java create mode 100644 pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysUserMapper.java create mode 100644 pig-auth-service/src/main/resources/logback.xml create mode 100644 pig-auth-service/src/main/resources/mapper/SysMenuMapper.xml create mode 100644 pig-auth-service/src/main/resources/mapper/SysRoleMapper.xml create mode 100644 pig-auth-service/src/main/resources/mapper/SysUserMapper.xml rename pig-common/src/main/java/com/github/pig/common/{web => }/constant/CommonConstant.java (87%) rename pig-common/src/main/java/com/github/pig/common/{web => }/util/MybatisPlusGenerator.java (90%) create mode 100644 pig-common/src/main/java/com/github/pig/common/vo/SysRole.java create mode 100644 pig-common/src/main/java/com/github/pig/common/vo/UserVo.java diff --git a/pig-admin-service/src/main/java/com/github/pig/admin/PigAdminApplication.java b/pig-admin-service/src/main/java/com/github/pig/admin/PigAdminApplication.java index 4cb4109d..91649352 100644 --- a/pig-admin-service/src/main/java/com/github/pig/admin/PigAdminApplication.java +++ b/pig-admin-service/src/main/java/com/github/pig/admin/PigAdminApplication.java @@ -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); } diff --git a/pig-common/src/main/java/com/github/pig/common/web/config/MybatisPlusConfig.java b/pig-auth-service/src/main/java/com/github/pig/auth/config/MybatisPlusConfig.java similarity index 84% rename from pig-common/src/main/java/com/github/pig/common/web/config/MybatisPlusConfig.java rename to pig-auth-service/src/main/java/com/github/pig/auth/config/MybatisPlusConfig.java index 136c0edf..5b2e6854 100644 --- a/pig-common/src/main/java/com/github/pig/common/web/config/MybatisPlusConfig.java +++ b/pig-auth-service/src/main/java/com/github/pig/auth/config/MybatisPlusConfig.java @@ -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() { diff --git a/pig-auth-service/src/main/java/com/github/pig/auth/config/PigAuthorizationConfig.java b/pig-auth-service/src/main/java/com/github/pig/auth/config/PigAuthorizationConfig.java index 8e2f128f..cf54a412 100644 --- a/pig-auth-service/src/main/java/com/github/pig/auth/config/PigAuthorizationConfig.java +++ b/pig-auth-service/src/main/java/com/github/pig/auth/config/PigAuthorizationConfig.java @@ -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; } + } diff --git a/pig-auth-service/src/main/java/com/github/pig/auth/entity/SysMenu.java b/pig-auth-service/src/main/java/com/github/pig/auth/entity/SysMenu.java new file mode 100644 index 00000000..46c817d5 --- /dev/null +++ b/pig-auth-service/src/main/java/com/github/pig/auth/entity/SysMenu.java @@ -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; + +/** + *

+ * 菜单权限表 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +@TableName("sys_menu") +public class SysMenu extends Model { + + 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 + + "}"; + } +} diff --git a/pig-auth-service/src/main/java/com/github/pig/auth/entity/SysRole.java b/pig-auth-service/src/main/java/com/github/pig/auth/entity/SysRole.java new file mode 100644 index 00000000..04d89830 --- /dev/null +++ b/pig-auth-service/src/main/java/com/github/pig/auth/entity/SysRole.java @@ -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; + +/** + *

+ *

+ *

+ * + * @author lengleng + * @since 2017-10-29 + */ +@TableName("sys_role") +public class SysRole extends Model { + + 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 + + "}"; + } +} diff --git a/pig-auth-service/src/main/java/com/github/pig/auth/entity/SysUser.java b/pig-auth-service/src/main/java/com/github/pig/auth/entity/SysUser.java new file mode 100644 index 00000000..eaa40174 --- /dev/null +++ b/pig-auth-service/src/main/java/com/github/pig/auth/entity/SysUser.java @@ -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; + +/** + *

+ * 用户表 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +@TableName("sys_user") +public class SysUser extends Model { + + 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 + + "}"; + } +} diff --git a/pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysMenuMapper.java b/pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysMenuMapper.java new file mode 100644 index 00000000..3976d72a --- /dev/null +++ b/pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysMenuMapper.java @@ -0,0 +1,16 @@ +package com.github.pig.auth.mapper; + +import com.github.pig.auth.entity.SysMenu; +import com.baomidou.mybatisplus.mapper.BaseMapper; + +/** + *

+ * 菜单权限表 Mapper 接口 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysMenuMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysRoleMapper.java b/pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysRoleMapper.java new file mode 100644 index 00000000..909e4a32 --- /dev/null +++ b/pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysRoleMapper.java @@ -0,0 +1,16 @@ +package com.github.pig.auth.mapper; + +import com.github.pig.auth.entity.SysRole; +import com.baomidou.mybatisplus.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysRoleMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysUserMapper.java b/pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysUserMapper.java new file mode 100644 index 00000000..9a32a528 --- /dev/null +++ b/pig-auth-service/src/main/java/com/github/pig/auth/mapper/SysUserMapper.java @@ -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; + +/** + *

+ * 用户表 Mapper 接口 + *

+ * + * @author lengleng + * @since 2017-10-29 + */ +public interface SysUserMapper extends BaseMapper { + /** + * 通过用户名查询用户信息(含有角色信息) + * + * @param username 用户名 + * @return userVo + */ + UserVo selectUserVoByUsername(String username); +} \ No newline at end of file diff --git a/pig-auth-service/src/main/java/com/github/pig/auth/serivce/UserDetailServiceImpl.java b/pig-auth-service/src/main/java/com/github/pig/auth/serivce/UserDetailServiceImpl.java index b7fab607..03eefc46 100644 --- a/pig-auth-service/src/main/java/com/github/pig/auth/serivce/UserDetailServiceImpl.java +++ b/pig-auth-service/src/main/java/com/github/pig/auth/serivce/UserDetailServiceImpl.java @@ -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; diff --git a/pig-auth-service/src/main/resources/logback.xml b/pig-auth-service/src/main/resources/logback.xml new file mode 100644 index 00000000..0eb03f07 --- /dev/null +++ b/pig-auth-service/src/main/resources/logback.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger -%msg%n + + + + + + + + + + ERROR + ACCEPT + DENY + + + + + ${log_dir}/%d{yyyy-MM-dd}/error-log.log + + ${maxHistory} + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + + + + WARN + ACCEPT + DENY + + + + ${log_dir}/%d{yyyy-MM-dd}/warn-log.log + + + ${maxHistory} + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + + + + INFO + ACCEPT + DENY + + + + ${log_dir}/%d{yyyy-MM-dd}/info-log.log + + + ${maxHistory} + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + + + + DEBUG + ACCEPT + DENY + + + + ${log_dir}/%d{yyyy-MM-dd}/debug-log.log + + + ${maxHistory} + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + + + + TRACE + ACCEPT + DENY + + + + ${log_dir}/%d{yyyy-MM-dd}/trace-log.log + + + ${maxHistory} + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pig-auth-service/src/main/resources/mapper/SysMenuMapper.xml b/pig-auth-service/src/main/resources/mapper/SysMenuMapper.xml new file mode 100644 index 00000000..20720c1f --- /dev/null +++ b/pig-auth-service/src/main/resources/mapper/SysMenuMapper.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/pig-auth-service/src/main/resources/mapper/SysRoleMapper.xml b/pig-auth-service/src/main/resources/mapper/SysRoleMapper.xml new file mode 100644 index 00000000..06989f16 --- /dev/null +++ b/pig-auth-service/src/main/resources/mapper/SysRoleMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/pig-auth-service/src/main/resources/mapper/SysUserMapper.xml b/pig-auth-service/src/main/resources/mapper/SysUserMapper.xml new file mode 100644 index 00000000..90d4f7ea --- /dev/null +++ b/pig-auth-service/src/main/resources/mapper/SysUserMapper.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pig-common/pom.xml b/pig-common/pom.xml index 2563aac7..58e718bc 100644 --- a/pig-common/pom.xml +++ b/pig-common/pom.xml @@ -52,10 +52,6 @@ - - org.springframework.boot - spring-boot-maven-plugin - diff --git a/pig-common/src/main/java/com/github/pig/common/web/constant/CommonConstant.java b/pig-common/src/main/java/com/github/pig/common/constant/CommonConstant.java similarity index 87% rename from pig-common/src/main/java/com/github/pig/common/web/constant/CommonConstant.java rename to pig-common/src/main/java/com/github/pig/common/constant/CommonConstant.java index ef30d448..2938a7a4 100644 --- a/pig-common/src/main/java/com/github/pig/common/web/constant/CommonConstant.java +++ b/pig-common/src/main/java/com/github/pig/common/constant/CommonConstant.java @@ -1,4 +1,4 @@ -package com.github.pig.common.web.constant; +package com.github.pig.common.constant; /** * @author lengleng diff --git a/pig-common/src/main/java/com/github/pig/common/web/util/MybatisPlusGenerator.java b/pig-common/src/main/java/com/github/pig/common/util/MybatisPlusGenerator.java similarity index 90% rename from pig-common/src/main/java/com/github/pig/common/web/util/MybatisPlusGenerator.java rename to pig-common/src/main/java/com/github/pig/common/util/MybatisPlusGenerator.java index a18efcf3..e95b7d2d 100644 --- a/pig-common/src/main/java/com/github/pig/common/web/util/MybatisPlusGenerator.java +++ b/pig-common/src/main/java/com/github/pig/common/util/MybatisPlusGenerator.java @@ -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(); diff --git a/pig-common/src/main/java/com/github/pig/common/vo/SysRole.java b/pig-common/src/main/java/com/github/pig/common/vo/SysRole.java new file mode 100644 index 00000000..7dd73a91 --- /dev/null +++ b/pig-common/src/main/java/com/github/pig/common/vo/SysRole.java @@ -0,0 +1,94 @@ +package com.github.pig.common.vo; + +import java.util.Date; + +/** + *

+ *

+ *

+ * + * @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 + + "}"; + } +} diff --git a/pig-common/src/main/java/com/github/pig/common/vo/UserVo.java b/pig-common/src/main/java/com/github/pig/common/vo/UserVo.java new file mode 100644 index 00000000..1a559332 --- /dev/null +++ b/pig-common/src/main/java/com/github/pig/common/vo/UserVo.java @@ -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 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 getRoleList() { + return roleList; + } + + public void setRoleList(List roleList) { + this.roleList = roleList; + } +} diff --git a/pig-common/src/main/java/com/github/pig/common/web/BaseController.java b/pig-common/src/main/java/com/github/pig/common/web/BaseController.java index b09d3c20..79a79006 100644 --- a/pig-common/src/main/java/com/github/pig/common/web/BaseController.java +++ b/pig-common/src/main/java/com/github/pig/common/web/BaseController.java @@ -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; diff --git a/pig-gateway/src/main/java/com/github/pig/gateway/service/impl/PermissionServiceImpl.java b/pig-gateway/src/main/java/com/github/pig/gateway/service/impl/PermissionServiceImpl.java index 74fc8f3a..a050e3b4 100644 --- a/pig-gateway/src/main/java/com/github/pig/gateway/service/impl/PermissionServiceImpl.java +++ b/pig-gateway/src/main/java/com/github/pig/gateway/service/impl/PermissionServiceImpl.java @@ -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;