Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update spring boot to v3 (major) #66

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.8</version>
<version>3.0.2</version>
<relativePath/>
</parent>

Expand Down Expand Up @@ -182,7 +182,7 @@
<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>2.7.8</version>
<version>3.0.2</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.ohmyclass.api.components.classmember.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.ohmyclass.api.components.group.entity.Group;
import lombok.Getter;
import lombok.Setter;

import java.util.Set;

import javax.persistence.*;
import jakarta.persistence.*;

import com.ohmyclass.api.components.user.entity.User;

Expand All @@ -16,7 +17,7 @@
@Table(name = "classmember")
public class ClassMember {

@Id
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
Expand All @@ -29,7 +30,7 @@ public class ClassMember {
@JsonManagedReference
private Group group;

// @ManyToMany(fetch = FetchType.LAZY)
// private List<Role> roles;
// @ManyToMany(fetch = FetchType.LAZY)
// private List<Role> roles;

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import java.util.Set;

@Getter
Expand All @@ -44,7 +44,7 @@ public class GroupMember {
private Group group;


// @ManyToMany(fetch = FetchType.LAZY)
// private List<Role> roles;
// @ManyToMany(fetch = FetchType.LAZY)
// private List<Role> roles;

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import java.util.Date;
import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import jakarta.persistence.*;
import java.util.Set;

@Getter
@Setter
@Entity
@Table(name = "group")
public class Group {
@Id
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
Expand All @@ -31,9 +31,7 @@ public class Group {
@OneToMany(fetch = FetchType.LAZY)
private Set<Subject> subjects;

@OneToMany(cascade = {CascadeType.ALL},
orphanRemoval = true,
mappedBy = "group")
@OneToMany(cascade = {CascadeType.ALL}, orphanRemoval = true, mappedBy = "group")
@JsonBackReference
private Set<Task> tasks;

Expand All @@ -42,7 +40,7 @@ public class Group {
@JsonManagedReference
private User user;

// @ManyToMany(fetch = FetchType.LAZY)
// private Set<Role> roles;
// @ManyToMany(fetch = FetchType.LAZY)
// private Set<Role> roles;

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import jakarta.persistence.*;

@Getter
@Setter
Expand Down
35 changes: 19 additions & 16 deletions src/main/java/com/ohmyclass/api/components/role/entity/Role.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import java.util.List;

@Getter
Expand All @@ -22,9 +22,9 @@
@Table(name = "role")
public class Role {

public Role() {}
public Role(String name) {
public Role() {}

public Role(String name) {
this.name = name;
}

Expand All @@ -45,8 +45,11 @@ public Role(String name) {
@JsonManagedReference
private User user;

/* @ManyToOne
@JoinColumn(name = "fkGroup")
@JsonManagedReference
private Group fkGroup;*/
/*
* @ManyToOne
*
* @JoinColumn(name = "fkGroup")
*
* @JsonManagedReference private Group fkGroup;
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
import lombok.Getter;
import lombok.Setter;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import java.util.Set;

@Getter
Expand All @@ -43,9 +43,7 @@ public class Subject {
@JsonManagedReference
private Group group;

@OneToMany(cascade = {CascadeType.ALL},
orphanRemoval = true,
mappedBy = "subject")
@OneToMany(cascade = {CascadeType.ALL}, orphanRemoval = true, mappedBy = "subject")
@JsonBackReference
private Set<Task> tasks;
}
24 changes: 12 additions & 12 deletions src/main/java/com/ohmyclass/api/components/task/entity/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import java.util.Date;
import java.util.List;
import java.util.Set;
Expand All @@ -30,7 +30,7 @@
@Entity
@Table(name = "Task")
public class Task {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import jakarta.persistence.*;

@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
Expand All @@ -25,52 +25,58 @@ public interface IUserController {

@PostMapping("/auth/register")
@Operation(summary = "Register a user into the database")
@ApiResponse(responseCode = "200", description = "The generated", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = Map.class)) })
@ApiResponse(responseCode = "200", description = "The generated",
content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))})
@ApiResponse(responseCode = "401", description = "Authentication failed")
@ApiResponse(responseCode = "500", description = "General server error")
Response<Map<String, String>> register(@RequestBody UserInDTO registration);

@PostMapping("/auth/refresh")
@Operation(summary = "Refresh the access token")
@ApiResponse(responseCode = "200", description = "The updated token", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = Map.class)) })
@ApiResponse(responseCode = "200", description = "The updated token",
content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))})
@ApiResponse(responseCode = "401", description = "Authentication failed")
@ApiResponse(responseCode = "500", description = "General server error")
void refreshToken(HttpServletRequest request, HttpServletResponse response);

@Secured("ROLE_USER")
@PutMapping("/auth/password-forgotten")
@Operation(summary = "Request a URL to change the password")
@ApiResponse(responseCode = "200", description = "Email has been sent", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = UserOutDTO.class)) })
@ApiResponse(responseCode = "200", description = "Email has been sent",
content = {@Content(mediaType = "application/json",
schema = @Schema(implementation = UserOutDTO.class))})
@ApiResponse(responseCode = "401", description = "Authentication failed")
@ApiResponse(responseCode = "500", description = "General server error")
void passwordForgotten(HttpServletRequest request, HttpServletResponse response);

@Secured("ROLE_ADMIN")
@GetMapping("/user/{username}")
@Operation(summary = "Get a user from the database")
@ApiResponse(responseCode = "200", description = "User", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = UserOutDTO.class)) })
@ApiResponse(responseCode = "200", description = "User",
content = {@Content(mediaType = "application/json",
schema = @Schema(implementation = UserOutDTO.class))})
@ApiResponse(responseCode = "401", description = "Authentication failed")
@ApiResponse(responseCode = "500", description = "General server error")
Response<UserOutDTO> getUser(@PathVariable String username);

@Secured("ROLE_USER")
@PutMapping("/user")
@Operation(summary = "Edit user details in database")
@ApiResponse(responseCode = "200", description = "The updated user", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class)) })
@ApiResponse(responseCode = "200", description = "The updated user",
content = {@Content(mediaType = "application/json",
schema = @Schema(implementation = Boolean.class))})
@ApiResponse(responseCode = "401", description = "Authentication failed")
@ApiResponse(responseCode = "500", description = "General server error")
Response<Boolean> updateUser(@RequestBody UserChangeInDTO userChangeIn);

@Secured("ROLE_USER")
@DeleteMapping("/user")
@Operation(summary = "Delete a user from the database")
@ApiResponse(responseCode = "200", description = "The success of the operation", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class)) })
@ApiResponse(responseCode = "200", description = "The success of the operation",
content = {@Content(mediaType = "application/json",
schema = @Schema(implementation = Boolean.class))})
@ApiResponse(responseCode = "401", description = "Authentication failed")
@ApiResponse(responseCode = "500", description = "General server error")
Response<Boolean> deleteUser(@RequestBody String username);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
Expand Down
Loading