mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 02:08:15 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
60645161db
@ -6,8 +6,9 @@
|
|||||||
<br>
|
<br>
|
||||||
[](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus)
|
[](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus)
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
|
[]()
|
||||||
|
|
||||||
RuoYi-Vue-Plus 是基于 RuoYi-Vue 针对 `分布式集群` 场景升级(不兼容原框架)
|
RuoYi-Vue-Plus 是基于 RuoYi-Vue 针对 `分布式集群` 场景升级(不兼容原框架)
|
||||||
|
|
||||||
|
|||||||
@ -108,6 +108,9 @@ token:
|
|||||||
|
|
||||||
# security配置
|
# security配置
|
||||||
security:
|
security:
|
||||||
|
# 登出路径
|
||||||
|
logout-url: /logout
|
||||||
|
# 匿名路径
|
||||||
anonymous:
|
anonymous:
|
||||||
- /login
|
- /login
|
||||||
- /register
|
- /register
|
||||||
@ -122,6 +125,8 @@ security:
|
|||||||
# actuator 监控配置
|
# actuator 监控配置
|
||||||
- /actuator
|
- /actuator
|
||||||
- /actuator/**
|
- /actuator/**
|
||||||
|
# 用户放行
|
||||||
|
permit-all:
|
||||||
|
|
||||||
# 重复提交
|
# 重复提交
|
||||||
repeat-submit:
|
repeat-submit:
|
||||||
@ -238,6 +243,11 @@ swagger:
|
|||||||
name: Lion Li
|
name: Lion Li
|
||||||
email: crazylionli@163.com
|
email: crazylionli@163.com
|
||||||
url: https://gitee.com/JavaLionLi/RuoYi-Vue-Plus
|
url: https://gitee.com/JavaLionLi/RuoYi-Vue-Plus
|
||||||
|
groups:
|
||||||
|
- name: 演示案例
|
||||||
|
basePackage: com.ruoyi.demo
|
||||||
|
- name: 系统模块
|
||||||
|
basePackage: com.ruoyi.admin
|
||||||
|
|
||||||
# 防止XSS攻击
|
# 防止XSS攻击
|
||||||
xss:
|
xss:
|
||||||
@ -261,7 +271,7 @@ thread-pool:
|
|||||||
# 线程池维护线程所允许的空闲时间
|
# 线程池维护线程所允许的空闲时间
|
||||||
keepAliveSeconds: 300
|
keepAliveSeconds: 300
|
||||||
# 线程池对拒绝任务(无线程可用)的处理策略
|
# 线程池对拒绝任务(无线程可用)的处理策略
|
||||||
# CALLER_RUNS_POLICY 等待
|
# CALLER_RUNS_POLICY 调用方执行
|
||||||
# DISCARD_OLDEST_POLICY 放弃最旧的
|
# DISCARD_OLDEST_POLICY 放弃最旧的
|
||||||
# DISCARD_POLICY 丢弃
|
# DISCARD_POLICY 丢弃
|
||||||
# ABORT_POLICY 中止
|
# ABORT_POLICY 中止
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum ThreadPoolRejectedPolicy {
|
public enum ThreadPoolRejectedPolicy {
|
||||||
|
|
||||||
CALLER_RUNS_POLICY("等待", ThreadPoolExecutor.CallerRunsPolicy.class),
|
CALLER_RUNS_POLICY("调用方执行", ThreadPoolExecutor.CallerRunsPolicy.class),
|
||||||
DISCARD_OLDEST_POLICY("放弃最旧的", ThreadPoolExecutor.DiscardOldestPolicy.class),
|
DISCARD_OLDEST_POLICY("放弃最旧的", ThreadPoolExecutor.DiscardOldestPolicy.class),
|
||||||
DISCARD_POLICY("丢弃", ThreadPoolExecutor.DiscardPolicy.class),
|
DISCARD_POLICY("丢弃", ThreadPoolExecutor.DiscardPolicy.class),
|
||||||
ABORT_POLICY("中止", ThreadPoolExecutor.AbortPolicy.class);
|
ABORT_POLICY("中止", ThreadPoolExecutor.AbortPolicy.class);
|
||||||
|
|||||||
@ -35,6 +35,7 @@ public class FileUtils extends FileUtil
|
|||||||
.append(percentEncodedFileName);
|
.append(percentEncodedFileName);
|
||||||
|
|
||||||
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
response.setHeader("Content-disposition", contentDispositionValue.toString());
|
||||||
|
response.setHeader("download-filename", percentEncodedFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -109,11 +109,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
|||||||
"/**/*.js"
|
"/**/*.js"
|
||||||
).permitAll()
|
).permitAll()
|
||||||
.antMatchers(securityProperties.getAnonymous()).anonymous()
|
.antMatchers(securityProperties.getAnonymous()).anonymous()
|
||||||
|
.antMatchers(securityProperties.getPermitAll()).permitAll()
|
||||||
// 除上面外的所有请求全部需要鉴权认证
|
// 除上面外的所有请求全部需要鉴权认证
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
.and()
|
.and()
|
||||||
.headers().frameOptions().disable();
|
.headers().frameOptions().disable();
|
||||||
httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);
|
httpSecurity.logout().logoutUrl(securityProperties.getLogoutUrl()).logoutSuccessHandler(logoutSuccessHandler);
|
||||||
// 添加JWT filter
|
// 添加JWT filter
|
||||||
httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
||||||
// 添加CORS filter
|
// 添加CORS filter
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
package com.ruoyi.framework.config;
|
package com.ruoyi.framework.config;
|
||||||
|
|
||||||
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
||||||
|
import com.ruoyi.common.properties.TokenProperties;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
import com.ruoyi.framework.config.properties.SwaggerProperties;
|
import com.ruoyi.framework.config.properties.SwaggerProperties;
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import io.swagger.models.auth.In;
|
import io.swagger.models.auth.In;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
@ -15,6 +16,7 @@ import springfox.documentation.spi.DocumentationType;
|
|||||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -27,82 +29,92 @@ import java.util.List;
|
|||||||
@EnableKnife4j
|
@EnableKnife4j
|
||||||
public class SwaggerConfig {
|
public class SwaggerConfig {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SwaggerProperties swaggerProperties;
|
private SwaggerProperties swaggerProperties;
|
||||||
|
|
||||||
/**
|
@Autowired
|
||||||
* 创建API
|
private TokenProperties tokenProperties;
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public Docket createRestApi() {
|
|
||||||
return new Docket(DocumentationType.OAS_30)
|
|
||||||
.enable(swaggerProperties.getEnabled())
|
|
||||||
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
|
||||||
.apiInfo(apiInfo())
|
|
||||||
// 设置哪些接口暴露给Swagger展示
|
|
||||||
.select()
|
|
||||||
// 扫描所有有注解的api,用这种方式更灵活
|
|
||||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
|
||||||
// 扫描指定包中的swagger注解
|
|
||||||
// .apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
|
|
||||||
// 扫描所有 .apis(RequestHandlerSelectors.any())
|
|
||||||
.paths(PathSelectors.any())
|
|
||||||
.build()
|
|
||||||
/* 设置安全模式,swagger可以设置访问token */
|
|
||||||
.securitySchemes(securitySchemes())
|
|
||||||
.securityContexts(securityContexts())
|
|
||||||
.pathMapping(swaggerProperties.getPathMapping());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安全模式,这里指定token通过Authorization头请求头传递
|
* 创建API
|
||||||
*/
|
*/
|
||||||
private List<SecurityScheme> securitySchemes() {
|
@PostConstruct
|
||||||
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
|
public void createRestApi() {
|
||||||
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
|
for (SwaggerProperties.Groups group : swaggerProperties.getGroups()) {
|
||||||
return apiKeyList;
|
String basePackage = group.getBasePackage();
|
||||||
}
|
Docket docket = new Docket(DocumentationType.OAS_30)
|
||||||
|
.enable(swaggerProperties.getEnabled())
|
||||||
|
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
|
||||||
|
.apiInfo(apiInfo())
|
||||||
|
// 设置哪些接口暴露给Swagger展示
|
||||||
|
.select()
|
||||||
|
// 扫描所有有注解的api,用这种方式更灵活
|
||||||
|
//.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||||
|
// 扫描指定包中的swagger注解
|
||||||
|
.apis(RequestHandlerSelectors.basePackage(basePackage))
|
||||||
|
// 扫描所有 .apis(RequestHandlerSelectors.any())
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build()
|
||||||
|
.groupName(group.getName())
|
||||||
|
// 设置安全模式,swagger可以设置访问token
|
||||||
|
.securitySchemes(securitySchemes())
|
||||||
|
.securityContexts(securityContexts())
|
||||||
|
.pathMapping(swaggerProperties.getPathMapping());
|
||||||
|
String beanName = StringUtils.substringAfterLast(basePackage, ".") + "Docket";
|
||||||
|
SpringUtils.registerBean(beanName, docket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安全上下文
|
* 安全模式,这里指定token通过Authorization头请求头传递
|
||||||
*/
|
*/
|
||||||
private List<SecurityContext> securityContexts() {
|
private List<SecurityScheme> securitySchemes() {
|
||||||
List<SecurityContext> securityContexts = new ArrayList<>();
|
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
|
||||||
securityContexts.add(
|
String header = tokenProperties.getHeader();
|
||||||
SecurityContext.builder()
|
apiKeyList.add(new ApiKey(header, header, In.HEADER.toValue()));
|
||||||
.securityReferences(defaultAuth())
|
return apiKeyList;
|
||||||
.operationSelector(o -> o.requestMappingPattern().matches("/.*"))
|
}
|
||||||
.build());
|
|
||||||
return securityContexts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认的安全上引用
|
* 安全上下文
|
||||||
*/
|
*/
|
||||||
private List<SecurityReference> defaultAuth() {
|
private List<SecurityContext> securityContexts() {
|
||||||
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
List<SecurityContext> securityContexts = new ArrayList<>();
|
||||||
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
securityContexts.add(
|
||||||
authorizationScopes[0] = authorizationScope;
|
SecurityContext.builder()
|
||||||
List<SecurityReference> securityReferences = new ArrayList<>();
|
.securityReferences(defaultAuth())
|
||||||
securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
|
.operationSelector(o -> o.requestMappingPattern().matches("/.*"))
|
||||||
return securityReferences;
|
.build());
|
||||||
}
|
return securityContexts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加摘要信息
|
* 默认的安全上引用
|
||||||
*/
|
*/
|
||||||
private ApiInfo apiInfo() {
|
private List<SecurityReference> defaultAuth() {
|
||||||
// 用ApiInfoBuilder进行定制
|
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
|
||||||
SwaggerProperties.Contact contact = swaggerProperties.getContact();
|
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
||||||
return new ApiInfoBuilder()
|
authorizationScopes[0] = authorizationScope;
|
||||||
// 设置标题
|
List<SecurityReference> securityReferences = new ArrayList<>();
|
||||||
.title(swaggerProperties.getTitle())
|
securityReferences.add(new SecurityReference(tokenProperties.getHeader(), authorizationScopes));
|
||||||
// 描述
|
return securityReferences;
|
||||||
.description(swaggerProperties.getDescription())
|
}
|
||||||
// 作者信息
|
|
||||||
.contact(new Contact(contact.getName(), contact.getUrl(), contact.getEmail()))
|
/**
|
||||||
// 版本
|
* 添加摘要信息
|
||||||
.version(swaggerProperties.getVersion())
|
*/
|
||||||
.build();
|
private ApiInfo apiInfo() {
|
||||||
}
|
// 用ApiInfoBuilder进行定制
|
||||||
|
SwaggerProperties.Contact contact = swaggerProperties.getContact();
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
// 设置标题
|
||||||
|
.title(swaggerProperties.getTitle())
|
||||||
|
// 描述
|
||||||
|
.description(swaggerProperties.getDescription())
|
||||||
|
// 作者信息
|
||||||
|
.contact(new Contact(contact.getName(), contact.getUrl(), contact.getEmail()))
|
||||||
|
// 版本
|
||||||
|
.version(swaggerProperties.getVersion())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,9 +14,19 @@ import org.springframework.stereotype.Component;
|
|||||||
@ConfigurationProperties(prefix = "security")
|
@ConfigurationProperties(prefix = "security")
|
||||||
public class SecurityProperties {
|
public class SecurityProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退出登录url
|
||||||
|
*/
|
||||||
|
private String logoutUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 匿名放行路径
|
* 匿名放行路径
|
||||||
*/
|
*/
|
||||||
private String[] anonymous;
|
private String[] anonymous;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户任意访问放行路径
|
||||||
|
*/
|
||||||
|
private String[] permitAll;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import lombok.NoArgsConstructor;
|
|||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* swagger 配置属性
|
* swagger 配置属性
|
||||||
*
|
*
|
||||||
@ -41,23 +43,46 @@ public class SwaggerProperties {
|
|||||||
*/
|
*/
|
||||||
private Contact contact;
|
private Contact contact;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组配置
|
||||||
|
*/
|
||||||
|
private List<Groups> groups;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public static class Contact{
|
public static class Contact {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系人
|
* 联系人
|
||||||
**/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系人url
|
* 联系人url
|
||||||
**/
|
*/
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系人email
|
* 联系人email
|
||||||
**/
|
*/
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public static class Groups {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基础包路径
|
||||||
|
*/
|
||||||
|
private String basePackage;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -573,7 +573,7 @@ export default {
|
|||||||
#end
|
#end
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/${moduleName}/${businessName}/export', this.queryParams);
|
this.#[[$download]]#.excel('/${moduleName}/${businessName}/export', this.queryParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -15,12 +15,15 @@ import java.util.Set;
|
|||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service("ss")
|
@Service("ss")
|
||||||
public class PermissionService
|
public class PermissionService {
|
||||||
{
|
/**
|
||||||
/** 所有权限标识 */
|
* 所有权限标识
|
||||||
|
*/
|
||||||
private static final String ALL_PERMISSION = "*:*:*";
|
private static final String ALL_PERMISSION = "*:*:*";
|
||||||
|
|
||||||
/** 管理员角色权限标识 */
|
/**
|
||||||
|
* 管理员角色权限标识
|
||||||
|
*/
|
||||||
private static final String SUPER_ADMIN = "admin";
|
private static final String SUPER_ADMIN = "admin";
|
||||||
|
|
||||||
private static final String ROLE_DELIMETER = ",";
|
private static final String ROLE_DELIMETER = ",";
|
||||||
@ -33,15 +36,12 @@ public class PermissionService
|
|||||||
* @param permission 权限字符串
|
* @param permission 权限字符串
|
||||||
* @return 用户是否具备某权限
|
* @return 用户是否具备某权限
|
||||||
*/
|
*/
|
||||||
public boolean hasPermi(String permission)
|
public boolean hasPermi(String permission) {
|
||||||
{
|
if (StringUtils.isEmpty(permission)) {
|
||||||
if (StringUtils.isEmpty(permission))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions()))
|
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return hasPermissions(loginUser.getPermissions(), permission);
|
return hasPermissions(loginUser.getPermissions(), permission);
|
||||||
@ -53,8 +53,7 @@ public class PermissionService
|
|||||||
* @param permission 权限字符串
|
* @param permission 权限字符串
|
||||||
* @return 用户是否不具备某权限
|
* @return 用户是否不具备某权限
|
||||||
*/
|
*/
|
||||||
public boolean lacksPermi(String permission)
|
public boolean lacksPermi(String permission) {
|
||||||
{
|
|
||||||
return hasPermi(permission) != true;
|
return hasPermi(permission) != true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,22 +63,17 @@ public class PermissionService
|
|||||||
* @param permissions 以 PERMISSION_NAMES_DELIMETER 为分隔符的权限列表
|
* @param permissions 以 PERMISSION_NAMES_DELIMETER 为分隔符的权限列表
|
||||||
* @return 用户是否具有以下任意一个权限
|
* @return 用户是否具有以下任意一个权限
|
||||||
*/
|
*/
|
||||||
public boolean hasAnyPermi(String permissions)
|
public boolean hasAnyPermi(String permissions) {
|
||||||
{
|
if (StringUtils.isEmpty(permissions)) {
|
||||||
if (StringUtils.isEmpty(permissions))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions()))
|
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<String> authorities = loginUser.getPermissions();
|
Set<String> authorities = loginUser.getPermissions();
|
||||||
for (String permission : permissions.split(PERMISSION_DELIMETER))
|
for (String permission : permissions.split(PERMISSION_DELIMETER)) {
|
||||||
{
|
if (permission != null && hasPermissions(authorities, permission)) {
|
||||||
if (permission != null && hasPermissions(authorities, permission))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,22 +86,17 @@ public class PermissionService
|
|||||||
* @param role 角色字符串
|
* @param role 角色字符串
|
||||||
* @return 用户是否具备某角色
|
* @return 用户是否具备某角色
|
||||||
*/
|
*/
|
||||||
public boolean hasRole(String role)
|
public boolean hasRole(String role) {
|
||||||
{
|
if (StringUtils.isEmpty(role)) {
|
||||||
if (StringUtils.isEmpty(role))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles()))
|
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (SysRole sysRole : loginUser.getUser().getRoles())
|
for (SysRole sysRole : loginUser.getUser().getRoles()) {
|
||||||
{
|
|
||||||
String roleKey = sysRole.getRoleKey();
|
String roleKey = sysRole.getRoleKey();
|
||||||
if (SUPER_ADMIN.equals(roleKey) || roleKey.equals(StringUtils.trim(role)))
|
if (SUPER_ADMIN.equals(roleKey) || roleKey.equals(StringUtils.trim(role))) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,8 +109,7 @@ public class PermissionService
|
|||||||
* @param role 角色名称
|
* @param role 角色名称
|
||||||
* @return 用户是否不具备某角色
|
* @return 用户是否不具备某角色
|
||||||
*/
|
*/
|
||||||
public boolean lacksRole(String role)
|
public boolean lacksRole(String role) {
|
||||||
{
|
|
||||||
return hasRole(role) != true;
|
return hasRole(role) != true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,21 +119,16 @@ public class PermissionService
|
|||||||
* @param roles 以 ROLE_NAMES_DELIMETER 为分隔符的角色列表
|
* @param roles 以 ROLE_NAMES_DELIMETER 为分隔符的角色列表
|
||||||
* @return 用户是否具有以下任意一个角色
|
* @return 用户是否具有以下任意一个角色
|
||||||
*/
|
*/
|
||||||
public boolean hasAnyRoles(String roles)
|
public boolean hasAnyRoles(String roles) {
|
||||||
{
|
if (StringUtils.isEmpty(roles)) {
|
||||||
if (StringUtils.isEmpty(roles))
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles()))
|
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (String role : roles.split(ROLE_DELIMETER))
|
for (String role : roles.split(ROLE_DELIMETER)) {
|
||||||
{
|
if (hasRole(role)) {
|
||||||
if (hasRole(role))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,11 +139,10 @@ public class PermissionService
|
|||||||
* 判断是否包含权限
|
* 判断是否包含权限
|
||||||
*
|
*
|
||||||
* @param permissions 权限列表
|
* @param permissions 权限列表
|
||||||
* @param permission 权限字符串
|
* @param permission 权限字符串
|
||||||
* @return 用户是否具备某权限
|
* @return 用户是否具备某权限
|
||||||
*/
|
*/
|
||||||
private boolean hasPermissions(Set<String> permissions, String permission)
|
private boolean hasPermissions(Set<String> permissions, String permission) {
|
||||||
{
|
|
||||||
return permissions.contains(ALL_PERMISSION) || permissions.contains(StringUtils.trim(permission));
|
return permissions.contains(ALL_PERMISSION) || permissions.contains(StringUtils.trim(permission));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import org.springframework.security.authentication.AuthenticationManager;
|
|||||||
import org.springframework.security.authentication.BadCredentialsException;
|
import org.springframework.security.authentication.BadCredentialsException;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -28,64 +28,55 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Component
|
@Service
|
||||||
public class SysLoginService
|
public class SysLoginService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AuthenticationManager authenticationManager;
|
private AuthenticationManager authenticationManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysConfigService configService;
|
private ISysConfigService configService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LogininforService asyncService;
|
private LogininforService asyncService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录验证
|
* 登录验证
|
||||||
*
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param password 密码
|
* @param password 密码
|
||||||
* @param code 验证码
|
* @param code 验证码
|
||||||
* @param uuid 唯一标识
|
* @param uuid 唯一标识
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String login(String username, String password, String code, String uuid)
|
public String login(String username, String password, String code, String uuid) {
|
||||||
{
|
HttpServletRequest request = ServletUtils.getRequest();
|
||||||
HttpServletRequest request = ServletUtils.getRequest();
|
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
||||||
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
|
||||||
// 验证码开关
|
// 验证码开关
|
||||||
if (captchaOnOff)
|
if (captchaOnOff) {
|
||||||
{
|
|
||||||
validateCaptcha(username, code, uuid, request);
|
validateCaptcha(username, code, uuid, request);
|
||||||
}
|
}
|
||||||
// 用户验证
|
// 用户验证
|
||||||
Authentication authentication = null;
|
Authentication authentication = null;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
||||||
authentication = authenticationManager
|
authentication = authenticationManager
|
||||||
.authenticate(new UsernamePasswordAuthenticationToken(username, password));
|
.authenticate(new UsernamePasswordAuthenticationToken(username, password));
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
if (e instanceof BadCredentialsException) {
|
||||||
{
|
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"), request);
|
||||||
if (e instanceof BadCredentialsException)
|
|
||||||
{
|
|
||||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"), request);
|
|
||||||
throw new UserPasswordNotMatchException();
|
throw new UserPasswordNotMatchException();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage(), request);
|
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage(), request);
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
asyncService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request);
|
asyncService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"), request);
|
||||||
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||||
recordLoginInfo(loginUser.getUserId());
|
recordLoginInfo(loginUser.getUserId());
|
||||||
// 生成token
|
// 生成token
|
||||||
@ -96,22 +87,22 @@ public class SysLoginService
|
|||||||
* 校验验证码
|
* 校验验证码
|
||||||
*
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param code 验证码
|
* @param code 验证码
|
||||||
* @param uuid 唯一标识
|
* @param uuid 唯一标识
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public void validateCaptcha(String username, String code, String uuid, HttpServletRequest request) {
|
public void validateCaptcha(String username, String code, String uuid, HttpServletRequest request) {
|
||||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||||
RedisUtils.deleteObject(verifyKey);
|
RedisUtils.deleteObject(verifyKey);
|
||||||
if (captcha == null) {
|
if (captcha == null) {
|
||||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"), request);
|
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"), request);
|
||||||
throw new CaptchaExpireException();
|
throw new CaptchaExpireException();
|
||||||
}
|
}
|
||||||
if (!code.equalsIgnoreCase(captcha)) {
|
if (!code.equalsIgnoreCase(captcha)) {
|
||||||
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"), request);
|
asyncService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"), request);
|
||||||
throw new CaptchaException();
|
throw new CaptchaException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,8 +110,7 @@ public class SysLoginService
|
|||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
public void recordLoginInfo(Long userId)
|
public void recordLoginInfo(Long userId) {
|
||||||
{
|
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
sysUser.setUserId(userId);
|
sysUser.setUserId(userId);
|
||||||
sysUser.setLoginIp(ServletUtils.getClientIP());
|
sysUser.setLoginIp(ServletUtils.getClientIP());
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package com.ruoyi.system.service;
|
|||||||
|
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -12,9 +12,9 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Component
|
@Service
|
||||||
public class SysPermissionService
|
public class SysPermissionService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysRoleService roleService;
|
private ISysRoleService roleService;
|
||||||
|
|
||||||
@ -27,16 +27,12 @@ public class SysPermissionService
|
|||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 角色权限信息
|
* @return 角色权限信息
|
||||||
*/
|
*/
|
||||||
public Set<String> getRolePermission(SysUser user)
|
public Set<String> getRolePermission(SysUser user) {
|
||||||
{
|
|
||||||
Set<String> roles = new HashSet<String>();
|
Set<String> roles = new HashSet<String>();
|
||||||
// 管理员拥有所有权限
|
// 管理员拥有所有权限
|
||||||
if (user.isAdmin())
|
if (user.isAdmin()) {
|
||||||
{
|
|
||||||
roles.add("admin");
|
roles.add("admin");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId()));
|
roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId()));
|
||||||
}
|
}
|
||||||
return roles;
|
return roles;
|
||||||
@ -48,16 +44,12 @@ public class SysPermissionService
|
|||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 菜单权限信息
|
* @return 菜单权限信息
|
||||||
*/
|
*/
|
||||||
public Set<String> getMenuPermission(SysUser user)
|
public Set<String> getMenuPermission(SysUser user) {
|
||||||
{
|
|
||||||
Set<String> perms = new HashSet<String>();
|
Set<String> perms = new HashSet<String>();
|
||||||
// 管理员拥有所有权限
|
// 管理员拥有所有权限
|
||||||
if (user.isAdmin())
|
if (user.isAdmin()) {
|
||||||
{
|
|
||||||
perms.add("*:*:*");
|
perms.add("*:*:*");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
|
perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
|
||||||
}
|
}
|
||||||
return perms;
|
return perms;
|
||||||
|
|||||||
@ -9,75 +9,59 @@ import com.ruoyi.common.exception.user.CaptchaException;
|
|||||||
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
||||||
import com.ruoyi.common.utils.*;
|
import com.ruoyi.common.utils.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册校验方法
|
* 注册校验方法
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Component
|
@Service
|
||||||
public class SysRegisterService
|
public class SysRegisterService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysConfigService configService;
|
private ISysConfigService configService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LogininforService asyncService;
|
private LogininforService asyncService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册
|
* 注册
|
||||||
*/
|
*/
|
||||||
public String register(RegisterBody registerBody)
|
public String register(RegisterBody registerBody) {
|
||||||
{
|
|
||||||
String msg = "", username = registerBody.getUsername(), password = registerBody.getPassword();
|
String msg = "", username = registerBody.getUsername(), password = registerBody.getPassword();
|
||||||
|
|
||||||
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
boolean captchaOnOff = configService.selectCaptchaOnOff();
|
||||||
// 验证码开关
|
// 验证码开关
|
||||||
if (captchaOnOff)
|
if (captchaOnOff) {
|
||||||
{
|
|
||||||
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid());
|
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isEmpty(username))
|
if (StringUtils.isEmpty(username)) {
|
||||||
{
|
|
||||||
msg = "用户名不能为空";
|
msg = "用户名不能为空";
|
||||||
}
|
} else if (StringUtils.isEmpty(password)) {
|
||||||
else if (StringUtils.isEmpty(password))
|
|
||||||
{
|
|
||||||
msg = "用户密码不能为空";
|
msg = "用户密码不能为空";
|
||||||
}
|
} else if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||||
else if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
|| username.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
|
|
||||||
{
|
|
||||||
msg = "账户长度必须在2到20个字符之间";
|
msg = "账户长度必须在2到20个字符之间";
|
||||||
}
|
} else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||||
else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
|
||||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
|
|
||||||
{
|
|
||||||
msg = "密码长度必须在5到20个字符之间";
|
msg = "密码长度必须在5到20个字符之间";
|
||||||
}
|
} else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username))) {
|
||||||
else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username)))
|
|
||||||
{
|
|
||||||
msg = "保存用户'" + username + "'失败,注册账号已存在";
|
msg = "保存用户'" + username + "'失败,注册账号已存在";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
sysUser.setUserName(username);
|
sysUser.setUserName(username);
|
||||||
sysUser.setNickName(username);
|
sysUser.setNickName(username);
|
||||||
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
|
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
|
||||||
boolean regFlag = userService.registerUser(sysUser);
|
boolean regFlag = userService.registerUser(sysUser);
|
||||||
if (!regFlag)
|
if (!regFlag) {
|
||||||
{
|
|
||||||
msg = "注册失败,请联系系统管理人员";
|
msg = "注册失败,请联系系统管理人员";
|
||||||
}
|
} else {
|
||||||
else
|
asyncService.recordLogininfor(username, Constants.REGISTER,
|
||||||
{
|
|
||||||
asyncService.recordLogininfor(username, Constants.REGISTER,
|
|
||||||
MessageUtils.message("user.register.success"), ServletUtils.getRequest());
|
MessageUtils.message("user.register.success"), ServletUtils.getRequest());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,21 +72,18 @@ public class SysRegisterService
|
|||||||
* 校验验证码
|
* 校验验证码
|
||||||
*
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param code 验证码
|
* @param code 验证码
|
||||||
* @param uuid 唯一标识
|
* @param uuid 唯一标识
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public void validateCaptcha(String username, String code, String uuid)
|
public void validateCaptcha(String username, String code, String uuid) {
|
||||||
{
|
|
||||||
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
||||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||||
RedisUtils.deleteObject(verifyKey);
|
RedisUtils.deleteObject(verifyKey);
|
||||||
if (captcha == null)
|
if (captcha == null) {
|
||||||
{
|
|
||||||
throw new CaptchaExpireException();
|
throw new CaptchaExpireException();
|
||||||
}
|
}
|
||||||
if (!code.equalsIgnoreCase(captcha))
|
if (!code.equalsIgnoreCase(captcha)) {
|
||||||
{
|
|
||||||
throw new CaptchaException();
|
throw new CaptchaException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import io.jsonwebtoken.Claims;
|
|||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@Component
|
@Service
|
||||||
public class TokenServiceImpl implements TokenService {
|
public class TokenServiceImpl implements TokenService {
|
||||||
|
|
||||||
protected static final long MILLIS_SECOND = 1000;
|
protected static final long MILLIS_SECOND = 1000;
|
||||||
|
|||||||
@ -21,8 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class UserDetailsServiceImpl implements UserDetailsService
|
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||||
{
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
@ -31,21 +30,15 @@ public class UserDetailsServiceImpl implements UserDetailsService
|
|||||||
private SysPermissionService permissionService;
|
private SysPermissionService permissionService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||||
{
|
|
||||||
SysUser user = userService.selectUserByUserName(username);
|
SysUser user = userService.selectUserByUserName(username);
|
||||||
if (StringUtils.isNull(user))
|
if (StringUtils.isNull(user)) {
|
||||||
{
|
|
||||||
log.info("登录用户:{} 不存在.", username);
|
log.info("登录用户:{} 不存在.", username);
|
||||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
throw new ServiceException("登录用户:" + username + " 不存在");
|
||||||
}
|
} else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
||||||
else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
|
|
||||||
{
|
|
||||||
log.info("登录用户:{} 已被删除.", username);
|
log.info("登录用户:{} 已被删除.", username);
|
||||||
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
||||||
}
|
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||||
else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
|
||||||
{
|
|
||||||
log.info("登录用户:{} 已被停用.", username);
|
log.info("登录用户:{} 已被停用.", username);
|
||||||
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
||||||
}
|
}
|
||||||
@ -53,8 +46,7 @@ public class UserDetailsServiceImpl implements UserDetailsService
|
|||||||
return createLoginUser(user);
|
return createLoginUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserDetails createLoginUser(SysUser user)
|
public UserDetails createLoginUser(SysUser user) {
|
||||||
{
|
|
||||||
return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
|
return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
"core-js": "3.8.1",
|
"core-js": "3.8.1",
|
||||||
"echarts": "4.9.0",
|
"echarts": "4.9.0",
|
||||||
"element-ui": "2.15.5",
|
"element-ui": "2.15.5",
|
||||||
"file-saver": "2.0.4",
|
"file-saver": "2.0.5",
|
||||||
"fuse.js": "6.4.3",
|
"fuse.js": "6.4.3",
|
||||||
"highlight.js": "9.18.5",
|
"highlight.js": "9.18.5",
|
||||||
"js-beautify": "1.13.0",
|
"js-beautify": "1.13.0",
|
||||||
|
|||||||
@ -17,7 +17,6 @@ import './assets/icons' // icon
|
|||||||
import './permission' // permission control
|
import './permission' // permission control
|
||||||
import { getDicts } from "@/api/system/dict/data";
|
import { getDicts } from "@/api/system/dict/data";
|
||||||
import { getConfigKey } from "@/api/system/config";
|
import { getConfigKey } from "@/api/system/config";
|
||||||
import { downLoadExcel } from "@/utils/download";
|
|
||||||
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi";
|
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi";
|
||||||
// 分页组件
|
// 分页组件
|
||||||
import Pagination from "@/components/Pagination";
|
import Pagination from "@/components/Pagination";
|
||||||
@ -44,7 +43,6 @@ Vue.prototype.resetForm = resetForm
|
|||||||
Vue.prototype.addDateRange = addDateRange
|
Vue.prototype.addDateRange = addDateRange
|
||||||
Vue.prototype.selectDictLabel = selectDictLabel
|
Vue.prototype.selectDictLabel = selectDictLabel
|
||||||
Vue.prototype.selectDictLabels = selectDictLabels
|
Vue.prototype.selectDictLabels = selectDictLabels
|
||||||
Vue.prototype.downLoadExcel = downLoadExcel
|
|
||||||
Vue.prototype.handleTree = handleTree
|
Vue.prototype.handleTree = handleTree
|
||||||
|
|
||||||
// 全局组件挂载
|
// 全局组件挂载
|
||||||
|
|||||||
71
ruoyi-ui/src/plugins/download.js
Normal file
71
ruoyi-ui/src/plugins/download.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import { saveAs } from 'file-saver'
|
||||||
|
import axios from 'axios'
|
||||||
|
import { getToken } from '@/utils/auth'
|
||||||
|
|
||||||
|
const baseURL = process.env.VUE_APP_BASE_API
|
||||||
|
|
||||||
|
export default {
|
||||||
|
excel(url, params) {
|
||||||
|
// get请求映射params参数
|
||||||
|
if (params) {
|
||||||
|
let urlparams = url + '?';
|
||||||
|
for (const propName of Object.keys(params)) {
|
||||||
|
const value = params[propName];
|
||||||
|
var part = encodeURIComponent(propName) + "=";
|
||||||
|
if (value !== null && typeof(value) !== "undefined") {
|
||||||
|
if (typeof value === 'object') {
|
||||||
|
for (const key of Object.keys(value)) {
|
||||||
|
if (value[key] !== null && typeof (value[key]) !== 'undefined') {
|
||||||
|
let params = propName + '[' + key + ']';
|
||||||
|
let subPart = encodeURIComponent(params) + '=';
|
||||||
|
urlparams += subPart + encodeURIComponent(value[key]) + '&';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
urlparams += part + encodeURIComponent(value) + "&";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
urlparams = urlparams.slice(0, -1);
|
||||||
|
url = urlparams;
|
||||||
|
}
|
||||||
|
url = baseURL + url
|
||||||
|
axios({
|
||||||
|
method: 'get',
|
||||||
|
url: url,
|
||||||
|
responseType: 'blob',
|
||||||
|
headers: { 'Authorization': 'Bearer ' + getToken() }
|
||||||
|
}).then(res => {
|
||||||
|
const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
|
||||||
|
this.saveAs(blob, decodeURI(res.headers['download-filename']))
|
||||||
|
})
|
||||||
|
},
|
||||||
|
oss(ossId, name) {
|
||||||
|
var url = baseURL + '/system/oss/download/' + ossId
|
||||||
|
axios({
|
||||||
|
method: 'get',
|
||||||
|
url: url,
|
||||||
|
responseType: 'blob',
|
||||||
|
headers: { 'Authorization': 'Bearer ' + getToken() }
|
||||||
|
}).then(res => {
|
||||||
|
const blob = new Blob([res.data], { type: 'application/octet-stream' })
|
||||||
|
this.saveAs(blob, name)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
zip(url, name) {
|
||||||
|
var url = baseURL + url
|
||||||
|
axios({
|
||||||
|
method: 'get',
|
||||||
|
url: url,
|
||||||
|
responseType: 'blob',
|
||||||
|
headers: { 'Authorization': 'Bearer ' + getToken() }
|
||||||
|
}).then(res => {
|
||||||
|
const blob = new Blob([res.data], { type: 'application/zip' })
|
||||||
|
this.saveAs(blob, name)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
saveAs(text, name, opts) {
|
||||||
|
saveAs(text, name, opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import cache from './cache'
|
import cache from './cache'
|
||||||
import modal from './modal'
|
import modal from './modal'
|
||||||
|
import download from './download'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
install(Vue) {
|
install(Vue) {
|
||||||
@ -7,5 +8,7 @@ export default {
|
|||||||
Vue.prototype.$cache = cache
|
Vue.prototype.$cache = cache
|
||||||
// 模态框对象
|
// 模态框对象
|
||||||
Vue.prototype.$modal = modal
|
Vue.prototype.$modal = modal
|
||||||
|
// 下载文件
|
||||||
|
Vue.prototype.$download = download
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,91 +0,0 @@
|
|||||||
import axios from 'axios'
|
|
||||||
import { getToken } from '@/utils/auth'
|
|
||||||
|
|
||||||
const mimeMap = {
|
|
||||||
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
||||||
zip: 'application/zip',
|
|
||||||
oss: 'application/octet-stream'
|
|
||||||
}
|
|
||||||
|
|
||||||
const baseUrl = process.env.VUE_APP_BASE_API
|
|
||||||
export function downLoadZip(str, filename) {
|
|
||||||
var url = baseUrl + str
|
|
||||||
axios({
|
|
||||||
method: 'get',
|
|
||||||
url: url,
|
|
||||||
responseType: 'blob',
|
|
||||||
headers: { 'Authorization': 'Bearer ' + getToken() }
|
|
||||||
}).then(res => {
|
|
||||||
resolveBlob(res, mimeMap.zip)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function downLoadOss(ossId) {
|
|
||||||
var url = baseUrl + '/system/oss/download/' + ossId
|
|
||||||
axios({
|
|
||||||
method: 'get',
|
|
||||||
url: url,
|
|
||||||
responseType: 'blob',
|
|
||||||
headers: { 'Authorization': 'Bearer ' + getToken() }
|
|
||||||
}).then(res => {
|
|
||||||
resolveBlob(res, mimeMap.oss)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function downLoadExcel(url, params) {
|
|
||||||
// get请求映射params参数
|
|
||||||
if (params) {
|
|
||||||
let urlparams = url + '?';
|
|
||||||
for (const propName of Object.keys(params)) {
|
|
||||||
const value = params[propName];
|
|
||||||
var part = encodeURIComponent(propName) + "=";
|
|
||||||
if (value !== null && typeof(value) !== "undefined") {
|
|
||||||
if (typeof value === 'object') {
|
|
||||||
for (const key of Object.keys(value)) {
|
|
||||||
if (value[key] !== null && typeof (value[key]) !== 'undefined') {
|
|
||||||
let params = propName + '[' + key + ']';
|
|
||||||
let subPart = encodeURIComponent(params) + '=';
|
|
||||||
urlparams += subPart + encodeURIComponent(value[key]) + '&';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
urlparams += part + encodeURIComponent(value) + "&";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
urlparams = urlparams.slice(0, -1);
|
|
||||||
url = urlparams;
|
|
||||||
}
|
|
||||||
url = baseUrl + url
|
|
||||||
axios({
|
|
||||||
method: 'get',
|
|
||||||
url: url,
|
|
||||||
responseType: 'blob',
|
|
||||||
headers: { 'Authorization': 'Bearer ' + getToken() }
|
|
||||||
}).then(res => {
|
|
||||||
resolveBlob(res, mimeMap.xlsx)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析blob响应内容并下载
|
|
||||||
* @param {*} res blob响应内容
|
|
||||||
* @param {String} mimeType MIME类型
|
|
||||||
*/
|
|
||||||
export function resolveBlob(res, mimeType) {
|
|
||||||
const aLink = document.createElement('a')
|
|
||||||
var blob = new Blob([res.data], { type: mimeType })
|
|
||||||
// //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名;
|
|
||||||
var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
|
|
||||||
var contentDisposition = decodeURI(res.headers['content-disposition'])
|
|
||||||
var result = patt.exec(contentDisposition)
|
|
||||||
var fileName = result[1]
|
|
||||||
fileName = fileName.replace(/\"/g, '')
|
|
||||||
aLink.style.display = 'none'
|
|
||||||
aLink.href = URL.createObjectURL(blob)
|
|
||||||
aLink.setAttribute('download', decodeURI(fileName)) // 设置下载文件名称
|
|
||||||
document.body.appendChild(aLink)
|
|
||||||
aLink.click()
|
|
||||||
URL.revokeObjectURL(aLink.href);//清除引用
|
|
||||||
document.body.removeChild(aLink);
|
|
||||||
}
|
|
||||||
@ -3,8 +3,6 @@
|
|||||||
* Copyright (c) 2019 ruoyi
|
* Copyright (c) 2019 ruoyi
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const baseURL = process.env.VUE_APP_BASE_API
|
|
||||||
|
|
||||||
// 日期格式化
|
// 日期格式化
|
||||||
export function parseTime(time, pattern) {
|
export function parseTime(time, pattern) {
|
||||||
if (arguments.length === 0 || !time) {
|
if (arguments.length === 0 || !time) {
|
||||||
|
|||||||
@ -358,7 +358,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/demo/demo/export', this.queryParams);
|
this.$download.excel('/demo/demo/export', this.queryParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -510,7 +510,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/monitor/job/export', this.queryParams);
|
this.$download.excel('/monitor/job/export', this.queryParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -293,7 +293,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/monitor/jobLog/export', this.queryParams);
|
this.$download.excel('/monitor/jobLog/export', this.queryParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -216,7 +216,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/monitor/logininfor/export', this.queryParams);
|
this.$download.excel('/monitor/logininfor/export', this.queryParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -303,7 +303,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/monitor/operlog/export', this.queryParams);
|
this.$download.excel('/monitor/operlog/export', this.queryParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -334,7 +334,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/system/config/export', this.queryParams);
|
this.$download.excel('/system/config/export', this.queryParams);
|
||||||
},
|
},
|
||||||
/** 刷新缓存按钮操作 */
|
/** 刷新缓存按钮操作 */
|
||||||
handleRefreshCache() {
|
handleRefreshCache() {
|
||||||
|
|||||||
@ -380,7 +380,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/system/dict/data/export', this.queryParams);
|
this.$download.excel('/system/dict/data/export', this.queryParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -338,7 +338,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/system/dict/type/export', this.queryParams);
|
this.$download.excel('/system/dict/type/export', this.queryParams);
|
||||||
},
|
},
|
||||||
/** 刷新缓存按钮操作 */
|
/** 刷新缓存按钮操作 */
|
||||||
handleRefreshCache() {
|
handleRefreshCache() {
|
||||||
|
|||||||
@ -188,7 +188,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listOss, delOss, changePreviewListResource } from "@/api/system/oss";
|
import { listOss, delOss, changePreviewListResource } from "@/api/system/oss";
|
||||||
import { downLoadOss } from "@/utils/download";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Oss",
|
name: "Oss",
|
||||||
@ -325,7 +324,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 下载按钮操作 */
|
/** 下载按钮操作 */
|
||||||
handleDownload(row) {
|
handleDownload(row) {
|
||||||
downLoadOss(row.ossId)
|
this.$download.oss(row.ossId)
|
||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
|
|||||||
@ -305,7 +305,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/system/post/export', this.queryParams);
|
this.$download.excel('/system/post/export', this.queryParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -613,7 +613,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/system/role/export', this.queryParams);
|
this.$download.excel('/system/role/export', this.queryParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -643,7 +643,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
this.downLoadExcel('/system/user/export', this.queryParams);
|
this.$download.excel('/system/user/export', this.queryParams);
|
||||||
},
|
},
|
||||||
/** 导入按钮操作 */
|
/** 导入按钮操作 */
|
||||||
handleImport() {
|
handleImport() {
|
||||||
@ -652,7 +652,7 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 下载模板操作 */
|
/** 下载模板操作 */
|
||||||
importTemplate() {
|
importTemplate() {
|
||||||
this.downLoadExcel('/system/user/importTemplate');
|
this.$download.excel('/system/user/importTemplate');
|
||||||
},
|
},
|
||||||
// 文件上传中处理
|
// 文件上传中处理
|
||||||
handleFileUploadProgress(event, file, fileList) {
|
handleFileUploadProgress(event, file, fileList) {
|
||||||
|
|||||||
@ -137,23 +137,13 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import draggable from 'vuedraggable'
|
import draggable from 'vuedraggable'
|
||||||
import { saveAs } from 'file-saver'
|
|
||||||
import beautifier from 'js-beautify'
|
import beautifier from 'js-beautify'
|
||||||
import ClipboardJS from 'clipboard'
|
import ClipboardJS from 'clipboard'
|
||||||
import render from '@/utils/generator/render'
|
import render from '@/utils/generator/render'
|
||||||
import RightPanel from './RightPanel'
|
import RightPanel from './RightPanel'
|
||||||
import {
|
import { inputComponents, selectComponents, layoutComponents, formConf } from '@/utils/generator/config'
|
||||||
inputComponents,
|
import { beautifierConf, titleCase } from '@/utils/index'
|
||||||
selectComponents,
|
import { makeUpHtml, vueTemplate, vueScript, cssStyle } from '@/utils/generator/html'
|
||||||
layoutComponents,
|
|
||||||
formConf
|
|
||||||
} from '@/utils/generator/config'
|
|
||||||
import {
|
|
||||||
exportDefault, beautifierConf, isNumberStr, titleCase
|
|
||||||
} from '@/utils/index'
|
|
||||||
import {
|
|
||||||
makeUpHtml, vueTemplate, vueScript, cssStyle
|
|
||||||
} from '@/utils/generator/html'
|
|
||||||
import { makeUpJs } from '@/utils/generator/js'
|
import { makeUpJs } from '@/utils/generator/js'
|
||||||
import { makeUpCss } from '@/utils/generator/css'
|
import { makeUpCss } from '@/utils/generator/css'
|
||||||
import drawingDefalut from '@/utils/generator/drawingDefalut'
|
import drawingDefalut from '@/utils/generator/drawingDefalut'
|
||||||
@ -161,7 +151,6 @@ import logo from '@/assets/logo/logo.png'
|
|||||||
import CodeTypeDialog from './CodeTypeDialog'
|
import CodeTypeDialog from './CodeTypeDialog'
|
||||||
import DraggableItem from './DraggableItem'
|
import DraggableItem from './DraggableItem'
|
||||||
|
|
||||||
const emptyActiveData = { style: {}, autosize: {} }
|
|
||||||
let oldActiveId
|
let oldActiveId
|
||||||
let tempActiveData
|
let tempActiveData
|
||||||
|
|
||||||
@ -287,7 +276,7 @@ export default {
|
|||||||
execDownload(data) {
|
execDownload(data) {
|
||||||
const codeStr = this.generateCode()
|
const codeStr = this.generateCode()
|
||||||
const blob = new Blob([codeStr], { type: 'text/plain;charset=utf-8' })
|
const blob = new Blob([codeStr], { type: 'text/plain;charset=utf-8' })
|
||||||
saveAs(blob, data.fileName)
|
this.$download.saveAs(blob, data.fileName)
|
||||||
},
|
},
|
||||||
execCopy(data) {
|
execCopy(data) {
|
||||||
document.getElementById('copyNode').click()
|
document.getElementById('copyNode').click()
|
||||||
|
|||||||
@ -180,7 +180,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
|
import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
|
||||||
import importTable from "./importTable";
|
import importTable from "./importTable";
|
||||||
import { downLoadZip } from "@/utils/download";
|
|
||||||
import hljs from "highlight.js/lib/highlight";
|
import hljs from "highlight.js/lib/highlight";
|
||||||
import "highlight.js/styles/github-gist.css";
|
import "highlight.js/styles/github-gist.css";
|
||||||
hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
|
hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
|
||||||
@ -270,7 +269,7 @@ export default {
|
|||||||
this.$modal.msgSuccess("成功生成到自定义路径:" + row.genPath);
|
this.$modal.msgSuccess("成功生成到自定义路径:" + row.genPath);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi");
|
this.$download.zip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 同步数据库操作 */
|
/** 同步数据库操作 */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user