mirror of
https://gitee.com/many2many/java-web.git
synced 2025-01-11 14:40:55 +08:00
example changed
This commit is contained in:
parent
9fb8b80bc6
commit
95680afb74
@ -0,0 +1,37 @@
|
||||
package com.lk.demo;
|
||||
|
||||
public class User {
|
||||
private String name;
|
||||
private String email;
|
||||
private String phone;
|
||||
|
||||
public User(String name, String email, String phone) {
|
||||
this.name = name;
|
||||
this.email = email;
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.lk.demo;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/users")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping("")
|
||||
public List<User> index() {
|
||||
return userService.getUsers();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.lk.demo;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
public List<User> getUsers(){
|
||||
List<User> users = new ArrayList<>();
|
||||
users.add(new User("mike","mike@mail.com", "188111111"));
|
||||
users.add(new User("john","john@mail.com", "133222222"));
|
||||
users.add(new User("tom","tom@mail.com", "199222222"));
|
||||
return users;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user