Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b69H5rTewUKPyhGS8r
34 lines
933 B
Java
34 lines
933 B
Java
package com.ankurm.ci;
|
|
|
|
import java.util.List;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
@RestController
|
|
public class TicketController {
|
|
|
|
public record NewTicket(String title) {
|
|
}
|
|
|
|
private final TicketRepository repository;
|
|
|
|
public TicketController(TicketRepository repository) {
|
|
this.repository = repository;
|
|
}
|
|
|
|
@GetMapping("/tickets")
|
|
public List<Ticket> list() {
|
|
return repository.findAll();
|
|
}
|
|
|
|
@PostMapping("/tickets")
|
|
@ResponseStatus(HttpStatus.CREATED)
|
|
public Ticket create(@RequestBody NewTicket body) {
|
|
return repository.save(body.title());
|
|
}
|
|
}
|