73 lines
2.3 KiB
Go
73 lines
2.3 KiB
Go
package request
|
|
|
|
import (
|
|
"narasi-ahli-be/app/database/entity"
|
|
"narasi-ahli-be/utils/paginator"
|
|
"time"
|
|
)
|
|
|
|
type ResearchJournalsQueryRequest struct {
|
|
JournalTitle *string `json:"journalTitle"`
|
|
Publisher *string `json:"publisher"`
|
|
PublishedYear *int `json:"publishedYear"`
|
|
Pagination *paginator.Pagination `json:"pagination"`
|
|
}
|
|
|
|
type ResearchJournalsCreateRequest struct {
|
|
JournalTitle string `json:"journalTitle" validate:"required,min=2,max=500"`
|
|
Publisher string `json:"publisher" validate:"required,min=2,max=255"`
|
|
JournalURL string `json:"journalUrl" validate:"required,url"`
|
|
PublishedDate *time.Time `json:"publishedDate"`
|
|
}
|
|
|
|
func (req ResearchJournalsCreateRequest) ToEntity() *entity.ResearchJournals {
|
|
return &entity.ResearchJournals{
|
|
JournalTitle: req.JournalTitle,
|
|
Publisher: req.Publisher,
|
|
JournalURL: req.JournalURL,
|
|
PublishedDate: req.PublishedDate,
|
|
}
|
|
}
|
|
|
|
type ResearchJournalsUpdateRequest struct {
|
|
JournalTitle string `json:"journalTitle" validate:"required,min=2,max=500"`
|
|
Publisher string `json:"publisher" validate:"required,min=2,max=255"`
|
|
JournalURL string `json:"journalUrl" validate:"required,url"`
|
|
PublishedDate *time.Time `json:"publishedDate"`
|
|
}
|
|
|
|
func (req ResearchJournalsUpdateRequest) ToEntity() *entity.ResearchJournals {
|
|
return &entity.ResearchJournals{
|
|
JournalTitle: req.JournalTitle,
|
|
Publisher: req.Publisher,
|
|
JournalURL: req.JournalURL,
|
|
PublishedDate: req.PublishedDate,
|
|
}
|
|
}
|
|
|
|
type ResearchJournalsQueryRequestContext struct {
|
|
JournalTitle string `json:"journalTitle"`
|
|
Publisher string `json:"publisher"`
|
|
PublishedYear string `json:"publishedYear"`
|
|
}
|
|
|
|
func (req ResearchJournalsQueryRequestContext) ToParamRequest() ResearchJournalsQueryRequest {
|
|
var request ResearchJournalsQueryRequest
|
|
|
|
if journalTitle := req.JournalTitle; journalTitle != "" {
|
|
request.JournalTitle = &journalTitle
|
|
}
|
|
if publisher := req.Publisher; publisher != "" {
|
|
request.Publisher = &publisher
|
|
}
|
|
if publishedYearStr := req.PublishedYear; publishedYearStr != "" {
|
|
// Extract year from publishedYearStr if it's a date string
|
|
if publishedYearStr != "" {
|
|
// For now, we'll handle this in the repository layer
|
|
// This could be enhanced to parse date strings
|
|
}
|
|
}
|
|
|
|
return request
|
|
}
|