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 让你从认识到忘不了,绝对是你最想要的!
|
||||
|
||||
@@ -25,32 +26,32 @@ gitee: [https://gitee.com/lab1024/smart-admin](https://gitee.com/lab1024/smart-
|
||||
#### 演示图
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/11.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/180453_252f5e9f_5469596.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180630_ee5b4f46_5469596.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/21.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/180737_9363e283_5469596.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180802_aefb78f4_5469596.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/31.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/180821_30fc7aaf_5469596.png")"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180844_01ebd7d2_5469596.png")"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/41.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/180902_02c8d838_5469596.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180918_ff1f7ff5_5469596.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/51.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/180938_86b39645_5469596.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2020/1208/180956_69e25a9c_5469596.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/61.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/181013_791d92f0_5469596.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2020/1208/181032_9f0dbbee_5469596.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="http://img.zhuoluodada.cn/cut/1.1.0/71.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/181049_099d0169_5469596.png"/></td>
|
||||
<td><img src="https://images.gitee.com/uploads/images/2020/1208/181104_914c457a_5469596.png"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -106,22 +107,31 @@ ps:以上规范基础都是以团队出发,让团队开心快乐的写代码
|
||||
#### 联系我们
|
||||
|
||||
[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微信群(**加我微信拉你入群!**)
|
||||
|
||||
<table>
|
||||
<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>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### 捐赠
|
||||
开源不易,感谢捐赠
|
||||
>*佛祖保佑捐赠这些人写程序永无bug,工资翻倍,迎娶白富美,走上人生巅峰!*
|
||||
<table>
|
||||
<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>
|
||||
</table>
|
||||
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
1 更新密码
|
||||
EmployeeController.updatePwd
|
||||
|
||||
2 更新功能点
|
||||
PrivilegeController functionSaveOrUpdate和menuBatchSave、batchSaveFunctionList
|
||||
|
||||
3 超管默认账号
|
||||
1 超管默认账号
|
||||
sa/123456
|
||||
|
||||
4 执行脚本:
|
||||
2 执行脚本:
|
||||
先执行:src/main/resources/sql/smart-admin.sql
|
||||
再执行:src/main/resources/sql/quartz_mysql_2.3.0.sql
|
||||
|
||||
5 除dev之外文件
|
||||
3 除dev之外文件
|
||||
|
||||
6 刷新页面,获取权限是否走缓存
|
||||
4 刷新页面,获取权限是否走缓存
|
||||
LoginService.getSession
|
||||
|
||||
7 test类中去掉代码生成run
|
||||
5 test类中去掉代码生成run
|
||||
|
||||
6 前端百度统计
|
||||
@@ -109,12 +109,18 @@
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--druid -->
|
||||
<!-- druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- p6spy -->
|
||||
<dependency>
|
||||
<groupId>p6spy</groupId>
|
||||
<artifactId>p6spy</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger begin -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
@@ -126,6 +132,14 @@
|
||||
</dependency>
|
||||
<!-- swagger end -->
|
||||
|
||||
<!-- knife4j begin -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>${knife4j.version}</version>
|
||||
</dependency>
|
||||
<!-- knife4j end -->
|
||||
|
||||
<!-- guava -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
|
||||
@@ -26,6 +26,18 @@ public @interface ApiModelPropertyEnum {
|
||||
|
||||
String example() default "";
|
||||
|
||||
/**
|
||||
* 是否隐藏
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean hidden() default false;
|
||||
|
||||
/**
|
||||
* 是否必须
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean required() default true;
|
||||
|
||||
String dataType() default "";
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.lab1024.smartadmin.common.anno;
|
||||
|
||||
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.Retention;
|
||||
@@ -23,12 +25,25 @@ public @interface DataScope {
|
||||
|
||||
DataScopeTypeEnum dataScopeType() default DataScopeTypeEnum.DEFAULT;
|
||||
|
||||
DataScopeWhereInTypeEnum whereInType() default DataScopeWhereInTypeEnum.EMPLOYEE;
|
||||
|
||||
/**
|
||||
* DataScopeWhereInTypeEnum.CUSTOM_STRATEGY类型 才可使用joinSqlImplClazz属性
|
||||
* @return
|
||||
*/
|
||||
Class<? extends DataScopePowerStrategy> joinSqlImplClazz() default DataScopePowerStrategy.class;
|
||||
|
||||
/**
|
||||
*
|
||||
* 第几个where 条件 从0开始
|
||||
* @return
|
||||
*/
|
||||
int whereIndex() default 0;
|
||||
|
||||
/**
|
||||
* DataScopeWhereInTypeEnum为CUSTOM_STRATEGY类型时,此属性无效
|
||||
* @return
|
||||
*/
|
||||
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.support.file.constant.FileResponseCodeConst;
|
||||
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.privilege.constant.PrivilegeResponseCodeConst;
|
||||
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 lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PageParamDTO {
|
||||
|
||||
@NotNull(message = "每页数量不能为空")
|
||||
@ApiModelProperty(value = "每页数量(不能为空)", example = "10")
|
||||
@Max(value = 200, message = "每页最大为200")
|
||||
@Max(value = 500, message = "每页最大为500")
|
||||
protected Integer pageSize;
|
||||
|
||||
@ApiModelProperty("是否查询总条数")
|
||||
|
||||
@@ -85,6 +85,10 @@ public class ResponseDTO<T> {
|
||||
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() {
|
||||
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
|
||||
public void apply(ModelPropertyContext context) {
|
||||
Optional<ApiModelPropertyEnum> annotation = Optional.absent();
|
||||
Optional<ApiModelPropertyEnum> enumOptional = Optional.absent();
|
||||
|
||||
if (context.getAnnotatedElement().isPresent()) {
|
||||
annotation = annotation.or(findApiModePropertyAnnotation(context.getAnnotatedElement().get()));
|
||||
enumOptional = enumOptional.or(findApiModePropertyAnnotation(context.getAnnotatedElement().get()));
|
||||
}
|
||||
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()) {
|
||||
Class<? extends BaseEnum> aClass = annotation.get().value();
|
||||
String enumInfo = BaseEnum.getInfo(aClass);
|
||||
String enumDesc = annotation.get().enumDesc();
|
||||
context.getBuilder().required(annotation.transform(toIsRequired()).or(false))
|
||||
.description(enumDesc +":"+enumInfo)
|
||||
.example(annotation.transform(toExample()).orNull());
|
||||
if (enumOptional.isPresent()) {
|
||||
ApiModelPropertyEnum anEnum = enumOptional.get();
|
||||
String enumInfo = BaseEnum.getInfo(anEnum.value());
|
||||
context.getBuilder()
|
||||
.required(enumOptional.transform(toIsRequired()).or(false))
|
||||
.description(anEnum.enumDesc() + ":" + enumInfo)
|
||||
.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.ConstraintValidatorContext;
|
||||
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> {
|
||||
|
||||
/**
|
||||
* 枚举类的类对象
|
||||
* 枚举类实例集合
|
||||
*/
|
||||
private Class<? extends BaseEnum> enumClass;
|
||||
private List<Object> enumValList;
|
||||
|
||||
/**
|
||||
* 是否必须
|
||||
@@ -27,8 +29,9 @@ public class EnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
||||
@Override
|
||||
public void initialize(CheckEnum constraintAnnotation) {
|
||||
// 获取注解传入的枚举类对象
|
||||
enumClass = constraintAnnotation.enumClazz();
|
||||
required = constraintAnnotation.required();
|
||||
Class<? extends BaseEnum> enumClass = constraintAnnotation.enumClazz();
|
||||
enumValList = Stream.of(enumClass.getEnumConstants()).map(BaseEnum::getValue).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@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 不能为空
|
||||
return false;
|
||||
}
|
||||
for (Object obj : list) {
|
||||
boolean hasEnum = this.hasEnum(obj);
|
||||
if (!hasEnum) {
|
||||
// 校验是否重复
|
||||
long count = list.stream().distinct().count();
|
||||
if (count != list.size()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean hasEnum(Object value) {
|
||||
// 校验是否为合法的枚举值
|
||||
BaseEnum[] enums = enumClass.getEnumConstants();
|
||||
for (BaseEnum baseEnum : enums) {
|
||||
if (baseEnum.getValue().equals(value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return enumValList.containsAll(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SmartDruidDataSourceConfig {
|
||||
@Value("${spring.datasource.time-between-eviction-runs-millis}")
|
||||
long timeBetweenEvictionRunsMillis;
|
||||
|
||||
@Value("${spring.datasource.min-evictable-edle-time-millis}")
|
||||
@Value("${spring.datasource.min-evictable-idle-time-millis}")
|
||||
long minEvictableIdleTimeMillis;
|
||||
|
||||
@Value("${spring.datasource.filters}")
|
||||
|
||||
@@ -30,8 +30,8 @@ public class SmartKaptchaConfig {
|
||||
properties.setProperty("kaptcha.border.color", "34,114,200");
|
||||
properties.setProperty("kaptcha.image.width", "125");
|
||||
properties.setProperty("kaptcha.image.height", "45");
|
||||
properties.setProperty("kaptcha.textproducer.char.string", "ABCDEFG23456789");
|
||||
properties.setProperty("kaptcha.textproducer.char.length", "5");
|
||||
properties.setProperty("kaptcha.textproducer.char.string", "0123456789");
|
||||
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.size", "38");
|
||||
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package net.lab1024.smartadmin.config;
|
||||
|
||||
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
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.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
@@ -29,16 +24,4 @@ public class SmartMybatisPlusConfig {
|
||||
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;
|
||||
|
||||
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.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
@@ -8,6 +8,8 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import io.swagger.annotations.Api;
|
||||
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.factory.config.BeanDefinition;
|
||||
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.Profile;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.RequestHandler;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.ParameterBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.schema.ModelRef;
|
||||
import springfox.documentation.service.*;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
@@ -48,6 +53,7 @@ import java.util.Map;
|
||||
*/
|
||||
@Slf4j
|
||||
@EnableSwagger2
|
||||
@EnableKnife4j
|
||||
@Configuration
|
||||
@Profile({"dev", "sit", "pre", "prod"})
|
||||
public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDefinitionRegistryPostProcessor {
|
||||
@@ -86,9 +92,9 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
|
||||
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
|
||||
public void setEnvironment(Environment environment) {
|
||||
@@ -105,7 +111,7 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
this.groupBuild();
|
||||
for (Map.Entry<String, List<String>> entry : groupMap.entrySet()) {
|
||||
String group = entry.getKey();
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(Docket.class, this :: baseDocket);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(Docket.class, this::baseDocket);
|
||||
BeanDefinition beanDefinition = builder.getRawBeanDefinition();
|
||||
registry.registerBeanDefinition(group + "Api", beanDefinition);
|
||||
}
|
||||
@@ -134,6 +140,16 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
}
|
||||
|
||||
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();
|
||||
// controller 包路径
|
||||
@@ -148,17 +164,18 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
.build()
|
||||
.apiInfo(this.serviceApiInfo())
|
||||
.securitySchemes(securitySchemes())
|
||||
.securityContexts(securityContexts());
|
||||
.securityContexts(securityContexts())
|
||||
.globalOperationParameters(Lists.newArrayList(parameter));
|
||||
}
|
||||
|
||||
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"));
|
||||
return apiKeyList;
|
||||
}
|
||||
|
||||
private List<SecurityContext> securityContexts() {
|
||||
List<SecurityContext> securityContexts=new ArrayList<>();
|
||||
List<SecurityContext> securityContexts = new ArrayList<>();
|
||||
securityContexts.add(
|
||||
SecurityContext.builder()
|
||||
.securityReferences(defaultAuth())
|
||||
@@ -171,7 +188,7 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||
authorizationScopes[0] = authorizationScope;
|
||||
List<SecurityReference> securityReferences=new ArrayList<>();
|
||||
List<SecurityReference> securityReferences = new ArrayList<>();
|
||||
securityReferences.add(new SecurityReference("x-access-token", authorizationScopes));
|
||||
return securityReferences;
|
||||
}
|
||||
@@ -192,7 +209,11 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
||||
return false;
|
||||
};
|
||||
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() {
|
||||
@@ -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.module.business.log.LogService;
|
||||
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.SmartStringUtil;
|
||||
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.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.constant.CommonConst;
|
||||
import net.lab1024.smartadmin.module.business.login.LoginResponseCodeConst;
|
||||
import net.lab1024.smartadmin.module.business.login.LoginTokenService;
|
||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
||||
import net.lab1024.smartadmin.module.system.login.LoginResponseCodeConst;
|
||||
import net.lab1024.smartadmin.module.system.login.LoginTokenService;
|
||||
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||
import net.lab1024.smartadmin.module.system.privilege.service.PrivilegeEmployeeService;
|
||||
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
||||
import net.lab1024.smartadmin.util.SmartStringUtil;
|
||||
@@ -36,7 +36,7 @@ import java.util.List;
|
||||
@Component
|
||||
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}")
|
||||
private String accessControlAllowOrigin;
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.lab1024.smartadmin.util.SmartStringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.lab1024.smartadmin.module.business.notice;
|
||||
|
||||
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.NoticeReceiveRecordDao;
|
||||
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.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
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.PageResultDTO;
|
||||
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.NoticeReceiveRecordDao;
|
||||
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.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
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.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.entity.NoticeEntity;
|
||||
import net.lab1024.smartadmin.module.system.datascope.constant.DataScopeWhereInTypeEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -29,6 +31,7 @@ public interface NoticeDao extends BaseMapper<NoticeEntity> {
|
||||
* @param queryDTO
|
||||
* @return NoticeEntity
|
||||
*/
|
||||
@DataScope(joinSql = "n.create_user in (#employeeIds)", whereInType = DataScopeWhereInTypeEnum.EMPLOYEE)
|
||||
List<NoticeVO> queryByPage(Page page, @Param("queryDTO") NoticeQueryDTO queryDTO);
|
||||
|
||||
|
||||
@@ -38,6 +41,7 @@ public interface NoticeDao extends BaseMapper<NoticeEntity> {
|
||||
* @param employeeId
|
||||
* @return
|
||||
*/
|
||||
@DataScope(joinSql = "e.department_id in (#departmentIds)", whereInType = DataScopeWhereInTypeEnum.DEPARTMENT)
|
||||
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.UploadVO;
|
||||
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 io.swagger.annotations.Api;
|
||||
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.vo.FileVO;
|
||||
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.SmartBeanUtil;
|
||||
import net.lab1024.smartadmin.util.SmartPageUtil;
|
||||
@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -42,6 +42,4 @@ public class IdGeneratorEntity extends BaseEntity implements Serializable {
|
||||
* 备注
|
||||
*/
|
||||
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 lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
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.TaskResultEnum;
|
||||
import net.lab1024.smartadmin.module.support.quartz.domain.entity.QuartzTaskEntity;
|
||||
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.util.SmartIPUtil;
|
||||
import net.lab1024.smartadmin.util.SmartQuartzUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
@@ -35,7 +35,7 @@ public class QuartzTask extends QuartzJobBean {
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||
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();
|
||||
|
||||
Long taskId = SmartQuartzUtil.getTaskIdByJobKey(jobKey);
|
||||
@@ -47,7 +47,11 @@ public class QuartzTask extends QuartzJobBean {
|
||||
QuartzTaskLogEntity taskLogEntity = new QuartzTaskLogEntity();
|
||||
taskLogEntity.setTaskId(taskId);
|
||||
taskLogEntity.setIpAddress(SmartIPUtil.getLocalHostIP());
|
||||
try {
|
||||
taskLogEntity.setTaskName(quartzTaskEntity.getTaskName());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String paramsStr = null;
|
||||
if (params != null) {
|
||||
paramsStr = params.toString();
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -82,7 +83,7 @@ public class QuartzTaskService {
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
public ResponseDTO<String> saveOrUpdateTask(QuartzTaskDTO quartzTaskDTO) throws Exception {
|
||||
ResponseDTO baseValid = this.baseValid(quartzTaskDTO);
|
||||
if (! baseValid.isSuccess()) {
|
||||
if (!baseValid.isSuccess()) {
|
||||
return baseValid;
|
||||
}
|
||||
Long taskId = quartzTaskDTO.getId();
|
||||
@@ -103,7 +104,7 @@ public class QuartzTaskService {
|
||||
if (taskBean == null) {
|
||||
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.succ();
|
||||
@@ -129,7 +130,12 @@ public class QuartzTaskService {
|
||||
taskEntity.setTaskStatus(updateEntity.getTaskStatus());
|
||||
taskEntity.setUpdateTime(new Date());
|
||||
quartzTaskDao.updateById(taskEntity);
|
||||
if(this.checkExist(taskEntity.getId())){
|
||||
this.updateQuartzTask(scheduler, taskEntity);
|
||||
}else{
|
||||
this.createQuartzTask(scheduler,taskEntity);
|
||||
}
|
||||
|
||||
return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
@@ -164,7 +170,7 @@ public class QuartzTaskService {
|
||||
}
|
||||
quartzTaskEntity.setTaskStatus(TaskStatusEnum.PAUSE.getStatus());
|
||||
quartzTaskDao.updateById(quartzTaskEntity);
|
||||
this.pauseQuartzTask(scheduler, taskId);
|
||||
this.pauseQuartzTask(scheduler, quartzTaskEntity);
|
||||
return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
@@ -183,7 +189,7 @@ public class QuartzTaskService {
|
||||
}
|
||||
quartzTaskEntity.setTaskStatus(TaskStatusEnum.NORMAL.getStatus());
|
||||
quartzTaskDao.updateById(quartzTaskEntity);
|
||||
this.resumeQuartzTask(scheduler, taskId);
|
||||
this.resumeQuartzTask(scheduler, quartzTaskEntity);
|
||||
return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
@@ -232,6 +238,10 @@ public class QuartzTaskService {
|
||||
|
||||
jobDetail.getJobDataMap().put(QuartzConst.QUARTZ_PARAMS_KEY, taskEntity.getTaskParams());
|
||||
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);
|
||||
//如果更新之前任务是暂停状态,此时再次暂停任务
|
||||
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();
|
||||
dataMap.put(QuartzConst.QUARTZ_PARAMS_KEY, taskEntity.getTaskParams());
|
||||
JobKey jobKey = SmartQuartzUtil.getJobKey(taskEntity.getId());
|
||||
if(!scheduler.checkExists(jobKey)){
|
||||
this.createQuartzTask(scheduler,taskEntity);
|
||||
scheduler.triggerJob(jobKey, dataMap);
|
||||
return;
|
||||
}
|
||||
scheduler.triggerJob(jobKey, dataMap);
|
||||
}
|
||||
|
||||
@@ -282,11 +297,16 @@ public class QuartzTaskService {
|
||||
* 暂停任务
|
||||
*
|
||||
* @param scheduler
|
||||
* @param taskId
|
||||
* @param quartzTaskEntity
|
||||
* @throws Exception
|
||||
*/
|
||||
private void pauseQuartzTask(Scheduler scheduler, Long taskId) throws Exception {
|
||||
JobKey jobKey = SmartQuartzUtil.getJobKey(taskId);
|
||||
private void pauseQuartzTask(Scheduler scheduler, QuartzTaskEntity quartzTaskEntity) throws Exception {
|
||||
JobKey jobKey = SmartQuartzUtil.getJobKey(quartzTaskEntity.getId());
|
||||
if(!scheduler.checkExists(jobKey)){
|
||||
this.createQuartzTask(scheduler,quartzTaskEntity);
|
||||
scheduler.pauseJob(jobKey);
|
||||
return;
|
||||
}
|
||||
scheduler.pauseJob(jobKey);
|
||||
}
|
||||
|
||||
@@ -294,11 +314,15 @@ public class QuartzTaskService {
|
||||
* 恢复任务
|
||||
*
|
||||
* @param scheduler
|
||||
* @param taskId
|
||||
* @param quartzTaskEntity
|
||||
* @throws Exception
|
||||
*/
|
||||
private void resumeQuartzTask(Scheduler scheduler, Long taskId) throws Exception {
|
||||
JobKey jobKey = SmartQuartzUtil.getJobKey(taskId);
|
||||
private void resumeQuartzTask(Scheduler scheduler, QuartzTaskEntity quartzTaskEntity) throws Exception {
|
||||
JobKey jobKey = SmartQuartzUtil.getJobKey(quartzTaskEntity.getId());
|
||||
if(!scheduler.checkExists(jobKey)){
|
||||
this.createQuartzTask(scheduler,quartzTaskEntity);
|
||||
return;
|
||||
}
|
||||
scheduler.resumeJob(jobKey);
|
||||
}
|
||||
|
||||
@@ -311,6 +335,15 @@ public class QuartzTaskService {
|
||||
*/
|
||||
private void deleteQuartzTask(Scheduler scheduler, Long taskId) throws Exception {
|
||||
JobKey jobKey = SmartQuartzUtil.getJobKey(taskId);
|
||||
if(!scheduler.checkExists(jobKey)){
|
||||
return;
|
||||
}
|
||||
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;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.common.domain.ITask;
|
||||
import net.lab1024.smartadmin.util.SmartDateUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -16,11 +17,12 @@ import java.util.Date;
|
||||
* @date 2019/4/13 0013 下午 14:26
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("exampleTask")
|
||||
public class Example implements ITask {
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
||||
|
||||
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
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public enum DataScopeTypeEnum {
|
||||
public enum DataScopeTypeEnum implements BaseEnum {
|
||||
|
||||
DEFAULT(0,0,"默认类型","数据范围样例");
|
||||
|
||||
private Integer type;
|
||||
private Integer value;
|
||||
private Integer sort;
|
||||
private String name;
|
||||
private String desc;
|
||||
|
||||
DataScopeTypeEnum(Integer type,Integer sort,String name,String desc) {
|
||||
this.type = type;
|
||||
DataScopeTypeEnum(Integer value,Integer sort,String name,String desc) {
|
||||
this.value = value;
|
||||
this.sort = sort;
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.lab1024.smartadmin.module.system.datascope.constant;
|
||||
|
||||
|
||||
import net.lab1024.smartadmin.common.domain.BaseEnum;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -14,7 +16,7 @@ import java.util.Optional;
|
||||
* @date 2019/4/28 0028 下午 15:37
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public enum DataScopeViewTypeEnum {
|
||||
public enum DataScopeViewTypeEnum implements BaseEnum {
|
||||
|
||||
ME(0,0,"本人"),
|
||||
|
||||
@@ -24,32 +26,29 @@ public enum DataScopeViewTypeEnum {
|
||||
|
||||
ALL(3,15,"全部");
|
||||
|
||||
private Integer type;
|
||||
private Integer value;
|
||||
private Integer level;
|
||||
private String name;
|
||||
private String desc;
|
||||
|
||||
DataScopeViewTypeEnum(Integer type,Integer level, String name) {
|
||||
this.type = type;
|
||||
DataScopeViewTypeEnum(Integer value,Integer level, String desc) {
|
||||
this.value = value;
|
||||
this.level = level;
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@Override
|
||||
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;
|
||||
|
||||
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
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public enum DataScopeWhereInTypeEnum {
|
||||
public enum DataScopeWhereInTypeEnum implements BaseEnum {
|
||||
|
||||
EMPLOYEE(0,"以员工IN"),
|
||||
|
||||
DEPARTMENT(1,"以部门IN");
|
||||
DEPARTMENT(1,"以部门IN"),
|
||||
|
||||
private Integer type;
|
||||
CUSTOM_STRATEGY(2,"自定义策略");
|
||||
|
||||
private Integer value;
|
||||
private String desc;
|
||||
|
||||
DataScopeWhereInTypeEnum(Integer type, String desc) {
|
||||
this.type = type;
|
||||
DataScopeWhereInTypeEnum(Integer value, String desc) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.lab1024.smartadmin.module.system.datascope.domain.dto;
|
||||
|
||||
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
|
||||
public class DataScopeSqlConfigDTO {
|
||||
|
||||
private Integer dataScopeType;
|
||||
/**
|
||||
* 数据范围类型
|
||||
* {@link DataScopeTypeEnum}
|
||||
*/
|
||||
private DataScopeTypeEnum dataScopeType;
|
||||
|
||||
/**
|
||||
* join sql 具体实现类
|
||||
*/
|
||||
private Class joinSqlImplClazz;
|
||||
|
||||
private String joinSql;
|
||||
|
||||
private Integer whereIndex;
|
||||
|
||||
private Integer dataScopeWhereInType;
|
||||
/**
|
||||
* whereIn类型
|
||||
* {@link DataScopeWhereInTypeEnum}
|
||||
*/
|
||||
private DataScopeWhereInTypeEnum dataScopeWhereInType;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DataScopeService {
|
||||
DataScopeViewTypeEnum[] enums = DataScopeViewTypeEnum.class.getEnumConstants();
|
||||
DataScopeViewTypeVO dataScopeViewTypeDTO;
|
||||
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);
|
||||
}
|
||||
Comparator<DataScopeViewTypeVO> comparator = (h1, h2) -> h1.getViewTypeLevel().compareTo(h2.getViewTypeLevel());
|
||||
@@ -72,7 +72,7 @@ public class DataScopeService {
|
||||
DataScopeDTO dataScopeDTO;
|
||||
for (DataScopeTypeEnum typeEnum : enums) {
|
||||
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);
|
||||
}
|
||||
Comparator<DataScopeDTO> comparator = (h1, h2) -> h1.getDataScopeTypeSort().compareTo(h2.getDataScopeTypeSort());
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package net.lab1024.smartadmin.module.system.datascope.service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.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 org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -32,6 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @date 2019/4/29 0029 上午 10:12
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataScopeSqlConfigService {
|
||||
|
||||
@@ -67,9 +73,10 @@ public class DataScopeSqlConfigService {
|
||||
DataScope dataScopeAnnotation = method.getAnnotation(DataScope.class);
|
||||
if (dataScopeAnnotation != null) {
|
||||
DataScopeSqlConfigDTO configDTO = new DataScopeSqlConfigDTO();
|
||||
configDTO.setDataScopeType(dataScopeAnnotation.dataScopeType().getType());
|
||||
configDTO.setDataScopeType(dataScopeAnnotation.dataScopeType());
|
||||
configDTO.setJoinSql(dataScopeAnnotation.joinSql());
|
||||
configDTO.setWhereIndex(dataScopeAnnotation.whereIndex());
|
||||
configDTO.setDataScopeWhereInType(dataScopeAnnotation.whereInType());
|
||||
dataScopeMethodMap.put(method.getDeclaringClass().getSimpleName() + "." + method.getName(), configDTO);
|
||||
}
|
||||
}
|
||||
@@ -94,12 +101,26 @@ public class DataScopeSqlConfigService {
|
||||
* @return
|
||||
*/
|
||||
public String getJoinSql(DataScopeSqlConfigDTO sqlConfigDTO) {
|
||||
Integer dataScopeType = sqlConfigDTO.getDataScopeType();
|
||||
DataScopeTypeEnum dataScopeTypeEnum = sqlConfigDTO.getDataScopeType();
|
||||
String joinSql = sqlConfigDTO.getJoinSql();
|
||||
RequestTokenBO requestToken = SmartRequestTokenUtil.getThreadLocalUser();
|
||||
Long employeeId = requestToken.getRequestUserId();
|
||||
if (DataScopeWhereInTypeEnum.EMPLOYEE.getType().equals(sqlConfigDTO.getDataScopeWhereInType())) {
|
||||
List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(dataScopeType, employeeId);
|
||||
if (DataScopeWhereInTypeEnum.CUSTOM_STRATEGY == sqlConfigDTO.getDataScopeWhereInType()) {
|
||||
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)) {
|
||||
return "";
|
||||
}
|
||||
@@ -107,8 +128,8 @@ public class DataScopeSqlConfigService {
|
||||
String sql = joinSql.replaceAll(EMPLOYEE_PARAM, employeeIds);
|
||||
return sql;
|
||||
}
|
||||
if (DataScopeWhereInTypeEnum.DEPARTMENT.getType().equals(sqlConfigDTO.getDataScopeWhereInType())) {
|
||||
List<Long> canViewDepartmentIds = dataScopeViewService.getCanViewDepartmentId(dataScopeType, employeeId);
|
||||
if (DataScopeWhereInTypeEnum.DEPARTMENT == sqlConfigDTO.getDataScopeWhereInType()) {
|
||||
List<Long> canViewDepartmentIds = dataScopeViewService.getCanViewDepartmentId(dataScopeTypeEnum, employeeId);
|
||||
if (CollectionUtils.isEmpty(canViewDepartmentIds)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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.constant.DataScopeTypeEnum;
|
||||
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.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.privilege.service.PrivilegeEmployeeService;
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -51,33 +53,40 @@ public class DataScopeViewService {
|
||||
/**
|
||||
* 获取某人可以查看的所有人员信息
|
||||
*
|
||||
* @param dataScopeType
|
||||
* @param dataScopeTypeEnum
|
||||
* @param employeeId
|
||||
* @return
|
||||
*/
|
||||
public List<Long> getCanViewEmployeeId(Integer dataScopeType, Long employeeId) {
|
||||
Integer viewType = this.getEmployeeDataScopeViewType(dataScopeType, employeeId);
|
||||
if (DataScopeViewTypeEnum.ME.getType().equals(viewType)) {
|
||||
public List<Long> getCanViewEmployeeId(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
|
||||
DataScopeViewTypeEnum viewType = this.getEmployeeDataScopeViewType(dataScopeTypeEnum, employeeId);
|
||||
if (DataScopeViewTypeEnum.ME == viewType) {
|
||||
return this.getMeEmployeeIdList(employeeId);
|
||||
}
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT.getType().equals(viewType)) {
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT == viewType) {
|
||||
return this.getDepartmentEmployeeIdList(employeeId);
|
||||
}
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB.getType().equals(viewType)) {
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
|
||||
return this.getDepartmentAndSubEmployeeIdList(employeeId);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT.getType().equals(viewType)) {
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT == viewType) {
|
||||
return this.getMeDepartmentIdList(employeeId);
|
||||
}
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB.getType().equals(viewType)) {
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
|
||||
return this.getDepartmentAndSubIdList(employeeId);
|
||||
}
|
||||
return Lists.newArrayList();
|
||||
@@ -101,28 +110,28 @@ public class DataScopeViewService {
|
||||
* @param employeeId
|
||||
* @return
|
||||
*/
|
||||
private Integer getEmployeeDataScopeViewType(Integer dataScopeType, Long employeeId) {
|
||||
public DataScopeViewTypeEnum getEmployeeDataScopeViewType(DataScopeTypeEnum dataScopeTypeEnum, Long employeeId) {
|
||||
if (employeeId == null) {
|
||||
return DataScopeViewTypeEnum.ME.getType();
|
||||
return DataScopeViewTypeEnum.ME;
|
||||
}
|
||||
|
||||
if (privilegeEmployeeService.isSuperman(employeeId)) {
|
||||
return DataScopeViewTypeEnum.ALL.getType();
|
||||
return DataScopeViewTypeEnum.ALL;
|
||||
}
|
||||
List<Long> roleIdList = roleEmployeeDao.selectRoleIdByEmployeeId(employeeId);
|
||||
//未设置角色 默认本人
|
||||
if (CollectionUtils.isEmpty(roleIdList)) {
|
||||
return DataScopeViewTypeEnum.ME.getType();
|
||||
return DataScopeViewTypeEnum.ME;
|
||||
}
|
||||
//未设置角色数据范围 默认本人
|
||||
List<DataScopeRoleEntity> dataScopeRoleList = dataScopeRoleDao.listByRoleIdList(roleIdList);
|
||||
if (CollectionUtils.isEmpty(dataScopeRoleList)) {
|
||||
return DataScopeViewTypeEnum.ME.getType();
|
||||
return DataScopeViewTypeEnum.ME;
|
||||
}
|
||||
Map<Integer, List<DataScopeRoleEntity>> listMap = dataScopeRoleList.stream().collect(Collectors.groupingBy(DataScopeRoleEntity :: getDataScopeType));
|
||||
List<DataScopeRoleEntity> viewLevelList = listMap.get(dataScopeType);
|
||||
DataScopeRoleEntity maxLevel = viewLevelList.stream().max(Comparator.comparing(e -> DataScopeViewTypeEnum.valueOf(e.getViewType()).getLevel())).get();
|
||||
return maxLevel.getViewType();
|
||||
Map<Integer, List<DataScopeRoleEntity>> listMap = dataScopeRoleList.stream().collect(Collectors.groupingBy(DataScopeRoleEntity::getDataScopeType));
|
||||
List<DataScopeRoleEntity> viewLevelList = listMap.get(dataScopeTypeEnum.getValue());
|
||||
DataScopeRoleEntity maxLevel = viewLevelList.stream().max(Comparator.comparing(e -> SmartBaseEnumUtil.getEnumByValue(e.getViewType(), DataScopeViewTypeEnum.class).getLevel())).get();
|
||||
return SmartBaseEnumUtil.getEnumByValue(maxLevel.getViewType(), DataScopeViewTypeEnum.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,6 +143,7 @@ public class DataScopeViewService {
|
||||
private List<Long> getMeEmployeeIdList(Long employeeId) {
|
||||
return Lists.newArrayList(employeeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本部门相关 可查看员工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 = "删除部门")
|
||||
@PostMapping("/department/delete/{departmentId}")
|
||||
public ResponseDTO<String> delDepartment(@PathVariable("departmentId") Long departmentId) {
|
||||
return departmentService.delDepartment(departmentId);
|
||||
@PostMapping("/department/delete/{deptId}")
|
||||
public ResponseDTO<String> delDepartment(@PathVariable Long deptId) {
|
||||
return departmentService.delDepartment(deptId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取部门信息", notes = "获取部门")
|
||||
@GetMapping("/department/query/{departmentId}")
|
||||
public ResponseDTO<DepartmentVO> getDepartment(@PathVariable("departmentId") Long departmentId) {
|
||||
return departmentService.getDepartmentById(departmentId);
|
||||
@GetMapping("/department/query/{deptId}")
|
||||
public ResponseDTO<DepartmentVO> getDepartment(@PathVariable Long deptId) {
|
||||
return departmentService.getDepartmentById(deptId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询部门列表", notes = "查询部门列表")
|
||||
@@ -78,21 +78,21 @@ public class DepartmentController {
|
||||
|
||||
|
||||
@ApiOperation(value = "上下移动")
|
||||
@GetMapping("/department/upOrDown/{departmentId}/{swapId}")
|
||||
public ResponseDTO<String> upOrDown(@PathVariable("departmentId") Long departmentId,@PathVariable("swapId") Long swapId) {
|
||||
return departmentService.upOrDown(departmentId,swapId);
|
||||
@GetMapping("/department/upOrDown/{deptId}/{swapId}")
|
||||
public ResponseDTO<String> upOrDown(@PathVariable Long deptId, @PathVariable Long swapId) {
|
||||
return departmentService.upOrDown(deptId, swapId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "升级")
|
||||
@GetMapping("/department/upgrade/{departmentId}")
|
||||
public ResponseDTO<String> upgrade(@PathVariable("departmentId") Long departmentId) {
|
||||
return departmentService.upgrade(departmentId);
|
||||
@GetMapping("/department/upgrade/{deptId}")
|
||||
public ResponseDTO<String> upgrade(@PathVariable Long deptId) {
|
||||
return departmentService.upgrade(deptId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "降级")
|
||||
@GetMapping("/department/downgrade/{departmentId}/{preId}")
|
||||
public ResponseDTO<String> downgrade(@PathVariable("departmentId") Long departmentId,@PathVariable("preId") Long preId) {
|
||||
return departmentService.downgrade(departmentId,preId);
|
||||
@GetMapping("/department/downgrade/{deptId}/{preId}")
|
||||
public ResponseDTO<String> downgrade(@PathVariable Long deptId, @PathVariable Long preId) {
|
||||
return departmentService.downgrade(deptId, preId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,14 +19,13 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface DepartmentDao extends BaseMapper<DepartmentEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门id,查询此部门子部门的数量
|
||||
* 根据部门id,查询此部门直接子部门的数量
|
||||
*
|
||||
* @param departmentId
|
||||
* @param deptId
|
||||
* @return int 子部门的数量
|
||||
*/
|
||||
Integer countSubDepartment(@Param("departmentId") Long departmentId);
|
||||
Integer countSubDepartment(@Param("deptId") Long deptId);
|
||||
|
||||
/**
|
||||
* 获取全部部门列表
|
||||
|
||||
@@ -14,7 +14,7 @@ public class DepartmentResponseCodeConst extends ResponseCodeConst {
|
||||
/**
|
||||
* 部门不存在 1001
|
||||
*/
|
||||
public static final DepartmentResponseCodeConst DEPT_NOT_EXISTS = new DepartmentResponseCodeConst(2001, "部门不存在!");
|
||||
public static final DepartmentResponseCodeConst DEPT_NOT_EXISTS = new DepartmentResponseCodeConst(2001, "部门不存在");
|
||||
|
||||
/**
|
||||
* 当前部门有子级部门 不能删除 10003
|
||||
|
||||
@@ -64,7 +64,7 @@ public class DepartmentService {
|
||||
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();
|
||||
employeeList.forEach(employeeDTO -> {
|
||||
@@ -103,7 +103,7 @@ public class DepartmentService {
|
||||
List<DepartmentVO> filterResult = new ArrayList<>();
|
||||
getParentDepartment(departmentVOList, parentId, filterResult);
|
||||
for (DepartmentVO dto : filterResult) {
|
||||
if (! departmentMap.containsKey(dto.getId())) {
|
||||
if (!departmentMap.containsKey(dto.getId())) {
|
||||
departmentMap.put(dto.getId(), dto);
|
||||
}
|
||||
}
|
||||
@@ -165,23 +165,27 @@ public class DepartmentService {
|
||||
* 1、需要判断当前部门是否有子部门,有子部门则不允许删除
|
||||
* 2、需要判断当前部门是否有员工,有员工则不能删除
|
||||
*
|
||||
* @param departmentId
|
||||
* @return AjaxResult<String>
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
@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) {
|
||||
return ResponseDTO.wrap(DepartmentResponseCodeConst.CANNOT_DEL_DEPARTMENT_WITH_CHILD);
|
||||
}
|
||||
|
||||
// 是否有员工
|
||||
int employeeNum = employeeDao.countByDepartmentId(departmentId);
|
||||
// 是否有未删除员工
|
||||
int employeeNum = employeeDao.countByDepartmentId(deptId, false);
|
||||
if (employeeNum > 0) {
|
||||
return ResponseDTO.wrap(DepartmentResponseCodeConst.CANNOT_DEL_DEPARTMENT_WITH_EMPLOYEE);
|
||||
}
|
||||
departmentDao.deleteById(departmentId);
|
||||
departmentDao.deleteById(deptId);
|
||||
return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
@@ -278,5 +282,4 @@ public class DepartmentService {
|
||||
departmentDao.updateById(departmentEntity);
|
||||
return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.module.system.employee.domain.dto.*;
|
||||
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 io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -86,7 +86,6 @@ public class EmployeeController {
|
||||
public ResponseDTO<String> updatePwd(@Valid @RequestBody EmployeeUpdatePwdDTO updatePwdDTO) {
|
||||
RequestTokenBO requestToken = SmartRequestTokenUtil.getRequestUser();
|
||||
return employeeService.updatePwd(updatePwdDTO, requestToken);
|
||||
// return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过部门id获取当前部门的人员&没有部门的人", notes = "@author yandanyang")
|
||||
|
||||
@@ -34,6 +34,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
|
||||
/**
|
||||
* 不带分页查询员工列表
|
||||
*
|
||||
* @param queryDTO
|
||||
* @return
|
||||
*/
|
||||
@@ -84,10 +85,11 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
/**
|
||||
* 获取某个部门员工数
|
||||
*
|
||||
* @param departmentId
|
||||
* @param depId
|
||||
* @param deleteFlag 可以null
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* 获取某个部门的员工
|
||||
*
|
||||
@@ -128,6 +131,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
|
||||
/**
|
||||
* 查询所有员工
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<EmployeeVO> selectAll();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.lab1024.smartadmin.module.system.employee;
|
||||
|
||||
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.domain.PageResultDTO;
|
||||
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.entity.EmployeeEntity;
|
||||
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.PositionService;
|
||||
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.SmartPageUtil;
|
||||
import net.lab1024.smartadmin.util.SmartVerificationUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.map.HashedMap;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -74,7 +74,7 @@ public class EmployeeService {
|
||||
*/
|
||||
private static final ConcurrentHashMap<Long, EmployeeBO> employeeCache = new ConcurrentHashMap<>();
|
||||
|
||||
public List<EmployeeVO> getAllEmployee(){
|
||||
public List<EmployeeVO> getAllEmployee() {
|
||||
return employeeDao.selectAll();
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public class EmployeeService {
|
||||
|
||||
for (EmployeeDTO employeeDTO : employeeList) {
|
||||
List<PositionRelationResultDTO> relationResultDTOList = employeePositionMap.get(employeeDTO.getId());
|
||||
if(relationResultDTOList != null){
|
||||
if (relationResultDTOList != null) {
|
||||
employeeDTO.setPositionRelationList(relationResultDTOList);
|
||||
employeeDTO.setPositionName(relationResultDTOList.stream().map(PositionRelationResultDTO::getPositionName).collect(Collectors.joining(",")));
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class EmployeeService {
|
||||
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) {
|
||||
return ResponseDTO.wrap(EmployeeResponseCodeConst.PHONE_EXISTS);
|
||||
}
|
||||
|
||||
@@ -22,11 +22,9 @@ public class EmployeeLoginFormDTO {
|
||||
@ApiModelProperty(example = "123456")
|
||||
private String loginPwd;
|
||||
|
||||
@NotNull(message = "验证码id不能为空")
|
||||
@ApiModelProperty(value = "验证码uuid")
|
||||
private String codeUuid;
|
||||
|
||||
@NotNull(message = "验证码不能为空")
|
||||
@ApiModelProperty(value = "验证码")
|
||||
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.NoValidPrivilege;
|
||||
@@ -6,9 +6,9 @@ import net.lab1024.smartadmin.common.anno.OperateLog;
|
||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.module.system.employee.domain.dto.EmployeeLoginFormDTO;
|
||||
import net.lab1024.smartadmin.module.business.login.domain.KaptchaVO;
|
||||
import net.lab1024.smartadmin.module.business.login.domain.LoginDetailVO;
|
||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
||||
import net.lab1024.smartadmin.module.system.login.domain.KaptchaVO;
|
||||
import net.lab1024.smartadmin.module.system.login.domain.LoginDetailVO;
|
||||
import net.lab1024.smartadmin.module.system.login.domain.RequestTokenBO;
|
||||
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -42,7 +42,6 @@ public class LoginController {
|
||||
return loginService.login(loginForm, request);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/session/get")
|
||||
@ApiOperation(value = "获取session", notes = "获取session")
|
||||
@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;
|
||||
|
||||
@@ -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.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.business.log.LogService;
|
||||
import net.lab1024.smartadmin.module.business.log.userloginlog.domain.UserLoginLogEntity;
|
||||
import net.lab1024.smartadmin.module.business.login.domain.KaptchaVO;
|
||||
import net.lab1024.smartadmin.module.business.login.domain.LoginDetailVO;
|
||||
import net.lab1024.smartadmin.module.business.login.domain.LoginPrivilegeDTO;
|
||||
import net.lab1024.smartadmin.module.business.login.domain.RequestTokenBO;
|
||||
import net.lab1024.smartadmin.module.system.login.domain.KaptchaVO;
|
||||
import net.lab1024.smartadmin.module.system.login.domain.LoginDetailVO;
|
||||
import net.lab1024.smartadmin.module.system.login.domain.LoginPrivilegeDTO;
|
||||
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.service.PrivilegeEmployeeService;
|
||||
import net.lab1024.smartadmin.util.SmartBeanUtil;
|
||||
@@ -83,15 +83,15 @@ public class LoginService {
|
||||
* @return 登录用户基本信息
|
||||
*/
|
||||
public ResponseDTO<LoginDetailVO> login(@Valid EmployeeLoginFormDTO loginForm, HttpServletRequest request) {
|
||||
String redisVerificationCode = redisValueOperations.get(loginForm.getCodeUuid());
|
||||
//增加删除已使用的验证码方式 频繁登录
|
||||
redisValueOperations.getOperations().delete(loginForm.getCodeUuid());
|
||||
if (StringUtils.isEmpty(redisVerificationCode)) {
|
||||
return ResponseDTO.wrap(EmployeeResponseCodeConst.VERIFICATION_CODE_INVALID);
|
||||
}
|
||||
if (!redisVerificationCode.equalsIgnoreCase(loginForm.getCode())) {
|
||||
return ResponseDTO.wrap(EmployeeResponseCodeConst.VERIFICATION_CODE_INVALID);
|
||||
}
|
||||
// String redisVerificationCode = redisValueOperations.get(loginForm.getCodeUuid());
|
||||
// //增加删除已使用的验证码方式 频繁登录
|
||||
// redisValueOperations.getOperations().delete(loginForm.getCodeUuid());
|
||||
// if (StringUtils.isEmpty(redisVerificationCode)) {
|
||||
// return ResponseDTO.wrap(EmployeeResponseCodeConst.VERIFICATION_CODE_INVALID);
|
||||
// }
|
||||
// if (!redisVerificationCode.equalsIgnoreCase(loginForm.getCode())) {
|
||||
// return ResponseDTO.wrap(EmployeeResponseCodeConst.VERIFICATION_CODE_INVALID);
|
||||
// }
|
||||
String loginPwd = SmartDigestUtil.encryptPassword(CommonConst.Password.SALT_FORMAT, loginForm.getLoginPwd());
|
||||
EmployeeDTO employeeDTO = employeeDao.login(loginForm.getLoginName(), loginPwd);
|
||||
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.module.system.employee.EmployeeService;
|
||||
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.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.Jwts;
|
||||
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;
|
||||
|
||||
@@ -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 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 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.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 lombok.Getter;
|
||||
@@ -42,7 +42,6 @@ public class PrivilegeController {
|
||||
@PostMapping("/privilege/menu/batchSaveMenu")
|
||||
public ResponseDTO<String> menuBatchSave(@Valid @RequestBody ValidateList<PrivilegeMenuDTO> menuList) {
|
||||
return privilegeService.menuBatchSave(menuList);
|
||||
// return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,14 +56,12 @@ public class PrivilegeController {
|
||||
@PostMapping("/privilege/function/saveOrUpdate")
|
||||
public ResponseDTO<String> functionSaveOrUpdate(@Valid @RequestBody PrivilegeFunctionDTO privilegeFunctionDTO) {
|
||||
return privilegeService.functionSaveOrUpdate(privilegeFunctionDTO);
|
||||
// return ResponseDTO.succ();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量保存功能点")
|
||||
@PostMapping("/privilege/function/batchSave")
|
||||
public ResponseDTO<String> batchSaveFunctionList(@Valid @RequestBody ValidateList<PrivilegeFunctionDTO> 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);
|
||||
|
||||
/**
|
||||
* 根据父节点key查询
|
||||
* @param keyList
|
||||
* @return
|
||||
*/
|
||||
List<PrivilegeEntity> selectByKeyList(@Param("keyList") List<String> keyList);
|
||||
|
||||
/**
|
||||
* 根据权限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.exception.SmartBusinessException;
|
||||
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.dao.PrivilegeDao;
|
||||
import net.lab1024.smartadmin.module.system.privilege.domain.entity.PrivilegeEntity;
|
||||
|
||||
@@ -216,10 +216,18 @@ public class PrivilegeService {
|
||||
return ResponseDTO.wrap(PrivilegeResponseCodeConst.MENU_NOT_EXIST);
|
||||
}
|
||||
|
||||
//数据库中存在的数据
|
||||
List<PrivilegeEntity> existFunctionList = privilegeDao.selectByParentKey(menuKey);
|
||||
Map<String, PrivilegeEntity> privilegeEntityMap = existFunctionList.stream().collect(Collectors.toMap(PrivilegeEntity::getKey, e -> e));
|
||||
List<String> functionKeyList = functionList.stream().map(PrivilegeFunctionDTO::getFunctionKey).collect(Collectors.toList());
|
||||
|
||||
//数据库中存在的数据
|
||||
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()) {
|
||||
List<PrivilegeEntity> privilegeEntityList = functionList.stream().map(e -> function2Privilege(e)).collect(Collectors.toList());
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package net.lab1024.smartadmin.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
@@ -34,12 +35,15 @@ public class SmartBigDecimalUtil {
|
||||
public static BigDecimal add(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.add(num2), PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.multiply(num2), PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.subtract(num2), PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
||||
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) {
|
||||
return setScale(num1.add(num2), SIX_PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.multiply(num2), SIX_PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.subtract(num2), SIX_PRICE_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
||||
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) {
|
||||
return setScale(num1.add(num2), WEIGHT_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal multiply(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.multiply(num2), WEIGHT_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
|
||||
return setScale(num1.subtract(num2), WEIGHT_DECIMAL_POINT);
|
||||
}
|
||||
|
||||
public static BigDecimal divide(BigDecimal num1, BigDecimal num2) {
|
||||
return num1.divide(num2, WEIGHT_DECIMAL_POINT, RoundingMode.HALF_UP);
|
||||
}
|
||||
@@ -176,7 +186,7 @@ public class SmartBigDecimalUtil {
|
||||
* @return boolean
|
||||
*/
|
||||
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) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
if (num2.equals(Integer.valueOf(0))) {
|
||||
if (num2.equals(0)) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal bigDecimalNum1 = new BigDecimal(num1);
|
||||
@@ -272,7 +282,7 @@ public class SmartBigDecimalUtil {
|
||||
* @return String
|
||||
*/
|
||||
public static Boolean isNotEmpty(BigDecimal num) {
|
||||
return ! isEmpty(num);
|
||||
return !isEmpty(num);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,8 +293,7 @@ public class SmartBigDecimalUtil {
|
||||
* @return
|
||||
*/
|
||||
public static BigDecimal convertTenThousand(BigDecimal num, int point) {
|
||||
BigDecimal decimal = num.divide(new BigDecimal(10000), point, RoundingMode.HALF_UP);
|
||||
return decimal;
|
||||
return num.divide(new BigDecimal(10000), point, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,4 +309,25 @@ public class SmartBigDecimalUtil {
|
||||
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<>();
|
||||
result.setPageNum(page.getCurrent());
|
||||
result.setPageSize(page.getSize());
|
||||
result.setTotal(Long.valueOf(page.getTotal()));
|
||||
result.setTotal(page.getTotal());
|
||||
result.setPages(page.getPages());
|
||||
result.setList(page.getRecords());
|
||||
return result;
|
||||
@@ -33,7 +33,7 @@ public class SmartPageUtil {
|
||||
|
||||
List<OrderItemDTO> orders = baseDTO.getOrders();
|
||||
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.setCurrent(baseDTO.getPageNum());
|
||||
@@ -90,7 +90,7 @@ public class SmartPageUtil {
|
||||
PageResultDTO pageResultDTO = new PageResultDTO();
|
||||
pageResultDTO.setPageNum(page.getCurrent());
|
||||
pageResultDTO.setPageSize(page.getSize());
|
||||
pageResultDTO.setTotal(Long.valueOf(page.getTotal()));
|
||||
pageResultDTO.setTotal(page.getTotal());
|
||||
pageResultDTO.setPages(page.getPages());
|
||||
return pageResultDTO;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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.RequestContextHolder;
|
||||
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/
|
||||
|
||||
######################### 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.password=Root.123
|
||||
spring.datasource.initial-size=2
|
||||
@@ -31,8 +31,8 @@ spring.datasource.min-idle=1
|
||||
spring.datasource.max-active=10
|
||||
spring.datasource.max-wait=60000
|
||||
spring.datasource.time-between-eviction-runs-millis=60000
|
||||
spring.datasource.min-evictable-edle-time-millis=300000
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.min-evictable-idle-time-millis=300000
|
||||
spring.datasource.driver-class-name=com.p6spy.engine.spy.P6SpyDriver
|
||||
spring.datasource.filters=stat
|
||||
spring.datasource.druid.username=druid
|
||||
spring.datasource.druid.password=123456
|
||||
@@ -44,16 +44,16 @@ spring.redis.host=127.0.0.1
|
||||
spring.redis.port=6379
|
||||
spring.redis.timeout=10000ms
|
||||
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.max-idle=10
|
||||
spring.redis.lettuce.pool.max-wait=30000ms
|
||||
|
||||
########################## rest http pool #########################
|
||||
#\u6700\u5927\u8FDE\u63A5\u6570
|
||||
http.pool.max-total=100
|
||||
http.pool.max-total=10
|
||||
#\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
|
||||
http.pool.socket-timeout=8000
|
||||
#\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.thread-count=1
|
||||
smart-reload.time-interval=5
|
||||
smart-reload.time-interval=300
|
||||
|
||||
######################### cros #########################
|
||||
access-control-allow-origin=*
|
||||
|
||||
######################### heart beat #########################
|
||||
heart-beat.delayHandlerTime=60000
|
||||
heart-beat.intervalTime=180000
|
||||
heart-beat.intervalTime=300000
|
||||
|
||||
######################### quartz #############################
|
||||
#\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.tablePrefix=QRTZ_
|
||||
spring.quartz.properties.org.quartz.jobStore.isClustered=true
|
||||
#\u8C03\u5EA6\u5B9E\u4F8B\u5931\u6548\u7684\u68C0\u67E5\u65F6\u95F4\u95F4\u9694
|
||||
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=10000
|
||||
#\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=60000
|
||||
spring.quartz.properties.org.quartz.jobStore.useProperties=false
|
||||
#\u8C03\u5EA6\u7EBF\u7A0B
|
||||
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
|
||||
@@ -119,3 +119,5 @@ spring.quartz.job-store-type=jdbc
|
||||
#ALWAYS,EMBEDDED,NEVER
|
||||
spring.quartz.jdbc.initialize-schema=NEVER
|
||||
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
|
||||
</sql>
|
||||
|
||||
<select id="countSubDepartment" resultType="integer">
|
||||
SELECT
|
||||
count(1)
|
||||
FROM
|
||||
t_department
|
||||
WHERE
|
||||
parent_id = #{departmentId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="DepartmentVO">
|
||||
SELECT
|
||||
<include refid="baseSql"></include>,
|
||||
@@ -50,5 +41,14 @@
|
||||
</select>
|
||||
|
||||
|
||||
<select id="countSubDepartment" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
count(1)
|
||||
FROM
|
||||
t_department
|
||||
WHERE
|
||||
parent_id = #{deptId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -106,7 +106,7 @@
|
||||
FROM
|
||||
t_employee e
|
||||
WHERE
|
||||
e.login_name = #{phone} and e.is_disabled = #{isDisabled}
|
||||
e.phone = #{phone} and e.is_disabled = #{isDisabled}
|
||||
</select>
|
||||
|
||||
|
||||
@@ -124,7 +124,10 @@
|
||||
FROM
|
||||
t_employee e
|
||||
WHERE
|
||||
e.department_id = #{departmentId}
|
||||
e.department_id = #{depId}
|
||||
<if test="deleteFlag != null">
|
||||
AND e.is_delete = #{deleteFlag}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
@@ -146,7 +149,7 @@
|
||||
t_employee e
|
||||
WHERE
|
||||
e.department_id IN
|
||||
<foreach collection="departmentIds" item="item" separator=",">
|
||||
<foreach collection="departmentIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
order by e.create_time desc
|
||||
@@ -158,7 +161,7 @@
|
||||
FROM
|
||||
t_employee e
|
||||
where e.id IN
|
||||
<foreach collection="ids" item="item" separator=",">
|
||||
<foreach collection="ids" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
order by e.create_time desc
|
||||
|
||||
@@ -99,6 +99,19 @@
|
||||
p.key = #{key}
|
||||
</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
|
||||
<include refid="baseSql"></include>,
|
||||
|
||||
@@ -31,7 +31,7 @@ spring.datasource.min-idle=1
|
||||
spring.datasource.max-active=10
|
||||
spring.datasource.max-wait=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.filters=stat
|
||||
spring.datasource.druid.username=druid
|
||||
@@ -44,16 +44,16 @@ spring.redis.host=127.0.0.1
|
||||
spring.redis.port=6379
|
||||
spring.redis.timeout=10000ms
|
||||
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.max-idle=10
|
||||
spring.redis.lettuce.pool.max-wait=30000ms
|
||||
|
||||
########################## rest http pool #########################
|
||||
#\u6700\u5927\u8FDE\u63A5\u6570
|
||||
http.pool.max-total=100
|
||||
http.pool.max-total=10
|
||||
#\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
|
||||
http.pool.socket-timeout=8000
|
||||
#\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.thread-count=1
|
||||
smart-reload.time-interval=5
|
||||
smart-reload.time-interval=30
|
||||
|
||||
######################### cros #########################
|
||||
access-control-allow-origin=*
|
||||
|
||||
######################### heart beat #########################
|
||||
heart-beat.delayHandlerTime=60000
|
||||
heart-beat.intervalTime=180000
|
||||
heart-beat.intervalTime=60000
|
||||
|
||||
######################### quartz #############################
|
||||
#\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.initial-size=2
|
||||
spring.datasource.min-idle=1
|
||||
spring.datasource.max-active=10
|
||||
spring.datasource.max-active=100
|
||||
spring.datasource.max-wait=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.filters=stat
|
||||
spring.datasource.druid.username=druid
|
||||
spring.datasource.druid.password=Gq123456
|
||||
spring.datasource.druid.password=druid
|
||||
spring.datasource.druid.login.enabled=false
|
||||
|
||||
######################### redis #######################################
|
||||
@@ -44,16 +44,16 @@ spring.redis.host=127.0.0.1
|
||||
spring.redis.port=6379
|
||||
spring.redis.timeout=10000ms
|
||||
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.max-idle=10
|
||||
spring.redis.lettuce.pool.max-wait=30000ms
|
||||
|
||||
########################## rest http pool #########################
|
||||
#\u6700\u5927\u8FDE\u63A5\u6570
|
||||
http.pool.max-total=100
|
||||
http.pool.max-total=10
|
||||
#\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
|
||||
http.pool.socket-timeout=8000
|
||||
#\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.thread-count=2
|
||||
smart-reload.time-interval=20
|
||||
smart-reload.time-interval=30
|
||||
######################### cros #########################
|
||||
access-control-allow-origin=preview.smartadmin.1024lab.net
|
||||
######################### heart beat #########################
|
||||
heart-beat.delayHandlerTime=60000
|
||||
heart-beat.intervalTime=180000
|
||||
heart-beat.intervalTime=60000
|
||||
|
||||
######################### quartz #############################
|
||||
#\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/
|
||||
|
||||
######################### 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.password=root
|
||||
spring.datasource.initial-size=2
|
||||
@@ -31,8 +31,8 @@ spring.datasource.min-idle=1
|
||||
spring.datasource.max-active=10
|
||||
spring.datasource.max-wait=60000
|
||||
spring.datasource.time-between-eviction-runs-millis=60000
|
||||
spring.datasource.min-evictable-edle-time-millis=300000
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.min-evictable-idle-time-millis=300000
|
||||
spring.datasource.driver-class-name=com.p6spy.engine.spy.P6SpyDriver
|
||||
spring.datasource.filters=stat
|
||||
spring.datasource.druid.username=druid
|
||||
spring.datasource.druid.password=123456
|
||||
@@ -44,16 +44,16 @@ spring.redis.host=127.0.0.1
|
||||
spring.redis.port=6379
|
||||
spring.redis.timeout=10000ms
|
||||
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.max-idle=10
|
||||
spring.redis.lettuce.pool.max-wait=30000ms
|
||||
|
||||
########################## rest http pool #########################
|
||||
#\u6700\u5927\u8FDE\u63A5\u6570
|
||||
http.pool.max-total=100
|
||||
http.pool.max-total=10
|
||||
#\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
|
||||
http.pool.socket-timeout=8000
|
||||
#\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.thread-count=1
|
||||
smart-reload.time-interval=5
|
||||
smart-reload.time-interval=120
|
||||
|
||||
######################### cros #########################
|
||||
access-control-allow-origin=*
|
||||
|
||||
######################### heart beat #########################
|
||||
heart-beat.delayHandlerTime=60000
|
||||
heart-beat.intervalTime=180000
|
||||
heart-beat.intervalTime=300000
|
||||
|
||||
######################### quartz #############################
|
||||
#\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>
|
||||
import { ${moduleVar}Api } from '@/api/${webModuleName}';
|
||||
export default {
|
||||
name: 'CodeReviewListForm',
|
||||
name: '${moduleClass}ListForm',
|
||||
components: {
|
||||
},
|
||||
props: {
|
||||
@@ -103,7 +103,7 @@
|
||||
resetForm() {
|
||||
this.form = {
|
||||
#foreach ($column in $columnList)
|
||||
#if($column.columnName != 'id' && $column.fieldName != 'updateTime' && $column.fieldName != 'createTime')
|
||||
#if( $column.fieldName != 'updateTime' && $column.fieldName != 'createTime')
|
||||
//${column.columnDesc}
|
||||
${column.fieldName}:null,
|
||||
#end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
NODE_ENV=development
|
||||
VUE_APP_TYPE=dev
|
||||
VUE_APP_URL=http://172.16.0.145:10086/smart-admin-api/
|
||||
VUE_APP_SOCKET_URL=ws://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://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
|
||||
/dist
|
||||
|
||||
package-lock.json
|
||||
|
||||
/tests/e2e/videos/
|
||||
/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",
|
||||
"dayjs": "^1.7.7",
|
||||
"decimal.js": "^10.1.1",
|
||||
"e-guide-layer": "^0.1.1",
|
||||
"echarts": "^4.0.4",
|
||||
"gq-plus": "^2.1.5",
|
||||
"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"
|
||||
/>
|
||||
|
||||
<div class="custom-bread-crumb" style="margin-left: 30px;">
|
||||
<div class="custom-bread-crumb" style="margin-left: 30px;" id="topMenuSelectDiv">
|
||||
<div class="ivu-breadcrumb" >
|
||||
<Dropdown @on-click="changeTopMenu">
|
||||
<a href="javascript:void(0)" style="font-size:15px;font-weight:600">
|
||||
@@ -35,6 +35,7 @@
|
||||
<div class="custom-content-con">
|
||||
<slot></slot>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@@ -64,6 +65,27 @@ export default {
|
||||
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: {
|
||||
// 面包屑集合
|
||||
breadCrumbList() {
|
||||
@@ -80,3 +102,5 @@ export default {
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
v-else
|
||||
>
|
||||
<common-icon :type="item.children[0].icon || ''" />
|
||||
<span>{{ showTitle(item.children[0]) }}</span>
|
||||
<span>{{ showTitle(item.children[0]) }} </span>
|
||||
</menu-item>
|
||||
</template>
|
||||
<template v-else>
|
||||
<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>
|
||||
<common-icon :type="item.icon || ''" />
|
||||
<span>{{ showTitle(item) }}</span>
|
||||
<span>{{ showTitle(item) }} </span>
|
||||
</menu-item>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
.scrollbar;
|
||||
}
|
||||
.logo-con{
|
||||
padding: 19px 0 15px 20px;
|
||||
padding: 19px 10px 15px 5px;
|
||||
&.collapsed{
|
||||
padding: 19px 0 15px;
|
||||
text-align: center;
|
||||
@@ -28,7 +28,7 @@
|
||||
margin-left: 200px;
|
||||
}
|
||||
.search-bar{
|
||||
padding:0 20px;
|
||||
padding:0 14px;
|
||||
margin-bottom: 20px;
|
||||
&.collapsed{
|
||||
padding:0 12px;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<Sider
|
||||
:collapsed-width="60"
|
||||
:style="{overflow: 'hidden'}"
|
||||
:width="256"
|
||||
:width="185"
|
||||
class="left-sider"
|
||||
collapsible
|
||||
hide-trigger
|
||||
|
||||
@@ -23,9 +23,13 @@ import enumInfo from '@/constants';
|
||||
// 处理table操作按钮
|
||||
import tableAction from './lib/table-action';
|
||||
|
||||
//时间
|
||||
// 时间
|
||||
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.use(Enum, { enumInfo });
|
||||
|
||||
@@ -20,24 +20,26 @@ export const threeRouter = [
|
||||
children: [
|
||||
{
|
||||
path: '/three-router/level-two/level-three1',
|
||||
name: 'RoleOneTwo',
|
||||
name: 'ThreeLevelRouterView',
|
||||
meta: {
|
||||
title: '三级A',
|
||||
title: '三级菜单子颗粒',
|
||||
privilege: [
|
||||
{ title: '添加', name: 'roleOneTwo-add' },
|
||||
{ title: '删除', name: 'roleOneTwo-delete' }
|
||||
{ title: '添加', name: 'three-level-router-view-add' },
|
||||
{ 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',
|
||||
name: 'RoleTwoTwo',
|
||||
meta: {
|
||||
title: '三级B',
|
||||
title: '三级菜单子哈',
|
||||
privilege: [
|
||||
{ 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')
|
||||
|
||||
@@ -42,7 +42,7 @@ export const systemSetting = [
|
||||
path: '/system-setting/system-privilege',
|
||||
name: 'SystemPrivilege',
|
||||
meta: {
|
||||
title: '菜单权限',
|
||||
title: '菜单设置',
|
||||
privilege: [
|
||||
{
|
||||
title: '编辑',
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
}
|
||||
|
||||
.ivu-menu-submenu-title {
|
||||
padding: 10px 24px !important;
|
||||
padding: 8px 24px !important;
|
||||
}
|
||||
|
||||
.ivu-menu-submenu-has-parent-submenu {
|
||||
@@ -41,7 +41,7 @@
|
||||
// 二级菜单
|
||||
.ivu-menu-item,
|
||||
.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
|
||||
no-repeat !important;
|
||||
|
||||
@@ -63,9 +63,9 @@
|
||||
}
|
||||
}
|
||||
.ivu-menu-submenu-has-parent-submenu {
|
||||
padding-left: 41px !important;
|
||||
padding-left: 31px !important;
|
||||
.ivu-menu-submenu-title {
|
||||
padding: 0 24px !important;
|
||||
padding: 0 17px !important;
|
||||
}
|
||||
&.ivu-menu-child-item-active {
|
||||
background: url('../assets/images/slider/sub_slider_active.png') 30px
|
||||
@@ -73,12 +73,12 @@
|
||||
border-right: 0;
|
||||
}
|
||||
.ivu-menu {
|
||||
padding-top: 10px;
|
||||
padding-top: 8px;
|
||||
}
|
||||
.ivu-menu-item,
|
||||
.ivu-menu-item-active:hover {
|
||||
background: none !important;
|
||||
padding-left: 52px !important;
|
||||
padding-left: 32px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ export default {
|
||||
let g = this;
|
||||
g.editor = new WangEditor('#editor');
|
||||
g.editor.customConfig = {
|
||||
zIndex:1,
|
||||
// 功能键
|
||||
menus: [
|
||||
'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">
|
||||
<Input placeholder="请输入密码" type="password" v-model="formData.loginPwd"></Input>
|
||||
</FormItem>
|
||||
<FormItem prop="code">
|
||||
<!-- <FormItem prop="code">
|
||||
<Input class="code-input" placeholder="请输入验证码" v-model="formData.code"></Input>
|
||||
<img :src="codeUrl" @click="verificationCode" class="codeUrl" v-if="codeUrl" />
|
||||
</FormItem>
|
||||
</FormItem> -->
|
||||
<FormItem class="remember">
|
||||
<Checkbox>记住密码</Checkbox>
|
||||
</FormItem>
|
||||
@@ -18,7 +18,7 @@
|
||||
<Button :loading="btnLoading" @click="login" long type="primary">登录</Button>
|
||||
</FormItem>
|
||||
<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">
|
||||
<img alt class="marginLeft" src="../../../assets/images/login-taobao.png" />
|
||||
<img alt class="marginLeft" src="../../../assets/images/login-alipay.png" />
|
||||
@@ -47,14 +47,15 @@ export default {
|
||||
default: () => {
|
||||
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() {
|
||||
return {
|
||||
@@ -63,7 +64,7 @@ export default {
|
||||
formData: {
|
||||
code: '',
|
||||
codeUuid: '',
|
||||
loginName: 'demo',
|
||||
loginName: 'sa',
|
||||
loginPwd: '123456'
|
||||
},
|
||||
codeUrl: ''
|
||||
@@ -79,7 +80,7 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.verificationCode();
|
||||
// this.verificationCode();
|
||||
},
|
||||
methods: {
|
||||
// 获取验证码
|
||||
@@ -125,7 +126,7 @@ export default {
|
||||
//TODO zhuoda sentry
|
||||
console.error(e);
|
||||
this.btnLoading = false;
|
||||
this.verificationCode();
|
||||
//this.verificationCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
width: 424px;
|
||||
background: #fff;
|
||||
padding: 32px 32px;
|
||||
border-radius: 0 8px 8px 0;
|
||||
border-radius: 8px;
|
||||
.ivu-input {
|
||||
border: 1px solid #E8E8EE;
|
||||
border-radius: 4px;
|
||||
|
||||
@@ -365,6 +365,7 @@ export default {
|
||||
} catch (e) {
|
||||
//TODO zhuoda sentry
|
||||
console.error(e);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
@@ -400,13 +401,21 @@ export default {
|
||||
},
|
||||
// 删除任务
|
||||
async deleteTask(id) {
|
||||
this.$Spin.show();
|
||||
try{
|
||||
let result = await taskApi.deleteTask(id);
|
||||
this.$Message.success('删除任务成功!');
|
||||
this.getTaskList();
|
||||
} catch (error) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
this.$Spin.hide();
|
||||
}
|
||||
},
|
||||
// 操作任务
|
||||
async controlTask(type, id) {
|
||||
this.$Spin.show();
|
||||
try{
|
||||
switch (type) {
|
||||
case 'RUN':
|
||||
await taskApi.updateTaskRun(id);
|
||||
@@ -418,15 +427,26 @@ export default {
|
||||
await taskApi.updateTaskResume(id);
|
||||
break;
|
||||
}
|
||||
this.$Spin.hide();
|
||||
this.$Message.success('操作成功');
|
||||
this.getTaskList();
|
||||
} catch (error) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
this.$Spin.hide();
|
||||
}
|
||||
},
|
||||
// 触发更新
|
||||
handleUpdate() {
|
||||
this.$refs['updateRef'].validate(valid => {
|
||||
if (valid) {
|
||||
this.$Spin.show();
|
||||
try{
|
||||
this.updateTask();
|
||||
} catch (error) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
this.$Spin.hide();
|
||||
}
|
||||
} else {
|
||||
this.$Message.success('验证信息不通过');
|
||||
}
|
||||
@@ -444,6 +464,7 @@ export default {
|
||||
} catch (e) {
|
||||
//TODO zhuoda sentry
|
||||
console.error(e);
|
||||
} finally {
|
||||
this.updateLoading = false;
|
||||
}
|
||||
},
|
||||
@@ -464,6 +485,7 @@ export default {
|
||||
} catch (e) {
|
||||
//TODO zhuoda sentry
|
||||
console.error(e);
|
||||
} finally {
|
||||
this.saveLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -21,19 +21,19 @@
|
||||
<div class="level-one">
|
||||
<Checkbox
|
||||
:label="module.key"
|
||||
@click.prevent.native="selectCheckbox(tree, moduleIndex)"
|
||||
>{{module.name}}</Checkbox>
|
||||
@click.prevent.native="selectCheckbox(module)"
|
||||
>{{module.name}} </Checkbox>
|
||||
</div>
|
||||
<!--div 二级权限模块 start-->
|
||||
<div
|
||||
:key="childrenModule.key"
|
||||
class="level-teo"
|
||||
class="level-two"
|
||||
v-for="(childrenModule, childrenModuleIndex) in module.children"
|
||||
>
|
||||
<Checkbox
|
||||
:label="childrenModule.key"
|
||||
@click.prevent.native="selectCheckbox(module.children,childrenModuleIndex,tree)"
|
||||
class="level-teo-label"
|
||||
@click.prevent.native="selectCheckbox(childrenModule)"
|
||||
class="level-two-label"
|
||||
>{{childrenModule.name}}</Checkbox>
|
||||
<!--div 三级权限模块 start-->
|
||||
<div class="level-three">
|
||||
@@ -46,23 +46,56 @@
|
||||
<Checkbox
|
||||
:key="pages.key"
|
||||
:label="pages.key"
|
||||
@click.prevent.native="selectCheckbox(childrenModule.children,pagesIndex,module.children)"
|
||||
@click.prevent.native="selectCheckbox(pages)"
|
||||
class="level-three-label"
|
||||
>{{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-if="page.children && page.children.length > 0">
|
||||
<!--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(pages.children, pageIndex,childrenModule.children,module.children)"
|
||||
@click.prevent.native="selectCheckbox(page)"
|
||||
>{{page.name}}</Checkbox>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
<!--div 四级权限模块 start-->
|
||||
</div>
|
||||
<Checkbox
|
||||
:key="pages.key"
|
||||
:label="pages.key"
|
||||
@click.prevent.native="selectCheckbox(childrenModule.children,pagesIndex,module.children)"
|
||||
@click.prevent.native="selectCheckbox(pages)"
|
||||
v-else
|
||||
>{{pages.name}}</Checkbox>
|
||||
</template>
|
||||
@@ -101,6 +134,8 @@ export default {
|
||||
return {
|
||||
// 权限数据
|
||||
tree: [],
|
||||
//权限铺平的map
|
||||
treeMap: null,
|
||||
loading: false,
|
||||
// 提交保存数据
|
||||
rolePower: {
|
||||
@@ -133,118 +168,95 @@ export default {
|
||||
activated() {},
|
||||
methods: {
|
||||
// 勾选权限
|
||||
selectCheckbox(
|
||||
currentModuleList,
|
||||
moduleIndex,
|
||||
upOneModuleList,
|
||||
upTwoModuleList
|
||||
) {
|
||||
let module = currentModuleList[moduleIndex];
|
||||
selectCheckbox(module) {
|
||||
// 是否勾选
|
||||
let findIndex = this.checkedData.indexOf(module.key);
|
||||
if (findIndex !== -1) {
|
||||
this.spliceCheck(module);
|
||||
// 取消的上级ID
|
||||
// 判断同级是否全部已取消勾选
|
||||
let currentLevelAllUnchecked = this.isUnCheckedThisLevel(
|
||||
currentModuleList
|
||||
);
|
||||
if (currentLevelAllUnchecked && upOneModuleList) {
|
||||
// 判断上级是否全部已取消勾选
|
||||
let upOneLevelAllUnchecked = this.isUnCheckedThisLevel(
|
||||
upOneModuleList
|
||||
);
|
||||
if (upOneLevelAllUnchecked && upTwoModuleList) {
|
||||
// 判断上上级是否全部已取消勾选
|
||||
this.isUnCheckedThisLevel(upTwoModuleList);
|
||||
//取消自己和孩子
|
||||
this.removeCheckAndChidlrenCheck(module);
|
||||
//判断父级及其以上是否有重复
|
||||
if (module.parentKey) {
|
||||
let parentPrivilege = this.treeMap.get(module.parentKey);
|
||||
if (parentPrivilege) {
|
||||
this.unCheckedParent(parentPrivilege);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 选中子级所有checkBox
|
||||
this.addCheck(module);
|
||||
// 选中上级组件
|
||||
if (module.parentKey) {
|
||||
if (
|
||||
this.checkedData.findIndex(val => val === module.parentKey) === -1
|
||||
) {
|
||||
this.checkedData.push(module.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);
|
||||
this.addCheckAndChildrenCheck(module);
|
||||
// 父类集合选中
|
||||
let parentKey = module.parentKey;
|
||||
while (parentKey != null) {
|
||||
let parentPrivilege = this.treeMap.get(parentKey);
|
||||
if (parentPrivilege) {
|
||||
let findIndex = this.checkedData.findIndex(val => val == parentKey);
|
||||
if (findIndex == -1) {
|
||||
this.checkedData.push(parentKey);
|
||||
}
|
||||
parentKey = parentPrivilege.parentKey;
|
||||
} else {
|
||||
parentKey = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 判断同级是否全部已取消勾选
|
||||
isUnCheckedThisLevel(moduleList) {
|
||||
let thisLevelAllUnchecked = true;
|
||||
moduleList.forEach(e => {
|
||||
let brotherIndex = this.checkedData.findIndex(val => val == e.key);
|
||||
if (brotherIndex != -1) {
|
||||
thisLevelAllUnchecked = false;
|
||||
}
|
||||
});
|
||||
if (thisLevelAllUnchecked) {
|
||||
let number = this.checkedData.findIndex(
|
||||
e => e == moduleList[0].parentKey
|
||||
// 取消父级check
|
||||
unCheckedParent(parentPrivilege) {
|
||||
if (
|
||||
parentPrivilege &&
|
||||
parentPrivilege.children &&
|
||||
parentPrivilege.children.length > 0
|
||||
) {
|
||||
if (!this.judgeArrayExistCheck(parentPrivilege.children)) {
|
||||
let findIndex = this.checkedData.findIndex(
|
||||
val => val == parentPrivilege.key
|
||||
);
|
||||
if (number != -1) {
|
||||
this.checkedData.splice(number, 1);
|
||||
if (findIndex != -1) {
|
||||
this.checkedData.splice(findIndex, 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
|
||||
addCheck(module) {
|
||||
addCheckAndChildrenCheck(module) {
|
||||
let findIndex = this.checkedData.findIndex(val => val == module.key);
|
||||
if (findIndex == -1) {
|
||||
this.checkedData.push(module.key);
|
||||
}
|
||||
|
||||
if (module.children) {
|
||||
module.children.forEach(item => {
|
||||
this.addCheck(item);
|
||||
this.addCheckAndChildrenCheck(item);
|
||||
});
|
||||
}
|
||||
},
|
||||
// 取消自己和下级勾选
|
||||
spliceCheck(module) {
|
||||
removeCheckAndChidlrenCheck(module) {
|
||||
let findIndex = this.checkedData.findIndex(val => val == module.key);
|
||||
if (findIndex != -1) {
|
||||
this.checkedData.splice(findIndex, 1);
|
||||
}
|
||||
if (module.children) {
|
||||
module.children.forEach(item => {
|
||||
this.spliceCheck(item);
|
||||
this.removeCheckAndChidlrenCheck(item);
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -272,13 +284,23 @@ export default {
|
||||
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) {
|
||||
try {
|
||||
let response = await privilegeApi.getListPrivilegeByRoleId(id);
|
||||
let datas = response.data;
|
||||
this.tree = datas.privilege;
|
||||
console.log('tree', this.tree);
|
||||
this.treeMap = new Map();
|
||||
this.tree2map(this.tree);
|
||||
this.checkedData = datas.selectedKey || [];
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -360,14 +382,14 @@ export default {
|
||||
border-bottom: 1px solid rgb(240, 240, 240);
|
||||
padding: 10px 0;
|
||||
}
|
||||
.level-teo {
|
||||
.level-two {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 4%;
|
||||
position: relative;
|
||||
border-bottom: 1px solid rgb(240, 240, 240);
|
||||
line-height: 40px;
|
||||
.level-teo-label {
|
||||
.level-two-label {
|
||||
width: 12%;
|
||||
min-width: 120px;
|
||||
}
|
||||
@@ -381,15 +403,21 @@ export default {
|
||||
.isLevel-four {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-bottom: 1px rgb(240, 240, 240) solid;
|
||||
.level-three-label {
|
||||
width: 12%;
|
||||
min-width: 120px;
|
||||
}
|
||||
.Level-four {
|
||||
.level-four {
|
||||
padding-left: 4%;
|
||||
flex: 1;
|
||||
min-height: 40px;
|
||||
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