yq hace 2 años
padre
commit
baa0ce6ee3

+ 1 - 0
eladmin-system/pom.xml

@@ -120,6 +120,7 @@
 
     <!-- 打包 -->
     <build>
+        <finalName>zhcy</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>

+ 24 - 0
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java

@@ -135,6 +135,30 @@ public class AuthorizationController {
         return ResponseEntity.ok(authInfo);
     }
 
+    @ApiOperation("登录授权")
+    @AnonymousPostMapping(value = "/login3")
+    public ResponseEntity<Object> login3(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
+        UsernamePasswordAuthenticationToken authenticationToken =
+                new UsernamePasswordAuthenticationToken(authUser.getUsername(), authUser.getPassword());
+        Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
+        SecurityContextHolder.getContext().setAuthentication(authentication);
+        // 生成令牌
+        String token = tokenProvider.createToken(authentication);
+        final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal();
+        // 保存在线信息
+        onlineUserService.save(jwtUserDto, token, request);
+        // 返回 token 与 用户信息
+        Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
+            put("token", properties.getTokenStartWith() + token);
+            put("user", jwtUserDto);
+        }};
+        if (loginProperties.isSingleLogin()) {
+            //踢掉之前已经登录的token
+            onlineUserService.checkLoginOnUser(authUser.getUsername(), token);
+        }
+        return ResponseEntity.ok(authInfo);
+    }
+
     @ApiOperation("获取用户信息")
     @GetMapping(value = "/info")
     public ResponseEntity<Object> getUserInfo() {

+ 3 - 3
eladmin-system/src/main/resources/config/application-dev.yml

@@ -7,9 +7,9 @@ spring:
 #      url: jdbc:log4jdbc:mysql://114.55.24.6:3308/dm_restaurant?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
 #      username: root
 #      password: shimao@123
-      url: jdbc:log4jdbc:mysql://10.23.39.230:13306/dm_restaurant?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
-      username: dm_restaurant
-      password: V24U7Khu
+      url: jdbc:log4jdbc:mysql://101.133.214.75:3306/dm_restaurant?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
+      username: usky
+      password: Yt#75Usky
       # 初始连接数
       initial-size: 5
       # 最小连接数

+ 1 - 1
eladmin-system/src/main/resources/config/application.yml

@@ -1,5 +1,5 @@
 server:
-  port: 1537
+  port: 1539
 
 spring:
   main: