api: Implement skill-related entities

pull/1/head
Lunix-420 2024-10-28 11:52:07 +01:00
parent 7ae9475386
commit a4dfcba99a
4 changed files with 45 additions and 23 deletions

View File

@ -0,0 +1,20 @@
package com.maradona.backend;
import jakarta.persistence.*;
import java.util.List;
@Entity
public class PrimarySkill {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long psid;
@Column(nullable = false, length = 255)
private String description;
@OneToMany(mappedBy = "primarySkill", cascade = CascadeType.ALL, orphanRemoval = true)
private List<SecondarySkill> secondarySkills;
// TODO: Getters and Setters
}

View File

@ -0,0 +1,20 @@
package com.maradona.backend;
import jakarta.persistence.*;
@Entity
public class SecondarySkill {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long ssid;
@Column(nullable = false, length = 255)
private String description;
@ManyToOne
@JoinColumn(name = "psid", nullable = false)
private PrimarySkill primarySkill;
// Getters and Setters
}

View File

@ -1,16 +0,0 @@
package com.maradona.backend;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Entity
public class Skill {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String primary;
private String secondary;
}

View File

@ -4,15 +4,13 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@RestController
@RequestMapping("/api")
@RequestMapping("/api/skills")
public class SkillController {
@PostMapping("skills")
public ResponseEntity<Skill> createSkill(@RequestBody Skill skill) {
return ResponseEntity.ok(skill);
}
}