mirror of
https://github.com/1024-lab/smart-admin.git
synced 2026-06-02 03:55:59 +00:00
v1.11.0
This commit is contained in:
42
README.md
42
README.md
@@ -1,3 +1,4 @@
|
|||||||
|
### SmartAdmin 2.0 (即 vue3 的 js版本和ts版本 )正在火热开发中,欢迎持续关注 !
|
||||||
#### 简介
|
#### 简介
|
||||||
SmartAdmin由河南·洛阳 [1024创新实验室](https://www.1024lab.net/)团队研发的一套互联网企业级的通用型中后台解决方案!使用最前沿的前后台技术栈SpringBoot和Vue,前后端分离,<font color="#DC143C">**我们开源一套漂亮的代码和一套整洁的代码规范**</font>,让大家在这浮躁的代码世界里感受到一股把代码写好的清流!同时又让开发者节省大量的时间,减少加班,快乐工作,热爱生活。SmartAdmin 让你从认识到忘不了,绝对是你最想要的!
|
SmartAdmin由河南·洛阳 [1024创新实验室](https://www.1024lab.net/)团队研发的一套互联网企业级的通用型中后台解决方案!使用最前沿的前后台技术栈SpringBoot和Vue,前后端分离,<font color="#DC143C">**我们开源一套漂亮的代码和一套整洁的代码规范**</font>,让大家在这浮躁的代码世界里感受到一股把代码写好的清流!同时又让开发者节省大量的时间,减少加班,快乐工作,热爱生活。SmartAdmin 让你从认识到忘不了,绝对是你最想要的!
|
||||||
|
|
||||||
@@ -25,32 +26,32 @@ gitee: [https://gitee.com/lab1024/smart-admin](https://gitee.com/lab1024/smart-
|
|||||||
#### 演示图
|
#### 演示图
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/11.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180453_252f5e9f_5469596.png"/></td>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/12.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180630_ee5b4f46_5469596.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/21.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180737_9363e283_5469596.png"/></td>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/22.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180802_aefb78f4_5469596.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/31.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180821_30fc7aaf_5469596.png")"/></td>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/32.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180844_01ebd7d2_5469596.png")"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/41.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180902_02c8d838_5469596.png"/></td>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/42.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180918_ff1f7ff5_5469596.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/51.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180938_86b39645_5469596.png"/></td>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/52.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180956_69e25a9c_5469596.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/61.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/181013_791d92f0_5469596.png"/></td>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/62.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/181032_9f0dbbee_5469596.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/71.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/181049_099d0169_5469596.png"/></td>
|
||||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/72.png"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/181104_914c457a_5469596.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@@ -106,22 +107,31 @@ ps:以上规范基础都是以团队出发,让团队开心快乐的写代码
|
|||||||
#### 联系我们
|
#### 联系我们
|
||||||
|
|
||||||
[1024创新实验室](https://www.1024lab.net/)
|
[1024创新实验室](https://www.1024lab.net/)
|
||||||
|
公众号
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><img src="https://images.gitee.com/uploads/images/2021/0305/210257_cd96d824_5469596.jpeg"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
SmartAdmin微信群(**加我微信拉你入群!**)
|
SmartAdmin微信群(**加我微信拉你入群!**)
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="http://img.zhuoluodada.cn/wechat/zhuoda-wechat.jpg"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/181125_2ab89aa9_5469596.jpeg"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### 捐赠
|
#### 捐赠
|
||||||
开源不易,感谢捐赠
|
开源不易,感谢捐赠
|
||||||
>*佛祖保佑捐赠这些人写程序永无bug,工资翻倍,迎娶白富美,走上人生巅峰!*
|
>*佛祖保佑捐赠这些人写程序永无bug,工资翻倍,迎娶白富美,走上人生巅峰!*
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="http://img.zhuoluodada.cn/wechat/zhuoda-wechat-money-v1.jpg"/></td>
|
<td><img src="https://images.gitee.com/uploads/images/2020/1208/181143_b6804a87_5469596.jpeg"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
1 更新密码
|
1 超管默认账号
|
||||||
EmployeeController.updatePwd
|
|
||||||
|
|
||||||
2 更新功能点
|
|
||||||
PrivilegeController functionSaveOrUpdate和menuBatchSave、batchSaveFunctionList
|
|
||||||
|
|
||||||
3 超管默认账号
|
|
||||||
sa/123456
|
sa/123456
|
||||||
|
|
||||||
4 执行脚本:
|
2 执行脚本:
|
||||||
先执行:src/main/resources/sql/smart-admin.sql
|
先执行:src/main/resources/sql/smart-admin.sql
|
||||||
再执行:src/main/resources/sql/quartz_mysql_2.3.0.sql
|
再执行:src/main/resources/sql/quartz_mysql_2.3.0.sql
|
||||||
|
|
||||||
5 除dev之外文件
|
3 除dev之外文件
|
||||||
|
|
||||||
6 刷新页面,获取权限是否走缓存
|
4 刷新页面,获取权限是否走缓存
|
||||||
LoginService.getSession
|
LoginService.getSession
|
||||||
|
|
||||||
7 test类中去掉代码生成run
|
5 test类中去掉代码生成run
|
||||||
|
|
||||||
|
6 前端百度统计
|
||||||
@@ -109,12 +109,18 @@
|
|||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--druid -->
|
<!-- druid -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid</artifactId>
|
<artifactId>druid</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- p6spy -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>p6spy</groupId>
|
||||||
|
<artifactId>p6spy</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- swagger begin -->
|
<!-- swagger begin -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
@@ -126,6 +132,14 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<!-- swagger end -->
|
<!-- swagger end -->
|
||||||
|
|
||||||
|
<!-- knife4j begin -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
|
<version>${knife4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- knife4j end -->
|
||||||
|
|
||||||
<!-- guava -->
|
<!-- guava -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
|
|||||||
@@ -26,6 +26,18 @@ public @interface ApiModelPropertyEnum {
|
|||||||
|
|
||||||
String example() default "";
|
String example() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否隐藏
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean hidden() default false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否必须
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
boolean required() default true;
|
boolean required() default true;
|
||||||
|
|
||||||
String dataType() default "";
|
String dataType() default "";
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package net.lab1024.smartadmin.common.anno;
|
package net.lab1024.smartadmin.common.anno;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeTypeEnum;
|
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeTypeEnum;
|
||||||
|
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeWhereInTypeEnum;
|
||||||
|
import net.lab1024.smartadmin.module.system.datascope.strategy.DataScopePowerStrategy;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@@ -23,12 +25,25 @@ public @interface DataScope {
|
|||||||
|
|
||||||
DataScopeTypeEnum dataScopeType() default DataScopeTypeEnum.DEFAULT;
|
DataScopeTypeEnum dataScopeType() default DataScopeTypeEnum.DEFAULT;
|
||||||
|
|
||||||
|
DataScopeWhereInTypeEnum whereInType() default DataScopeWhereInTypeEnum.EMPLOYEE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* DataScopeWhereInTypeEnum.CUSTOM_STRATEGY类型 才可使用joinSqlImplClazz属性
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Class<? extends DataScopePowerStrategy> joinSqlImplClazz() default DataScopePowerStrategy.class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
* 第几个where 条件 从0开始
|
* 第几个where 条件 从0开始
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int whereIndex() default 0;
|
int whereIndex() default 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DataScopeWhereInTypeEnum为CUSTOM_STRATEGY类型时,此属性无效
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
String joinSql() default "";
|
String joinSql() default "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.lab1024.smartadmin.module.system.department.DepartmentResponseCodeCon
|
|||||||
import net.lab1024.smartadmin.module.system.employee.constant.EmployeeResponseCodeConst;
|
import net.lab1024.smartadmin.module.system.employee.constant.EmployeeResponseCodeConst;
|
||||||
import net.lab1024.smartadmin.module.support.file.constant.FileResponseCodeConst;
|
import net.lab1024.smartadmin.module.support.file.constant.FileResponseCodeConst;
|
||||||
import net.lab1024.smartadmin.module.business.log.orderoperatelog.constant.OrderOperateLogOperateTypeConst;
|
import net.lab1024.smartadmin.module.business.log.orderoperatelog.constant.OrderOperateLogOperateTypeConst;
|
||||||
import net.lab1024.smartadmin.module.business.login.LoginResponseCodeConst;
|
import net.lab1024.smartadmin.module.system.login.LoginResponseCodeConst;
|
||||||
import net.lab1024.smartadmin.module.system.position.PositionResponseCodeConst;
|
import net.lab1024.smartadmin.module.system.position.PositionResponseCodeConst;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.constant.PrivilegeResponseCodeConst;
|
import net.lab1024.smartadmin.module.system.privilege.constant.PrivilegeResponseCodeConst;
|
||||||
import net.lab1024.smartadmin.module.system.role.basic.RoleResponseCodeConst;
|
import net.lab1024.smartadmin.module.system.role.basic.RoleResponseCodeConst;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class PageParamDTO {
|
|||||||
|
|
||||||
@NotNull(message = "每页数量不能为空")
|
@NotNull(message = "每页数量不能为空")
|
||||||
@ApiModelProperty(value = "每页数量(不能为空)", example = "10")
|
@ApiModelProperty(value = "每页数量(不能为空)", example = "10")
|
||||||
@Max(value = 200, message = "每页最大为200")
|
@Max(value = 500, message = "每页最大为500")
|
||||||
protected Integer pageSize;
|
protected Integer pageSize;
|
||||||
|
|
||||||
@ApiModelProperty("是否查询总条数")
|
@ApiModelProperty("是否查询总条数")
|
||||||
|
|||||||
@@ -85,6 +85,10 @@ public class ResponseDTO<T> {
|
|||||||
return new ResponseDTO<T>(codeConst, msg);
|
return new ResponseDTO<T>(codeConst, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> ResponseDTO<T> wrapMsg(ResponseCodeConst codeConst, String msg) {
|
||||||
|
return new ResponseDTO<T>(codeConst, msg);
|
||||||
|
}
|
||||||
|
|
||||||
public String getMsg() {
|
public String getMsg() {
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.common.mybatis;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.ibatis.mapping.BoundSql;
|
|
||||||
import org.apache.ibatis.mapping.MappedStatement;
|
|
||||||
import org.apache.ibatis.plugin.*;
|
|
||||||
import org.apache.ibatis.session.ResultHandler;
|
|
||||||
import org.apache.ibatis.session.RowBounds;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [ mybaits sql 拦截 ]
|
|
||||||
*
|
|
||||||
* @author zhuoda
|
|
||||||
* @version 1.0
|
|
||||||
* @company 1024lab.net
|
|
||||||
* @copyright (c) 2019 1024lab.netInc. All rights reserved.
|
|
||||||
* @date
|
|
||||||
* @since JDK1.8
|
|
||||||
*/
|
|
||||||
@Intercepts({@Signature(type = org.apache.ibatis.executor.Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})})
|
|
||||||
@Slf4j
|
|
||||||
public class MyBatisSqlQuerySqlDebugPlugin implements Interceptor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object intercept(Invocation invocation) throws Throwable {
|
|
||||||
MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
|
|
||||||
Object parameter = invocation.getArgs()[1];
|
|
||||||
BoundSql boundSql = mappedStatement.getBoundSql(parameter);
|
|
||||||
log.info(boundSql.getSql()+"\r\n"+boundSql.getParameterMappings().toString());
|
|
||||||
Object obj = invocation.proceed();
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object plugin(Object arg0) {
|
|
||||||
return Plugin.wrap(arg0,this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setProperties(Properties arg0) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.common.mybatis;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.ibatis.mapping.BoundSql;
|
|
||||||
import org.apache.ibatis.mapping.MappedStatement;
|
|
||||||
import org.apache.ibatis.plugin.*;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [ mybaits sql 拦截 ]
|
|
||||||
*
|
|
||||||
* @author zhuoda
|
|
||||||
* @version 1.0
|
|
||||||
* @company 1024lab.net
|
|
||||||
* @copyright (c) 2019 1024lab.netInc. All rights reserved.
|
|
||||||
* @date
|
|
||||||
* @since JDK1.8
|
|
||||||
*/
|
|
||||||
@Intercepts({@Signature(type = org.apache.ibatis.executor.Executor.class, method = "update", args = {MappedStatement.class, Object.class})})
|
|
||||||
@Slf4j
|
|
||||||
public class MyBatisSqlUpdateSqlDebugPlugin implements Interceptor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object intercept(Invocation invocation) throws Throwable {
|
|
||||||
MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
|
|
||||||
Object parameter = invocation.getArgs()[1];
|
|
||||||
BoundSql boundSql = mappedStatement.getBoundSql(parameter);
|
|
||||||
log.info(boundSql.getSql()+"\r\n"+boundSql.getParameterMappings().toString());
|
|
||||||
Object obj = invocation.proceed();
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object plugin(Object arg0) {
|
|
||||||
return Plugin.wrap(arg0,this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setProperties(Properties arg0) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -45,22 +45,23 @@ public class SmartSwaggerApiModelEnumPlugin implements ModelPropertyBuilderPlugi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(ModelPropertyContext context) {
|
public void apply(ModelPropertyContext context) {
|
||||||
Optional<ApiModelPropertyEnum> annotation = Optional.absent();
|
Optional<ApiModelPropertyEnum> enumOptional = Optional.absent();
|
||||||
|
|
||||||
if (context.getAnnotatedElement().isPresent()) {
|
if (context.getAnnotatedElement().isPresent()) {
|
||||||
annotation = annotation.or(findApiModePropertyAnnotation(context.getAnnotatedElement().get()));
|
enumOptional = enumOptional.or(findApiModePropertyAnnotation(context.getAnnotatedElement().get()));
|
||||||
}
|
}
|
||||||
if (context.getBeanPropertyDefinition().isPresent()) {
|
if (context.getBeanPropertyDefinition().isPresent()) {
|
||||||
annotation = annotation.or(findPropertyAnnotation(context.getBeanPropertyDefinition().get(), ApiModelPropertyEnum.class));
|
enumOptional = enumOptional.or(findPropertyAnnotation(context.getBeanPropertyDefinition().get(), ApiModelPropertyEnum.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (annotation.isPresent()) {
|
if (enumOptional.isPresent()) {
|
||||||
Class<? extends BaseEnum> aClass = annotation.get().value();
|
ApiModelPropertyEnum anEnum = enumOptional.get();
|
||||||
String enumInfo = BaseEnum.getInfo(aClass);
|
String enumInfo = BaseEnum.getInfo(anEnum.value());
|
||||||
String enumDesc = annotation.get().enumDesc();
|
context.getBuilder()
|
||||||
context.getBuilder().required(annotation.transform(toIsRequired()).or(false))
|
.required(enumOptional.transform(toIsRequired()).or(false))
|
||||||
.description(enumDesc +":"+enumInfo)
|
.description(anEnum.enumDesc() + ":" + enumInfo)
|
||||||
.example(annotation.transform(toExample()).orNull());
|
.example(enumOptional.transform(toExample()).orNull())
|
||||||
|
.isHidden(anEnum.hidden());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import net.lab1024.smartadmin.common.domain.BaseEnum;
|
|||||||
import javax.validation.ConstraintValidator;
|
import javax.validation.ConstraintValidator;
|
||||||
import javax.validation.ConstraintValidatorContext;
|
import javax.validation.ConstraintValidatorContext;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 枚举类校验器
|
* 枚举类校验器
|
||||||
@@ -15,9 +17,9 @@ import java.util.List;
|
|||||||
public class EnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
public class EnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 枚举类的类对象
|
* 枚举类实例集合
|
||||||
*/
|
*/
|
||||||
private Class<? extends BaseEnum> enumClass;
|
private List<Object> enumValList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否必须
|
* 是否必须
|
||||||
@@ -27,8 +29,9 @@ public class EnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize(CheckEnum constraintAnnotation) {
|
public void initialize(CheckEnum constraintAnnotation) {
|
||||||
// 获取注解传入的枚举类对象
|
// 获取注解传入的枚举类对象
|
||||||
enumClass = constraintAnnotation.enumClazz();
|
|
||||||
required = constraintAnnotation.required();
|
required = constraintAnnotation.required();
|
||||||
|
Class<? extends BaseEnum> enumClass = constraintAnnotation.enumClazz();
|
||||||
|
enumValList = Stream.of(enumClass.getEnumConstants()).map(BaseEnum::getValue).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -44,7 +47,7 @@ public class EnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 校验是否为合法的枚举值
|
// 校验是否为合法的枚举值
|
||||||
return this.hasEnum(value);
|
return enumValList.contains(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,23 +61,11 @@ public class EnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
|||||||
// 必须的情况下 list 不能为空
|
// 必须的情况下 list 不能为空
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (Object obj : list) {
|
// 校验是否重复
|
||||||
boolean hasEnum = this.hasEnum(obj);
|
long count = list.stream().distinct().count();
|
||||||
if (!hasEnum) {
|
if (count != list.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return enumValList.containsAll(list);
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasEnum(Object value) {
|
|
||||||
// 校验是否为合法的枚举值
|
|
||||||
BaseEnum[] enums = enumClass.getEnumConstants();
|
|
||||||
for (BaseEnum baseEnum : enums) {
|
|
||||||
if (baseEnum.getValue().equals(value)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class SmartDruidDataSourceConfig {
|
|||||||
@Value("${spring.datasource.time-between-eviction-runs-millis}")
|
@Value("${spring.datasource.time-between-eviction-runs-millis}")
|
||||||
long timeBetweenEvictionRunsMillis;
|
long timeBetweenEvictionRunsMillis;
|
||||||
|
|
||||||
@Value("${spring.datasource.min-evictable-edle-time-millis}")
|
@Value("${spring.datasource.min-evictable-idle-time-millis}")
|
||||||
long minEvictableIdleTimeMillis;
|
long minEvictableIdleTimeMillis;
|
||||||
|
|
||||||
@Value("${spring.datasource.filters}")
|
@Value("${spring.datasource.filters}")
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ public class SmartKaptchaConfig {
|
|||||||
properties.setProperty("kaptcha.border.color", "34,114,200");
|
properties.setProperty("kaptcha.border.color", "34,114,200");
|
||||||
properties.setProperty("kaptcha.image.width", "125");
|
properties.setProperty("kaptcha.image.width", "125");
|
||||||
properties.setProperty("kaptcha.image.height", "45");
|
properties.setProperty("kaptcha.image.height", "45");
|
||||||
properties.setProperty("kaptcha.textproducer.char.string", "ABCDEFG23456789");
|
properties.setProperty("kaptcha.textproducer.char.string", "0123456789");
|
||||||
properties.setProperty("kaptcha.textproducer.char.length", "5");
|
properties.setProperty("kaptcha.textproducer.char.length", "4");
|
||||||
properties.setProperty("kaptcha.textproducer.font.names", "Arial,Arial Narrow,Serif,Helvetica,Tahoma,Times New Roman,Verdana");
|
properties.setProperty("kaptcha.textproducer.font.names", "Arial,Arial Narrow,Serif,Helvetica,Tahoma,Times New Roman,Verdana");
|
||||||
properties.setProperty("kaptcha.textproducer.font.size", "38");
|
properties.setProperty("kaptcha.textproducer.font.size", "38");
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
package net.lab1024.smartadmin.config;
|
package net.lab1024.smartadmin.config;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
|
||||||
import net.lab1024.smartadmin.common.mybatis.MyBatisSqlQuerySqlDebugPlugin;
|
|
||||||
import net.lab1024.smartadmin.common.mybatis.MyBatisSqlUpdateSqlDebugPlugin;
|
|
||||||
import net.lab1024.smartadmin.constant.SystemEnvironmentEnum;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
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.context.annotation.Profile;
|
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,16 +24,4 @@ public class SmartMybatisPlusConfig {
|
|||||||
return new PaginationInterceptor().setCountSqlParser(new JsqlParserCountOptimize(true));
|
return new PaginationInterceptor().setCountSqlParser(new JsqlParserCountOptimize(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 打印sql log
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
@Profile(SystemEnvironmentEnum.DEV_ENV)
|
|
||||||
ConfigurationCustomizer mybatisConfigurationCustomizer() {
|
|
||||||
return configuration -> {
|
|
||||||
configuration.addInterceptor(new MyBatisSqlUpdateSqlDebugPlugin());
|
|
||||||
configuration.addInterceptor(new MyBatisSqlQuerySqlDebugPlugin());
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.lab1024.smartadmin.config;
|
package net.lab1024.smartadmin.config;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
@@ -8,6 +8,8 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||||
|
import net.lab1024.smartadmin.interceptor.SmartAuthenticationInterceptor;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
@@ -18,11 +20,14 @@ import org.springframework.context.EnvironmentAware;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import springfox.documentation.RequestHandler;
|
import springfox.documentation.RequestHandler;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.ParameterBuilder;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.schema.ModelRef;
|
||||||
import springfox.documentation.service.*;
|
import springfox.documentation.service.*;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||||
@@ -48,6 +53,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@EnableSwagger2
|
@EnableSwagger2
|
||||||
|
@EnableKnife4j
|
||||||
@Configuration
|
@Configuration
|
||||||
@Profile({"dev", "sit", "pre", "prod"})
|
@Profile({"dev", "sit", "pre", "prod"})
|
||||||
public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDefinitionRegistryPostProcessor {
|
public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDefinitionRegistryPostProcessor {
|
||||||
@@ -86,9 +92,9 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
|||||||
|
|
||||||
private String groupName = "default";
|
private String groupName = "default";
|
||||||
|
|
||||||
private List<String> groupList = Lists.newArrayList();
|
private final List<String> groupList = Lists.newArrayList();
|
||||||
|
|
||||||
private Map<String, List<String>> groupMap = Maps.newHashMap();
|
private final Map<String, List<String>> groupMap = Maps.newHashMap();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEnvironment(Environment environment) {
|
public void setEnvironment(Environment environment) {
|
||||||
@@ -105,7 +111,7 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
|||||||
this.groupBuild();
|
this.groupBuild();
|
||||||
for (Map.Entry<String, List<String>> entry : groupMap.entrySet()) {
|
for (Map.Entry<String, List<String>> entry : groupMap.entrySet()) {
|
||||||
String group = entry.getKey();
|
String group = entry.getKey();
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(Docket.class, this :: baseDocket);
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(Docket.class, this::baseDocket);
|
||||||
BeanDefinition beanDefinition = builder.getRawBeanDefinition();
|
BeanDefinition beanDefinition = builder.getRawBeanDefinition();
|
||||||
registry.registerBeanDefinition(group + "Api", beanDefinition);
|
registry.registerBeanDefinition(group + "Api", beanDefinition);
|
||||||
}
|
}
|
||||||
@@ -134,6 +140,16 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Docket baseDocket() {
|
private Docket baseDocket() {
|
||||||
|
// 配置全局参数 token
|
||||||
|
ParameterBuilder tokenPar = new ParameterBuilder();
|
||||||
|
Parameter parameter = tokenPar.name(SmartAuthenticationInterceptor.TOKEN_NAME)
|
||||||
|
.description("token")
|
||||||
|
.modelRef(new ModelRef("string"))
|
||||||
|
.parameterType("header")
|
||||||
|
.defaultValue("")
|
||||||
|
.required(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
// 请求类型过滤规则
|
// 请求类型过滤规则
|
||||||
Predicate<RequestHandler> controllerPredicate = getControllerPredicate();
|
Predicate<RequestHandler> controllerPredicate = getControllerPredicate();
|
||||||
// controller 包路径
|
// controller 包路径
|
||||||
@@ -148,17 +164,18 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
|||||||
.build()
|
.build()
|
||||||
.apiInfo(this.serviceApiInfo())
|
.apiInfo(this.serviceApiInfo())
|
||||||
.securitySchemes(securitySchemes())
|
.securitySchemes(securitySchemes())
|
||||||
.securityContexts(securityContexts());
|
.securityContexts(securityContexts())
|
||||||
|
.globalOperationParameters(Lists.newArrayList(parameter));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ApiKey> securitySchemes() {
|
private List<ApiKey> securitySchemes() {
|
||||||
List<ApiKey> apiKeyList= new ArrayList<>();
|
List<ApiKey> apiKeyList = new ArrayList<>();
|
||||||
apiKeyList.add(new ApiKey("x-access-token", "x-access-token", "header"));
|
apiKeyList.add(new ApiKey("x-access-token", "x-access-token", "header"));
|
||||||
return apiKeyList;
|
return apiKeyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SecurityContext> securityContexts() {
|
private List<SecurityContext> securityContexts() {
|
||||||
List<SecurityContext> securityContexts=new ArrayList<>();
|
List<SecurityContext> securityContexts = new ArrayList<>();
|
||||||
securityContexts.add(
|
securityContexts.add(
|
||||||
SecurityContext.builder()
|
SecurityContext.builder()
|
||||||
.securityReferences(defaultAuth())
|
.securityReferences(defaultAuth())
|
||||||
@@ -171,7 +188,7 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
|||||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
||||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||||
authorizationScopes[0] = authorizationScope;
|
authorizationScopes[0] = authorizationScope;
|
||||||
List<SecurityReference> securityReferences=new ArrayList<>();
|
List<SecurityReference> securityReferences = new ArrayList<>();
|
||||||
securityReferences.add(new SecurityReference("x-access-token", authorizationScopes));
|
securityReferences.add(new SecurityReference("x-access-token", authorizationScopes));
|
||||||
return securityReferences;
|
return securityReferences;
|
||||||
}
|
}
|
||||||
@@ -192,7 +209,11 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
groupIndex++;
|
groupIndex++;
|
||||||
return Predicates.and(RequestHandlerSelectors.withClassAnnotation(RestController.class), methodPredicate);
|
return Predicates.or(
|
||||||
|
Predicates.and(RequestHandlerSelectors.withClassAnnotation(RestController.class), methodPredicate),
|
||||||
|
Predicates.and(
|
||||||
|
RequestHandlerSelectors.withMethodAnnotation(ResponseBody.class), methodPredicate)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiInfo serviceApiInfo() {
|
private ApiInfo serviceApiInfo() {
|
||||||
@@ -212,6 +233,4 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import net.lab1024.smartadmin.common.anno.OperateLog;
|
|||||||
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
||||||
import net.lab1024.smartadmin.module.business.log.LogService;
|
import net.lab1024.smartadmin.module.business.log.LogService;
|
||||||
import net.lab1024.smartadmin.module.business.log.useroperatelog.domain.UserOperateLogEntity;
|
import net.lab1024.smartadmin.module.business.log.useroperatelog.domain.UserOperateLogEntity;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
||||||
import net.lab1024.smartadmin.util.SmartStringUtil;
|
import net.lab1024.smartadmin.util.SmartStringUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import net.lab1024.smartadmin.common.anno.NoNeedLogin;
|
|||||||
import net.lab1024.smartadmin.common.anno.NoValidPrivilege;
|
import net.lab1024.smartadmin.common.anno.NoValidPrivilege;
|
||||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||||
import net.lab1024.smartadmin.constant.CommonConst;
|
import net.lab1024.smartadmin.constant.CommonConst;
|
||||||
import net.lab1024.smartadmin.module.business.login.LoginResponseCodeConst;
|
import net.lab1024.smartadmin.module.system.login.LoginResponseCodeConst;
|
||||||
import net.lab1024.smartadmin.module.business.login.LoginTokenService;
|
import net.lab1024.smartadmin.module.system.login.LoginTokenService;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.service.PrivilegeEmployeeService;
|
import net.lab1024.smartadmin.module.system.privilege.service.PrivilegeEmployeeService;
|
||||||
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
||||||
import net.lab1024.smartadmin.util.SmartStringUtil;
|
import net.lab1024.smartadmin.util.SmartStringUtil;
|
||||||
@@ -36,7 +36,7 @@ import java.util.List;
|
|||||||
@Component
|
@Component
|
||||||
public class SmartAuthenticationInterceptor extends HandlerInterceptorAdapter {
|
public class SmartAuthenticationInterceptor extends HandlerInterceptorAdapter {
|
||||||
|
|
||||||
private static final String TOKEN_NAME = "x-access-token";
|
public static final String TOKEN_NAME = "x-access-token";
|
||||||
|
|
||||||
@Value("${access-control-allow-origin}")
|
@Value("${access-control-allow-origin}")
|
||||||
private String accessControlAllowOrigin;
|
private String accessControlAllowOrigin;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.lab1024.smartadmin.util.SmartStringUtil;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package net.lab1024.smartadmin.module.business.notice;
|
package net.lab1024.smartadmin.module.business.notice;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import net.lab1024.smartadmin.module.business.notice.dao.NoticeDao;
|
import net.lab1024.smartadmin.module.business.notice.dao.NoticeDao;
|
||||||
import net.lab1024.smartadmin.module.business.notice.dao.NoticeReceiveRecordDao;
|
import net.lab1024.smartadmin.module.business.notice.dao.NoticeReceiveRecordDao;
|
||||||
import net.lab1024.smartadmin.module.business.notice.domain.dto.NoticeUpdateDTO;
|
import net.lab1024.smartadmin.module.business.notice.domain.dto.NoticeUpdateDTO;
|
||||||
@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import net.lab1024.smartadmin.common.constant.ResponseCodeConst;
|
|||||||
import net.lab1024.smartadmin.common.domain.PageParamDTO;
|
import net.lab1024.smartadmin.common.domain.PageParamDTO;
|
||||||
import net.lab1024.smartadmin.common.domain.PageResultDTO;
|
import net.lab1024.smartadmin.common.domain.PageResultDTO;
|
||||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import net.lab1024.smartadmin.module.business.notice.dao.NoticeDao;
|
import net.lab1024.smartadmin.module.business.notice.dao.NoticeDao;
|
||||||
import net.lab1024.smartadmin.module.business.notice.dao.NoticeReceiveRecordDao;
|
import net.lab1024.smartadmin.module.business.notice.dao.NoticeReceiveRecordDao;
|
||||||
import net.lab1024.smartadmin.module.business.notice.domain.dto.*;
|
import net.lab1024.smartadmin.module.business.notice.domain.dto.*;
|
||||||
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package net.lab1024.smartadmin.module.business.notice.dao;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import net.lab1024.smartadmin.common.anno.DataScope;
|
||||||
import net.lab1024.smartadmin.module.business.notice.domain.dto.*;
|
import net.lab1024.smartadmin.module.business.notice.domain.dto.*;
|
||||||
import net.lab1024.smartadmin.module.business.notice.domain.entity.NoticeEntity;
|
import net.lab1024.smartadmin.module.business.notice.domain.entity.NoticeEntity;
|
||||||
|
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeWhereInTypeEnum;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -29,6 +31,7 @@ public interface NoticeDao extends BaseMapper<NoticeEntity> {
|
|||||||
* @param queryDTO
|
* @param queryDTO
|
||||||
* @return NoticeEntity
|
* @return NoticeEntity
|
||||||
*/
|
*/
|
||||||
|
@DataScope(joinSql = "n.create_user in (#employeeIds)", whereInType = DataScopeWhereInTypeEnum.EMPLOYEE)
|
||||||
List<NoticeVO> queryByPage(Page page, @Param("queryDTO") NoticeQueryDTO queryDTO);
|
List<NoticeVO> queryByPage(Page page, @Param("queryDTO") NoticeQueryDTO queryDTO);
|
||||||
|
|
||||||
|
|
||||||
@@ -38,6 +41,7 @@ public interface NoticeDao extends BaseMapper<NoticeEntity> {
|
|||||||
* @param employeeId
|
* @param employeeId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@DataScope(joinSql = "e.department_id in (#departmentIds)", whereInType = DataScopeWhereInTypeEnum.DEPARTMENT)
|
||||||
List<NoticeVO> queryUnreadByPage(Page page, @Param("employeeId") Long employeeId, @Param("sendStatus") Integer sendStatus);
|
List<NoticeVO> queryUnreadByPage(Page page, @Param("employeeId") Long employeeId, @Param("sendStatus") Integer sendStatus);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import net.lab1024.smartadmin.module.support.file.domain.dto.FileQueryDTO;
|
|||||||
import net.lab1024.smartadmin.module.support.file.domain.vo.FileVO;
|
import net.lab1024.smartadmin.module.support.file.domain.vo.FileVO;
|
||||||
import net.lab1024.smartadmin.module.support.file.domain.vo.UploadVO;
|
import net.lab1024.smartadmin.module.support.file.domain.vo.UploadVO;
|
||||||
import net.lab1024.smartadmin.module.support.file.service.FileService;
|
import net.lab1024.smartadmin.module.support.file.service.FileService;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import net.lab1024.smartadmin.module.support.file.domain.dto.FileQueryDTO;
|
|||||||
import net.lab1024.smartadmin.module.support.file.domain.entity.FileEntity;
|
import net.lab1024.smartadmin.module.support.file.domain.entity.FileEntity;
|
||||||
import net.lab1024.smartadmin.module.support.file.domain.vo.FileVO;
|
import net.lab1024.smartadmin.module.support.file.domain.vo.FileVO;
|
||||||
import net.lab1024.smartadmin.module.support.file.domain.vo.UploadVO;
|
import net.lab1024.smartadmin.module.support.file.domain.vo.UploadVO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import net.lab1024.smartadmin.util.SmartBaseEnumUtil;
|
import net.lab1024.smartadmin.util.SmartBaseEnumUtil;
|
||||||
import net.lab1024.smartadmin.util.SmartBeanUtil;
|
import net.lab1024.smartadmin.util.SmartBeanUtil;
|
||||||
import net.lab1024.smartadmin.util.SmartPageUtil;
|
import net.lab1024.smartadmin.util.SmartPageUtil;
|
||||||
@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -42,6 +42,4 @@ public class IdGeneratorEntity extends BaseEntity implements Serializable {
|
|||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
private Date updateTime;
|
|
||||||
private Date createTime;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||||||
import net.lab1024.smartadmin.common.domain.BaseEntity;
|
import net.lab1024.smartadmin.common.domain.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [ ]
|
* [ ]
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package net.lab1024.smartadmin.module.support.quartz.service;
|
package net.lab1024.smartadmin.module.support.quartz.service;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.lab1024.smartadmin.common.domain.ITask;
|
||||||
import net.lab1024.smartadmin.module.support.quartz.constant.QuartzConst;
|
import net.lab1024.smartadmin.module.support.quartz.constant.QuartzConst;
|
||||||
import net.lab1024.smartadmin.module.support.quartz.constant.TaskResultEnum;
|
import net.lab1024.smartadmin.module.support.quartz.constant.TaskResultEnum;
|
||||||
import net.lab1024.smartadmin.module.support.quartz.domain.entity.QuartzTaskEntity;
|
import net.lab1024.smartadmin.module.support.quartz.domain.entity.QuartzTaskEntity;
|
||||||
import net.lab1024.smartadmin.module.support.quartz.domain.entity.QuartzTaskLogEntity;
|
import net.lab1024.smartadmin.module.support.quartz.domain.entity.QuartzTaskLogEntity;
|
||||||
import net.lab1024.smartadmin.common.domain.ITask;
|
|
||||||
import net.lab1024.smartadmin.third.SmartApplicationContext;
|
import net.lab1024.smartadmin.third.SmartApplicationContext;
|
||||||
import net.lab1024.smartadmin.util.SmartIPUtil;
|
import net.lab1024.smartadmin.util.SmartIPUtil;
|
||||||
import net.lab1024.smartadmin.util.SmartQuartzUtil;
|
import net.lab1024.smartadmin.util.SmartQuartzUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.quartz.JobDetail;
|
import org.quartz.JobDetail;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
import org.quartz.JobExecutionException;
|
import org.quartz.JobExecutionException;
|
||||||
@@ -35,7 +35,7 @@ public class QuartzTask extends QuartzJobBean {
|
|||||||
@Override
|
@Override
|
||||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||||
JobDetail jobDetail = context.getJobDetail();
|
JobDetail jobDetail = context.getJobDetail();
|
||||||
Object params = jobDetail.getJobDataMap().get(QuartzConst.QUARTZ_PARAMS_KEY);
|
Object params = context.getMergedJobDataMap().get(QuartzConst.QUARTZ_PARAMS_KEY);
|
||||||
JobKey jobKey = jobDetail.getKey();
|
JobKey jobKey = jobDetail.getKey();
|
||||||
|
|
||||||
Long taskId = SmartQuartzUtil.getTaskIdByJobKey(jobKey);
|
Long taskId = SmartQuartzUtil.getTaskIdByJobKey(jobKey);
|
||||||
@@ -47,7 +47,11 @@ public class QuartzTask extends QuartzJobBean {
|
|||||||
QuartzTaskLogEntity taskLogEntity = new QuartzTaskLogEntity();
|
QuartzTaskLogEntity taskLogEntity = new QuartzTaskLogEntity();
|
||||||
taskLogEntity.setTaskId(taskId);
|
taskLogEntity.setTaskId(taskId);
|
||||||
taskLogEntity.setIpAddress(SmartIPUtil.getLocalHostIP());
|
taskLogEntity.setIpAddress(SmartIPUtil.getLocalHostIP());
|
||||||
taskLogEntity.setTaskName(quartzTaskEntity.getTaskName());
|
try {
|
||||||
|
taskLogEntity.setTaskName(quartzTaskEntity.getTaskName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
String paramsStr = null;
|
String paramsStr = null;
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
paramsStr = params.toString();
|
paramsStr = params.toString();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -82,7 +83,7 @@ public class QuartzTaskService {
|
|||||||
@Transactional(rollbackFor = Throwable.class)
|
@Transactional(rollbackFor = Throwable.class)
|
||||||
public ResponseDTO<String> saveOrUpdateTask(QuartzTaskDTO quartzTaskDTO) throws Exception {
|
public ResponseDTO<String> saveOrUpdateTask(QuartzTaskDTO quartzTaskDTO) throws Exception {
|
||||||
ResponseDTO baseValid = this.baseValid(quartzTaskDTO);
|
ResponseDTO baseValid = this.baseValid(quartzTaskDTO);
|
||||||
if (! baseValid.isSuccess()) {
|
if (!baseValid.isSuccess()) {
|
||||||
return baseValid;
|
return baseValid;
|
||||||
}
|
}
|
||||||
Long taskId = quartzTaskDTO.getId();
|
Long taskId = quartzTaskDTO.getId();
|
||||||
@@ -103,7 +104,7 @@ public class QuartzTaskService {
|
|||||||
if (taskBean == null) {
|
if (taskBean == null) {
|
||||||
return ResponseDTO.wrap(ResponseCodeConst.ERROR_PARAM, "taskBean 不存在");
|
return ResponseDTO.wrap(ResponseCodeConst.ERROR_PARAM, "taskBean 不存在");
|
||||||
}
|
}
|
||||||
if (! CronExpression.isValidExpression(quartzTaskDTO.getTaskCron())) {
|
if (!CronExpression.isValidExpression(quartzTaskDTO.getTaskCron())) {
|
||||||
return ResponseDTO.wrap(ResponseCodeConst.ERROR_PARAM, "请传入正确的正则表达式");
|
return ResponseDTO.wrap(ResponseCodeConst.ERROR_PARAM, "请传入正确的正则表达式");
|
||||||
}
|
}
|
||||||
return ResponseDTO.succ();
|
return ResponseDTO.succ();
|
||||||
@@ -129,7 +130,12 @@ public class QuartzTaskService {
|
|||||||
taskEntity.setTaskStatus(updateEntity.getTaskStatus());
|
taskEntity.setTaskStatus(updateEntity.getTaskStatus());
|
||||||
taskEntity.setUpdateTime(new Date());
|
taskEntity.setUpdateTime(new Date());
|
||||||
quartzTaskDao.updateById(taskEntity);
|
quartzTaskDao.updateById(taskEntity);
|
||||||
this.updateQuartzTask(scheduler, taskEntity);
|
if(this.checkExist(taskEntity.getId())){
|
||||||
|
this.updateQuartzTask(scheduler, taskEntity);
|
||||||
|
}else{
|
||||||
|
this.createQuartzTask(scheduler,taskEntity);
|
||||||
|
}
|
||||||
|
|
||||||
return ResponseDTO.succ();
|
return ResponseDTO.succ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +170,7 @@ public class QuartzTaskService {
|
|||||||
}
|
}
|
||||||
quartzTaskEntity.setTaskStatus(TaskStatusEnum.PAUSE.getStatus());
|
quartzTaskEntity.setTaskStatus(TaskStatusEnum.PAUSE.getStatus());
|
||||||
quartzTaskDao.updateById(quartzTaskEntity);
|
quartzTaskDao.updateById(quartzTaskEntity);
|
||||||
this.pauseQuartzTask(scheduler, taskId);
|
this.pauseQuartzTask(scheduler, quartzTaskEntity);
|
||||||
return ResponseDTO.succ();
|
return ResponseDTO.succ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +189,7 @@ public class QuartzTaskService {
|
|||||||
}
|
}
|
||||||
quartzTaskEntity.setTaskStatus(TaskStatusEnum.NORMAL.getStatus());
|
quartzTaskEntity.setTaskStatus(TaskStatusEnum.NORMAL.getStatus());
|
||||||
quartzTaskDao.updateById(quartzTaskEntity);
|
quartzTaskDao.updateById(quartzTaskEntity);
|
||||||
this.resumeQuartzTask(scheduler, taskId);
|
this.resumeQuartzTask(scheduler, quartzTaskEntity);
|
||||||
return ResponseDTO.succ();
|
return ResponseDTO.succ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,6 +238,10 @@ public class QuartzTaskService {
|
|||||||
|
|
||||||
jobDetail.getJobDataMap().put(QuartzConst.QUARTZ_PARAMS_KEY, taskEntity.getTaskParams());
|
jobDetail.getJobDataMap().put(QuartzConst.QUARTZ_PARAMS_KEY, taskEntity.getTaskParams());
|
||||||
scheduler.scheduleJob(jobDetail, trigger);
|
scheduler.scheduleJob(jobDetail, trigger);
|
||||||
|
//如果任务是暂停状态,则暂停任务
|
||||||
|
if (TaskStatusEnum.PAUSE.getStatus().equals(taskEntity.getTaskStatus())) {
|
||||||
|
this.pauseQuartzTask(scheduler, taskEntity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,7 +265,7 @@ public class QuartzTaskService {
|
|||||||
scheduler.rescheduleJob(triggerKey, trigger);
|
scheduler.rescheduleJob(triggerKey, trigger);
|
||||||
//如果更新之前任务是暂停状态,此时再次暂停任务
|
//如果更新之前任务是暂停状态,此时再次暂停任务
|
||||||
if (TaskStatusEnum.PAUSE.getStatus().equals(taskEntity.getTaskStatus())) {
|
if (TaskStatusEnum.PAUSE.getStatus().equals(taskEntity.getTaskStatus())) {
|
||||||
this.pauseQuartzTask(scheduler, Long.valueOf(taskEntity.getId()));
|
this.pauseQuartzTask(scheduler, taskEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,6 +285,11 @@ public class QuartzTaskService {
|
|||||||
JobDataMap dataMap = new JobDataMap();
|
JobDataMap dataMap = new JobDataMap();
|
||||||
dataMap.put(QuartzConst.QUARTZ_PARAMS_KEY, taskEntity.getTaskParams());
|
dataMap.put(QuartzConst.QUARTZ_PARAMS_KEY, taskEntity.getTaskParams());
|
||||||
JobKey jobKey = SmartQuartzUtil.getJobKey(taskEntity.getId());
|
JobKey jobKey = SmartQuartzUtil.getJobKey(taskEntity.getId());
|
||||||
|
if(!scheduler.checkExists(jobKey)){
|
||||||
|
this.createQuartzTask(scheduler,taskEntity);
|
||||||
|
scheduler.triggerJob(jobKey, dataMap);
|
||||||
|
return;
|
||||||
|
}
|
||||||
scheduler.triggerJob(jobKey, dataMap);
|
scheduler.triggerJob(jobKey, dataMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,11 +297,16 @@ public class QuartzTaskService {
|
|||||||
* 暂停任务
|
* 暂停任务
|
||||||
*
|
*
|
||||||
* @param scheduler
|
* @param scheduler
|
||||||
* @param taskId
|
* @param quartzTaskEntity
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private void pauseQuartzTask(Scheduler scheduler, Long taskId) throws Exception {
|
private void pauseQuartzTask(Scheduler scheduler, QuartzTaskEntity quartzTaskEntity) throws Exception {
|
||||||
JobKey jobKey = SmartQuartzUtil.getJobKey(taskId);
|
JobKey jobKey = SmartQuartzUtil.getJobKey(quartzTaskEntity.getId());
|
||||||
|
if(!scheduler.checkExists(jobKey)){
|
||||||
|
this.createQuartzTask(scheduler,quartzTaskEntity);
|
||||||
|
scheduler.pauseJob(jobKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
scheduler.pauseJob(jobKey);
|
scheduler.pauseJob(jobKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,11 +314,15 @@ public class QuartzTaskService {
|
|||||||
* 恢复任务
|
* 恢复任务
|
||||||
*
|
*
|
||||||
* @param scheduler
|
* @param scheduler
|
||||||
* @param taskId
|
* @param quartzTaskEntity
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private void resumeQuartzTask(Scheduler scheduler, Long taskId) throws Exception {
|
private void resumeQuartzTask(Scheduler scheduler, QuartzTaskEntity quartzTaskEntity) throws Exception {
|
||||||
JobKey jobKey = SmartQuartzUtil.getJobKey(taskId);
|
JobKey jobKey = SmartQuartzUtil.getJobKey(quartzTaskEntity.getId());
|
||||||
|
if(!scheduler.checkExists(jobKey)){
|
||||||
|
this.createQuartzTask(scheduler,quartzTaskEntity);
|
||||||
|
return;
|
||||||
|
}
|
||||||
scheduler.resumeJob(jobKey);
|
scheduler.resumeJob(jobKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +335,15 @@ public class QuartzTaskService {
|
|||||||
*/
|
*/
|
||||||
private void deleteQuartzTask(Scheduler scheduler, Long taskId) throws Exception {
|
private void deleteQuartzTask(Scheduler scheduler, Long taskId) throws Exception {
|
||||||
JobKey jobKey = SmartQuartzUtil.getJobKey(taskId);
|
JobKey jobKey = SmartQuartzUtil.getJobKey(taskId);
|
||||||
|
if(!scheduler.checkExists(jobKey)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
scheduler.deleteJob(jobKey);
|
scheduler.deleteJob(jobKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Boolean checkExist(Long taskId) throws Exception{
|
||||||
|
JobKey jobKey = SmartQuartzUtil.getJobKey(taskId);
|
||||||
|
return scheduler.checkExists(jobKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.lab1024.smartadmin.module.support.quartz.task.test;
|
package net.lab1024.smartadmin.module.support.quartz.task.test;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.smartadmin.common.domain.ITask;
|
import net.lab1024.smartadmin.common.domain.ITask;
|
||||||
import net.lab1024.smartadmin.util.SmartDateUtil;
|
import net.lab1024.smartadmin.util.SmartDateUtil;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -16,11 +17,12 @@ import java.util.Date;
|
|||||||
* @date 2019/4/13 0013 下午 14:26
|
* @date 2019/4/13 0013 下午 14:26
|
||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Component("exampleTask")
|
@Component("exampleTask")
|
||||||
public class Example implements ITask {
|
public class Example implements ITask {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String paramJson) throws Exception {
|
public void execute(String paramJson) throws Exception {
|
||||||
System.out.println(SmartDateUtil.formatYMDHMS(new Date()) + ",今天搬了" + System.currentTimeMillis() + "块砖,paramJson:" + paramJson);
|
log.warn("{}-今天搬了{}块砖,paramJson:{}",SmartDateUtil.formatYMDHMS(new Date()),System.currentTimeMillis(),paramJson );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package net.lab1024.smartadmin.module.system.datascope.constant;
|
package net.lab1024.smartadmin.module.system.datascope.constant;
|
||||||
|
|
||||||
|
|
||||||
|
import net.lab1024.smartadmin.common.domain.BaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [ ]
|
* [ ]
|
||||||
*
|
*
|
||||||
@@ -11,30 +13,32 @@ package net.lab1024.smartadmin.module.system.datascope.constant;
|
|||||||
* @date 2019/4/28 0028 下午 15:37
|
* @date 2019/4/28 0028 下午 15:37
|
||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
public enum DataScopeTypeEnum {
|
public enum DataScopeTypeEnum implements BaseEnum {
|
||||||
|
|
||||||
DEFAULT(0,0,"默认类型","数据范围样例");
|
DEFAULT(0,0,"默认类型","数据范围样例");
|
||||||
|
|
||||||
private Integer type;
|
private Integer value;
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
private String name;
|
private String name;
|
||||||
private String desc;
|
private String desc;
|
||||||
|
|
||||||
DataScopeTypeEnum(Integer type,Integer sort,String name,String desc) {
|
DataScopeTypeEnum(Integer value,Integer sort,String name,String desc) {
|
||||||
this.type = type;
|
this.value = value;
|
||||||
this.sort = sort;
|
this.sort = sort;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getType() {
|
@Override
|
||||||
return type;
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getSort() {
|
public Integer getSort() {
|
||||||
return sort;
|
return sort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getDesc() {
|
public String getDesc() {
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package net.lab1024.smartadmin.module.system.datascope.constant;
|
package net.lab1024.smartadmin.module.system.datascope.constant;
|
||||||
|
|
||||||
|
|
||||||
|
import net.lab1024.smartadmin.common.domain.BaseEnum;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -14,7 +16,7 @@ import java.util.Optional;
|
|||||||
* @date 2019/4/28 0028 下午 15:37
|
* @date 2019/4/28 0028 下午 15:37
|
||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
public enum DataScopeViewTypeEnum {
|
public enum DataScopeViewTypeEnum implements BaseEnum {
|
||||||
|
|
||||||
ME(0,0,"本人"),
|
ME(0,0,"本人"),
|
||||||
|
|
||||||
@@ -24,32 +26,29 @@ public enum DataScopeViewTypeEnum {
|
|||||||
|
|
||||||
ALL(3,15,"全部");
|
ALL(3,15,"全部");
|
||||||
|
|
||||||
private Integer type;
|
private Integer value;
|
||||||
private Integer level;
|
private Integer level;
|
||||||
private String name;
|
private String desc;
|
||||||
|
|
||||||
DataScopeViewTypeEnum(Integer type,Integer level, String name) {
|
DataScopeViewTypeEnum(Integer value,Integer level, String desc) {
|
||||||
this.type = type;
|
this.value = value;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.name = name;
|
this.desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getType() {
|
@Override
|
||||||
return type;
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getLevel() {
|
public Integer getLevel() {
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
@Override
|
||||||
return name;
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataScopeViewTypeEnum valueOf(Integer type) {
|
|
||||||
DataScopeViewTypeEnum[] values = DataScopeViewTypeEnum.values();
|
|
||||||
Optional<DataScopeViewTypeEnum> first = Arrays.stream(values).filter(e -> e.getType().equals(type)).findFirst();
|
|
||||||
return !first.isPresent() ? null : first.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package net.lab1024.smartadmin.module.system.datascope.constant;
|
package net.lab1024.smartadmin.module.system.datascope.constant;
|
||||||
|
|
||||||
|
import net.lab1024.smartadmin.common.domain.BaseEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [ ]
|
* [ ]
|
||||||
*
|
*
|
||||||
@@ -10,25 +12,28 @@ package net.lab1024.smartadmin.module.system.datascope.constant;
|
|||||||
* @date 2019/5/8 0008 下午 16:00
|
* @date 2019/5/8 0008 下午 16:00
|
||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
public enum DataScopeWhereInTypeEnum {
|
public enum DataScopeWhereInTypeEnum implements BaseEnum {
|
||||||
|
|
||||||
EMPLOYEE(0,"以员工IN"),
|
EMPLOYEE(0,"以员工IN"),
|
||||||
|
|
||||||
DEPARTMENT(1,"以部门IN");
|
DEPARTMENT(1,"以部门IN"),
|
||||||
|
|
||||||
private Integer type;
|
CUSTOM_STRATEGY(2,"自定义策略");
|
||||||
|
|
||||||
|
private Integer value;
|
||||||
private String desc;
|
private String desc;
|
||||||
|
|
||||||
DataScopeWhereInTypeEnum(Integer type, String desc) {
|
DataScopeWhereInTypeEnum(Integer value, String desc) {
|
||||||
this.type = type;
|
this.value = value;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getType() {
|
@Override
|
||||||
return type;
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getDesc() {
|
public String getDesc() {
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package net.lab1024.smartadmin.module.system.datascope.domain.dto;
|
package net.lab1024.smartadmin.module.system.datascope.domain.dto;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeTypeEnum;
|
||||||
|
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeWhereInTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [ ]
|
* [ ]
|
||||||
@@ -15,11 +17,24 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class DataScopeSqlConfigDTO {
|
public class DataScopeSqlConfigDTO {
|
||||||
|
|
||||||
private Integer dataScopeType;
|
/**
|
||||||
|
* 数据范围类型
|
||||||
|
* {@link DataScopeTypeEnum}
|
||||||
|
*/
|
||||||
|
private DataScopeTypeEnum dataScopeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* join sql 具体实现类
|
||||||
|
*/
|
||||||
|
private Class joinSqlImplClazz;
|
||||||
|
|
||||||
private String joinSql;
|
private String joinSql;
|
||||||
|
|
||||||
private Integer whereIndex;
|
private Integer whereIndex;
|
||||||
|
|
||||||
private Integer dataScopeWhereInType;
|
/**
|
||||||
|
* whereIn类型
|
||||||
|
* {@link DataScopeWhereInTypeEnum}
|
||||||
|
*/
|
||||||
|
private DataScopeWhereInTypeEnum dataScopeWhereInType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class DataScopeService {
|
|||||||
DataScopeViewTypeEnum[] enums = DataScopeViewTypeEnum.class.getEnumConstants();
|
DataScopeViewTypeEnum[] enums = DataScopeViewTypeEnum.class.getEnumConstants();
|
||||||
DataScopeViewTypeVO dataScopeViewTypeDTO;
|
DataScopeViewTypeVO dataScopeViewTypeDTO;
|
||||||
for (DataScopeViewTypeEnum viewTypeEnum : enums) {
|
for (DataScopeViewTypeEnum viewTypeEnum : enums) {
|
||||||
dataScopeViewTypeDTO = DataScopeViewTypeVO.builder().viewType(viewTypeEnum.getType()).viewTypeLevel(viewTypeEnum.getLevel()).viewTypeName(viewTypeEnum.getName()).build();
|
dataScopeViewTypeDTO = DataScopeViewTypeVO.builder().viewType(viewTypeEnum.getValue()).viewTypeLevel(viewTypeEnum.getLevel()).viewTypeName(viewTypeEnum.getDesc()).build();
|
||||||
viewTypeList.add(dataScopeViewTypeDTO);
|
viewTypeList.add(dataScopeViewTypeDTO);
|
||||||
}
|
}
|
||||||
Comparator<DataScopeViewTypeVO> comparator = (h1, h2) -> h1.getViewTypeLevel().compareTo(h2.getViewTypeLevel());
|
Comparator<DataScopeViewTypeVO> comparator = (h1, h2) -> h1.getViewTypeLevel().compareTo(h2.getViewTypeLevel());
|
||||||
@@ -72,7 +72,7 @@ public class DataScopeService {
|
|||||||
DataScopeDTO dataScopeDTO;
|
DataScopeDTO dataScopeDTO;
|
||||||
for (DataScopeTypeEnum typeEnum : enums) {
|
for (DataScopeTypeEnum typeEnum : enums) {
|
||||||
dataScopeDTO =
|
dataScopeDTO =
|
||||||
DataScopeDTO.builder().dataScopeType(typeEnum.getType()).dataScopeTypeDesc(typeEnum.getDesc()).dataScopeTypeName(typeEnum.getName()).dataScopeTypeSort(typeEnum.getSort()).build();
|
DataScopeDTO.builder().dataScopeType(typeEnum.getValue()).dataScopeTypeDesc(typeEnum.getDesc()).dataScopeTypeName(typeEnum.getName()).dataScopeTypeSort(typeEnum.getSort()).build();
|
||||||
dataScopeTypeList.add(dataScopeDTO);
|
dataScopeTypeList.add(dataScopeDTO);
|
||||||
}
|
}
|
||||||
Comparator<DataScopeDTO> comparator = (h1, h2) -> h1.getDataScopeTypeSort().compareTo(h2.getDataScopeTypeSort());
|
Comparator<DataScopeDTO> comparator = (h1, h2) -> h1.getDataScopeTypeSort().compareTo(h2.getDataScopeTypeSort());
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
package net.lab1024.smartadmin.module.system.datascope.service;
|
package net.lab1024.smartadmin.module.system.datascope.service;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.smartadmin.common.anno.DataScope;
|
import net.lab1024.smartadmin.common.anno.DataScope;
|
||||||
|
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeTypeEnum;
|
||||||
|
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeViewTypeEnum;
|
||||||
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeWhereInTypeEnum;
|
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeWhereInTypeEnum;
|
||||||
import net.lab1024.smartadmin.module.system.datascope.domain.dto.DataScopeSqlConfigDTO;
|
import net.lab1024.smartadmin.module.system.datascope.domain.dto.DataScopeSqlConfigDTO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.datascope.strategy.DataScopePowerStrategy;
|
||||||
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
|
import net.lab1024.smartadmin.third.SmartApplicationContext;
|
||||||
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -32,6 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
* @date 2019/4/29 0029 上午 10:12
|
* @date 2019/4/29 0029 上午 10:12
|
||||||
* @since JDK1.8
|
* @since JDK1.8
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class DataScopeSqlConfigService {
|
public class DataScopeSqlConfigService {
|
||||||
|
|
||||||
@@ -67,9 +73,10 @@ public class DataScopeSqlConfigService {
|
|||||||
DataScope dataScopeAnnotation = method.getAnnotation(DataScope.class);
|
DataScope dataScopeAnnotation = method.getAnnotation(DataScope.class);
|
||||||
if (dataScopeAnnotation != null) {
|
if (dataScopeAnnotation != null) {
|
||||||
DataScopeSqlConfigDTO configDTO = new DataScopeSqlConfigDTO();
|
DataScopeSqlConfigDTO configDTO = new DataScopeSqlConfigDTO();
|
||||||
configDTO.setDataScopeType(dataScopeAnnotation.dataScopeType().getType());
|
configDTO.setDataScopeType(dataScopeAnnotation.dataScopeType());
|
||||||
configDTO.setJoinSql(dataScopeAnnotation.joinSql());
|
configDTO.setJoinSql(dataScopeAnnotation.joinSql());
|
||||||
configDTO.setWhereIndex(dataScopeAnnotation.whereIndex());
|
configDTO.setWhereIndex(dataScopeAnnotation.whereIndex());
|
||||||
|
configDTO.setDataScopeWhereInType(dataScopeAnnotation.whereInType());
|
||||||
dataScopeMethodMap.put(method.getDeclaringClass().getSimpleName() + "." + method.getName(), configDTO);
|
dataScopeMethodMap.put(method.getDeclaringClass().getSimpleName() + "." + method.getName(), configDTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,12 +101,26 @@ public class DataScopeSqlConfigService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getJoinSql(DataScopeSqlConfigDTO sqlConfigDTO) {
|
public String getJoinSql(DataScopeSqlConfigDTO sqlConfigDTO) {
|
||||||
Integer dataScopeType = sqlConfigDTO.getDataScopeType();
|
DataScopeTypeEnum dataScopeTypeEnum = sqlConfigDTO.getDataScopeType();
|
||||||
String joinSql = sqlConfigDTO.getJoinSql();
|
String joinSql = sqlConfigDTO.getJoinSql();
|
||||||
RequestTokenBO requestToken = SmartRequestTokenUtil.getThreadLocalUser();
|
RequestTokenBO requestToken = SmartRequestTokenUtil.getThreadLocalUser();
|
||||||
Long employeeId = requestToken.getRequestUserId();
|
Long employeeId = requestToken.getRequestUserId();
|
||||||
if (DataScopeWhereInTypeEnum.EMPLOYEE.getType().equals(sqlConfigDTO.getDataScopeWhereInType())) {
|
if (DataScopeWhereInTypeEnum.CUSTOM_STRATEGY == sqlConfigDTO.getDataScopeWhereInType()) {
|
||||||
List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(dataScopeType, employeeId);
|
Class strategyClass = sqlConfigDTO.getJoinSqlImplClazz();
|
||||||
|
if(strategyClass == null){
|
||||||
|
log.warn("data scope custom strategy class is null");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
DataScopePowerStrategy powerStrategy = (DataScopePowerStrategy)SmartApplicationContext.getBean(sqlConfigDTO.getJoinSqlImplClazz());
|
||||||
|
if (powerStrategy == null) {
|
||||||
|
log.warn("data scope custom strategy class:{} ,bean is null",sqlConfigDTO.getJoinSqlImplClazz());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
DataScopeViewTypeEnum viewTypeEnum = dataScopeViewService.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
|
||||||
|
return powerStrategy.getCondition(viewTypeEnum,sqlConfigDTO);
|
||||||
|
}
|
||||||
|
if (DataScopeWhereInTypeEnum.EMPLOYEE == sqlConfigDTO.getDataScopeWhereInType()) {
|
||||||
|
List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(dataScopeTypeEnum, employeeId);
|
||||||
if (CollectionUtils.isEmpty(canViewEmployeeIds)) {
|
if (CollectionUtils.isEmpty(canViewEmployeeIds)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -107,8 +128,8 @@ public class DataScopeSqlConfigService {
|
|||||||
String sql = joinSql.replaceAll(EMPLOYEE_PARAM, employeeIds);
|
String sql = joinSql.replaceAll(EMPLOYEE_PARAM, employeeIds);
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
if (DataScopeWhereInTypeEnum.DEPARTMENT.getType().equals(sqlConfigDTO.getDataScopeWhereInType())) {
|
if (DataScopeWhereInTypeEnum.DEPARTMENT == sqlConfigDTO.getDataScopeWhereInType()) {
|
||||||
List<Long> canViewDepartmentIds = dataScopeViewService.getCanViewDepartmentId(dataScopeType, employeeId);
|
List<Long> canViewDepartmentIds = dataScopeViewService.getCanViewDepartmentId(dataScopeTypeEnum, employeeId);
|
||||||
if (CollectionUtils.isEmpty(canViewDepartmentIds)) {
|
if (CollectionUtils.isEmpty(canViewDepartmentIds)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package net.lab1024.smartadmin.module.system.datascope.service;
|
package net.lab1024.smartadmin.module.system.datascope.service;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import net.lab1024.smartadmin.module.system.datascope.DataScopeRoleDao;
|
import net.lab1024.smartadmin.module.system.datascope.DataScopeRoleDao;
|
||||||
|
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeTypeEnum;
|
||||||
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeViewTypeEnum;
|
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeViewTypeEnum;
|
||||||
import net.lab1024.smartadmin.module.system.datascope.domain.entity.DataScopeRoleEntity;
|
import net.lab1024.smartadmin.module.system.datascope.domain.entity.DataScopeRoleEntity;
|
||||||
import net.lab1024.smartadmin.module.system.department.DepartmentTreeService;
|
import net.lab1024.smartadmin.module.system.department.DepartmentTreeService;
|
||||||
@@ -10,7 +12,7 @@ import net.lab1024.smartadmin.module.system.employee.domain.entity.EmployeeEntit
|
|||||||
import net.lab1024.smartadmin.module.system.employee.domain.vo.EmployeeVO;
|
import net.lab1024.smartadmin.module.system.employee.domain.vo.EmployeeVO;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.service.PrivilegeEmployeeService;
|
import net.lab1024.smartadmin.module.system.privilege.service.PrivilegeEmployeeService;
|
||||||
import net.lab1024.smartadmin.module.system.role.roleemployee.RoleEmployeeDao;
|
import net.lab1024.smartadmin.module.system.role.roleemployee.RoleEmployeeDao;
|
||||||
import com.google.common.collect.Lists;
|
import net.lab1024.smartadmin.util.SmartBaseEnumUtil;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -51,33 +53,40 @@ public class DataScopeViewService {
|
|||||||
/**
|
/**
|
||||||
* 获取某人可以查看的所有人员信息
|
* 获取某人可以查看的所有人员信息
|
||||||
*
|
*
|
||||||
* @param dataScopeType
|
* @param dataScopeTypeEnum
|
||||||
* @param employeeId
|
* @param employeeId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Long> getCanViewEmployeeId(Integer dataScopeType, Long employeeId) {
|
public List<Long> getCanViewEmployeeId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
|
||||||
Integer viewType = this.getEmployeeDataScopeViewType(dataScopeType, employeeId);
|
DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
|
||||||
if (DataScopeViewTypeEnum.ME.getType().equals(viewType)) {
|
if (DataScopeViewTypeEnum.ME == viewType) {
|
||||||
return this.getMeEmployeeIdList(employeeId);
|
return this.getMeEmployeeIdList(employeeId);
|
||||||
}
|
}
|
||||||
if (DataScopeViewTypeEnum.DEPARTMENT.getType().equals(viewType)) {
|
if (DataScopeViewTypeEnum.DEPARTMENT == viewType) {
|
||||||
return this.getDepartmentEmployeeIdList(employeeId);
|
return this.getDepartmentEmployeeIdList(employeeId);
|
||||||
}
|
}
|
||||||
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB.getType().equals(viewType)) {
|
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
|
||||||
return this.getDepartmentAndSubEmployeeIdList(employeeId);
|
return this.getDepartmentAndSubEmployeeIdList(employeeId);
|
||||||
}
|
}
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Long> getCanViewDepartmentId(Integer dataScopeType, Long employeeId) {
|
/**
|
||||||
Integer viewType = this.getEmployeeDataScopeViewType(dataScopeType, employeeId);
|
* 获取某人可以查看的所有部门信息
|
||||||
if (DataScopeViewTypeEnum.ME.getType().equals(viewType)) {
|
*
|
||||||
|
* @param dataScopeTypeEnum
|
||||||
|
* @param employeeId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Long> getCanViewDepartmentId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
|
||||||
|
DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
|
||||||
|
if (DataScopeViewTypeEnum.ME == viewType) {
|
||||||
return this.getMeDepartmentIdList(employeeId);
|
return this.getMeDepartmentIdList(employeeId);
|
||||||
}
|
}
|
||||||
if (DataScopeViewTypeEnum.DEPARTMENT.getType().equals(viewType)) {
|
if (DataScopeViewTypeEnum.DEPARTMENT == viewType) {
|
||||||
return this.getMeDepartmentIdList(employeeId);
|
return this.getMeDepartmentIdList(employeeId);
|
||||||
}
|
}
|
||||||
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB.getType().equals(viewType)) {
|
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
|
||||||
return this.getDepartmentAndSubIdList(employeeId);
|
return this.getDepartmentAndSubIdList(employeeId);
|
||||||
}
|
}
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
@@ -101,28 +110,28 @@ public class DataScopeViewService {
|
|||||||
* @param employeeId
|
* @param employeeId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Integer getEmployeeDataScopeViewType(Integer dataScopeType, Long employeeId) {
|
public DataScopeViewTypeEnum getEmployeeDataScopeViewType(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
|
||||||
if (employeeId == null) {
|
if (employeeId == null) {
|
||||||
return DataScopeViewTypeEnum.ME.getType();
|
return DataScopeViewTypeEnum.ME;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (privilegeEmployeeService.isSuperman(employeeId)) {
|
if (privilegeEmployeeService.isSuperman(employeeId)) {
|
||||||
return DataScopeViewTypeEnum.ALL.getType();
|
return DataScopeViewTypeEnum.ALL;
|
||||||
}
|
}
|
||||||
List<Long> roleIdList = roleEmployeeDao.selectRoleIdByEmployeeId(employeeId);
|
List<Long> roleIdList = roleEmployeeDao.selectRoleIdByEmployeeId(employeeId);
|
||||||
//未设置角色 默认本人
|
//未设置角色 默认本人
|
||||||
if (CollectionUtils.isEmpty(roleIdList)) {
|
if (CollectionUtils.isEmpty(roleIdList)) {
|
||||||
return DataScopeViewTypeEnum.ME.getType();
|
return DataScopeViewTypeEnum.ME;
|
||||||
}
|
}
|
||||||
//未设置角色数据范围 默认本人
|
//未设置角色数据范围 默认本人
|
||||||
List<DataScopeRoleEntity> dataScopeRoleList = dataScopeRoleDao.listByRoleIdList(roleIdList);
|
List<DataScopeRoleEntity> dataScopeRoleList = dataScopeRoleDao.listByRoleIdList(roleIdList);
|
||||||
if (CollectionUtils.isEmpty(dataScopeRoleList)) {
|
if (CollectionUtils.isEmpty(dataScopeRoleList)) {
|
||||||
return DataScopeViewTypeEnum.ME.getType();
|
return DataScopeViewTypeEnum.ME;
|
||||||
}
|
}
|
||||||
Map<Integer, List<DataScopeRoleEntity>> listMap = dataScopeRoleList.stream().collect(Collectors.groupingBy(DataScopeRoleEntity :: getDataScopeType));
|
Map<Integer, List<DataScopeRoleEntity>> listMap = dataScopeRoleList.stream().collect(Collectors.groupingBy(DataScopeRoleEntity::getDataScopeType));
|
||||||
List<DataScopeRoleEntity> viewLevelList = listMap.get(dataScopeType);
|
List<DataScopeRoleEntity> viewLevelList = listMap.get(dataScopeTypeEnum.getValue());
|
||||||
DataScopeRoleEntity maxLevel = viewLevelList.stream().max(Comparator.comparing(e -> DataScopeViewTypeEnum.valueOf(e.getViewType()).getLevel())).get();
|
DataScopeRoleEntity maxLevel = viewLevelList.stream().max(Comparator.comparing(e -> SmartBaseEnumUtil.getEnumByValue(e.getViewType(), DataScopeViewTypeEnum.class).getLevel())).get();
|
||||||
return maxLevel.getViewType();
|
return SmartBaseEnumUtil.getEnumByValue(maxLevel.getViewType(), DataScopeViewTypeEnum.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,6 +143,7 @@ public class DataScopeViewService {
|
|||||||
private List<Long> getMeEmployeeIdList(Long employeeId) {
|
private List<Long> getMeEmployeeIdList(Long employeeId) {
|
||||||
return Lists.newArrayList(employeeId);
|
return Lists.newArrayList(employeeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取本部门相关 可查看员工id
|
* 获取本部门相关 可查看员工id
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package net.lab1024.smartadmin.module.system.datascope.strategy;
|
||||||
|
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeViewTypeEnum;
|
||||||
|
import net.lab1024.smartadmin.module.system.datascope.domain.dto.DataScopeSqlConfigDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [ 数据范围策略 ,使用DataScopeWhereInTypeEnum.CUSTOM_STRATEGY类型,DataScope注解的joinSql属性无用]
|
||||||
|
*
|
||||||
|
* @author yandanyang
|
||||||
|
* @version 1.0
|
||||||
|
* @company 1024lab.net
|
||||||
|
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
||||||
|
* @date 2020/11/28 0008 下午 16:00
|
||||||
|
* @since JDK1.8
|
||||||
|
*/
|
||||||
|
public abstract class DataScopePowerStrategy {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取joinsql 字符串
|
||||||
|
* @param viewTypeEnum 查看的类型
|
||||||
|
* @param sqlConfigDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract String getCondition(DataScopeViewTypeEnum viewTypeEnum, DataScopeSqlConfigDTO sqlConfigDTO);
|
||||||
|
}
|
||||||
@@ -59,15 +59,15 @@ public class DepartmentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "删除部门", notes = "删除部门")
|
@ApiOperation(value = "删除部门", notes = "删除部门")
|
||||||
@PostMapping("/department/delete/{departmentId}")
|
@PostMapping("/department/delete/{deptId}")
|
||||||
public ResponseDTO<String> delDepartment(@PathVariable("departmentId") Long departmentId) {
|
public ResponseDTO<String> delDepartment(@PathVariable Long deptId) {
|
||||||
return departmentService.delDepartment(departmentId);
|
return departmentService.delDepartment(deptId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取部门信息", notes = "获取部门")
|
@ApiOperation(value = "获取部门信息", notes = "获取部门")
|
||||||
@GetMapping("/department/query/{departmentId}")
|
@GetMapping("/department/query/{deptId}")
|
||||||
public ResponseDTO<DepartmentVO> getDepartment(@PathVariable("departmentId") Long departmentId) {
|
public ResponseDTO<DepartmentVO> getDepartment(@PathVariable Long deptId) {
|
||||||
return departmentService.getDepartmentById(departmentId);
|
return departmentService.getDepartmentById(deptId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "查询部门列表", notes = "查询部门列表")
|
@ApiOperation(value = "查询部门列表", notes = "查询部门列表")
|
||||||
@@ -78,21 +78,21 @@ public class DepartmentController {
|
|||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "上下移动")
|
@ApiOperation(value = "上下移动")
|
||||||
@GetMapping("/department/upOrDown/{departmentId}/{swapId}")
|
@GetMapping("/department/upOrDown/{deptId}/{swapId}")
|
||||||
public ResponseDTO<String> upOrDown(@PathVariable("departmentId") Long departmentId,@PathVariable("swapId") Long swapId) {
|
public ResponseDTO<String> upOrDown(@PathVariable Long deptId, @PathVariable Long swapId) {
|
||||||
return departmentService.upOrDown(departmentId,swapId);
|
return departmentService.upOrDown(deptId, swapId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "升级")
|
@ApiOperation(value = "升级")
|
||||||
@GetMapping("/department/upgrade/{departmentId}")
|
@GetMapping("/department/upgrade/{deptId}")
|
||||||
public ResponseDTO<String> upgrade(@PathVariable("departmentId") Long departmentId) {
|
public ResponseDTO<String> upgrade(@PathVariable Long deptId) {
|
||||||
return departmentService.upgrade(departmentId);
|
return departmentService.upgrade(deptId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "降级")
|
@ApiOperation(value = "降级")
|
||||||
@GetMapping("/department/downgrade/{departmentId}/{preId}")
|
@GetMapping("/department/downgrade/{deptId}/{preId}")
|
||||||
public ResponseDTO<String> downgrade(@PathVariable("departmentId") Long departmentId,@PathVariable("preId") Long preId) {
|
public ResponseDTO<String> downgrade(@PathVariable Long deptId, @PathVariable Long preId) {
|
||||||
return departmentService.downgrade(departmentId,preId);
|
return departmentService.downgrade(deptId, preId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,13 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface DepartmentDao extends BaseMapper<DepartmentEntity> {
|
public interface DepartmentDao extends BaseMapper<DepartmentEntity> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据部门id,查询此部门子部门的数量
|
* 根据部门id,查询此部门直接子部门的数量
|
||||||
*
|
*
|
||||||
* @param departmentId
|
* @param deptId
|
||||||
* @return int 子部门的数量
|
* @return int 子部门的数量
|
||||||
*/
|
*/
|
||||||
Integer countSubDepartment(@Param("departmentId") Long departmentId);
|
Integer countSubDepartment(@Param("deptId") Long deptId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全部部门列表
|
* 获取全部部门列表
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class DepartmentResponseCodeConst extends ResponseCodeConst {
|
|||||||
/**
|
/**
|
||||||
* 部门不存在 1001
|
* 部门不存在 1001
|
||||||
*/
|
*/
|
||||||
public static final DepartmentResponseCodeConst DEPT_NOT_EXISTS = new DepartmentResponseCodeConst(2001, "部门不存在!");
|
public static final DepartmentResponseCodeConst DEPT_NOT_EXISTS = new DepartmentResponseCodeConst(2001, "部门不存在");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前部门有子级部门 不能删除 10003
|
* 当前部门有子级部门 不能删除 10003
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class DepartmentService {
|
|||||||
departmentVOList = filterDepartment(departmentVOList, departmentName);
|
departmentVOList = filterDepartment(departmentVOList, departmentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Long, DepartmentVO> departmentMap = departmentVOList.stream().collect(Collectors.toMap(DepartmentVO :: getId, Function.identity()));
|
Map<Long, DepartmentVO> departmentMap = departmentVOList.stream().collect(Collectors.toMap(DepartmentVO::getId, Function.identity()));
|
||||||
// 获取全部员工列表
|
// 获取全部员工列表
|
||||||
List<EmployeeDTO> employeeList = employeeDao.listAll();
|
List<EmployeeDTO> employeeList = employeeDao.listAll();
|
||||||
employeeList.forEach(employeeDTO -> {
|
employeeList.forEach(employeeDTO -> {
|
||||||
@@ -103,7 +103,7 @@ public class DepartmentService {
|
|||||||
List<DepartmentVO> filterResult = new ArrayList<>();
|
List<DepartmentVO> filterResult = new ArrayList<>();
|
||||||
getParentDepartment(departmentVOList, parentId, filterResult);
|
getParentDepartment(departmentVOList, parentId, filterResult);
|
||||||
for (DepartmentVO dto : filterResult) {
|
for (DepartmentVO dto : filterResult) {
|
||||||
if (! departmentMap.containsKey(dto.getId())) {
|
if (!departmentMap.containsKey(dto.getId())) {
|
||||||
departmentMap.put(dto.getId(), dto);
|
departmentMap.put(dto.getId(), dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,23 +165,27 @@ public class DepartmentService {
|
|||||||
* 1、需要判断当前部门是否有子部门,有子部门则不允许删除
|
* 1、需要判断当前部门是否有子部门,有子部门则不允许删除
|
||||||
* 2、需要判断当前部门是否有员工,有员工则不能删除
|
* 2、需要判断当前部门是否有员工,有员工则不能删除
|
||||||
*
|
*
|
||||||
* @param departmentId
|
* @param deptId
|
||||||
* @return AjaxResult<String>
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ResponseDTO<String> delDepartment(Long departmentId) {
|
public ResponseDTO<String> delDepartment(Long deptId) {
|
||||||
|
DepartmentEntity departmentEntity = departmentDao.selectById(deptId);
|
||||||
|
if (null == departmentEntity) {
|
||||||
|
return ResponseDTO.wrap(DepartmentResponseCodeConst.DEPT_NOT_EXISTS);
|
||||||
|
}
|
||||||
// 是否有子级部门
|
// 是否有子级部门
|
||||||
int subDepartmentNum = departmentDao.countSubDepartment(departmentId);
|
int subDepartmentNum = departmentDao.countSubDepartment(deptId);
|
||||||
if (subDepartmentNum > 0) {
|
if (subDepartmentNum > 0) {
|
||||||
return ResponseDTO.wrap(DepartmentResponseCodeConst.CANNOT_DEL_DEPARTMENT_WITH_CHILD);
|
return ResponseDTO.wrap(DepartmentResponseCodeConst.CANNOT_DEL_DEPARTMENT_WITH_CHILD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否有员工
|
// 是否有未删除员工
|
||||||
int employeeNum = employeeDao.countByDepartmentId(departmentId);
|
int employeeNum = employeeDao.countByDepartmentId(deptId, false);
|
||||||
if (employeeNum > 0) {
|
if (employeeNum > 0) {
|
||||||
return ResponseDTO.wrap(DepartmentResponseCodeConst.CANNOT_DEL_DEPARTMENT_WITH_EMPLOYEE);
|
return ResponseDTO.wrap(DepartmentResponseCodeConst.CANNOT_DEL_DEPARTMENT_WITH_EMPLOYEE);
|
||||||
}
|
}
|
||||||
departmentDao.deleteById(departmentId);
|
departmentDao.deleteById(deptId);
|
||||||
return ResponseDTO.succ();
|
return ResponseDTO.succ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,5 +282,4 @@ public class DepartmentService {
|
|||||||
departmentDao.updateById(departmentEntity);
|
departmentDao.updateById(departmentEntity);
|
||||||
return ResponseDTO.succ();
|
return ResponseDTO.succ();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
|||||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||||
import net.lab1024.smartadmin.module.system.employee.domain.dto.*;
|
import net.lab1024.smartadmin.module.system.employee.domain.dto.*;
|
||||||
import net.lab1024.smartadmin.module.system.employee.domain.vo.EmployeeVO;
|
import net.lab1024.smartadmin.module.system.employee.domain.vo.EmployeeVO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@@ -86,7 +86,6 @@ public class EmployeeController {
|
|||||||
public ResponseDTO<String> updatePwd(@Valid @RequestBody EmployeeUpdatePwdDTO updatePwdDTO) {
|
public ResponseDTO<String> updatePwd(@Valid @RequestBody EmployeeUpdatePwdDTO updatePwdDTO) {
|
||||||
RequestTokenBO requestToken = SmartRequestTokenUtil.getRequestUser();
|
RequestTokenBO requestToken = SmartRequestTokenUtil.getRequestUser();
|
||||||
return employeeService.updatePwd(updatePwdDTO, requestToken);
|
return employeeService.updatePwd(updatePwdDTO, requestToken);
|
||||||
// return ResponseDTO.succ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "通过部门id获取当前部门的人员&没有部门的人", notes = "@author yandanyang")
|
@ApiOperation(value = "通过部门id获取当前部门的人员&没有部门的人", notes = "@author yandanyang")
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 不带分页查询员工列表
|
* 不带分页查询员工列表
|
||||||
|
*
|
||||||
* @param queryDTO
|
* @param queryDTO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -84,10 +85,11 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
|||||||
/**
|
/**
|
||||||
* 获取某个部门员工数
|
* 获取某个部门员工数
|
||||||
*
|
*
|
||||||
* @param departmentId
|
* @param depId
|
||||||
|
* @param deleteFlag 可以null
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer countByDepartmentId(@Param("departmentId") Long departmentId);
|
Integer countByDepartmentId(@Param("depId") Long depId, @Param("deleteFlag") Boolean deleteFlag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取一批员工
|
* 获取一批员工
|
||||||
@@ -99,6 +101,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
|||||||
|
|
||||||
|
|
||||||
EmployeeDTO getEmployeeById(@Param("id") Long employeeId);
|
EmployeeDTO getEmployeeById(@Param("id") Long employeeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取某个部门的员工
|
* 获取某个部门的员工
|
||||||
*
|
*
|
||||||
@@ -128,6 +131,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有员工
|
* 查询所有员工
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<EmployeeVO> selectAll();
|
List<EmployeeVO> selectAll();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.lab1024.smartadmin.module.system.employee;
|
package net.lab1024.smartadmin.module.system.employee;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
||||||
import net.lab1024.smartadmin.common.domain.PageResultDTO;
|
import net.lab1024.smartadmin.common.domain.PageResultDTO;
|
||||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||||
@@ -13,7 +14,7 @@ import net.lab1024.smartadmin.module.system.employee.domain.bo.EmployeeBO;
|
|||||||
import net.lab1024.smartadmin.module.system.employee.domain.dto.*;
|
import net.lab1024.smartadmin.module.system.employee.domain.dto.*;
|
||||||
import net.lab1024.smartadmin.module.system.employee.domain.entity.EmployeeEntity;
|
import net.lab1024.smartadmin.module.system.employee.domain.entity.EmployeeEntity;
|
||||||
import net.lab1024.smartadmin.module.system.employee.domain.vo.EmployeeVO;
|
import net.lab1024.smartadmin.module.system.employee.domain.vo.EmployeeVO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import net.lab1024.smartadmin.module.system.position.PositionDao;
|
import net.lab1024.smartadmin.module.system.position.PositionDao;
|
||||||
import net.lab1024.smartadmin.module.system.position.PositionService;
|
import net.lab1024.smartadmin.module.system.position.PositionService;
|
||||||
import net.lab1024.smartadmin.module.system.position.domain.dto.PositionRelationAddDTO;
|
import net.lab1024.smartadmin.module.system.position.domain.dto.PositionRelationAddDTO;
|
||||||
@@ -25,7 +26,6 @@ import net.lab1024.smartadmin.util.SmartBeanUtil;
|
|||||||
import net.lab1024.smartadmin.util.SmartDigestUtil;
|
import net.lab1024.smartadmin.util.SmartDigestUtil;
|
||||||
import net.lab1024.smartadmin.util.SmartPageUtil;
|
import net.lab1024.smartadmin.util.SmartPageUtil;
|
||||||
import net.lab1024.smartadmin.util.SmartVerificationUtil;
|
import net.lab1024.smartadmin.util.SmartVerificationUtil;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.map.HashedMap;
|
import org.apache.commons.collections.map.HashedMap;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -74,7 +74,7 @@ public class EmployeeService {
|
|||||||
*/
|
*/
|
||||||
private static final ConcurrentHashMap<Long, EmployeeBO> employeeCache = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<Long, EmployeeBO> employeeCache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public List<EmployeeVO> getAllEmployee(){
|
public List<EmployeeVO> getAllEmployee() {
|
||||||
return employeeDao.selectAll();
|
return employeeDao.selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ public class EmployeeService {
|
|||||||
|
|
||||||
for (EmployeeDTO employeeDTO : employeeList) {
|
for (EmployeeDTO employeeDTO : employeeList) {
|
||||||
List<PositionRelationResultDTO> relationResultDTOList = employeePositionMap.get(employeeDTO.getId());
|
List<PositionRelationResultDTO> relationResultDTOList = employeePositionMap.get(employeeDTO.getId());
|
||||||
if(relationResultDTOList != null){
|
if (relationResultDTOList != null) {
|
||||||
employeeDTO.setPositionRelationList(relationResultDTOList);
|
employeeDTO.setPositionRelationList(relationResultDTOList);
|
||||||
employeeDTO.setPositionName(relationResultDTOList.stream().map(PositionRelationResultDTO::getPositionName).collect(Collectors.joining(",")));
|
employeeDTO.setPositionName(relationResultDTOList.stream().map(PositionRelationResultDTO::getPositionName).collect(Collectors.joining(",")));
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ public class EmployeeService {
|
|||||||
return ResponseDTO.wrap(EmployeeResponseCodeConst.LOGIN_NAME_EXISTS);
|
return ResponseDTO.wrap(EmployeeResponseCodeConst.LOGIN_NAME_EXISTS);
|
||||||
}
|
}
|
||||||
//同电话员工
|
//同电话员工
|
||||||
EmployeeDTO samePhoneEmployee = employeeDao.getByPhone(entity.getLoginName(), EmployeeStatusEnum.NORMAL.getValue());
|
EmployeeDTO samePhoneEmployee = employeeDao.getByPhone(entity.getPhone(), EmployeeStatusEnum.NORMAL.getValue());
|
||||||
if (null != samePhoneEmployee) {
|
if (null != samePhoneEmployee) {
|
||||||
return ResponseDTO.wrap(EmployeeResponseCodeConst.PHONE_EXISTS);
|
return ResponseDTO.wrap(EmployeeResponseCodeConst.PHONE_EXISTS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,11 +22,9 @@ public class EmployeeLoginFormDTO {
|
|||||||
@ApiModelProperty(example = "123456")
|
@ApiModelProperty(example = "123456")
|
||||||
private String loginPwd;
|
private String loginPwd;
|
||||||
|
|
||||||
@NotNull(message = "验证码id不能为空")
|
|
||||||
@ApiModelProperty(value = "验证码uuid")
|
@ApiModelProperty(value = "验证码uuid")
|
||||||
private String codeUuid;
|
private String codeUuid;
|
||||||
|
|
||||||
@NotNull(message = "验证码不能为空")
|
|
||||||
@ApiModelProperty(value = "验证码")
|
@ApiModelProperty(value = "验证码")
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.module.business.login;
|
package net.lab1024.smartadmin.module.system.login;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.common.anno.NoNeedLogin;
|
import net.lab1024.smartadmin.common.anno.NoNeedLogin;
|
||||||
import net.lab1024.smartadmin.common.anno.NoValidPrivilege;
|
import net.lab1024.smartadmin.common.anno.NoValidPrivilege;
|
||||||
@@ -6,9 +6,9 @@ import net.lab1024.smartadmin.common.anno.OperateLog;
|
|||||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||||
import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeLoginFormDTO;
|
import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeLoginFormDTO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.KaptchaVO;
|
import net.lab1024.smartadmin.module.system.login.domain.KaptchaVO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.LoginDetailVO;
|
import net.lab1024.smartadmin.module.system.login.domain.LoginDetailVO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@@ -42,7 +42,6 @@ public class LoginController {
|
|||||||
return loginService.login(loginForm, request);
|
return loginService.login(loginForm, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/session/get")
|
@GetMapping("/session/get")
|
||||||
@ApiOperation(value = "获取session", notes = "获取session")
|
@ApiOperation(value = "获取session", notes = "获取session")
|
||||||
@NoValidPrivilege
|
@NoValidPrivilege
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.module.business.login;
|
package net.lab1024.smartadmin.module.system.login;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.common.constant.ResponseCodeConst;
|
import net.lab1024.smartadmin.common.constant.ResponseCodeConst;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.module.business.login;
|
package net.lab1024.smartadmin.module.system.login;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
||||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||||
@@ -12,10 +12,10 @@ import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeDTO;
|
|||||||
import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeLoginFormDTO;
|
import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeLoginFormDTO;
|
||||||
import net.lab1024.smartadmin.module.business.log.LogService;
|
import net.lab1024.smartadmin.module.business.log.LogService;
|
||||||
import net.lab1024.smartadmin.module.business.log.userloginlog.domain.UserLoginLogEntity;
|
import net.lab1024.smartadmin.module.business.log.userloginlog.domain.UserLoginLogEntity;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.KaptchaVO;
|
import net.lab1024.smartadmin.module.system.login.domain.KaptchaVO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.LoginDetailVO;
|
import net.lab1024.smartadmin.module.system.login.domain.LoginDetailVO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.LoginPrivilegeDTO;
|
import net.lab1024.smartadmin.module.system.login.domain.LoginPrivilegeDTO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.domain.entity.PrivilegeEntity;
|
import net.lab1024.smartadmin.module.system.privilege.domain.entity.PrivilegeEntity;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.service.PrivilegeEmployeeService;
|
import net.lab1024.smartadmin.module.system.privilege.service.PrivilegeEmployeeService;
|
||||||
import net.lab1024.smartadmin.util.SmartBeanUtil;
|
import net.lab1024.smartadmin.util.SmartBeanUtil;
|
||||||
@@ -83,15 +83,15 @@ public class LoginService {
|
|||||||
* @return 登录用户基本信息
|
* @return 登录用户基本信息
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<LoginDetailVO> login(@Valid EmployeeLoginFormDTO loginForm, HttpServletRequest request) {
|
public ResponseDTO<LoginDetailVO> login(@Valid EmployeeLoginFormDTO loginForm, HttpServletRequest request) {
|
||||||
String redisVerificationCode = redisValueOperations.get(loginForm.getCodeUuid());
|
// String redisVerificationCode = redisValueOperations.get(loginForm.getCodeUuid());
|
||||||
//增加删除已使用的验证码方式 频繁登录
|
// //增加删除已使用的验证码方式 频繁登录
|
||||||
redisValueOperations.getOperations().delete(loginForm.getCodeUuid());
|
// redisValueOperations.getOperations().delete(loginForm.getCodeUuid());
|
||||||
if (StringUtils.isEmpty(redisVerificationCode)) {
|
// if (StringUtils.isEmpty(redisVerificationCode)) {
|
||||||
return ResponseDTO.wrap(EmployeeResponseCodeConst.VERIFICATION_CODE_INVALID);
|
// return ResponseDTO.wrap(EmployeeResponseCodeConst.VERIFICATION_CODE_INVALID);
|
||||||
}
|
// }
|
||||||
if (!redisVerificationCode.equalsIgnoreCase(loginForm.getCode())) {
|
// if (!redisVerificationCode.equalsIgnoreCase(loginForm.getCode())) {
|
||||||
return ResponseDTO.wrap(EmployeeResponseCodeConst.VERIFICATION_CODE_INVALID);
|
// return ResponseDTO.wrap(EmployeeResponseCodeConst.VERIFICATION_CODE_INVALID);
|
||||||
}
|
// }
|
||||||
String loginPwd = SmartDigestUtil.encryptPassword(CommonConst.Password.SALT_FORMAT, loginForm.getLoginPwd());
|
String loginPwd = SmartDigestUtil.encryptPassword(CommonConst.Password.SALT_FORMAT, loginForm.getLoginPwd());
|
||||||
EmployeeDTO employeeDTO = employeeDao.login(loginForm.getLoginName(), loginPwd);
|
EmployeeDTO employeeDTO = employeeDao.login(loginForm.getLoginName(), loginPwd);
|
||||||
if (null == employeeDTO) {
|
if (null == employeeDTO) {
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package net.lab1024.smartadmin.module.business.login;
|
package net.lab1024.smartadmin.module.system.login;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
||||||
import net.lab1024.smartadmin.module.system.employee.EmployeeService;
|
import net.lab1024.smartadmin.module.system.employee.EmployeeService;
|
||||||
import net.lab1024.smartadmin.module.system.employee.constant.EmployeeStatusEnum;
|
import net.lab1024.smartadmin.module.system.employee.constant.EmployeeStatusEnum;
|
||||||
import net.lab1024.smartadmin.module.system.employee.domain.bo.EmployeeBO;
|
import net.lab1024.smartadmin.module.system.employee.domain.bo.EmployeeBO;
|
||||||
import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeDTO;
|
import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeDTO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.module.business.login.domain;
|
package net.lab1024.smartadmin.module.system.login.domain;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.module.business.login.domain;
|
package net.lab1024.smartadmin.module.system.login.domain;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeDTO;
|
import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeDTO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.module.business.login.domain;
|
package net.lab1024.smartadmin.module.system.login.domain;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.module.business.login.domain;
|
package net.lab1024.smartadmin.module.system.login.domain;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.common.anno.ApiModelPropertyEnum;
|
import net.lab1024.smartadmin.common.anno.ApiModelPropertyEnum;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.constant.PrivilegeTypeEnum;
|
import net.lab1024.smartadmin.module.system.privilege.constant.PrivilegeTypeEnum;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.module.business.login.domain;
|
package net.lab1024.smartadmin.module.system.login.domain;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.module.system.employee.domain.bo.EmployeeBO;
|
import net.lab1024.smartadmin.module.system.employee.domain.bo.EmployeeBO;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -42,7 +42,6 @@ public class PrivilegeController {
|
|||||||
@PostMapping("/privilege/menu/batchSaveMenu")
|
@PostMapping("/privilege/menu/batchSaveMenu")
|
||||||
public ResponseDTO<String> menuBatchSave(@Valid @RequestBody ValidateList<PrivilegeMenuDTO> menuList) {
|
public ResponseDTO<String> menuBatchSave(@Valid @RequestBody ValidateList<PrivilegeMenuDTO> menuList) {
|
||||||
return privilegeService.menuBatchSave(menuList);
|
return privilegeService.menuBatchSave(menuList);
|
||||||
// return ResponseDTO.succ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -57,14 +56,12 @@ public class PrivilegeController {
|
|||||||
@PostMapping("/privilege/function/saveOrUpdate")
|
@PostMapping("/privilege/function/saveOrUpdate")
|
||||||
public ResponseDTO<String> functionSaveOrUpdate(@Valid @RequestBody PrivilegeFunctionDTO privilegeFunctionDTO) {
|
public ResponseDTO<String> functionSaveOrUpdate(@Valid @RequestBody PrivilegeFunctionDTO privilegeFunctionDTO) {
|
||||||
return privilegeService.functionSaveOrUpdate(privilegeFunctionDTO);
|
return privilegeService.functionSaveOrUpdate(privilegeFunctionDTO);
|
||||||
// return ResponseDTO.succ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "批量保存功能点")
|
@ApiOperation(value = "批量保存功能点")
|
||||||
@PostMapping("/privilege/function/batchSave")
|
@PostMapping("/privilege/function/batchSave")
|
||||||
public ResponseDTO<String> batchSaveFunctionList(@Valid @RequestBody ValidateList<PrivilegeFunctionDTO> functionList) {
|
public ResponseDTO<String> batchSaveFunctionList(@Valid @RequestBody ValidateList<PrivilegeFunctionDTO> functionList) {
|
||||||
return privilegeService.batchSaveFunctionList(functionList);
|
return privilegeService.batchSaveFunctionList(functionList);
|
||||||
// return ResponseDTO.succ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,13 @@ public interface PrivilegeDao extends BaseMapper<PrivilegeEntity> {
|
|||||||
*/
|
*/
|
||||||
List<PrivilegeEntity> selectByParentKey(@Param("parentKey") String parentKey);
|
List<PrivilegeEntity> selectByParentKey(@Param("parentKey") String parentKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据父节点key查询
|
||||||
|
* @param keyList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<PrivilegeEntity> selectByKeyList(@Param("keyList") List<String> keyList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据权限key查询
|
* 根据权限key查询
|
||||||
* @param key
|
* @param key
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package net.lab1024.smartadmin.module.system.privilege.service;
|
|||||||
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
import net.lab1024.smartadmin.common.constant.JudgeEnum;
|
||||||
import net.lab1024.smartadmin.common.exception.SmartBusinessException;
|
import net.lab1024.smartadmin.common.exception.SmartBusinessException;
|
||||||
import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeDTO;
|
import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeDTO;
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.constant.PrivilegeTypeEnum;
|
import net.lab1024.smartadmin.module.system.privilege.constant.PrivilegeTypeEnum;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.dao.PrivilegeDao;
|
import net.lab1024.smartadmin.module.system.privilege.dao.PrivilegeDao;
|
||||||
import net.lab1024.smartadmin.module.system.privilege.domain.entity.PrivilegeEntity;
|
import net.lab1024.smartadmin.module.system.privilege.domain.entity.PrivilegeEntity;
|
||||||
|
|||||||
@@ -216,10 +216,18 @@ public class PrivilegeService {
|
|||||||
return ResponseDTO.wrap(PrivilegeResponseCodeConst.MENU_NOT_EXIST);
|
return ResponseDTO.wrap(PrivilegeResponseCodeConst.MENU_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
//数据库中存在的数据
|
List<String> functionKeyList = functionList.stream().map(PrivilegeFunctionDTO::getFunctionKey).collect(Collectors.toList());
|
||||||
List<PrivilegeEntity> existFunctionList = privilegeDao.selectByParentKey(menuKey);
|
|
||||||
Map<String, PrivilegeEntity> privilegeEntityMap = existFunctionList.stream().collect(Collectors.toMap(PrivilegeEntity::getKey, e -> e));
|
|
||||||
|
|
||||||
|
//数据库中存在的数据
|
||||||
|
List<PrivilegeEntity> existFunctionList = privilegeDao.selectByKeyList(functionKeyList);
|
||||||
|
//校验是否parent key重复
|
||||||
|
boolean parentKeyExist = existFunctionList.stream().anyMatch(e -> !menuKey.equals(e.getParentKey()));
|
||||||
|
if(parentKeyExist){
|
||||||
|
return ResponseDTO.wrap(PrivilegeResponseCodeConst.ROUTER_KEY_NO_REPEAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
existFunctionList = privilegeDao.selectByParentKey(menuKey);
|
||||||
|
Map<String, PrivilegeEntity> privilegeEntityMap = existFunctionList.stream().collect(Collectors.toMap(PrivilegeEntity::getKey, e -> e));
|
||||||
//如果没有,则保存全部
|
//如果没有,则保存全部
|
||||||
if (existFunctionList.isEmpty()) {
|
if (existFunctionList.isEmpty()) {
|
||||||
List<PrivilegeEntity> privilegeEntityList = functionList.stream().map(e -> function2Privilege(e)).collect(Collectors.toList());
|
List<PrivilegeEntity> privilegeEntityList = functionList.stream().map(e -> function2Privilege(e)).collect(Collectors.toList());
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
package net.lab1024.smartadmin.util;
|
package net.lab1024.smartadmin.util;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
@@ -34,12 +35,15 @@ public class SmartBigDecimalUtil {
|
|||||||
public static BigDecimal add(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal add(BigDecimal num1, BigDecimal num2) {
|
||||||
return setScale(num1.add(num2), PRICE_DECIMAL_POINT);
|
return setScale(num1.add(num2), PRICE_DECIMAL_POINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
||||||
return setScale(num1.multiply(num2), PRICE_DECIMAL_POINT);
|
return setScale(num1.multiply(num2), PRICE_DECIMAL_POINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
||||||
return setScale(num1.subtract(num2), PRICE_DECIMAL_POINT);
|
return setScale(num1.subtract(num2), PRICE_DECIMAL_POINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
||||||
return setScale(num1.divide(num2, RoundingMode.HALF_UP), PRICE_DECIMAL_POINT);
|
return setScale(num1.divide(num2, RoundingMode.HALF_UP), PRICE_DECIMAL_POINT);
|
||||||
}
|
}
|
||||||
@@ -53,12 +57,15 @@ public class SmartBigDecimalUtil {
|
|||||||
public static BigDecimal add(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal add(BigDecimal num1, BigDecimal num2) {
|
||||||
return setScale(num1.add(num2), SIX_PRICE_DECIMAL_POINT);
|
return setScale(num1.add(num2), SIX_PRICE_DECIMAL_POINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
||||||
return setScale(num1.multiply(num2), SIX_PRICE_DECIMAL_POINT);
|
return setScale(num1.multiply(num2), SIX_PRICE_DECIMAL_POINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
||||||
return setScale(num1.subtract(num2), SIX_PRICE_DECIMAL_POINT);
|
return setScale(num1.subtract(num2), SIX_PRICE_DECIMAL_POINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
||||||
return num1.divide(num2, PRICE_DECIMAL_POINT, RoundingMode.HALF_UP);
|
return num1.divide(num2, PRICE_DECIMAL_POINT, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
@@ -72,12 +79,15 @@ public class SmartBigDecimalUtil {
|
|||||||
public static BigDecimal add(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal add(BigDecimal num1, BigDecimal num2) {
|
||||||
return setScale(num1.add(num2), WEIGHT_DECIMAL_POINT);
|
return setScale(num1.add(num2), WEIGHT_DECIMAL_POINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
||||||
return setScale(num1.multiply(num2), WEIGHT_DECIMAL_POINT);
|
return setScale(num1.multiply(num2), WEIGHT_DECIMAL_POINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
||||||
return setScale(num1.subtract(num2), WEIGHT_DECIMAL_POINT);
|
return setScale(num1.subtract(num2), WEIGHT_DECIMAL_POINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
||||||
return num1.divide(num2, WEIGHT_DECIMAL_POINT, RoundingMode.HALF_UP);
|
return num1.divide(num2, WEIGHT_DECIMAL_POINT, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
@@ -176,7 +186,7 @@ public class SmartBigDecimalUtil {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean isLessThan(BigDecimal num1, BigDecimal num2) {
|
public static boolean isLessThan(BigDecimal num1, BigDecimal num2) {
|
||||||
return num1.compareTo(num2) == - 1;
|
return num1.compareTo(num2) == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,7 +237,7 @@ public class SmartBigDecimalUtil {
|
|||||||
if (num1 == null || num2 == null) {
|
if (num1 == null || num2 == null) {
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
if (num2.equals(Integer.valueOf(0))) {
|
if (num2.equals(0)) {
|
||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
BigDecimal bigDecimalNum1 = new BigDecimal(num1);
|
BigDecimal bigDecimalNum1 = new BigDecimal(num1);
|
||||||
@@ -272,7 +282,7 @@ public class SmartBigDecimalUtil {
|
|||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public static Boolean isNotEmpty(BigDecimal num) {
|
public static Boolean isNotEmpty(BigDecimal num) {
|
||||||
return ! isEmpty(num);
|
return !isEmpty(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -283,8 +293,7 @@ public class SmartBigDecimalUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static BigDecimal convertTenThousand(BigDecimal num, int point) {
|
public static BigDecimal convertTenThousand(BigDecimal num, int point) {
|
||||||
BigDecimal decimal = num.divide(new BigDecimal(10000), point, RoundingMode.HALF_UP);
|
return num.divide(new BigDecimal(10000), point, RoundingMode.HALF_UP);
|
||||||
return decimal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -300,4 +309,25 @@ public class SmartBigDecimalUtil {
|
|||||||
return BigDecimal.ZERO.subtract(num);
|
return BigDecimal.ZERO.subtract(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比较 num1,num2 返回最大的值
|
||||||
|
*
|
||||||
|
* @param num1
|
||||||
|
* @param num2
|
||||||
|
* @return BigDecimal
|
||||||
|
*/
|
||||||
|
public static BigDecimal max(BigDecimal num1, BigDecimal num2) {
|
||||||
|
return num1.compareTo(num2) > 0 ? num1 : num2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比较 num1,num2 返回最小的值
|
||||||
|
*
|
||||||
|
* @param num1
|
||||||
|
* @param num2
|
||||||
|
* @return BigDecimal
|
||||||
|
*/
|
||||||
|
public static BigDecimal min(BigDecimal num1, BigDecimal num2) {
|
||||||
|
return num1.compareTo(num2) < 0 ? num1 : num2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package net.lab1024.smartadmin.util;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhuoda
|
||||||
|
*/
|
||||||
|
public class SmartFileUtil extends FileUtils {
|
||||||
|
|
||||||
|
public static boolean isXmlFile(File file) {
|
||||||
|
return "xml".equalsIgnoreCase(getFileExtension(file.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件后缀名
|
||||||
|
*
|
||||||
|
* @param fullName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getFileExtension(String fullName) {
|
||||||
|
String fileName = new File(fullName).getName();
|
||||||
|
int dotIndex = fileName.lastIndexOf('.');
|
||||||
|
return (dotIndex == -1) ? "" : fileName.substring(dotIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不带后缀名的文件名
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getNameWithoutExtension(String file) {
|
||||||
|
String fileName = new File(file).getName();
|
||||||
|
int dotIndex = fileName.lastIndexOf('.');
|
||||||
|
return (dotIndex == -1) ? fileName : fileName.substring(0, dotIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFileExist(String filePath) {
|
||||||
|
File file = new File(filePath);
|
||||||
|
return file.exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证文件是否存在,如果不存在则抛出异常
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static void isFileExistThrowException(String filePath) throws IOException {
|
||||||
|
File file = new File(filePath);
|
||||||
|
if (!file.exists()) {
|
||||||
|
throw new FileNotFoundException(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BufferedReader newBufferedReader(File file, Charset charset) throws FileNotFoundException {
|
||||||
|
return new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BufferedWriter newBufferedWriter(File file, Charset charset) throws FileNotFoundException {
|
||||||
|
return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean createParentDirs(File file) throws IOException {
|
||||||
|
File parent = file.getCanonicalFile().getParentFile();
|
||||||
|
if (parent == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return parent.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean createNotExistParentDirFile(File file) throws IOException {
|
||||||
|
boolean createParentDirsRes = createParentDirs(file);
|
||||||
|
if (!createParentDirsRes) {
|
||||||
|
throw new IOException("cannot create parent Directory of " + file.getName());
|
||||||
|
}
|
||||||
|
return file.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@ public class SmartPageUtil {
|
|||||||
PageResultDTO<T> result = new PageResultDTO<>();
|
PageResultDTO<T> result = new PageResultDTO<>();
|
||||||
result.setPageNum(page.getCurrent());
|
result.setPageNum(page.getCurrent());
|
||||||
result.setPageSize(page.getSize());
|
result.setPageSize(page.getSize());
|
||||||
result.setTotal(Long.valueOf(page.getTotal()));
|
result.setTotal(page.getTotal());
|
||||||
result.setPages(page.getPages());
|
result.setPages(page.getPages());
|
||||||
result.setList(page.getRecords());
|
result.setList(page.getRecords());
|
||||||
return result;
|
return result;
|
||||||
@@ -33,7 +33,7 @@ public class SmartPageUtil {
|
|||||||
|
|
||||||
List<OrderItemDTO> orders = baseDTO.getOrders();
|
List<OrderItemDTO> orders = baseDTO.getOrders();
|
||||||
if (orders != null && !orders.isEmpty()) {
|
if (orders != null && !orders.isEmpty()) {
|
||||||
List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderItemList = orders.stream().map(e -> convertOrderItem(e)).collect(Collectors.toList());
|
List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderItemList = orders.stream().map(SmartPageUtil::convertOrderItem).collect(Collectors.toList());
|
||||||
page.setOrders(orderItemList);
|
page.setOrders(orderItemList);
|
||||||
}
|
}
|
||||||
page.setCurrent(baseDTO.getPageNum());
|
page.setCurrent(baseDTO.getPageNum());
|
||||||
@@ -90,7 +90,7 @@ public class SmartPageUtil {
|
|||||||
PageResultDTO pageResultDTO = new PageResultDTO();
|
PageResultDTO pageResultDTO = new PageResultDTO();
|
||||||
pageResultDTO.setPageNum(page.getCurrent());
|
pageResultDTO.setPageNum(page.getCurrent());
|
||||||
pageResultDTO.setPageSize(page.getSize());
|
pageResultDTO.setPageSize(page.getSize());
|
||||||
pageResultDTO.setTotal(Long.valueOf(page.getTotal()));
|
pageResultDTO.setTotal(page.getTotal());
|
||||||
pageResultDTO.setPages(page.getPages());
|
pageResultDTO.setPages(page.getPages());
|
||||||
return pageResultDTO;
|
return pageResultDTO;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.lab1024.smartadmin.util;
|
package net.lab1024.smartadmin.util;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package net.lab1024.smartadmin.util.excel;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* zhuoda
|
||||||
|
*/
|
||||||
|
public class SmartExcel {
|
||||||
|
|
||||||
|
List<SmartSheet> sheetList = new ArrayList<SmartSheet>();;
|
||||||
|
|
||||||
|
public SmartExcel(String fileName) {
|
||||||
|
org.apache.poi.ss.usermodel.Workbook workbook = null;
|
||||||
|
try {
|
||||||
|
workbook = fileName.endsWith(".xls") ? new HSSFWorkbook(new FileInputStream(fileName)) : new XSSFWorkbook(new FileInputStream(fileName));
|
||||||
|
int numberOfSheets = workbook.getNumberOfSheets();
|
||||||
|
for (int index = 0; index < numberOfSheets; index++) {
|
||||||
|
addSheet(new SmartSheet(workbook.getSheetAt(index)));
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw new RuntimeException(t);
|
||||||
|
} finally {
|
||||||
|
if (workbook != null) {
|
||||||
|
try {
|
||||||
|
workbook.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
workbook = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SmartExcel(InputStream ins, SmartExcelFileType fileType) {
|
||||||
|
org.apache.poi.ss.usermodel.Workbook workbook = null;
|
||||||
|
try {
|
||||||
|
workbook = fileType == SmartExcelFileType.XLS ? new HSSFWorkbook(ins) : new XSSFWorkbook(ins);
|
||||||
|
int numberOfSheets = workbook.getNumberOfSheets();
|
||||||
|
for (int index = 0; index < numberOfSheets; index++) {
|
||||||
|
addSheet(new SmartSheet(workbook.getSheetAt(index)));
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw new RuntimeException(t);
|
||||||
|
} finally {
|
||||||
|
if (workbook != null) {
|
||||||
|
try {
|
||||||
|
workbook.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
workbook = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected void addSheet(SmartSheet sheet) {
|
||||||
|
this.sheetList.add(sheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected void addSheetList(Collection<SmartSheet> sheets) {
|
||||||
|
this.sheetList.addAll(sheets);
|
||||||
|
}
|
||||||
|
|
||||||
|
final public List<SmartSheet> getSheetList() {
|
||||||
|
return sheetList;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public SmartSheet getSheet(String sheetName) {
|
||||||
|
for (SmartSheet sheet : sheetList) {
|
||||||
|
if (sheet.getName().equals(sheetName)) {
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.lab1024.smartadmin.util.excel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhuoda
|
||||||
|
*/
|
||||||
|
public enum SmartExcelFileType {
|
||||||
|
XLS,
|
||||||
|
XLSX
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package net.lab1024.smartadmin.util.excel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhuoda
|
||||||
|
* @Date 2020/8/10
|
||||||
|
*/
|
||||||
|
|
||||||
|
import net.lab1024.smartadmin.util.SmartFileUtil;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class SmartExcelReader {
|
||||||
|
|
||||||
|
public static SmartExcel openExcel(String filePath) throws IOException {
|
||||||
|
SmartFileUtil.isFileExistThrowException(filePath);
|
||||||
|
return new SmartExcel(new File(filePath).getCanonicalPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SmartExcel openExcel(File file) throws IOException {
|
||||||
|
return new SmartExcel(file.getCanonicalPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SmartExcel openExcel(InputStream ins, SmartExcelFileType fileType) throws IOException {
|
||||||
|
return new SmartExcel(ins, fileType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
SmartExcel smartExcel = openExcel(new FileInputStream(new File("F:/privilege.xlsx")), SmartExcelFileType.XLSX);
|
||||||
|
System.out.println(smartExcel.getSheetList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
package net.lab1024.smartadmin.util.excel;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.CellType;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhuoda
|
||||||
|
*/
|
||||||
|
public class SmartSheet {
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
private final int rowCount;
|
||||||
|
private final int columnCount;
|
||||||
|
private final String[][] datas;
|
||||||
|
|
||||||
|
public SmartSheet(org.apache.poi.ss.usermodel.Sheet sheet) {
|
||||||
|
this.name = sheet.getSheetName();
|
||||||
|
this.rowCount = sheet.getLastRowNum() + 1;
|
||||||
|
// 初始化基本数据
|
||||||
|
int maxColumnCount = 0;
|
||||||
|
this.datas = new String[rowCount][];
|
||||||
|
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
||||||
|
Row row = sheet.getRow(rowIndex);
|
||||||
|
if (row == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int _columnCount = row.getLastCellNum() + 1;
|
||||||
|
this.datas[rowIndex] = new String[_columnCount];
|
||||||
|
for (int colIndex = 0; colIndex < _columnCount; colIndex++) {
|
||||||
|
this.datas[rowIndex][colIndex] = getCellContents(row.getCell(colIndex));
|
||||||
|
}
|
||||||
|
if (maxColumnCount < _columnCount) {
|
||||||
|
maxColumnCount = _columnCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.columnCount = maxColumnCount;
|
||||||
|
// 根据单元格合并情况,填充内容
|
||||||
|
for (int index = 0; index < sheet.getNumMergedRegions(); index++) {
|
||||||
|
CellRangeAddress mergedRegion = sheet.getMergedRegion(index);
|
||||||
|
String upperLeftData = this.datas[mergedRegion.getFirstRow()][mergedRegion.getFirstColumn()];
|
||||||
|
for (int rowIndex = mergedRegion.getFirstRow(); rowIndex <= mergedRegion.getLastRow(); rowIndex++) {
|
||||||
|
String[] _rowDatas = this.datas[rowIndex];
|
||||||
|
if (_rowDatas == null) {
|
||||||
|
this.datas[rowIndex] = new String[mergedRegion.getLastColumn() + 1];
|
||||||
|
} else if (_rowDatas.length < mergedRegion.getLastColumn() + 1) {
|
||||||
|
String[] newStrArray = new String[mergedRegion.getLastColumn() + 1];
|
||||||
|
System.arraycopy(_rowDatas, 0, newStrArray, 0, _rowDatas.length);
|
||||||
|
this.datas[rowIndex] = newStrArray;
|
||||||
|
}
|
||||||
|
for (int colIndex = mergedRegion.getFirstColumn(); colIndex <= mergedRegion.getLastColumn(); colIndex++) {
|
||||||
|
this.datas[rowIndex][colIndex] = upperLeftData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCellContents(Cell cell) {
|
||||||
|
if (cell == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return getCellContents(cell.getCellType(), cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCellContents(CellType type, Cell cell) {
|
||||||
|
switch (type) {
|
||||||
|
case BLANK:
|
||||||
|
return "";
|
||||||
|
case NUMERIC:
|
||||||
|
return cell.getStringCellValue();
|
||||||
|
case STRING:
|
||||||
|
return cell.getStringCellValue();
|
||||||
|
case FORMULA:
|
||||||
|
return getCellContents(cell.getCachedFormulaResultType(), cell);
|
||||||
|
case BOOLEAN:
|
||||||
|
return String.valueOf(cell.getBooleanCellValue());
|
||||||
|
case ERROR:
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException(String.format("unsupported cell type:%d, col:%d, row:%d, sheet:%s", cell.getCellType(), cell.getColumnIndex(),
|
||||||
|
cell.getRowIndex(), getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRowCount() {
|
||||||
|
return rowCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColumnCount() {
|
||||||
|
return columnCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(int rowIndex, int columnIndex) {
|
||||||
|
if (rowIndex < 0 || rowIndex >= datas.length) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (columnIndex < 0 || datas[rowIndex] == null || columnIndex >= datas[rowIndex].length) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String value = datas[rowIndex][columnIndex];
|
||||||
|
return value == null ? "": value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -4,5 +4,5 @@
|
|||||||
____) | | | | | | (_| | | | |_ / ____ \ (_| | | | | | | | | | |
|
____) | | | | | | (_| | | | |_ / ____ \ (_| | | | | | | | | | |
|
||||||
|_____/|_| |_| |_|\__,_|_| \__/_/ \_\__,_|_| |_| |_|_|_| |_|
|
|_____/|_| |_| |_|\__,_|_| \__/_/ \_\__,_|_| |_| |_|_|_| |_|
|
||||||
|
|
||||||
SmartAdmin v1.1.0
|
SmartAdmin v1.2.0
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ spring.servlet.multipart.max-request-size=30MB
|
|||||||
file-upload-service.path=/home/upload/
|
file-upload-service.path=/home/upload/
|
||||||
|
|
||||||
######################### database #########################
|
######################### database #########################
|
||||||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/smart-admin-dev?autoReconnect=true&useServerPreparedStmts=false&rewriteBatchedStatements=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&serverTimezone=UTC
|
spring.datasource.url=jdbc:p6spy:mysql://127.0.0.1:3306/smart-admin-dev?autoReconnect=true&useServerPreparedStmts=false&rewriteBatchedStatements=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&serverTimezone=UTC
|
||||||
spring.datasource.username=root
|
spring.datasource.username=root
|
||||||
spring.datasource.password=Root.123
|
spring.datasource.password=Root.123
|
||||||
spring.datasource.initial-size=2
|
spring.datasource.initial-size=2
|
||||||
@@ -31,8 +31,8 @@ spring.datasource.min-idle=1
|
|||||||
spring.datasource.max-active=10
|
spring.datasource.max-active=10
|
||||||
spring.datasource.max-wait=60000
|
spring.datasource.max-wait=60000
|
||||||
spring.datasource.time-between-eviction-runs-millis=60000
|
spring.datasource.time-between-eviction-runs-millis=60000
|
||||||
spring.datasource.min-evictable-edle-time-millis=300000
|
spring.datasource.min-evictable-idle-time-millis=300000
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.p6spy.engine.spy.P6SpyDriver
|
||||||
spring.datasource.filters=stat
|
spring.datasource.filters=stat
|
||||||
spring.datasource.druid.username=druid
|
spring.datasource.druid.username=druid
|
||||||
spring.datasource.druid.password=123456
|
spring.datasource.druid.password=123456
|
||||||
@@ -44,16 +44,16 @@ spring.redis.host=127.0.0.1
|
|||||||
spring.redis.port=6379
|
spring.redis.port=6379
|
||||||
spring.redis.timeout=10000ms
|
spring.redis.timeout=10000ms
|
||||||
spring.redis.password=
|
spring.redis.password=
|
||||||
spring.redis.lettuce..pool.max-active=100
|
spring.redis.lettuce.pool.max-active=10
|
||||||
spring.redis.lettuce.pool.min-idle=5
|
spring.redis.lettuce.pool.min-idle=5
|
||||||
spring.redis.lettuce.pool.max-idle=10
|
spring.redis.lettuce.pool.max-idle=10
|
||||||
spring.redis.lettuce.pool.max-wait=30000ms
|
spring.redis.lettuce.pool.max-wait=30000ms
|
||||||
|
|
||||||
########################## rest http pool #########################
|
########################## rest http pool #########################
|
||||||
#\u6700\u5927\u8FDE\u63A5\u6570
|
#\u6700\u5927\u8FDE\u63A5\u6570
|
||||||
http.pool.max-total=100
|
http.pool.max-total=10
|
||||||
#\u5355\u8DEF\u7531\u6700\u5927\u8FDE\u63A5\u6570
|
#\u5355\u8DEF\u7531\u6700\u5927\u8FDE\u63A5\u6570
|
||||||
http.pool.default-max-per-route=25
|
http.pool.default-max-per-route=5
|
||||||
#\u670D\u52A1\u5668\u8FD4\u56DE\u6570\u636E(response)\u7684\u65F6\u95F4
|
#\u670D\u52A1\u5668\u8FD4\u56DE\u6570\u636E(response)\u7684\u65F6\u95F4
|
||||||
http.pool.socket-timeout=8000
|
http.pool.socket-timeout=8000
|
||||||
#\u8FDE\u63A5\u4E0A\u670D\u52A1\u5668(\u63E1\u624B\u6210\u529F)\u7684\u65F6\u95F4
|
#\u8FDE\u63A5\u4E0A\u670D\u52A1\u5668(\u63E1\u624B\u6210\u529F)\u7684\u65F6\u95F4
|
||||||
@@ -83,14 +83,14 @@ jwt.key=smart-admin-jwt-key
|
|||||||
|
|
||||||
########################## smart reload #########################
|
########################## smart reload #########################
|
||||||
smart-reload.thread-count=1
|
smart-reload.thread-count=1
|
||||||
smart-reload.time-interval=5
|
smart-reload.time-interval=300
|
||||||
|
|
||||||
######################### cros #########################
|
######################### cros #########################
|
||||||
access-control-allow-origin=*
|
access-control-allow-origin=*
|
||||||
|
|
||||||
######################### heart beat #########################
|
######################### heart beat #########################
|
||||||
heart-beat.delayHandlerTime=60000
|
heart-beat.delayHandlerTime=60000
|
||||||
heart-beat.intervalTime=180000
|
heart-beat.intervalTime=300000
|
||||||
|
|
||||||
######################### quartz #############################
|
######################### quartz #############################
|
||||||
#\u8C03\u5EA6\u6807\u8BC6\u540D \u96C6\u7FA4\u4E2D\u6BCF\u4E00\u4E2A\u5B9E\u4F8B\u90FD\u5FC5\u987B\u4F7F\u7528\u76F8\u540C\u7684\u540D\u79F0
|
#\u8C03\u5EA6\u6807\u8BC6\u540D \u96C6\u7FA4\u4E2D\u6BCF\u4E00\u4E2A\u5B9E\u4F8B\u90FD\u5FC5\u987B\u4F7F\u7528\u76F8\u540C\u7684\u540D\u79F0
|
||||||
@@ -106,8 +106,8 @@ spring.quartz.properties.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.
|
|||||||
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
|
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
|
||||||
spring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_
|
spring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_
|
||||||
spring.quartz.properties.org.quartz.jobStore.isClustered=true
|
spring.quartz.properties.org.quartz.jobStore.isClustered=true
|
||||||
#\u8C03\u5EA6\u5B9E\u4F8B\u5931\u6548\u7684\u68C0\u67E5\u65F6\u95F4\u95F4\u9694
|
#\u8C03\u5EA6\u5B9E\u4F8B\u5931\u6548\u7684\u68C0\u67E5\u65F6\u95F4\u95F4\u9694, \u5F00\u53D1\u73AF\u5883\u6539\u4E3A\u4E8660\u79D2
|
||||||
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=10000
|
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=60000
|
||||||
spring.quartz.properties.org.quartz.jobStore.useProperties=false
|
spring.quartz.properties.org.quartz.jobStore.useProperties=false
|
||||||
#\u8C03\u5EA6\u7EBF\u7A0B
|
#\u8C03\u5EA6\u7EBF\u7A0B
|
||||||
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
|
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
|
||||||
@@ -119,3 +119,5 @@ spring.quartz.job-store-type=jdbc
|
|||||||
#ALWAYS,EMBEDDED,NEVER
|
#ALWAYS,EMBEDDED,NEVER
|
||||||
spring.quartz.jdbc.initialize-schema=NEVER
|
spring.quartz.jdbc.initialize-schema=NEVER
|
||||||
spring.quartz.jdbc.schema=classpath:sql/quartz_mysql_2.3.0.sql
|
spring.quartz.jdbc.schema=classpath:sql/quartz_mysql_2.3.0.sql
|
||||||
|
#\u81EA\u52A8\u626B\u63CF\u4EFB\u52A1\u5355\u5E76\u53D1\u73B0\u6539\u52A8\u7684\u65F6\u95F4\u95F4\u9694,\u5355\u4F4D\u4E3A\u79D2
|
||||||
|
org.quartz.plugin.jobInitializer.scanInterval = 300
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory
|
||||||
|
# \u81EA\u5B9A\u4E49\u65E5\u5FD7\u6253\u5370
|
||||||
|
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
|
||||||
|
#\u65E5\u5FD7\u8F93\u51FA\u5230\u63A7\u5236\u53F0
|
||||||
|
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
|
||||||
|
# \u4F7F\u7528\u65E5\u5FD7\u7CFB\u7EDF\u8BB0\u5F55 sql
|
||||||
|
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
|
||||||
|
# \u8BBE\u7F6E p6spy driver \u4EE3\u7406
|
||||||
|
deregisterdrivers=true
|
||||||
|
# \u53D6\u6D88JDBC URL\u524D\u7F00
|
||||||
|
useprefix=true
|
||||||
|
# \u914D\u7F6E\u8BB0\u5F55 Log \u4F8B\u5916,\u53EF\u53BB\u6389\u7684\u7ED3\u679C\u96C6\u6709error,info,batch,debug,statement,commit,rollback,result,resultset.
|
||||||
|
#excludecategories=info,debug,result,commit,resultset
|
||||||
|
# \u65E5\u671F\u683C\u5F0F
|
||||||
|
dateformat=yyyy-MM-dd HH:mm:ss
|
||||||
|
|
||||||
|
# \u662F\u5426\u5F00\u542F\u6162SQL\u8BB0\u5F55
|
||||||
|
outagedetection=true
|
||||||
|
# \u6162SQL\u8BB0\u5F55\u6807\u51C6 2 \u79D2
|
||||||
|
outagedetectioninterval=2
|
||||||
@@ -18,15 +18,6 @@
|
|||||||
d.create_time
|
d.create_time
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="countSubDepartment" resultType="integer">
|
|
||||||
SELECT
|
|
||||||
count(1)
|
|
||||||
FROM
|
|
||||||
t_department
|
|
||||||
WHERE
|
|
||||||
parent_id = #{departmentId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="listAll" resultMap="DepartmentVO">
|
<select id="listAll" resultMap="DepartmentVO">
|
||||||
SELECT
|
SELECT
|
||||||
<include refid="baseSql"></include>,
|
<include refid="baseSql"></include>,
|
||||||
@@ -50,5 +41,14 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="countSubDepartment" resultType="java.lang.Integer">
|
||||||
|
SELECT
|
||||||
|
count(1)
|
||||||
|
FROM
|
||||||
|
t_department
|
||||||
|
WHERE
|
||||||
|
parent_id = #{deptId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
FROM
|
FROM
|
||||||
t_employee e
|
t_employee e
|
||||||
WHERE
|
WHERE
|
||||||
e.login_name = #{phone} and e.is_disabled = #{isDisabled}
|
e.phone = #{phone} and e.is_disabled = #{isDisabled}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
@@ -124,7 +124,10 @@
|
|||||||
FROM
|
FROM
|
||||||
t_employee e
|
t_employee e
|
||||||
WHERE
|
WHERE
|
||||||
e.department_id = #{departmentId}
|
e.department_id = #{depId}
|
||||||
|
<if test="deleteFlag != null">
|
||||||
|
AND e.is_delete = #{deleteFlag}
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
@@ -146,7 +149,7 @@
|
|||||||
t_employee e
|
t_employee e
|
||||||
WHERE
|
WHERE
|
||||||
e.department_id IN
|
e.department_id IN
|
||||||
<foreach collection="departmentIds" item="item" separator=",">
|
<foreach collection="departmentIds" item="item" open="(" close=")" separator=",">
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
order by e.create_time desc
|
order by e.create_time desc
|
||||||
@@ -158,7 +161,7 @@
|
|||||||
FROM
|
FROM
|
||||||
t_employee e
|
t_employee e
|
||||||
where e.id IN
|
where e.id IN
|
||||||
<foreach collection="ids" item="item" separator=",">
|
<foreach collection="ids" item="item" open="(" close=")" separator=",">
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
order by e.create_time desc
|
order by e.create_time desc
|
||||||
|
|||||||
@@ -99,6 +99,19 @@
|
|||||||
p.key = #{key}
|
p.key = #{key}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByKeyList" resultMap="PrivilegeEntity">
|
||||||
|
SELECT
|
||||||
|
<include refid="baseSql"></include>
|
||||||
|
FROM
|
||||||
|
t_privilege p
|
||||||
|
WHERE
|
||||||
|
p.key in
|
||||||
|
<foreach item="item" collection="keyList" open="(" close=")"
|
||||||
|
separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectAll" resultMap="PrivilegeEntity">
|
<select id="selectAll" resultMap="PrivilegeEntity">
|
||||||
SELECT
|
SELECT
|
||||||
<include refid="baseSql"></include>,
|
<include refid="baseSql"></include>,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ spring.datasource.min-idle=1
|
|||||||
spring.datasource.max-active=10
|
spring.datasource.max-active=10
|
||||||
spring.datasource.max-wait=60000
|
spring.datasource.max-wait=60000
|
||||||
spring.datasource.time-between-eviction-runs-millis=60000
|
spring.datasource.time-between-eviction-runs-millis=60000
|
||||||
spring.datasource.min-evictable-edle-time-millis=300000
|
spring.datasource.min-evictable-idle-time-millis=300000
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
spring.datasource.filters=stat
|
spring.datasource.filters=stat
|
||||||
spring.datasource.druid.username=druid
|
spring.datasource.druid.username=druid
|
||||||
@@ -44,16 +44,16 @@ spring.redis.host=127.0.0.1
|
|||||||
spring.redis.port=6379
|
spring.redis.port=6379
|
||||||
spring.redis.timeout=10000ms
|
spring.redis.timeout=10000ms
|
||||||
spring.redis.password=
|
spring.redis.password=
|
||||||
spring.redis.lettuce..pool.max-active=100
|
spring.redis.lettuce.pool.max-active=10
|
||||||
spring.redis.lettuce.pool.min-idle=5
|
spring.redis.lettuce.pool.min-idle=5
|
||||||
spring.redis.lettuce.pool.max-idle=10
|
spring.redis.lettuce.pool.max-idle=10
|
||||||
spring.redis.lettuce.pool.max-wait=30000ms
|
spring.redis.lettuce.pool.max-wait=30000ms
|
||||||
|
|
||||||
########################## rest http pool #########################
|
########################## rest http pool #########################
|
||||||
#\u6700\u5927\u8FDE\u63A5\u6570
|
#\u6700\u5927\u8FDE\u63A5\u6570
|
||||||
http.pool.max-total=100
|
http.pool.max-total=10
|
||||||
#\u5355\u8DEF\u7531\u6700\u5927\u8FDE\u63A5\u6570
|
#\u5355\u8DEF\u7531\u6700\u5927\u8FDE\u63A5\u6570
|
||||||
http.pool.default-max-per-route=25
|
http.pool.default-max-per-route=5
|
||||||
#\u670D\u52A1\u5668\u8FD4\u56DE\u6570\u636E(response)\u7684\u65F6\u95F4
|
#\u670D\u52A1\u5668\u8FD4\u56DE\u6570\u636E(response)\u7684\u65F6\u95F4
|
||||||
http.pool.socket-timeout=8000
|
http.pool.socket-timeout=8000
|
||||||
#\u8FDE\u63A5\u4E0A\u670D\u52A1\u5668(\u63E1\u624B\u6210\u529F)\u7684\u65F6\u95F4
|
#\u8FDE\u63A5\u4E0A\u670D\u52A1\u5668(\u63E1\u624B\u6210\u529F)\u7684\u65F6\u95F4
|
||||||
@@ -83,14 +83,14 @@ jwt.key=smart-admin-jwt-key
|
|||||||
|
|
||||||
########################## smart reload #########################
|
########################## smart reload #########################
|
||||||
smart-reload.thread-count=1
|
smart-reload.thread-count=1
|
||||||
smart-reload.time-interval=5
|
smart-reload.time-interval=30
|
||||||
|
|
||||||
######################### cros #########################
|
######################### cros #########################
|
||||||
access-control-allow-origin=*
|
access-control-allow-origin=*
|
||||||
|
|
||||||
######################### heart beat #########################
|
######################### heart beat #########################
|
||||||
heart-beat.delayHandlerTime=60000
|
heart-beat.delayHandlerTime=60000
|
||||||
heart-beat.intervalTime=180000
|
heart-beat.intervalTime=60000
|
||||||
|
|
||||||
######################### quartz #############################
|
######################### quartz #############################
|
||||||
#\u8C03\u5EA6\u6807\u8BC6\u540D \u96C6\u7FA4\u4E2D\u6BCF\u4E00\u4E2A\u5B9E\u4F8B\u90FD\u5FC5\u987B\u4F7F\u7528\u76F8\u540C\u7684\u540D\u79F0
|
#\u8C03\u5EA6\u6807\u8BC6\u540D \u96C6\u7FA4\u4E2D\u6BCF\u4E00\u4E2A\u5B9E\u4F8B\u90FD\u5FC5\u987B\u4F7F\u7528\u76F8\u540C\u7684\u540D\u79F0
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ spring.datasource.username=smart-admin
|
|||||||
spring.datasource.password=Admin@123457
|
spring.datasource.password=Admin@123457
|
||||||
spring.datasource.initial-size=2
|
spring.datasource.initial-size=2
|
||||||
spring.datasource.min-idle=1
|
spring.datasource.min-idle=1
|
||||||
spring.datasource.max-active=10
|
spring.datasource.max-active=100
|
||||||
spring.datasource.max-wait=60000
|
spring.datasource.max-wait=60000
|
||||||
spring.datasource.time-between-eviction-runs-millis=60000
|
spring.datasource.time-between-eviction-runs-millis=60000
|
||||||
spring.datasource.min-evictable-edle-time-millis=300000
|
spring.datasource.min-evictable-idle-time-millis=300000
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
spring.datasource.filters=stat
|
spring.datasource.filters=stat
|
||||||
spring.datasource.druid.username=druid
|
spring.datasource.druid.username=druid
|
||||||
spring.datasource.druid.password=Gq123456
|
spring.datasource.druid.password=druid
|
||||||
spring.datasource.druid.login.enabled=false
|
spring.datasource.druid.login.enabled=false
|
||||||
|
|
||||||
######################### redis #######################################
|
######################### redis #######################################
|
||||||
@@ -44,16 +44,16 @@ spring.redis.host=127.0.0.1
|
|||||||
spring.redis.port=6379
|
spring.redis.port=6379
|
||||||
spring.redis.timeout=10000ms
|
spring.redis.timeout=10000ms
|
||||||
spring.redis.password=Gq123456@
|
spring.redis.password=Gq123456@
|
||||||
spring.redis.lettuce..pool.max-active=100
|
spring.redis.lettuce.pool.max-active=10
|
||||||
spring.redis.lettuce.pool.min-idle=5
|
spring.redis.lettuce.pool.min-idle=5
|
||||||
spring.redis.lettuce.pool.max-idle=10
|
spring.redis.lettuce.pool.max-idle=10
|
||||||
spring.redis.lettuce.pool.max-wait=30000ms
|
spring.redis.lettuce.pool.max-wait=30000ms
|
||||||
|
|
||||||
########################## rest http pool #########################
|
########################## rest http pool #########################
|
||||||
#\u6700\u5927\u8FDE\u63A5\u6570
|
#\u6700\u5927\u8FDE\u63A5\u6570
|
||||||
http.pool.max-total=100
|
http.pool.max-total=10
|
||||||
#\u5355\u8DEF\u7531\u6700\u5927\u8FDE\u63A5\u6570
|
#\u5355\u8DEF\u7531\u6700\u5927\u8FDE\u63A5\u6570
|
||||||
http.pool.default-max-per-route=25
|
http.pool.default-max-per-route=5
|
||||||
#\u670D\u52A1\u5668\u8FD4\u56DE\u6570\u636E(response)\u7684\u65F6\u95F4
|
#\u670D\u52A1\u5668\u8FD4\u56DE\u6570\u636E(response)\u7684\u65F6\u95F4
|
||||||
http.pool.socket-timeout=8000
|
http.pool.socket-timeout=8000
|
||||||
#\u8FDE\u63A5\u4E0A\u670D\u52A1\u5668(\u63E1\u624B\u6210\u529F)\u7684\u65F6\u95F4
|
#\u8FDE\u63A5\u4E0A\u670D\u52A1\u5668(\u63E1\u624B\u6210\u529F)\u7684\u65F6\u95F4
|
||||||
@@ -83,12 +83,12 @@ jwt.key=smart-admin-jwt-key
|
|||||||
|
|
||||||
########################## smart reload #########################
|
########################## smart reload #########################
|
||||||
smart-reload.thread-count=2
|
smart-reload.thread-count=2
|
||||||
smart-reload.time-interval=20
|
smart-reload.time-interval=30
|
||||||
######################### cros #########################
|
######################### cros #########################
|
||||||
access-control-allow-origin=preview.smartadmin.1024lab.net
|
access-control-allow-origin=preview.smartadmin.1024lab.net
|
||||||
######################### heart beat #########################
|
######################### heart beat #########################
|
||||||
heart-beat.delayHandlerTime=60000
|
heart-beat.delayHandlerTime=60000
|
||||||
heart-beat.intervalTime=180000
|
heart-beat.intervalTime=60000
|
||||||
|
|
||||||
######################### quartz #############################
|
######################### quartz #############################
|
||||||
#\u8C03\u5EA6\u6807\u8BC6\u540D \u96C6\u7FA4\u4E2D\u6BCF\u4E00\u4E2A\u5B9E\u4F8B\u90FD\u5FC5\u987B\u4F7F\u7528\u76F8\u540C\u7684\u540D\u79F0
|
#\u8C03\u5EA6\u6807\u8BC6\u540D \u96C6\u7FA4\u4E2D\u6BCF\u4E00\u4E2A\u5B9E\u4F8B\u90FD\u5FC5\u987B\u4F7F\u7528\u76F8\u540C\u7684\u540D\u79F0
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ spring.servlet.multipart.max-request-size=30MB
|
|||||||
file-upload-service.path=/home/upload/
|
file-upload-service.path=/home/upload/
|
||||||
|
|
||||||
######################### database #########################
|
######################### database #########################
|
||||||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/smart-admin-sit?autoReconnect=true&useServerPreparedStmts=false&rewriteBatchedStatements=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&serverTimezone=UTC
|
spring.datasource.url=jdbc:p6spy:mysql://127.0.0.1:3306/smart-admin-sit?autoReconnect=true&useServerPreparedStmts=false&rewriteBatchedStatements=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&serverTimezone=UTC
|
||||||
spring.datasource.username=root
|
spring.datasource.username=root
|
||||||
spring.datasource.password=root
|
spring.datasource.password=root
|
||||||
spring.datasource.initial-size=2
|
spring.datasource.initial-size=2
|
||||||
@@ -31,8 +31,8 @@ spring.datasource.min-idle=1
|
|||||||
spring.datasource.max-active=10
|
spring.datasource.max-active=10
|
||||||
spring.datasource.max-wait=60000
|
spring.datasource.max-wait=60000
|
||||||
spring.datasource.time-between-eviction-runs-millis=60000
|
spring.datasource.time-between-eviction-runs-millis=60000
|
||||||
spring.datasource.min-evictable-edle-time-millis=300000
|
spring.datasource.min-evictable-idle-time-millis=300000
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.p6spy.engine.spy.P6SpyDriver
|
||||||
spring.datasource.filters=stat
|
spring.datasource.filters=stat
|
||||||
spring.datasource.druid.username=druid
|
spring.datasource.druid.username=druid
|
||||||
spring.datasource.druid.password=123456
|
spring.datasource.druid.password=123456
|
||||||
@@ -44,16 +44,16 @@ spring.redis.host=127.0.0.1
|
|||||||
spring.redis.port=6379
|
spring.redis.port=6379
|
||||||
spring.redis.timeout=10000ms
|
spring.redis.timeout=10000ms
|
||||||
spring.redis.password=
|
spring.redis.password=
|
||||||
spring.redis.lettuce..pool.max-active=100
|
spring.redis.lettuce.pool.max-active=10
|
||||||
spring.redis.lettuce.pool.min-idle=5
|
spring.redis.lettuce.pool.min-idle=5
|
||||||
spring.redis.lettuce.pool.max-idle=10
|
spring.redis.lettuce.pool.max-idle=10
|
||||||
spring.redis.lettuce.pool.max-wait=30000ms
|
spring.redis.lettuce.pool.max-wait=30000ms
|
||||||
|
|
||||||
########################## rest http pool #########################
|
########################## rest http pool #########################
|
||||||
#\u6700\u5927\u8FDE\u63A5\u6570
|
#\u6700\u5927\u8FDE\u63A5\u6570
|
||||||
http.pool.max-total=100
|
http.pool.max-total=10
|
||||||
#\u5355\u8DEF\u7531\u6700\u5927\u8FDE\u63A5\u6570
|
#\u5355\u8DEF\u7531\u6700\u5927\u8FDE\u63A5\u6570
|
||||||
http.pool.default-max-per-route=25
|
http.pool.default-max-per-route=5
|
||||||
#\u670D\u52A1\u5668\u8FD4\u56DE\u6570\u636E(response)\u7684\u65F6\u95F4
|
#\u670D\u52A1\u5668\u8FD4\u56DE\u6570\u636E(response)\u7684\u65F6\u95F4
|
||||||
http.pool.socket-timeout=8000
|
http.pool.socket-timeout=8000
|
||||||
#\u8FDE\u63A5\u4E0A\u670D\u52A1\u5668(\u63E1\u624B\u6210\u529F)\u7684\u65F6\u95F4
|
#\u8FDE\u63A5\u4E0A\u670D\u52A1\u5668(\u63E1\u624B\u6210\u529F)\u7684\u65F6\u95F4
|
||||||
@@ -83,14 +83,14 @@ jwt.key=smart-admin-jwt-key
|
|||||||
|
|
||||||
########################## smart reload #########################
|
########################## smart reload #########################
|
||||||
smart-reload.thread-count=1
|
smart-reload.thread-count=1
|
||||||
smart-reload.time-interval=5
|
smart-reload.time-interval=120
|
||||||
|
|
||||||
######################### cros #########################
|
######################### cros #########################
|
||||||
access-control-allow-origin=*
|
access-control-allow-origin=*
|
||||||
|
|
||||||
######################### heart beat #########################
|
######################### heart beat #########################
|
||||||
heart-beat.delayHandlerTime=60000
|
heart-beat.delayHandlerTime=60000
|
||||||
heart-beat.intervalTime=180000
|
heart-beat.intervalTime=300000
|
||||||
|
|
||||||
######################### quartz #############################
|
######################### quartz #############################
|
||||||
#\u8C03\u5EA6\u6807\u8BC6\u540D \u96C6\u7FA4\u4E2D\u6BCF\u4E00\u4E2A\u5B9E\u4F8B\u90FD\u5FC5\u987B\u4F7F\u7528\u76F8\u540C\u7684\u540D\u79F0
|
#\u8C03\u5EA6\u6807\u8BC6\u540D \u96C6\u7FA4\u4E2D\u6BCF\u4E00\u4E2A\u5B9E\u4F8B\u90FD\u5FC5\u987B\u4F7F\u7528\u76F8\u540C\u7684\u540D\u79F0
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory
|
||||||
|
# \u81EA\u5B9A\u4E49\u65E5\u5FD7\u6253\u5370
|
||||||
|
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
|
||||||
|
#\u65E5\u5FD7\u8F93\u51FA\u5230\u63A7\u5236\u53F0
|
||||||
|
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
|
||||||
|
# \u4F7F\u7528\u65E5\u5FD7\u7CFB\u7EDF\u8BB0\u5F55 sql
|
||||||
|
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
|
||||||
|
# \u8BBE\u7F6E p6spy driver \u4EE3\u7406
|
||||||
|
deregisterdrivers=true
|
||||||
|
# \u53D6\u6D88JDBC URL\u524D\u7F00
|
||||||
|
useprefix=true
|
||||||
|
# \u914D\u7F6E\u8BB0\u5F55 Log \u4F8B\u5916,\u53EF\u53BB\u6389\u7684\u7ED3\u679C\u96C6\u6709error,info,batch,debug,statement,commit,rollback,result,resultset.
|
||||||
|
#excludecategories=info,debug,result,commit,resultset
|
||||||
|
# \u65E5\u671F\u683C\u5F0F
|
||||||
|
dateformat=yyyy-MM-dd HH:mm:ss
|
||||||
|
|
||||||
|
# \u662F\u5426\u5F00\u542F\u6162SQL\u8BB0\u5F55
|
||||||
|
outagedetection=true
|
||||||
|
# \u6162SQL\u8BB0\u5F55\u6807\u51C6 2 \u79D2
|
||||||
|
outagedetectioninterval=2
|
||||||
File diff suppressed because one or more lines are too long
@@ -23,7 +23,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { ${moduleVar}Api } from '@/api/${webModuleName}';
|
import { ${moduleVar}Api } from '@/api/${webModuleName}';
|
||||||
export default {
|
export default {
|
||||||
name: 'CodeReviewListForm',
|
name: '${moduleClass}ListForm',
|
||||||
components: {
|
components: {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@@ -103,7 +103,7 @@
|
|||||||
resetForm() {
|
resetForm() {
|
||||||
this.form = {
|
this.form = {
|
||||||
#foreach ($column in $columnList)
|
#foreach ($column in $columnList)
|
||||||
#if($column.columnName != 'id' && $column.fieldName != 'updateTime' && $column.fieldName != 'createTime')
|
#if( $column.fieldName != 'updateTime' && $column.fieldName != 'createTime')
|
||||||
//${column.columnDesc}
|
//${column.columnDesc}
|
||||||
${column.fieldName}:null,
|
${column.fieldName}:null,
|
||||||
#end
|
#end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VUE_APP_TYPE=dev
|
VUE_APP_TYPE=dev
|
||||||
VUE_APP_URL=http://172.16.0.145:10086/smart-admin-api/
|
VUE_APP_URL=http://127.0.0.1:10086/smart-admin-api/
|
||||||
VUE_APP_SOCKET_URL=ws://172.16.0.145:10086/smart-admin-api/
|
VUE_APP_SOCKET_URL=ws://127.0.0.1:10086/smart-admin-api/
|
||||||
|
|||||||
2
smart-admin-web/.gitignore
vendored
2
smart-admin-web/.gitignore
vendored
@@ -2,8 +2,6 @@
|
|||||||
node_modules
|
node_modules
|
||||||
/dist
|
/dist
|
||||||
|
|
||||||
package-lock.json
|
|
||||||
|
|
||||||
/tests/e2e/videos/
|
/tests/e2e/videos/
|
||||||
/tests/e2e/screenshots/
|
/tests/e2e/screenshots/
|
||||||
|
|
||||||
|
|||||||
15500
smart-admin-web/package-lock.json
generated
Normal file
15500
smart-admin-web/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@
|
|||||||
"cropperjs": "^1.2.2",
|
"cropperjs": "^1.2.2",
|
||||||
"dayjs": "^1.7.7",
|
"dayjs": "^1.7.7",
|
||||||
"decimal.js": "^10.1.1",
|
"decimal.js": "^10.1.1",
|
||||||
|
"e-guide-layer": "^0.1.1",
|
||||||
"echarts": "^4.0.4",
|
"echarts": "^4.0.4",
|
||||||
"gq-plus": "^2.1.5",
|
"gq-plus": "^2.1.5",
|
||||||
"html2canvas": "^1.0.0-alpha.12",
|
"html2canvas": "^1.0.0-alpha.12",
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.7 KiB |
BIN
smart-admin-web/src/assets/images/logo1.png
Normal file
BIN
smart-admin-web/src/assets/images/logo1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
@@ -12,3 +12,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.step-bottom-btn{
|
||||||
|
width: 380px !important;
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
icon="icon iconfont icondaohangzhedie"
|
icon="icon iconfont icondaohangzhedie"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="custom-bread-crumb" style="margin-left: 30px;">
|
<div class="custom-bread-crumb" style="margin-left: 30px;" id="topMenuSelectDiv">
|
||||||
<div class="ivu-breadcrumb" >
|
<div class="ivu-breadcrumb" >
|
||||||
<Dropdown @on-click="changeTopMenu">
|
<Dropdown @on-click="changeTopMenu">
|
||||||
<a href="javascript:void(0)" style="font-size:15px;font-weight:600">
|
<a href="javascript:void(0)" style="font-size:15px;font-weight:600">
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
<div class="custom-content-con">
|
<div class="custom-content-con">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@@ -64,6 +65,27 @@ export default {
|
|||||||
required:true
|
required:true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
guideActiveIndex: 0,
|
||||||
|
guideList: [
|
||||||
|
{
|
||||||
|
confirmBtnText: '第一步:选择顶级菜单(SmartAdmin是支持四级菜单的哦)',
|
||||||
|
targetDom: '#topMenuSelectDiv',
|
||||||
|
clickHandle: () => {
|
||||||
|
this.guideActiveIndex = 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
confirmBtnText: '第二步:选择顶级下单下的三级菜单',
|
||||||
|
targetDom: '.side-menu-wrapper',
|
||||||
|
clickHandle: () => {
|
||||||
|
this.guideActiveIndex = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
// 面包屑集合
|
// 面包屑集合
|
||||||
breadCrumbList() {
|
breadCrumbList() {
|
||||||
@@ -80,3 +102,5 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,14 +20,14 @@
|
|||||||
v-else
|
v-else
|
||||||
>
|
>
|
||||||
<common-icon :type="item.children[0].icon || ''" />
|
<common-icon :type="item.children[0].icon || ''" />
|
||||||
<span>{{ showTitle(item.children[0]) }}</span>
|
<span>{{ showTitle(item.children[0]) }} </span>
|
||||||
</menu-item>
|
</menu-item>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<side-menu-item :key="`menu-${item.name}`" :parent-item="item" v-if="item.children && item.children.length > 0"></side-menu-item>
|
<side-menu-item :key="`menu-${item.name}`" :parent-item="item" v-if="item.children && item.children.length > 0"></side-menu-item>
|
||||||
<menu-item :key="`menu-${item.name}`" :name="getNameOrHref(item)" v-else>
|
<menu-item :key="`menu-${item.name}`" :name="getNameOrHref(item)" v-else>
|
||||||
<common-icon :type="item.icon || ''" />
|
<common-icon :type="item.icon || ''" />
|
||||||
<span>{{ showTitle(item) }}</span>
|
<span>{{ showTitle(item) }} </span>
|
||||||
</menu-item>
|
</menu-item>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
.scrollbar;
|
.scrollbar;
|
||||||
}
|
}
|
||||||
.logo-con{
|
.logo-con{
|
||||||
padding: 19px 0 15px 20px;
|
padding: 19px 10px 15px 5px;
|
||||||
&.collapsed{
|
&.collapsed{
|
||||||
padding: 19px 0 15px;
|
padding: 19px 0 15px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
margin-left: 200px;
|
margin-left: 200px;
|
||||||
}
|
}
|
||||||
.search-bar{
|
.search-bar{
|
||||||
padding:0 20px;
|
padding:0 14px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
&.collapsed{
|
&.collapsed{
|
||||||
padding:0 12px;
|
padding:0 12px;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<Sider
|
<Sider
|
||||||
:collapsed-width="60"
|
:collapsed-width="60"
|
||||||
:style="{overflow: 'hidden'}"
|
:style="{overflow: 'hidden'}"
|
||||||
:width="256"
|
:width="185"
|
||||||
class="left-sider"
|
class="left-sider"
|
||||||
collapsible
|
collapsible
|
||||||
hide-trigger
|
hide-trigger
|
||||||
|
|||||||
@@ -23,9 +23,13 @@ import enumInfo from '@/constants';
|
|||||||
// 处理table操作按钮
|
// 处理table操作按钮
|
||||||
import tableAction from './lib/table-action';
|
import tableAction from './lib/table-action';
|
||||||
|
|
||||||
//时间
|
// 时间
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
|
import 'e-guide-layer/dist/e-guide-layer.css'
|
||||||
|
import eGuideLayer from 'e-guide-layer'
|
||||||
|
|
||||||
|
Vue.use(eGuideLayer);
|
||||||
|
|
||||||
Vue.prototype.$tableAction = tableAction;
|
Vue.prototype.$tableAction = tableAction;
|
||||||
Vue.use(Enum, { enumInfo });
|
Vue.use(Enum, { enumInfo });
|
||||||
@@ -42,7 +46,7 @@ Number.prototype.toFixed = function (length) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//时间处理
|
//时间处理
|
||||||
moment.locale('zh-cn'); //设置语言 或 moment.lang('zh-cn');
|
moment.locale('zh-cn'); //设置语言 或 moment.lang('zh-cn');
|
||||||
Vue.prototype.$moment = moment;//赋值使用
|
Vue.prototype.$moment = moment;//赋值使用
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,24 +20,26 @@ export const threeRouter = [
|
|||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '/three-router/level-two/level-three1',
|
path: '/three-router/level-two/level-three1',
|
||||||
name: 'RoleOneTwo',
|
name: 'ThreeLevelRouterView',
|
||||||
meta: {
|
meta: {
|
||||||
title: '三级A',
|
title: '三级菜单子颗粒',
|
||||||
privilege: [
|
privilege: [
|
||||||
{ title: '添加', name: 'roleOneTwo-add' },
|
{ title: '添加', name: 'three-level-router-view-add' },
|
||||||
{ title: '删除', name: 'roleOneTwo-delete' }
|
{ title: '查询', name: 'three-level-router-view-query' },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
component: () => import('@/views/system/system-setting/system-config/system-config.vue')
|
component: () => import('@/views/business/three-level-router/three-level-router-view.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/three-router/level-two/level-three2',
|
path: '/three-router/level-two/level-three2',
|
||||||
name: 'RoleTwoTwo',
|
name: 'RoleTwoTwo',
|
||||||
meta: {
|
meta: {
|
||||||
title: '三级B',
|
title: '三级菜单子哈',
|
||||||
privilege: [
|
privilege: [
|
||||||
{ title: '添加', name: 'roleTwoTwo-add' },
|
{ title: '添加', name: 'roleTwoTwo-add' },
|
||||||
{ title: '删除', name: 'roleTwoTwo-delete' }
|
{ title: '删除', name: 'roleTwoTwo-delete' },
|
||||||
|
{ title: '删除', name: 'roleTwoTwo-delete1' },
|
||||||
|
{ title: '删除', name: 'roleTwoTwo-delete2' },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
component: () => import('@/views/support/monitor/sql.vue')
|
component: () => import('@/views/support/monitor/sql.vue')
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export const systemSetting = [
|
|||||||
path: '/system-setting/system-privilege',
|
path: '/system-setting/system-privilege',
|
||||||
name: 'SystemPrivilege',
|
name: 'SystemPrivilege',
|
||||||
meta: {
|
meta: {
|
||||||
title: '菜单权限',
|
title: '菜单设置',
|
||||||
privilege: [
|
privilege: [
|
||||||
{
|
{
|
||||||
title: '编辑',
|
title: '编辑',
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ivu-menu-submenu-title {
|
.ivu-menu-submenu-title {
|
||||||
padding: 10px 24px !important;
|
padding: 8px 24px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ivu-menu-submenu-has-parent-submenu {
|
.ivu-menu-submenu-has-parent-submenu {
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
// 二级菜单
|
// 二级菜单
|
||||||
.ivu-menu-item,
|
.ivu-menu-item,
|
||||||
.ivu-menu-submenu-has-parent-submenu {
|
.ivu-menu-submenu-has-parent-submenu {
|
||||||
padding: 9px 0 9px 65px !important;
|
padding: 8px 0 9px 48px !important;
|
||||||
background: url('../assets/images/slider/sub_slider_default.png') 30px 0
|
background: url('../assets/images/slider/sub_slider_default.png') 30px 0
|
||||||
no-repeat !important;
|
no-repeat !important;
|
||||||
|
|
||||||
@@ -63,9 +63,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.ivu-menu-submenu-has-parent-submenu {
|
.ivu-menu-submenu-has-parent-submenu {
|
||||||
padding-left: 41px !important;
|
padding-left: 31px !important;
|
||||||
.ivu-menu-submenu-title {
|
.ivu-menu-submenu-title {
|
||||||
padding: 0 24px !important;
|
padding: 0 17px !important;
|
||||||
}
|
}
|
||||||
&.ivu-menu-child-item-active {
|
&.ivu-menu-child-item-active {
|
||||||
background: url('../assets/images/slider/sub_slider_active.png') 30px
|
background: url('../assets/images/slider/sub_slider_active.png') 30px
|
||||||
@@ -73,12 +73,12 @@
|
|||||||
border-right: 0;
|
border-right: 0;
|
||||||
}
|
}
|
||||||
.ivu-menu {
|
.ivu-menu {
|
||||||
padding-top: 10px;
|
padding-top: 8px;
|
||||||
}
|
}
|
||||||
.ivu-menu-item,
|
.ivu-menu-item,
|
||||||
.ivu-menu-item-active:hover {
|
.ivu-menu-item-active:hover {
|
||||||
background: none !important;
|
background: none !important;
|
||||||
padding-left: 52px !important;
|
padding-left: 32px !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ export default {
|
|||||||
let g = this;
|
let g = this;
|
||||||
g.editor = new WangEditor('#editor');
|
g.editor = new WangEditor('#editor');
|
||||||
g.editor.customConfig = {
|
g.editor.customConfig = {
|
||||||
|
zIndex:1,
|
||||||
// 功能键
|
// 功能键
|
||||||
menus: [
|
menus: [
|
||||||
'head', // 标题
|
'head', // 标题
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<template>
|
||||||
|
<Card class="warp-card" dis-hover>
|
||||||
|
<Alert>
|
||||||
|
<h3>三级路由,第四级页面</h3>
|
||||||
|
<pre>
|
||||||
|
当前页面为第四级页面,页面中有两个按钮,进行权限测试
|
||||||
|
</pre>
|
||||||
|
</Alert>
|
||||||
|
<Form class="tools" inline>
|
||||||
|
<FormItem>
|
||||||
|
<Input placeholder="请输入" v-model="searchString">
|
||||||
|
<Button icon="ios-search" slot="append"></Button>
|
||||||
|
</Input>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem>
|
||||||
|
<Button @click="addContent" v-privilege="'three-level-router-view-add'" icon="md-add" type="primary">添加</Button>
|
||||||
|
</FormItem>
|
||||||
|
</Form>
|
||||||
|
<Table :columns="columns" :data="tableData" border></Table>
|
||||||
|
</Card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'ThreeLevelRouterView',
|
||||||
|
components: {},
|
||||||
|
props: {},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
sourceData: [
|
||||||
|
{ name: '张三' },
|
||||||
|
{ name: '李四' },
|
||||||
|
{ name: '王二' },
|
||||||
|
{ name: '唐三' },
|
||||||
|
{ name: '赵大' },
|
||||||
|
{ name: '李二' }
|
||||||
|
],
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
title: '名称',
|
||||||
|
key: 'name'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
tableData: [],
|
||||||
|
searchString: ''
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
addContent() {
|
||||||
|
this.$Message.success('哇哦,你点击了添加操作哦~');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style lang="less" scoped>
|
||||||
|
</style>
|
||||||
@@ -7,10 +7,10 @@
|
|||||||
<FormItem prop="loginPwd">
|
<FormItem prop="loginPwd">
|
||||||
<Input placeholder="请输入密码" type="password" v-model="formData.loginPwd"></Input>
|
<Input placeholder="请输入密码" type="password" v-model="formData.loginPwd"></Input>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem prop="code">
|
<!-- <FormItem prop="code">
|
||||||
<Input class="code-input" placeholder="请输入验证码" v-model="formData.code"></Input>
|
<Input class="code-input" placeholder="请输入验证码" v-model="formData.code"></Input>
|
||||||
<img :src="codeUrl" @click="verificationCode" class="codeUrl" v-if="codeUrl" />
|
<img :src="codeUrl" @click="verificationCode" class="codeUrl" v-if="codeUrl" />
|
||||||
</FormItem>
|
</FormItem> -->
|
||||||
<FormItem class="remember">
|
<FormItem class="remember">
|
||||||
<Checkbox>记住密码</Checkbox>
|
<Checkbox>记住密码</Checkbox>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<Button :loading="btnLoading" @click="login" long type="primary">登录</Button>
|
<Button :loading="btnLoading" @click="login" long type="primary">登录</Button>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<div class="other-way">
|
<div class="other-way">
|
||||||
<p class="inline" style="float:left">其他方式登陆(账号:demo/123456 demo1/123456)</p>
|
<p class="inline" style="float:left">其他方式登陆(账号:demo/123456)</p>
|
||||||
<div class="inline align" style="float:right">
|
<div class="inline align" style="float:right">
|
||||||
<img alt class="marginLeft" src="../../../assets/images/login-taobao.png" />
|
<img alt class="marginLeft" src="../../../assets/images/login-taobao.png" />
|
||||||
<img alt class="marginLeft" src="../../../assets/images/login-alipay.png" />
|
<img alt class="marginLeft" src="../../../assets/images/login-alipay.png" />
|
||||||
@@ -47,14 +47,15 @@ export default {
|
|||||||
default: () => {
|
default: () => {
|
||||||
return [{ required: true, message: '密码不能为空', trigger: 'blur' }];
|
return [{ required: true, message: '密码不能为空', trigger: 'blur' }];
|
||||||
}
|
}
|
||||||
},
|
|
||||||
// 验证码规则
|
|
||||||
codedRules: {
|
|
||||||
type: Array,
|
|
||||||
default: () => {
|
|
||||||
return [{ required: true, message: '验证码不能为空', trigger: 'blur' }];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// ,
|
||||||
|
// // 验证码规则
|
||||||
|
// codedRules: {
|
||||||
|
// type: Array,
|
||||||
|
// default: () => {
|
||||||
|
// return [{ required: true, message: '验证码不能为空', trigger: 'blur' }];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -63,7 +64,7 @@ export default {
|
|||||||
formData: {
|
formData: {
|
||||||
code: '',
|
code: '',
|
||||||
codeUuid: '',
|
codeUuid: '',
|
||||||
loginName: 'demo',
|
loginName: 'sa',
|
||||||
loginPwd: '123456'
|
loginPwd: '123456'
|
||||||
},
|
},
|
||||||
codeUrl: ''
|
codeUrl: ''
|
||||||
@@ -79,7 +80,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.verificationCode();
|
// this.verificationCode();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
@@ -125,9 +126,9 @@ export default {
|
|||||||
//TODO zhuoda sentry
|
//TODO zhuoda sentry
|
||||||
console.error(e);
|
console.error(e);
|
||||||
this.btnLoading = false;
|
this.btnLoading = false;
|
||||||
this.verificationCode();
|
//this.verificationCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
width: 424px;
|
width: 424px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
padding: 32px 32px;
|
padding: 32px 32px;
|
||||||
border-radius: 0 8px 8px 0;
|
border-radius: 8px;
|
||||||
.ivu-input {
|
.ivu-input {
|
||||||
border: 1px solid #E8E8EE;
|
border: 1px solid #E8E8EE;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
|||||||
@@ -365,6 +365,7 @@ export default {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
//TODO zhuoda sentry
|
//TODO zhuoda sentry
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
} finally {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -400,33 +401,52 @@ export default {
|
|||||||
},
|
},
|
||||||
// 删除任务
|
// 删除任务
|
||||||
async deleteTask(id) {
|
async deleteTask(id) {
|
||||||
let result = await taskApi.deleteTask(id);
|
this.$Spin.show();
|
||||||
this.$Message.success('删除任务成功!');
|
try{
|
||||||
this.getTaskList();
|
let result = await taskApi.deleteTask(id);
|
||||||
|
this.$Message.success('删除任务成功!');
|
||||||
|
this.getTaskList();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(e);
|
||||||
|
} finally {
|
||||||
|
this.$Spin.hide();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 操作任务
|
// 操作任务
|
||||||
async controlTask(type, id) {
|
async controlTask(type, id) {
|
||||||
this.$Spin.show();
|
this.$Spin.show();
|
||||||
switch (type) {
|
try{
|
||||||
case 'RUN':
|
switch (type) {
|
||||||
await taskApi.updateTaskRun(id);
|
case 'RUN':
|
||||||
break;
|
await taskApi.updateTaskRun(id);
|
||||||
case 'PAUSE':
|
break;
|
||||||
await taskApi.updateTaskPause(id);
|
case 'PAUSE':
|
||||||
break;
|
await taskApi.updateTaskPause(id);
|
||||||
case 'RESUME':
|
break;
|
||||||
await taskApi.updateTaskResume(id);
|
case 'RESUME':
|
||||||
break;
|
await taskApi.updateTaskResume(id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.$Message.success('操作成功');
|
||||||
|
this.getTaskList();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(e);
|
||||||
|
} finally {
|
||||||
|
this.$Spin.hide();
|
||||||
}
|
}
|
||||||
this.$Spin.hide();
|
|
||||||
this.$Message.success('操作成功');
|
|
||||||
this.getTaskList();
|
|
||||||
},
|
},
|
||||||
// 触发更新
|
// 触发更新
|
||||||
handleUpdate() {
|
handleUpdate() {
|
||||||
this.$refs['updateRef'].validate(valid => {
|
this.$refs['updateRef'].validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.updateTask();
|
this.$Spin.show();
|
||||||
|
try{
|
||||||
|
this.updateTask();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(e);
|
||||||
|
} finally {
|
||||||
|
this.$Spin.hide();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$Message.success('验证信息不通过');
|
this.$Message.success('验证信息不通过');
|
||||||
}
|
}
|
||||||
@@ -444,6 +464,7 @@ export default {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
//TODO zhuoda sentry
|
//TODO zhuoda sentry
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
} finally {
|
||||||
this.updateLoading = false;
|
this.updateLoading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -464,6 +485,7 @@ export default {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
//TODO zhuoda sentry
|
//TODO zhuoda sentry
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
} finally {
|
||||||
this.saveLoading = false;
|
this.saveLoading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -21,19 +21,19 @@
|
|||||||
<div class="level-one">
|
<div class="level-one">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:label="module.key"
|
:label="module.key"
|
||||||
@click.prevent.native="selectCheckbox(tree, moduleIndex)"
|
@click.prevent.native="selectCheckbox(module)"
|
||||||
>{{module.name}}</Checkbox>
|
>{{module.name}} </Checkbox>
|
||||||
</div>
|
</div>
|
||||||
<!--div 二级权限模块 start-->
|
<!--div 二级权限模块 start-->
|
||||||
<div
|
<div
|
||||||
:key="childrenModule.key"
|
:key="childrenModule.key"
|
||||||
class="level-teo"
|
class="level-two"
|
||||||
v-for="(childrenModule, childrenModuleIndex) in module.children"
|
v-for="(childrenModule, childrenModuleIndex) in module.children"
|
||||||
>
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:label="childrenModule.key"
|
:label="childrenModule.key"
|
||||||
@click.prevent.native="selectCheckbox(module.children,childrenModuleIndex,tree)"
|
@click.prevent.native="selectCheckbox(childrenModule)"
|
||||||
class="level-teo-label"
|
class="level-two-label"
|
||||||
>{{childrenModule.name}}</Checkbox>
|
>{{childrenModule.name}}</Checkbox>
|
||||||
<!--div 三级权限模块 start-->
|
<!--div 三级权限模块 start-->
|
||||||
<div class="level-three">
|
<div class="level-three">
|
||||||
@@ -46,23 +46,56 @@
|
|||||||
<Checkbox
|
<Checkbox
|
||||||
:key="pages.key"
|
:key="pages.key"
|
||||||
:label="pages.key"
|
:label="pages.key"
|
||||||
@click.prevent.native="selectCheckbox(childrenModule.children,pagesIndex,module.children)"
|
@click.prevent.native="selectCheckbox(pages)"
|
||||||
class="level-three-label"
|
class="level-three-label"
|
||||||
>{{pages.name}}</Checkbox>
|
>{{pages.name}}</Checkbox>
|
||||||
<div :key="pagesIndex" class="Level-four" v-if="pages.children.length > 0">
|
<!--div 四级权限模块 start-->
|
||||||
|
<div :key="pagesIndex" class="level-four" v-if="pages.children.length > 0">
|
||||||
<template v-for="(page, pageIndex) in pages.children">
|
<template v-for="(page, pageIndex) in pages.children">
|
||||||
<Checkbox
|
<!---
|
||||||
:key="page.key"
|
如果是第四级菜单的话,会继续往下一层遍历
|
||||||
:label="page.key"
|
-->
|
||||||
@click.prevent.native="selectCheckbox(pages.children, pageIndex,childrenModule.children,module.children)"
|
<template v-if="page.children && page.children.length > 0">
|
||||||
>{{page.name}}</Checkbox>
|
<!--div 五级权限模块 start-->
|
||||||
|
<div :key="page.key" class="isLevel-four">
|
||||||
|
<Checkbox
|
||||||
|
:label="page.key"
|
||||||
|
@click.prevent.native="selectCheckbox(page)"
|
||||||
|
class="level-three-label"
|
||||||
|
>{{page.name}}</Checkbox>
|
||||||
|
<!--div 五级权限的功能点 start-->
|
||||||
|
<div
|
||||||
|
class="level-four"
|
||||||
|
v-if="page.children && page.children.length > 0"
|
||||||
|
>
|
||||||
|
<template
|
||||||
|
v-for="(fiveLevelFunction, fiveLevelIndex) in page.children"
|
||||||
|
>
|
||||||
|
<Checkbox
|
||||||
|
:label="fiveLevelFunction.key"
|
||||||
|
@click.prevent.native="selectCheckbox(fiveLevelFunction)"
|
||||||
|
>{{fiveLevelFunction.name}}</Checkbox>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<!--div 五级权限的功能点 start-->
|
||||||
|
</div>
|
||||||
|
<!--div 五级权限模块 start-->
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<Checkbox
|
||||||
|
:key="page.key"
|
||||||
|
:label="page.key"
|
||||||
|
@click.prevent.native="selectCheckbox(page)"
|
||||||
|
>{{page.name}}</Checkbox>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
<!--div 四级权限模块 start-->
|
||||||
</div>
|
</div>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:key="pages.key"
|
:key="pages.key"
|
||||||
:label="pages.key"
|
:label="pages.key"
|
||||||
@click.prevent.native="selectCheckbox(childrenModule.children,pagesIndex,module.children)"
|
@click.prevent.native="selectCheckbox(pages)"
|
||||||
v-else
|
v-else
|
||||||
>{{pages.name}}</Checkbox>
|
>{{pages.name}}</Checkbox>
|
||||||
</template>
|
</template>
|
||||||
@@ -101,6 +134,8 @@ export default {
|
|||||||
return {
|
return {
|
||||||
// 权限数据
|
// 权限数据
|
||||||
tree: [],
|
tree: [],
|
||||||
|
//权限铺平的map
|
||||||
|
treeMap: null,
|
||||||
loading: false,
|
loading: false,
|
||||||
// 提交保存数据
|
// 提交保存数据
|
||||||
rolePower: {
|
rolePower: {
|
||||||
@@ -133,118 +168,95 @@ export default {
|
|||||||
activated() {},
|
activated() {},
|
||||||
methods: {
|
methods: {
|
||||||
// 勾选权限
|
// 勾选权限
|
||||||
selectCheckbox(
|
selectCheckbox(module) {
|
||||||
currentModuleList,
|
|
||||||
moduleIndex,
|
|
||||||
upOneModuleList,
|
|
||||||
upTwoModuleList
|
|
||||||
) {
|
|
||||||
let module = currentModuleList[moduleIndex];
|
|
||||||
// 是否勾选
|
// 是否勾选
|
||||||
let findIndex = this.checkedData.indexOf(module.key);
|
let findIndex = this.checkedData.indexOf(module.key);
|
||||||
if (findIndex !== -1) {
|
if (findIndex !== -1) {
|
||||||
this.spliceCheck(module);
|
//取消自己和孩子
|
||||||
// 取消的上级ID
|
this.removeCheckAndChidlrenCheck(module);
|
||||||
// 判断同级是否全部已取消勾选
|
//判断父级及其以上是否有重复
|
||||||
let currentLevelAllUnchecked = this.isUnCheckedThisLevel(
|
if (module.parentKey) {
|
||||||
currentModuleList
|
let parentPrivilege = this.treeMap.get(module.parentKey);
|
||||||
);
|
if (parentPrivilege) {
|
||||||
if (currentLevelAllUnchecked && upOneModuleList) {
|
this.unCheckedParent(parentPrivilege);
|
||||||
// 判断上级是否全部已取消勾选
|
|
||||||
let upOneLevelAllUnchecked = this.isUnCheckedThisLevel(
|
|
||||||
upOneModuleList
|
|
||||||
);
|
|
||||||
if (upOneLevelAllUnchecked && upTwoModuleList) {
|
|
||||||
// 判断上上级是否全部已取消勾选
|
|
||||||
this.isUnCheckedThisLevel(upTwoModuleList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 选中子级所有checkBox
|
// 选中子级所有checkBox
|
||||||
this.addCheck(module);
|
this.addCheckAndChildrenCheck(module);
|
||||||
// 选中上级组件
|
// 父类集合选中
|
||||||
if (module.parentKey) {
|
let parentKey = module.parentKey;
|
||||||
if (
|
while (parentKey != null) {
|
||||||
this.checkedData.findIndex(val => val === module.parentKey) === -1
|
let parentPrivilege = this.treeMap.get(parentKey);
|
||||||
) {
|
if (parentPrivilege) {
|
||||||
this.checkedData.push(module.parentKey);
|
let findIndex = this.checkedData.findIndex(val => val == parentKey);
|
||||||
}
|
if (findIndex == -1) {
|
||||||
}
|
this.checkedData.push(parentKey);
|
||||||
// 选中上上级组件
|
|
||||||
if (upOneModuleList) {
|
|
||||||
let upOneFindIndex = upOneModuleList.findIndex(
|
|
||||||
e => e.key === module.parentKey
|
|
||||||
);
|
|
||||||
let upOneFind =
|
|
||||||
upOneFindIndex === -1 ? null : upOneModuleList[upOneFindIndex];
|
|
||||||
if (
|
|
||||||
upOneFind &&
|
|
||||||
upOneFind.parentKey &&
|
|
||||||
this.checkedData.findIndex(val => val === upOneFind.parentKey) ===
|
|
||||||
-1
|
|
||||||
) {
|
|
||||||
this.checkedData.push(upOneFind.parentKey);
|
|
||||||
}
|
|
||||||
// 选中上上上级组件
|
|
||||||
if (upTwoModuleList) {
|
|
||||||
console.log(1111, upTwoModuleList, upOneFind);
|
|
||||||
let upTwoFindIndex = upTwoModuleList.findIndex(
|
|
||||||
e => e.key === upOneFind.parentKey
|
|
||||||
);
|
|
||||||
let upTwoFind =
|
|
||||||
upTwoFindIndex === -1 ? null : upTwoModuleList[upTwoFindIndex];
|
|
||||||
if (
|
|
||||||
upTwoFind &&
|
|
||||||
upTwoFind.parentKey &&
|
|
||||||
this.checkedData.findIndex(val => val === upTwoFind.parentKey) ===
|
|
||||||
-1
|
|
||||||
) {
|
|
||||||
this.checkedData.push(upTwoFind.parentKey);
|
|
||||||
}
|
}
|
||||||
|
parentKey = parentPrivilege.parentKey;
|
||||||
|
} else {
|
||||||
|
parentKey = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 判断同级是否全部已取消勾选
|
// 取消父级check
|
||||||
isUnCheckedThisLevel(moduleList) {
|
unCheckedParent(parentPrivilege) {
|
||||||
let thisLevelAllUnchecked = true;
|
if (
|
||||||
moduleList.forEach(e => {
|
parentPrivilege &&
|
||||||
let brotherIndex = this.checkedData.findIndex(val => val == e.key);
|
parentPrivilege.children &&
|
||||||
if (brotherIndex != -1) {
|
parentPrivilege.children.length > 0
|
||||||
thisLevelAllUnchecked = false;
|
) {
|
||||||
}
|
if (!this.judgeArrayExistCheck(parentPrivilege.children)) {
|
||||||
});
|
let findIndex = this.checkedData.findIndex(
|
||||||
if (thisLevelAllUnchecked) {
|
val => val == parentPrivilege.key
|
||||||
let number = this.checkedData.findIndex(
|
);
|
||||||
e => e == moduleList[0].parentKey
|
if (findIndex != -1) {
|
||||||
);
|
this.checkedData.splice(findIndex, 1);
|
||||||
if (number != -1) {
|
}
|
||||||
this.checkedData.splice(number, 1);
|
|
||||||
|
parentPrivilege = this.treeMap.get(parentPrivilege.parentKey);
|
||||||
|
this.unCheckedParent(parentPrivilege);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return thisLevelAllUnchecked;
|
|
||||||
},
|
},
|
||||||
|
//判断权限数组是否有选中的,有返回true,没有任何选中返回false
|
||||||
|
judgeArrayExistCheck(privilegeArray) {
|
||||||
|
if (!privilegeArray) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let privilege of privilegeArray) {
|
||||||
|
let findIndex = this.checkedData.findIndex(val => val == privilege.key);
|
||||||
|
if (findIndex != -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
// 选中子级所有checkBox
|
// 选中子级所有checkBox
|
||||||
addCheck(module) {
|
addCheckAndChildrenCheck(module) {
|
||||||
let findIndex = this.checkedData.findIndex(val => val == module.key);
|
let findIndex = this.checkedData.findIndex(val => val == module.key);
|
||||||
if (findIndex == -1) {
|
if (findIndex == -1) {
|
||||||
this.checkedData.push(module.key);
|
this.checkedData.push(module.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module.children) {
|
if (module.children) {
|
||||||
module.children.forEach(item => {
|
module.children.forEach(item => {
|
||||||
this.addCheck(item);
|
this.addCheckAndChildrenCheck(item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 取消自己和下级勾选
|
// 取消自己和下级勾选
|
||||||
spliceCheck(module) {
|
removeCheckAndChidlrenCheck(module) {
|
||||||
let findIndex = this.checkedData.findIndex(val => val == module.key);
|
let findIndex = this.checkedData.findIndex(val => val == module.key);
|
||||||
if (findIndex != -1) {
|
if (findIndex != -1) {
|
||||||
this.checkedData.splice(findIndex, 1);
|
this.checkedData.splice(findIndex, 1);
|
||||||
}
|
}
|
||||||
if (module.children) {
|
if (module.children) {
|
||||||
module.children.forEach(item => {
|
module.children.forEach(item => {
|
||||||
this.spliceCheck(item);
|
this.removeCheckAndChidlrenCheck(item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -272,13 +284,23 @@ export default {
|
|||||||
this.$Spin.hide();
|
this.$Spin.hide();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//将权限tree 打平成map
|
||||||
|
tree2map(tree) {
|
||||||
|
if (tree) {
|
||||||
|
for (const privilege of tree) {
|
||||||
|
this.treeMap.set(privilege.key, privilege);
|
||||||
|
this.tree2map(privilege.children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
// 获取角色可选的功能权限
|
// 获取角色可选的功能权限
|
||||||
async getListPrivilegeByRoleId(id) {
|
async getListPrivilegeByRoleId(id) {
|
||||||
try {
|
try {
|
||||||
let response = await privilegeApi.getListPrivilegeByRoleId(id);
|
let response = await privilegeApi.getListPrivilegeByRoleId(id);
|
||||||
let datas = response.data;
|
let datas = response.data;
|
||||||
this.tree = datas.privilege;
|
this.tree = datas.privilege;
|
||||||
console.log('tree', this.tree);
|
this.treeMap = new Map();
|
||||||
|
this.tree2map(this.tree);
|
||||||
this.checkedData = datas.selectedKey || [];
|
this.checkedData = datas.selectedKey || [];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@@ -360,14 +382,14 @@ export default {
|
|||||||
border-bottom: 1px solid rgb(240, 240, 240);
|
border-bottom: 1px solid rgb(240, 240, 240);
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
}
|
}
|
||||||
.level-teo {
|
.level-two {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-left: 4%;
|
margin-left: 4%;
|
||||||
position: relative;
|
position: relative;
|
||||||
border-bottom: 1px solid rgb(240, 240, 240);
|
border-bottom: 1px solid rgb(240, 240, 240);
|
||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
.level-teo-label {
|
.level-two-label {
|
||||||
width: 12%;
|
width: 12%;
|
||||||
min-width: 120px;
|
min-width: 120px;
|
||||||
}
|
}
|
||||||
@@ -381,15 +403,21 @@ export default {
|
|||||||
.isLevel-four {
|
.isLevel-four {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
border-bottom: 1px rgb(240, 240, 240) solid;
|
||||||
.level-three-label {
|
.level-three-label {
|
||||||
width: 12%;
|
width: 12%;
|
||||||
min-width: 120px;
|
min-width: 120px;
|
||||||
}
|
}
|
||||||
.Level-four {
|
.level-four {
|
||||||
padding-left: 4%;
|
padding-left: 4%;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 40px;
|
min-height: 40px;
|
||||||
border-left: 1px rgb(240, 240, 240) solid;
|
border-left: 1px rgb(240, 240, 240) solid;
|
||||||
|
.level-five {
|
||||||
|
padding-left: 4%;
|
||||||
|
min-height: 40px;
|
||||||
|
border-left: 1px rgb(240, 240, 240) solid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user