-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dubbo-samples-rest-springmvc-1 (#1121)
- Loading branch information
1 parent
4131d1f
commit 46a945c
Showing
9 changed files
with
786 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...st-springmvc/src/main/java/org/apache/dubbo/rest/demo/expansion/filter/FilterService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.apache.dubbo.rest.demo.expansion.filter; | ||
|
||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
@RequestMapping(value = "/filter") | ||
public interface FilterService { | ||
@GetMapping(value = "/get/{name}", consumes = "application/json", produces = MediaType.TEXT_PLAIN_VALUE) | ||
public String filterGet(@PathVariable(value = "name") String name); | ||
} |
12 changes: 12 additions & 0 deletions
12
...pringmvc/src/main/java/org/apache/dubbo/rest/demo/expansion/filter/FilterServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.apache.dubbo.rest.demo.expansion.filter; | ||
import org.apache.dubbo.config.annotation.DubboService; | ||
|
||
@DubboService | ||
public class FilterServiceImpl implements FilterService{ | ||
|
||
@Override | ||
public String filterGet(String name) { | ||
return name; | ||
} | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
...bbo-samples-triple-rest-springmvc/src/main/java/org/apache/dubbo/rest/demo/pojo/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package org.apache.dubbo.rest.demo.pojo; | ||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
// 需要 implements Serializable | ||
public class User implements Serializable{ | ||
|
||
private Long id; | ||
|
||
private String name; | ||
|
||
private Integer age; | ||
|
||
public User(Long id, String name){ | ||
this.id = id; | ||
this.name = name; | ||
} | ||
|
||
public User(Long id, String name, Integer age){ | ||
this.id = id; | ||
this.name = name; | ||
this.age = age; | ||
} | ||
|
||
public User(){ | ||
|
||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Integer getAge() { | ||
return age; | ||
} | ||
|
||
public void setAge(Integer age) { | ||
this.age = age; | ||
} | ||
|
||
public static User getInstance() { | ||
User user = new User(); | ||
user.setAge(18); | ||
user.setName("dubbo"); | ||
user.setId(404l); | ||
return user; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
User user = (User) o; | ||
return Objects.equals(id, user.id) && Objects.equals(name, user.name) && Objects.equals(age, user.age); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id, name, age); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + "id=" + id + ", name='" + name + '\'' + ", age=" + age + '}'; | ||
} | ||
|
||
public String stringToJson(){ | ||
return "{\"id\":\"" + this.id + "\", \"name\":\"" + this.name + "\"}"; | ||
} | ||
|
||
} |
Oops, something went wrong.