提交 42b044c5 编写于 作者: 门心叼龙's avatar 门心叼龙

code perfect

上级 25296ca5
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GrepConsole">
<option name="pinnedGrepConsolesState">
<PinnedGrepConsolesState>
<option name="map">
<map>
<entry>
<key>
<RunConfigurationRef>
<option name="icon" value="SpringBoot.svg" />
<option name="name" value="EurekaServerApplication" />
</RunConfigurationRef>
</key>
<value>
<Pins />
</value>
</entry>
<entry>
<key>
<RunConfigurationRef>
<option name="icon" value="SpringBoot.svg" />
<option name="name" value="UserServiceApplication" />
</RunConfigurationRef>
</key>
<value>
<Pins />
</value>
</entry>
<entry>
<key>
<RunConfigurationRef>
<option name="icon" value="SpringBoot.svg" />
<option name="name" value="LogServiceApplication" />
</RunConfigurationRef>
</key>
<value>
<Pins />
</value>
</entry>
<entry>
<key>
<RunConfigurationRef>
<option name="icon" value="SpringBoot.svg" />
<option name="name" value="UaaServiceApplication" />
</RunConfigurationRef>
</key>
<value>
<Pins />
</value>
</entry>
</map>
</option>
</PinnedGrepConsolesState>
</option>
</component>
</project>
\ No newline at end of file
{"code":1002,"error":"获取token失败","data":null}
\ No newline at end of file
{"code":1002,"error":"获取token失败","data":null}
\ No newline at end of file
{"timestamp":1583749657394,"status":500,"error":"Internal Server Error","exception":"java.lang.ArithmeticException","message":"/ by zero","path":"/user/login"}
\ No newline at end of file
{"code":1002,"error":"获取token失败","data":null}
\ No newline at end of file
{"timestamp":1583751020496,"status":500,"error":"Internal Server Error","exception":"java.lang.RuntimeException","message":"Big bug","path":"/user/login"}
\ No newline at end of file
{"code":1002,"error":"获取token失败","data":null}
\ No newline at end of file
{"code":1002,"error":"获取token失败","data":null}
\ No newline at end of file
{"code":1002,"error":"获取token失败","data":null}
\ No newline at end of file
{"timestamp":1583768420665,"status":500,"error":"Internal Server Error","exception":"java.lang.ArithmeticException","message":"/ by zero","path":"/user/login"}
\ No newline at end of file
POST http://192.168.31.105:8762/user/login?username=gxl&password=123456
POST http://192.168.31.105:5000/newsapi/newstype//query/all?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODQwOTQ5MDcsInVzZXJfbmFtZSI6Imd4bCIsImF1dGhvcml0aWVzIjpbIlJPTEVfVVNFUiIsIlJPTEVfQURNSU4iXSwianRpIjoiNGM3MzM5YTItYjcwMi00Mjc0LWEzYzgtYzgzZGY4ODc4OTcwIiwiY2xpZW50X2lkIjoidWFhLXNlcnZpY2UiLCJzY29wZSI6WyJzZXJ2aWNlIl19.HVX2Ka9wV1a6rOseCFoAdLVHigpI6wzPUN1Tr_ZGpUGaX7TrqFIr-GmEMkKny5krCWEznz4BKtAEfDy_hoKS4T0SV1DwkQpfKR_nWbd9TvLQhJcL7PgXgkUZGijo-9Uk2n4lIzgVCnBBvUfVFDnXeTHwHbi_6INmbv6nh3qD6HeDgbUe4EWBhRZQ_fR-fxiNlqRWiz9rLWPZYhy_kbOg11ymkPM0BEaJT0S9UitfhKu3Hz06fkI0tGdH2xmwjh6N0Rzbpw8sjIxJIswlw2C4GUXx7qB8V-X4FfWyYblHJgz0hN120EniWaT4nx9BiEx6RAGBV4LMH4h6F6dcZEkDZw
<> 2020-03-12T062324.200.json
###
POST http://192.168.31.105:5000/newsapi/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-12T062209.401.json
###
POST http://192.168.31.105:5000/userapi/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-12T062147.200.json
###
POST http://192.168.31.105:5000/userapi/user/login?password=123&username=gyp
Accept: */*
Cache-Control: no-cache
<> 2020-03-12T025017.200.json
###
POST http://192.168.31.105:8762/userapi/user/login?password=123&username=gyp
Accept: */*
Cache-Control: no-cache
<> 2020-03-12T025008.401.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyp
Accept: */*
Cache-Control: no-cache
<> 2020-03-12T024947.200.json
###
POST http://192.168.31.105:5000/userapi/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-12T024846.200.json
###
POST http://192.168.31.105:5000/userapi/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-12T024830.200.json
###
POST http://192.168.31.105:8762/userapi/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-12T024813.401.json
###
POST http://192.168.31.105:8762/userapi/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-12T024811.401.json
###
POST http://192.168.31.105:8762/abc/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-12T024724.401.json
###
POST http://192.168.31.105:8762/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-12T024702.200.json
###
POST http://192.168.31.105:8762/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T030237.200.json
###
POST http://192.168.31.105:8762/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T030049.200.json
###
POST http://192.168.31.105:8762/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T030037.200.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyc
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T025541.200.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyp
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T025224.200.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyc
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T025107.200.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyc
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T025106.200.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyc
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T024831.200.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyc
Accept: */*
Cache-Control: no-cache
<> 2020-03-09T114020.500.json
<> 2020-03-11T024830.200.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyc
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T024829.200.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyc
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T024740.200.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyc
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T024606.200.json
###
POST http://192.168.31.105:8762/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T022745.200.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyc
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T022519.200.json
###
POST http://192.168.31.105:8762/user/login?password=123&username=gyc
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T022310.200.json
###
POST http://192.168.31.105:8762/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T021933.200.json
###
POST http://192.168.31.105:8762/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T021928.200.json
###
POST http://192.168.31.105:8762/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T021926.200.json
###
POST http://192.168.31.105:8762/user/login?password=123456&username=gxl
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T021923.200.json
###
......@@ -10,7 +251,7 @@ POST http://192.168.31.105:8762/user/login?username=gxl&password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-09T075630.200.json
<> 2020-03-11T021025.200.json
###
......@@ -18,7 +259,7 @@ POST http://192.168.31.105:8762/user/login?username=gxl&password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-09T075613.200.json
<> 2020-03-11T021023.200.json
###
......@@ -26,7 +267,23 @@ POST http://192.168.31.105:8762/user/login?username=gxl&password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-09T072234.200.json
<> 2020-03-11T021007.200.json
###
POST http://192.168.31.105:8762/user/login?username=gyc&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T020430.200.json
###
POST http://192.168.31.105:8762/user/login?username=gyc&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T020418.200.json
###
......@@ -34,7 +291,29 @@ POST http://192.168.31.105:8762/user/login?username=gxl&password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-09T065020.500.json
###
POST http://192.168.31.105:8762/user/login?username=gyc&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T015836.200.json
###
POST http://192.168.31.105:8762/user/login?username=gyc&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T015820.200.json
###
POST http://192.168.31.105:8762/user/login?username=gyc&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T015516.200.json
###
......@@ -42,7 +321,7 @@ POST http://192.168.31.105:8762/user/login?username=gxl&password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-09T064526.200.json
<> 2020-03-11T015431.200.json
###
......@@ -50,7 +329,15 @@ POST http://192.168.31.105:8762/user/login?username=gxl&password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-09T062737.500.json
<> 2020-03-11T015426.200.json
###
POST http://192.168.31.105:8762/user/login?username=gyp&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T015013.200.json
###
......@@ -58,21 +345,55 @@ POST http://192.168.31.105:8762/user/login?username=gxl&password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-09T062531.200.json
<> 2020-03-11T014948.200.json
###
POST http://192.168.31.105:8762/user/login?username=gyp&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T014655.200.json
###
POST http://192.168.31.105:8762/user/login?username=gyp&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T014654.200.json
###
POST http://192.168.31.105:8762/user/login?username=gyp&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T014649.200.json
###
POST http://192.168.31.102:8762/user/login?username=gxl&password=123456
POST http://192.168.31.105:8762/user/login?username=gyp&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T014644.200.json
###
POST http://192.168.31.105:8762/user/login?username=gyp&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-11T014642.200.json
###
POST http://laptop-btkihh20:8762/user/login?username=gxl&password=123456
POST http://192.168.31.105:8762/user/login?username=gyp&password=123
Accept: */*
Cache-Control: no-cache
<> 2020-03-09T062234.200.json
<> 2020-03-11T014638.200.json
###
#hystrix:
# command:
# default:
# execution:
# isolation:
# thread:
# timeoutInMilliseconds: 20000
hystrix:
threadpool.default.coreSize: "20"
threadpool.default.maxQueueSize: "500000"
threadpool.default.keepAliveTimeMinutes: "2"
threadpool.default.queueSizeRejectionThreshold: "500000"
command:
default:
fallback.isolation.semaphore.maxConcurrentRequests: "20"
execution:
timeout:
enabled: "false"
isolation:
strategy: "THREAD"
thread:
timeoutInMilliseconds: 20000
timeoutInMilliseconds: "30000"
ribbon:
eager-load:
enabled: true
clients: user-service,news-service
ReadTimeout: 20000
ConnectTimeout: 20000
zuul:
ribbon:
eager-load:
enabled: true
host:
connect-timeout-millis: 20000
socket-timeout-millis: 20000
......@@ -21,6 +44,11 @@ zuul:
serviceId: user-service
sensitiveHeaders:
news-service:
path: /newsapi/**
serviceId: news-service
sensitiveHeaders:
blog-service:
path: /blogapi/**
serviceId: blog-service
......
......@@ -13,12 +13,13 @@ import org.springframework.stereotype.Service;
* Update:     <br>
*/
@Service
public class SysLogService {
public class SysLogService {
@Autowired
SysLogDAO sysLogDAO;
public void saveLogger(SysLog sysLog){
System.out.println("MYTAG:Logger saveLogger start...");
sysLogDAO.save(sysLog);
}
}
......@@ -36,7 +36,7 @@ public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
log.info("Configuring ResourceServerSecurityConfigurer ");
resources.resourceId("user-service").tokenStore(tokenStore);
resources.resourceId("news-service").tokenStore(tokenStore);
}
@Autowired
......
......@@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
......@@ -38,7 +39,11 @@ public class OAuth2Config extends AuthorizationServerConfigurerAdapter {
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.tokenStore(tokenStore()).tokenEnhancer(jwtTokenEnhancer()).authenticationManager(authenticationManager);
endpoints
.tokenStore(tokenStore())
.tokenEnhancer(jwtTokenEnhancer())
.allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST)
.authenticationManager(authenticationManager);
}
@Autowired
......
......@@ -39,6 +39,7 @@ public class SysLoggerAspect {
@Before("loggerPointCut()")
public void saveSysLog(JoinPoint joinPoint) {
System.out.println("MYTAG:User SysLoggerAspect saveLogger start...");
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
......
......@@ -27,7 +27,7 @@ public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter
http
.csrf().disable()
.authorizeRequests()
.regexMatchers(".*swagger.*",".*v2.*",".*webjars.*","/user/login.*","/user/registry.*","/user/test.*").permitAll()
.regexMatchers(".*swagger.*",".*v2.*",".*webjars.*","/user/hi.*","/user/login.*","/user/registry.*","/user/test.*").permitAll()
.antMatchers("/**").authenticated();
// .antMatchers("/**").permitAll();
}
......
......@@ -22,6 +22,7 @@ public class LoggerService {
private AmqpTemplate rabbitTemplate;
public void log(SysLog sysLog){
System.out.println("MYTAG:User LoggerService log start...");
rabbitTemplate.convertAndSend(RabbitConfig.queueName, JSON.toJSONString(sysLog));
}
}
......@@ -39,7 +39,6 @@ public class UserService {
public RespDTO login(String username, String password) {
User user = userDao.findByUsername(username);
int a = 1/0;
if (null == user) {
throw new CommonException(ErrorCode.USER_NOT_FOUND);
}
......@@ -47,7 +46,9 @@ public class UserService {
throw new CommonException(ErrorCode.USER_PASSWORD_ERROR);
}
JWT jwt = authServiceClient.getToken("Basic dWFhLXNlcnZpY2U6MTIzNDU2", "password", username, password);
// 获得用户菜单
if (null == jwt) {
jwt = authServiceClient.getToken("Basic dWFhLXNlcnZpY2U6MTIzNDU2", "password", username, password);
}
if (null == jwt) {
throw new CommonException(ErrorCode.GET_TOKEN_FAIL);
}
......
......@@ -7,6 +7,7 @@ import com.fly.user.service.UserService;
import com.fly.user.util.BPwdEncoderUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
......@@ -52,4 +53,11 @@ public class UserController {
User user= userService.getUserInfo(username);
return RespDTO.onSuc(user);
}
@Value("${server.port}")
String port;
@GetMapping("/hi")
public String home(@RequestParam String name) {
return "hi "+name+",i am from port:" +port;
}
}
......@@ -8,6 +8,42 @@ spring:
profiles:
active: pro
### Feign 配置
feign:
# 是否开启断路器(熔断器)
hystrix:
enabled: false
client:
config:
default:
connect-timeout: 20000
read-timeout: 20000
#hystrix:
# command:
# default:
# execution:
# timeout:
# # 禁用熔断器超时时间,不推荐
# enabled: false
#### Hystrix 配置
#hystrix:
# command:
# default:
# execution:
# isolation:
# thread:
# # 熔断器超时时间,默认:1000/毫秒
# timeoutInMilliseconds: 1000 * 10
#### Feign 配置
#feign:
# # 是否开启断路器(熔断器)
# hystrix:
# enabled: false
# datasource:
# driver-class-name: com.mysql.jdbc.Driver
# url: jdbc:mysql://localhost:3306/spring-cloud-auth?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册