✨ 远程调用-第三方
This commit is contained in:
parent
42d21d0947
commit
b450d0172d
|
@ -0,0 +1,10 @@
|
|||
package cn.bunny.model.order.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LoginDto {
|
||||
String username;
|
||||
String password;
|
||||
String type;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package cn.bunny.service.feign;
|
||||
|
||||
import cn.bunny.model.order.bean.LoginDto;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(value = "bunny-client", url = "http://bunny-web.site/api/user")
|
||||
public interface BunnyFeignClient {
|
||||
|
||||
@PostMapping("login")
|
||||
String login(@RequestBody LoginDto dtp);
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package cn.bunny.service.feign;
|
||||
|
||||
import cn.bunny.model.order.bean.LoginDto;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
public class BunnyFeignClientTest {
|
||||
|
||||
@Autowired
|
||||
private BunnyFeignClient bunnyFeignClient;
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
LoginDto loginDto = new LoginDto();
|
||||
loginDto.setUsername("bunny");
|
||||
loginDto.setPassword("admin123");
|
||||
loginDto.setType("default");
|
||||
String login = bunnyFeignClient.login(loginDto);
|
||||
|
||||
System.out.println(login);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue