Commit 153d1234 by fengshuonan

Merge branch 'ultimate'

# Conflicts:
#	README.md
#	src/main/webapp/assets/common/static/stylefeng/feng.js
parents e73ac7e6 71fb4619
...@@ -31,3 +31,8 @@ hs_err_pid* ...@@ -31,3 +31,8 @@ hs_err_pid*
.classpath .classpath
.project .project
.settings/ .settings/
.DS_Store
_dockerCerts/
# Guns V5.1 # Guns旗舰版v1.0 震撼发布
## 介绍 ## 介绍
Guns基于SpringBoot 2,致力于做更简洁的后台管理系统,完美整合springmvc + shiro + mybatis-plus + beetl!Guns项目代码简洁,注释丰富,上手容易,同时Guns包含许多基础模块(用户管理,角色管理,部门管理,字典管理等10个模块),可以直接作为一个后台管理系统的脚手架! 2018目标 `更简洁``更规范`! Guns基于SpringBoot 2,致力于做更简洁的后台管理系统,完美整合springmvc + shiro + mybatis-plus + beetl!Guns项目代码简洁,注释丰富,上手容易,同时Guns包含许多基础模块(用户管理,角色管理,部门管理,字典管理等10个模块),可以直接作为一个后台管理系统的脚手架!
## 旗舰版抢先看 ### Guns旗舰版v1.0 更新内容
Guns旗舰版预计12月底发布第一个版本,目前功能尚不完善,demo地址(admin/111111):[http://demo.stylefeng.cn](http://demo.stylefeng.cn),不要再问旗舰版收不收费,不然我真的就收费了 :smiling_imp: :smiling_imp:
### Guns v5.1更新内容 > * 前端页面风格和架构焕然一新,全面升级bootstrap 4.0,您现在拥有两种界面风格可选
> * 引入vue.js,实现业务数据双向绑定,不增加学习成本的情况下,提升自己的开发效率
> * 优化前端框架结构,加载速度更快,使用更加灵活可配置
> * 前后端代码整体重构,逻辑更加清晰,代码量更加简洁,增加关键部分注释,代码的可读性提高
> * 增加docker-maven-plugin插件,可一键部署项目到装有docker的服务器
> * 重构shiro部分的业务代码和配置,更加清晰简洁
> * 规范后端数据库设计,字段和表的命名都修改为下划线命名,将以往的全小写命名去除
> * 框架整体的包名变为cn开头,和域名stylefeng.cn保持一致! ## 旗舰版在线demo
> * 优化了shiro相关的几个服务类的结构,整体业务逻辑不变,优化了部分包结构和类之间的关系,项目整体更加简洁和易维护! demo地址(admin/111111):[http://demo.stylefeng.cn](http://demo.stylefeng.cn)
> * 整合了guns-core,和roses项目的kernel-core,并把kernel-core上传到了maven的中央仓库!
> * 剔除了guns-generator模块,抽出单独的项目https://gitee.com/stylefeng/guns-generator来维护,并且guns-generator也上传到了maven中央仓库!
> * 框架整体回归了单模块应用,返璞归真,开箱即用,快速开发新项目,新业务!
**另外更新了Guns技术文档的版本到5.1,与项目版本保持一致,详情见文档详情!**
## 最新Guns技术文档 ## 最新Guns技术文档
Guns框架有作者在业余时间整理的技术文档,详情点击[查看详情](https://gitee.com/stylefeng/guns/wikis/pages?title=Guns%E6%8A%80%E6%9C%AF%E6%96%87%E6%A1%A3&parent=) Guns框架有作者在业余时间整理的技术文档,详情点击[查看详情](https://gitee.com/stylefeng/guns/wikis/pages?title=Guns%E6%8A%80%E6%9C%AF%E6%96%87%E6%A1%A3&parent=)
...@@ -23,7 +23,7 @@ Guns框架有作者在业余时间整理的技术文档,详情点击[查看详 ...@@ -23,7 +23,7 @@ Guns框架有作者在业余时间整理的技术文档,详情点击[查看详
Guns框架有作者在业余时间录制的视频教程,详情点击[教程介绍](https://gitee.com/stylefeng/guns/wikis/pages?title=Guns%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B&parent=) Guns框架有作者在业余时间录制的视频教程,详情点击[教程介绍](https://gitee.com/stylefeng/guns/wikis/pages?title=Guns%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B&parent=)
## 技术讨论 & [wiki地址](https://gitee.com/stylefeng/guns/wikis/Home) ## 技术讨论 & [wiki地址](https://gitee.com/stylefeng/guns/wikis/Home)
如果对项目有任何疑问或者建议,欢迎加入Guns技术交流1群:254550081,Guns技术交流2群:684163663,Guns技术交流3群:207434260(加之前先看下文档guns-admin/doc/Guns技术文档 v1.0.pdf) 如果对项目有任何疑问或者建议,欢迎加入Guns技术交流1群:254550081,Guns技术交流2群:684163663,Guns技术交流3群:207434260
## 管理系统功能 ## 管理系统功能
1.用户管理 2.角色管理 3.部门管理 4.菜单管理 5.字典管理 6.业务日志 7.登录日志 8.监控管理 9.通知管理 10.代码生成 1.用户管理 2.角色管理 3.部门管理 4.菜单管理 5.字典管理 6.业务日志 7.登录日志 8.监控管理 9.通知管理 10.代码生成
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<dependency> <dependency>
<groupId>cn.stylefeng.roses</groupId> <groupId>cn.stylefeng.roses</groupId>
<artifactId>kernel-core</artifactId> <artifactId>kernel-core</artifactId>
<version>1.1.0</version> <version>1.1.2</version>
</dependency> </dependency>
<dependency> <dependency>
...@@ -149,6 +149,12 @@ ...@@ -149,6 +149,12 @@
<version>${jwt.version}</version> <version>${jwt.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!--需要分布式session的话需要放开注释--> <!--需要分布式session的话需要放开注释-->
<!--<dependency>--> <!--<dependency>-->
<!--<groupId>org.springframework.session</groupId>--> <!--<groupId>org.springframework.session</groupId>-->
...@@ -161,6 +167,7 @@ ...@@ -161,6 +167,7 @@
</dependencies> </dependencies>
<build> <build>
<finalName>${project.artifactId}</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
...@@ -174,6 +181,13 @@ ...@@ -174,6 +181,13 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration> <configuration>
<fork>true</fork><!-- 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart --> <fork>true</fork><!-- 如果没有该项配置,肯呢个devtools不会起作用,即应用不会restart -->
</configuration> </configuration>
...@@ -188,6 +202,30 @@ ...@@ -188,6 +202,30 @@
<useDefaultDelimiters>false</useDefaultDelimiters> <useDefaultDelimiters>false</useDefaultDelimiters>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.26.1</version>
<configuration>
<dockerHost>tcp://demo.stylefeng.cn:2376</dockerHost>
<certPath>_dockerCerts</certPath>
<images>
<image>
<alias>service</alias>
<name>stylefeng/${project.artifactId}:latest</name>
<build>
<from>java:8</from>
<assembly>
<descriptor>docker-assembly.xml</descriptor>
</assembly>
<cmd>
<shell>java -jar /maven/${project.artifactId}.jar</shell>
</cmd>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins> </plugins>
<resources> <resources>
<resource> <resource>
......
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<files>
<file>
<source>target/${project.artifactId}.jar</source>
<destName>${project.artifactId}.jar</destName>
</file>
</files>
</assembly>
\ No newline at end of file
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
package cn.stylefeng.guns; package cn.stylefeng.guns;
import cn.stylefeng.guns.generator.config.GeneratorAutoConfiguration;
import cn.stylefeng.roses.core.config.WebAutoConfiguration; import cn.stylefeng.roses.core.config.WebAutoConfiguration;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -27,7 +28,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; ...@@ -27,7 +28,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* @author stylefeng * @author stylefeng
* @Date 2017/5/21 12:06 * @Date 2017/5/21 12:06
*/ */
@SpringBootApplication(exclude = WebAutoConfiguration.class) @SpringBootApplication(exclude = {WebAutoConfiguration.class, GeneratorAutoConfiguration.class})
public class GunsApplication { public class GunsApplication {
private final static Logger logger = LoggerFactory.getLogger(GunsApplication.class); private final static Logger logger = LoggerFactory.getLogger(GunsApplication.class);
......
...@@ -44,7 +44,7 @@ import java.util.HashMap; ...@@ -44,7 +44,7 @@ import java.util.HashMap;
@Configuration @Configuration
@ConditionalOnProperty(prefix = "guns.muti-datasource", name = "open", havingValue = "true") @ConditionalOnProperty(prefix = "guns.muti-datasource", name = "open", havingValue = "true")
@EnableTransactionManagement(order = 2, proxyTargetClass = true) @EnableTransactionManagement(order = 2, proxyTargetClass = true)
@MapperScan(basePackages = {"cn.stylefeng.guns.modular.*.dao", "cn.stylefeng.guns.multi.mapper"}) @MapperScan(basePackages = {"cn.stylefeng.guns.modular.*.mapper", "cn.stylefeng.guns.multi.mapper"})
public class MultiDataSourceConfig { public class MultiDataSourceConfig {
/** /**
......
...@@ -15,14 +15,10 @@ ...@@ -15,14 +15,10 @@
*/ */
package cn.stylefeng.guns.config.datasource; package cn.stylefeng.guns.config.datasource;
import cn.stylefeng.roses.core.config.properties.DruidProperties;
import cn.stylefeng.roses.core.datascope.DataScopeInterceptor; import cn.stylefeng.roses.core.datascope.DataScopeInterceptor;
import com.alibaba.druid.pool.DruidDataSource;
import com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor; import com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
...@@ -36,37 +32,10 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; ...@@ -36,37 +32,10 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration @Configuration
@ConditionalOnProperty(prefix = "guns.muti-datasource", name = "open", havingValue = "false", matchIfMissing = true) @ConditionalOnProperty(prefix = "guns.muti-datasource", name = "open", havingValue = "false", matchIfMissing = true)
@EnableTransactionManagement @EnableTransactionManagement
@MapperScan(basePackages = {"cn.stylefeng.guns.modular.*.dao"}) @MapperScan(basePackages = {"cn.stylefeng.guns.modular.*.mapper"})
public class SingleDataSourceConfig { public class SingleDataSourceConfig {
/** /**
* druid配置
*/
@Bean
@ConfigurationProperties(prefix = "spring.datasource")
public DruidProperties druidProperties() {
return new DruidProperties();
}
/**
* 单数据源连接池配置
*/
@Bean
public DruidDataSource dataSource(DruidProperties druidProperties) {
DruidDataSource dataSource = new DruidDataSource();
druidProperties.config(dataSource);
return dataSource;
}
/**
* mybatis-plus分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
/**
* 数据范围mybatis插件 * 数据范围mybatis插件
*/ */
@Bean @Bean
......
...@@ -43,6 +43,8 @@ import java.util.HashMap; ...@@ -43,6 +43,8 @@ import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import static cn.stylefeng.guns.core.common.constant.Const.NONE_PERMISSION_RES;
/** /**
* shiro权限管理的配置 * shiro权限管理的配置
* *
...@@ -175,11 +177,9 @@ public class ShiroConfig { ...@@ -175,11 +177,9 @@ public class ShiroConfig {
* *
*/ */
Map<String, String> hashMap = new LinkedHashMap<>(); Map<String, String> hashMap = new LinkedHashMap<>();
hashMap.put("/static/**", "anon"); for (String nonePermissionRe : NONE_PERMISSION_RES) {
hashMap.put("/gunsApi/**", "anon"); hashMap.put(nonePermissionRe, "anon");
hashMap.put("/login", "anon"); }
hashMap.put("/global/sessionError", "anon");
hashMap.put("/kaptcha", "anon");
hashMap.put("/**", "user"); hashMap.put("/**", "user");
shiroFilter.setFilterChainDefinitionMap(hashMap); shiroFilter.setFilterChainDefinitionMap(hashMap);
return shiroFilter; return shiroFilter;
...@@ -192,7 +192,7 @@ public class ShiroConfig { ...@@ -192,7 +192,7 @@ public class ShiroConfig {
public MethodInvokingFactoryBean methodInvokingFactoryBean(DefaultWebSecurityManager securityManager) { public MethodInvokingFactoryBean methodInvokingFactoryBean(DefaultWebSecurityManager securityManager) {
MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean(); MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
bean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager"); bean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
bean.setArguments(new Object[]{securityManager}); bean.setArguments(securityManager);
return bean; return bean;
} }
......
...@@ -17,6 +17,7 @@ package cn.stylefeng.guns.config.web; ...@@ -17,6 +17,7 @@ package cn.stylefeng.guns.config.web;
import cn.stylefeng.guns.config.properties.GunsProperties; import cn.stylefeng.guns.config.properties.GunsProperties;
import cn.stylefeng.guns.core.common.controller.GunsErrorView; import cn.stylefeng.guns.core.common.controller.GunsErrorView;
import cn.stylefeng.guns.core.interceptor.AttributeSetInteceptor;
import cn.stylefeng.guns.core.interceptor.RestApiInteceptor; import cn.stylefeng.guns.core.interceptor.RestApiInteceptor;
import cn.stylefeng.guns.core.listener.ConfigListener; import cn.stylefeng.guns.core.listener.ConfigListener;
import cn.stylefeng.roses.core.xss.XssFilter; import cn.stylefeng.roses.core.xss.XssFilter;
...@@ -44,6 +45,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; ...@@ -44,6 +45,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.Arrays; import java.util.Arrays;
import java.util.Properties; import java.util.Properties;
import static cn.stylefeng.guns.core.common.constant.Const.NONE_PERMISSION_RES;
/** /**
* web 配置类 * web 配置类
* *
...@@ -57,13 +60,18 @@ public class WebConfig implements WebMvcConfigurer { ...@@ -57,13 +60,18 @@ public class WebConfig implements WebMvcConfigurer {
private GunsProperties gunsProperties; private GunsProperties gunsProperties;
/** /**
* 增加swagger的支持 * 静态资源映射
*/ */
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
if (gunsProperties.getSwaggerOpen()) { if (gunsProperties.getSwaggerOpen()) {
//swagger
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
//本应用
registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/assets/");
} }
} }
...@@ -73,6 +81,7 @@ public class WebConfig implements WebMvcConfigurer { ...@@ -73,6 +81,7 @@ public class WebConfig implements WebMvcConfigurer {
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new RestApiInteceptor()).addPathPatterns("/gunsApi/**"); registry.addInterceptor(new RestApiInteceptor()).addPathPatterns("/gunsApi/**");
registry.addInterceptor(new AttributeSetInteceptor()).excludePathPatterns(NONE_PERMISSION_RES).addPathPatterns("/**");
} }
/** /**
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package cn.stylefeng.guns.core.beetl; package cn.stylefeng.guns.core.beetl;
import cn.stylefeng.guns.core.tag.DictSelectorTag; import cn.stylefeng.guns.core.util.DefaultImages;
import cn.stylefeng.guns.core.util.KaptchaUtil; import cn.stylefeng.guns.core.util.KaptchaUtil;
import cn.stylefeng.roses.core.util.ToolUtil; import cn.stylefeng.roses.core.util.ToolUtil;
import org.beetl.core.Context; import org.beetl.core.Context;
...@@ -38,15 +38,13 @@ public class BeetlConfiguration extends BeetlGroupUtilConfiguration { ...@@ -38,15 +38,13 @@ public class BeetlConfiguration extends BeetlGroupUtilConfiguration {
@Autowired @Autowired
private Environment env; private Environment env;
@Autowired
private DictSelectorTag dictSelectorTag;
@Override @Override
public void initOther() { public void initOther() {
groupTemplate.registerFunctionPackage("images", new DefaultImages());
groupTemplate.registerFunctionPackage("shiro", new ShiroExt()); groupTemplate.registerFunctionPackage("shiro", new ShiroExt());
groupTemplate.registerFunctionPackage("tool", new ToolUtil()); groupTemplate.registerFunctionPackage("tool", new ToolUtil());
groupTemplate.registerFunctionPackage("kaptcha", new KaptchaUtil()); groupTemplate.registerFunctionPackage("kaptcha", new KaptchaUtil());
groupTemplate.registerTagFactory("dictSelector", () -> dictSelectorTag);
groupTemplate.registerFunction("env", new Function() { groupTemplate.registerFunction("env", new Function() {
@Override @Override
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
*/ */
package cn.stylefeng.guns.core.common.constant; package cn.stylefeng.guns.core.common.constant;
import cn.hutool.core.collection.CollectionUtil;
import java.util.List;
/** /**
* 系统常量 * 系统常量
* *
...@@ -36,16 +40,21 @@ public interface Const { ...@@ -36,16 +40,21 @@ public interface Const {
/** /**
* 管理员id * 管理员id
*/ */
Integer ADMIN_ID = 1; Long ADMIN_ID = 1L;
/** /**
* 超级管理员角色id * 超级管理员角色id
*/ */
Integer ADMIN_ROLE_ID = 1; Long ADMIN_ROLE_ID = 1L;
/** /**
* 接口文档的菜单名 * 接口文档的菜单名
*/ */
String API_MENU_NAME = "接口文档"; String API_MENU_NAME = "接口文档";
/**
* 不需要权限验证的资源表达式
*/
List<String> NONE_PERMISSION_RES = CollectionUtil.newLinkedList("/assets/**", "/gunsApi/**", "/login", "/global/sessionError", "/kaptcha", "/error", "/global/error");
} }
...@@ -23,7 +23,14 @@ package cn.stylefeng.guns.core.common.constant; ...@@ -23,7 +23,14 @@ package cn.stylefeng.guns.core.common.constant;
*/ */
public interface DatasourceEnum { public interface DatasourceEnum {
String DATA_SOURCE_GUNS = "dataSourceGuns"; //guns数据源 /**
* guns数据源
*/
String DATA_SOURCE_GUNS = "dataSourceGuns";
/**
* 其他业务的数据源(第二个数据库)
*/
String DATA_SOURCE_BIZ = "dataSourceBiz";
String DATA_SOURCE_BIZ = "dataSourceBiz"; //其他业务的数据源
} }
/**
* Copyright 2018-2020 stylefeng & fengshuonan (sn93@qq.com)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.stylefeng.guns.core.common.constant;
/**
* 默认的头像base64编码
*
* @author fengshuonan
* @date 2018-11-10-12:12 PM
*/
public class DefaultAvatar {
public static final String BASE_64_AVATAR = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAARCABjAGQDASIAAhEBAxEB/8QAHAAAAgIDAQEAAAAAAAAAAAAAAAkHCAUGCgQD/8QAPBAAAQMDAgMGBAQEBAcAAAAAAQIDBAUGEQAHCBIhCRMUMUFhIjJRcSNygZEVFiRCF0OCoRhSYnODosH/xAAXAQEBAQEAAAAAAAAAAAAAAAAAAQID/8QAGhEBAQEBAQEBAAAAAAAAAAAAAAECEQMxIf/aAAwDAQACEQMRAD8Aahozo0aA0Z0aXp2jXaFyNmi/sxs1UWzd77eKnU0YUKYhQ+RHp3pHr6aCynETxqbC8NENxF9XQmXW+TmaodN5X5q/pzJyA2PdZHtnS79yu2m3cq0txna3bi37fg5IQ7UlOTpJHocgobH25T99LwrNaq1xVORWq7UpE+fLcLr8iQ4VuOLJySSepOdeLQWorfad8a1alKkDeBUBBJKWYdIhNoT7D8HJ/UnWWsrtVeMi05okVO+4FzR/WLVqTHKD/rZQhz/21Vm0rTrl73JS7Ut2EuTUKxOYp0ZABwXnlhCAT6ZJ/YH6ax9QgyaZOkU6Y2W34rqmXUn+1STgj9xoG88PnbH2Td0+Lbm/FoC1ZUhSWxWKatT0EKPq42rLjY9wV/ppiVAuCh3TR4twW3VotSps5oPRpUV0ONOoPkUqHQ65bghRSVhJKU+Zx0Grb8CfHXd3DPd0W2bknyalt/UnktzILiirwRUcd+zn5SPUeRGgfVo14aHW6XclGhXBRJjcuBUWESYz7ZylxtYykj9Dr3aA0aNGgNGjRoIY4vN94XDtsRcW4TjyE1BLBiUpsnq5LcBCAPt5/prnWr1drV316fcVdmuzajUX1yZL7qsqWtRySTpkfbJbk1m59xrR2OoKHnm6ZEVVZTDYzzvODKTj1AbGdLcpUXvIlRl5GI7KUn/WoJ/+6DKV2iQaZb1ux47KnatVkOTninr+EpXIygD65Q4T906sTuNwiVjafZzbmiVCiO1Ddfd+qpVApyUkqgU9tKcNY9HFuOslR/tSCPrqNrbtG8axvXT27M29n3q5ShBcbp0ZtZQ7iO2oJKkj4RzEn99NR4TNnOIq6t2Le3S4l7DplCh2LRZsa1ozK8uNPy3G+bnSpSlZShLnxE+a/YaDG8PHBLb2y+7G19nOMMzZ1pUGXeFyzwjIl1eQoRoqAT5NtJRL5B9cnzOl+do1sRK2Q4mLiEaGpqhXS8qt0tYThHK8eZxsfkWVJx9ANPmj2vCj3hPvJLqzLqFNiUxaD8qW47shxJHuTKXn7DUGcc/DRZHEZs3Oj3FITTarbrTs+l1QNlSmFhPxIUAMqQrABA9cY0CkNh9gf564O97N0DE7yRQn4HhFFPUBklbnKfcOgH7aqxpunCHUNrLJ4Ern2/uCtIfn1Ryqxqz3DSleBdWFCOZCcZbScIwojGlNv0sNfxEB4K8A73fTqFjnKcg6B3HZL7wPbj8NX8o1OWp6oWROVT/iVlXhnMra/wB+cfoNXb0oLsTrnksbpX9Z/OfDy6E3UOX0Ljb7aAf2cVpvvvoDRo0aA0aNGgpPxe8N1v09zdTidqUtM64pFuJpVvw8ZLSiyhohII6uFWSnl69dLr4LuFJO6+8dT2U3npdwWt46kCoJSuMWJJDSwsYDg8lAEZxpxXEFGqMabZ12Kos2rUW36i7JqDEOC5NcZcU3ysSfDt5W6ltWSQgFWD0+usNtDW27tuKZdFz1WDXajBQI8CqubfzaAthLhwWG5Etai9n1SjHvrOtcS1ru6tY254A+GStXTt3ZjClUeOxGjhQy9MlLUllpch3HMoBRST9ADgDVR+AHtCOIbeXiEgbUX8mn1umXNImTXJCGC0umttRXHAhvBx3fM2gYVk/EepyNMM3R27sveazKttjftNVOo1Ya7qQ2lRSpJB5krSofKpKgFA/UDUacL/A5slwsVipXHYLNWqFaqTJjKqFWkIedZjlQUWm+RCEpBKU5OCTgdcdNYz6S/Vubifqyml58fnaN35w27ntbT7b2zR5MpiLGnTZ89S18vP8AF3QbTjzQU/FzevlphQVkfTVE+O3s55PFFfcLcyyL2gUGt+FRCqDNRZcUxIQjohxKkAqSoJwnHLg4HUa6WyHWHodatLii2pjcXOz1sMUi96GlcW76I2gdzWIoH9VGeSBh08hUtCiM6VrfduRKLbFcuVmGqI3X7lej0+OtHKURGypw4HpyqKUHTxuDrhnp/CltaNvWbiFbqEuUqdUZga7pDjyhjCEEkhIAwCTk+2qubx9mvee/9yKDN6U60qNQnpqmFuw1yV1CZJe7x50JBRyN/KAokk9emszcqXsvKjbsTbOlv7i3/fpbV4SJR2qXzY6d668hwDP5WlabtqpHARswnhZodZ2EuhTLt1yH117+IxwTGqcLKW0qaJwrLZICkqAILgxkddW31tRo0dfro0Bo0ax1w3BSLVoVQuSvTW4dOpkdyVKfcOEttISVKJ/QaDR9/t/tveHLb+ZuDuFUwzHaBRFioIL81/GUtNp9SfU+QHU6Wzsnxkb68anE1JsRNbatm3KhSpjlLpTCOduM8wnvWXVL6KU5zJGVeWCQBjVVONvisuDii3Zm1gynmrWpLq4tCg83wIZBx3pHqteMk++rHdjBt09V94Lo3IeZ/pqBSvBsuY/z3iARn8mdDnTT7KueZWabCjXdTWaDcy0KEmluSW1rKkdFONcqiVtE9UnAOD1AOtxEVLjLjK88riShWFFJwfoR1Go+39f2updiSq3udbbFZiRFIEWL3IckPSVqCGm2PUOKWoJTgjqdR3QrCvanWiu4KZd192TKaZXINDZrCK7yJCeZLaPGoUkKIwOQAAHoDjrrnMSXqXt+tfq/CFdFzzFWjc1Yp0+2WHx4e4pkqVJryoOQUxcKUGkOpGUeKypak4PKF/HqzqYLcCGxCY5i3HbS0jmUVHlAwMk9SdRptVd12Jtar1u8LplV2LGfcciTX4LDCnYiEBQcSGEpSsKByCB19Omomj7k8Q+9VXm2pbF4WrZKnabFrrCI8BybJECSpYaZdf70JadIQSeVGRzApONXWewqeKjd1Dp12wLPiFU2uzh3yorPxGMwPN54/wCWj0Geqj5ZwdYS/wCl7J2RcMHcC6bHDlwLc5o1SptsyJ00rA8lORmVqA/OQNePYw2/bVQnWHVLRXb94JT4ua4/JVLVVk+XiUSl/G8M+YV8Sft114eOPu2uEzc6SVrbcj0CQ60tCyhSVpGUkEEHz1M+ci6t1e1mLJj3Df8AuendKp25PoNEpNKdpdHjVFAbly1vOIW5IW2CS0kBsJSlXxHmJIGBmXdUF7KPiur281jVPai/6y7UbitJtL0SVIXzOyIBIThRPVRQopGT1wofTV+tdCTg0aNGgNLn7YHiOesywKZsPbk4tVG6x4yqltWFJgoVhKD+daTn2SPrpjGueXj/AN0Ht1uKy+ayJPfQqbONIg4OU9xH/DBH35SfudBXbT1ezR2tZ2L4TWrvuNoQ5lx97XpqnBgoYSk90FfZIJ/XSiuE3ZSdv7vza+3kdlSoj8tMmorAyG4jZCnCfbGB+unj8QZbdoNrcPFpLMV27HG4TwZ6GLSGEgvr6eXwp5B7nQaq5eat9dwdk3n6c5Dpk5VRu4xXevOiKhSIqiPoVuMugfbUpbi7rWZtcIzN0TnVT5xIh02EwqRMk48yhpHXA+pwPfWm3HSptp757eVqiUB56lx7fq1Bjojt5Qw8W2nWUqx8qSI5SCfUgay+3Vnt7X2fXd9N2VJmXlNgPVitS1jm/h8ZCC4IbGfkbbQMHHzKCifPQaRS9sw2yKFb+/sy27PqIblxKA0qPHmRWnWkEMB1f4rafXl8xzEamPaTZCwNnaMKTZNIRFbXyqeeUsuvPqAwFOOK6qONQVYZi7v3nAt7f7ZO3o9Svi2l3NSahDe53BExH52HeoUh1sym083qUnHQDUn8OdyVCn0m4dqboqTsur7fVV2lB59WXpEA/iQ3lE+ZLC28q9SDoNqr1q1mp7xWzdSGWm6ZQaZNbLvP8br0gpTyY+iQgHP/AFajTtCHnGuD3cotkjno7iT9j56+m424FT3MviJtptvUH/A0SS3PumrwjzCO22eZMNtQ6KdWR1A8h99eHiwrNH3X4LNyqja8sTGV0KWlOEkKS610UhST1CgQcg6BOvAbvYNieJe1LpmyizSJz/8ACqoc/D4Z/wCAqP15SQr7jXQ6lSVpC0KBSoZBHkRrlfbcW04l1tRSpBCkkehGuibgX3dO9XC/ZN2ypPfVGLCFJqJKsq8RG/DJV7qQELP5tBPejRo0GubkVefQNu7or1KQVzabRZsuMkDJLrbC1IAH3A1zF1eZKqNVmT5ri3JEh9xx1SzlRUVEnOupV1tt5tTLyErQtJSpKhkKB8wRqnlydlJwk3HeRvBVEr0BLjyn3qXDqIRCcUTk5SpBWB18krGgiPsgeHRyy7Dqu/10wgxMuVHh6UXRgtwUE8znXy5j6+oA1ZnaN3/EzcG6t85SVLhuuKt+3Ob+2Cwr8V1I9O8dB6/ROsxv5U2tvtraVtTt3EbhVG53GrZoseOOUR2lJw44APIIbBOfqRrdLPtanWbbNKtKjNhEOlxm4rQAxnlHVR9yck+5Og2alxudRfUCAn5dRvxeyHovC1uu9HJCxZ9VSCPQGMsE/sTqWmGw00lCfQY1q27Vj/4l7XXbt4ZCWf5lok2lB1Q6Nl9lTYUfsVZ/TQRhY7LFb4oqs7FSDEsawaTR2voh6Y++64kf+OPGJ9iNbluDsBYO4lc/mipKq9Mqyo4ivy6RUXIbkpkZ5W3Sg/GBk4PmM9DrXOGPb/ca14NzXduzTodPue6p0Vx6HFlJkIYYiwmIrY7xPQ85ZcdwPLvQPMHU2kZ6aCP7Qsq2Nv6Oi3LSorFNgtEnu2h1Wo+a1qPxLUfVSiSdRNaNCjyqnv5tI+j+imITVI7H9oEyMsr5R+dI1PlQb7uUvHkeuogfUm1eKCizHE4h31b0ilOk9EmTGIdR+pb5hoOeOr052j1abSXx+JCkOR1/mQopP+400zsT90pDzN+7NzJHM2wlm4ILZPy9e5fOPcqY/bVAeK+xpO3HEduDaclotmPXJD6ARgcjyu9Tj2w4NWR7HVNW/wCKyS5AZdVEFtzUzlpB5UNlTfLzH/uBGgdzo0aNAaNGjQV9uUmp8XlKiT/x2aRZzkuC2r5WHnZBQ4tI/wCYpSBk+g1MkQAyG8j10aNBntGjRoDRo0aDEVjo+j3TqEOIImNV9rqmweSUxfNNabdHmlDiilwfZSeh0aNAsXtb6RTYvGAhUaIhsz6DAdklOR3iytxJUffAA/TTK+ArZnbDbHYyjV2xrPh0upXJFbkVWYlS3X5SwTjmW4pSgkdcJBCRkkDro0aCyujRo0H/2Q==";
}
...@@ -32,7 +32,7 @@ public class DeptDict extends AbstractDictMap { ...@@ -32,7 +32,7 @@ public class DeptDict extends AbstractDictMap {
put("pid", "上级名称"); put("pid", "上级名称");
put("simplename", "部门简称"); put("simplename", "部门简称");
put("fullname", "部门全称"); put("fullname", "部门全称");
put("tips", "备注"); put("description", "备注");
} }
@Override @Override
......
...@@ -27,7 +27,7 @@ public class LogDict extends AbstractDictMap { ...@@ -27,7 +27,7 @@ public class LogDict extends AbstractDictMap {
@Override @Override
public void init() { public void init() {
put("tips", "备注"); put("description", "备注");
} }
@Override @Override
......
...@@ -36,7 +36,7 @@ public class MenuDict extends AbstractDictMap { ...@@ -36,7 +36,7 @@ public class MenuDict extends AbstractDictMap {
put("url", "url地址"); put("url", "url地址");
put("num", "菜单排序号"); put("num", "菜单排序号");
put("levels", "菜单层级"); put("levels", "菜单层级");
put("tips", "备注"); put("description", "备注");
put("status", "菜单状态"); put("status", "菜单状态");
put("isopen", "是否打开"); put("isopen", "是否打开");
put("", ""); put("", "");
......
...@@ -31,15 +31,15 @@ public class RoleDict extends AbstractDictMap { ...@@ -31,15 +31,15 @@ public class RoleDict extends AbstractDictMap {
put("num", "角色排序"); put("num", "角色排序");
put("pid", "角色的父级"); put("pid", "角色的父级");
put("name", "角色名称"); put("name", "角色名称");
put("deptid", "部门名称"); put("deptId", "部门名称");
put("tips", "备注"); put("description", "备注");
put("ids", "资源名称"); put("ids", "资源名称");
} }
@Override @Override
protected void initBeWrapped() { protected void initBeWrapped() {
putFieldWrapperMethodName("pid", "getSingleRoleName"); putFieldWrapperMethodName("pid", "getSingleRoleName");
putFieldWrapperMethodName("deptid", "getDeptName"); putFieldWrapperMethodName("deptId", "getDeptName");
putFieldWrapperMethodName("roleId", "getSingleRoleName"); putFieldWrapperMethodName("roleId", "getSingleRoleName");
putFieldWrapperMethodName("ids", "getMenuNames"); putFieldWrapperMethodName("ids", "getMenuNames");
} }
......
...@@ -36,14 +36,14 @@ public class UserDict extends AbstractDictMap { ...@@ -36,14 +36,14 @@ public class UserDict extends AbstractDictMap {
put("email", "电子邮件"); put("email", "电子邮件");
put("phone", "电话"); put("phone", "电话");
put("roleid", "角色名称"); put("roleid", "角色名称");
put("deptid", "部门名称"); put("deptId", "部门名称");
put("roleIds", "角色名称集合"); put("roleIds", "角色名称集合");
} }
@Override @Override
protected void initBeWrapped() { protected void initBeWrapped() {
putFieldWrapperMethodName("sex", "getSexName"); putFieldWrapperMethodName("sex", "getSexName");
putFieldWrapperMethodName("deptid", "getDeptName"); putFieldWrapperMethodName("deptId", "getDeptName");
putFieldWrapperMethodName("roleid", "getSingleRoleName"); putFieldWrapperMethodName("roleid", "getSingleRoleName");
putFieldWrapperMethodName("userId", "getUserAccountById"); putFieldWrapperMethodName("userId", "getUserAccountById");
putFieldWrapperMethodName("roleIds", "getRoleName"); putFieldWrapperMethodName("roleIds", "getRoleName");
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package cn.stylefeng.guns.core.common.constant.factory; package cn.stylefeng.guns.core.common.constant.factory;
import cn.stylefeng.guns.modular.system.model.Dict; import cn.stylefeng.guns.modular.system.entity.Dict;
import java.util.List; import java.util.List;
...@@ -33,7 +33,7 @@ public interface IConstantFactory { ...@@ -33,7 +33,7 @@ public interface IConstantFactory {
* @author stylefeng * @author stylefeng
* @Date 2017/5/9 23:41 * @Date 2017/5/9 23:41
*/ */
String getUserNameById(Integer userId); String getUserNameById(Long userId);
/** /**
* 根据用户id获取用户账号 * 根据用户id获取用户账号
...@@ -41,7 +41,7 @@ public interface IConstantFactory { ...@@ -41,7 +41,7 @@ public interface IConstantFactory {
* @author stylefeng * @author stylefeng
* @date 2017年5月16日21:55:371 * @date 2017年5月16日21:55:371
*/ */
String getUserAccountById(Integer userId); String getUserAccountById(Long userId);
/** /**
* 通过角色ids获取角色名称 * 通过角色ids获取角色名称
...@@ -51,17 +51,17 @@ public interface IConstantFactory { ...@@ -51,17 +51,17 @@ public interface IConstantFactory {
/** /**
* 通过角色id获取角色名称 * 通过角色id获取角色名称
*/ */
String getSingleRoleName(Integer roleId); String getSingleRoleName(Long roleId);
/** /**
* 通过角色id获取角色英文名称 * 通过角色id获取角色英文名称
*/ */
String getSingleRoleTip(Integer roleId); String getSingleRoleTip(Long roleId);
/** /**
* 获取部门名称 * 获取部门名称
*/ */
String getDeptName(Integer deptId); String getDeptName(Long deptId);
/** /**
* 获取菜单的名称们(多个) * 获取菜单的名称们(多个)
...@@ -79,39 +79,44 @@ public interface IConstantFactory { ...@@ -79,39 +79,44 @@ public interface IConstantFactory {
String getMenuNameByCode(String code); String getMenuNameByCode(String code);
/** /**
* 获取菜单名称通过编号
*/
Long getMenuIdByCode(String code);
/**
* 获取字典名称 * 获取字典名称
*/ */
String getDictName(Integer dictId); String getDictName(Long dictId);
/** /**
* 获取通知标题 * 获取通知标题
*/ */
String getNoticeTitle(Integer dictId); String getNoticeTitle(Long dictId);
/** /**
* 根据字典名称和字典中的值获取对应的名称 * 根据字典名称和字典中的值获取对应的名称
*/ */
String getDictsByName(String name, Integer val); String getDictsByName(String name, String code);
/** /**
* 获取性别名称 * 获取性别名称
*/ */
String getSexName(Integer sex); String getSexName(String sexCode);
/** /**
* 获取用户登录状态 * 获取用户登录状态
*/ */
String getStatusName(Integer status); String getStatusName(String status);
/** /**
* 获取菜单状态 * 获取菜单状态
*/ */
String getMenuStatusName(Integer status); String getMenuStatusName(String status);
/** /**
* 查询字典 * 查询字典
*/ */
List<Dict> findInDict(Integer id); List<Dict> findInDict(Long id);
/** /**
* 获取被缓存的对象(用户删除业务) * 获取被缓存的对象(用户删除业务)
...@@ -121,11 +126,11 @@ public interface IConstantFactory { ...@@ -121,11 +126,11 @@ public interface IConstantFactory {
/** /**
* 获取子部门id * 获取子部门id
*/ */
List<Integer> getSubDeptId(Integer deptid); List<Long> getSubDeptId(Long deptId);
/** /**
* 获取所有父部门id * 获取所有父部门id
*/ */
List<Integer> getParentDeptIds(Integer deptid); List<Long> getParentDeptIds(Long deptId);
} }
...@@ -32,15 +32,28 @@ public class PageFactory<T> { ...@@ -32,15 +32,28 @@ public class PageFactory<T> {
public Page<T> defaultPage() { public Page<T> defaultPage() {
HttpServletRequest request = HttpContext.getRequest(); HttpServletRequest request = HttpContext.getRequest();
int limit = Integer.valueOf(request.getParameter("limit")); //每页多少条数据
int offset = Integer.valueOf(request.getParameter("offset")); //每页的偏移量(本页当前有多少条) //每页多少条数据
String sort = request.getParameter("sort"); //排序字段名称 int limit = Integer.valueOf(request.getParameter("limit"));
String order = request.getParameter("order"); //asc或desc(升序或降序)
//每页的偏移量(本页当前有多少条)
int offset = Integer.valueOf(request.getParameter("offset"));
//排序字段名称
String sort = request.getParameter("sort");
//asc或desc(升序或降序)
String order = request.getParameter("order");
//如果没有排序字段名称
if (ToolUtil.isEmpty(sort)) { if (ToolUtil.isEmpty(sort)) {
Page<T> page = new Page<>((offset / limit + 1), limit); Page<T> page = new Page<>((offset / limit + 1), limit);
page.setOpenSort(false); page.setOpenSort(false);
return page; return page;
} else { } else {
//如果有排序字段
Page<T> page = new Page<>((offset / limit + 1), limit, sort); Page<T> page = new Page<>((offset / limit + 1), limit, sort);
if (Order.ASC.getDes().equals(order)) { if (Order.ASC.getDes().equals(order)) {
page.setAsc(true); page.setAsc(true);
......
...@@ -15,46 +15,33 @@ ...@@ -15,46 +15,33 @@
*/ */
package cn.stylefeng.guns.core.common.constant.state; package cn.stylefeng.guns.core.common.constant.state;
import lombok.Getter;
/** /**
* 管理员的状态 * 管理员的状态
* *
* @author fengshuonan * @author fengshuonan
* @Date 2017年1月10日 下午9:54:13 * @Date 2017年1月10日 下午9:54:13
*/ */
@Getter
public enum ManagerStatus { public enum ManagerStatus {
OK(1, "启用"), FREEZED(2, "冻结"), DELETED(3, "被删除"); OK("ENABLE", "启用"), FREEZED("LOCKED", "冻结"), DELETED("DELETED", "被删除");
int code; String code;
String message; String message;
ManagerStatus(int code, String message) { ManagerStatus(String code, String message) {
this.code = code; this.code = code;
this.message = message; this.message = message;
} }
public int getCode() { public static String getDescription(String value) {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static String valueOf(Integer value) {
if (value == null) { if (value == null) {
return ""; return "";
} else { } else {
for (ManagerStatus ms : ManagerStatus.values()) { for (ManagerStatus ms : ManagerStatus.values()) {
if (ms.getCode() == value) { if (ms.getCode().equals(value)) {
return ms.getMessage(); return ms.getMessage();
} }
} }
......
...@@ -15,47 +15,34 @@ ...@@ -15,47 +15,34 @@
*/ */
package cn.stylefeng.guns.core.common.constant.state; package cn.stylefeng.guns.core.common.constant.state;
import lombok.Getter;
/** /**
* 菜单的状态 * 菜单的状态
* *
* @author fengshuonan * @author fengshuonan
* @Date 2017年1月22日 下午12:14:59 * @Date 2017年1月22日 下午12:14:59
*/ */
@Getter
public enum MenuStatus { public enum MenuStatus {
ENABLE(1, "启用"), ENABLE("ENABLE", "启用"),
DISABLE(0, "禁用"); DISABLE("DISABLE", "禁用");
int code; String code;
String message; String message;
MenuStatus(int code, String message) { MenuStatus(String code, String message) {
this.code = code; this.code = code;
this.message = message; this.message = message;
} }
public int getCode() { public static String getDescription(String status) {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static String valueOf(Integer status) {
if (status == null) { if (status == null) {
return ""; return "";
} else { } else {
for (MenuStatus s : MenuStatus.values()) { for (MenuStatus s : MenuStatus.values()) {
if (s.getCode() == status) { if (s.getCode().equals(status)) {
return s.getMessage(); return s.getMessage();
} }
} }
......
...@@ -53,6 +53,7 @@ public enum BizExceptionEnum implements AbstractBaseExceptionEnum { ...@@ -53,6 +53,7 @@ public enum BizExceptionEnum implements AbstractBaseExceptionEnum {
/** /**
* 账户问题 * 账户问题
*/ */
NOT_LOGIN(401, "当前用户未登录"),
USER_ALREADY_REG(401, "该用户已经注册"), USER_ALREADY_REG(401, "该用户已经注册"),
NO_THIS_USER(400, "没有此用户"), NO_THIS_USER(400, "没有此用户"),
USER_NOT_EXISTED(400, "没有此用户"), USER_NOT_EXISTED(400, "没有此用户"),
......
...@@ -16,7 +16,9 @@ ...@@ -16,7 +16,9 @@
package cn.stylefeng.guns.core.common.node; package cn.stylefeng.guns.core.common.node;
import cn.stylefeng.roses.kernel.model.enums.YesOrNotEnum; import cn.stylefeng.roses.kernel.model.enums.YesOrNotEnum;
import lombok.Data;
import java.io.Serializable;
import java.util.*; import java.util.*;
/** /**
...@@ -24,7 +26,8 @@ import java.util.*; ...@@ -24,7 +26,8 @@ import java.util.*;
* @Description 菜单的节点 * @Description 菜单的节点
* @date 2016年12月6日 上午11:34:17 * @date 2016年12月6日 上午11:34:17
*/ */
public class MenuNode implements Comparable { @Data
public class MenuNode implements Comparable, Serializable {
/** /**
* 节点id * 节点id
...@@ -47,9 +50,9 @@ public class MenuNode implements Comparable { ...@@ -47,9 +50,9 @@ public class MenuNode implements Comparable {
private Integer levels; private Integer levels;
/** /**
* 按钮级别 * 按钮级别(Y N)
*/ */
private Integer ismenu; private String ismenu;
/** /**
* 按钮的排序 * 按钮的排序
...@@ -74,7 +77,7 @@ public class MenuNode implements Comparable { ...@@ -74,7 +77,7 @@ public class MenuNode implements Comparable {
/** /**
* 查询子节点时候的临时集合 * 查询子节点时候的临时集合
*/ */
private List<MenuNode> linkedList = new ArrayList<MenuNode>(); private List<MenuNode> linkedList = new ArrayList<>();
public MenuNode() { public MenuNode() {
super(); super();
...@@ -86,97 +89,6 @@ public class MenuNode implements Comparable { ...@@ -86,97 +89,6 @@ public class MenuNode implements Comparable {
this.parentId = parentId; this.parentId = parentId;
} }
public Integer getLevels() {
return levels;
}
public void setLevels(Integer levels) {
this.levels = levels;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public static MenuNode createRoot() {
return new MenuNode(0L, -1L);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public List<MenuNode> getChildren() {
return children;
}
public void setChildren(List<MenuNode> children) {
this.children = children;
}
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
public Integer getIsmenu() {
return ismenu;
}
public void setIsmenu(Integer ismenu) {
this.ismenu = ismenu;
}
@Override
public String toString() {
return "MenuNode{" +
"id=" + id +
", parentId=" + parentId +
", name='" + name + '\'' +
", levels=" + levels +
", num=" + num +
", url='" + url + '\'' +
", icon='" + icon + '\'' +
", children=" + children +
", linkedList=" + linkedList +
'}';
}
/** /**
* 重写排序比较接口,首先根据等级排序,然后更具排序字段排序 * 重写排序比较接口,首先根据等级排序,然后更具排序字段排序
* *
...@@ -209,8 +121,10 @@ public class MenuNode implements Comparable { ...@@ -209,8 +121,10 @@ public class MenuNode implements Comparable {
if (nodes.size() <= 0) { if (nodes.size() <= 0) {
return nodes; return nodes;
} }
//剔除非菜单 //剔除非菜单
nodes.removeIf(node -> !node.getIsmenu().equals(YesOrNotEnum.Y.getCode())); nodes.removeIf(node -> !node.getIsmenu().equals(YesOrNotEnum.Y.name()));
//对菜单排序,返回列表按菜单等级,序号的排序方式排列 //对菜单排序,返回列表按菜单等级,序号的排序方式排列
Collections.sort(nodes); Collections.sort(nodes);
return mergeList(nodes, nodes.get(nodes.size() - 1).getLevels(), null); return mergeList(nodes, nodes.get(nodes.size() - 1).getLevels(), null);
...@@ -245,7 +159,7 @@ public class MenuNode implements Comparable { ...@@ -245,7 +159,7 @@ public class MenuNode implements Comparable {
if (n < 0) { if (n < 0) {
return menuList; return menuList;
} else { } else {
return mergeList(menuList.subList(0, n + 1), menuList.get(n).getLevels(), currentMap); return mergeList(new ArrayList<>(menuList.subList(0, n + 1)), menuList.get(n).getLevels(), currentMap);
} }
} }
......
...@@ -13,35 +13,54 @@ ...@@ -13,35 +13,54 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.stylefeng.guns.modular.system.service; package cn.stylefeng.guns.core.common.node;
import cn.stylefeng.guns.core.common.node.ZTreeNode; import cn.stylefeng.roses.kernel.model.tree.Tree;
import cn.stylefeng.guns.modular.system.model.Dept; import lombok.Data;
import com.baomidou.mybatisplus.service.IService;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 部门服务 * jquery ztree 插件的节点
* *
* @author fengshuonan * @author fengshuonan
* @date 2017-04-27 17:00 * @date 2017年2月17日 下午8:25:14
*/ */
public interface IDeptService extends IService<Dept> { @Data
public class TreeviewNode implements Tree {
/** /**
* 删除部门 * 附加信息,一般用于存业务id
*/ */
void deleteDept(Integer deptId); private String tags;
/** /**
* 获取ztree的节点列表 * 父级id
*/ */
List<ZTreeNode> tree(); private String parentId;
/** /**
* 获取所有部门列表 * 节点名称
*/ */
List<Map<String, Object>> list(String condition); private String text;
/**
* 子节点
*/
private List<TreeviewNode> nodes;
@Override
public String getNodeId() {
return tags;
}
@Override
public String getNodeParentId() {
return parentId;
}
@Override
public void setChildrenNodes(List childrenNodes) {
this.nodes = childrenNodes;
}
} }
...@@ -15,12 +15,15 @@ ...@@ -15,12 +15,15 @@
*/ */
package cn.stylefeng.guns.core.common.node; package cn.stylefeng.guns.core.common.node;
import lombok.Data;
/** /**
* jquery ztree 插件的节点 * jquery ztree 插件的节点
* *
* @author fengshuonan * @author fengshuonan
* @date 2017年2月17日 下午8:25:14 * @date 2017年2月17日 下午8:25:14
*/ */
@Data
public class ZTreeNode { public class ZTreeNode {
private Long id; //节点id private Long id; //节点id
...@@ -33,61 +36,19 @@ public class ZTreeNode { ...@@ -33,61 +36,19 @@ public class ZTreeNode {
private Boolean checked; //是否被选中 private Boolean checked; //是否被选中
public Long getId() { /**
return id; * 创建ztree的父级节点
} *
* @author fengshuonan
public void setId(Long id) { * @Date 2018/12/23 4:51 PM
this.id = id; */
}
public Long getpId() {
return pId;
}
public void setpId(Long pId) {
this.pId = pId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Boolean getOpen() {
return open;
}
public void setOpen(Boolean open) {
this.open = open;
}
public Boolean getIsOpen() {
return open;
}
public void setIsOpen(Boolean open) {
this.open = open;
}
public Boolean getChecked() {
return checked;
}
public void setChecked(Boolean checked) {
this.checked = checked;
}
public static ZTreeNode createParent() { public static ZTreeNode createParent() {
ZTreeNode zTreeNode = new ZTreeNode(); ZTreeNode zTreeNode = new ZTreeNode();
zTreeNode.setChecked(true); zTreeNode.setChecked(true);
zTreeNode.setId(0L); zTreeNode.setId(0L);
zTreeNode.setName("顶级"); zTreeNode.setName("顶级");
zTreeNode.setOpen(true); zTreeNode.setOpen(true);
zTreeNode.setpId(0L); zTreeNode.setPId(0L);
return zTreeNode; return zTreeNode;
} }
} }
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.stylefeng.guns.core.interceptor;
import cn.stylefeng.guns.core.shiro.ShiroKit;
import cn.stylefeng.guns.core.shiro.ShiroUser;
import cn.stylefeng.guns.core.util.DefaultImages;
import org.apache.shiro.authc.AuthenticationException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 自动渲染当前用户信息登录属性 的过滤器
*
* @author fengshuonan
* @Date 2018/10/30 4:30 PM
*/
public class AttributeSetInteceptor extends HandlerInterceptorAdapter {
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//没有视图的直接跳过过滤器
if (modelAndView == null || modelAndView.getViewName() == null) {
return;
}
//视图结尾不是html的直接跳过
if (!modelAndView.getViewName().endsWith("html")) {
return;
}
ShiroUser user = ShiroKit.getUser();
if (user == null) {
throw new AuthenticationException("当前没有登录账号!");
} else {
modelAndView.addObject("menus", user.getMenus());
modelAndView.addObject("name", user.getName());
modelAndView.addObject("avatar", DefaultImages.defaultAvatarUrl());
modelAndView.addObject("email", user.getEmail());
}
}
}
...@@ -17,8 +17,8 @@ package cn.stylefeng.guns.core.log.factory; ...@@ -17,8 +17,8 @@ package cn.stylefeng.guns.core.log.factory;
import cn.stylefeng.guns.core.common.constant.state.LogSucceed; import cn.stylefeng.guns.core.common.constant.state.LogSucceed;
import cn.stylefeng.guns.core.common.constant.state.LogType; import cn.stylefeng.guns.core.common.constant.state.LogType;
import cn.stylefeng.guns.modular.system.model.LoginLog; import cn.stylefeng.guns.modular.system.entity.LoginLog;
import cn.stylefeng.guns.modular.system.model.OperationLog; import cn.stylefeng.guns.modular.system.entity.OperationLog;
import java.util.Date; import java.util.Date;
...@@ -33,14 +33,14 @@ public class LogFactory { ...@@ -33,14 +33,14 @@ public class LogFactory {
/** /**
* 创建操作日志 * 创建操作日志
*/ */
public static OperationLog createOperationLog(LogType logType, Integer userId, String bussinessName, String clazzName, String methodName, String msg, LogSucceed succeed) { public static OperationLog createOperationLog(LogType logType, Long userId, String bussinessName, String clazzName, String methodName, String msg, LogSucceed succeed) {
OperationLog operationLog = new OperationLog(); OperationLog operationLog = new OperationLog();
operationLog.setLogtype(logType.getMessage()); operationLog.setLogType(logType.getMessage());
operationLog.setLogname(bussinessName); operationLog.setLogName(bussinessName);
operationLog.setUserid(userId); operationLog.setUserId(userId);
operationLog.setClassname(clazzName); operationLog.setClassName(clazzName);
operationLog.setMethod(methodName); operationLog.setMethod(methodName);
operationLog.setCreatetime(new Date()); operationLog.setCreateTime(new Date());
operationLog.setSucceed(succeed.getMessage()); operationLog.setSucceed(succeed.getMessage());
operationLog.setMessage(msg); operationLog.setMessage(msg);
return operationLog; return operationLog;
...@@ -49,13 +49,13 @@ public class LogFactory { ...@@ -49,13 +49,13 @@ public class LogFactory {
/** /**
* 创建登录日志 * 创建登录日志
*/ */
public static LoginLog createLoginLog(LogType logType, Integer userId, String msg, String ip) { public static LoginLog createLoginLog(LogType logType, Long userId, String msg, String ip) {
LoginLog loginLog = new LoginLog(); LoginLog loginLog = new LoginLog();
loginLog.setLogname(logType.getMessage()); loginLog.setLogName(logType.getMessage());
loginLog.setUserid(userId); loginLog.setUserId(userId);
loginLog.setCreatetime(new Date()); loginLog.setCreateTime(new Date());
loginLog.setSucceed(LogSucceed.SUCCESS.getMessage()); loginLog.setSucceed(LogSucceed.SUCCESS.getMessage());
loginLog.setIp(ip); loginLog.setIpAddress(ip);
loginLog.setMessage(msg); loginLog.setMessage(msg);
return loginLog; return loginLog;
} }
......
...@@ -18,10 +18,10 @@ package cn.stylefeng.guns.core.log.factory; ...@@ -18,10 +18,10 @@ package cn.stylefeng.guns.core.log.factory;
import cn.stylefeng.guns.core.common.constant.state.LogSucceed; import cn.stylefeng.guns.core.common.constant.state.LogSucceed;
import cn.stylefeng.guns.core.common.constant.state.LogType; import cn.stylefeng.guns.core.common.constant.state.LogType;
import cn.stylefeng.guns.core.log.LogManager; import cn.stylefeng.guns.core.log.LogManager;
import cn.stylefeng.guns.modular.system.dao.LoginLogMapper; import cn.stylefeng.guns.modular.system.entity.LoginLog;
import cn.stylefeng.guns.modular.system.dao.OperationLogMapper; import cn.stylefeng.guns.modular.system.entity.OperationLog;
import cn.stylefeng.guns.modular.system.model.LoginLog; import cn.stylefeng.guns.modular.system.mapper.LoginLogMapper;
import cn.stylefeng.guns.modular.system.model.OperationLog; import cn.stylefeng.guns.modular.system.mapper.OperationLogMapper;
import cn.stylefeng.roses.core.util.SpringContextHolder; import cn.stylefeng.roses.core.util.SpringContextHolder;
import cn.stylefeng.roses.core.util.ToolUtil; import cn.stylefeng.roses.core.util.ToolUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -41,7 +41,7 @@ public class LogTaskFactory { ...@@ -41,7 +41,7 @@ public class LogTaskFactory {
private static LoginLogMapper loginLogMapper = SpringContextHolder.getBean(LoginLogMapper.class); private static LoginLogMapper loginLogMapper = SpringContextHolder.getBean(LoginLogMapper.class);
private static OperationLogMapper operationLogMapper = SpringContextHolder.getBean(OperationLogMapper.class); private static OperationLogMapper operationLogMapper = SpringContextHolder.getBean(OperationLogMapper.class);
public static TimerTask loginLog(final Integer userId, final String ip) { public static TimerTask loginLog(final Long userId, final String ip) {
return new TimerTask() { return new TimerTask() {
@Override @Override
public void run() { public void run() {
...@@ -70,7 +70,7 @@ public class LogTaskFactory { ...@@ -70,7 +70,7 @@ public class LogTaskFactory {
}; };
} }
public static TimerTask exitLog(final Integer userId, final String ip) { public static TimerTask exitLog(final Long userId, final String ip) {
return new TimerTask() { return new TimerTask() {
@Override @Override
public void run() { public void run() {
...@@ -84,7 +84,7 @@ public class LogTaskFactory { ...@@ -84,7 +84,7 @@ public class LogTaskFactory {
}; };
} }
public static TimerTask bussinessLog(final Integer userId, final String bussinessName, final String clazzName, final String methodName, final String msg) { public static TimerTask bussinessLog(final Long userId, final String bussinessName, final String clazzName, final String methodName, final String msg) {
return new TimerTask() { return new TimerTask() {
@Override @Override
public void run() { public void run() {
...@@ -99,7 +99,7 @@ public class LogTaskFactory { ...@@ -99,7 +99,7 @@ public class LogTaskFactory {
}; };
} }
public static TimerTask exceptionLog(final Integer userId, final Exception exception) { public static TimerTask exceptionLog(final Long userId, final Exception exception) {
return new TimerTask() { return new TimerTask() {
@Override @Override
public void run() { public void run() {
......
/** /**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) * Copyright 2018-2020 stylefeng & fengshuonan (sn93@qq.com)
* <p> * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -13,19 +13,31 @@ ...@@ -13,19 +13,31 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package cn.stylefeng.guns.modular.system.dao; package cn.stylefeng.guns.core.metadata;
import cn.stylefeng.guns.modular.system.model.Relation; import cn.stylefeng.guns.core.shiro.ShiroKit;
import com.baomidou.mybatisplus.mapper.BaseMapper; import cn.stylefeng.roses.core.metadata.CustomMetaObjectHandler;
import org.springframework.stereotype.Component;
/** /**
* <p> * 字段填充器
* 角色和菜单关联表 Mapper 接口
* </p>
* *
* @author stylefeng * @author fengshuonan
* @since 2017-07-11 * @Date 2018/12/8 15:01
*/ */
public interface RelationMapper extends BaseMapper<Relation> { @Component
public class GunsMpFieldHandler extends CustomMetaObjectHandler {
@Override
protected Object getUserUniqueId() {
try {
return ShiroKit.getUser().getId();
} catch (Exception e) {
//如果获取不到当前用户就存空id
return "";
}
}
} }
...@@ -17,7 +17,7 @@ package cn.stylefeng.guns.core.shiro; ...@@ -17,7 +17,7 @@ package cn.stylefeng.guns.core.shiro;
import cn.stylefeng.guns.core.shiro.service.UserAuthService; import cn.stylefeng.guns.core.shiro.service.UserAuthService;
import cn.stylefeng.guns.core.shiro.service.impl.UserAuthServiceServiceImpl; import cn.stylefeng.guns.core.shiro.service.impl.UserAuthServiceServiceImpl;
import cn.stylefeng.guns.modular.system.model.User; import cn.stylefeng.guns.modular.system.entity.User;
import cn.stylefeng.roses.core.util.ToolUtil; import cn.stylefeng.roses.core.util.ToolUtil;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo; import org.apache.shiro.authc.AuthenticationInfo;
...@@ -56,12 +56,12 @@ public class ShiroDbRealm extends AuthorizingRealm { ...@@ -56,12 +56,12 @@ public class ShiroDbRealm extends AuthorizingRealm {
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
UserAuthService shiroFactory = UserAuthServiceServiceImpl.me(); UserAuthService shiroFactory = UserAuthServiceServiceImpl.me();
ShiroUser shiroUser = (ShiroUser) principals.getPrimaryPrincipal(); ShiroUser shiroUser = (ShiroUser) principals.getPrimaryPrincipal();
List<Integer> roleList = shiroUser.getRoleList(); List<Long> roleList = shiroUser.getRoleList();
Set<String> permissionSet = new HashSet<>(); Set<String> permissionSet = new HashSet<>();
Set<String> roleNameSet = new HashSet<>(); Set<String> roleNameSet = new HashSet<>();
for (Integer roleId : roleList) { for (Long roleId : roleList) {
List<String> permissions = shiroFactory.findPermissionsByRoleId(roleId); List<String> permissions = shiroFactory.findPermissionsByRoleId(roleId);
if (permissions != null) { if (permissions != null) {
for (String permission : permissions) { for (String permission : permissions) {
......
...@@ -17,7 +17,10 @@ package cn.stylefeng.guns.core.shiro; ...@@ -17,7 +17,10 @@ package cn.stylefeng.guns.core.shiro;
import cn.stylefeng.guns.core.common.constant.Const; import cn.stylefeng.guns.core.common.constant.Const;
import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory; import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import cn.stylefeng.guns.core.common.exception.BizExceptionEnum;
import cn.stylefeng.guns.modular.system.entity.User;
import cn.stylefeng.roses.core.util.ToolUtil; import cn.stylefeng.roses.core.util.ToolUtil;
import cn.stylefeng.roses.kernel.model.exception.ServiceException;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.crypto.hash.Md5Hash; import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash; import org.apache.shiro.crypto.hash.SimpleHash;
...@@ -91,6 +94,19 @@ public class ShiroKit { ...@@ -91,6 +94,19 @@ public class ShiroKit {
} }
/** /**
* 获取ShiroUser,不为空的
*
* @return ShiroUser
*/
public static ShiroUser getUserNotNull() {
if (isGuest()) {
throw new ServiceException(BizExceptionEnum.NOT_LOGIN);
} else {
return (ShiroUser) getSubject().getPrincipals().getPrimaryPrincipal();
}
}
/**
* 从shiro获取session * 从shiro获取session
*/ */
public static Session getSession() { public static Session getSession() {
...@@ -258,9 +274,9 @@ public class ShiroKit { ...@@ -258,9 +274,9 @@ public class ShiroKit {
/** /**
* 获取当前用户的部门数据范围的集合 * 获取当前用户的部门数据范围的集合
*/ */
public static List<Integer> getDeptDataScope() { public static List<Long> getDeptDataScope() {
Integer deptId = getUser().getDeptId(); Long deptId = getUser().getDeptId();
List<Integer> subDeptIds = ConstantFactory.me().getSubDeptId(deptId); List<Long> subDeptIds = ConstantFactory.me().getSubDeptId(deptId);
subDeptIds.add(deptId); subDeptIds.add(deptId);
return subDeptIds; return subDeptIds;
} }
...@@ -269,8 +285,8 @@ public class ShiroKit { ...@@ -269,8 +285,8 @@ public class ShiroKit {
* 判断当前用户是否是超级管理员 * 判断当前用户是否是超级管理员
*/ */
public static boolean isAdmin() { public static boolean isAdmin() {
List<Integer> roleList = ShiroKit.getUser().getRoleList(); List<Long> roleList = ShiroKit.getUser().getRoleList();
for (Integer integer : roleList) { for (Long integer : roleList) {
String singleRoleTip = ConstantFactory.me().getSingleRoleTip(integer); String singleRoleTip = ConstantFactory.me().getSingleRoleTip(integer);
if (singleRoleTip.equals(Const.ADMIN_NAME)) { if (singleRoleTip.equals(Const.ADMIN_NAME)) {
return true; return true;
...@@ -279,4 +295,25 @@ public class ShiroKit { ...@@ -279,4 +295,25 @@ public class ShiroKit {
return false; return false;
} }
/**
* 通过用户表的信息创建一个shiroUser对象
*/
public static ShiroUser createShiroUser(User user) {
ShiroUser shiroUser = new ShiroUser();
if (user == null) {
return shiroUser;
}
shiroUser.setId(user.getUserId());
shiroUser.setAccount(user.getAccount());
shiroUser.setDeptId(user.getDeptId());
shiroUser.setDeptName(ConstantFactory.me().getDeptName(user.getDeptId()));
shiroUser.setName(user.getName());
shiroUser.setEmail(user.getEmail());
shiroUser.setAvatar(user.getAvatar());
return shiroUser;
}
} }
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
*/ */
package cn.stylefeng.guns.core.shiro; package cn.stylefeng.guns.core.shiro;
import cn.stylefeng.guns.core.common.node.MenuNode;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
...@@ -24,73 +27,60 @@ import java.util.List; ...@@ -24,73 +27,60 @@ import java.util.List;
* @author fengshuonan * @author fengshuonan
* @date 2016年12月5日 上午10:26:43 * @date 2016年12月5日 上午10:26:43
*/ */
@Data
public class ShiroUser implements Serializable { public class ShiroUser implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Integer id; // 主键ID /**
public String account; // 账号 * 用户主键ID
public String name; // 姓名 */
public Integer deptId; // 部门id private Long id;
public List<Integer> roleList; // 角色集
public String deptName; // 部门名称
public List<String> roleNames; // 角色名称集
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getName() { /**
return name; * 账号
} */
private String account;
public void setName(String name) { /**
this.name = name; * 姓名
} */
private String name;
public Integer getDeptId() { /**
return deptId; * 邮箱
} */
private String email;
public void setDeptId(Integer deptId) { /**
this.deptId = deptId; * 头像
} */
private String avatar;
public List<Integer> getRoleList() { /**
return roleList; * 部门id
} */
private Long deptId;
public void setRoleList(List<Integer> roleList) { /**
this.roleList = roleList; * 角色集
} */
private List<Long> roleList;
public String getDeptName() { /**
return deptName; * 部门名称
} */
private String deptName;
public void setDeptName(String deptName) { /**
this.deptName = deptName; * 角色名称集
} */
private List<String> roleNames;
public List<String> getRoleNames() { /**
return roleNames; * 用户所能看到的菜单列表
} */
private List<MenuNode> menus;
public void setRoleNames(List<String> roleNames) {
this.roleNames = roleNames;
}
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
package cn.stylefeng.guns.core.shiro.service; package cn.stylefeng.guns.core.shiro.service;
import cn.stylefeng.guns.core.shiro.ShiroUser; import cn.stylefeng.guns.core.shiro.ShiroUser;
import cn.stylefeng.guns.modular.system.model.User; import cn.stylefeng.guns.modular.system.entity.User;
import org.apache.shiro.authc.SimpleAuthenticationInfo; import org.apache.shiro.authc.SimpleAuthenticationInfo;
import java.util.List; import java.util.List;
...@@ -48,14 +48,14 @@ public interface UserAuthService { ...@@ -48,14 +48,14 @@ public interface UserAuthService {
* *
* @param roleId 角色id * @param roleId 角色id
*/ */
List<String> findPermissionsByRoleId(Integer roleId); List<String> findPermissionsByRoleId(Long roleId);
/** /**
* 根据角色id获取角色名称 * 根据角色id获取角色名称
* *
* @param roleId 角色id * @param roleId 角色id
*/ */
String findRoleNameByRoleId(Integer roleId); String findRoleNameByRoleId(Long roleId);
/** /**
* 获取shiro的认证信息 * 获取shiro的认证信息
......
...@@ -18,11 +18,13 @@ package cn.stylefeng.guns.core.shiro.service.impl; ...@@ -18,11 +18,13 @@ package cn.stylefeng.guns.core.shiro.service.impl;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory; import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import cn.stylefeng.guns.core.common.constant.state.ManagerStatus; import cn.stylefeng.guns.core.common.constant.state.ManagerStatus;
import cn.stylefeng.guns.core.shiro.ShiroKit;
import cn.stylefeng.guns.core.shiro.ShiroUser; import cn.stylefeng.guns.core.shiro.ShiroUser;
import cn.stylefeng.guns.core.shiro.service.UserAuthService; import cn.stylefeng.guns.core.shiro.service.UserAuthService;
import cn.stylefeng.guns.modular.system.dao.MenuMapper; import cn.stylefeng.guns.modular.system.entity.User;
import cn.stylefeng.guns.modular.system.dao.UserMapper; import cn.stylefeng.guns.modular.system.mapper.MenuMapper;
import cn.stylefeng.guns.modular.system.model.User; import cn.stylefeng.guns.modular.system.mapper.UserMapper;
import cn.stylefeng.guns.modular.system.service.UserService;
import cn.stylefeng.roses.core.util.SpringContextHolder; import cn.stylefeng.roses.core.util.SpringContextHolder;
import org.apache.shiro.authc.CredentialsException; import org.apache.shiro.authc.CredentialsException;
import org.apache.shiro.authc.LockedAccountException; import org.apache.shiro.authc.LockedAccountException;
...@@ -48,6 +50,9 @@ public class UserAuthServiceServiceImpl implements UserAuthService { ...@@ -48,6 +50,9 @@ public class UserAuthServiceServiceImpl implements UserAuthService {
@Autowired @Autowired
private MenuMapper menuMapper; private MenuMapper menuMapper;
@Autowired
private UserService userService;
public static UserAuthService me() { public static UserAuthService me() {
return SpringContextHolder.getBean(UserAuthService.class); return SpringContextHolder.getBean(UserAuthService.class);
} }
...@@ -62,7 +67,7 @@ public class UserAuthServiceServiceImpl implements UserAuthService { ...@@ -62,7 +67,7 @@ public class UserAuthServiceServiceImpl implements UserAuthService {
throw new CredentialsException(); throw new CredentialsException();
} }
// 账号被冻结 // 账号被冻结
if (user.getStatus() != ManagerStatus.OK.getCode()) { if (!user.getStatus().equals(ManagerStatus.OK.getCode())) {
throw new LockedAccountException(); throw new LockedAccountException();
} }
return user; return user;
...@@ -70,34 +75,35 @@ public class UserAuthServiceServiceImpl implements UserAuthService { ...@@ -70,34 +75,35 @@ public class UserAuthServiceServiceImpl implements UserAuthService {
@Override @Override
public ShiroUser shiroUser(User user) { public ShiroUser shiroUser(User user) {
ShiroUser shiroUser = new ShiroUser();
ShiroUser shiroUser = ShiroKit.createShiroUser(user);
shiroUser.setId(user.getId());
shiroUser.setAccount(user.getAccount()); //用户角色数组
shiroUser.setDeptId(user.getDeptid()); Long[] roleArray = Convert.toLongArray(user.getRoleId());
shiroUser.setDeptName(ConstantFactory.me().getDeptName(user.getDeptid()));
shiroUser.setName(user.getName()); //获取用户角色列表
List<Long> roleList = new ArrayList<>();
Integer[] roleArray = Convert.toIntArray(user.getRoleid()); List<String> roleNameList = new ArrayList<>();
List<Integer> roleList = new ArrayList<Integer>(); for (Long roleId : roleArray) {
List<String> roleNameList = new ArrayList<String>();
for (int roleId : roleArray) {
roleList.add(roleId); roleList.add(roleId);
roleNameList.add(ConstantFactory.me().getSingleRoleName(roleId)); roleNameList.add(ConstantFactory.me().getSingleRoleName(roleId));
} }
shiroUser.setRoleList(roleList); shiroUser.setRoleList(roleList);
shiroUser.setRoleNames(roleNameList); shiroUser.setRoleNames(roleNameList);
//获取用户拥有的菜单
shiroUser.setMenus(userService.getUserMenuNodes(roleList));
return shiroUser; return shiroUser;
} }
@Override @Override
public List<String> findPermissionsByRoleId(Integer roleId) { public List<String> findPermissionsByRoleId(Long roleId) {
return menuMapper.getResUrlsByRoleId(roleId); return menuMapper.getResUrlsByRoleId(roleId);
} }
@Override @Override
public String findRoleNameByRoleId(Integer roleId) { public String findRoleNameByRoleId(Long roleId) {
return ConstantFactory.me().getSingleRoleTip(roleId); return ConstantFactory.me().getSingleRoleTip(roleId);
} }
......
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.stylefeng.guns.core.tag;
import cn.stylefeng.guns.core.common.exception.BizExceptionEnum;
import cn.stylefeng.guns.modular.system.model.Dict;
import cn.stylefeng.guns.modular.system.service.IDictService;
import cn.stylefeng.roses.core.util.ToolUtil;
import cn.stylefeng.roses.kernel.model.exception.ServiceException;
import org.beetl.core.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* 字典标签渲染
*
* @author zhangjiajia
* @Date 2018年6月4日17:33:32
*/
@Component
@Scope("prototype")
public class DictSelectorTag extends Tag {
@Autowired
IDictService iDictService;
@Override
public void render() {
//String tagName = (String) this.args[0];
Map attrs = (Map) args[1];
if (ToolUtil.isEmpty(attrs.get("code"))) {
throw new ServiceException(BizExceptionEnum.ERROR_CODE_EMPTY);
}
//字典类型编码
String code = attrs.get("code").toString();
//控件显示类型select 选择框,radio 单选按钮,checkbox 多选按钮
String type = ToolUtil.isNotEmpty(attrs.get("type")) ? attrs.get("type").toString() : "select";
//开启多选
String multiple = ToolUtil.isNotEmpty(attrs.get("multiple")) ? attrs.get("multiple").toString() : "";
//字典名称
String label = ToolUtil.isNotEmpty(attrs.get("label")) ? attrs.get("label").toString() : "";
//提示
String placeholder = (ToolUtil.isNotEmpty(attrs.get("placeholder")) ? attrs.get("placeholder").toString() : "");
//宽度
String width = ToolUtil.isNotEmpty(attrs.get("width")) ? attrs.get("width").toString() : "248";
//默认值
String value = ToolUtil.isNotEmpty(attrs.get("value")) ? attrs.get("value").toString() : "";
//id
String id = ToolUtil.isNotEmpty(attrs.get("id")) ? attrs.get("id").toString() : "";
//name
String name = ToolUtil.isNotEmpty(attrs.get("name")) ? attrs.get("name").toString() : "";
//分割线
String underline = ToolUtil.isNotEmpty(attrs.get("underline")) ? attrs.get("underline").toString() : "";
//onchange事件
String onchange = ToolUtil.isNotEmpty(attrs.get("onchange")) ? attrs.get("onchange").toString() : "";
//readonly属性
String readonly = ToolUtil.isNotEmpty(attrs.get("readonly")) ? attrs.get("readonly").toString() : "";
//disabled属性
String disabled = ToolUtil.isNotEmpty(attrs.get("disabled")) ? attrs.get("disabled").toString() : "";
//searchnum 下拉选项数量达到多少启用搜索,默认10
int searchnum = ToolUtil.isNum(attrs.get("searchnum")) ? Integer.parseInt(attrs.get("searchnum").toString()) : 10;
//根据code查询字典数据
List<Dict> list = iDictService.selectByParentCode(code);
StringBuffer html = new StringBuffer();
html.append("<div class=\"form-group\">\r\n");
html.append("<label class=\"col-sm-3 control-label\">" + label + "</label>\r\n");
html.append("<div class=\"col-sm-9\">\r\n");
//单选按钮
if ("radio".equals(type)) {
list.forEach(obj -> {
html.append("<label class=\"radio-inline i-checks\">\r\n<input type=\"radio\" ");
//判断控件是否禁用
if ("true".equals(disabled) || "disabled".equals(disabled)) {
html.append("disabled ");
} else {
if (ToolUtil.isNotEmpty(name)) {
html.append("name=\"" + name + "\" ");
}
}
if ("true".equals(readonly) || "disabled".equals(readonly)) {
html.append("disabled ");
}
if (ToolUtil.isNotEmpty(value) && value.equals(obj.getCode())) {
html.append("checked ");
}
html.append("value=\"" + obj.getCode() + "\" >" + obj.getName() + "</label>\r\n");
});
//多选按钮
} else if ("checkbox".equals(type)) {
list.forEach(obj -> {
html.append("<label class=\"checkbox-inline i-checks\">\r\n<input type=\"checkbox\" ");
//判断控件是否禁用
if ("true".equals(disabled) || "disabled".equals(disabled)) {
html.append("disabled ");
} else {
if (ToolUtil.isNotEmpty(name)) {
html.append("name=\"" + name + "\" ");
}
}
if ("true".equals(readonly) || "disabled".equals(readonly)) {
html.append("disabled ");
}
if (ToolUtil.isNotEmpty(value) && value.equals(obj.getCode())) {
html.append("checked ");
}
html.append("value=\"" + obj.getCode() + "\" >" + obj.getName() + "</label>\r\n");
});
//默认select
} else {
//开启多选
if ("true".equals(multiple)) {
if (list.size() >= searchnum) {
html.append("<select multiple ");
} else {
html.append("<select multiple=\"multiple\" size=\"10\" ");
}
} else {
html.append("<select ");
}
//判断控件是否启用提示
if (ToolUtil.isNotEmpty(placeholder)) {
html.append(" data-placeholder=\"" + placeholder + "\" ");
}
//判断控件是否禁用
if ("true".equals(disabled) || "disabled".equals(disabled)) {
html.append("disabled=\"disabled\" ");
} else {
//启用
if (ToolUtil.isNotEmpty(id)) {
html.append("id=\"" + id + "\" ");
}
if (ToolUtil.isNotEmpty(name)) {
html.append("name=\"" + name + "\" ");
}
}
//判断是否启用搜索框
//判断下拉数据,如果查询出来的条数达到启用搜索的数量就启用
if (list.size() >= searchnum) {
html.append("class=\"form-control chosen-select\" style=\"width:" + width + "px\" tabindex=\"1\" \r\n");
} else {
html.append("class=\"form-control\" style=\"width:" + width + "px\" \r\n");
}
//判断控件是否只读
if ("true".equals(readonly) || "readonly".equals(readonly)) {
if (list.size() >= searchnum) {
html.append("disabled=\"disabled\" ");
} else {
html.append("onfocus=\"this.defaultIndex=this.selectedIndex;\" onchange=\"this.selectedIndex=this.defaultIndex;\" ");
}
}
//判断是否绑定onchange事件
if (ToolUtil.isNotEmpty(onchange)) {
html.append("onchange=\"" + onchange + "($(this).children('option:selected').val())\" ");
}
html.append(">");
if (ToolUtil.isNotEmpty(placeholder)) {
html.append("<option value=\"\">" + placeholder + "</option>\r\n");
}
//将查询出来的数据添加到select中
list.forEach(obj -> {
if (ToolUtil.isNotEmpty(value) && value.equals(obj.getCode())) {
html.append("<option selected value=\"" + obj.getCode() + "\">" + obj.getName() + "</option>\r\n");
} else {
html.append("<option value=\"" + obj.getCode() + "\">" + obj.getName() + "</option>\r\n");
}
});
html.append("</select>\r\n");
}
html.append("</div>\r\n</div>\r\n");
//判断是否添加分割线
if (ToolUtil.isNotEmpty(underline) && "true".equals(underline)) {
html.append("<div class=\"hr-line-dashed\" ></div >\r\n");
}
try {
this.ctx.byteWriter.writeString(html.toString());
} catch (IOException e) {
throw new RuntimeException("输出字典标签错误");
}
}
}
...@@ -205,9 +205,9 @@ public class Contrast { ...@@ -205,9 +205,9 @@ public class Contrast {
String value = requests.get(item); String value = requests.get(item);
if (fieldWarpperMethodName != null) { if (fieldWarpperMethodName != null) {
Object valueWarpper = DictFieldWarpperFactory.createFieldWarpper(value, fieldWarpperMethodName); Object valueWarpper = DictFieldWarpperFactory.createFieldWarpper(value, fieldWarpperMethodName);
sb.append(dictMap.get(item) + "=" + valueWarpper + ","); sb.append(dictMap.get(item)).append("=").append(valueWarpper).append(",");
} else { } else {
sb.append(dictMap.get(item) + "=" + value + ","); sb.append(dictMap.get(item)).append("=").append(value).append(",");
} }
} }
return StrUtil.removeSuffix(sb.toString(), ","); return StrUtil.removeSuffix(sb.toString(), ",");
...@@ -216,9 +216,9 @@ public class Contrast { ...@@ -216,9 +216,9 @@ public class Contrast {
String value = requests.get(key); String value = requests.get(key);
if (fieldWarpperMethodName != null) { if (fieldWarpperMethodName != null) {
Object valueWarpper = DictFieldWarpperFactory.createFieldWarpper(value, fieldWarpperMethodName); Object valueWarpper = DictFieldWarpperFactory.createFieldWarpper(value, fieldWarpperMethodName);
sb.append(dictMap.get(key) + "=" + valueWarpper); sb.append(dictMap.get(key)).append("=").append(valueWarpper);
} else { } else {
sb.append(dictMap.get(key) + "=" + value); sb.append(dictMap.get(key)).append("=").append(value);
} }
return sb.toString(); return sb.toString();
} }
......
/**
* Copyright 2018-2020 stylefeng & fengshuonan (sn93@qq.com)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.stylefeng.guns.core.util;
import cn.stylefeng.guns.core.listener.ConfigListener;
/**
* 获取默认图片地址
*
* @author fengshuonan
* @date 2018-10-30-5:50 PM
*/
public class DefaultImages {
/**
* 默认的登录页面背景
*
* @author fengshuonan
* @Date 2018/10/30 5:51 PM
*/
public static String loginBg() {
return ConfigListener.getConf().get("contextPath") + "/assets/common/images/login-register.jpg";
}
/**
* 默认的用户图片的base64编码
*
* @author fengshuonan
* @Date 2018/10/30 5:51 PM
*/
public static String defaultAvatarUrl() {
return ConfigListener.getConf().get("contextPath") + "/system/previewAvatar";
}
/**
* 默认的404错误页面背景
*
* @author fengshuonan
* @Date 2018/10/30 5:51 PM
*/
public static String error404() {
return ConfigListener.getConf().get("contextPath") + "/assets/common/images/error-bg.jpg";
}
}
...@@ -18,8 +18,8 @@ package cn.stylefeng.guns.modular.api; ...@@ -18,8 +18,8 @@ package cn.stylefeng.guns.modular.api;
import cn.stylefeng.guns.core.shiro.ShiroKit; import cn.stylefeng.guns.core.shiro.ShiroKit;
import cn.stylefeng.guns.core.shiro.ShiroUser; import cn.stylefeng.guns.core.shiro.ShiroUser;
import cn.stylefeng.guns.core.util.JwtTokenUtil; import cn.stylefeng.guns.core.util.JwtTokenUtil;
import cn.stylefeng.guns.modular.system.dao.UserMapper; import cn.stylefeng.guns.modular.system.entity.User;
import cn.stylefeng.guns.modular.system.model.User; import cn.stylefeng.guns.modular.system.mapper.UserMapper;
import cn.stylefeng.roses.core.base.controller.BaseController; import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ErrorResponseData; import cn.stylefeng.roses.core.reqres.response.ErrorResponseData;
import org.apache.shiro.authc.SimpleAuthenticationInfo; import org.apache.shiro.authc.SimpleAuthenticationInfo;
...@@ -76,7 +76,7 @@ public class ApiController extends BaseController { ...@@ -76,7 +76,7 @@ public class ApiController extends BaseController {
if (passwordTrueFlag) { if (passwordTrueFlag) {
HashMap<String, Object> result = new HashMap<>(); HashMap<String, Object> result = new HashMap<>();
result.put("token", JwtTokenUtil.generateToken(String.valueOf(user.getId()))); result.put("token", JwtTokenUtil.generateToken(String.valueOf(user.getUserId())));
return result; return result;
} else { } else {
return new ErrorResponseData(500, "账号密码错误!"); return new ErrorResponseData(500, "账号密码错误!");
......
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.stylefeng.guns.modular.system.controller;
import cn.stylefeng.guns.modular.system.service.INoticeService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
import java.util.Map;
/**
* 总览信息
*
* @author fengshuonan
* @Date 2017年3月4日23:05:54
*/
@Controller
@RequestMapping("/blackboard")
public class BlackboardController extends BaseController {
@Autowired
private INoticeService noticeService;
/**
* 跳转到黑板
*/
@RequestMapping("")
public String blackboard(Model model) {
List<Map<String, Object>> notices = noticeService.list(null);
model.addAttribute("noticeList", notices);
return "/blackboard.html";
}
}
...@@ -15,22 +15,26 @@ ...@@ -15,22 +15,26 @@
*/ */
package cn.stylefeng.guns.modular.system.controller; package cn.stylefeng.guns.modular.system.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.stylefeng.guns.core.common.annotion.BussinessLog; import cn.stylefeng.guns.core.common.annotion.BussinessLog;
import cn.stylefeng.guns.core.common.annotion.Permission; import cn.stylefeng.guns.core.common.annotion.Permission;
import cn.stylefeng.guns.core.common.constant.dictmap.DeptDict; import cn.stylefeng.guns.core.common.constant.dictmap.DeptDict;
import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory; import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import cn.stylefeng.guns.core.common.exception.BizExceptionEnum; import cn.stylefeng.guns.core.common.node.TreeviewNode;
import cn.stylefeng.guns.core.common.node.ZTreeNode; import cn.stylefeng.guns.core.common.node.ZTreeNode;
import cn.stylefeng.guns.core.log.LogObjectHolder; import cn.stylefeng.guns.core.log.LogObjectHolder;
import cn.stylefeng.guns.modular.system.model.Dept; import cn.stylefeng.guns.modular.system.entity.Dept;
import cn.stylefeng.guns.modular.system.service.IDeptService; import cn.stylefeng.guns.modular.system.model.DeptDto;
import cn.stylefeng.guns.modular.system.service.DeptService;
import cn.stylefeng.guns.modular.system.warpper.DeptTreeWarpper;
import cn.stylefeng.guns.modular.system.warpper.DeptWarpper; import cn.stylefeng.guns.modular.system.warpper.DeptWarpper;
import cn.stylefeng.roses.core.base.controller.BaseController; import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.core.treebuild.DefaultTreeBuildFactory;
import cn.stylefeng.roses.core.util.ToolUtil; import cn.stylefeng.roses.core.util.ToolUtil;
import cn.stylefeng.roses.kernel.model.exception.ServiceException; import cn.stylefeng.roses.kernel.model.exception.RequestEmptyException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -52,10 +56,13 @@ public class DeptController extends BaseController { ...@@ -52,10 +56,13 @@ public class DeptController extends BaseController {
private String PREFIX = "/system/dept/"; private String PREFIX = "/system/dept/";
@Autowired @Autowired
private IDeptService deptService; private DeptService deptService;
/** /**
* 跳转到部门管理首页 * 跳转到部门管理首页
*
* @author fengshuonan
* @Date 2018/12/23 4:56 PM
*/ */
@RequestMapping("") @RequestMapping("")
public String index() { public String index() {
...@@ -64,6 +71,9 @@ public class DeptController extends BaseController { ...@@ -64,6 +71,9 @@ public class DeptController extends BaseController {
/** /**
* 跳转到添加部门 * 跳转到添加部门
*
* @author fengshuonan
* @Date 2018/12/23 4:56 PM
*/ */
@RequestMapping("/dept_add") @RequestMapping("/dept_add")
public String deptAdd() { public String deptAdd() {
...@@ -72,19 +82,30 @@ public class DeptController extends BaseController { ...@@ -72,19 +82,30 @@ public class DeptController extends BaseController {
/** /**
* 跳转到修改部门 * 跳转到修改部门
*
* @author fengshuonan
* @Date 2018/12/23 4:56 PM
*/ */
@Permission @Permission
@RequestMapping("/dept_update/{deptId}") @RequestMapping("/dept_update")
public String deptUpdate(@PathVariable Integer deptId, Model model) { public String deptUpdate(@RequestParam("deptId") Long deptId) {
if (ToolUtil.isEmpty(deptId)) {
throw new RequestEmptyException();
}
//缓存部门修改前详细信息
Dept dept = deptService.selectById(deptId); Dept dept = deptService.selectById(deptId);
model.addAttribute(dept);
model.addAttribute("pName", ConstantFactory.me().getDeptName(dept.getPid()));
LogObjectHolder.me().set(dept); LogObjectHolder.me().set(dept);
return PREFIX + "dept_edit.html"; return PREFIX + "dept_edit.html";
} }
/** /**
* 获取部门的tree列表 * 获取部门的tree列表,ztree格式
*
* @author fengshuonan
* @Date 2018/12/23 4:56 PM
*/ */
@RequestMapping(value = "/tree") @RequestMapping(value = "/tree")
@ResponseBody @ResponseBody
...@@ -95,66 +116,100 @@ public class DeptController extends BaseController { ...@@ -95,66 +116,100 @@ public class DeptController extends BaseController {
} }
/** /**
* 获取部门的tree列表,treeview格式
*
* @author fengshuonan
* @Date 2018/12/23 4:57 PM
*/
@RequestMapping(value = "/treeview")
@ResponseBody
public List<TreeviewNode> treeview() {
List<TreeviewNode> treeviewNodes = this.deptService.treeviewNodes();
//构建树
DefaultTreeBuildFactory<TreeviewNode> factory = new DefaultTreeBuildFactory<>();
factory.setRootParentId("0");
List<TreeviewNode> results = factory.doTreeBuild(treeviewNodes);
//把子节点为空的设为null
DeptTreeWarpper.clearNull(results);
return results;
}
/**
* 新增部门 * 新增部门
*
* @author fengshuonan
* @Date 2018/12/23 4:57 PM
*/ */
@BussinessLog(value = "添加部门", key = "simplename", dict = DeptDict.class) @BussinessLog(value = "添加部门", key = "simpleName", dict = DeptDict.class)
@RequestMapping(value = "/add") @RequestMapping(value = "/add")
@Permission @Permission
@ResponseBody @ResponseBody
public Object add(Dept dept) { public ResponseData add(Dept dept) {
if (ToolUtil.isOneEmpty(dept, dept.getSimplename())) { this.deptService.addDept(dept);
throw new ServiceException(BizExceptionEnum.REQUEST_NULL); return SUCCESS_TIP;
}
//完善pids,根据pid拿到pid的pids
deptSetPids(dept);
return this.deptService.insert(dept);
} }
/** /**
* 获取所有部门列表 * 获取所有部门列表
*
* @author fengshuonan
* @Date 2018/12/23 4:57 PM
*/ */
@RequestMapping(value = "/list") @RequestMapping(value = "/list")
@Permission @Permission
@ResponseBody @ResponseBody
public Object list(String condition) { public Object list(@RequestParam(value = "condition", required = false) String condition,
List<Map<String, Object>> list = this.deptService.list(condition); @RequestParam(value = "deptId", required = false) String deptId) {
List<Map<String, Object>> list = this.deptService.list(condition, deptId);
return super.warpObject(new DeptWarpper(list)); return super.warpObject(new DeptWarpper(list));
} }
/** /**
* 部门详情 * 部门详情
*
* @author fengshuonan
* @Date 2018/12/23 4:57 PM
*/ */
@RequestMapping(value = "/detail/{deptId}") @RequestMapping(value = "/detail/{deptId}")
@Permission @Permission
@ResponseBody @ResponseBody
public Object detail(@PathVariable("deptId") Integer deptId) { public Object detail(@PathVariable("deptId") Long deptId) {
return deptService.selectById(deptId); Dept dept = deptService.selectById(deptId);
DeptDto deptDto = new DeptDto();
BeanUtil.copyProperties(dept, deptDto);
deptDto.setPName(ConstantFactory.me().getDeptName(deptDto.getPid()));
return deptDto;
} }
/** /**
* 修改部门 * 修改部门
*
* @author fengshuonan
* @Date 2018/12/23 4:57 PM
*/ */
@BussinessLog(value = "修改部门", key = "simplename", dict = DeptDict.class) @BussinessLog(value = "修改部门", key = "simpleName", dict = DeptDict.class)
@RequestMapping(value = "/update") @RequestMapping(value = "/update")
@Permission @Permission
@ResponseBody @ResponseBody
public Object update(Dept dept) { public ResponseData update(Dept dept) {
if (ToolUtil.isEmpty(dept) || dept.getId() == null) { deptService.editDept(dept);
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
deptSetPids(dept);
deptService.updateById(dept);
return SUCCESS_TIP; return SUCCESS_TIP;
} }
/** /**
* 删除部门 * 删除部门
*
* @author fengshuonan
* @Date 2018/12/23 4:57 PM
*/ */
@BussinessLog(value = "删除部门", key = "deptId", dict = DeptDict.class) @BussinessLog(value = "删除部门", key = "deptId", dict = DeptDict.class)
@RequestMapping(value = "/delete") @RequestMapping(value = "/delete")
@Permission @Permission
@ResponseBody @ResponseBody
public Object delete(@RequestParam Integer deptId) { public ResponseData delete(@RequestParam Long deptId) {
//缓存被删除的部门名称 //缓存被删除的部门名称
LogObjectHolder.me().set(ConstantFactory.me().getDeptName(deptId)); LogObjectHolder.me().set(ConstantFactory.me().getDeptName(deptId));
...@@ -164,16 +219,4 @@ public class DeptController extends BaseController { ...@@ -164,16 +219,4 @@ public class DeptController extends BaseController {
return SUCCESS_TIP; return SUCCESS_TIP;
} }
private void deptSetPids(Dept dept) {
if (ToolUtil.isEmpty(dept.getPid()) || dept.getPid().equals(0)) {
dept.setPid(0);
dept.setPids("[0],");
} else {
int pid = dept.getPid();
Dept temp = deptService.selectById(pid);
String pids = temp.getPids();
dept.setPid(pid);
dept.setPids(pids + "[" + pid + "],");
}
}
} }
...@@ -20,19 +20,15 @@ import cn.stylefeng.guns.core.common.annotion.Permission; ...@@ -20,19 +20,15 @@ import cn.stylefeng.guns.core.common.annotion.Permission;
import cn.stylefeng.guns.core.common.constant.Const; import cn.stylefeng.guns.core.common.constant.Const;
import cn.stylefeng.guns.core.common.constant.dictmap.DictMap; import cn.stylefeng.guns.core.common.constant.dictmap.DictMap;
import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory; import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import cn.stylefeng.guns.core.common.exception.BizExceptionEnum;
import cn.stylefeng.guns.core.log.LogObjectHolder; import cn.stylefeng.guns.core.log.LogObjectHolder;
import cn.stylefeng.guns.modular.system.model.Dict; import cn.stylefeng.guns.modular.system.model.DictDto;
import cn.stylefeng.guns.modular.system.service.IDictService; import cn.stylefeng.guns.modular.system.service.DictService;
import cn.stylefeng.guns.modular.system.warpper.DictWarpper; import cn.stylefeng.guns.modular.system.warpper.DictWarpper;
import cn.stylefeng.roses.core.base.controller.BaseController; import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.util.ToolUtil; import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.kernel.model.exception.ServiceException;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
...@@ -53,10 +49,13 @@ public class DictController extends BaseController { ...@@ -53,10 +49,13 @@ public class DictController extends BaseController {
private String PREFIX = "/system/dict/"; private String PREFIX = "/system/dict/";
@Autowired @Autowired
private IDictService dictService; private DictService dictService;
/** /**
* 跳转到字典管理首页 * 跳转到字典管理首页
*
* @author fengshuonan
* @Date 2018/12/23 5:21 PM
*/ */
@RequestMapping("") @RequestMapping("")
public String index() { public String index() {
...@@ -64,46 +63,48 @@ public class DictController extends BaseController { ...@@ -64,46 +63,48 @@ public class DictController extends BaseController {
} }
/** /**
* 跳转到添加字典 * 跳转到添加字典类型
*
* @author fengshuonan
* @Date 2018/12/23 5:21 PM
*/ */
@RequestMapping("/dict_add") @RequestMapping("/dict_add_type")
public String deptAdd() { public String deptAddType() {
return PREFIX + "dict_add.html"; return PREFIX + "dict_add_type.html";
} }
/** /**
* 跳转到修改字典 * 跳转到添加字典条目
*
* @author fengshuonan
* @Date 2018/12/23 5:22 PM
*/ */
@Permission(Const.ADMIN_NAME) @RequestMapping("/dict_add_item")
@RequestMapping("/dict_edit/{dictId}") public String deptAddItem(@RequestParam("dictId") Long dictId, Model model) {
public String deptUpdate(@PathVariable Integer dictId, Model model) { model.addAttribute("dictTypeId", dictId);
Dict dict = dictService.selectById(dictId); model.addAttribute("dictTypeName", ConstantFactory.me().getDictName(dictId));
model.addAttribute("dict", dict); return PREFIX + "dict_add_item.html";
List<Dict> subDicts = dictService.selectList(new EntityWrapper<Dict>().eq("pid", dictId));
model.addAttribute("subDicts", subDicts);
LogObjectHolder.me().set(dict);
return PREFIX + "dict_edit.html";
} }
/** /**
* 新增字典 * 新增字典
* *
* @param dictValues 格式例如 "1:启用;2:禁用;3:冻结" * @author fengshuonan
* @Date 2018/12/23 5:22 PM
*/ */
@BussinessLog(value = "添加字典记录", key = "dictName,dictValues", dict = DictMap.class)
@RequestMapping(value = "/add") @RequestMapping(value = "/add")
@Permission(Const.ADMIN_NAME) @Permission(Const.ADMIN_NAME)
@ResponseBody @ResponseBody
public Object add(String dictCode, String dictTips, String dictName, String dictValues) { public ResponseData add(DictDto dictDto) {
if (ToolUtil.isOneEmpty(dictCode, dictName, dictValues)) { this.dictService.addDict(dictDto);
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
this.dictService.addDict(dictCode, dictName, dictTips, dictValues);
return SUCCESS_TIP; return SUCCESS_TIP;
} }
/** /**
* 获取所有字典列表 * 获取所有字典列表
*
* @author fengshuonan
* @Date 2018/12/23 5:22 PM
*/ */
@RequestMapping(value = "/list") @RequestMapping(value = "/list")
@Permission(Const.ADMIN_NAME) @Permission(Const.ADMIN_NAME)
...@@ -114,43 +115,22 @@ public class DictController extends BaseController { ...@@ -114,43 +115,22 @@ public class DictController extends BaseController {
} }
/** /**
* 字典详情
*/
@RequestMapping(value = "/detail/{dictId}")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object detail(@PathVariable("dictId") Integer dictId) {
return dictService.selectById(dictId);
}
/**
* 修改字典
*/
@BussinessLog(value = "修改字典", key = "dictName,dictValues", dict = DictMap.class)
@RequestMapping(value = "/update")
@Permission(Const.ADMIN_NAME)
@ResponseBody
public Object update(Integer dictId, String dictCode, String dictName, String dictTips, String dictValues) {
if (ToolUtil.isOneEmpty(dictId, dictCode, dictName, dictValues)) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
}
dictService.editDict(dictId, dictCode, dictName, dictTips, dictValues);
return SUCCESS_TIP;
}
/**
* 删除字典记录 * 删除字典记录
*
* @author fengshuonan
* @Date 2018/12/23 5:22 PM
*/ */
@BussinessLog(value = "删除字典记录", key = "dictId", dict = DictMap.class) @BussinessLog(value = "删除字典记录", key = "dictId", dict = DictMap.class)
@RequestMapping(value = "/delete") @RequestMapping(value = "/delete")
@Permission(Const.ADMIN_NAME) @Permission(Const.ADMIN_NAME)
@ResponseBody @ResponseBody
public Object delete(@RequestParam Integer dictId) { public ResponseData delete(@RequestParam Long dictId) {
//缓存被删除的名称 //缓存被删除的名称
LogObjectHolder.me().set(ConstantFactory.me().getDictName(dictId)); LogObjectHolder.me().set(ConstantFactory.me().getDictName(dictId));
this.dictService.delteDict(dictId); this.dictService.delteDict(dictId);
return SUCCESS_TIP; return SUCCESS_TIP;
} }
......
...@@ -22,8 +22,8 @@ import cn.stylefeng.guns.core.common.constant.Const; ...@@ -22,8 +22,8 @@ import cn.stylefeng.guns.core.common.constant.Const;
import cn.stylefeng.guns.core.common.constant.factory.PageFactory; import cn.stylefeng.guns.core.common.constant.factory.PageFactory;
import cn.stylefeng.guns.core.common.constant.state.BizLogType; import cn.stylefeng.guns.core.common.constant.state.BizLogType;
import cn.stylefeng.guns.core.common.page.PageInfoBT; import cn.stylefeng.guns.core.common.page.PageInfoBT;
import cn.stylefeng.guns.modular.system.model.OperationLog; import cn.stylefeng.guns.modular.system.entity.OperationLog;
import cn.stylefeng.guns.modular.system.service.IOperationLogService; import cn.stylefeng.guns.modular.system.service.OperationLogService;
import cn.stylefeng.guns.modular.system.warpper.LogWarpper; import cn.stylefeng.guns.modular.system.warpper.LogWarpper;
import cn.stylefeng.roses.core.base.controller.BaseController; import cn.stylefeng.roses.core.base.controller.BaseController;
import com.baomidou.mybatisplus.mapper.SqlRunner; import com.baomidou.mybatisplus.mapper.SqlRunner;
...@@ -51,10 +51,13 @@ public class LogController extends BaseController { ...@@ -51,10 +51,13 @@ public class LogController extends BaseController {
private static String PREFIX = "/system/log/"; private static String PREFIX = "/system/log/";
@Autowired @Autowired
private IOperationLogService operationLogService; private OperationLogService operationLogService;
/** /**
* 跳转到日志管理的首页 * 跳转到日志管理的首页
*
* @author fengshuonan
* @Date 2018/12/23 5:34 PM
*/ */
@RequestMapping("") @RequestMapping("")
public String index() { public String index() {
...@@ -63,24 +66,40 @@ public class LogController extends BaseController { ...@@ -63,24 +66,40 @@ public class LogController extends BaseController {
/** /**
* 查询操作日志列表 * 查询操作日志列表
*
* @author fengshuonan
* @Date 2018/12/23 5:34 PM
*/ */
@RequestMapping("/list") @RequestMapping("/list")
@Permission(Const.ADMIN_NAME) @Permission(Const.ADMIN_NAME)
@ResponseBody @ResponseBody
public Object list(@RequestParam(required = false) String beginTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String logName, @RequestParam(required = false) Integer logType) { public Object list(@RequestParam(required = false) String beginTime,
@RequestParam(required = false) String endTime,
@RequestParam(required = false) String logName,
@RequestParam(required = false) Integer logType) {
//获取分页参数
Page<OperationLog> page = new PageFactory<OperationLog>().defaultPage(); Page<OperationLog> page = new PageFactory<OperationLog>().defaultPage();
List<Map<String, Object>> result = operationLogService.getOperationLogs(page, beginTime, endTime, logName, BizLogType.valueOf(logType), page.getOrderByField(), page.isAsc());
//根据条件查询操作日志
List<Map<String, Object>> result = operationLogService.getOperationLogs(page, beginTime, endTime, logName,
BizLogType.valueOf(logType), page.getOrderByField(), page.isAsc());
page.setRecords(new LogWarpper(result).wrap()); page.setRecords(new LogWarpper(result).wrap());
return new PageInfoBT<>(page); return new PageInfoBT<>(page);
} }
/** /**
* 查询操作日志详情 * 查询操作日志详情
*
* @author fengshuonan
* @Date 2018/12/23 5:34 PM
*/ */
@RequestMapping("/detail/{id}") @RequestMapping("/detail/{id}")
@Permission(Const.ADMIN_NAME) @Permission(Const.ADMIN_NAME)
@ResponseBody @ResponseBody
public Object detail(@PathVariable Integer id) { public Object detail(@PathVariable Long id) {
OperationLog operationLog = operationLogService.selectById(id); OperationLog operationLog = operationLogService.selectById(id);
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(operationLog); Map<String, Object> stringObjectMap = BeanUtil.beanToMap(operationLog);
return super.warpObject(new LogWarpper(stringObjectMap)); return super.warpObject(new LogWarpper(stringObjectMap));
...@@ -88,6 +107,9 @@ public class LogController extends BaseController { ...@@ -88,6 +107,9 @@ public class LogController extends BaseController {
/** /**
* 清空日志 * 清空日志
*
* @author fengshuonan
* @Date 2018/12/23 5:34 PM
*/ */
@BussinessLog(value = "清空业务日志") @BussinessLog(value = "清空业务日志")
@RequestMapping("/delLog") @RequestMapping("/delLog")
......
...@@ -15,23 +15,13 @@ ...@@ -15,23 +15,13 @@
*/ */
package cn.stylefeng.guns.modular.system.controller; package cn.stylefeng.guns.modular.system.controller;
import cn.stylefeng.guns.core.common.exception.InvalidKaptchaException;
import cn.stylefeng.guns.core.common.node.MenuNode;
import cn.stylefeng.guns.core.log.LogManager; import cn.stylefeng.guns.core.log.LogManager;
import cn.stylefeng.guns.core.log.factory.LogTaskFactory; import cn.stylefeng.guns.core.log.factory.LogTaskFactory;
import cn.stylefeng.guns.core.shiro.ShiroKit; import cn.stylefeng.guns.core.shiro.ShiroKit;
import cn.stylefeng.guns.core.shiro.ShiroUser; import cn.stylefeng.guns.core.shiro.ShiroUser;
import cn.stylefeng.guns.core.util.ApiMenuFilter;
import cn.stylefeng.guns.core.util.KaptchaUtil;
import cn.stylefeng.guns.modular.system.model.User;
import cn.stylefeng.guns.modular.system.service.IMenuService;
import cn.stylefeng.guns.modular.system.service.IUserService;
import cn.stylefeng.roses.core.base.controller.BaseController; import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.google.code.kaptcha.Constants;
import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -50,41 +40,32 @@ import static cn.stylefeng.roses.core.util.HttpContext.getIp; ...@@ -50,41 +40,32 @@ import static cn.stylefeng.roses.core.util.HttpContext.getIp;
@Controller @Controller
public class LoginController extends BaseController { public class LoginController extends BaseController {
@Autowired
private IMenuService menuService;
@Autowired
private IUserService userService;
/** /**
* 跳转到主页 * 跳转到主页
*
* @author fengshuonan
* @Date 2018/12/23 5:41 PM
*/ */
@RequestMapping(value = "/", method = RequestMethod.GET) @RequestMapping(value = "/", method = RequestMethod.GET)
public String index(Model model) { public String index(Model model) {
//获取菜单列表
List<Integer> roleList = ShiroKit.getUser().getRoleList(); //获取当前用户角色列表
List<Long> roleList = ShiroKit.getUserNotNull().getRoleList();
if (roleList == null || roleList.size() == 0) { if (roleList == null || roleList.size() == 0) {
ShiroKit.getSubject().logout(); ShiroKit.getSubject().logout();
model.addAttribute("tips", "该用户没有角色,无法登陆"); model.addAttribute("tips", "该用户没有角色,无法登陆");
return "/login.html"; return "/login.html";
} }
List<MenuNode> menus = menuService.getMenusByRoleIds(roleList);
List<MenuNode> titles = MenuNode.buildTitle(menus);
titles = ApiMenuFilter.build(titles);
model.addAttribute("titles", titles);
//获取用户头像
Integer id = ShiroKit.getUser().getId();
User user = userService.selectById(id);
String avatar = user.getAvatar();
model.addAttribute("avatar", avatar);
return "/index.html"; return "/index.html";
} }
/** /**
* 跳转到登录页面 * 跳转到登录页面
*
* @author fengshuonan
* @Date 2018/12/23 5:41 PM
*/ */
@RequestMapping(value = "/login", method = RequestMethod.GET) @RequestMapping(value = "/login", method = RequestMethod.GET)
public String login() { public String login() {
...@@ -97,6 +78,9 @@ public class LoginController extends BaseController { ...@@ -97,6 +78,9 @@ public class LoginController extends BaseController {
/** /**
* 点击登录执行的动作 * 点击登录执行的动作
*
* @author fengshuonan
* @Date 2018/12/23 5:42 PM
*/ */
@RequestMapping(value = "/login", method = RequestMethod.POST) @RequestMapping(value = "/login", method = RequestMethod.POST)
public String loginVali() { public String loginVali() {
...@@ -105,30 +89,21 @@ public class LoginController extends BaseController { ...@@ -105,30 +89,21 @@ public class LoginController extends BaseController {
String password = super.getPara("password").trim(); String password = super.getPara("password").trim();
String remember = super.getPara("remember"); String remember = super.getPara("remember");
//验证验证码是否正确
if (KaptchaUtil.getKaptchaOnOff()) {
String kaptcha = super.getPara("kaptcha").trim();
String code = (String) super.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY);
if (ToolUtil.isEmpty(kaptcha) || !kaptcha.equalsIgnoreCase(code)) {
throw new InvalidKaptchaException();
}
}
Subject currentUser = ShiroKit.getSubject(); Subject currentUser = ShiroKit.getSubject();
UsernamePasswordToken token = new UsernamePasswordToken(username, password.toCharArray()); UsernamePasswordToken token = new UsernamePasswordToken(username, password.toCharArray());
//如果开启了记住我功能
if ("on".equals(remember)) { if ("on".equals(remember)) {
token.setRememberMe(true); token.setRememberMe(true);
} else { } else {
token.setRememberMe(false); token.setRememberMe(false);
} }
//执行shiro登录操作
currentUser.login(token); currentUser.login(token);
ShiroUser shiroUser = ShiroKit.getUser(); //登录成功,记录登录日志
super.getSession().setAttribute("shiroUser", shiroUser); ShiroUser shiroUser = ShiroKit.getUserNotNull();
super.getSession().setAttribute("username", shiroUser.getAccount());
LogManager.me().executeLog(LogTaskFactory.loginLog(shiroUser.getId(), getIp())); LogManager.me().executeLog(LogTaskFactory.loginLog(shiroUser.getId(), getIp()));
ShiroKit.getSession().setAttribute("sessionFlag", true); ShiroKit.getSession().setAttribute("sessionFlag", true);
...@@ -138,10 +113,13 @@ public class LoginController extends BaseController { ...@@ -138,10 +113,13 @@ public class LoginController extends BaseController {
/** /**
* 退出登录 * 退出登录
*
* @author fengshuonan
* @Date 2018/12/23 5:42 PM
*/ */
@RequestMapping(value = "/logout", method = RequestMethod.GET) @RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logOut() { public String logOut() {
LogManager.me().executeLog(LogTaskFactory.exitLog(ShiroKit.getUser().getId(), getIp())); LogManager.me().executeLog(LogTaskFactory.exitLog(ShiroKit.getUserNotNull().getId(), getIp()));
ShiroKit.getSubject().logout(); ShiroKit.getSubject().logout();
deleteAllCookie(); deleteAllCookie();
return REDIRECT + "/login"; return REDIRECT + "/login";
......
...@@ -20,8 +20,8 @@ import cn.stylefeng.guns.core.common.annotion.Permission; ...@@ -20,8 +20,8 @@ import cn.stylefeng.guns.core.common.annotion.Permission;
import cn.stylefeng.guns.core.common.constant.Const; import cn.stylefeng.guns.core.common.constant.Const;
import cn.stylefeng.guns.core.common.constant.factory.PageFactory; import cn.stylefeng.guns.core.common.constant.factory.PageFactory;
import cn.stylefeng.guns.core.common.page.PageInfoBT; import cn.stylefeng.guns.core.common.page.PageInfoBT;
import cn.stylefeng.guns.modular.system.model.LoginLog; import cn.stylefeng.guns.modular.system.entity.LoginLog;
import cn.stylefeng.guns.modular.system.service.ILoginLogService; import cn.stylefeng.guns.modular.system.service.LoginLogService;
import cn.stylefeng.guns.modular.system.warpper.LogWarpper; import cn.stylefeng.guns.modular.system.warpper.LogWarpper;
import cn.stylefeng.roses.core.base.controller.BaseController; import cn.stylefeng.roses.core.base.controller.BaseController;
import com.baomidou.mybatisplus.mapper.SqlRunner; import com.baomidou.mybatisplus.mapper.SqlRunner;
...@@ -48,10 +48,13 @@ public class LoginLogController extends BaseController { ...@@ -48,10 +48,13 @@ public class LoginLogController extends BaseController {
private static String PREFIX = "/system/log/"; private static String PREFIX = "/system/log/";
@Autowired @Autowired
private ILoginLogService loginLogService; private LoginLogService loginLogService;
/** /**
* 跳转到日志管理的首页 * 跳转到日志管理的首页
*
* @author fengshuonan
* @Date 2018/12/23 5:51 PM
*/ */
@RequestMapping("") @RequestMapping("")
public String index() { public String index() {
...@@ -60,19 +63,32 @@ public class LoginLogController extends BaseController { ...@@ -60,19 +63,32 @@ public class LoginLogController extends BaseController {
/** /**
* 查询登录日志列表 * 查询登录日志列表
*
* @author fengshuonan
* @Date 2018/12/23 5:51 PM
*/ */
@RequestMapping("/list") @RequestMapping("/list")
@Permission(Const.ADMIN_NAME) @Permission(Const.ADMIN_NAME)
@ResponseBody @ResponseBody
public Object list(@RequestParam(required = false) String beginTime, @RequestParam(required = false) String endTime, @RequestParam(required = false) String logName) { public Object list(@RequestParam(required = false) String beginTime,
@RequestParam(required = false) String endTime,
@RequestParam(required = false) String logName) {
//获取分页参数
Page<LoginLog> page = new PageFactory<LoginLog>().defaultPage(); Page<LoginLog> page = new PageFactory<LoginLog>().defaultPage();
//根据条件查询日志
List<Map<String, Object>> result = loginLogService.getLoginLogs(page, beginTime, endTime, logName, page.getOrderByField(), page.isAsc()); List<Map<String, Object>> result = loginLogService.getLoginLogs(page, beginTime, endTime, logName, page.getOrderByField(), page.isAsc());
page.setRecords(new LogWarpper(result).wrap()); page.setRecords(new LogWarpper(result).wrap());
return new PageInfoBT<>(page); return new PageInfoBT<>(page);
} }
/** /**
* 清空日志 * 清空日志
*
* @author fengshuonan
* @Date 2018/12/23 5:51 PM
*/ */
@BussinessLog("清空登录日志") @BussinessLog("清空登录日志")
@RequestMapping("/delLoginLog") @RequestMapping("/delLoginLog")
......
...@@ -15,14 +15,15 @@ ...@@ -15,14 +15,15 @@
*/ */
package cn.stylefeng.guns.modular.system.controller; package cn.stylefeng.guns.modular.system.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.stylefeng.guns.core.common.annotion.BussinessLog; import cn.stylefeng.guns.core.common.annotion.BussinessLog;
import cn.stylefeng.guns.core.common.constant.dictmap.NoticeMap; import cn.stylefeng.guns.core.common.constant.dictmap.NoticeMap;
import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory; import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import cn.stylefeng.guns.core.common.exception.BizExceptionEnum; import cn.stylefeng.guns.core.common.exception.BizExceptionEnum;
import cn.stylefeng.guns.core.log.LogObjectHolder; import cn.stylefeng.guns.core.log.LogObjectHolder;
import cn.stylefeng.guns.core.shiro.ShiroKit; import cn.stylefeng.guns.core.shiro.ShiroKit;
import cn.stylefeng.guns.modular.system.model.Notice; import cn.stylefeng.guns.modular.system.entity.Notice;
import cn.stylefeng.guns.modular.system.service.INoticeService; import cn.stylefeng.guns.modular.system.service.NoticeService;
import cn.stylefeng.guns.modular.system.warpper.NoticeWrapper; import cn.stylefeng.guns.modular.system.warpper.NoticeWrapper;
import cn.stylefeng.roses.core.base.controller.BaseController; import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.util.ToolUtil; import cn.stylefeng.roses.core.util.ToolUtil;
...@@ -52,10 +53,13 @@ public class NoticeController extends BaseController { ...@@ -52,10 +53,13 @@ public class NoticeController extends BaseController {
private String PREFIX = "/system/notice/"; private String PREFIX = "/system/notice/";
@Autowired @Autowired
private INoticeService noticeService; private NoticeService noticeService;
/** /**
* 跳转到通知列表首页 * 跳转到通知列表首页
*
* @author fengshuonan
* @Date 2018/12/23 6:06 PM
*/ */
@RequestMapping("") @RequestMapping("")
public String index() { public String index() {
...@@ -64,6 +68,9 @@ public class NoticeController extends BaseController { ...@@ -64,6 +68,9 @@ public class NoticeController extends BaseController {
/** /**
* 跳转到添加通知 * 跳转到添加通知
*
* @author fengshuonan
* @Date 2018/12/23 6:06 PM
*/ */
@RequestMapping("/notice_add") @RequestMapping("/notice_add")
public String noticeAdd() { public String noticeAdd() {
...@@ -72,27 +79,36 @@ public class NoticeController extends BaseController { ...@@ -72,27 +79,36 @@ public class NoticeController extends BaseController {
/** /**
* 跳转到修改通知 * 跳转到修改通知
*
* @author fengshuonan
* @Date 2018/12/23 6:06 PM
*/ */
@RequestMapping("/notice_update/{noticeId}") @RequestMapping("/notice_update/{noticeId}")
public String noticeUpdate(@PathVariable Integer noticeId, Model model) { public String noticeUpdate(@PathVariable Long noticeId, Model model) {
Notice notice = this.noticeService.selectById(noticeId); Notice notice = this.noticeService.selectById(noticeId);
model.addAttribute("notice", notice); model.addAllAttributes(BeanUtil.beanToMap(notice));
LogObjectHolder.me().set(notice); LogObjectHolder.me().set(notice);
return PREFIX + "notice_edit.html"; return PREFIX + "notice_edit.html";
} }
/** /**
* 跳转到首页通知 * 跳转到首页通知
*
* @author fengshuonan
* @Date 2018/12/23 6:06 PM
*/ */
@RequestMapping("/hello") @RequestMapping("/hello")
public String hello() { public String hello() {
List<Map<String, Object>> notices = noticeService.list(null); List<Map<String, Object>> notices = noticeService.list(null);
super.setAttr("noticeList", notices); super.setAttr("noticeList", notices);
return "/blackboard.html"; return PREFIX + "notice_index.html";
} }
/** /**
* 获取通知列表 * 获取通知列表
*
* @author fengshuonan
* @Date 2018/12/23 6:06 PM
*/ */
@RequestMapping(value = "/list") @RequestMapping(value = "/list")
@ResponseBody @ResponseBody
...@@ -103,6 +119,9 @@ public class NoticeController extends BaseController { ...@@ -103,6 +119,9 @@ public class NoticeController extends BaseController {
/** /**
* 新增通知 * 新增通知
*
* @author fengshuonan
* @Date 2018/12/23 6:06 PM
*/ */
@RequestMapping(value = "/add") @RequestMapping(value = "/add")
@ResponseBody @ResponseBody
...@@ -111,19 +130,22 @@ public class NoticeController extends BaseController { ...@@ -111,19 +130,22 @@ public class NoticeController extends BaseController {
if (ToolUtil.isOneEmpty(notice, notice.getTitle(), notice.getContent())) { if (ToolUtil.isOneEmpty(notice, notice.getTitle(), notice.getContent())) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL); throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
} }
notice.setCreater(ShiroKit.getUser().getId()); notice.setCreateUser(ShiroKit.getUserNotNull().getId());
notice.setCreatetime(new Date()); notice.setCreateTime(new Date());
notice.insert(); this.noticeService.insert(notice);
return SUCCESS_TIP; return SUCCESS_TIP;
} }
/** /**
* 删除通知 * 删除通知
*
* @author fengshuonan
* @Date 2018/12/23 6:06 PM
*/ */
@RequestMapping(value = "/delete") @RequestMapping(value = "/delete")
@ResponseBody @ResponseBody
@BussinessLog(value = "删除通知", key = "noticeId", dict = NoticeMap.class) @BussinessLog(value = "删除通知", key = "noticeId", dict = NoticeMap.class)
public Object delete(@RequestParam Integer noticeId) { public Object delete(@RequestParam Long noticeId) {
//缓存通知名称 //缓存通知名称
LogObjectHolder.me().set(ConstantFactory.me().getNoticeTitle(noticeId)); LogObjectHolder.me().set(ConstantFactory.me().getNoticeTitle(noticeId));
...@@ -135,18 +157,21 @@ public class NoticeController extends BaseController { ...@@ -135,18 +157,21 @@ public class NoticeController extends BaseController {
/** /**
* 修改通知 * 修改通知
*
* @author fengshuonan
* @Date 2018/12/23 6:06 PM
*/ */
@RequestMapping(value = "/update") @RequestMapping(value = "/update")
@ResponseBody @ResponseBody
@BussinessLog(value = "修改通知", key = "title", dict = NoticeMap.class) @BussinessLog(value = "修改通知", key = "title", dict = NoticeMap.class)
public Object update(Notice notice) { public Object update(Notice notice) {
if (ToolUtil.isOneEmpty(notice, notice.getId(), notice.getTitle(), notice.getContent())) { if (ToolUtil.isOneEmpty(notice, notice.getNoticeId(), notice.getTitle(), notice.getContent())) {
throw new ServiceException(BizExceptionEnum.REQUEST_NULL); throw new ServiceException(BizExceptionEnum.REQUEST_NULL);
} }
Notice old = this.noticeService.selectById(notice.getId()); Notice old = this.noticeService.selectById(notice.getNoticeId());
old.setTitle(notice.getTitle()); old.setTitle(notice.getTitle());
old.setContent(notice.getContent()); old.setContent(notice.getContent());
old.updateById(); this.noticeService.updateById(old);
return SUCCESS_TIP; return SUCCESS_TIP;
} }
......
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.stylefeng.guns.modular.system.controller;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollectionUtil;
import cn.stylefeng.guns.core.common.constant.DefaultAvatar;
import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import cn.stylefeng.guns.core.shiro.ShiroKit;
import cn.stylefeng.guns.core.shiro.ShiroUser;
import cn.stylefeng.guns.modular.system.entity.FileInfo;
import cn.stylefeng.guns.modular.system.entity.User;
import cn.stylefeng.guns.modular.system.factory.UserFactory;
import cn.stylefeng.guns.modular.system.service.FileInfoService;
import cn.stylefeng.guns.modular.system.service.UserService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.core.util.ToolUtil;
import cn.stylefeng.roses.kernel.model.exception.RequestEmptyException;
import cn.stylefeng.roses.kernel.model.exception.ServiceException;
import cn.stylefeng.roses.kernel.model.exception.enums.CoreExceptionEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
/**
* 通用控制器
*
* @author fengshuonan
* @Date 2017年2月17日20:27:22
*/
@Controller
@RequestMapping("/system")
@Slf4j
public class SystemController extends BaseController {
private String PREFIX = "/common/";
@Autowired
private UserService userService;
@Autowired
private FileInfoService fileInfoService;
/**
* 通用的树列表选择器
*
* @author fengshuonan
* @Date 2018/12/23 6:59 PM
*/
@RequestMapping("/commonTree")
public String deptTreeList(@RequestParam("formName") String formName,
@RequestParam("formId") String formId,
@RequestParam("treeUrl") String treeUrl, Model model) {
if (ToolUtil.isOneEmpty(formName, formId, treeUrl)) {
throw new RequestEmptyException("请求数据不完整!");
}
try {
model.addAttribute("formName", URLDecoder.decode(formName, "UTF-8"));
model.addAttribute("formId", URLDecoder.decode(formId, "UTF-8"));
model.addAttribute("treeUrl", URLDecoder.decode(treeUrl, "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RequestEmptyException("请求数据不完整!");
}
return PREFIX + "common_tree_dlg.html";
}
/**
* 上传头像
*
* @author fengshuonan
* @Date 2018/11/9 12:45 PM
*/
@RequestMapping("/uploadAvatar")
@ResponseBody
public Object uploadAvatar(@RequestParam String avatar) {
if (ToolUtil.isEmpty(avatar)) {
throw new RequestEmptyException("请求头像为空");
}
avatar = avatar.substring(avatar.indexOf(",") + 1);
fileInfoService.uploadAvatar(avatar);
return SUCCESS_TIP;
}
/**
* 预览头像
*
* @author fengshuonan
* @Date 2018/11/9 12:45 PM
*/
@RequestMapping("/previewAvatar")
@ResponseBody
public Object previewAvatar(HttpServletResponse response) {
ShiroUser currentUser = ShiroKit.getUser();
if (currentUser == null) {
throw new ServiceException(CoreExceptionEnum.NO_CURRENT_USER);
}
//获取当前用户的头像id
User user = userService.selectById(currentUser.getId());
String avatar = user.getAvatar();
//如果头像id为空就返回默认的
if (ToolUtil.isEmpty(avatar)) {
avatar = DefaultAvatar.BASE_64_AVATAR;
} else {
FileInfo fileInfo = fileInfoService.selectById(avatar);
if (fileInfo == null) {
avatar = DefaultAvatar.BASE_64_AVATAR;
} else {
avatar = fileInfo.getFileData();
}
}
//输出图片的文件流
try {
response.setContentType("image/jpeg");
byte[] decode = Base64.decode(avatar);
response.getOutputStream().write(decode);
} catch (IOException e) {
log.error("获取图片的流错误!", avatar);
throw new ServiceException(CoreExceptionEnum.SERVICE_ERROR);
}
return null;
}
/**
* 获取当前用户详情
*
* @author fengshuonan
* @Date 2018/12/23 6:59 PM
*/
@RequestMapping("/currentUserInfo")
@ResponseBody
public ResponseData getUserInfo() {
ShiroUser currentUser = ShiroKit.getUser();
if (currentUser == null) {
throw new ServiceException(CoreExceptionEnum.NO_CURRENT_USER);
}
User user = userService.selectById(currentUser.getId());
Map<String, Object> map = UserFactory.removeUnSafeFields(user);
HashMap<Object, Object> hashMap = CollectionUtil.newHashMap();
hashMap.putAll(map);
hashMap.put("roleName", ConstantFactory.me().getRoleName(user.getRoleId()));
hashMap.put("deptName", ConstantFactory.me().getDeptName(user.getDeptId()));
return ResponseData.success(hashMap);
}
}
<?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="cn.stylefeng.guns.modular.system.dao.DeptMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.system.model.Dept">
<id column="id" property="id"/>
<result column="num" property="num"/>
<result column="pid" property="pid"/>
<result column="pids" property="pids"/>
<result column="simplename" property="simplename"/>
<result column="fullname" property="fullname"/>
<result column="tips" property="tips"/>
<result column="version" property="version"/>
</resultMap>
<select id="tree" resultType="cn.stylefeng.guns.core.common.node.ZTreeNode">
select id,pid as pId,simplename as name,
(
CASE
WHEN (pId = 0 OR pId IS NULL) THEN
'true'
ELSE
'false'
END
) as isOpen from sys_dept
</select>
<select id="list" resultType="map">
select * from sys_dept
<if test="condition != null and condition != ''">
where simplename like CONCAT('%',#{condition},'%') or fullname like CONCAT('%',#{condition},'%')
</if>
order by num ASC
</select>
</mapper>
<?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="cn.stylefeng.guns.modular.system.dao.DictMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.system.model.Dict">
<id column="id" property="id"/>
<result column="num" property="num"/>
<result column="pid" property="pid"/>
<result column="name" property="name"/>
<result column="code" property="code"/>
<result column="tips" property="tips"/>
</resultMap>
<sql id="Base_Column_List">
id, num, pid, name,code,tips
</sql>
<select id="selectByCode" resultType="cn.stylefeng.guns.modular.system.model.Dict">
select
<include refid="Base_Column_List"/>
from sys_dict
where code = #{code}
</select>
<select id="selectByParentCode" resultType="cn.stylefeng.guns.modular.system.model.Dict">
select
<include refid="Base_Column_List"/>
from sys_dict
where pid in(select id from sys_dict where code = #{code}) order by num asc
</select>
<select id="list" resultType="map">
select * from sys_dict
where pid = 0
<if test="condition != null and condition != ''">
AND name like CONCAT('%',#{condition},'%')
</if>
order by id ASC
</select>
</mapper>
<?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="cn.stylefeng.guns.modular.system.dao.NoticeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.system.model.Notice">
<id column="id" property="id"/>
<result column="title" property="title"/>
<result column="type" property="type"/>
<result column="content" property="content"/>
<result column="createtime" property="createtime"/>
<result column="creater" property="creater"/>
</resultMap>
<select id="list" resultType="map">
select * from sys_notice
<if test="condition != null and condition != ''">
where title like CONCAT('%',#{condition},'%') or content like CONCAT('%',#{condition},'%')
</if>
order by createtime DESC
</select>
</mapper>
<?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="cn.stylefeng.guns.modular.system.dao.RelationMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.system.model.Relation">
<id column="id" property="id" />
<result column="menuid" property="menuid" />
<result column="roleid" property="roleid" />
</resultMap>
</mapper>
<?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="cn.stylefeng.guns.modular.system.dao.UserMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.system.model.User">
<id column="id" property="id" />
<result column="avatar" property="avatar" />
<result column="account" property="account" />
<result column="password" property="password" />
<result column="salt" property="salt" />
<result column="name" property="name" />
<result column="birthday" property="birthday" />
<result column="sex" property="sex" />
<result column="email" property="email" />
<result column="phone" property="phone" />
<result column="roleid" property="roleid" />
<result column="deptid" property="deptid" />
<result column="status" property="status" />
<result column="createtime" property="createtime" />
<result column="version" property="version" />
</resultMap>
<sql id="Base_Column_List">
id, account, name, birthday, sex, email, avatar,
phone, roleid,
deptid, status,
createtime, version
</sql>
<sql id="Base_Column_List_With_Pwd">
id, account, name, birthday,password, sex, email, avatar,
phone, roleid,salt,
deptid, status,
createtime, version
</sql>
<select id="selectUsers" resultType="map">
select
<include refid="Base_Column_List" />
from sys_user
where status != 3
<if test="name != null and name != ''">
and (phone like CONCAT('%',#{name},'%')
or account like CONCAT('%',#{name},'%')
or name like CONCAT('%',#{name},'%'))
</if>
<if test="deptid != null and deptid != 0">
and (deptid = #{deptid} or deptid in ( select id from sys_dept where pids like CONCAT('%[', #{deptid}, ']%') ))
</if>
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
and (createTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
</if>
</select>
<update id="setStatus">
update sys_user set status = #{status} where id =
#{userId}
</update>
<update id="changePwd">
update sys_user set password = #{pwd} where id =
#{userId}
</update>
<update id="setRoles">
update sys_user set roleid = #{roleIds} where id =
#{userId}
</update>
<select id="getByAccount" resultType="cn.stylefeng.guns.modular.system.model.User">
select
<include refid="Base_Column_List_With_Pwd" />
from sys_user where account = #{account} and status != 3
</select>
</mapper>
package cn.stylefeng.guns.modular.system.entity;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 数据库链接信息
* </p>
*
* @author stylefeng
* @since 2018-12-07
*/
@TableName("code_dbinfo")
public class CodeDbinfo implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "DB_ID", type = IdType.ID_WORKER)
private Long dbId;
/**
* 别名
*/
@TableField("NAME")
private String name;
/**
* 数据库驱动
*/
@TableField("DB_DRIVER")
private String dbDriver;
/**
* 数据库地址
*/
@TableField("DB_URL")
private String dbUrl;
/**
* 数据库账户
*/
@TableField("DB_USER_NAME")
private String dbUserName;
/**
* 连接密码
*/
@TableField("DB_PASSWORD")
private String dbPassword;
/**
* 数据库类型(字典)
*/
@TableField("DB_TYPE")
private String dbType;
/**
* 创建时间
*/
@TableField(value = "CREATE_TIME", fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@TableField(value = "UPDATE_TIME", fill = FieldFill.UPDATE)
private Date updateTime;
/**
* 创建用户
*/
@TableField(value = "CREATE_USER", fill = FieldFill.INSERT)
private Long createUser;
/**
* 修改用户
*/
@TableField(value = "UPDATE_USER", fill = FieldFill.UPDATE)
private Long updateUser;
public Long getDbId() {
return dbId;
}
public void setDbId(Long dbId) {
this.dbId = dbId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDbDriver() {
return dbDriver;
}
public void setDbDriver(String dbDriver) {
this.dbDriver = dbDriver;
}
public String getDbUrl() {
return dbUrl;
}
public void setDbUrl(String dbUrl) {
this.dbUrl = dbUrl;
}
public String getDbUserName() {
return dbUserName;
}
public void setDbUserName(String dbUserName) {
this.dbUserName = dbUserName;
}
public String getDbPassword() {
return dbPassword;
}
public void setDbPassword(String dbPassword) {
this.dbPassword = dbPassword;
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
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 Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
@Override
public String toString() {
return "CodeDbinfo{" +
", dbId=" + dbId +
", name=" + name +
", dbDriver=" + dbDriver +
", dbUrl=" + dbUrl +
", dbUserName=" + dbUserName +
", dbPassword=" + dbPassword +
", dbType=" + dbType +
", createTime=" + createTime +
", updateTime=" + updateTime +
", createUser=" + createUser +
", updateUser=" + updateUser +
"}";
}
}
package cn.stylefeng.guns.modular.system.model; package cn.stylefeng.guns.modular.system.entity;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
...@@ -13,69 +15,88 @@ import java.io.Serializable; ...@@ -13,69 +15,88 @@ import java.io.Serializable;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-07-11 * @since 2018-12-07
*/ */
@TableName("sys_dept") @TableName("sys_dept")
public class Dept extends Model<Dept> { public class Dept implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 主键id * 主键id
*/ */
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "DEPT_ID", type = IdType.ID_WORKER)
private Integer id; private Long deptId;
/**
* 排序
*/
private Integer num;
/** /**
* 父部门id * 父部门id
*/ */
private Integer pid; @TableField("PID")
private Long pid;
/** /**
* 父级ids * 父级ids
*/ */
@TableField("PIDS")
private String pids; private String pids;
/** /**
* 简称 * 简称
*/ */
private String simplename; @TableField("SIMPLE_NAME")
private String simpleName;
/** /**
* 全称 * 全称
*/ */
private String fullname; @TableField("FULL_NAME")
private String fullName;
/** /**
* 提示 * 描述
*/ */
private String tips; @TableField("DESCRIPTION")
private String description;
/** /**
* 版本(乐观锁保留字段) * 版本(乐观锁保留字段)
*/ */
@TableField("VERSION")
private Integer version; private Integer version;
/**
* 排序
*/
@TableField("SORT")
private Integer sort;
/**
* 创建时间
*/
@TableField(value = "CREATE_TIME", fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@TableField(value = "UPDATE_TIME", fill = FieldFill.UPDATE)
private Date updateTime;
/**
* 创建人
*/
@TableField(value = "CREATE_USER", fill = FieldFill.INSERT)
private Long createUser;
/**
* 修改人
*/
@TableField(value = "UPDATE_USER", fill = FieldFill.UPDATE)
private Long updateUser;
public Integer getId() { public Long getDeptId() {
return id; return deptId;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getNum() {
return num;
} }
public void setNum(Integer num) { public void setDeptId(Long deptId) {
this.num = num; this.deptId = deptId;
} }
public Integer getPid() { public Long getPid() {
return pid; return pid;
} }
public void setPid(Integer pid) { public void setPid(Long pid) {
this.pid = pid; this.pid = pid;
} }
...@@ -87,28 +108,28 @@ public class Dept extends Model<Dept> { ...@@ -87,28 +108,28 @@ public class Dept extends Model<Dept> {
this.pids = pids; this.pids = pids;
} }
public String getSimplename() { public String getSimpleName() {
return simplename; return simpleName;
} }
public void setSimplename(String simplename) { public void setSimpleName(String simpleName) {
this.simplename = simplename; this.simpleName = simpleName;
} }
public String getFullname() { public String getFullName() {
return fullname; return fullName;
} }
public void setFullname(String fullname) { public void setFullName(String fullName) {
this.fullname = fullname; this.fullName = fullName;
} }
public String getTips() { public String getDescription() {
return tips; return description;
} }
public void setTips(String tips) { public void setDescription(String description) {
this.tips = tips; this.description = description;
} }
public Integer getVersion() { public Integer getVersion() {
...@@ -119,22 +140,61 @@ public class Dept extends Model<Dept> { ...@@ -119,22 +140,61 @@ public class Dept extends Model<Dept> {
this.version = version; this.version = version;
} }
@Override public Integer getSort() {
protected Serializable pkVal() { return sort;
return this.id; }
public void setSort(Integer sort) {
this.sort = sort;
}
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 Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
} }
@Override @Override
public String toString() { public String toString() {
return "Dept{" + return "Dept{" +
"id=" + id + ", deptId=" + deptId +
", num=" + num +
", pid=" + pid + ", pid=" + pid +
", pids=" + pids + ", pids=" + pids +
", simplename=" + simplename + ", simpleName=" + simpleName +
", fullname=" + fullname + ", fullName=" + fullName +
", tips=" + tips + ", description=" + description +
", version=" + version + ", version=" + version +
", sort=" + sort +
", createTime=" + createTime +
", updateTime=" + updateTime +
", createUser=" + createUser +
", updateUser=" + updateUser +
"}"; "}";
} }
} }
package cn.stylefeng.guns.modular.system.entity;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 字典表
* </p>
*
* @author stylefeng
* @since 2018-12-07
*/
@TableName("sys_dict")
public class Dict implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@TableId(value = "DICT_ID", type = IdType.ID_WORKER)
private Long dictId;
/**
* 父级字典id
*/
@TableField("PID")
private Long pid;
/**
* 字典名称
*/
@TableField("NAME")
private String name;
/**
* 字典的编码
*/
@TableField("CODE")
private String code;
/**
* 字典描述
*/
@TableField("DESCRIPTION")
private String description;
/**
* 排序
*/
@TableField("SORT")
private Integer sort;
/**
* 创建时间
*/
@TableField(value = "CREATE_TIME", fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@TableField(value = "UPDATE_TIME", fill = FieldFill.UPDATE)
private Date updateTime;
/**
* 创建人
*/
@TableField(value = "CREATE_USER", fill = FieldFill.INSERT)
private Long createUser;
/**
* 修改人
*/
@TableField(value = "UPDATE_USER", fill = FieldFill.UPDATE)
private Long updateUser;
public Long getDictId() {
return dictId;
}
public void setDictId(Long dictId) {
this.dictId = dictId;
}
public Long getPid() {
return pid;
}
public void setPid(Long pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
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 Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
@Override
public String toString() {
return "Dict{" +
", dictId=" + dictId +
", pid=" + pid +
", name=" + name +
", code=" + code +
", description=" + description +
", sort=" + sort +
", createTime=" + createTime +
", updateTime=" + updateTime +
", createUser=" + createUser +
", updateUser=" + updateUser +
"}";
}
}
package cn.stylefeng.guns.modular.system.entity;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 文件信息表
*
* </p>
*
* @author stylefeng
* @since 2018-12-07
*/
@TableName("sys_file_info")
public class FileInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@TableId(value = "FILE_ID", type = IdType.ID_WORKER_STR)
private String fileId;
/**
* base64编码的文件
*/
@TableField("FILE_DATA")
private String fileData;
/**
* 创建时间
*/
@TableField(value = "CREATE_TIME", fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@TableField(value = "UPDATE_TIME", fill = FieldFill.UPDATE)
private Date updateTime;
/**
* 创建用户
*/
@TableField(value = "CREATE_USER", fill = FieldFill.INSERT)
private Long createUser;
/**
* 修改用户
*/
@TableField(value = "UPDATE_USER", fill = FieldFill.UPDATE)
private Long updateUser;
public String getFileId() {
return fileId;
}
public void setFileId(String fileId) {
this.fileId = fileId;
}
public String getFileData() {
return fileData;
}
public void setFileData(String fileData) {
this.fileData = fileData;
}
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 Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
@Override
public String toString() {
return "FileInfo{" +
", fileId=" + fileId +
", fileData=" + fileData +
", createTime=" + createTime +
", updateTime=" + updateTime +
", createUser=" + createUser +
", updateUser=" + updateUser +
"}";
}
}
package cn.stylefeng.guns.modular.system.model; package cn.stylefeng.guns.modular.system.entity;
import com.baomidou.mybatisplus.activerecord.Model; import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName; import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType; import com.baomidou.mybatisplus.enums.IdType;
import java.io.Serializable; import java.io.Serializable;
...@@ -14,74 +15,80 @@ import java.util.Date; ...@@ -14,74 +15,80 @@ import java.util.Date;
* </p> * </p>
* *
* @author stylefeng * @author stylefeng
* @since 2017-07-11 * @since 2018-12-07
*/ */
@TableName("sys_login_log") @TableName("sys_login_log")
public class LoginLog extends Model<LoginLog> { public class LoginLog implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 主键 * 主键
*/ */
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "LOGIN_LOG_ID", type = IdType.ID_WORKER)
private Integer id; private Long loginLogId;
/** /**
* 日志名称 * 日志名称
*/ */
private String logname; @TableField("LOG_NAME")
private String logName;
/** /**
* 管理员id * 管理员id
*/ */
private Integer userid; @TableField("USER_ID")
private Long userId;
/** /**
* 创建时间 * 创建时间
*/ */
private Date createtime; @TableField(value = "CREATE_TIME", fill = FieldFill.INSERT)
private Date createTime;
/** /**
* 是否执行成功 * 是否执行成功
*/ */
@TableField("SUCCEED")
private String succeed; private String succeed;
/** /**
* 具体消息 * 具体消息
*/ */
@TableField("MESSAGE")
private String message; private String message;
/** /**
* 登录ip * 登录ip
*/ */
private String ip; @TableField("IP_ADDRESS")
private String ipAddress;
public Integer getId() { public Long getLoginLogId() {
return id; return loginLogId;
} }
public void setId(Integer id) { public void setLoginLogId(Long loginLogId) {
this.id = id; this.loginLogId = loginLogId;
} }
public String getLogname() { public String getLogName() {
return logname; return logName;
} }
public void setLogname(String logname) { public void setLogName(String logName) {
this.logname = logname; this.logName = logName;
} }
public Integer getUserid() { public Long getUserId() {
return userid; return userId;
} }
public void setUserid(Integer userid) { public void setUserId(Long userId) {
this.userid = userid; this.userId = userId;
} }
public Date getCreatetime() { public Date getCreateTime() {
return createtime; return createTime;
} }
public void setCreatetime(Date createtime) { public void setCreateTime(Date createTime) {
this.createtime = createtime; this.createTime = createTime;
} }
public String getSucceed() { public String getSucceed() {
...@@ -100,29 +107,24 @@ public class LoginLog extends Model<LoginLog> { ...@@ -100,29 +107,24 @@ public class LoginLog extends Model<LoginLog> {
this.message = message; this.message = message;
} }
public String getIp() { public String getIpAddress() {
return ip; return ipAddress;
} }
public void setIp(String ip) { public void setIpAddress(String ipAddress) {
this.ip = ip; this.ipAddress = ipAddress;
}
@Override
protected Serializable pkVal() {
return this.id;
} }
@Override @Override
public String toString() { public String toString() {
return "LoginLog{" + return "LoginLog{" +
"id=" + id + ", loginLogId=" + loginLogId +
", logname=" + logname + ", logName=" + logName +
", userid=" + userid + ", userId=" + userId +
", createtime=" + createtime + ", createTime=" + createTime +
", succeed=" + succeed + ", succeed=" + succeed +
", message=" + message + ", message=" + message +
", ip=" + ip + ", ipAddress=" + ipAddress +
"}"; "}";
} }
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment