feat: update articles
This commit is contained in:
parent
82571754a7
commit
c64e4dbe75
|
|
@ -57,18 +57,19 @@ func (req ArticlesCreateRequest) ToEntity() *entity.Articles {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ArticlesUpdateRequest struct {
|
type ArticlesUpdateRequest struct {
|
||||||
Title string `json:"title" validate:"required"`
|
Title string `json:"title" validate:"required"`
|
||||||
Slug string `json:"slug" validate:"required"`
|
Slug string `json:"slug" validate:"required"`
|
||||||
Description string `json:"description" validate:"required"`
|
Description string `json:"description" validate:"required"`
|
||||||
HtmlDescription string `json:"htmlDescription" validate:"required"`
|
HtmlDescription string `json:"htmlDescription" validate:"required"`
|
||||||
CategoryIds string `json:"categoryIds" validate:"required"`
|
CategoryIds string `json:"categoryIds" validate:"required"`
|
||||||
TypeId int `json:"typeId" validate:"required"`
|
TypeId int `json:"typeId" validate:"required"`
|
||||||
Tags string `json:"tags" validate:"required"`
|
Tags string `json:"tags" validate:"required"`
|
||||||
CreatedById *uint `json:"createdById"`
|
CreatedAt *string `json:"createdAt"`
|
||||||
AiArticleId *int `json:"aiArticleId"`
|
CreatedById *uint `json:"createdById"`
|
||||||
IsPublish *bool `json:"isPublish"`
|
AiArticleId *int `json:"aiArticleId"`
|
||||||
IsDraft *bool `json:"isDraft"`
|
IsPublish *bool `json:"isPublish"`
|
||||||
StatusId *int `json:"statusId"`
|
IsDraft *bool `json:"isDraft"`
|
||||||
|
StatusId *int `json:"statusId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req ArticlesUpdateRequest) ToEntity() *entity.Articles {
|
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) {
|
func (_i *articlesService) Update(id uint, req request.ArticlesUpdateRequest) (err error) {
|
||||||
_i.Log.Info().Interface("data", req).Msg("")
|
_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 {
|
func (_i *articlesService) Delete(id uint) error {
|
||||||
|
|
|
||||||
|
|
@ -8387,6 +8387,9 @@ const docTemplate = `{
|
||||||
"categoryIds": {
|
"categoryIds": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"createdAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"createdById": {
|
"createdById": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -8376,6 +8376,9 @@
|
||||||
"categoryIds": {
|
"categoryIds": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"createdAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"createdById": {
|
"createdById": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,8 @@ definitions:
|
||||||
type: integer
|
type: integer
|
||||||
categoryIds:
|
categoryIds:
|
||||||
type: string
|
type: string
|
||||||
|
createdAt:
|
||||||
|
type: string
|
||||||
createdById:
|
createdById:
|
||||||
type: integer
|
type: integer
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue