diff options
| author | realtradam <[email protected]> | 2024-07-15 22:20:09 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2024-07-15 22:20:09 -0400 |
| commit | b1581ed1046f4aef077aea4fe6a1b01e599125d2 (patch) | |
| tree | 73e887083219b7b7c5eda1919628692b76f2a372 /src/main/java | |
| parent | 1d8b48dfab6d1de72c841d309732c6da3bc6136c (diff) | |
| download | spring-blog-b1581ed1046f4aef077aea4fe6a1b01e599125d2.tar.gz spring-blog-b1581ed1046f4aef077aea4fe6a1b01e599125d2.zip | |
remove lombok
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/com/blog/web/dto/ArticleDto.java | 78 | ||||
| -rw-r--r-- | src/main/java/com/blog/web/dto/RegistrationDto.java | 33 | ||||
| -rw-r--r-- | src/main/java/com/blog/web/mappers/ArticleMapper.java | 36 | ||||
| -rw-r--r-- | src/main/java/com/blog/web/models/Article.java | 80 | ||||
| -rw-r--r-- | src/main/java/com/blog/web/models/Role.java | 24 | ||||
| -rw-r--r-- | src/main/java/com/blog/web/models/UserEntity.java | 44 |
6 files changed, 262 insertions, 33 deletions
diff --git a/src/main/java/com/blog/web/dto/ArticleDto.java b/src/main/java/com/blog/web/dto/ArticleDto.java index 232fa3c..65ec6da 100644 --- a/src/main/java/com/blog/web/dto/ArticleDto.java +++ b/src/main/java/com/blog/web/dto/ArticleDto.java @@ -11,8 +11,6 @@ import org.hibernate.validator.constraints.URL; import java.time.LocalDateTime; -@Data -@Builder public class ArticleDto { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -31,4 +29,80 @@ public class ArticleDto { @ManyToOne @JoinColumn(name = "created_by", nullable = false) private UserEntity createdBy; + + public ArticleDto( + long id, + String title, + String photoUrl, + String content, + UserEntity createdBy, + LocalDateTime createdOn, + LocalDateTime updatedOn + ) { + this.id = id; + this.title = title; + this.photoUrl = photoUrl; + this.content = content; + this.createdBy = createdBy; + this.createdOn = createdOn; + this.updatedOn = updatedOn; + } + + public ArticleDto() {}; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public @NotEmpty(message = "Article title should not be empty") String getTitle() { + return title; + } + + public void setTitle(@NotEmpty(message = "Article title should not be empty") String title) { + this.title = title; + } + + public @NotEmpty(message = "Article Photo URL should not be empty") @URL(message = "Article Photo URL should be a URL") String getPhotoUrl() { + return photoUrl; + } + + public void setPhotoUrl(@NotEmpty(message = "Article Photo URL should not be empty") @URL(message = "Article Photo URL should be a URL") String photoUrl) { + this.photoUrl = photoUrl; + } + + public @NotEmpty(message = "Article Content should not be empty") String getContent() { + return content; + } + + public void setContent(@NotEmpty(message = "Article Content should not be empty") String content) { + this.content = content; + } + + public LocalDateTime getCreatedOn() { + return createdOn; + } + + public void setCreatedOn(LocalDateTime createdOn) { + this.createdOn = createdOn; + } + + public LocalDateTime getUpdatedOn() { + return updatedOn; + } + + public void setUpdatedOn(LocalDateTime updatedOn) { + this.updatedOn = updatedOn; + } + + public UserEntity getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(UserEntity createdBy) { + this.createdBy = createdBy; + } } diff --git a/src/main/java/com/blog/web/dto/RegistrationDto.java b/src/main/java/com/blog/web/dto/RegistrationDto.java index 1682c5c..6d37b57 100644 --- a/src/main/java/com/blog/web/dto/RegistrationDto.java +++ b/src/main/java/com/blog/web/dto/RegistrationDto.java @@ -6,7 +6,6 @@ import lombok.Builder; import lombok.Data; import lombok.Getter; -@Data public class RegistrationDto { private Long id; @NotEmpty @@ -15,4 +14,36 @@ public class RegistrationDto { private String email; @NotEmpty private String password; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public @NotEmpty String getUsername() { + return username; + } + + public void setUsername(@NotEmpty String username) { + this.username = username; + } + + public @NotEmpty String getEmail() { + return email; + } + + public void setEmail(@NotEmpty String email) { + this.email = email; + } + + public @NotEmpty String getPassword() { + return password; + } + + public void setPassword(@NotEmpty String password) { + this.password = password; + } } diff --git a/src/main/java/com/blog/web/mappers/ArticleMapper.java b/src/main/java/com/blog/web/mappers/ArticleMapper.java index a3642da..cdeb238 100644 --- a/src/main/java/com/blog/web/mappers/ArticleMapper.java +++ b/src/main/java/com/blog/web/mappers/ArticleMapper.java @@ -5,27 +5,27 @@ import com.blog.web.models.Article; public class ArticleMapper { public static Article mapToArticle(ArticleDto articleDto) { - Article article = Article.builder() - .id(articleDto.getId()) - .title(articleDto.getTitle()) - .photoUrl(articleDto.getPhotoUrl()) - .content(articleDto.getContent()) - .createdBy(articleDto.getCreatedBy()) - .createdOn(articleDto.getCreatedOn()) - .updatedOn(articleDto.getUpdatedOn()) - .build(); + Article article = new Article( + articleDto.getId(), + articleDto.getTitle(), + articleDto.getPhotoUrl(), + articleDto.getContent(), + articleDto.getCreatedBy(), + articleDto.getCreatedOn(), + articleDto.getUpdatedOn() + ); return article; } public static ArticleDto mapToArticleDto(Article article) { - return ArticleDto.builder() - .id(article.getId()) - .title(article.getTitle()) - .photoUrl(article.getPhotoUrl()) - .content(article.getContent()) - .createdBy(article.getCreatedBy()) - .createdOn(article.getCreatedOn()) - .updatedOn(article.getUpdatedOn()) - .build(); + return new ArticleDto( + article.getId(), + article.getTitle(), + article.getPhotoUrl(), + article.getContent(), + article.getCreatedBy(), + article.getCreatedOn(), + article.getUpdatedOn() + ); } } diff --git a/src/main/java/com/blog/web/models/Article.java b/src/main/java/com/blog/web/models/Article.java index 049b04c..02c8abf 100644 --- a/src/main/java/com/blog/web/models/Article.java +++ b/src/main/java/com/blog/web/models/Article.java @@ -11,10 +11,6 @@ import org.hibernate.annotations.UpdateTimestamp; import java.time.LocalDateTime; -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder @Entity public class Article { @Id @@ -30,4 +26,80 @@ public class Article { @ManyToOne @JoinColumn(name = "created_by", nullable = false) private UserEntity createdBy; + + public Article( + Long id, + String title, + String photoUrl, + String content, + UserEntity createdBy, + LocalDateTime createdOn, + LocalDateTime updatedOn + ) { + this.id = id; + this.title = title; + this.photoUrl = photoUrl; + this.content = content; + this.createdBy = createdBy; + this.createdOn = createdOn; + this.updatedOn = updatedOn; + } + + public Article() {}; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getPhotoUrl() { + return photoUrl; + } + + public void setPhotoUrl(String photoUrl) { + this.photoUrl = photoUrl; + } + + public LocalDateTime getCreatedOn() { + return createdOn; + } + + public void setCreatedOn(LocalDateTime createdOn) { + this.createdOn = createdOn; + } + + public LocalDateTime getUpdatedOn() { + return updatedOn; + } + + public void setUpdatedOn(LocalDateTime updatedOn) { + this.updatedOn = updatedOn; + } + + public UserEntity getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(UserEntity createdBy) { + this.createdBy = createdBy; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } } diff --git a/src/main/java/com/blog/web/models/Role.java b/src/main/java/com/blog/web/models/Role.java index b04c9d8..7fa47b0 100644 --- a/src/main/java/com/blog/web/models/Role.java +++ b/src/main/java/com/blog/web/models/Role.java @@ -11,10 +11,6 @@ import java.sql.Array; import java.util.ArrayList; import java.util.List; -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor @Entity(name = "roles") public class Role { @Id @@ -23,4 +19,24 @@ public class Role { private String name; @ManyToMany(mappedBy = "roles") private List<UserEntity> users = new ArrayList<>(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List<UserEntity> getUsers() { + return users; + } } diff --git a/src/main/java/com/blog/web/models/UserEntity.java b/src/main/java/com/blog/web/models/UserEntity.java index 2dfb036..c416cb6 100644 --- a/src/main/java/com/blog/web/models/UserEntity.java +++ b/src/main/java/com/blog/web/models/UserEntity.java @@ -9,10 +9,6 @@ import lombok.Setter; import java.util.ArrayList; import java.util.List; -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor @Entity(name = "users") // Named UserEntity to prevent conflicts with Java User object public class UserEntity { @@ -29,4 +25,44 @@ public class UserEntity { inverseJoinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id")} ) private List<Role> roles = new ArrayList<>(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public List<Role> getRoles() { + return roles; + } + + public void setRoles(List<Role> roles) { + this.roles = roles; + } } |
