码迷,mamicode.com
首页 > Windows程序 > 详细

Restful API

时间:2021-04-13 12:17:10      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:Pageable   var   api   java   pac   span   erb   pre   pat   

 

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;
    }








}

 

Restful API

标签:Pageable   var   api   java   pac   span   erb   pre   pat   

原文地址:https://www.cnblogs.com/mingforyou/p/14649468.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!