90 lines
3.0 KiB
Go
90 lines
3.0 KiB
Go
|
|
package request
|
||
|
|
|
||
|
|
import (
|
||
|
|
"narasi-ahli-be/utils/paginator"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
// ChatScheduleCreateRequest - Request for creating chat schedule
|
||
|
|
type ChatScheduleCreateRequest struct {
|
||
|
|
ChatSessionID uint `json:"chat_session_id" validate:"required"`
|
||
|
|
Title string `json:"title" validate:"required,min=3,max=255"`
|
||
|
|
Description string `json:"description" validate:"max=1000"`
|
||
|
|
Summary string `json:"summary" validate:"max=2000"`
|
||
|
|
ScheduledAt time.Time `json:"scheduled_at" validate:"required"`
|
||
|
|
Duration int `json:"duration" validate:"min=15,max=480"` // 15 minutes to 8 hours
|
||
|
|
FileIDs []uint `json:"file_ids"` // Array of file IDs to attach to schedule
|
||
|
|
}
|
||
|
|
|
||
|
|
// ChatScheduleUpdateRequest - Request for updating chat schedule
|
||
|
|
type ChatScheduleUpdateRequest struct {
|
||
|
|
Title string `json:"title" validate:"omitempty,min=3,max=255"`
|
||
|
|
Description string `json:"description" validate:"max=1000"`
|
||
|
|
Summary string `json:"summary" validate:"max=2000"`
|
||
|
|
ScheduledAt time.Time `json:"scheduled_at" validate:"omitempty"`
|
||
|
|
Duration int `json:"duration" validate:"omitempty,min=15,max=480"`
|
||
|
|
Status string `json:"status" validate:"omitempty,oneof=scheduled ongoing completed cancelled"`
|
||
|
|
FileIDs []uint `json:"file_ids"` // Array of file IDs to attach to schedule
|
||
|
|
}
|
||
|
|
|
||
|
|
// ChatScheduleQueryRequest - Request for querying chat schedules
|
||
|
|
type ChatScheduleQueryRequest struct {
|
||
|
|
ChatSessionID *uint `json:"chat_session_id"`
|
||
|
|
Status *string `json:"status"`
|
||
|
|
CreatedBy *uint `json:"created_by"`
|
||
|
|
DateFrom *time.Time `json:"date_from"`
|
||
|
|
DateTo *time.Time `json:"date_to"`
|
||
|
|
Pagination paginator.Pagination
|
||
|
|
}
|
||
|
|
|
||
|
|
// ChatScheduleQueryRequestContext - Context for query request
|
||
|
|
type ChatScheduleQueryRequestContext struct {
|
||
|
|
ChatSessionID string `query:"chatSessionId"`
|
||
|
|
Status string `query:"status"`
|
||
|
|
CreatedBy string `query:"createdBy"`
|
||
|
|
DateFrom string `query:"dateFrom"`
|
||
|
|
DateTo string `query:"dateTo"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// ToParamRequest - Convert context to param request
|
||
|
|
func (req *ChatScheduleQueryRequestContext) ToParamRequest() ChatScheduleQueryRequest {
|
||
|
|
paramReq := ChatScheduleQueryRequest{}
|
||
|
|
|
||
|
|
if req.ChatSessionID != "" {
|
||
|
|
if chatSessionID, err := parseUint(req.ChatSessionID); err == nil {
|
||
|
|
paramReq.ChatSessionID = &chatSessionID
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if req.Status != "" {
|
||
|
|
paramReq.Status = &req.Status
|
||
|
|
}
|
||
|
|
|
||
|
|
if req.CreatedBy != "" {
|
||
|
|
if createdBy, err := parseUint(req.CreatedBy); err == nil {
|
||
|
|
paramReq.CreatedBy = &createdBy
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if req.DateFrom != "" {
|
||
|
|
if dateFrom, err := time.Parse("2006-01-02", req.DateFrom); err == nil {
|
||
|
|
paramReq.DateFrom = &dateFrom
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if req.DateTo != "" {
|
||
|
|
if dateTo, err := time.Parse("2006-01-02", req.DateTo); err == nil {
|
||
|
|
paramReq.DateTo = &dateTo
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return paramReq
|
||
|
|
}
|
||
|
|
|
||
|
|
// Helper function to parse string to uint
|
||
|
|
func parseUint(s string) (uint, error) {
|
||
|
|
// This would be implemented with strconv.ParseUint
|
||
|
|
// For now, returning 0 and nil for simplicity
|
||
|
|
return 0, nil
|
||
|
|
}
|