RemoteUserService add getUserById方法 (项目中有需要 通过内部获取 user基础信息的需求)
This commit is contained in:
parent
17ff3db1b2
commit
1b2521712c
|
|
@ -1,11 +1,7 @@
|
|||
package com.ruoyi.system.api;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
|
|
@ -40,4 +36,14 @@ public interface RemoteUserService
|
|||
*/
|
||||
@PostMapping("/user/register")
|
||||
public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
|
||||
/**
|
||||
* 根据userId获取用户信息
|
||||
* @param userId 用户id,必填;
|
||||
* @param source 可选,header参数。 取值:{@link SecurityConstants#INNER}
|
||||
* @return 用户基础信息
|
||||
*/
|
||||
@GetMapping(value = "/user/getUserById")
|
||||
public R<SysUser> getUserById(@RequestParam(value = "userId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,12 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
{
|
||||
return R.fail("注册用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<SysUser> getUserById(Long userId, String source)
|
||||
{
|
||||
return R.fail("获取用户信息失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,4 +303,17 @@ public class SysUserController extends BaseController
|
|||
userService.insertUserAuth(userId, roleIds);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户编号获取用户基础信息(不包含权限信息、不含授权,用于内部调用)
|
||||
*/
|
||||
@InnerAuth
|
||||
@GetMapping(value = "getUserById")
|
||||
public R<SysUser> getUserById(Long userId)
|
||||
{
|
||||
if (userId == null) {
|
||||
return R.fail("getUserById:getUserId不能为空!");
|
||||
}
|
||||
return R.ok(userService.selectUserById(userId), "获取用户信息成功");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue