2023-08-14 09:19:43 +08:00
|
|
|
package net.risesoft.demo.controller;
|
|
|
|
|
2023-10-29 19:48:16 +08:00
|
|
|
import java.util.ArrayList;
|
2023-08-14 09:19:43 +08:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
2023-10-29 19:48:16 +08:00
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
2023-08-14 09:19:43 +08:00
|
|
|
import net.risesoft.demo.entity.User;
|
|
|
|
import net.risesoft.demo.repository.UserRepository;
|
|
|
|
|
|
|
|
@RestController
|
2023-10-27 13:36:45 +08:00
|
|
|
@RequestMapping
|
2023-08-14 09:19:43 +08:00
|
|
|
public class UserController {
|
|
|
|
|
|
|
|
private final UserRepository userRepository;
|
|
|
|
|
|
|
|
public UserController(UserRepository userRepository) {
|
|
|
|
super();
|
|
|
|
this.userRepository = userRepository;
|
|
|
|
}
|
|
|
|
|
2023-10-29 19:48:16 +08:00
|
|
|
@GetMapping({"", "/"})
|
|
|
|
public List<String> hosts(HttpServletRequest request){
|
|
|
|
List<String> list = new ArrayList<String>();
|
2023-11-01 21:26:54 +08:00
|
|
|
list.add("serverName=" + request.getServerName());
|
|
|
|
list.add("localAddr=" + request.getLocalAddr());
|
2023-10-29 19:48:16 +08:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2023-11-01 21:26:54 +08:00
|
|
|
@GetMapping({"/users"})
|
2023-10-29 19:48:16 +08:00
|
|
|
public List<User> users(){
|
2023-08-14 09:19:43 +08:00
|
|
|
return userRepository.findAll();
|
|
|
|
}
|
|
|
|
}
|