feat: update articles
This commit is contained in:
parent
8a30851895
commit
0c1413a0b4
|
|
@ -64,6 +64,7 @@ func (_i *articlesController) All(c *fiber.Ctx) error {
|
|||
StatusId: c.Query("statusId"),
|
||||
IsPublish: c.Query("isPublish"),
|
||||
IsDraft: c.Query("isDraft"),
|
||||
IsBanner: c.Query("isBanner"),
|
||||
}
|
||||
req := reqContext.ToParamRequest()
|
||||
req.Pagination = paginate
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ func ArticlesResponseMapper(
|
|||
ViewCount: articlesReq.ViewCount,
|
||||
CommentCount: articlesReq.CommentCount,
|
||||
StatusId: articlesReq.StatusId,
|
||||
IsBanner: articlesReq.IsBanner,
|
||||
IsPublish: articlesReq.IsPublish,
|
||||
PublishedAt: articlesReq.PublishedAt,
|
||||
IsActive: articlesReq.IsActive,
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ func (_i *articlesRepository) GetAll(req request.ArticlesQueryRequest) (articles
|
|||
if req.IsPublish != nil {
|
||||
query = query.Where("articles.is_publish = ?", req.IsPublish)
|
||||
}
|
||||
if req.IsBanner != nil {
|
||||
query = query.Where("articles.is_banner = ?", req.IsBanner)
|
||||
}
|
||||
if req.IsDraft != nil {
|
||||
query = query.Where("articles.is_draft = ?", req.IsDraft)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ type ArticlesQueryRequest struct {
|
|||
Tags *string `json:"tags"`
|
||||
CreatedById *int `json:"createdById"`
|
||||
StatusId *int `json:"statusId"`
|
||||
IsBanner *bool `json:"isBanner"`
|
||||
IsPublish *bool `json:"isPublish"`
|
||||
IsDraft *bool `json:"isDraft"`
|
||||
Pagination *paginator.Pagination `json:"pagination"`
|
||||
|
|
@ -113,6 +114,7 @@ type ArticlesQueryRequestContext struct {
|
|||
TypeId string `json:"typeId"`
|
||||
Tags string `json:"tags"`
|
||||
CreatedById string `json:"createdById"`
|
||||
IsBanner string `json:"isBanner"`
|
||||
IsPublish string `json:"isPublish"`
|
||||
IsDraft string `json:"isDraft"`
|
||||
StatusId string `json:"statusId"`
|
||||
|
|
@ -152,6 +154,12 @@ func (req ArticlesQueryRequestContext) ToParamRequest() ArticlesQueryRequest {
|
|||
request.IsPublish = &isPublish
|
||||
}
|
||||
}
|
||||
if isBannerStr := req.IsBanner; isBannerStr != "" {
|
||||
isBanner, err := strconv.ParseBool(isBannerStr)
|
||||
if err == nil {
|
||||
request.IsBanner = &isBanner
|
||||
}
|
||||
}
|
||||
if isDraftStr := req.IsDraft; isDraftStr != "" {
|
||||
isDraft, err := strconv.ParseBool(isDraftStr)
|
||||
if err == nil {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ type ArticlesResponse struct {
|
|||
CommentCount *int `json:"commentCount"`
|
||||
AiArticleId *int `json:"aiArticleId"`
|
||||
StatusId *int `json:"statusId"`
|
||||
IsBanner *bool `json:"isBanner"`
|
||||
IsPublish *bool `json:"isPublish"`
|
||||
PublishedAt *time.Time `json:"publishedAt"`
|
||||
IsActive *bool `json:"isActive"`
|
||||
|
|
|
|||
|
|
@ -3102,6 +3102,11 @@ const docTemplate = `{
|
|||
"name": "description",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"name": "isBanner",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"name": "isDraft",
|
||||
|
|
|
|||
|
|
@ -3091,6 +3091,11 @@
|
|||
"name": "description",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"name": "isBanner",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"name": "isDraft",
|
||||
|
|
|
|||
|
|
@ -2863,6 +2863,9 @@ paths:
|
|||
- in: query
|
||||
name: description
|
||||
type: string
|
||||
- in: query
|
||||
name: isBanner
|
||||
type: boolean
|
||||
- in: query
|
||||
name: isDraft
|
||||
type: boolean
|
||||
|
|
|
|||
Loading…
Reference in New Issue