4 lab УРАААААААААААА

This commit is contained in:
Павел Сорокин 2023-04-07 22:15:50 +04:00
parent 4b9638ad2f
commit 688fd255c6
4 changed files with 26 additions and 20 deletions

Binary file not shown.

View File

@ -54,4 +54,10 @@ public class PostController {
public PostDto deletePost(@PathVariable Long id) {
return new PostDto(postService.deletePost(id));
}
@DeleteMapping
public void deleteall()
{
postService.deleteAllPosts();
}
}

View File

@ -11,9 +11,9 @@ import java.util.List;
public class PostDto {
private Long id;
private String Heading;
private String heading;
private String Content;
private String content;
private User user;
@ -24,8 +24,8 @@ public class PostDto {
public PostDto(){}
public PostDto(Post post)
{
this.Heading = post.getHeading();
this.Content = post.getContent();
this.heading = post.getHeading();
this.content = post.getContent();
this.image = new String(post.getImage(), StandardCharsets.UTF_8);
}
@ -36,11 +36,11 @@ public class PostDto {
}
public String getHeading()
{
return Heading;
return heading;
}
public String getContent()
{
return Content;
return content;
}
public User getUser()
{

View File

@ -17,11 +17,11 @@ public class Post {
private Long id;
@Column
@NotBlank(message = "Heading cannot be null")
private String Heading;
@NotBlank(message = "heading cannot be null")
private String heading;
@NotBlank(message = "Content cannot be null")
private String Content;
@NotBlank(message = "content cannot be null")
private String content;
@Lob
private byte[] image;
@ -35,13 +35,13 @@ public class Post {
public Post(){}
public Post(String Heading, String Content,byte[] image)
{
this.Heading = Heading;
this.Content = Content;
this.heading = Heading;
this.content = Content;
this.image=image;
}
public Post(PostDto postDto) {
this.Heading = postDto.getHeading();
this.Content = postDto.getContent();
this.heading = postDto.getHeading();
this.content = postDto.getContent();
this.image = postDto.getImage().getBytes();
}
public Long getId()
@ -50,18 +50,18 @@ public class Post {
}
public String getHeading()
{
return Heading;
return heading;
}
public String getContent()
{
return Content;
return content;
}
public void setHeading(String Heading){
this.Heading =Heading;
this.heading =Heading;
}
public void setContent(String Content)
{
this.Content = Content;
this.content = Content;
}
public void setUser(User user) {
this.user = user;
@ -102,8 +102,8 @@ public class Post {
public String toString() {
return "Post{" +
"id=" + id +
", Heading='" + Heading + '\'' +
", Content ='" + Content + '\'' +
", heading='" + heading + '\'' +
", content ='" + content + '\'' +
'}';
}
}