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