✨ Truncate too content when listing
This commit is contained in:
@ -108,6 +108,14 @@ func listPost(c *fiber.Ctx) error {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
if c.QueryBool("truncate", true) {
|
||||
for _, item := range items {
|
||||
if item != nil {
|
||||
item = lo.ToPtr(services.TruncatePostContent(*item))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"count": count,
|
||||
"data": items,
|
||||
@ -161,6 +169,14 @@ func listPostMinimal(c *fiber.Ctx) error {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
if c.QueryBool("truncate", false) {
|
||||
for _, item := range items {
|
||||
if item != nil {
|
||||
item = lo.ToPtr(services.TruncatePostContent(*item))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"count": count,
|
||||
"data": items,
|
||||
@ -188,6 +204,14 @@ func listDraftPost(c *fiber.Ctx) error {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
if c.QueryBool("truncate", true) {
|
||||
for _, item := range items {
|
||||
if item != nil {
|
||||
item = lo.ToPtr(services.TruncatePostContent(*item))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"count": count,
|
||||
"data": items,
|
||||
|
@ -52,6 +52,14 @@ func listRecommendationNews(c *fiber.Ctx) error {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
if c.QueryBool("truncate", true) {
|
||||
for _, item := range items {
|
||||
if item != nil {
|
||||
item = lo.ToPtr(services.TruncatePostContent(*item))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"count": count,
|
||||
"data": items,
|
||||
@ -106,6 +114,14 @@ func listRecommendationFriends(c *fiber.Ctx) error {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
if c.QueryBool("truncate", true) {
|
||||
for _, item := range items {
|
||||
if item != nil {
|
||||
item = lo.ToPtr(services.TruncatePostContent(*item))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"count": count,
|
||||
"data": items,
|
||||
@ -148,6 +164,14 @@ func listRecommendationShuffle(c *fiber.Ctx) error {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
if c.QueryBool("truncate", true) {
|
||||
for _, item := range items {
|
||||
if item != nil {
|
||||
item = lo.ToPtr(services.TruncatePostContent(*item))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"count": count,
|
||||
"data": items,
|
||||
|
Reference in New Issue
Block a user