Pre Merge pull request !102 from dazer007/RemoteUserService-add-getUserById
This commit is contained in:
commit
bc35bc6352
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
|||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
|
@ -16,7 +18,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
|
|||
|
||||
/**
|
||||
* 用户对象 sys_user
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SysUser extends BaseEntity
|
||||
|
|
@ -69,6 +71,7 @@ public class SysUser extends BaseEntity
|
|||
private String loginIp;
|
||||
|
||||
/** 最后登录时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||
private Date loginDate;
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
@ -304,4 +304,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