feat(channel): integrate channel functionality into post management
- Added Channel support in Post model, including ChannelID field in PostRequest and PostResponse DTOs. - Updated PostService and PostRepository to handle channel-specific logic for creating and listing posts. - Introduced ChannelRepository and ChannelService, along with corresponding handlers for managing channels. - Enhanced router to include routes for channel management and public channel listing. - Seeded default channels in the database during initialization.
This commit is contained in:
@@ -135,6 +135,7 @@ type PostImageResponse struct {
|
||||
type PostResponse struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
ChannelID *string `json:"channel_id,omitempty"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Images []PostImageResponse `json:"images"`
|
||||
@@ -159,6 +160,7 @@ type PostResponse struct {
|
||||
type PostDetailResponse struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
ChannelID *string `json:"channel_id,omitempty"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Images []PostImageResponse `json:"images"`
|
||||
@@ -870,7 +872,7 @@ type GetMyMemberInfoParams struct {
|
||||
type CreateVotePostRequest struct {
|
||||
Title string `json:"title" binding:"required,max=200"`
|
||||
Content string `json:"content" binding:"max=2000"`
|
||||
CommunityID string `json:"community_id"`
|
||||
ChannelID *string `json:"channel_id,omitempty"`
|
||||
Images []string `json:"images"`
|
||||
VoteOptions []string `json:"vote_options" binding:"required,min=2,max=10"` // 投票选项,至少2个最多10个
|
||||
}
|
||||
@@ -930,7 +932,7 @@ type AdminPostListResponse struct {
|
||||
type AdminPostDetailResponse struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
CommunityID string `json:"community_id"`
|
||||
ChannelID *string `json:"channel_id,omitempty"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
Images []PostImageResponse `json:"images"`
|
||||
|
||||
@@ -50,6 +50,7 @@ func ConvertPostToResponse(post *model.Post, isLiked, isFavorited bool) *PostRes
|
||||
return &PostResponse{
|
||||
ID: post.ID,
|
||||
UserID: post.UserID,
|
||||
ChannelID: post.ChannelID,
|
||||
Title: post.Title,
|
||||
Content: post.Content,
|
||||
Images: images,
|
||||
@@ -90,6 +91,7 @@ func ConvertPostToDetailResponse(post *model.Post, isLiked, isFavorited bool) *P
|
||||
return &PostDetailResponse{
|
||||
ID: post.ID,
|
||||
UserID: post.UserID,
|
||||
ChannelID: post.ChannelID,
|
||||
Title: post.Title,
|
||||
Content: post.Content,
|
||||
Images: images,
|
||||
|
||||
Reference in New Issue
Block a user