|
|
@@ -14,16 +14,15 @@ import com.fs.framework.security.LoginUser;
|
|
|
import com.fs.framework.service.CompanyLoginService;
|
|
|
import com.fs.framework.service.CompanyPermissionService;
|
|
|
import com.fs.framework.service.TokenService;
|
|
|
+import com.fs.framework.service.UserDetailsBynameServiceImpl;
|
|
|
import com.fs.system.domain.SysConfig;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.security.core.userdetails.UserDetails;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 登录验证
|
|
|
@@ -48,6 +47,8 @@ public class CompanyLoginController
|
|
|
private RedisCache redisCache;
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
+ @Autowired
|
|
|
+ private UserDetailsBynameServiceImpl userDetailsBynameService;
|
|
|
|
|
|
/**
|
|
|
* 登录方法
|
|
|
@@ -70,6 +71,21 @@ public class CompanyLoginController
|
|
|
return ajax;
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/login2")
|
|
|
+ public AjaxResult login2(@RequestBody LoginBody loginBody) {
|
|
|
+
|
|
|
+ UserDetails userDetails = userDetailsBynameService.loadUserByUsername(loginBody.getUsername());
|
|
|
+ if (ObjectUtils.isEmpty(userDetails)) {
|
|
|
+ AjaxResult ajax = AjaxResult.error("账号不存在");
|
|
|
+ return ajax;
|
|
|
+ }
|
|
|
+ AjaxResult ajax = AjaxResult.success();
|
|
|
+ // 生成令牌
|
|
|
+ String token = loginService.login2(loginBody.getUsername());
|
|
|
+ ajax.put(Constants.TOKEN, token);
|
|
|
+ return ajax;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取用户信息
|