chore(ci, dto): update build workflow and enhance post DTOs
Some checks failed
Build Backend / build (push) Failing after 13m9s
Build Backend / build-docker (push) Has been skipped

- Added NODE_NO_WARNINGS environment variable to build and deploy workflows.
- Upgraded actions/upload-artifact and actions/download-artifact to version 4 in the build workflow.
- Introduced ContentEditedAt field in PostResponse and PostDetailResponse DTOs to track content modification timestamps.
- Updated post conversion functions to include ContentEditedAt in responses.
- Ensured ContentEditedAt is set during post updates in the repository.
This commit is contained in:
lafay
2026-03-23 14:08:36 +08:00
parent d2969a32de
commit 081e44c4ff
9 changed files with 143 additions and 105 deletions

View File

@@ -1,4 +1,4 @@
package service
package service
import (
"context"
@@ -278,25 +278,26 @@ func convertPostToAdminListResponse(post *model.Post) dto.AdminPostListResponse
}
return dto.AdminPostListResponse{
ID: post.ID,
UserID: post.UserID,
Title: post.Title,
Content: post.Content,
Images: images,
Status: string(post.Status),
LikesCount: post.LikesCount,
CommentsCount: post.CommentsCount,
FavoritesCount: post.FavoritesCount,
ViewsCount: post.ViewsCount,
IsPinned: post.IsPinned,
IsFeatured: post.IsFeatured,
IsLocked: post.IsLocked,
RejectReason: post.RejectReason,
ReviewedAt: dto.FormatTimePointer(post.ReviewedAt),
ReviewedBy: post.ReviewedBy,
CreatedAt: post.CreatedAt.Format("2006-01-02T15:04:05Z07:00"),
UpdatedAt: post.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"),
Author: author,
ID: post.ID,
UserID: post.UserID,
Title: post.Title,
Content: post.Content,
Images: images,
Status: string(post.Status),
LikesCount: post.LikesCount,
CommentsCount: post.CommentsCount,
FavoritesCount: post.FavoritesCount,
ViewsCount: post.ViewsCount,
IsPinned: post.IsPinned,
IsFeatured: post.IsFeatured,
IsLocked: post.IsLocked,
RejectReason: post.RejectReason,
ReviewedAt: dto.FormatTimePointer(post.ReviewedAt),
ReviewedBy: post.ReviewedBy,
CreatedAt: post.CreatedAt.Format("2006-01-02T15:04:05Z07:00"),
UpdatedAt: post.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"),
ContentEditedAt: dto.FormatTimePointer(post.ContentEditedAt),
Author: author,
}
}
@@ -319,28 +320,29 @@ func convertPostToAdminDetailResponse(post *model.Post) *dto.AdminPostDetailResp
}
return &dto.AdminPostDetailResponse{
ID: post.ID,
UserID: post.UserID,
CommunityID: post.CommunityID,
Title: post.Title,
Content: post.Content,
Images: images,
Status: string(post.Status),
LikesCount: post.LikesCount,
CommentsCount: post.CommentsCount,
FavoritesCount: post.FavoritesCount,
SharesCount: post.SharesCount,
ViewsCount: post.ViewsCount,
HotScore: post.HotScore,
IsPinned: post.IsPinned,
IsFeatured: post.IsFeatured,
IsLocked: post.IsLocked,
IsVote: post.IsVote,
RejectReason: post.RejectReason,
ReviewedAt: dto.FormatTimePointer(post.ReviewedAt),
ReviewedBy: post.ReviewedBy,
CreatedAt: post.CreatedAt.Format("2006-01-02T15:04:05Z07:00"),
UpdatedAt: post.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"),
Author: author,
ID: post.ID,
UserID: post.UserID,
CommunityID: post.CommunityID,
Title: post.Title,
Content: post.Content,
Images: images,
Status: string(post.Status),
LikesCount: post.LikesCount,
CommentsCount: post.CommentsCount,
FavoritesCount: post.FavoritesCount,
SharesCount: post.SharesCount,
ViewsCount: post.ViewsCount,
HotScore: post.HotScore,
IsPinned: post.IsPinned,
IsFeatured: post.IsFeatured,
IsLocked: post.IsLocked,
IsVote: post.IsVote,
RejectReason: post.RejectReason,
ReviewedAt: dto.FormatTimePointer(post.ReviewedAt),
ReviewedBy: post.ReviewedBy,
CreatedAt: post.CreatedAt.Format("2006-01-02T15:04:05Z07:00"),
UpdatedAt: post.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"),
ContentEditedAt: dto.FormatTimePointer(post.ContentEditedAt),
Author: author,
}
}

View File

@@ -283,8 +283,10 @@ func (s *VoteService) convertToPostResponse(post *model.Post, currentUserID stri
IsPinned: post.IsPinned,
IsLocked: post.IsLocked,
IsVote: post.IsVote,
CreatedAt: dto.FormatTime(post.CreatedAt),
Images: make([]dto.PostImageResponse, 0, len(post.Images)),
CreatedAt: dto.FormatTime(post.CreatedAt),
UpdatedAt: dto.FormatTime(post.UpdatedAt),
ContentEditedAt: dto.FormatTimePointer(post.ContentEditedAt),
Images: make([]dto.PostImageResponse, 0, len(post.Images)),
}
// 转换图片