parent
8d84c5aec3
commit
6911a66096
@ -1,12 +1,45 @@
|
||||
package com.luoo.music.client;
|
||||
|
||||
import api.Result;
|
||||
import com.luoo.music.pojo.UserInfo;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@FeignClient("luoo-user")
|
||||
public interface UserClient {
|
||||
|
||||
@GetMapping("/admin")
|
||||
public Result findAll();
|
||||
Result findAll();
|
||||
|
||||
@GetMapping("/cms/admin/{id}")
|
||||
Result<AdminUser> findById(@PathVariable("id") String id);
|
||||
|
||||
/**
|
||||
* 通过用户ID获取用户信息
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
default UserInfo queryUserInfoById(String userId){
|
||||
if (StringUtils.isBlank(userId)) {
|
||||
return null;
|
||||
}
|
||||
Result<AdminUser> result = findById(userId);
|
||||
AdminUser adminUser = result.getData();
|
||||
if (Objects.isNull(adminUser)) {
|
||||
return null;
|
||||
}
|
||||
UserInfo user = UserInfo.builder().id(adminUser.getId()).name(adminUser.getLoginname()).type("admin").build();
|
||||
return user;
|
||||
}
|
||||
|
||||
@Data
|
||||
class AdminUser{
|
||||
private String id;
|
||||
private String loginname;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue