RemoteUserService add getUserById方法 (项目中有需要 通过内部获取 user基础信息的需求)

pull/102/head
duandazhi 4 years ago
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;
@ -15,7 +11,7 @@ import com.ruoyi.system.api.model.LoginUser;
/**
*
*
*
* @author ruoyi
*/
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
@ -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);
}

@ -11,7 +11,7 @@ import com.ruoyi.system.api.model.LoginUser;
/**
*
*
*
* @author ruoyi
*/
@Component
@ -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());
}
};
}
}

@ -40,7 +40,7 @@ import com.ruoyi.system.service.ISysUserService;
/**
*
*
*
* @author ruoyi
*/
@RestController
@ -147,7 +147,7 @@ public class SysUserController extends BaseController
/**
*
*
*
* @return
*/
@GetMapping("getInfo")
@ -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…
Cancel
Save