This commit is contained in:
zhuo 2020-09-06 17:29:52 +08:00
parent 029d9b0ef0
commit 486cc02088
61 changed files with 714 additions and 282 deletions

View File

@ -22,13 +22,15 @@
<velocity.version>1.7</velocity.version>
<velocity-engine-core.version>2.0</velocity-engine-core.version>
<swagger.version>2.7.0</swagger.version>
<knife4j.version>2.0.4</knife4j.version>
<mybatis-plus-boot.version>3.3.1</mybatis-plus-boot.version>
<fastjson.version>1.2.66</fastjson.version>
<fastjson.version>1.2.73</fastjson.version>
<guava.version>28.2-jre</guava.version>
<aliyun-oss.version>2.7.0</aliyun-oss.version>
<qiniu-oss.version>[7.2.0, 7.2.99]</qiniu-oss.version>
<jjwt.version>0.9.1</jjwt.version>
<druid.version>1.1.21</druid.version>
<p6spy.version>3.9.1</p6spy.version>
<concurrentlinkedhashmap.version>1.4.2</concurrentlinkedhashmap.version>
<easypoi.version>4.1.2</easypoi.version>
<commons-fileupload.version>1.3.1</commons-fileupload.version>
@ -124,6 +126,13 @@
<version>${druid.version}</version>
</dependency>
<!--p6spy-->
<dependency>
<groupId>p6spy</groupId>
<artifactId>p6spy</artifactId>
<version>${p6spy.version}</version>
</dependency>
<!-- swagger begin -->
<dependency>
<groupId>io.springfox</groupId>
@ -137,6 +146,14 @@
</dependency>
<!-- swagger end -->
<!-- knife4j start -->
<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>

View File

@ -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>

View File

@ -1,6 +1,7 @@
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 java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@ -23,6 +24,8 @@ public @interface DataScope {
DataScopeTypeEnum dataScopeType() default DataScopeTypeEnum.DEFAULT;
DataScopeWhereInTypeEnum whereInType() default DataScopeWhereInTypeEnum.EMPLOYEE;
/**
* 第几个where 条件 从0开始
* @return

View File

@ -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;

View File

@ -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("是否查询总条数")

View File

@ -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) {
}
}

View File

@ -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) {
}
}

View File

@ -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");

View File

@ -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());
};
}
}

View File

@ -1,5 +1,6 @@
package net.lab1024.smartadmin.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import net.lab1024.smartadmin.constant.SwaggerTagConst;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
@ -48,6 +49,7 @@ import java.util.Map;
*/
@Slf4j
@EnableSwagger2
@EnableKnife4j
@Configuration
@Profile({"dev", "sit", "pre", "prod"})
public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDefinitionRegistryPostProcessor {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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.*;

View File

@ -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 = "n.create_user_department_id in (#departmentIds)", whereInType = DataScopeWhereInTypeEnum.DEPARTMENT)
List<NoticeVO> queryUnreadByPage(Page page, @Param("employeeId") Long employeeId, @Param("sendStatus") Integer sendStatus);

View File

@ -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;

View File

@ -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;

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import net.lab1024.smartadmin.common.domain.BaseEntity;
import lombok.Data;
/**
* [ ]
*

View File

@ -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);

View File

@ -3,7 +3,7 @@ package net.lab1024.smartadmin.module.system.datascope.service;
import net.lab1024.smartadmin.common.anno.DataScope;
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.login.domain.RequestTokenBO;
import net.lab1024.smartadmin.util.SmartRequestTokenUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -70,6 +70,7 @@ public class DataScopeSqlConfigService {
configDTO.setDataScopeType(dataScopeAnnotation.dataScopeType().getType());
configDTO.setJoinSql(dataScopeAnnotation.joinSql());
configDTO.setWhereIndex(dataScopeAnnotation.whereIndex());
configDTO.setDataScopeWhereInType(dataScopeAnnotation.whereInType().getType());
dataScopeMethodMap.put(method.getDeclaringClass().getSimpleName() + "." + method.getName(), configDTO);
}
}

View File

@ -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;

View File

@ -13,7 +13,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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -1,4 +1,4 @@
package net.lab1024.smartadmin.module.business.login.domain;
package net.lab1024.smartadmin.module.system.login.domain;
import lombok.Data;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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());

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -0,0 +1,10 @@
package net.lab1024.smartadmin.util.excel;
/**
* @author zhuoda
*/
public enum SmartExcelFileType {
XLS,
XLSX
}

View File

@ -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());
}
}

View File

@ -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;
}
}

View File

@ -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
@ -32,7 +32,7 @@ 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.driver-class-name=com.p6spy.engine.spy.P6SpyDriver
spring.datasource.filters=stat
spring.datasource.druid.username=druid
spring.datasource.druid.password=123456
@ -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

View File

@ -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

View File

@ -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>,

View File

@ -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

View File

@ -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

View File

@ -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
@ -32,7 +32,7 @@ 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.driver-class-name=com.p6spy.engine.spy.P6SpyDriver
spring.datasource.filters=stat
spring.datasource.druid.username=druid
spring.datasource.druid.password=123456
@ -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

View File

@ -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

View File

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -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>

View File

@ -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;

View File

@ -3,7 +3,7 @@
<Sider
:collapsed-width="60"
:style="{overflow: 'hidden'}"
:width="256"
:width="185"
class="left-sider"
collapsible
hide-trigger

View File

@ -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')

View File

@ -42,7 +42,7 @@ export const systemSetting = [
path: '/system-setting/system-privilege',
name: 'SystemPrivilege',
meta: {
title: '菜单权限',
title: '菜单设置',
privilege: [
{
title: '编辑',

View File

@ -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;
}
}
}

View File

@ -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>

View File

@ -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" />

View File

@ -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">
<Checkbox
:key="page.key"
:label="page.key"
@click.prevent.native="selectCheckbox(pages.children, pageIndex,childrenModule.children,module.children)"
>{{page.name}}</Checkbox>
<!---
如果是第四级菜单的话会继续往下一层遍历
-->
<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(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
);
if (number != -1) {
this.checkedData.splice(number, 1);
// 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 (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;
}
}
}
}

View File

@ -17,7 +17,7 @@
<Form-item label="功能Key" prop="functionKey" required>
<Input disabled placeholder="请输入功能Key" v-model="privilege.functionKey"></Input>
</Form-item>
<Form-item label="Url" required>
<Form-item label="Url">
<Select filterable multiple v-model="urlArray">
<OptionGroup :key="i" :label="items.label" v-for="(items, i) in urlList">
<Option :key="j" :label="item.url" :value="item.name" v-for="(item, j) in items.data">

View File

@ -113,7 +113,7 @@
:title="formData.title"
:typeDisabled="typeDisabled"
@closeModal="closeModal"
@updateMenuSuccess="getPrivilegeList"
@updateMenuSuccess="loadPrivilegeTableData"
></privilege-form>
</Col>
</Row>
@ -366,6 +366,16 @@ console.error(privilegeTree)
pointsChangeNum++;
}
}
//
if(serverPointData.length > frontPrivilegeData.length){
for (const serverFunction of serverPointData) {
if(frontPrivilegeData.findIndex(e => e.name === serverFunction.functionKey ) === -1){
//
pointsChangeNum++;
}
}
}
this.pointsChangeNum = pointsChangeNum;
this.privilegeTableData = frontPrivilegeData;
},