feat: update articles
This commit is contained in:
parent
4390248c0e
commit
477d967f78
|
|
@ -57,18 +57,19 @@ func (req ArticlesCreateRequest) ToEntity() *entity.Articles {
|
|||
}
|
||||
|
||||
type ArticlesUpdateRequest struct {
|
||||
Title string `json:"title" validate:"required"`
|
||||
Slug string `json:"slug" validate:"required"`
|
||||
Description string `json:"description" validate:"required"`
|
||||
HtmlDescription string `json:"htmlDescription" validate:"required"`
|
||||
CategoryIds string `json:"categoryIds" validate:"required"`
|
||||
TypeId int `json:"typeId" validate:"required"`
|
||||
Tags string `json:"tags" validate:"required"`
|
||||
CreatedById *uint `json:"createdById"`
|
||||
AiArticleId *int `json:"aiArticleId"`
|
||||
IsPublish *bool `json:"isPublish"`
|
||||
IsDraft *bool `json:"isDraft"`
|
||||
StatusId *int `json:"statusId"`
|
||||
Title string `json:"title" validate:"required"`
|
||||
Slug string `json:"slug" validate:"required"`
|
||||
Description string `json:"description" validate:"required"`
|
||||
HtmlDescription string `json:"htmlDescription" validate:"required"`
|
||||
CategoryIds string `json:"categoryIds" validate:"required"`
|
||||
TypeId int `json:"typeId" validate:"required"`
|
||||
Tags string `json:"tags" validate:"required"`
|
||||
CreatedAt *string `json:"createdAt"`
|
||||
CreatedById *uint `json:"createdById"`
|
||||
AiArticleId *int `json:"aiArticleId"`
|
||||
IsPublish *bool `json:"isPublish"`
|
||||
IsDraft *bool `json:"isDraft"`
|
||||
StatusId *int `json:"statusId"`
|
||||
}
|
||||
|
||||
func (req ArticlesUpdateRequest) ToEntity() *entity.Articles {
|
||||
|
|
|
|||
|
|
@ -339,7 +339,18 @@ func (_i *articlesService) SaveThumbnail(c *fiber.Ctx) (err error) {
|
|||
|
||||
func (_i *articlesService) Update(id uint, req request.ArticlesUpdateRequest) (err error) {
|
||||
_i.Log.Info().Interface("data", req).Msg("")
|
||||
return _i.Repo.Update(id, req.ToEntity())
|
||||
newReq := req.ToEntity()
|
||||
|
||||
if req.CreatedAt != nil {
|
||||
layout := "2006-01-02 15:04:05"
|
||||
parsedTime, err := time.Parse(layout, *req.CreatedAt)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error parsing time:", err)
|
||||
}
|
||||
newReq.CreatedAt = parsedTime
|
||||
}
|
||||
|
||||
return _i.Repo.Update(id, newReq)
|
||||
}
|
||||
|
||||
func (_i *articlesService) Delete(id uint) error {
|
||||
|
|
|
|||
|
|
@ -8387,6 +8387,9 @@ const docTemplate = `{
|
|||
"categoryIds": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdById": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8376,6 +8376,9 @@
|
|||
"categoryIds": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdById": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -299,6 +299,8 @@ definitions:
|
|||
type: integer
|
||||
categoryIds:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
createdById:
|
||||
type: integer
|
||||
description:
|
||||
|
|
|
|||
Loading…
Reference in New Issue