|
@@ -1,10 +1,14 @@
|
|
|
package com.github.zuihou.oauth.controller;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.github.zuihou.authority.dao.auth.StationUserLoginInfoMapper;
|
|
|
import com.github.zuihou.authority.dao.core.StationMapper;
|
|
|
import com.github.zuihou.authority.dto.auth.LoginParamDTO;
|
|
|
+import com.github.zuihou.authority.entity.auth.Role;
|
|
|
import com.github.zuihou.authority.entity.auth.StationUserLoginInfo;
|
|
|
+import com.github.zuihou.authority.service.auth.RoleService;
|
|
|
import com.github.zuihou.base.R;
|
|
|
import com.github.zuihou.common.constant.BizConstant;
|
|
|
import com.github.zuihou.context.BaseContextHandler;
|
|
@@ -30,6 +34,8 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.github.zuihou.utils.BizAssert.isFalse;
|
|
|
|
|
@@ -49,6 +55,8 @@ public class OauthController {
|
|
|
@Autowired
|
|
|
private ValidateCodeService validateCodeService;
|
|
|
@Autowired
|
|
|
+ private RoleService roleService;
|
|
|
+ @Autowired
|
|
|
private TokenGranterBuilder tokenGranterBuilder;
|
|
|
@Autowired
|
|
|
private AdminUiService authManager;
|
|
@@ -66,7 +74,7 @@ public class OauthController {
|
|
|
*/
|
|
|
@ApiOperation(value = "获取认证token", notes = "登录或者清空缓存时调用")
|
|
|
@PostMapping(value = "/token")
|
|
|
- public R<AuthInfo> login(@Validated @RequestBody LoginParamDTO login) throws BizException {
|
|
|
+ public R<UserInfo> login(@Validated @RequestBody LoginParamDTO login) throws BizException {
|
|
|
if (StrUtil.isEmpty(login.getTenant())) {
|
|
|
login.setTenant(BaseContextHandler.getTenant());
|
|
|
}
|
|
@@ -75,9 +83,19 @@ public class OauthController {
|
|
|
TokenGranter granter = tokenGranterBuilder.getGranter(login.getGrantType());
|
|
|
R<AuthInfo> userInfo = granter.grant(login);
|
|
|
|
|
|
+
|
|
|
+ UserInfo u = new UserInfo();
|
|
|
+ BeanUtil.copyProperties(userInfo.getData(), u);
|
|
|
+ //获取角色
|
|
|
+ List<Role> roleList= roleService.findRoleByUserId(u.getUserId());
|
|
|
+ if(CollectionUtil.isNotEmpty(roleList)){
|
|
|
+ String roles = roleList.stream().map(e -> e.getName()).collect(Collectors.joining(","));
|
|
|
+ u.setRoles(roles);
|
|
|
+ }
|
|
|
+
|
|
|
// 账号密码登录绑定当前登录用户和上下料站的绑定关系
|
|
|
// stationLoginInfo(login, userInfo);
|
|
|
- return userInfo;
|
|
|
+ return R.success(u);
|
|
|
}
|
|
|
|
|
|
/**
|