[feat] 新增编辑用户信息的内部接口

This commit is contained in:
hsdllcw
2024-10-25 16:53:27 +08:00
parent 8bde724310
commit 08299ccd09
28 changed files with 177 additions and 89 deletions

View File

@@ -1,5 +1,6 @@
package com.ruoyi.system.api;
import com.ruoyi.system.api.inner.InnerRemoteUserService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -20,17 +21,8 @@ import com.ruoyi.system.api.model.LoginUser;
* @author ruoyi
*/
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
public interface RemoteUserService extends InnerRemoteUserService
{
/**
* 通过用户ID查询用户信息
*
* @param userId 用户ID
* @param source 请求来源
* @return 结果
*/
@GetMapping("/user/detail/{userId}")
public R<LoginUser> infoById(@PathVariable("userId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
* 通过用户名查询用户信息
*
@@ -41,15 +33,6 @@ public interface RemoteUserService
@GetMapping("/user/info/{username}")
public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
* 通过手机号查询用户信息
*
* @param phoneNumber 用户名
* @param source 请求来源
* @return 结果
*/
@GetMapping("/user/info/phoneNumber/{phoneNumber:\\d+}")
public R<LoginUser> getUserInfoByPhoneNumber(@PathVariable("phoneNumber") String phoneNumber, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
* 注册用户信息
*

View File

@@ -1,5 +1,6 @@
package com.ruoyi.system.api.factory;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
@@ -11,7 +12,7 @@ import com.ruoyi.system.api.model.LoginUser;
/**
* 用户服务降级处理
*
*
* @author ruoyi
*/
@Component
@@ -25,9 +26,9 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
log.error("用户服务调用失败:{}", throwable.getMessage());
return new RemoteUserService()
{
@NotNull
@Override
public R<LoginUser> infoById(Long userId, String source)
{
public R<LoginUser> infoById_Inner(Long userId, @NotNull String source) {
return R.fail("获取用户失败:" + throwable.getMessage());
}
@@ -37,8 +38,9 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
return R.fail("获取用户失败:" + throwable.getMessage());
}
@NotNull
@Override
public R<LoginUser> getUserInfoByPhoneNumber(String phoneNumber, String source) {
public R<LoginUser> getUserInfoByPhoneNumber_Inner(@NotNull String phoneNumber, @NotNull String source) {
return R.fail("获取用户失败:" + throwable.getMessage());
}
@@ -53,6 +55,12 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
{
return R.fail("记录用户登录信息失败:" + throwable.getMessage());
}
@NotNull
@Override
public R<LoginUser> edit_Inner(@NotNull LoginUser user, @NotNull String source) {
return R.fail("修改用户信息失败:" + throwable.getMessage());
}
};
}
}

View File

@@ -0,0 +1,32 @@
package com.ruoyi.system.api.inner;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.web.bind.annotation.*;
public interface InnerRemoteUserService {
/**
* 通过用户ID查询用户信息
*
* @param userId 用户ID
* @param source 请求来源
* @return 结果
*/
@GetMapping("/inner/user/detail/{userId}")
R<LoginUser> infoById_Inner(@PathVariable("userId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
* 通过手机号查询用户信息
*
* @param phoneNumber 用户名
* @param source 请求来源
* @return 结果
*/
@GetMapping("/inner/user/info/phoneNumber/{phoneNumber:\\d+}")
R<LoginUser> getUserInfoByPhoneNumber_Inner(@PathVariable("phoneNumber") String phoneNumber, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@PutMapping("/inner/user")
R<LoginUser> edit_Inner(@RequestBody LoginUser user, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}