✨ 添加新特性。支持国际化、重构pigxresourceserver注解

This commit is contained in:
冷冷 committed 2018-11-14 21:02:26 +08:00
1 parent f8a9c21901
commit 0cd3f3fa65
53 files changed
+353 -101

No files matched your search

+4 -4
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-auth</artifactId>
@@ -42,13 +42,13 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms-api</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--security-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-security</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--JDBC相关-->
<dependency>
@@ -59,7 +59,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-cache</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<!--spring security 、oauth、jwt依赖-->
<dependency>
@@ -20,7 +20,7 @@
package com.pig4cloud.pigx.auth;
import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients;
import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
+2 -2
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-common-cache</artifactId>
@@ -38,7 +38,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<!--缓存依赖-->
<dependency>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-common-core</artifactId>
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.core.config;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
/**
* @author lengleng
* @date 2018/11/14
* <p>
* 国际化配置
*/
@Configuration
public class MessageSourceConfig {
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource
= new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:i18n/messages");
return messageSource;
}
}
@@ -76,4 +76,9 @@ public interface CommonConstant {
* spring boot admin 事件key
*/
String EVENT_KEY = "event_key";
/**
* 验证码前缀
*/
String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY";
}
@@ -24,6 +24,14 @@ package com.pig4cloud.pigx.common.core.constant;
* @date 2017-12-18
*/
public interface SecurityConstants {
/**
* 验证码有效期
*/
int CODE_TIME = 60;
/**
* 验证码长度
*/
int CODE_SIZE = 4;
/**
* 角色前缀
*/
@@ -57,15 +65,6 @@ public interface SecurityConstants {
*/
String MOBILE_TOKEN_URL = "/mobile/token";
/**
* 默认登录URL
*/
String OAUTH_TOKEN_URL = "/oauth/token";
/**
* grant_type
*/
String REFRESH_TOKEN = "refresh_token";
/**
* oauth 客户端信息
@@ -1,5 +1,5 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.pig4cloud.pigx.common.core.config.JacksonConfig,\
com.pig4cloud.pigx.common.core.config.MessageSourceConfig,\
com.pig4cloud.pigx.common.core.config.RestTemplateConfig,\
com.pig4cloud.pigx.common.core.exception.GlobalExceptionHandler,\
com.pig4cloud.pigx.common.core.util.SpringContextHolder
+2 -2
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-common-gateway</artifactId>
@@ -36,7 +36,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-common-job</artifactId>
+3 -3
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-common-log</artifactId>
@@ -38,13 +38,13 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--UPMS接口模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms-api</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--安全依赖获取上下文信息-->
<dependency>
+3 -3
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-common-security</artifactId>
@@ -38,7 +38,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--安全模块-->
<dependency>
@@ -49,7 +49,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms-api</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
</dependencies>
</project>
@@ -15,7 +15,7 @@
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.common.security.feign;
package com.pig4cloud.pigx.common.security.annotation;
import org.springframework.cloud.openfeign.EnableFeignClients;
@@ -38,4 +38,12 @@ import java.lang.annotation.*;
@EnableGlobalMethodSecurity(prePostEnabled = true)
@Import(PigxResourceServerAutoConfiguration.class)
public @interface EnablePigxResourceServer {
/**
* false:上下文获取用户名
* true: 上下文获取全部用户信息
*
* @return
*/
boolean details() default false;
}
@@ -17,6 +17,7 @@
package com.pig4cloud.pigx.common.security.component;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@@ -48,7 +49,8 @@ public class BaseResourceServerConfigurerAdapter extends ResourceServerConfigure
private PermitAllUrlProperties permitAllUrlProperties;
@Autowired
private RestTemplate lbRestTemplate;
@Setter
private boolean details;
/**
* 默认的配置,对外暴露
@@ -81,7 +83,11 @@ public class BaseResourceServerConfigurerAdapter extends ResourceServerConfigure
*/
@Override
public void configure(ResourceServerSecurityConfigurer resources) {
canGetUser(resources);
if (details) {
canGetUser(resources);
} else {
notGetUser(resources);
}
}
@@ -17,6 +17,8 @@
package com.pig4cloud.pigx.common.security.component;
import cn.hutool.core.util.ClassUtil;
import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
@@ -25,6 +27,8 @@ import org.springframework.context.annotation.Primary;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.web.client.RestTemplate;
import java.util.Set;
/**
* @author lengleng
* @date 2018/11/10
@@ -41,6 +45,14 @@ public class PigxResourceServerAutoConfiguration {
@Bean
@ConditionalOnMissingBean(ResourceServerConfigurerAdapter.class)
public ResourceServerConfigurerAdapter resourceServerConfigurerAdapter() {
return new BaseResourceServerConfigurerAdapter();
Set<Class<?>> classes = ClassUtil.scanPackageByAnnotation("com.pig4cloud.pigx", EnablePigxResourceServer.class);
boolean details = false;
for (Class<?> clazz : classes) {
details = clazz.getAnnotation(EnablePigxResourceServer.class).details();
}
BaseResourceServerConfigurerAdapter baseResourceServerConfigurerAdapter
= new BaseResourceServerConfigurerAdapter();
baseResourceServerConfigurerAdapter.setDetails(details);
return baseResourceServerConfigurerAdapter;
}
}
@@ -1,22 +1,20 @@
#
# Copyright (c) 2018-2025, lengleng All rights reserved.
#
# Copyright (c) 2018-2025, lengleng All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# Neither the name of the pig4cloud.com developer nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
# Author: lengleng (wangiegie@gmail.com)
# this list of conditions and the following disclaimer.
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# Neither the name of the pig4cloud.com developer nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
# Author: lengleng (wangiegie@gmail.com)
#
#
AbstractAccessDecisionManager.accessDenied=\u4E0D\u5141\u8BB8\u8BBF\u95EE
AbstractAccessDecisionManager.accessDenied=\u6743\u9650\u4E0D\u8DB3,\u4E0D\u5141\u8BB8\u8BBF\u95EE
AbstractLdapAuthenticationProvider.emptyPassword=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
AbstractSecurityInterceptor.authenticationNotFound=\u672A\u5728SecurityContext\u4E2D\u67E5\u627E\u5230\u8BA4\u8BC1\u5BF9\u8C61
AbstractUserDetailsAuthenticationProvider.badCredentials=\u7528\u6237\u540D\u4E0D\u5B58\u5728\u6216\u8005\u5BC6\u7801\u9519\u8BEF
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-common-swagger</artifactId>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-common-transaction</artifactId>
@@ -17,7 +17,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--lcn 模块端控制依赖-->
<dependency>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-common</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-config</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-eureka</artifactId>
+4 -4
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-gateway</artifactId>
@@ -46,7 +46,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-gateway</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<!--配置中心客户端-->
<dependency>
@@ -63,13 +63,13 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--缓存-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-cache</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<!--接口文档-->
<dependency>
@@ -19,6 +19,7 @@ package com.pig4cloud.pigx.gateway.config;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -49,10 +50,6 @@ public class KaptchaConfiguration {
*/
private static final String DEFAULT_IMAGE_HEIGHT = "40";
/**
* 默认生成图形验证码长度
*/
private static final String DEFAULT_IMAGE_LENGTH = "4";
/**
* 边框颜色,合法值: r,g,b (and optional alpha) 或者 white,black,blue.
*/
@@ -80,7 +77,7 @@ public class KaptchaConfiguration {
properties.put(KAPTCHA_IMAGE_WIDTH, DEFAULT_IMAGE_WIDTH);
properties.put(KAPTCHA_IMAGE_HEIGHT, DEFAULT_IMAGE_HEIGHT);
properties.put(KAPTCHA_IMAGE_FONT_SIZE, DEFAULT_IMAGE_FONT_SIZE);
properties.put(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, DEFAULT_IMAGE_LENGTH);
properties.put(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, SecurityConstants.CODE_SIZE);
Config config = new Config(properties);
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
defaultKaptcha.setConfig(config);
@@ -20,6 +20,7 @@ package com.pig4cloud.pigx.gateway.filter;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import com.pig4cloud.pigx.common.core.constant.CommonConstant;
import com.pig4cloud.pigx.common.core.exception.CheckedException;
import com.pig4cloud.pigx.common.core.exception.ValidateCodeException;
import com.pig4cloud.pigx.gateway.config.FilterIgnorePropertiesConfig;
@@ -45,8 +46,7 @@ import java.io.IOException;
@Component
@AllArgsConstructor
public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
public static final String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY";
public static final String OAUTH_TOKEN_URL = "/oauth/token";
static final String OAUTH_TOKEN_URL = "/oauth/token";
private static final String BASIC_ = "Basic ";
private final RedisTemplate redisTemplate;
private final FilterIgnorePropertiesConfig filterIgnorePropertiesConfig;
@@ -157,7 +157,7 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
throw new ValidateCodeException();
}
String key = DEFAULT_CODE_KEY + randomStr;
String key = CommonConstant.DEFAULT_CODE_KEY + randomStr;
if (!redisTemplate.hasKey(key)) {
throw new ValidateCodeException();
}
@@ -18,7 +18,8 @@
package com.pig4cloud.pigx.gateway.handler;
import com.google.code.kaptcha.Producer;
import com.pig4cloud.pigx.gateway.filter.ValidateCodeGatewayFilter;
import com.pig4cloud.pigx.common.core.constant.CommonConstant;
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ByteArrayResource;
@@ -58,7 +59,8 @@ public class ImageCodeHandler implements HandlerFunction<ServerResponse> {
//保存验证码信息
String randomStr = serverRequest.queryParam("randomStr").get();
redisTemplate.opsForValue().set(ValidateCodeGatewayFilter.DEFAULT_CODE_KEY + randomStr, text, 60, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(CommonConstant.DEFAULT_CODE_KEY + randomStr, text
, SecurityConstants.CODE_TIME, TimeUnit.SECONDS);
// 转换流信息写出
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
+2 -2
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-upms-api</artifactId>
@@ -38,7 +38,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
</dependencies>
</project>
+7 -7
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-upms-biz</artifactId>
@@ -37,25 +37,25 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms-api</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--日志处理-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-log</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--缓存依赖-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-cache</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<!--swagger-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-swagger</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--eureka 客户端-->
<dependency>
@@ -71,13 +71,13 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-security</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--支持动态路由配置 -->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-gateway</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<!--mybatis-->
<dependency>
@@ -20,8 +20,8 @@
package com.pig4cloud.pigx.admin;
import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients;
import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer;
import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients;
import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
@@ -34,7 +34,7 @@ import org.springframework.cloud.client.SpringCloudApplication;
@EnablePigxSwagger2
@SpringCloudApplication
@EnablePigxFeignClients
@EnablePigxResourceServer
@EnablePigxResourceServer(details = true)
public class PigxAdminApplication {
public static void main(String[] args) {
SpringApplication.run(PigxAdminApplication.class, args);
@@ -25,6 +25,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysDept;
import com.pig4cloud.pigx.admin.service.SysDeptService;
import com.pig4cloud.pigx.common.core.constant.CommonConstant;
import com.pig4cloud.pigx.common.core.util.R;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -44,6 +45,7 @@ import java.util.List;
@RestController
@AllArgsConstructor
@RequestMapping("/dept")
@Api(value = "dept", description = "部门管理模块")
public class DeptController {
private final SysDeptService sysDeptService;
@@ -28,6 +28,7 @@ import com.pig4cloud.pigx.common.core.constant.CommonConstant;
import com.pig4cloud.pigx.common.core.util.Query;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
@@ -49,6 +50,7 @@ import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/dict" )
@Api(value = "dict",description = "字典管理模块")
public class DictController {
private final SysDictService sysDictService;
@@ -27,6 +27,7 @@ import com.pig4cloud.pigx.admin.api.vo.PreLogVo;
import com.pig4cloud.pigx.admin.service.SysLogService;
import com.pig4cloud.pigx.common.core.util.Query;
import com.pig4cloud.pigx.common.core.util.R;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -44,8 +45,9 @@ import java.util.Map;
* @since 2017-11-20
*/
@RestController
@RequestMapping("/log")
@AllArgsConstructor
@RequestMapping("/log")
@Api(value = "log",description = "日志管理模块")
public class LogController {
private final SysLogService sysLogService;
@@ -28,6 +28,7 @@ import com.pig4cloud.pigx.admin.service.SysMenuService;
import com.pig4cloud.pigx.common.core.constant.CommonConstant;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -46,6 +47,7 @@ import java.util.stream.Collectors;
@RestController
@AllArgsConstructor
@RequestMapping("/menu")
@Api(value = "menu",description = "菜单管理模块")
public class MenuController {
private final SysMenuService sysMenuService;
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.controller;
import com.pig4cloud.pigx.admin.service.MobileService;
import com.pig4cloud.pigx.common.core.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
/**
* @author lengleng
* @date 2018/11/14
* <p>
* 手机验证码
*/
@RestController
@AllArgsConstructor
@RequestMapping("/mobile")
@Api(value = "mobile",description = "手机管理模块")
public class MobileController {
private final MobileService mobileService;
@ResponseBody
@GetMapping("/{mobile}")
@ApiOperation(value = "发送手机验证码", httpMethod = "GET")
@ApiImplicitParam(name = "mobile", value = "手机号", paramType = "path", type = "string", required = true)
public R<Boolean> code(@PathVariable String mobile) {
return mobileService.sendSmsCode(mobile);
}
}
@@ -25,6 +25,7 @@ import com.pig4cloud.pigx.admin.api.entity.SysOauthClientDetails;
import com.pig4cloud.pigx.admin.service.SysOauthClientDetailsService;
import com.pig4cloud.pigx.common.core.util.Query;
import com.pig4cloud.pigx.common.core.util.R;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -43,6 +44,7 @@ import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/client")
@Api(value = "client",description = "客户端管理模块")
public class OauthClientDetailsController {
private final SysOauthClientDetailsService sysOauthClientDetailsService;
@@ -27,6 +27,7 @@ import com.pig4cloud.pigx.admin.service.SysRoleService;
import com.pig4cloud.pigx.common.core.constant.CommonConstant;
import com.pig4cloud.pigx.common.core.util.Query;
import com.pig4cloud.pigx.common.core.util.R;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -41,6 +42,7 @@ import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/role")
@Api(value = "role",description = "角色管理模块")
public class RoleController {
private final SysRoleService sysRoleService;
private final SysRoleMenuService sysRoleMenuService;
@@ -20,6 +20,7 @@ package com.pig4cloud.pigx.admin.controller;
import cn.hutool.json.JSONArray;
import com.pig4cloud.pigx.admin.service.SysRouteConfService;
import com.pig4cloud.pigx.common.core.util.R;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
@@ -33,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
@RestController
@AllArgsConstructor
@RequestMapping("/route")
@Api(value = "route",description = "动态路由管理模块")
public class SysRouteConfController {
private final SysRouteConfService sysRouteConfService;
@@ -25,6 +25,7 @@ import com.pig4cloud.pigx.admin.service.SysSocialDetailsService;
import com.pig4cloud.pigx.admin.service.SysUserService;
import com.pig4cloud.pigx.common.core.util.Query;
import com.pig4cloud.pigx.common.core.util.R;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
@@ -41,6 +42,7 @@ import java.util.Map;
@RestController
@RequestMapping("/social")
@AllArgsConstructor
@Api(value = "social",description = "三方账号管理模块")
public class SysSocialDetailsController {
private final SysUserService sysUserService;
private final SysSocialDetailsService sysSocialDetailsService;
@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.plugins.Page;
import com.pig4cloud.pigx.admin.api.feign.RemoteTokenService;
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import com.pig4cloud.pigx.common.core.util.R;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -35,6 +36,7 @@ import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/token")
@Api(value = "token",description = "令牌管理模块")
public class TokenController {
private final RemoteTokenService remoteTokenService;
@@ -35,6 +35,7 @@ import com.pig4cloud.pigx.common.core.util.Query;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
@@ -55,6 +56,7 @@ import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/user")
@Api(value = "user", description = "用户管理模块")
public class UserController {
private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder();
private final SysUserService userService;
@@ -116,7 +118,7 @@ public class UserController {
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('sys_user_del')")
@ApiOperation(value = "删除用户", notes = "根据ID删除用户")
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "int", paramType = "path", example = "1000")
@ApiImplicitParam(name = "id", value = "用户ID", required = true, dataType = "int", paramType = "path")
public R<Boolean> userDel(@PathVariable Integer id) {
SysUser sysUser = userService.selectById(id);
return new R<>(userService.deleteUserById(sysUser));
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.service;
import com.pig4cloud.pigx.common.core.util.R;
/**
* @author lengleng
* @date 2018/11/14
*/
public interface MobileService {
/**
* 发送手机验证码
*
* @param mobile mobile
* @return code
*/
R<Boolean> sendSmsCode(String mobile);
}
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.pig4cloud.pigx.admin.api.entity.SysUser;
import com.pig4cloud.pigx.admin.mapper.SysUserMapper;
import com.pig4cloud.pigx.admin.service.MobileService;
import com.pig4cloud.pigx.common.core.constant.CommonConstant;
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import com.pig4cloud.pigx.common.core.util.R;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* @author lengleng
* @date 2018/11/14
* <p>
* 手机登录相关业务实现
*/
@Slf4j
@Service
@AllArgsConstructor
public class MobileServiceImpl implements MobileService {
private final RedisTemplate redisTemplate;
private final SysUserMapper userMapper;
/**
* 发送手机验证码
* TODO: 调用短信网关发送验证码,测试返回前端
*
* @param mobile mobile
* @return code
*/
@Override
public R<Boolean> sendSmsCode(String mobile) {
SysUser condition = new SysUser();
condition.setPhone(mobile);
List<SysUser> userList = userMapper.selectList(new EntityWrapper<>(condition));
if (CollUtil.isEmpty(userList)) {
log.info("手机号未注册:{}", mobile);
return new R<>(Boolean.FALSE, "手机号未注册");
}
Object codeObj = redisTemplate.opsForValue().get(CommonConstant.DEFAULT_CODE_KEY + mobile);
if (codeObj != null) {
log.info("手机号验证码未过期:{},{}", mobile, codeObj);
return new R<>(Boolean.FALSE, "手机号未注册");
}
String code = RandomUtil.randomNumbers(4);
log.debug("手机号生成验证码成功:{},{}", mobile, code);
redisTemplate.opsForValue().set(CommonConstant.DEFAULT_CODE_KEY + mobile, code
, SecurityConstants.CODE_TIME, TimeUnit.SECONDS);
return new R<>(Boolean.TRUE, code);
}
}
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-upms</artifactId>
+5 -5
View File
@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-activiti</artifactId>
@@ -41,12 +41,12 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-upms-api</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
@@ -111,12 +111,12 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-swagger</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-security</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<!--undertow容器-->
<dependency>
+4 -4
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-codegen</artifactId>
@@ -34,19 +34,19 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--swagger-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-swagger</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--安全模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-security</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--代码生成模板引擎-->
<dependency>
@@ -18,7 +18,7 @@
package com.pig4cloud.pigx.codegen;
import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer;
import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients;
import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients;
import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
+4 -4
View File
@@ -23,7 +23,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-daemon</artifactId>
@@ -41,7 +41,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-job</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--mybatis-->
<dependency>
@@ -68,13 +68,13 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-swagger</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!-- 安全模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-security</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
<!--web 模块-->
<dependency>
@@ -19,7 +19,7 @@ package com.pig4cloud.pigx.daemon;
import com.pig4cloud.pigx.common.job.annotation.EnablePigxJob;
import com.pig4cloud.pigx.common.security.annotation.EnablePigxResourceServer;
import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients;
import com.pig4cloud.pigx.common.security.annotation.EnablePigxFeignClients;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
+3 -3
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-monitor</artifactId>
@@ -36,12 +36,12 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-cache</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
</dependency>
<!--监控服务端-->
<dependency>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-visual</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-tx-manager</artifactId>
@@ -63,7 +63,7 @@
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-core</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</dependency>
</dependencies>
<build>
+1 -1
View File
@@ -24,7 +24,7 @@
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
</parent>
<artifactId>pigx-visual</artifactId>
+1 -1
View File
@@ -24,7 +24,7 @@
<groupId>com.pig4cloud</groupId>
<artifactId>pigx</artifactId>
<version>1.7.1</version>
<version>1.8.0</version>
<name>${project.artifactId}</name>
<packaging>pom</packaging>
<url>https://www.pig4cloud.com</url>