Compare commits
No commits in common. "1d4efc1f2b2d961afd07d2eff759267fb2031241" and "45d6b51967006de6bfc92cf4c3ef15a4cb26b3e7" have entirely different histories.
1d4efc1f2b
...
45d6b51967
5 changed files with 25 additions and 80 deletions
|
@ -1,26 +1,18 @@
|
||||||
package de.hmmh.pmt;
|
package de.hmmh.pmt;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import de.hmmh.pmt.db.Project;
|
|
||||||
import de.hmmh.pmt.db.ProjectRepository;
|
|
||||||
import de.hmmh.pmt.oas.DefaultApi;
|
import de.hmmh.pmt.oas.DefaultApi;
|
||||||
import de.hmmh.pmt.oas.dtos.GetAllProjectsDTO;
|
import de.hmmh.pmt.oas.models.HelloOut;
|
||||||
import de.hmmh.pmt.oas.dtos.ProjectInfo;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("${openapi.projectManagement.base-path:/api/v1}")
|
@RequestMapping("${openapi.projectManagement.base-path:/api/v1}")
|
||||||
public class ApiController implements DefaultApi {
|
public class ApiController implements DefaultApi {
|
||||||
@Autowired
|
|
||||||
private ProjectRepository projectRepository;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ObjectMapper> getObjectMapper() {
|
public Optional<ObjectMapper> getObjectMapper() {
|
||||||
|
@ -33,16 +25,9 @@ public class ApiController implements DefaultApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<GetAllProjectsDTO> getAllProjects() {
|
public ResponseEntity<HelloOut> getHello() {
|
||||||
GetAllProjectsDTO response = new GetAllProjectsDTO();
|
HelloOut hello = new HelloOut();
|
||||||
|
hello.setMsg("Hello World");
|
||||||
for (Project project : this.projectRepository.findAll()){
|
return ResponseEntity.ok(hello);
|
||||||
ProjectInfo projectInfo = new ProjectInfo();
|
|
||||||
projectInfo.setId(project.getId());
|
|
||||||
projectInfo.setName(project.getName());
|
|
||||||
response.add(projectInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResponseEntity.ok(response);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
package de.hmmh.pmt.db;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import jakarta.validation.constraints.Size;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@Entity
|
|
||||||
@Table(name = "project")
|
|
||||||
public final class Project {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@NotBlank
|
|
||||||
@Size(min = 3, max = 64)
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private LocalDateTime start;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private LocalDateTime plannedEnd;
|
|
||||||
|
|
||||||
private LocalDateTime end;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
package de.hmmh.pmt.db;
|
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
public interface ProjectRepository extends JpaRepository<Project, Long> {
|
|
||||||
}
|
|
|
@ -5,21 +5,22 @@ info:
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
servers:
|
servers:
|
||||||
- url: /api/v1
|
- url: /api/v1
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
ProjectInfo:
|
HelloOut:
|
||||||
|
description: "A Test Schema"
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
id:
|
msg:
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
name:
|
|
||||||
type: string
|
type: string
|
||||||
GetAllProjectsDTO:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/components/schemas/ProjectInfo"
|
|
||||||
responses:
|
responses:
|
||||||
|
OK:
|
||||||
|
description: "OK"
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
InternalError:
|
InternalError:
|
||||||
description: "Internal Server Error"
|
description: "Internal Server Error"
|
||||||
content:
|
content:
|
||||||
|
@ -27,14 +28,16 @@ components:
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
paths:
|
paths:
|
||||||
/project:
|
/hello:
|
||||||
get:
|
get:
|
||||||
operationId: "getAllProjects"
|
operationId: "GetHello"
|
||||||
description: "Get a List of all Projects"
|
description: "A Simple Hello World Endpoint"
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: ""
|
description: "A Hello Response"
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/GetAllProjectsDTO"
|
$ref: "#/components/schemas/HelloOut"
|
||||||
|
500:
|
||||||
|
$ref: "#/components/responses/InternalError"
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"modelPackage": "de.hmmh.pmt.oas.dtos",
|
"modelPackage": "de.hmmh.pmt.oas.models",
|
||||||
"apiPackage": "de.hmmh.pmt.oas",
|
"apiPackage": "de.hmmh.pmt.oas",
|
||||||
"invokerPackage": "de.hmmh.pmt.oas",
|
"invokerPackage": "de.hmmh.pmt.oas",
|
||||||
"java8": false,
|
"java8": false,
|
||||||
|
|
Loading…
Reference in a new issue