mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-24 15:10:48 +08:00
refactor: extract post dtos
This commit is contained in:
14
backend/src/main/java/com/openisle/dto/AuthorDto.java
Normal file
14
backend/src/main/java/com/openisle/dto/AuthorDto.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.openisle.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* DTO representing a post or comment author.
|
||||
*/
|
||||
@Data
|
||||
public class AuthorDto {
|
||||
private Long id;
|
||||
private String username;
|
||||
private String avatar;
|
||||
}
|
||||
|
||||
16
backend/src/main/java/com/openisle/dto/CategoryDto.java
Normal file
16
backend/src/main/java/com/openisle/dto/CategoryDto.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.openisle.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* DTO representing a post category.
|
||||
*/
|
||||
@Data
|
||||
public class CategoryDto {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String description;
|
||||
private String icon;
|
||||
private String smallIcon;
|
||||
}
|
||||
|
||||
21
backend/src/main/java/com/openisle/dto/CommentDto.java
Normal file
21
backend/src/main/java/com/openisle/dto/CommentDto.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.openisle.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DTO representing a comment and its nested replies.
|
||||
*/
|
||||
@Data
|
||||
public class CommentDto {
|
||||
private Long id;
|
||||
private String content;
|
||||
private LocalDateTime createdAt;
|
||||
private AuthorDto author;
|
||||
private List<CommentDto> replies;
|
||||
private List<ReactionDto> reactions;
|
||||
private int reward;
|
||||
}
|
||||
|
||||
16
backend/src/main/java/com/openisle/dto/PostDetailDto.java
Normal file
16
backend/src/main/java/com/openisle/dto/PostDetailDto.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.openisle.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Detailed DTO for a post, including comments.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PostDetailDto extends PostSummaryDto {
|
||||
private List<CommentDto> comments;
|
||||
}
|
||||
|
||||
18
backend/src/main/java/com/openisle/dto/PostRequest.java
Normal file
18
backend/src/main/java/com/openisle/dto/PostRequest.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.openisle.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Request body for creating or updating a post.
|
||||
*/
|
||||
@Data
|
||||
public class PostRequest {
|
||||
private Long categoryId;
|
||||
private String title;
|
||||
private String content;
|
||||
private List<Long> tagIds;
|
||||
private String captcha;
|
||||
}
|
||||
|
||||
30
backend/src/main/java/com/openisle/dto/PostSummaryDto.java
Normal file
30
backend/src/main/java/com/openisle/dto/PostSummaryDto.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.openisle.dto;
|
||||
|
||||
import com.openisle.model.PostStatus;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Lightweight DTO for listing posts without comments.
|
||||
*/
|
||||
@Data
|
||||
public class PostSummaryDto {
|
||||
private Long id;
|
||||
private String title;
|
||||
private String content;
|
||||
private LocalDateTime createdAt;
|
||||
private AuthorDto author;
|
||||
private CategoryDto category;
|
||||
private List<TagDto> tags;
|
||||
private long views;
|
||||
private PostStatus status;
|
||||
private LocalDateTime pinnedAt;
|
||||
private LocalDateTime lastReplyAt;
|
||||
private List<ReactionDto> reactions;
|
||||
private List<AuthorDto> participants;
|
||||
private boolean subscribed;
|
||||
private int reward;
|
||||
}
|
||||
|
||||
18
backend/src/main/java/com/openisle/dto/ReactionDto.java
Normal file
18
backend/src/main/java/com/openisle/dto/ReactionDto.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.openisle.dto;
|
||||
|
||||
import com.openisle.model.ReactionType;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* DTO representing a reaction on a post or comment.
|
||||
*/
|
||||
@Data
|
||||
public class ReactionDto {
|
||||
private Long id;
|
||||
private ReactionType type;
|
||||
private String user;
|
||||
private Long postId;
|
||||
private Long commentId;
|
||||
private int reward;
|
||||
}
|
||||
|
||||
16
backend/src/main/java/com/openisle/dto/TagDto.java
Normal file
16
backend/src/main/java/com/openisle/dto/TagDto.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.openisle.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* DTO representing a tag.
|
||||
*/
|
||||
@Data
|
||||
public class TagDto {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String description;
|
||||
private String icon;
|
||||
private String smallIcon;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user