Refactor blog post logic to standardize field names and improve error handling; implement pagination for post listing and add tag retrieval functionality.
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 53s
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 53s
This commit is contained in:
@@ -30,12 +30,12 @@ func (l *CreatePostLogic) CreatePost(req *types.CreatePostReq) (resp *types.Crea
|
||||
var coverID sql.NullInt64
|
||||
|
||||
// If cover image key is provided, get the file ID from files table
|
||||
if req.Cover_image_key != "" {
|
||||
if req.CoverImageKey != "" {
|
||||
query := `SELECT id FROM files WHERE file_key = $1`
|
||||
err := l.svcCtx.DB.QueryRowContext(l.ctx, query, req.Cover_image_key).Scan(&coverID.Int64)
|
||||
err := l.svcCtx.DB.QueryRowContext(l.ctx, query, req.CoverImageKey).Scan(&coverID.Int64)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
l.Errorf("Cover image file not found with key: %s", req.Cover_image_key)
|
||||
l.Errorf("Cover image file not found with key: %s", req.CoverImageKey)
|
||||
return nil, fmt.Errorf("cover image not found")
|
||||
}
|
||||
l.Errorf("Failed to get cover image file: %v", err)
|
||||
@@ -54,6 +54,6 @@ func (l *CreatePostLogic) CreatePost(req *types.CreatePostReq) (resp *types.Crea
|
||||
}
|
||||
|
||||
return &types.CreatePostResp{
|
||||
Post_id: fmt.Sprintf("%d", postID),
|
||||
PostId: fmt.Sprintf("%d", postID),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user