Restful API
package com.example.query; import java.io.Serializable; public class UserQuery implements Serializable { private Integer id; private String username; private String name; private String phone; private String telepone; private String address; private String email; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getTelepone() { return telepone; } public void setTelepone(String telepone) { this.telepone = telepone; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } @Override public String toString() { return "UserQuery{" + "id=" + id + ", username='" + username + '\'' + ", name='" + name + '\'' + ", phone='" + phone + '\'' + ", telepone='" + telepone + '\'' + ", address='" + address + '\'' + ", email='" + email + '\'' + '}'; } }
package com.example.controller; import com.example.pojo.User; import com.example.query.UserQuery; import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.*; import java.util.List; //@Controller @RestController @Api(tags = "用户数据接口") @RequestMapping("/user") public class UserController { // @RequestMapping(value = "/user/username", method = RequestMethod.GET) // @GetMapping("/user/username") @GetMapping("/username") // public List<User> queryByUsername(@RequestParam String username){ public List<User> queryByUsername(@RequestParam(name="username",required = false, defaultValue = "name_test") String nikename){ return null; } // @RequestMapping(value = "/user", method = RequestMethod.GET) // @GetMapping("/user") @GetMapping public List<User> query(UserQuery userQuery){ // public List<User> query(UserQuery userQuery, Pageable pageable){//Pageable 用于存放分页信息 return null; } // @RequestMapping(value = "/user/{id}", method = RequestMethod.GET) // @GetMapping("/user/{id}") @PostMapping("/{id}") // public User getUserById(@PathVariable String id){ public User getUserById(@PathVariable(name = "id",required = true) String uid){ return null; } }