26 lines
651 B
Java
26 lines
651 B
Java
package com.example.backend.controller;
|
|
|
|
|
|
import com.example.backend.entity.User;
|
|
import com.example.backend.service.UserService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@RestController
|
|
@RequestMapping("/users")
|
|
public class UserController {
|
|
|
|
@Autowired
|
|
private UserService userService;
|
|
|
|
@PostMapping
|
|
public User createUser(@RequestBody User user) {
|
|
return userService.createUser(user);
|
|
}
|
|
|
|
@GetMapping("/{username}")
|
|
public User getUserByUsername(@PathVariable String username) {
|
|
return userService.findByUsername(username);
|
|
}
|
|
}
|