|
@@ -2,6 +2,9 @@ package com.ozs.web.controller.system;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
+
|
|
|
+import com.ozs.common.core.domain.model.LoginUser;
|
|
|
+import com.ozs.framework.web.service.TokenService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import com.ozs.common.constant.Constants;
|
|
@@ -22,8 +25,7 @@ import com.ozs.system.service.ISysMenuService;
|
|
|
@RestController
|
|
|
//@RequestMapping("/app")
|
|
|
@RequestMapping("")
|
|
|
-public class SysLoginController
|
|
|
-{
|
|
|
+public class SysLoginController {
|
|
|
@Autowired
|
|
|
private SysLoginService loginService;
|
|
|
|
|
@@ -33,6 +35,9 @@ public class SysLoginController
|
|
|
@Autowired
|
|
|
private SysPermissionService permissionService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+
|
|
|
/**
|
|
|
* 登录方法
|
|
|
*
|
|
@@ -40,13 +45,18 @@ public class SysLoginController
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@PostMapping("/login")
|
|
|
- public AjaxResult login(@RequestBody LoginBody loginBody)
|
|
|
- {
|
|
|
+ public AjaxResult login(@RequestBody LoginBody loginBody) {
|
|
|
AjaxResult ajax = AjaxResult.success();
|
|
|
// 生成令牌
|
|
|
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
|
|
loginBody.getUuid());
|
|
|
ajax.put(Constants.TOKEN, token);
|
|
|
+ LoginUser loginedUser = tokenService.getLoginedUserByToken(token);
|
|
|
+ if (loginedUser != null) {
|
|
|
+ ajax.put("userId", loginedUser.getUserId());
|
|
|
+ ajax.put("username", loginedUser.getUsername());
|
|
|
+ ajax.put("avatar", loginedUser.getUser() != null ? loginedUser.getUser().getAvatar() : "");
|
|
|
+ }
|
|
|
return ajax;
|
|
|
}
|
|
|
|