Commit 6e4d272b authored by XCQi's avatar XCQi

首次提交

parent b968b0f5
......@@ -2,20 +2,10 @@ package com.yingxin.springcloudserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class SpringCloudServerApplication {
@RequestMapping("/")
public String home() {
return "hello world.";
}
public static void main(String[] args) {
SpringApplication.run(SpringCloudServerApplication.class, args);
}
}
package com.yingxin.springcloudserver.controller;
import com.yingxin.springcloudserver.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@RestController
public class RestApi {
@RequestMapping("/")
public String home() {
return "hello world.";
}
@GetMapping("/exampleforget")
public User getUser() {
return new User("no1", "张三", 25);
}
@GetMapping("/queryUserList")
public List<User> getUsers() {
List<User> users = new ArrayList<>();
User tom = new User("no1", "tom", 25);
User amy = new User("no2", "amy", 22);
users.add(tom);
users.add(amy);
return users;
}
}
package com.yingxin.springcloudserver.entity;
public class User {
private String id;
private String name;//姓名
private Integer age;//年龄
public User() {
}
public User(String id, String name, Integer age) {
this.id = id;
this.name = name;
this.age = age;
}
public String getId() {
return id;
}
public void setId(String 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;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment