diff --git a/app/database/entity/advertisement.entity.go b/app/database/entity/advertisement.entity.go deleted file mode 100644 index 4dcc541..0000000 --- a/app/database/entity/advertisement.entity.go +++ /dev/null @@ -1,20 +0,0 @@ -package entity - -import ( - "time" -) - -type Advertisement struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Title string `json:"title" gorm:"type:varchar"` - Description string `json:"description" gorm:"type:varchar"` - RedirectLink string `json:"redirect_link" gorm:"type:varchar"` - ContentFilePath *string `json:"content_file_path" gorm:"type:varchar"` - ContentFileName *string `json:"content_file_name" gorm:"type:varchar"` - Placement string `json:"placement" gorm:"type:varchar"` - StatusId int `json:"status_id" gorm:"type:int4"` - IsPublish bool `json:"is_publish" gorm:"type:bool"` - IsActive bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` -} diff --git a/app/database/entity/ai_chat_logs.entity.go b/app/database/entity/ai_chat_logs.entity.go deleted file mode 100644 index 216bba1..0000000 --- a/app/database/entity/ai_chat_logs.entity.go +++ /dev/null @@ -1,18 +0,0 @@ -package entity - -import ( - "jaecoo-be/app/database/entity/users" - "time" -) - -type AIChatLogs struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - SessionID uint `json:"session_id" gorm:"type:int4;not null;index"` - UserID uint `json:"user_id" gorm:"type:int4;not null;index"` - StartDate time.Time `json:"start_date" gorm:"not null"` - EndDate *time.Time `json:"end_date"` - TotalDuration int64 `json:"total_duration" gorm:"type:bigint;default:0"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - User *users.Users `json:"user" gorm:"foreignKey:UserID;references:ID"` -} diff --git a/app/database/entity/ai_chat_messages.entity.go b/app/database/entity/ai_chat_messages.entity.go deleted file mode 100644 index d35062e..0000000 --- a/app/database/entity/ai_chat_messages.entity.go +++ /dev/null @@ -1,14 +0,0 @@ -package entity - -import ( - "time" -) - -type AIChatMessages struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - SessionID string `json:"session_id" gorm:"type:varchar;not null;index"` - MessageType string `json:"message_type" gorm:"type:varchar;not null"` - Content string `json:"content" gorm:"type:text;not null"` - IsActive bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` -} diff --git a/app/database/entity/ai_chat_sessions.entity.go b/app/database/entity/ai_chat_sessions.entity.go deleted file mode 100644 index 43d376b..0000000 --- a/app/database/entity/ai_chat_sessions.entity.go +++ /dev/null @@ -1,19 +0,0 @@ -package entity - -import ( - "jaecoo-be/app/database/entity/users" - "time" -) - -type AIChatSessions struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - SessionID string `json:"session_id" gorm:"type:varchar;not null;unique;index"` - UserID uint `json:"user_id" gorm:"type:int4;not null;index"` - AgentID string `json:"agent_id" gorm:"type:varchar;not null"` - Title string `json:"title" gorm:"type:varchar;not null"` - MessageCount int `json:"message_count" gorm:"type:int4;default:0"` - IsActive bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - User *users.Users `json:"user" gorm:"foreignKey:UserID;references:ID"` -} diff --git a/app/database/entity/campaign_approvals.entity.go b/app/database/entity/campaign_approvals.entity.go deleted file mode 100644 index 5f92cdb..0000000 --- a/app/database/entity/campaign_approvals.entity.go +++ /dev/null @@ -1,21 +0,0 @@ -package entity - -import ( - users "jaecoo-be/app/database/entity/users" - "time" - - "gorm.io/gorm" -) - -type CampaignApprovals struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - CampaignID uint `json:"campaign_id" gorm:"type:int4"` - Campaign Campaigns `json:"campaign" gorm:"foreignKey:CampaignID;references:ID"` - ApproverID uint `json:"approver_id" gorm:"type:int4"` - Approver users.Users `json:"approver" gorm:"foreignKey:ApproverID;references:ID"` - Status string `json:"status" gorm:"type:varchar(20);default:'pending'"` // pending, approved, rejected - Notes *string `json:"notes" gorm:"type:text"` - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` -} diff --git a/app/database/entity/campaign_chats.entity.go b/app/database/entity/campaign_chats.entity.go deleted file mode 100644 index 7604b22..0000000 --- a/app/database/entity/campaign_chats.entity.go +++ /dev/null @@ -1,21 +0,0 @@ -package entity - -import ( - users "jaecoo-be/app/database/entity/users" - "time" - - "gorm.io/gorm" -) - -type CampaignChats struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - CampaignID uint `json:"campaign_id" gorm:"type:int4"` - Campaign Campaigns `json:"campaign" gorm:"foreignKey:CampaignID;references:ID"` - SenderID uint `json:"sender_id" gorm:"type:int4"` - Sender users.Users `json:"sender" gorm:"foreignKey:SenderID;references:ID"` - Message string `json:"message" gorm:"type:text"` - AttachmentURL *string `json:"attachment_url" gorm:"type:text"` - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` -} diff --git a/app/database/entity/campaign_destination_relations.entity.go b/app/database/entity/campaign_destination_relations.entity.go deleted file mode 100644 index 0041058..0000000 --- a/app/database/entity/campaign_destination_relations.entity.go +++ /dev/null @@ -1,22 +0,0 @@ -package entity - -import ( - "time" - - "gorm.io/gorm" -) - -type CampaignDestinationRelations struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - CampaignID uint `json:"campaign_id" gorm:"type:int4"` - Campaign Campaigns `json:"campaign" gorm:"foreignKey:CampaignID;references:ID"` - DestinationID uint `json:"destination_id" gorm:"type:int4"` - Destination CampaignDestinations `json:"destination" gorm:"foreignKey:DestinationID;references:ID"` - ScheduledAt *time.Time `json:"scheduled_at" gorm:"type:timestamp"` - PublishStatus string `json:"publish_status" gorm:"type:varchar(20);default:'pending'"` // pending, success, failed - PublishResponse *string `json:"publish_response" gorm:"type:text"` - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` -} diff --git a/app/database/entity/campaign_destinations.entity.go b/app/database/entity/campaign_destinations.entity.go deleted file mode 100644 index 70ffd3d..0000000 --- a/app/database/entity/campaign_destinations.entity.go +++ /dev/null @@ -1,21 +0,0 @@ -package entity - -import ( - "time" - "gorm.io/gorm" -) - -type CampaignDestinations struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - CampaignTypeID uint `json:"campaign_type_id" gorm:"type:int4"` - CampaignType CampaignTypes `json:"campaign_type" gorm:"foreignKey:CampaignTypeID;references:ID"` - Name string `json:"name" gorm:"type:varchar(150)"` - SubType *string `json:"sub_type" gorm:"type:varchar(100)"` - Description *string `json:"description" gorm:"type:text"` - URL *string `json:"url" gorm:"type:varchar(255)"` - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` -} - diff --git a/app/database/entity/campaign_files.entity.go b/app/database/entity/campaign_files.entity.go deleted file mode 100644 index ee41c10..0000000 --- a/app/database/entity/campaign_files.entity.go +++ /dev/null @@ -1,22 +0,0 @@ -package entity - -import ( - "time" - "gorm.io/gorm" -) - -type CampaignFiles struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - CampaignID uint `json:"campaign_id" gorm:"type:int4"` - Campaign Campaigns `json:"campaign" gorm:"foreignKey:CampaignID;references:ID"` - Type string `json:"type" gorm:"type:varchar(20)"` // url, file - FileURL *string `json:"file_url" gorm:"type:text"` - ExternalURL *string `json:"external_url" gorm:"type:text"` - IsDraft *bool `json:"is_draft" gorm:"type:bool;default:false"` - IsPublish *bool `json:"is_publish" gorm:"type:bool;default:false"` - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` -} - diff --git a/app/database/entity/campaign_types.entity.go b/app/database/entity/campaign_types.entity.go deleted file mode 100644 index 2364dc2..0000000 --- a/app/database/entity/campaign_types.entity.go +++ /dev/null @@ -1,17 +0,0 @@ -package entity - -import ( - "time" - "gorm.io/gorm" -) - -type CampaignTypes struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Name string `json:"name" gorm:"type:varchar(150)"` - Description *string `json:"description" gorm:"type:text"` - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` -} - diff --git a/app/database/entity/campaigns.entity.go b/app/database/entity/campaigns.entity.go deleted file mode 100644 index 9399ca7..0000000 --- a/app/database/entity/campaigns.entity.go +++ /dev/null @@ -1,29 +0,0 @@ -package entity - -import ( - users "jaecoo-be/app/database/entity/users" - "time" - - "gorm.io/gorm" -) - -type Campaigns struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Title string `json:"title" gorm:"type:varchar(255)"` - CampaignTypeID uint `json:"campaign_type_id" gorm:"type:int4"` - CampaignType CampaignTypes `json:"campaign_type" gorm:"foreignKey:CampaignTypeID;references:ID"` - StartDate *time.Time `json:"start_date" gorm:"type:date"` - EndDate *time.Time `json:"end_date" gorm:"type:date"` - MediaTypeSelected *string `json:"media_type_selected" gorm:"type:varchar(100)"` - MediaItemSelected *string `json:"media_item_selected" gorm:"type:text"` // JSON array or comma-separated - Purpose *string `json:"purpose" gorm:"type:text"` - MediaPromote *bool `json:"media_promote" gorm:"type:bool;default:false"` - Description *string `json:"description" gorm:"type:text"` - CreatorID uint `json:"creator_id" gorm:"type:int4"` - Creator users.Users `json:"creator" gorm:"foreignKey:CreatorID;references:ID"` - Status string `json:"status" gorm:"type:varchar(50);default:'draft'"` // draft, waiting_approval, approved, rejected, published, archived - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` -} diff --git a/app/database/entity/chat_messages.entity.go b/app/database/entity/chat_messages.entity.go deleted file mode 100644 index 43ae307..0000000 --- a/app/database/entity/chat_messages.entity.go +++ /dev/null @@ -1,24 +0,0 @@ -package entity - -import ( - "jaecoo-be/app/database/entity/users" - "time" -) - -type ChatMessages struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - ChatSessionID uint `json:"chat_session_id" gorm:"type:int4;not null;index"` - SenderID uint `json:"sender_id" gorm:"type:int4;not null;index"` - Message string `json:"message" gorm:"type:text;not null"` - MessageType string `json:"message_type" gorm:"type:varchar(20);not null;default:'text';check:message_type IN ('text', 'image', 'file', 'user', 'assistant')"` // 'text', 'image', 'file', 'user', 'assistant' - IsEdited bool `json:"is_edited" gorm:"default:false"` - EditedAt *time.Time `json:"edited_at"` - IsDeleted bool `json:"is_deleted" gorm:"default:false"` - DeletedAt *time.Time `json:"deleted_at"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - - // Relationships - ChatSession *ChatSessions `json:"chat_session" gorm:"foreignKey:ChatSessionID;references:ID"` - Sender *users.Users `json:"sender" gorm:"foreignKey:SenderID;references:ID"` -} diff --git a/app/database/entity/chat_participants.entity.go b/app/database/entity/chat_participants.entity.go deleted file mode 100644 index f70864a..0000000 --- a/app/database/entity/chat_participants.entity.go +++ /dev/null @@ -1,21 +0,0 @@ -package entity - -import ( - "jaecoo-be/app/database/entity/users" - "time" -) - -type ChatParticipants struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - ChatSessionID uint `json:"chat_session_id" gorm:"type:int4;not null;index"` - UserID uint `json:"user_id" gorm:"type:int4;not null;index"` - JoinedAt time.Time `json:"joined_at" gorm:"default:now()"` - LeftAt *time.Time `json:"left_at"` - IsActive bool `json:"is_active" gorm:"default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - - // Relationships - ChatSession *ChatSessions `json:"chat_session" gorm:"foreignKey:ChatSessionID;references:ID"` - User *users.Users `json:"user" gorm:"foreignKey:UserID;references:ID"` -} diff --git a/app/database/entity/chat_schedule_files.entity.go b/app/database/entity/chat_schedule_files.entity.go deleted file mode 100644 index adc5d14..0000000 --- a/app/database/entity/chat_schedule_files.entity.go +++ /dev/null @@ -1,23 +0,0 @@ -package entity - -import ( - "time" -) - -type ChatScheduleFiles struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - ChatScheduleID uint `json:"chat_schedule_id" gorm:"type:int4;not null;index"` - FileName string `json:"file_name" gorm:"type:varchar(255);not null"` - OriginalName string `json:"original_name" gorm:"type:varchar(255);not null"` - FilePath string `json:"file_path" gorm:"type:varchar(500);not null"` - FileSize int64 `json:"file_size" gorm:"type:int8"` - MimeType string `json:"mime_type" gorm:"type:varchar(100)"` - FileType string `json:"file_type" gorm:"type:varchar(20);not null;check:file_type IN ('article', 'journal', 'video', 'audio', 'document', 'other')"` - Description string `json:"description" gorm:"type:text"` - IsRequired bool `json:"is_required" gorm:"default:false"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - - // Relationships - ChatSchedule *ChatSchedules `json:"chat_schedule" gorm:"foreignKey:ChatScheduleID;references:ID"` -} diff --git a/app/database/entity/chat_schedules.entity.go b/app/database/entity/chat_schedules.entity.go deleted file mode 100644 index c2dfa9e..0000000 --- a/app/database/entity/chat_schedules.entity.go +++ /dev/null @@ -1,27 +0,0 @@ -package entity - -import ( - "jaecoo-be/app/database/entity/users" - "time" -) - -type ChatSchedules struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - ChatSessionID uint `json:"chat_session_id" gorm:"type:int4;not null;index"` - Title string `json:"title" gorm:"type:varchar(255);not null"` - Description string `json:"description" gorm:"type:text"` - Summary string `json:"summary" gorm:"type:text"` - ScheduledAt time.Time `json:"scheduled_at" gorm:"not null"` - Duration int `json:"duration" gorm:"type:int4;default:60"` // duration in minutes - Status string `json:"status" gorm:"type:varchar(20);not null;default:'scheduled';check:status IN ('scheduled', 'ongoing', 'completed', 'cancelled')"` - IsReminderSent bool `json:"is_reminder_sent" gorm:"default:false"` - ReminderSentAt *time.Time `json:"reminder_sent_at"` - CreatedBy uint `json:"created_by" gorm:"type:int4;not null;index"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - - // Relationships - ChatSession *ChatSessions `json:"chat_session" gorm:"foreignKey:ChatSessionID;references:ID"` - Creator *users.Users `json:"creator" gorm:"foreignKey:CreatedBy;references:ID"` - Files []*ChatScheduleFiles `json:"files" gorm:"foreignKey:ChatScheduleID;references:ID"` -} diff --git a/app/database/entity/chat_sessions.entity.go b/app/database/entity/chat_sessions.entity.go deleted file mode 100644 index d505475..0000000 --- a/app/database/entity/chat_sessions.entity.go +++ /dev/null @@ -1,20 +0,0 @@ -package entity - -import ( - "jaecoo-be/app/database/entity/users" - "time" -) - -type ChatSessions struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Name *string `json:"name" gorm:"type:varchar(255)"` // null for personal chat, filled for group chat - Type string `json:"type" gorm:"type:varchar(20);not null;default:'personal'"` // 'personal' or 'group' - CreatedBy uint `json:"created_by" gorm:"type:int4;not null;index"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - - // Relationships - Creator *users.Users `json:"creator" gorm:"foreignKey:CreatedBy;references:ID"` - Participants []*ChatParticipants `json:"participants" gorm:"foreignKey:ChatSessionID;references:ID"` - Messages []*ChatMessages `json:"messages" gorm:"foreignKey:ChatSessionID;references:ID"` -} diff --git a/app/database/entity/conversations.entity.go b/app/database/entity/conversations.entity.go deleted file mode 100644 index 9056d4e..0000000 --- a/app/database/entity/conversations.entity.go +++ /dev/null @@ -1,17 +0,0 @@ -package entity - -import ( - "jaecoo-be/app/database/entity/users" - "time" -) - -type Conversations struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Participant1ID uint `json:"participant1_id" gorm:"type:int4;not null;index"` - Participant2ID uint `json:"participant2_id" gorm:"type:int4;not null;index"` - LastMessageAt *time.Time `json:"last_message_at"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - Participant1 *users.Users `json:"participant1" gorm:"foreignKey:Participant1ID;references:ID"` - Participant2 *users.Users `json:"participant2" gorm:"foreignKey:Participant2ID;references:ID"` -} diff --git a/app/database/entity/ebook_purchases.entity.go b/app/database/entity/ebook_purchases.entity.go deleted file mode 100644 index 88e0ecb..0000000 --- a/app/database/entity/ebook_purchases.entity.go +++ /dev/null @@ -1,26 +0,0 @@ -package entity - -import ( - users "jaecoo-be/app/database/entity/users" - "time" -) - -type EbookPurchases struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - BuyerId uint `json:"buyer_id" gorm:"type:int4"` - Buyer *users.Users `json:"buyer" gorm:"foreignKey:BuyerId;references:ID"` - EbookId uint `json:"ebook_id" gorm:"type:int4"` - Ebook *Ebooks `json:"ebook" gorm:"foreignKey:EbookId;references:ID"` - PurchasePrice float64 `json:"purchase_price" gorm:"type:decimal(10,2)"` - PaymentMethod *string `json:"payment_method" gorm:"type:varchar"` - PaymentStatus *string `json:"payment_status" gorm:"type:varchar;default:'pending'"` - TransactionId *string `json:"transaction_id" gorm:"type:varchar"` - PaymentProof *string `json:"payment_proof" gorm:"type:varchar"` - PaymentDate *time.Time `json:"payment_date" gorm:"type:timestamp"` - DownloadCount *int `json:"download_count" gorm:"type:int4;default:0"` - LastDownloadAt *time.Time `json:"last_download_at" gorm:"type:timestamp"` - StatusId *int `json:"status_id" gorm:"type:int4;default:1"` - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` -} diff --git a/app/database/entity/ebook_ratings.entity.go b/app/database/entity/ebook_ratings.entity.go deleted file mode 100644 index 5dc1550..0000000 --- a/app/database/entity/ebook_ratings.entity.go +++ /dev/null @@ -1,24 +0,0 @@ -package entity - -import ( - users "jaecoo-be/app/database/entity/users" - "time" -) - -type EbookRatings struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - UserId uint `json:"user_id" gorm:"type:int4"` - User *users.Users `json:"user" gorm:"foreignKey:UserId;references:ID"` - EbookId uint `json:"ebook_id" gorm:"type:int4"` - Ebook *Ebooks `json:"ebook" gorm:"foreignKey:EbookId;references:ID"` - PurchaseId uint `json:"purchase_id" gorm:"type:int4"` - Purchase *EbookPurchases `json:"purchase" gorm:"foreignKey:PurchaseId;references:ID"` - Rating int `json:"rating" gorm:"type:int4;check:rating >= 1 AND rating <= 5"` - Review *string `json:"review" gorm:"type:text"` - IsAnonymous *bool `json:"is_anonymous" gorm:"type:bool;default:false"` - IsVerified *bool `json:"is_verified" gorm:"type:bool;default:true"` - StatusId *int `json:"status_id" gorm:"type:int4;default:1"` - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` -} diff --git a/app/database/entity/ebook_wishlists.entity.go b/app/database/entity/ebook_wishlists.entity.go deleted file mode 100644 index aca7d2e..0000000 --- a/app/database/entity/ebook_wishlists.entity.go +++ /dev/null @@ -1,16 +0,0 @@ -package entity - -import ( - users "jaecoo-be/app/database/entity/users" - "time" -) - -type EbookWishlists struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - UserId uint `json:"user_id" gorm:"type:int4"` - User *users.Users `json:"user" gorm:"foreignKey:UserId;references:ID"` - EbookId uint `json:"ebook_id" gorm:"type:int4"` - Ebook *Ebooks `json:"ebook" gorm:"foreignKey:EbookId;references:ID"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` -} diff --git a/app/database/entity/ebooks.entity.go b/app/database/entity/ebooks.entity.go deleted file mode 100644 index b6484a5..0000000 --- a/app/database/entity/ebooks.entity.go +++ /dev/null @@ -1,40 +0,0 @@ -package entity - -import ( - users "jaecoo-be/app/database/entity/users" - "time" -) - -type Ebooks struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Title string `json:"title" gorm:"type:varchar"` - Slug string `json:"slug" gorm:"type:varchar"` - Description string `json:"description" gorm:"type:varchar"` - Price float64 `json:"price" gorm:"type:decimal(10,2)"` - PdfFilePath *string `json:"pdf_file_path" gorm:"type:varchar"` - PdfFileName *string `json:"pdf_file_name" gorm:"type:varchar"` - PdfFileSize *int64 `json:"pdf_file_size" gorm:"type:int8"` - ThumbnailPath *string `json:"thumbnail_path" gorm:"type:varchar"` - ThumbnailName *string `json:"thumbnail_name" gorm:"type:varchar"` - AuthorId uint `json:"author_id" gorm:"type:int4"` - Author *users.Users `json:"author" gorm:"foreignKey:AuthorId;references:ID"` - Category *string `json:"category" gorm:"type:varchar"` - Tags *string `json:"tags" gorm:"type:varchar"` - PageCount *int `json:"page_count" gorm:"type:int4"` - Language *string `json:"language" gorm:"type:varchar;default:'id'"` - Isbn *string `json:"isbn" gorm:"type:varchar"` - Publisher *string `json:"publisher" gorm:"type:varchar"` - PublishedYear *int `json:"published_year" gorm:"type:int4"` - DownloadCount *int `json:"download_count" gorm:"type:int4;default:0"` - PurchaseCount *int `json:"purchase_count" gorm:"type:int4;default:0"` - WishlistCount *int `json:"wishlist_count" gorm:"type:int4;default:0"` - Rating *float64 `json:"rating" gorm:"type:decimal(3,2);default:0"` - ReviewCount *int `json:"review_count" gorm:"type:int4;default:0"` - StatusId *int `json:"status_id" gorm:"type:int4;default:1"` - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - IsPublished *bool `json:"is_published" gorm:"type:bool;default:false"` - PublishedAt *time.Time `json:"published_at" gorm:"type:timestamp"` - CreatedById *uint `json:"created_by_id" gorm:"type:int4"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` -} diff --git a/app/database/entity/education_history.entity.go b/app/database/entity/education_history.entity.go deleted file mode 100644 index a210d07..0000000 --- a/app/database/entity/education_history.entity.go +++ /dev/null @@ -1,19 +0,0 @@ -package entity - -import ( - "jaecoo-be/app/database/entity/users" - "time" -) - -type EducationHistory struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - UserID uint `json:"user_id" gorm:"type:int4;not null;index"` - SchoolName string `json:"school_name" gorm:"type:varchar;not null"` - Major string `json:"major" gorm:"type:varchar;not null"` - EducationLevel string `json:"education_level" gorm:"type:varchar;not null"` - GraduationYear int `json:"graduation_year" gorm:"type:int4;not null"` - CertificateImage *string `json:"certificate_image" gorm:"type:varchar"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - User *users.Users `json:"user" gorm:"foreignKey:UserID;references:ID"` -} diff --git a/app/database/entity/magazine_files.entity.go b/app/database/entity/magazine_files.entity.go deleted file mode 100644 index c16ad49..0000000 --- a/app/database/entity/magazine_files.entity.go +++ /dev/null @@ -1,24 +0,0 @@ -package entity - -import "time" - -type MagazineFiles struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Title string `json:"title" gorm:"type:varchar"` - Description string `json:"description" gorm:"type:varchar"` - MagazineId uint `json:"magazine_id" gorm:"type:int4"` - DownloadCount *int `json:"download_count" gorm:"type:int4"` - StatusId int `json:"status_id" gorm:"type:int4"` - IsPublish *bool `json:"is_publish" gorm:"type:bool"` - FilePath *string `json:"file_path" gorm:"type:varchar"` - FileUrl *string `json:"file_url" gorm:"type:varchar"` - FileName *string `json:"file_name" gorm:"type:varchar"` - FileAlt *string `json:"file_alt" gorm:"type:varchar"` - WidthPixel *string `json:"width_pixel" gorm:"type:varchar"` - HeightPixel *string `json:"height_pixel" gorm:"type:varchar"` - Size *string `json:"size" gorm:"type:varchar"` - PublishedAt *time.Time `json:"published_at" gorm:"type:timestamp"` - IsActive bool `json:"is_active" gorm:"type:bool"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` -} diff --git a/app/database/entity/magazines.entity.go b/app/database/entity/magazines.entity.go deleted file mode 100644 index 3cfc206..0000000 --- a/app/database/entity/magazines.entity.go +++ /dev/null @@ -1,20 +0,0 @@ -package entity - -import "time" - -type Magazines struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Title string `json:"title" gorm:"type:varchar"` - Description string `json:"description" gorm:"type:varchar"` - ThumbnailName *string `json:"thumbnail_name" gorm:"type:varchar"` - ThumbnailPath *string `json:"thumbnail_path" gorm:"type:varchar"` - ThumbnailUrl *string `json:"thumbnail_url" gorm:"type:varchar"` - PageUrl *string `json:"page_url" gorm:"type:varchar"` - CreatedById *uint `json:"created_by_id" gorm:"type:int4"` - StatusId int `json:"status_id" gorm:"type:int4"` - IsPublish *bool `json:"is_publish" gorm:"type:bool"` - PublishedAt *time.Time `json:"published_at" gorm:"type:timestamp"` - IsActive bool `json:"is_active" gorm:"type:bool"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` -} diff --git a/app/database/entity/master_menus.entity.go b/app/database/entity/master_menus.entity.go deleted file mode 100644 index 143e764..0000000 --- a/app/database/entity/master_menus.entity.go +++ /dev/null @@ -1,18 +0,0 @@ -package entity - -import "time" - -type MasterMenus struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Name string `json:"name" gorm:"type:varchar"` - Description string `json:"description" gorm:"type:varchar"` - ModuleId int `json:"module_id" gorm:"type:int4"` - ParentMenuId *int `json:"parent_menu_id" gorm:"type:int4"` - Icon *string `json:"icon" gorm:"type:varchar"` - Group string `json:"group" gorm:"type:varchar"` - Position *int `json:"position" gorm:"type:int4"` - StatusId int `json:"status_id" gorm:"type:int4"` - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` -} diff --git a/app/database/entity/master_modules.entity.go b/app/database/entity/master_modules.entity.go deleted file mode 100644 index 0d39445..0000000 --- a/app/database/entity/master_modules.entity.go +++ /dev/null @@ -1,16 +0,0 @@ -package entity - -import ( - "time" -) - -type MasterModules struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Name string `json:"name" gorm:"type:varchar"` - Description string `json:"description" gorm:"type:varchar"` - PathUrl string `json:"path_url" gorm:"type:varchar"` - StatusId int `json:"status_id" gorm:"type:int4"` - IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` -} diff --git a/app/database/entity/master_statuses.entity.go b/app/database/entity/master_statuses.entity.go deleted file mode 100644 index 75d20a0..0000000 --- a/app/database/entity/master_statuses.entity.go +++ /dev/null @@ -1,7 +0,0 @@ -package entity - -type MasterStatuses struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Name string `json:"name" gorm:"type:varchar"` - IsActive bool `json:"is_active" gorm:"type:bool"` -} diff --git a/app/database/entity/research_journals.entity.go b/app/database/entity/research_journals.entity.go deleted file mode 100644 index 39fbfd3..0000000 --- a/app/database/entity/research_journals.entity.go +++ /dev/null @@ -1,18 +0,0 @@ -package entity - -import ( - "jaecoo-be/app/database/entity/users" - "time" -) - -type ResearchJournals struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - UserID uint `json:"user_id" gorm:"type:int4;not null;index"` - JournalTitle string `json:"journal_title" gorm:"type:varchar;not null"` - Publisher string `json:"publisher" gorm:"type:varchar;not null"` - JournalURL string `json:"journal_url" gorm:"type:varchar;not null"` - PublishedDate *time.Time `json:"published_date"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - User *users.Users `json:"user" gorm:"foreignKey:UserID;references:ID"` -} diff --git a/app/database/entity/subscription.entity.go b/app/database/entity/subscription.entity.go deleted file mode 100644 index 710cbf4..0000000 --- a/app/database/entity/subscription.entity.go +++ /dev/null @@ -1,14 +0,0 @@ -package entity - -import ( - "time" - - ) - -type Subscription struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - Email string `json:"email" gorm:"type:varchar"` - IsActive bool `json:"is_active" gorm:"type:bool;default:true"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` -} diff --git a/app/database/entity/work_history.entity.go b/app/database/entity/work_history.entity.go deleted file mode 100644 index 236eb31..0000000 --- a/app/database/entity/work_history.entity.go +++ /dev/null @@ -1,18 +0,0 @@ -package entity - -import ( - "jaecoo-be/app/database/entity/users" - "time" -) - -type WorkHistory struct { - ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` - UserID uint `json:"user_id" gorm:"type:int4;not null;index"` - JobTitle string `json:"job_title" gorm:"type:varchar;not null"` - CompanyName string `json:"company_name" gorm:"type:varchar;not null"` - StartDate time.Time `json:"start_date" gorm:"not null"` - EndDate *time.Time `json:"end_date"` - CreatedAt time.Time `json:"created_at" gorm:"default:now()"` - UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` - User *users.Users `json:"user" gorm:"foreignKey:UserID;references:ID"` -} diff --git a/app/database/index.database.go b/app/database/index.database.go index e6fae97..1ff2bb2 100644 --- a/app/database/index.database.go +++ b/app/database/index.database.go @@ -87,7 +87,6 @@ func Models() []interface{} { return []interface{}{ entity.ActivityLogs{}, entity.ActivityLogTypes{}, - entity.Advertisement{}, entity.Articles{}, entity.ArticleCategories{}, entity.ArticleApprovals{}, @@ -101,49 +100,14 @@ func Models() []interface{} { entity.Districts{}, entity.Feedbacks{}, entity.ForgotPasswords{}, - entity.Magazines{}, - entity.MagazineFiles{}, - entity.MasterMenus{}, - entity.MasterModules{}, - entity.MasterStatuses{}, entity.MasterApprovalStatuses{}, entity.Provinces{}, entity.OneTimePasswords{}, - entity.Subscription{}, user_levels.UserLevels{}, entity.UserRoles{}, entity.UserRoleAccesses{}, users.Users{}, entity.UserRoleLevelDetails{}, - - // Narasi Ahli entities - entity.EducationHistory{}, - entity.WorkHistory{}, - entity.ResearchJournals{}, - entity.Conversations{}, - entity.ChatMessages{}, - entity.ChatParticipants{}, - entity.ChatSessions{}, - entity.ChatSchedules{}, - entity.ChatScheduleFiles{}, - entity.AIChatSessions{}, - entity.AIChatMessages{}, - entity.AIChatLogs{}, - - // Ebook entities - entity.Ebooks{}, - entity.EbookWishlists{}, - entity.EbookPurchases{}, - entity.EbookRatings{}, - - // Campaign entities - entity.CampaignTypes{}, - entity.CampaignDestinations{}, - entity.Campaigns{}, - entity.CampaignFiles{}, - entity.CampaignDestinationRelations{}, - entity.CampaignApprovals{}, - entity.CampaignChats{}, } } diff --git a/app/database/seeds/master_statuses.seeds.go b/app/database/seeds/master_statuses.seeds.go deleted file mode 100644 index 2141580..0000000 --- a/app/database/seeds/master_statuses.seeds.go +++ /dev/null @@ -1,46 +0,0 @@ -package seeds - -import ( - "jaecoo-be/app/database/entity" - - "gorm.io/gorm" -) - -type MasterStatusesSeeder struct{} - -var masterStatuses = []entity.MasterStatuses{ - { - ID: 1, - Name: "Waiting", - IsActive: true, - }, - { - ID: 2, - Name: "Active", - IsActive: true, - }, - { - ID: 3, - Name: "Inactive", - IsActive: true, - }, -} - -func (MasterStatusesSeeder) Seed(conn *gorm.DB) error { - for _, row := range masterStatuses { - if err := conn.Create(&row).Error; err != nil { - return err - } - } - - return nil -} - -func (MasterStatusesSeeder) Count(conn *gorm.DB) (int, error) { - var count int64 - if err := conn.Model(&entity.MasterStatuses{}).Count(&count).Error; err != nil { - return 0, err - } - - return int(count), nil -} diff --git a/app/module/advertisement/advertisement.module.go b/app/module/advertisement/advertisement.module.go deleted file mode 100644 index 7abfe0d..0000000 --- a/app/module/advertisement/advertisement.module.go +++ /dev/null @@ -1,57 +0,0 @@ -package advertisement - -import ( - "jaecoo-be/app/module/advertisement/controller" - "jaecoo-be/app/module/advertisement/repository" - "jaecoo-be/app/module/advertisement/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of AdvertisementRouter -type AdvertisementRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// register bulky of Advertisement module -var NewAdvertisementModule = fx.Options( - // register repository of Advertisement module - fx.Provide(repository.NewAdvertisementRepository), - - // register service of Advertisement module - fx.Provide(service.NewAdvertisementService), - - // register controller of Advertisement module - fx.Provide(controller.NewController), - - // register router of Advertisement module - fx.Provide(NewAdvertisementRouter), -) - -// init AdvertisementRouter -func NewAdvertisementRouter(fiber *fiber.App, controller *controller.Controller) *AdvertisementRouter { - return &AdvertisementRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of Advertisement module -func (_i *AdvertisementRouter) RegisterAdvertisementRoutes() { - // define controllers - advertisementController := _i.Controller.Advertisement - - // define routes - _i.App.Route("/advertisement", func(router fiber.Router) { - router.Get("/", advertisementController.All) - router.Get("/:id", advertisementController.Show) - router.Post("/", advertisementController.Save) - router.Post("/upload/:id", advertisementController.Upload) - router.Get("/viewer/:filename", advertisementController.Viewer) - router.Put("/:id", advertisementController.Update) - router.Put("/publish/:id", advertisementController.UpdatePublish) - router.Delete("/:id", advertisementController.Delete) - }) -} diff --git a/app/module/advertisement/controller/advertisement.controller.go b/app/module/advertisement/controller/advertisement.controller.go deleted file mode 100644 index 144d513..0000000 --- a/app/module/advertisement/controller/advertisement.controller.go +++ /dev/null @@ -1,284 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/advertisement/request" - "jaecoo-be/app/module/advertisement/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type advertisementController struct { - advertisementService service.AdvertisementService - Log zerolog.Logger -} - -type AdvertisementController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Upload(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - UpdatePublish(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error - Viewer(c *fiber.Ctx) error -} - -func NewAdvertisementController(advertisementService service.AdvertisementService, log zerolog.Logger) AdvertisementController { - return &advertisementController{ - advertisementService: advertisementService, - Log: log, - } -} - -// All get all Advertisement -// @Summary Get all Advertisement -// @Description API for getting all Advertisement -// @Tags Advertisement -// @Security Bearer -// @Param req query request.AdvertisementQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /advertisement [get] -func (_i *advertisementController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.AdvertisementQueryRequestContext{ - Title: c.Query("title"), - Description: c.Query("description"), - RedirectLink: c.Query("redirectLink"), - Placement: c.Query("placement"), - StatusId: c.Query("statusId"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - advertisementData, paging, err := _i.advertisementService.All(req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Advertisement list successfully retrieved"}, - Data: advertisementData, - Meta: paging, - }) -} - -// Show get one Advertisement -// @Summary Get one Advertisement -// @Description API for getting one Advertisement -// @Tags Advertisement -// @Security Bearer -// @Param id path int true "Advertisement ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /advertisement/{id} [get] -func (_i *advertisementController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - advertisementData, err := _i.advertisementService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Advertisement successfully retrieved"}, - Data: advertisementData, - }) -} - -// Save create Advertisement -// @Summary Create Advertisement -// @Description API for create Advertisement -// @Tags Advertisement -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.AdvertisementCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /advertisement [post] -func (_i *advertisementController) Save(c *fiber.Ctx) error { - req := new(request.AdvertisementCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - dataResult, err := _i.advertisementService.Save(*req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Advertisement successfully created"}, - Data: dataResult, - }) -} - -// Upload Advertisement -// @Summary Upload Advertisement -// @Description API for Upload File Advertisement -// @Tags Advertisement -// @Security Bearer -// @Produce json -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param file formData file true "Upload file" multiple false -// @Param id path int true "Advertisement ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /advertisement/upload/{id} [post] -func (_i *advertisementController) Upload(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.advertisementService.Upload(c, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Advertisement successfully upload"}, - }) -} - -// Update update Advertisement -// @Summary update Advertisement -// @Description API for update Advertisement -// @Tags Advertisement -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param payload body request.AdvertisementUpdateRequest true "Required payload" -// @Param id path int true "Advertisement ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /advertisement/{id} [put] -func (_i *advertisementController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.AdvertisementUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.advertisementService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Advertisement successfully updated"}, - }) -} - -// UpdatePublish Advertisement -// @Summary Update Publish Advertisement -// @Description API for Update Publish Advertisement -// @Tags Advertisement -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Advertisement ID" -// @Param isPublish query bool true "Advertisement Publish Status" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /advertisement/publish/{id} [put] -func (_i *advertisementController) UpdatePublish(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - isPublish, err := strconv.ParseBool(c.Query("isPublish")) - if err != nil { - return err - } - - err = _i.advertisementService.UpdatePublish(uint(id), isPublish) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Advertisement successfully publish updated"}, - }) -} - -// Delete delete Advertisement -// @Summary delete Advertisement -// @Description API for delete Advertisement -// @Tags Advertisement -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Advertisement ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /advertisement/{id} [delete] -func (_i *advertisementController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.advertisementService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Advertisement successfully deleted"}, - }) -} - -// Viewer Advertisement -// @Summary Viewer Advertisement -// @Description API for Viewer Advertisement -// @Tags Advertisement -// @Security Bearer -// @Param filename path string true "Content File Name" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /advertisement/viewer/{filename} [get] -func (_i *advertisementController) Viewer(c *fiber.Ctx) error { - return _i.advertisementService.Viewer(c) -} diff --git a/app/module/advertisement/controller/controller.go b/app/module/advertisement/controller/controller.go deleted file mode 100644 index 12fb653..0000000 --- a/app/module/advertisement/controller/controller.go +++ /dev/null @@ -1,17 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/advertisement/service" - - "github.com/rs/zerolog" -) - -type Controller struct { - Advertisement AdvertisementController -} - -func NewController(AdvertisementService service.AdvertisementService, log zerolog.Logger) *Controller { - return &Controller{ - Advertisement: NewAdvertisementController(AdvertisementService, log), - } -} diff --git a/app/module/advertisement/mapper/advertisement.mapper.go b/app/module/advertisement/mapper/advertisement.mapper.go deleted file mode 100644 index c00951c..0000000 --- a/app/module/advertisement/mapper/advertisement.mapper.go +++ /dev/null @@ -1,28 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - res "jaecoo-be/app/module/advertisement/response" -) - -func AdvertisementResponseMapper(advertisementReq *entity.Advertisement, host string) (advertisementRes *res.AdvertisementResponse) { - if advertisementReq != nil { - advertisementRes = &res.AdvertisementResponse{ - ID: advertisementReq.ID, - Title: advertisementReq.Title, - Description: advertisementReq.Description, - RedirectLink: advertisementReq.RedirectLink, - Placement: advertisementReq.Placement, - StatusId: advertisementReq.StatusId, - IsActive: advertisementReq.IsActive, - IsPublish: advertisementReq.IsPublish, - CreatedAt: advertisementReq.CreatedAt, - UpdatedAt: advertisementReq.UpdatedAt, - } - - if advertisementReq.ContentFilePath != nil { - advertisementRes.ContentFileUrl = host + "/advertisement/viewer/" + *advertisementReq.ContentFileName - } - } - return advertisementRes -} diff --git a/app/module/advertisement/repository/advertisement.repository.go b/app/module/advertisement/repository/advertisement.repository.go deleted file mode 100644 index 569c6c7..0000000 --- a/app/module/advertisement/repository/advertisement.repository.go +++ /dev/null @@ -1,124 +0,0 @@ -package repository - -import ( - "fmt" - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/advertisement/request" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "strings" - - "github.com/rs/zerolog" -) - -type advertisementRepository struct { - DB *database.Database - Log zerolog.Logger -} - -// AdvertisementRepository define interface of IAdvertisementRepository -type AdvertisementRepository interface { - GetAll(req request.AdvertisementQueryRequest) (advertisements []*entity.Advertisement, paging paginator.Pagination, err error) - FindOne(id uint) (advertisement *entity.Advertisement, err error) - FindByFilename(contentFilename string) (advertisement *entity.Advertisement, err error) - Create(advertisement *entity.Advertisement) (advertisementReturn *entity.Advertisement, err error) - Update(id uint, advertisement *entity.Advertisement) (err error) - Delete(id uint) (err error) -} - -func NewAdvertisementRepository(db *database.Database, logger zerolog.Logger) AdvertisementRepository { - return &advertisementRepository{ - DB: db, - Log: logger, - } -} - -// implement interface of IAdvertisementRepository -func (_i *advertisementRepository) GetAll(req request.AdvertisementQueryRequest) (advertisements []*entity.Advertisement, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.Advertisement{}) - - query = query.Where("is_active = ?", true) - - if req.Title != nil && *req.Title != "" { - title := strings.ToLower(*req.Title) - query = query.Where("LOWER(title) LIKE ?", "%"+strings.ToLower(title)+"%") - } - if req.Description != nil && *req.Description != "" { - description := strings.ToLower(*req.Description) - query = query.Where("LOWER(description) LIKE ?", "%"+strings.ToLower(description)+"%") - } - if req.RedirectLink != nil && *req.RedirectLink != "" { - redirectLink := strings.ToLower(*req.RedirectLink) - query = query.Where("LOWER(redirect_link) LIKE ?", "%"+strings.ToLower(redirectLink)+"%") - } - if req.Placement != nil && *req.Placement != "" { - placement := strings.ToLower(*req.Placement) - query = query.Where("LOWER(placement) LIKE ?", "%"+strings.ToLower(placement)+"%") - } - if req.StatusId != nil { - query = query.Where("status_id = ?", req.StatusId) - } - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction)) - } - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&advertisements).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *advertisementRepository) FindOne(id uint) (advertisement *entity.Advertisement, err error) { - query := _i.DB.DB.Where("id = ?", id) - - if err := query.First(&advertisement).Error; err != nil { - return nil, err - } - - return advertisement, nil -} - -func (_i *advertisementRepository) FindByFilename(contentFilename string) (advertisement *entity.Advertisement, err error) { - query := _i.DB.DB.Where("content_file_name = ?", contentFilename) - - if err := query.First(&advertisement).Error; err != nil { - return nil, err - } - - return advertisement, nil -} - -func (_i *advertisementRepository) Create(advertisement *entity.Advertisement) (advertisementReturn *entity.Advertisement, err error) { - result := _i.DB.DB.Create(advertisement) - return advertisement, result.Error -} - -func (_i *advertisementRepository) Update(id uint, advertisement *entity.Advertisement) (err error) { - advertisementMap, err := utilSvc.StructToMap(advertisement) - if err != nil { - return err - } - query := _i.DB.DB.Model(&entity.Advertisement{}).Where(&entity.Advertisement{ID: id}) - return query.Updates(advertisementMap).Error -} - -func (_i *advertisementRepository) Delete(id uint) error { - query := _i.DB.DB.Model(&entity.Advertisement{}).Where("id = ?", id) - return query.Delete(&entity.Advertisement{}).Error -} diff --git a/app/module/advertisement/request/advertisement.request.go b/app/module/advertisement/request/advertisement.request.go deleted file mode 100644 index 12adeb5..0000000 --- a/app/module/advertisement/request/advertisement.request.go +++ /dev/null @@ -1,100 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -type AdvertisementGeneric interface { - ToEntity() -} - -type AdvertisementQueryRequest struct { - Title *string `json:"title"` - Description *string `json:"description"` - RedirectLink *string `json:"redirectLink"` - Placement *string `json:"placement"` - IsPublish *bool `json:"isPublish"` - StatusId *int `json:"statusId"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type AdvertisementCreateRequest struct { - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - RedirectLink string `json:"redirectLink" validate:"required"` - Placement string `json:"placement" validate:"required"` -} - -func (req AdvertisementCreateRequest) ToEntity() *entity.Advertisement { - return &entity.Advertisement{ - Title: req.Title, - Description: req.Description, - RedirectLink: req.RedirectLink, - Placement: req.Placement, - StatusId: 1, - IsPublish: true, - IsActive: true, - } -} - -type AdvertisementUpdateRequest struct { - ID uint `json:"id" validate:"required"` - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - RedirectLink string `json:"redirectLink" validate:"required"` - Placement string `json:"placement" validate:"required"` -} - -func (req AdvertisementUpdateRequest) ToEntity() *entity.Advertisement { - return &entity.Advertisement{ - ID: req.ID, - Title: req.Title, - Description: req.Description, - RedirectLink: req.RedirectLink, - Placement: req.Placement, - UpdatedAt: time.Now(), - } -} - -type AdvertisementQueryRequestContext struct { - Title string `json:"title"` - Description string `json:"description"` - RedirectLink string `json:"redirectLink"` - Placement string `json:"placement"` - StatusId string `json:"statusId"` - IsPublish string `json:"isPublish"` -} - -func (req AdvertisementQueryRequestContext) ToParamRequest() AdvertisementQueryRequest { - var request AdvertisementQueryRequest - - if title := req.Title; title != "" { - request.Title = &title - } - if description := req.Description; description != "" { - request.Description = &description - } - if redirectLink := req.RedirectLink; redirectLink != "" { - request.RedirectLink = &redirectLink - } - if placement := req.Placement; placement != "" { - request.Placement = &placement - } - if isPublishStr := req.IsPublish; isPublishStr != "" { - isPublish, err := strconv.ParseBool(isPublishStr) - if err == nil { - request.IsPublish = &isPublish - } - } - if statusIdStr := req.StatusId; statusIdStr != "" { - statusId, err := strconv.Atoi(statusIdStr) - if err == nil { - request.StatusId = &statusId - } - } - - return request -} diff --git a/app/module/advertisement/response/advertisement.response.go b/app/module/advertisement/response/advertisement.response.go deleted file mode 100644 index 55db4aa..0000000 --- a/app/module/advertisement/response/advertisement.response.go +++ /dev/null @@ -1,17 +0,0 @@ -package response - -import "time" - -type AdvertisementResponse struct { - ID uint `json:"id"` - Title string `json:"title"` - Description string `json:"description"` - RedirectLink string `json:"redirectLink"` - ContentFileUrl string `json:"contentFileUrl"` - Placement string `json:"placement"` - StatusId int `json:"statusId"` - IsPublish bool `json:"isPublish"` - IsActive bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} diff --git a/app/module/advertisement/service/advertisement.service.go b/app/module/advertisement/service/advertisement.service.go deleted file mode 100644 index c5844f5..0000000 --- a/app/module/advertisement/service/advertisement.service.go +++ /dev/null @@ -1,264 +0,0 @@ -package service - -import ( - "context" - "fmt" - "io" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/advertisement/mapper" - "jaecoo-be/app/module/advertisement/repository" - "jaecoo-be/app/module/advertisement/request" - "jaecoo-be/app/module/advertisement/response" - usersRepository "jaecoo-be/app/module/users/repository" - config "jaecoo-be/config/config" - minioStorage "jaecoo-be/config/config" - "jaecoo-be/utils/paginator" - "log" - "math/rand" - "mime" - "path/filepath" - "strconv" - "strings" - "time" - - "github.com/gofiber/fiber/v2" - "github.com/minio/minio-go/v7" - "github.com/rs/zerolog" -) - -// AdvertisementService -type advertisementService struct { - Repo repository.AdvertisementRepository - UsersRepo usersRepository.UsersRepository - Log zerolog.Logger - Cfg *config.Config - MinioStorage *minioStorage.MinioStorage -} - -// AdvertisementService define interface of IAdvertisementService -type AdvertisementService interface { - All(req request.AdvertisementQueryRequest) (advertisement []*response.AdvertisementResponse, paging paginator.Pagination, err error) - Show(id uint) (advertisement *response.AdvertisementResponse, err error) - Save(req request.AdvertisementCreateRequest) (advertisement *entity.Advertisement, err error) - Upload(c *fiber.Ctx, id uint) (err error) - Update(id uint, req request.AdvertisementUpdateRequest) (err error) - UpdatePublish(id uint, isPublish bool) (err error) - Delete(id uint) error - Viewer(c *fiber.Ctx) (err error) -} - -// NewAdvertisementService init AdvertisementService -func NewAdvertisementService(repo repository.AdvertisementRepository, minioStorage *minioStorage.MinioStorage, usersRepo usersRepository.UsersRepository, log zerolog.Logger, cfg *config.Config) AdvertisementService { - - return &advertisementService{ - Repo: repo, - UsersRepo: usersRepo, - MinioStorage: minioStorage, - Log: log, - Cfg: cfg, - } -} - -// All implement interface of AdvertisementService -func (_i *advertisementService) All(req request.AdvertisementQueryRequest) (advertisements []*response.AdvertisementResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req) - if err != nil { - return - } - - host := _i.Cfg.App.Domain - for _, result := range results { - advertisements = append(advertisements, mapper.AdvertisementResponseMapper(result, host)) - } - - return -} - -func (_i *advertisementService) Show(id uint) (advertisement *response.AdvertisementResponse, err error) { - result, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - - host := _i.Cfg.App.Domain - return mapper.AdvertisementResponseMapper(result, host), nil -} - -func (_i *advertisementService) Save(req request.AdvertisementCreateRequest) (advertisement *entity.Advertisement, err error) { - _i.Log.Info().Interface("data", req).Msg("") - newReq := req.ToEntity() - return _i.Repo.Create(newReq) -} - -func (_i *advertisementService) Upload(c *fiber.Ctx, id uint) (err error) { - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - - form, err := c.MultipartForm() - - if err != nil { - return err - } - //filess := form.File["files"] - - // Create minio connection. - minioClient, err := _i.MinioStorage.ConnectMinio() - - result, err := _i.Repo.FindOne(id) - - if result == nil { - // Return status 400. Id not found. - return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ - "error": true, - "msg": err.Error(), - }) - } - - if err != nil { - // Return status 500 and minio connection error. - return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ - "error": true, - "msg": err.Error(), - }) - } - - for _, files := range form.File { - - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "Uploader:: top"). - Interface("files", files).Msg("") - - for _, fileHeader := range files { - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "Uploader:: loop"). - Interface("data", fileHeader).Msg("") - - src, err := fileHeader.Open() - if err != nil { - return err - } - defer src.Close() - - filename := filepath.Base(fileHeader.Filename) - filename = strings.ReplaceAll(filename, " ", "") - filenameWithoutExt := filepath.Clean(filename[:len(filename)-len(filepath.Ext(filename))]) - extension := filepath.Ext(fileHeader.Filename)[1:] - - now := time.Now() - rand.New(rand.NewSource(now.UnixNano())) - randUniqueId := rand.Intn(1000000) - - newFilenameWithoutExt := filenameWithoutExt + "_" + strconv.Itoa(randUniqueId) - newFilename := newFilenameWithoutExt + "." + extension - - objectName := fmt.Sprintf("advertisement/upload/%d/%d/%s", now.Year(), now.Month(), newFilename) - - result.ContentFileName = &newFilename - result.ContentFilePath = &objectName - - err = _i.Repo.Update(id, result) - if err != nil { - return err - } - - // Upload file ke MinIO - _, err = minioClient.PutObject(context.Background(), bucketName, objectName, src, fileHeader.Size, minio.PutObjectOptions{}) - if err != nil { - return err - } - } - } - - return -} - -func (_i *advertisementService) Update(id uint, req request.AdvertisementUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - newReq := req.ToEntity() - return _i.Repo.Update(id, newReq) -} - -func (_i *advertisementService) UpdatePublish(id uint, isPublish bool) (err error) { - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "UpdatePublish"). - Interface("ids", id).Msg("") - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "UpdatePublish"). - Interface("isPublish", isPublish).Msg("") - - result, err := _i.Repo.FindOne(id) - if err != nil { - return err - } - - result.IsPublish = isPublish - - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "UpdatePublish"). - Interface("result", result).Msg("") - - return _i.Repo.Update(id, result) -} - -func (_i *advertisementService) Delete(id uint) error { - result, err := _i.Repo.FindOne(id) - if err != nil { - return err - } - result.IsActive = false - return _i.Repo.Update(id, result) -} - -func (_i *advertisementService) Viewer(c *fiber.Ctx) (err error) { - filename := c.Params("filename") - result, err := _i.Repo.FindByFilename(filename) - if err != nil { - return err - } - - ctx := context.Background() - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - objectName := *result.ContentFilePath - - // Create minio connection. - minioClient, err := _i.MinioStorage.ConnectMinio() - if err != nil { - // Return status 500 and minio connection error. - return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ - "error": true, - "msg": err.Error(), - }) - } - - fileContent, err := minioClient.GetObject(ctx, bucketName, objectName, minio.GetObjectOptions{}) - if err != nil { - log.Fatalln(err) - } - defer fileContent.Close() - - // Tentukan Content-Type berdasarkan ekstensi file - contentType := mime.TypeByExtension("." + getFileExtension(objectName)) - if contentType == "" { - contentType = "application/octet-stream" // fallback jika tidak ada tipe MIME yang cocok - } - - c.Set("Content-Type", contentType) - - if _, err := io.Copy(c.Response().BodyWriter(), fileContent); err != nil { - return err - } - - return -} - -func getFileExtension(filename string) string { - // split file name - parts := strings.Split(filename, ".") - - // jika tidak ada ekstensi, kembalikan string kosong - if len(parts) == 1 || (len(parts) == 2 && parts[0] == "") { - return "" - } - - // ambil ekstensi terakhir - return parts[len(parts)-1] -} diff --git a/app/module/ai_chat/ai_chat.module.go b/app/module/ai_chat/ai_chat.module.go deleted file mode 100644 index 1ed18ca..0000000 --- a/app/module/ai_chat/ai_chat.module.go +++ /dev/null @@ -1,65 +0,0 @@ -package ai_chat - -import ( - "jaecoo-be/app/module/ai_chat/controller" - "jaecoo-be/app/module/ai_chat/repository" - "jaecoo-be/app/module/ai_chat/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of AIChatRouter -type AIChatRouter struct { - App fiber.Router - Controller controller.AIChatController -} - -// register bulky of AI Chat module -var NewAIChatModule = fx.Options( - // register repository of AI Chat module - fx.Provide(repository.NewAIChatRepository), - - // register service of AI Chat module - fx.Provide(service.NewAIChatService), - - // register controller of AI Chat module - fx.Provide(controller.NewAIChatController), - - // register router of AI Chat module - fx.Provide(NewAIChatRouter), -) - -// init AIChatRouter -func NewAIChatRouter(fiber *fiber.App, controller controller.AIChatController) *AIChatRouter { - return &AIChatRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of AI Chat module -func (_i *AIChatRouter) RegisterAIChatRoutes() { - // define controllers - aiChatController := _i.Controller - - // define routes - _i.App.Route("/ai-chat", func(router fiber.Router) { - // Sessions routes - router.Get("/sessions", aiChatController.GetUserSessions) - router.Get("/sessions/:id", aiChatController.GetSession) - router.Post("/sessions", aiChatController.CreateSession) - router.Put("/sessions/:id", aiChatController.UpdateSession) - router.Delete("/sessions/:id", aiChatController.DeleteSession) - - // Messages routes - router.Get("/sessions/:id/messages", aiChatController.GetSessionMessages) - router.Post("/sessions/messages", aiChatController.SendMessage) - router.Put("/sessions/messages/:messageId", aiChatController.UpdateMessage) - router.Delete("/sessions/messages/:messageId", aiChatController.DeleteMessage) - - // Logs routes - router.Get("/logs", aiChatController.GetUserLogs) - router.Get("/logs/:id", aiChatController.GetLog) - }) -} diff --git a/app/module/ai_chat/controller/ai_chat.controller.go b/app/module/ai_chat/controller/ai_chat.controller.go deleted file mode 100644 index ada67a7..0000000 --- a/app/module/ai_chat/controller/ai_chat.controller.go +++ /dev/null @@ -1,438 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/ai_chat/request" - "jaecoo-be/app/module/ai_chat/service" - "jaecoo-be/utils/paginator" - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" - "strconv" - - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog" -) - -type aiChatController struct { - aiChatService service.AIChatService - Log zerolog.Logger -} - -type AIChatController interface { - // AI Chat Sessions - GetUserSessions(c *fiber.Ctx) error - GetSession(c *fiber.Ctx) error - CreateSession(c *fiber.Ctx) error - UpdateSession(c *fiber.Ctx) error - DeleteSession(c *fiber.Ctx) error - - // AI Chat Messages - GetSessionMessages(c *fiber.Ctx) error - SendMessage(c *fiber.Ctx) error - UpdateMessage(c *fiber.Ctx) error - DeleteMessage(c *fiber.Ctx) error - - // AI Chat Logs - GetUserLogs(c *fiber.Ctx) error - GetLog(c *fiber.Ctx) error -} - -func NewAIChatController(aiChatService service.AIChatService, log zerolog.Logger) AIChatController { - return &aiChatController{ - aiChatService: aiChatService, - Log: log, - } -} - -// Get User Sessions -// @Summary Get user AI chat sessions -// @Description API for getting all AI chat sessions for authenticated user -// @Tags AI Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param req query request.AIChatSessionsQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ai-chat/sessions [get] -func (_i *aiChatController) GetUserSessions(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - authHeader := c.Get("Authorization") - - reqContext := request.AIChatSessionsQueryRequestContext{ - IsActive: c.Query("isActive"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - sessionsData, paging, err := _i.aiChatService.GetUserSessions(authHeader, req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"AI chat sessions successfully retrieved"}, - Data: sessionsData, - Meta: paging, - }) -} - -// Get Session -// @Summary Get one AI chat session -// @Description API for getting one AI chat session -// @Tags AI Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Session ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ai-chat/sessions/{id} [get] -func (_i *aiChatController) GetSession(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authHeader := c.Get("Authorization") - - sessionData, err := _i.aiChatService.GetSession(authHeader, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"AI chat session successfully retrieved"}, - Data: sessionData, - }) -} - -// Create Session -// @Summary Create AI chat session -// @Description API for create AI chat session -// @Tags AI Chat -// @Security Bearer -// @Param X-Csrf-Token header string false "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.AIChatSessionsCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ai-chat/sessions [post] -func (_i *aiChatController) CreateSession(c *fiber.Ctx) error { - req := new(request.AIChatSessionsCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authHeader := c.Get("Authorization") - - dataResult, err := _i.aiChatService.CreateSession(authHeader, *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"AI chat session successfully created"}, - Data: dataResult, - }) -} - -// Update Session -// @Summary Update AI chat session -// @Description API for update AI chat session -// @Tags AI Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param X-Csrf-Token header string false "Insert the X-Csrf-Token" -// @Param id path int true "Session ID" -// @Param payload body request.AIChatSessionsUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ai-chat/sessions/{id} [put] -func (_i *aiChatController) UpdateSession(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.AIChatSessionsUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authHeader := c.Get("Authorization") - - err = _i.aiChatService.UpdateSession(authHeader, uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"AI chat session successfully updated"}, - }) -} - -// Delete Session -// @Summary Delete AI chat session -// @Description API for delete AI chat session -// @Tags AI Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Session ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ai-chat/sessions/{id} [delete] -func (_i *aiChatController) DeleteSession(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authHeader := c.Get("Authorization") - - err = _i.aiChatService.DeleteSession(authHeader, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"AI chat session successfully deleted"}, - }) -} - -// Get Session Messages -// @Summary Get AI chat session messages -// @Description API for getting all messages in an AI chat session -// @Tags AI Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Session ID" -// @Param req query request.AIChatMessagesQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ai-chat/sessions/{id}/messages [get] -func (_i *aiChatController) GetSessionMessages(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - authHeader := c.Get("Authorization") - - reqContext := request.AIChatMessagesQueryRequestContext{} - req := reqContext.ToParamRequest() - req.Pagination = paginate - - messagesData, paging, err := _i.aiChatService.GetSessionMessages(authHeader, uint(id), req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"AI chat messages successfully retrieved"}, - Data: messagesData, - Meta: paging, - }) -} - -// Send Message -// @Summary Send message to AI chat session -// @Description API for sending a message to an AI chat session -// @Tags AI Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param payload body request.AIChatMessagesCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ai-chat/sessions/messages [post] -func (_i *aiChatController) SendMessage(c *fiber.Ctx) error { - req := new(request.AIChatMessagesCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authHeader := c.Get("Authorization") - - dataResult, err := _i.aiChatService.SendMessage(authHeader, *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Message successfully sent"}, - Data: dataResult, - }) -} - -// Update Message -// @Summary Update AI chat message -// @Description API for update AI chat message -// @Tags AI Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param messageId path int true "Message ID" -// @Param payload body request.AIChatMessagesUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ai-chat/sessions/messages/{messageId} [put] -func (_i *aiChatController) UpdateMessage(c *fiber.Ctx) error { - messageId, err := strconv.ParseUint(c.Params("messageId"), 10, 0) - if err != nil { - return err - } - - req := new(request.AIChatMessagesUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authHeader := c.Get("Authorization") - - err = _i.aiChatService.UpdateMessage(authHeader, uint(messageId), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"AI chat message successfully updated"}, - }) -} - -// Delete Message -// @Summary Delete AI chat message -// @Description API for delete AI chat message -// @Tags AI Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param messageId path int true "Message ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ai-chat/sessions/messages/{messageId} [delete] -func (_i *aiChatController) DeleteMessage(c *fiber.Ctx) error { - messageId, err := strconv.ParseUint(c.Params("messageId"), 10, 0) - if err != nil { - return err - } - - authHeader := c.Get("Authorization") - - err = _i.aiChatService.DeleteMessage(authHeader, uint(messageId)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"AI chat message successfully deleted"}, - }) -} - -// Get User Logs -// @Summary Get user AI chat logs -// @Description API for getting all AI chat logs for authenticated user -// @Tags AI Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param req query request.AIChatLogsQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ai-chat/logs [get] -func (_i *aiChatController) GetUserLogs(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - authHeader := c.Get("Authorization") - - reqContext := request.AIChatLogsQueryRequestContext{ - LogType: c.Query("logType"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - logsData, paging, err := _i.aiChatService.GetUserLogs(authHeader, req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"AI chat logs successfully retrieved"}, - Data: logsData, - Meta: paging, - }) -} - -// Get Log -// @Summary Get one AI chat log -// @Description API for getting one AI chat log -// @Tags AI Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Log ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ai-chat/logs/{id} [get] -func (_i *aiChatController) GetLog(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authHeader := c.Get("Authorization") - - logData, err := _i.aiChatService.GetLog(authHeader, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"AI chat log successfully retrieved"}, - Data: logData, - }) -} diff --git a/app/module/ai_chat/mapper/ai_chat.mapper.go b/app/module/ai_chat/mapper/ai_chat.mapper.go deleted file mode 100644 index 29d2ba6..0000000 --- a/app/module/ai_chat/mapper/ai_chat.mapper.go +++ /dev/null @@ -1,71 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/ai_chat/response" -) - -func AIChatSessionsResponseMapper(session *entity.AIChatSessions) *response.AIChatSessionsResponse { - result := &response.AIChatSessionsResponse{ - ID: session.ID, - SessionID: session.SessionID, - UserID: session.UserID, - AgentID: session.AgentID, - Title: session.Title, - MessageCount: session.MessageCount, - IsActive: session.IsActive, - CreatedAt: session.CreatedAt, - UpdatedAt: session.UpdatedAt, - } - - if session.User != nil { - result.User = &response.UserBasicInfo{ - ID: session.User.ID, - Username: session.User.Username, - Fullname: session.User.Fullname, - Email: session.User.Email, - } - } - - return result -} - -func AIChatMessagesResponseMapper(message *entity.AIChatMessages) *response.AIChatMessagesResponse { - return &response.AIChatMessagesResponse{ - ID: message.ID, - SessionID: message.SessionID, - MessageType: message.MessageType, - Content: message.Content, - IsActive: message.IsActive, - CreatedAt: message.CreatedAt, - } -} - -func AIChatSessionWithMessagesResponseMapper(session *entity.AIChatSessions, messages []*entity.AIChatMessages) *response.AIChatSessionWithMessagesResponse { - sessionResponse := AIChatSessionsResponseMapper(session) - - var messagesResponse []*response.AIChatMessagesResponse - for _, message := range messages { - messagesResponse = append(messagesResponse, AIChatMessagesResponseMapper(message)) - } - - return &response.AIChatSessionWithMessagesResponse{ - Session: sessionResponse, - Messages: messagesResponse, - } -} - -func AIChatLogsResponseMapper(log *entity.AIChatLogs) *response.AIChatLogsResponse { - result := &response.AIChatLogsResponse{ - ID: log.ID, - UserID: log.UserID, - SessionID: log.SessionID, - StartDate: log.StartDate, - EndDate: log.EndDate, - TotalDuration: log.TotalDuration, - CreatedAt: log.CreatedAt, - UpdatedAt: log.UpdatedAt, - } - - return result -} diff --git a/app/module/ai_chat/repository/ai_chat.repository.go b/app/module/ai_chat/repository/ai_chat.repository.go deleted file mode 100644 index 0b70075..0000000 --- a/app/module/ai_chat/repository/ai_chat.repository.go +++ /dev/null @@ -1,198 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/ai_chat/request" - "jaecoo-be/utils/paginator" -) - -type aiChatRepository struct { - DB *database.Database -} - -type AIChatRepository interface { - // AI Chat Sessions - GetUserSessions(userId uint, req request.AIChatSessionsQueryRequest) (sessions []*entity.AIChatSessions, paging paginator.Pagination, err error) - FindSessionByUserAndId(userId uint, sessionId uint) (session *entity.AIChatSessions, err error) - FindSessionBySessionId(sessionId string) (session *entity.AIChatSessions, err error) - CreateSession(session *entity.AIChatSessions) (result *entity.AIChatSessions, err error) - UpdateSession(userId uint, sessionId uint, session *entity.AIChatSessions) (err error) - DeleteSession(userId uint, sessionId uint) (err error) - IncrementMessageCount(sessionId uint) (err error) - - // AI Chat Messages - GetSessionMessages(sessionId string, req request.AIChatMessagesQueryRequest) (messages []*entity.AIChatMessages, paging paginator.Pagination, err error) - CreateMessage(message *entity.AIChatMessages) (result *entity.AIChatMessages, err error) - UpdateMessage(messageId uint, message *entity.AIChatMessages) (err error) - DeleteMessage(messageId uint) (err error) - GetLastMessage(sessionId string) (message *entity.AIChatMessages, err error) - - // AI Chat Logs - GetUserLogs(userId uint, req request.AIChatLogsQueryRequest) (logs []*entity.AIChatLogs, paging paginator.Pagination, err error) - FindLogByUserAndId(userId uint, logId uint) (log *entity.AIChatLogs, err error) -} - -func NewAIChatRepository(db *database.Database) AIChatRepository { - return &aiChatRepository{ - DB: db, - } -} - -// AI Chat Sessions methods -func (_i *aiChatRepository) GetUserSessions(userId uint, req request.AIChatSessionsQueryRequest) (sessions []*entity.AIChatSessions, paging paginator.Pagination, err error) { - query := _i.DB.DB.Model(&entity.AIChatSessions{}).Where("user_id = ?", userId) - - // Apply filters - if req.IsActive != nil { - query = query.Where("is_active = ?", *req.IsActive) - } - - // Include user relationship - // query = query.Preload("User") - - // Order by updated_at desc (most recent first) - query = query.Order("updated_at DESC") - - // Apply pagination - var count int64 - query.Count(&count) - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&sessions).Error - paging = *req.Pagination - - return -} - -func (_i *aiChatRepository) FindSessionByUserAndId(userId uint, sessionId uint) (session *entity.AIChatSessions, err error) { - err = _i.DB.DB.Model(&entity.AIChatSessions{}).Where("user_id = ? AND id = ?", userId, sessionId).Preload("User").First(&session).Error - return -} - -func (_i *aiChatRepository) FindSessionBySessionId(sessionId string) (session *entity.AIChatSessions, err error) { - err = _i.DB.DB.Model(&entity.AIChatSessions{}).Where("session_id = ?", sessionId).Preload("User").First(&session).Error - return -} - -func (_i *aiChatRepository) CreateSession(session *entity.AIChatSessions) (result *entity.AIChatSessions, err error) { - err = _i.DB.DB.Create(session).Error - if err != nil { - return nil, err - } - - // Reload with relationships - err = _i.DB.DB.Model(&entity.AIChatSessions{}).Preload("User").First(&result, session.ID).Error - return -} - -func (_i *aiChatRepository) UpdateSession(userId uint, sessionId uint, session *entity.AIChatSessions) (err error) { - err = _i.DB.DB.Model(&entity.AIChatSessions{}).Where("user_id = ? AND id = ?", userId, sessionId).Updates(session).Error - return -} - -func (_i *aiChatRepository) DeleteSession(userId uint, sessionId uint) (err error) { - err = _i.DB.DB.Model(&entity.AIChatSessions{}).Where("user_id = ? AND id = ?", userId, sessionId).Delete(&entity.AIChatSessions{}).Error - return -} - -func (_i *aiChatRepository) IncrementMessageCount(sessionId uint) (err error) { - err = _i.DB.DB.Exec("UPDATE ai_chat_sessions SET message_count = message_count + 1 WHERE id = ?", sessionId).Error - return -} - -// AI Chat Messages methods -func (_i *aiChatRepository) GetSessionMessages(sessionId string, req request.AIChatMessagesQueryRequest) (messages []*entity.AIChatMessages, paging paginator.Pagination, err error) { - query := _i.DB.DB.Model(&entity.AIChatMessages{}).Where("session_id = ?", sessionId) - - // Order by created_at asc (oldest first for chat) - query = query.Order("created_at ASC") - - // Apply pagination - var count int64 - query.Count(&count) - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&messages).Error - paging = *req.Pagination - - return -} - -func (_i *aiChatRepository) CreateMessage(message *entity.AIChatMessages) (result *entity.AIChatMessages, err error) { - err = _i.DB.DB.Create(message).Error - if err != nil { - return nil, err - } - - // Reload - err = _i.DB.DB.Model(&entity.AIChatMessages{}).First(&result, message.ID).Error - return -} - -func (_i *aiChatRepository) UpdateMessage(messageId uint, message *entity.AIChatMessages) (err error) { - err = _i.DB.DB.Model(&entity.AIChatMessages{}).Where("id = ?", messageId).Updates(message).Error - return -} - -func (_i *aiChatRepository) DeleteMessage(messageId uint) (err error) { - err = _i.DB.DB.Model(&entity.AIChatMessages{}).Where("id = ?", messageId).Delete(&entity.AIChatMessages{}).Error - return -} - -// AI Chat Logs methods -func (_i *aiChatRepository) GetUserLogs(userId uint, req request.AIChatLogsQueryRequest) (logs []*entity.AIChatLogs, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.AIChatLogs{}).Where("user_id = ?", userId) - - // Note: AIChatLogs entity doesn't have LogType field, so we skip this filter - // if req.LogType != nil && *req.LogType != "" { - // query = query.Where("log_type = ?", *req.LogType) - // } - - // Count total records - err = query.Count(&count).Error - if err != nil { - return - } - - // Apply pagination - if req.Pagination != nil { - query = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit) - } - - // Order by created_at desc (newest first) - query = query.Order("created_at DESC") - - err = query.Find(&logs).Error - if err != nil { - return - } - - // Set pagination info - if req.Pagination != nil { - paging = *req.Pagination - paging.Count = count - paging.TotalPage = int((count + int64(req.Pagination.Limit) - 1) / int64(req.Pagination.Limit)) - } - - return -} - -func (_i *aiChatRepository) FindLogByUserAndId(userId uint, logId uint) (log *entity.AIChatLogs, err error) { - query := _i.DB.DB.Model(&entity.AIChatLogs{}).Where("user_id = ? AND id = ?", userId, logId) - - if err := query.First(&log).Error; err != nil { - return nil, err - } - - return -} - -func (_i *aiChatRepository) GetLastMessage(sessionId string) (message *entity.AIChatMessages, err error) { - err = _i.DB.DB.Model(&entity.AIChatMessages{}).Where("session_id = ?", sessionId).Order("created_at DESC").First(&message).Error - return -} diff --git a/app/module/ai_chat/request/ai_chat.request.go b/app/module/ai_chat/request/ai_chat.request.go deleted file mode 100644 index e63b76e..0000000 --- a/app/module/ai_chat/request/ai_chat.request.go +++ /dev/null @@ -1,114 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" -) - -// AI Chat Sessions Request DTOs -type AIChatSessionsQueryRequest struct { - IsActive *bool `json:"isActive"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type AIChatSessionsCreateRequest struct { - SessionID string `json:"sessionId" validate:"required"` - Title string `json:"title" validate:"required,min=2,max=255"` - AgentID string `json:"agentId" validate:"required"` -} - -func (req AIChatSessionsCreateRequest) ToEntity() *entity.AIChatSessions { - return &entity.AIChatSessions{ - SessionID: req.SessionID, - AgentID: req.AgentID, - Title: req.Title, - MessageCount: 0, - IsActive: true, - } -} - -type AIChatSessionsUpdateRequest struct { - Title string `json:"title" validate:"required,min=2,max=255"` - IsActive bool `json:"isActive"` -} - -func (req AIChatSessionsUpdateRequest) ToEntity() *entity.AIChatSessions { - return &entity.AIChatSessions{ - Title: req.Title, - IsActive: req.IsActive, - } -} - -// AI Chat Messages Request DTOs -type AIChatMessagesQueryRequest struct { - Pagination *paginator.Pagination `json:"pagination"` -} - -type AIChatMessagesCreateRequest struct { - SessionID string `json:"sessionId" validate:"required"` - MessageType string `json:"messageType" validate:"required,oneof=user assistant"` - Content string `json:"content" validate:"required,min=1"` -} - -func (req AIChatMessagesCreateRequest) ToEntity() *entity.AIChatMessages { - return &entity.AIChatMessages{ - SessionID: req.SessionID, - MessageType: req.MessageType, - Content: req.Content, - IsActive: true, - } -} - -type AIChatMessagesUpdateRequest struct { - Content string `json:"content" validate:"required,min=1"` -} - -func (req AIChatMessagesUpdateRequest) ToEntity() *entity.AIChatMessages { - return &entity.AIChatMessages{ - Content: req.Content, - } -} - -type AIChatSessionsQueryRequestContext struct { - IsActive string `json:"isActive"` -} - -func (req AIChatSessionsQueryRequestContext) ToParamRequest() AIChatSessionsQueryRequest { - var request AIChatSessionsQueryRequest - - if isActiveStr := req.IsActive; isActiveStr != "" { - isActive := isActiveStr == "true" - request.IsActive = &isActive - } - - return request -} - -type AIChatMessagesQueryRequestContext struct { -} - -func (req AIChatMessagesQueryRequestContext) ToParamRequest() AIChatMessagesQueryRequest { - var request AIChatMessagesQueryRequest - - return request -} - -// AI Chat Logs Request DTOs -type AIChatLogsQueryRequest struct { - LogType *string `json:"logType"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type AIChatLogsQueryRequestContext struct { - LogType string `json:"logType"` -} - -func (req AIChatLogsQueryRequestContext) ToParamRequest() AIChatLogsQueryRequest { - var request AIChatLogsQueryRequest - - if logType := req.LogType; logType != "" { - request.LogType = &logType - } - - return request -} diff --git a/app/module/ai_chat/response/ai_chat.response.go b/app/module/ai_chat/response/ai_chat.response.go deleted file mode 100644 index 6dbfd30..0000000 --- a/app/module/ai_chat/response/ai_chat.response.go +++ /dev/null @@ -1,63 +0,0 @@ -package response - -import ( - "time" -) - -// AI Chat Sessions Response DTOs -type AIChatSessionsResponse struct { - ID uint `json:"id"` - SessionID string `json:"sessionId"` - UserID uint `json:"userId"` - AgentID string `json:"agentId"` - Title string `json:"title"` - MessageCount int `json:"messageCount"` - IsActive bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - - // Nested user info - User *UserBasicInfo `json:"user,omitempty"` - - // Last message preview - LastMessage *AIChatMessagesResponse `json:"lastMessage,omitempty"` -} - -// AI Chat Messages Response DTOs -type AIChatMessagesResponse struct { - ID uint `json:"id"` - SessionID string `json:"sessionId"` - MessageType string `json:"messageType"` - Content string `json:"content"` - IsActive bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` -} - -type UserBasicInfo struct { - ID uint `json:"id"` - Username string `json:"username"` - Fullname string `json:"fullname"` - Email string `json:"email"` -} - -// Session with messages -type AIChatSessionWithMessagesResponse struct { - Session *AIChatSessionsResponse `json:"session"` - Messages []*AIChatMessagesResponse `json:"messages"` - Pagination interface{} `json:"pagination"` -} - -// AI Chat Logs Response DTOs -type AIChatLogsResponse struct { - ID uint `json:"id"` - UserID uint `json:"userId"` - SessionID uint `json:"sessionId"` - StartDate time.Time `json:"startDate"` - EndDate *time.Time `json:"endDate"` - TotalDuration int64 `json:"totalDuration"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - - // Nested user info - User *UserBasicInfo `json:"user,omitempty"` -} diff --git a/app/module/ai_chat/service/ai_chat.service.go b/app/module/ai_chat/service/ai_chat.service.go deleted file mode 100644 index a85328c..0000000 --- a/app/module/ai_chat/service/ai_chat.service.go +++ /dev/null @@ -1,229 +0,0 @@ -package service - -import ( - "errors" - "jaecoo-be/app/module/ai_chat/mapper" - "jaecoo-be/app/module/ai_chat/repository" - "jaecoo-be/app/module/ai_chat/request" - "jaecoo-be/app/module/ai_chat/response" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - - "github.com/rs/zerolog" -) - -type aiChatService struct { - Repo repository.AIChatRepository - UsersRepo usersRepository.UsersRepository - Log zerolog.Logger -} - -type AIChatService interface { - // Sessions - GetUserSessions(authToken string, req request.AIChatSessionsQueryRequest) (sessions []*response.AIChatSessionsResponse, paging paginator.Pagination, err error) - GetSession(authToken string, id uint) (session *response.AIChatSessionsResponse, err error) - CreateSession(authToken string, req request.AIChatSessionsCreateRequest) (session *response.AIChatSessionsResponse, err error) - UpdateSession(authToken string, id uint, req request.AIChatSessionsUpdateRequest) (err error) - DeleteSession(authToken string, id uint) error - ArchiveSession(authToken string, id uint) error - - // Messages - GetSessionMessages(authToken string, sessionId uint, req request.AIChatMessagesQueryRequest) (messages []*response.AIChatMessagesResponse, paging paginator.Pagination, err error) - SendMessage(authToken string, req request.AIChatMessagesCreateRequest) (message *response.AIChatMessagesResponse, err error) - UpdateMessage(authToken string, messageId uint, req request.AIChatMessagesUpdateRequest) (err error) - DeleteMessage(authToken string, messageId uint) error - - // Logs - GetUserLogs(authToken string, req request.AIChatLogsQueryRequest) (logs []*response.AIChatLogsResponse, paging paginator.Pagination, err error) - GetLog(authToken string, logId uint) (log *response.AIChatLogsResponse, err error) -} - -func NewAIChatService(repo repository.AIChatRepository, usersRepo usersRepository.UsersRepository, log zerolog.Logger) AIChatService { - return &aiChatService{ - Repo: repo, - UsersRepo: usersRepo, - Log: log, - } -} - -// Sessions methods -func (_i *aiChatService) GetUserSessions(authToken string, req request.AIChatSessionsQueryRequest) (sessions []*response.AIChatSessionsResponse, paging paginator.Pagination, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - - results, paging, err := _i.Repo.GetUserSessions(userInfo.ID, req) - if err != nil { - return - } - - for _, result := range results { - sessions = append(sessions, mapper.AIChatSessionsResponseMapper(result)) - } - - return -} - -func (_i *aiChatService) GetSession(authToken string, id uint) (session *response.AIChatSessionsResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - - result, err := _i.Repo.FindSessionByUserAndId(userInfo.ID, id) - if err != nil { - return nil, err - } - - return mapper.AIChatSessionsResponseMapper(result), nil -} - -func (_i *aiChatService) CreateSession(authToken string, req request.AIChatSessionsCreateRequest) (session *response.AIChatSessionsResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - - entity := req.ToEntity() - entity.UserID = userInfo.ID - - _i.Log.Info().Interface("data", entity).Msg("Create AI chat session") - - result, err := _i.Repo.CreateSession(entity) - if err != nil { - return nil, err - } - - return mapper.AIChatSessionsResponseMapper(result), nil -} - -func (_i *aiChatService) UpdateSession(authToken string, id uint, req request.AIChatSessionsUpdateRequest) (err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - _i.Log.Info().Interface("data", req).Msg("Updating AI chat session") - - // Check if session exists and belongs to user - existing, err := _i.Repo.FindSessionByUserAndId(userInfo.ID, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("AI chat session not found") - } - - entity := req.ToEntity() - return _i.Repo.UpdateSession(userInfo.ID, id, entity) -} - -func (_i *aiChatService) DeleteSession(authToken string, id uint) error { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - - // Check if session exists and belongs to user - existing, err := _i.Repo.FindSessionByUserAndId(userInfo.ID, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("AI chat session not found") - } - - return _i.Repo.DeleteSession(userInfo.ID, id) -} - -func (_i *aiChatService) ArchiveSession(authToken string, id uint) error { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - - // Check if session exists and belongs to user - existing, err := _i.Repo.FindSessionByUserAndId(userInfo.ID, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("AI chat session not found") - } - - // Update status to archived - existing.IsActive = false - return _i.Repo.UpdateSession(userInfo.ID, id, existing) -} - -// Messages methods -func (_i *aiChatService) GetSessionMessages(authToken string, sessionId uint, req request.AIChatMessagesQueryRequest) (messages []*response.AIChatMessagesResponse, paging paginator.Pagination, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - - // Verify session belongs to user - session, err := _i.Repo.FindSessionByUserAndId(userInfo.ID, sessionId) - if err != nil { - return nil, paginator.Pagination{}, err - } - - results, paging, err := _i.Repo.GetSessionMessages(session.SessionID, req) - if err != nil { - return - } - - for _, result := range results { - messages = append(messages, mapper.AIChatMessagesResponseMapper(result)) - } - - return -} - -func (_i *aiChatService) SendMessage(authToken string, req request.AIChatMessagesCreateRequest) (message *response.AIChatMessagesResponse, err error) { - // userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - - // Verify session exists - session, err := _i.Repo.FindSessionBySessionId(req.SessionID) - if err != nil { - return nil, err - } - - entity := req.ToEntity() - - result, err := _i.Repo.CreateMessage(entity) - if err != nil { - return nil, err - } - - // Increment message count in session - err = _i.Repo.IncrementMessageCount(session.ID) - if err != nil { - _i.Log.Error().Err(err).Msg("Failed to increment message count") - } - - return mapper.AIChatMessagesResponseMapper(result), nil -} - -// Update Message -func (_i *aiChatService) UpdateMessage(authToken string, messageId uint, req request.AIChatMessagesUpdateRequest) (err error) { - // userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - - entity := req.ToEntity() - return _i.Repo.UpdateMessage(messageId, entity) -} - -// Delete Message -func (_i *aiChatService) DeleteMessage(authToken string, messageId uint) error { - // userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - - return _i.Repo.DeleteMessage(messageId) -} - -// Logs methods -func (_i *aiChatService) GetUserLogs(authToken string, req request.AIChatLogsQueryRequest) (logs []*response.AIChatLogsResponse, paging paginator.Pagination, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - - results, paging, err := _i.Repo.GetUserLogs(userInfo.ID, req) - if err != nil { - return - } - - for _, result := range results { - logs = append(logs, mapper.AIChatLogsResponseMapper(result)) - } - - return -} - -func (_i *aiChatService) GetLog(authToken string, logId uint) (log *response.AIChatLogsResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - - result, err := _i.Repo.FindLogByUserAndId(userInfo.ID, logId) - if err != nil { - return nil, err - } - - return mapper.AIChatLogsResponseMapper(result), nil -} diff --git a/app/module/campaign_destinations/campaign_destinations.module.go b/app/module/campaign_destinations/campaign_destinations.module.go deleted file mode 100644 index ce8267d..0000000 --- a/app/module/campaign_destinations/campaign_destinations.module.go +++ /dev/null @@ -1,54 +0,0 @@ -package campaign_destinations - -import ( - "jaecoo-be/app/module/campaign_destinations/controller" - "jaecoo-be/app/module/campaign_destinations/repository" - "jaecoo-be/app/module/campaign_destinations/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// CampaignDestinationsRouter struct of CampaignDestinationsRouter -type CampaignDestinationsRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// NewCampaignDestinationsModule register bulky of CampaignDestinations module -var NewCampaignDestinationsModule = fx.Options( - // register repository of CampaignDestinations module - fx.Provide(repository.NewCampaignDestinationsRepository), - - // register service of CampaignDestinations module - fx.Provide(service.NewCampaignDestinationsService), - - // register controller of CampaignDestinations module - fx.Provide(controller.NewController), - - // register router of CampaignDestinations module - fx.Provide(NewCampaignDestinationsRouter), -) - -// NewCampaignDestinationsRouter init CampaignDestinationsRouter -func NewCampaignDestinationsRouter(fiber *fiber.App, controller *controller.Controller) *CampaignDestinationsRouter { - return &CampaignDestinationsRouter{ - App: fiber, - Controller: controller, - } -} - -// RegisterCampaignDestinationsRoutes register routes of CampaignDestinations module -func (_i *CampaignDestinationsRouter) RegisterCampaignDestinationsRoutes() { - // define controllers - campaignDestinationsController := _i.Controller.CampaignDestinations - - // define routes - _i.App.Route("/campaign-destinations", func(router fiber.Router) { - router.Get("/", campaignDestinationsController.All) - router.Get("/:id", campaignDestinationsController.Show) - router.Post("/", campaignDestinationsController.Save) - router.Put("/:id", campaignDestinationsController.Update) - router.Delete("/:id", campaignDestinationsController.Delete) - }) -} diff --git a/app/module/campaign_destinations/controller/campaign_destinations.controller.go b/app/module/campaign_destinations/controller/campaign_destinations.controller.go deleted file mode 100644 index 5bae548..0000000 --- a/app/module/campaign_destinations/controller/campaign_destinations.controller.go +++ /dev/null @@ -1,201 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/campaign_destinations/request" - "jaecoo-be/app/module/campaign_destinations/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type campaignDestinationsController struct { - campaignDestinationsService service.CampaignDestinationsService - Log zerolog.Logger -} - -type CampaignDestinationsController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error -} - -func NewCampaignDestinationsController(campaignDestinationsService service.CampaignDestinationsService, log zerolog.Logger) CampaignDestinationsController { - return &campaignDestinationsController{ - campaignDestinationsService: campaignDestinationsService, - Log: log, - } -} - -// All CampaignDestinations -// @Summary Get all CampaignDestinations -// @Description API for getting all CampaignDestinations -// @Tags CampaignDestinations -// @Security Bearer -// @Param X-Client-Key header string true "Insert the X-Client-Key" -// @Param req query request.CampaignDestinationsQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaign-destinations [get] -func (_i *campaignDestinationsController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.CampaignDestinationsQueryRequestContext{ - Name: c.Query("name"), - CampaignTypeID: c.Query("campaignTypeId"), - IsActive: c.Query("isActive"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - authToken := c.Get("Authorization") - campaignDestinationsData, paging, err := _i.campaignDestinationsService.All(req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignDestinations list successfully retrieved"}, - Data: campaignDestinationsData, - Meta: paging, - }) -} - -// Show CampaignDestinations -// @Summary Get one CampaignDestinations -// @Description API for getting one CampaignDestinations -// @Tags CampaignDestinations -// @Security Bearer -// @Param id path int true "CampaignDestinations ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaign-destinations/{id} [get] -func (_i *campaignDestinationsController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - campaignDestinationsData, err := _i.campaignDestinationsService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignDestinations successfully retrieved"}, - Data: campaignDestinationsData, - }) -} - -// Save CampaignDestinations -// @Summary Create CampaignDestinations -// @Description API for create CampaignDestinations -// @Tags CampaignDestinations -// @Security Bearer -// @Param X-Csrf-Token header string false "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.CampaignDestinationsCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaign-destinations [post] -func (_i *campaignDestinationsController) Save(c *fiber.Ctx) error { - req := new(request.CampaignDestinationsCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authToken := c.Get("Authorization") - - dataResult, err := _i.campaignDestinationsService.Save(*req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignDestinations successfully created"}, - Data: dataResult, - }) -} - -// Update CampaignDestinations -// @Summary Update CampaignDestinations -// @Description API for update CampaignDestinations -// @Tags CampaignDestinations -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param payload body request.CampaignDestinationsUpdateRequest true "Required payload" -// @Param id path int true "CampaignDestinations ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaign-destinations/{id} [put] -func (_i *campaignDestinationsController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.CampaignDestinationsUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.campaignDestinationsService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignDestinations successfully updated"}, - }) -} - -// Delete CampaignDestinations -// @Summary Delete CampaignDestinations -// @Description API for delete CampaignDestinations -// @Tags CampaignDestinations -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "CampaignDestinations ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaign-destinations/{id} [delete] -func (_i *campaignDestinationsController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.campaignDestinationsService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignDestinations successfully deleted"}, - }) -} diff --git a/app/module/campaign_destinations/controller/controller.go b/app/module/campaign_destinations/controller/controller.go deleted file mode 100644 index f87edf5..0000000 --- a/app/module/campaign_destinations/controller/controller.go +++ /dev/null @@ -1,17 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/campaign_destinations/service" - - "github.com/rs/zerolog" -) - -type Controller struct { - CampaignDestinations CampaignDestinationsController -} - -func NewController(CampaignDestinationsService service.CampaignDestinationsService, log zerolog.Logger) *Controller { - return &Controller{ - CampaignDestinations: NewCampaignDestinationsController(CampaignDestinationsService, log), - } -} diff --git a/app/module/campaign_destinations/mapper/campaign_destinations.mapper.go b/app/module/campaign_destinations/mapper/campaign_destinations.mapper.go deleted file mode 100644 index bdbaf92..0000000 --- a/app/module/campaign_destinations/mapper/campaign_destinations.mapper.go +++ /dev/null @@ -1,31 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - res "jaecoo-be/app/module/campaign_destinations/response" -) - -func CampaignDestinationsResponseMapper(campaignDestinationsReq *entity.CampaignDestinations) (campaignDestinationsRes *res.CampaignDestinationsResponse) { - if campaignDestinationsReq != nil { - campaignDestinationsRes = &res.CampaignDestinationsResponse{ - ID: campaignDestinationsReq.ID, - CampaignTypeID: campaignDestinationsReq.CampaignTypeID, - SubType: campaignDestinationsReq.SubType, - Name: campaignDestinationsReq.Name, - Description: campaignDestinationsReq.Description, - URL: campaignDestinationsReq.URL, - IsActive: campaignDestinationsReq.IsActive, - CreatedAt: campaignDestinationsReq.CreatedAt, - UpdatedAt: campaignDestinationsReq.UpdatedAt, - } - - if campaignDestinationsReq.CampaignType.ID > 0 { - campaignDestinationsRes.CampaignType = &res.CampaignTypeInfo{ - ID: campaignDestinationsReq.CampaignType.ID, - Name: campaignDestinationsReq.CampaignType.Name, - Description: campaignDestinationsReq.CampaignType.Description, - } - } - } - return campaignDestinationsRes -} diff --git a/app/module/campaign_destinations/repository/campaign_destinations.repository.go b/app/module/campaign_destinations/repository/campaign_destinations.repository.go deleted file mode 100644 index ed46411..0000000 --- a/app/module/campaign_destinations/repository/campaign_destinations.repository.go +++ /dev/null @@ -1,105 +0,0 @@ -package repository - -import ( - "fmt" - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/campaign_destinations/request" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "strings" - - "github.com/rs/zerolog" -) - -type campaignDestinationsRepository struct { - DB *database.Database - Log zerolog.Logger -} - -// CampaignDestinationsRepository define interface of ICampaignDestinationsRepository -type CampaignDestinationsRepository interface { - GetAll(req request.CampaignDestinationsQueryRequest) (campaignDestinationss []*entity.CampaignDestinations, paging paginator.Pagination, err error) - FindOne(id uint) (campaignDestinations *entity.CampaignDestinations, err error) - Create(campaignDestinations *entity.CampaignDestinations) (campaignDestinationsReturn *entity.CampaignDestinations, err error) - Update(id uint, campaignDestinations *entity.CampaignDestinations) (err error) - Delete(id uint) (err error) -} - -func NewCampaignDestinationsRepository(db *database.Database, log zerolog.Logger) CampaignDestinationsRepository { - return &campaignDestinationsRepository{ - DB: db, - Log: log, - } -} - -// implement interface of ICampaignDestinationsRepository -func (_i *campaignDestinationsRepository) GetAll(req request.CampaignDestinationsQueryRequest) (campaignDestinationss []*entity.CampaignDestinations, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.CampaignDestinations{}).Preload("CampaignType") - - if req.Name != nil && *req.Name != "" { - name := strings.ToLower(*req.Name) - query = query.Where("LOWER(name) LIKE ?", "%"+strings.ToLower(name)+"%") - } - if req.CampaignTypeID != nil { - query = query.Where("campaign_type_id = ?", req.CampaignTypeID) - } - if req.IsActive != nil { - query = query.Where("is_active = ?", req.IsActive) - } - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction)) - } else { - direction := "DESC" - sortBy := "created_at" - query.Order(fmt.Sprintf("%s %s", sortBy, direction)) - } - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&campaignDestinationss).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *campaignDestinationsRepository) FindOne(id uint) (campaignDestinations *entity.CampaignDestinations, err error) { - query := _i.DB.DB.Where("id = ?", id).Preload("CampaignType") - - if err := query.First(&campaignDestinations).Error; err != nil { - return nil, err - } - - return campaignDestinations, nil -} - -func (_i *campaignDestinationsRepository) Create(campaignDestinations *entity.CampaignDestinations) (campaignDestinationsReturn *entity.CampaignDestinations, err error) { - result := _i.DB.DB.Create(campaignDestinations) - return campaignDestinations, result.Error -} - -func (_i *campaignDestinationsRepository) Update(id uint, campaignDestinations *entity.CampaignDestinations) (err error) { - campaignDestinationsMap, err := utilSvc.StructToMap(campaignDestinations) - if err != nil { - return err - } - query := _i.DB.DB.Model(&entity.CampaignDestinations{}).Where(&entity.CampaignDestinations{ID: id}) - return query.Updates(campaignDestinationsMap).Error -} - -func (_i *campaignDestinationsRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.CampaignDestinations{}, id).Error -} diff --git a/app/module/campaign_destinations/request/campaign_destinations.request.go b/app/module/campaign_destinations/request/campaign_destinations.request.go deleted file mode 100644 index 6c65571..0000000 --- a/app/module/campaign_destinations/request/campaign_destinations.request.go +++ /dev/null @@ -1,92 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -type CampaignDestinationsQueryRequest struct { - Name *string `json:"name"` - CampaignTypeID *uint `json:"campaignTypeId"` - IsActive *bool `json:"isActive"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type CampaignDestinationsCreateRequest struct { - CampaignTypeID uint `json:"campaignTypeId" validate:"required"` - Name string `json:"name" validate:"required"` - SubType *string `json:"subType"` - Description *string `json:"description"` - URL *string `json:"url"` - IsActive *bool `json:"isActive"` - CreatedById *uint `json:"createdById"` -} - -func (req CampaignDestinationsCreateRequest) ToEntity() *entity.CampaignDestinations { - isActive := true - if req.IsActive != nil { - isActive = *req.IsActive - } - return &entity.CampaignDestinations{ - CampaignTypeID: req.CampaignTypeID, - SubType: req.SubType, - Name: req.Name, - Description: req.Description, - URL: req.URL, - IsActive: &isActive, - CreatedAt: time.Now(), - UpdatedAt: time.Now(), - } -} - -type CampaignDestinationsUpdateRequest struct { - CampaignTypeID uint `json:"campaignTypeId" validate:"required"` - Name string `json:"name" validate:"required"` - SubType *string `json:"subType"` - Description *string `json:"description"` - URL *string `json:"url"` - IsActive *bool `json:"isActive"` -} - -func (req CampaignDestinationsUpdateRequest) ToEntity() *entity.CampaignDestinations { - return &entity.CampaignDestinations{ - CampaignTypeID: req.CampaignTypeID, - SubType: req.SubType, - Name: req.Name, - Description: req.Description, - URL: req.URL, - IsActive: req.IsActive, - UpdatedAt: time.Now(), - } -} - -type CampaignDestinationsQueryRequestContext struct { - Name string `json:"name"` - CampaignTypeID string `json:"campaignTypeId"` - IsActive string `json:"isActive"` -} - -func (req CampaignDestinationsQueryRequestContext) ToParamRequest() CampaignDestinationsQueryRequest { - var request CampaignDestinationsQueryRequest - - if name := req.Name; name != "" { - request.Name = &name - } - if campaignTypeIDStr := req.CampaignTypeID; campaignTypeIDStr != "" { - campaignTypeID, err := strconv.ParseUint(campaignTypeIDStr, 10, 32) - if err == nil { - campaignTypeIDUint := uint(campaignTypeID) - request.CampaignTypeID = &campaignTypeIDUint - } - } - if isActiveStr := req.IsActive; isActiveStr != "" { - isActive, err := strconv.ParseBool(isActiveStr) - if err == nil { - request.IsActive = &isActive - } - } - - return request -} diff --git a/app/module/campaign_destinations/response/campaign_destinations.response.go b/app/module/campaign_destinations/response/campaign_destinations.response.go deleted file mode 100644 index 8dce08d..0000000 --- a/app/module/campaign_destinations/response/campaign_destinations.response.go +++ /dev/null @@ -1,23 +0,0 @@ -package response - -import "time" - -type CampaignDestinationsResponse struct { - ID uint `json:"id"` - CampaignTypeID uint `json:"campaignTypeId"` - CampaignType *CampaignTypeInfo `json:"campaignType,omitempty"` - SubType *string `json:"subType"` - Name string `json:"name"` - Description *string `json:"description"` - URL *string `json:"url"` - IsActive *bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - -type CampaignTypeInfo struct { - ID uint `json:"id"` - Name string `json:"name"` - Description *string `json:"description"` -} - diff --git a/app/module/campaign_destinations/service/campaign_destinations.service.go b/app/module/campaign_destinations/service/campaign_destinations.service.go deleted file mode 100644 index 7f498df..0000000 --- a/app/module/campaign_destinations/service/campaign_destinations.service.go +++ /dev/null @@ -1,93 +0,0 @@ -package service - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/campaign_destinations/mapper" - "jaecoo-be/app/module/campaign_destinations/repository" - "jaecoo-be/app/module/campaign_destinations/request" - "jaecoo-be/app/module/campaign_destinations/response" - usersRepository "jaecoo-be/app/module/users/repository" - config "jaecoo-be/config/config" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - - "github.com/rs/zerolog" -) - -// CampaignDestinationsService -type campaignDestinationsService struct { - Repo repository.CampaignDestinationsRepository - UsersRepo usersRepository.UsersRepository - Log zerolog.Logger - Cfg *config.Config -} - -// CampaignDestinationsService define interface of ICampaignDestinationsService -type CampaignDestinationsService interface { - All(req request.CampaignDestinationsQueryRequest, authToken string) (campaignDestinations []*response.CampaignDestinationsResponse, paging paginator.Pagination, err error) - Show(id uint) (campaignDestinations *response.CampaignDestinationsResponse, err error) - Save(req request.CampaignDestinationsCreateRequest, authToken string) (campaignDestinations *entity.CampaignDestinations, err error) - Update(id uint, req request.CampaignDestinationsUpdateRequest) (err error) - Delete(id uint) error -} - -// NewCampaignDestinationsService init CampaignDestinationsService -func NewCampaignDestinationsService(repo repository.CampaignDestinationsRepository, usersRepo usersRepository.UsersRepository, log zerolog.Logger, cfg *config.Config) CampaignDestinationsService { - return &campaignDestinationsService{ - Repo: repo, - UsersRepo: usersRepo, - Log: log, - Cfg: cfg, - } -} - -// All implement interface of CampaignDestinationsService -func (_i *campaignDestinationsService) All(req request.CampaignDestinationsQueryRequest, authToken string) (campaignDestinationss []*response.CampaignDestinationsResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req) - if err != nil { - return - } - - for _, result := range results { - campaignDestinationss = append(campaignDestinationss, mapper.CampaignDestinationsResponseMapper(result)) - } - - return -} - -func (_i *campaignDestinationsService) Show(id uint) (campaignDestinations *response.CampaignDestinationsResponse, err error) { - result, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - return mapper.CampaignDestinationsResponseMapper(result), nil -} - -func (_i *campaignDestinationsService) Save(req request.CampaignDestinationsCreateRequest, authToken string) (campaignDestinations *entity.CampaignDestinations, err error) { - _i.Log.Info().Interface("data", req).Msg("") - newReq := req.ToEntity() - - if req.CreatedById != nil { - createdBy, err := _i.UsersRepo.FindOne(*req.CreatedById) - if err != nil { - return nil, err - } - _ = createdBy - } else { - createdBy := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - _ = createdBy - } - - return _i.Repo.Create(newReq) -} - -func (_i *campaignDestinationsService) Update(id uint, req request.CampaignDestinationsUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - - newReq := req.ToEntity() - return _i.Repo.Update(id, newReq) -} - -func (_i *campaignDestinationsService) Delete(id uint) error { - return _i.Repo.Delete(id) -} diff --git a/app/module/campaign_files/campaign_files.module.go b/app/module/campaign_files/campaign_files.module.go deleted file mode 100644 index 1add14c..0000000 --- a/app/module/campaign_files/campaign_files.module.go +++ /dev/null @@ -1,55 +0,0 @@ -package campaign_files - -import ( - "jaecoo-be/app/module/campaign_files/controller" - "jaecoo-be/app/module/campaign_files/repository" - "jaecoo-be/app/module/campaign_files/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// CampaignFilesRouter struct of CampaignFilesRouter -type CampaignFilesRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// NewCampaignFilesModule register bulky of CampaignFiles module -var NewCampaignFilesModule = fx.Options( - // register repository of CampaignFiles module - fx.Provide(repository.NewCampaignFilesRepository), - - // register service of CampaignFiles module - fx.Provide(service.NewCampaignFilesService), - - // register controller of CampaignFiles module - fx.Provide(controller.NewController), - - // register router of CampaignFiles module - fx.Provide(NewCampaignFilesRouter), -) - -// NewCampaignFilesRouter init CampaignFilesRouter -func NewCampaignFilesRouter(fiber *fiber.App, controller *controller.Controller) *CampaignFilesRouter { - return &CampaignFilesRouter{ - App: fiber, - Controller: controller, - } -} - -// RegisterCampaignFilesRoutes register routes of CampaignFiles module -func (_i *CampaignFilesRouter) RegisterCampaignFilesRoutes() { - // define controllers - campaignFilesController := _i.Controller.CampaignFiles - - // define routes - _i.App.Route("/campaign-files", func(router fiber.Router) { - router.Get("/", campaignFilesController.All) - router.Get("/:id", campaignFilesController.Show) - router.Get("/campaign/:campaignId", campaignFilesController.GetByCampaign) - router.Post("/", campaignFilesController.Save) - router.Put("/:id", campaignFilesController.Update) - router.Delete("/:id", campaignFilesController.Delete) - }) -} diff --git a/app/module/campaign_files/controller/campaign_files.controller.go b/app/module/campaign_files/controller/campaign_files.controller.go deleted file mode 100644 index 2f16f95..0000000 --- a/app/module/campaign_files/controller/campaign_files.controller.go +++ /dev/null @@ -1,156 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/campaign_files/request" - "jaecoo-be/app/module/campaign_files/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type campaignFilesController struct { - campaignFilesService service.CampaignFilesService - Log zerolog.Logger -} - -type CampaignFilesController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - GetByCampaign(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error -} - -func NewCampaignFilesController(campaignFilesService service.CampaignFilesService, log zerolog.Logger) CampaignFilesController { - return &campaignFilesController{ - campaignFilesService: campaignFilesService, - Log: log, - } -} - -func (_i *campaignFilesController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.CampaignFilesQueryRequestContext{ - CampaignID: c.Query("campaignId"), - Type: c.Query("type"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - authToken := c.Get("Authorization") - data, paging, err := _i.campaignFilesService.All(req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignFiles list successfully retrieved"}, - Data: data, - Meta: paging, - }) -} - -func (_i *campaignFilesController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - data, err := _i.campaignFilesService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignFiles successfully retrieved"}, - Data: data, - }) -} - -func (_i *campaignFilesController) GetByCampaign(c *fiber.Ctx) error { - campaignID, err := strconv.ParseUint(c.Params("campaignId"), 10, 0) - if err != nil { - return err - } - - data, err := _i.campaignFilesService.GetByCampaign(uint(campaignID)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignFiles successfully retrieved"}, - Data: data, - }) -} - -func (_i *campaignFilesController) Save(c *fiber.Ctx) error { - req := new(request.CampaignFilesCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authToken := c.Get("Authorization") - dataResult, err := _i.campaignFilesService.Save(*req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignFiles successfully created"}, - Data: dataResult, - }) -} - -func (_i *campaignFilesController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.CampaignFilesUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.campaignFilesService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignFiles successfully updated"}, - }) -} - -func (_i *campaignFilesController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.campaignFilesService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignFiles successfully deleted"}, - }) -} diff --git a/app/module/campaign_files/controller/controller.go b/app/module/campaign_files/controller/controller.go deleted file mode 100644 index 62a3520..0000000 --- a/app/module/campaign_files/controller/controller.go +++ /dev/null @@ -1,17 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/campaign_files/service" - - "github.com/rs/zerolog" -) - -type Controller struct { - CampaignFiles CampaignFilesController -} - -func NewController(CampaignFilesService service.CampaignFilesService, log zerolog.Logger) *Controller { - return &Controller{ - CampaignFiles: NewCampaignFilesController(CampaignFilesService, log), - } -} diff --git a/app/module/campaign_files/mapper/campaign_files.mapper.go b/app/module/campaign_files/mapper/campaign_files.mapper.go deleted file mode 100644 index 4690b7b..0000000 --- a/app/module/campaign_files/mapper/campaign_files.mapper.go +++ /dev/null @@ -1,24 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - res "jaecoo-be/app/module/campaign_files/response" -) - -func CampaignFilesResponseMapper(campaignFilesReq *entity.CampaignFiles) (campaignFilesRes *res.CampaignFilesResponse) { - if campaignFilesReq != nil { - campaignFilesRes = &res.CampaignFilesResponse{ - ID: campaignFilesReq.ID, - CampaignID: campaignFilesReq.CampaignID, - Type: campaignFilesReq.Type, - FileURL: campaignFilesReq.FileURL, - ExternalURL: campaignFilesReq.ExternalURL, - IsDraft: campaignFilesReq.IsDraft, - IsPublish: campaignFilesReq.IsPublish, - IsActive: campaignFilesReq.IsActive, - CreatedAt: campaignFilesReq.CreatedAt, - UpdatedAt: campaignFilesReq.UpdatedAt, - } - } - return campaignFilesRes -} diff --git a/app/module/campaign_files/repository/campaign_files.repository.go b/app/module/campaign_files/repository/campaign_files.repository.go deleted file mode 100644 index d4d3d82..0000000 --- a/app/module/campaign_files/repository/campaign_files.repository.go +++ /dev/null @@ -1,99 +0,0 @@ -package repository - -import ( - "fmt" - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/campaign_files/request" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - - "github.com/rs/zerolog" -) - -type campaignFilesRepository struct { - DB *database.Database - Log zerolog.Logger -} - -type CampaignFilesRepository interface { - GetAll(req request.CampaignFilesQueryRequest) (campaignFiless []*entity.CampaignFiles, paging paginator.Pagination, err error) - FindOne(id uint) (campaignFiles *entity.CampaignFiles, err error) - FindByCampaign(campaignID uint) (campaignFiles []*entity.CampaignFiles, err error) - Create(campaignFiles *entity.CampaignFiles) (campaignFilesReturn *entity.CampaignFiles, err error) - Update(id uint, campaignFiles *entity.CampaignFiles) (err error) - Delete(id uint) (err error) -} - -func NewCampaignFilesRepository(db *database.Database, log zerolog.Logger) CampaignFilesRepository { - return &campaignFilesRepository{ - DB: db, - Log: log, - } -} - -func (_i *campaignFilesRepository) GetAll(req request.CampaignFilesQueryRequest) (campaignFiless []*entity.CampaignFiles, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.CampaignFiles{}).Preload("Campaign") - - if req.CampaignID != nil { - query = query.Where("campaign_id = ?", req.CampaignID) - } - if req.Type != nil && *req.Type != "" { - query = query.Where("type = ?", req.Type) - } - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction)) - } else { - query.Order("created_at DESC") - } - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&campaignFiless).Error - if err != nil { - return - } - - paging = *req.Pagination - return -} - -func (_i *campaignFilesRepository) FindOne(id uint) (campaignFiles *entity.CampaignFiles, err error) { - query := _i.DB.DB.Where("id = ?", id).Preload("Campaign") - if err := query.First(&campaignFiles).Error; err != nil { - return nil, err - } - return campaignFiles, nil -} - -func (_i *campaignFilesRepository) FindByCampaign(campaignID uint) (campaignFiles []*entity.CampaignFiles, err error) { - query := _i.DB.DB.Where("campaign_id = ?", campaignID).Preload("Campaign") - err = query.Find(&campaignFiles).Error - return -} - -func (_i *campaignFilesRepository) Create(campaignFiles *entity.CampaignFiles) (campaignFilesReturn *entity.CampaignFiles, err error) { - result := _i.DB.DB.Create(campaignFiles) - return campaignFiles, result.Error -} - -func (_i *campaignFilesRepository) Update(id uint, campaignFiles *entity.CampaignFiles) (err error) { - campaignFilesMap, err := utilSvc.StructToMap(campaignFiles) - if err != nil { - return err - } - return _i.DB.DB.Model(&entity.CampaignFiles{}).Where(&entity.CampaignFiles{ID: id}).Updates(campaignFilesMap).Error -} - -func (_i *campaignFilesRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.CampaignFiles{}, id).Error -} diff --git a/app/module/campaign_files/request/campaign_files.request.go b/app/module/campaign_files/request/campaign_files.request.go deleted file mode 100644 index 3b0b720..0000000 --- a/app/module/campaign_files/request/campaign_files.request.go +++ /dev/null @@ -1,85 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -type CampaignFilesQueryRequest struct { - CampaignID *uint `json:"campaignId"` - Type *string `json:"type"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type CampaignFilesCreateRequest struct { - CampaignID uint `json:"campaignId" validate:"required"` - Type string `json:"type" validate:"required"` // url, file - FileURL *string `json:"fileUrl"` - ExternalURL *string `json:"externalUrl"` - IsDraft *bool `json:"isDraft"` - IsPublish *bool `json:"isPublish"` -} - -func (req CampaignFilesCreateRequest) ToEntity() *entity.CampaignFiles { - isDraft := false - isPublish := false - if req.IsDraft != nil { - isDraft = *req.IsDraft - } - if req.IsPublish != nil { - isPublish = *req.IsPublish - } - return &entity.CampaignFiles{ - CampaignID: req.CampaignID, - Type: req.Type, - FileURL: req.FileURL, - ExternalURL: req.ExternalURL, - IsDraft: &isDraft, - IsPublish: &isPublish, - CreatedAt: time.Now(), - UpdatedAt: time.Now(), - } -} - -type CampaignFilesUpdateRequest struct { - Type string `json:"type" validate:"required"` - FileURL *string `json:"fileUrl"` - ExternalURL *string `json:"externalUrl"` - IsDraft *bool `json:"isDraft"` - IsPublish *bool `json:"isPublish"` -} - -func (req CampaignFilesUpdateRequest) ToEntity() *entity.CampaignFiles { - return &entity.CampaignFiles{ - Type: req.Type, - FileURL: req.FileURL, - ExternalURL: req.ExternalURL, - IsDraft: req.IsDraft, - IsPublish: req.IsPublish, - UpdatedAt: time.Now(), - } -} - -type CampaignFilesQueryRequestContext struct { - CampaignID string `json:"campaignId"` - Type string `json:"type"` -} - -func (req CampaignFilesQueryRequestContext) ToParamRequest() CampaignFilesQueryRequest { - var request CampaignFilesQueryRequest - - if campaignIDStr := req.CampaignID; campaignIDStr != "" { - campaignID, err := strconv.ParseUint(campaignIDStr, 10, 32) - if err == nil { - campaignIDUint := uint(campaignID) - request.CampaignID = &campaignIDUint - } - } - if typeStr := req.Type; typeStr != "" { - request.Type = &typeStr - } - - return request -} diff --git a/app/module/campaign_files/response/campaign_files.response.go b/app/module/campaign_files/response/campaign_files.response.go deleted file mode 100644 index 53a541b..0000000 --- a/app/module/campaign_files/response/campaign_files.response.go +++ /dev/null @@ -1,17 +0,0 @@ -package response - -import "time" - -type CampaignFilesResponse struct { - ID uint `json:"id"` - CampaignID uint `json:"campaignId"` - Type string `json:"type"` - FileURL *string `json:"fileUrl"` - ExternalURL *string `json:"externalUrl"` - IsDraft *bool `json:"isDraft"` - IsPublish *bool `json:"isPublish"` - IsActive *bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - diff --git a/app/module/campaign_files/service/campaign_files.service.go b/app/module/campaign_files/service/campaign_files.service.go deleted file mode 100644 index b5c5bfe..0000000 --- a/app/module/campaign_files/service/campaign_files.service.go +++ /dev/null @@ -1,85 +0,0 @@ -package service - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/campaign_files/mapper" - "jaecoo-be/app/module/campaign_files/repository" - "jaecoo-be/app/module/campaign_files/request" - "jaecoo-be/app/module/campaign_files/response" - usersRepository "jaecoo-be/app/module/users/repository" - config "jaecoo-be/config/config" - "jaecoo-be/utils/paginator" - - "github.com/rs/zerolog" -) - -type campaignFilesService struct { - Repo repository.CampaignFilesRepository - UsersRepo usersRepository.UsersRepository - Log zerolog.Logger - Cfg *config.Config -} - -type CampaignFilesService interface { - All(req request.CampaignFilesQueryRequest, authToken string) (campaignFiles []*response.CampaignFilesResponse, paging paginator.Pagination, err error) - Show(id uint) (campaignFiles *response.CampaignFilesResponse, err error) - GetByCampaign(campaignID uint) (campaignFiles []*response.CampaignFilesResponse, err error) - Save(req request.CampaignFilesCreateRequest, authToken string) (campaignFiles *entity.CampaignFiles, err error) - Update(id uint, req request.CampaignFilesUpdateRequest) (err error) - Delete(id uint) error -} - -func NewCampaignFilesService(repo repository.CampaignFilesRepository, usersRepo usersRepository.UsersRepository, log zerolog.Logger, cfg *config.Config) CampaignFilesService { - return &campaignFilesService{ - Repo: repo, - UsersRepo: usersRepo, - Log: log, - Cfg: cfg, - } -} - -func (_i *campaignFilesService) All(req request.CampaignFilesQueryRequest, authToken string) (campaignFiless []*response.CampaignFilesResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req) - if err != nil { - return - } - - for _, result := range results { - campaignFiless = append(campaignFiless, mapper.CampaignFilesResponseMapper(result)) - } - return -} - -func (_i *campaignFilesService) Show(id uint) (campaignFiles *response.CampaignFilesResponse, err error) { - result, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - return mapper.CampaignFilesResponseMapper(result), nil -} - -func (_i *campaignFilesService) GetByCampaign(campaignID uint) (campaignFiless []*response.CampaignFilesResponse, err error) { - results, err := _i.Repo.FindByCampaign(campaignID) - if err != nil { - return nil, err - } - - for _, result := range results { - campaignFiless = append(campaignFiless, mapper.CampaignFilesResponseMapper(result)) - } - return -} - -func (_i *campaignFilesService) Save(req request.CampaignFilesCreateRequest, authToken string) (campaignFiles *entity.CampaignFiles, err error) { - newReq := req.ToEntity() - return _i.Repo.Create(newReq) -} - -func (_i *campaignFilesService) Update(id uint, req request.CampaignFilesUpdateRequest) (err error) { - newReq := req.ToEntity() - return _i.Repo.Update(id, newReq) -} - -func (_i *campaignFilesService) Delete(id uint) error { - return _i.Repo.Delete(id) -} diff --git a/app/module/campaign_types/campaign_types.module.go b/app/module/campaign_types/campaign_types.module.go deleted file mode 100644 index 2383cee..0000000 --- a/app/module/campaign_types/campaign_types.module.go +++ /dev/null @@ -1,54 +0,0 @@ -package campaign_types - -import ( - "jaecoo-be/app/module/campaign_types/controller" - "jaecoo-be/app/module/campaign_types/repository" - "jaecoo-be/app/module/campaign_types/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// CampaignTypesRouter struct of CampaignTypesRouter -type CampaignTypesRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// NewCampaignTypesModule register bulky of CampaignTypes module -var NewCampaignTypesModule = fx.Options( - // register repository of CampaignTypes module - fx.Provide(repository.NewCampaignTypesRepository), - - // register service of CampaignTypes module - fx.Provide(service.NewCampaignTypesService), - - // register controller of CampaignTypes module - fx.Provide(controller.NewController), - - // register router of CampaignTypes module - fx.Provide(NewCampaignTypesRouter), -) - -// NewCampaignTypesRouter init CampaignTypesRouter -func NewCampaignTypesRouter(fiber *fiber.App, controller *controller.Controller) *CampaignTypesRouter { - return &CampaignTypesRouter{ - App: fiber, - Controller: controller, - } -} - -// RegisterCampaignTypesRoutes register routes of CampaignTypes module -func (_i *CampaignTypesRouter) RegisterCampaignTypesRoutes() { - // define controllers - campaignTypesController := _i.Controller.CampaignTypes - - // define routes - _i.App.Route("/campaign-types", func(router fiber.Router) { - router.Get("/", campaignTypesController.All) - router.Get("/:id", campaignTypesController.Show) - router.Post("/", campaignTypesController.Save) - router.Put("/:id", campaignTypesController.Update) - router.Delete("/:id", campaignTypesController.Delete) - }) -} diff --git a/app/module/campaign_types/controller/campaign_types.controller.go b/app/module/campaign_types/controller/campaign_types.controller.go deleted file mode 100644 index ff8b361..0000000 --- a/app/module/campaign_types/controller/campaign_types.controller.go +++ /dev/null @@ -1,199 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/campaign_types/request" - "jaecoo-be/app/module/campaign_types/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type campaignTypesController struct { - campaignTypesService service.CampaignTypesService - Log zerolog.Logger -} - -type CampaignTypesController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error -} - -func NewCampaignTypesController(campaignTypesService service.CampaignTypesService, log zerolog.Logger) CampaignTypesController { - return &campaignTypesController{ - campaignTypesService: campaignTypesService, - Log: log, - } -} - -// All CampaignTypes -// @Summary Get all CampaignTypes -// @Description API for getting all CampaignTypes -// @Tags CampaignTypes -// @Security Bearer -// @Param X-Client-Key header string true "Insert the X-Client-Key" -// @Param req query request.CampaignTypesQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaign-types [get] -func (_i *campaignTypesController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.CampaignTypesQueryRequestContext{ - Name: c.Query("name"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - authToken := c.Get("Authorization") - campaignTypesData, paging, err := _i.campaignTypesService.All(req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignTypes list successfully retrieved"}, - Data: campaignTypesData, - Meta: paging, - }) -} - -// Show CampaignTypes -// @Summary Get one CampaignTypes -// @Description API for getting one CampaignTypes -// @Tags CampaignTypes -// @Security Bearer -// @Param id path int true "CampaignTypes ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaign-types/{id} [get] -func (_i *campaignTypesController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - campaignTypesData, err := _i.campaignTypesService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignTypes successfully retrieved"}, - Data: campaignTypesData, - }) -} - -// Save CampaignTypes -// @Summary Create CampaignTypes -// @Description API for create CampaignTypes -// @Tags CampaignTypes -// @Security Bearer -// @Param X-Csrf-Token header string false "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.CampaignTypesCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaign-types [post] -func (_i *campaignTypesController) Save(c *fiber.Ctx) error { - req := new(request.CampaignTypesCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authToken := c.Get("Authorization") - - dataResult, err := _i.campaignTypesService.Save(*req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignTypes successfully created"}, - Data: dataResult, - }) -} - -// Update CampaignTypes -// @Summary Update CampaignTypes -// @Description API for update CampaignTypes -// @Tags CampaignTypes -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param payload body request.CampaignTypesUpdateRequest true "Required payload" -// @Param id path int true "CampaignTypes ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaign-types/{id} [put] -func (_i *campaignTypesController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.CampaignTypesUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.campaignTypesService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignTypes successfully updated"}, - }) -} - -// Delete CampaignTypes -// @Summary Delete CampaignTypes -// @Description API for delete CampaignTypes -// @Tags CampaignTypes -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "CampaignTypes ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaign-types/{id} [delete] -func (_i *campaignTypesController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.campaignTypesService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"CampaignTypes successfully deleted"}, - }) -} diff --git a/app/module/campaign_types/controller/controller.go b/app/module/campaign_types/controller/controller.go deleted file mode 100644 index b20667e..0000000 --- a/app/module/campaign_types/controller/controller.go +++ /dev/null @@ -1,17 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/campaign_types/service" - - "github.com/rs/zerolog" -) - -type Controller struct { - CampaignTypes CampaignTypesController -} - -func NewController(CampaignTypesService service.CampaignTypesService, log zerolog.Logger) *Controller { - return &Controller{ - CampaignTypes: NewCampaignTypesController(CampaignTypesService, log), - } -} diff --git a/app/module/campaign_types/mapper/campaign_types.mapper.go b/app/module/campaign_types/mapper/campaign_types.mapper.go deleted file mode 100644 index 84fb66d..0000000 --- a/app/module/campaign_types/mapper/campaign_types.mapper.go +++ /dev/null @@ -1,20 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - res "jaecoo-be/app/module/campaign_types/response" -) - -func CampaignTypesResponseMapper(campaignTypesReq *entity.CampaignTypes) (campaignTypesRes *res.CampaignTypesResponse) { - if campaignTypesReq != nil { - campaignTypesRes = &res.CampaignTypesResponse{ - ID: campaignTypesReq.ID, - Name: campaignTypesReq.Name, - Description: campaignTypesReq.Description, - IsActive: campaignTypesReq.IsActive, - CreatedAt: campaignTypesReq.CreatedAt, - UpdatedAt: campaignTypesReq.UpdatedAt, - } - } - return campaignTypesRes -} diff --git a/app/module/campaign_types/repository/campaign_types.repository.go b/app/module/campaign_types/repository/campaign_types.repository.go deleted file mode 100644 index 93d52c2..0000000 --- a/app/module/campaign_types/repository/campaign_types.repository.go +++ /dev/null @@ -1,99 +0,0 @@ -package repository - -import ( - "fmt" - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/campaign_types/request" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "strings" - - "github.com/rs/zerolog" -) - -type campaignTypesRepository struct { - DB *database.Database - Log zerolog.Logger -} - -// CampaignTypesRepository define interface of ICampaignTypesRepository -type CampaignTypesRepository interface { - GetAll(req request.CampaignTypesQueryRequest) (campaignTypess []*entity.CampaignTypes, paging paginator.Pagination, err error) - FindOne(id uint) (campaignTypes *entity.CampaignTypes, err error) - Create(campaignTypes *entity.CampaignTypes) (campaignTypesReturn *entity.CampaignTypes, err error) - Update(id uint, campaignTypes *entity.CampaignTypes) (err error) - Delete(id uint) (err error) -} - -func NewCampaignTypesRepository(db *database.Database, log zerolog.Logger) CampaignTypesRepository { - return &campaignTypesRepository{ - DB: db, - Log: log, - } -} - -// implement interface of ICampaignTypesRepository -func (_i *campaignTypesRepository) GetAll(req request.CampaignTypesQueryRequest) (campaignTypess []*entity.CampaignTypes, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.CampaignTypes{}) - - if req.Name != nil && *req.Name != "" { - name := strings.ToLower(*req.Name) - query = query.Where("LOWER(name) LIKE ?", "%"+strings.ToLower(name)+"%") - } - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction)) - } else { - direction := "DESC" - sortBy := "created_at" - query.Order(fmt.Sprintf("%s %s", sortBy, direction)) - } - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&campaignTypess).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *campaignTypesRepository) FindOne(id uint) (campaignTypes *entity.CampaignTypes, err error) { - query := _i.DB.DB.Where("id = ?", id) - - if err := query.First(&campaignTypes).Error; err != nil { - return nil, err - } - - return campaignTypes, nil -} - -func (_i *campaignTypesRepository) Create(campaignTypes *entity.CampaignTypes) (campaignTypesReturn *entity.CampaignTypes, err error) { - result := _i.DB.DB.Create(campaignTypes) - return campaignTypes, result.Error -} - -func (_i *campaignTypesRepository) Update(id uint, campaignTypes *entity.CampaignTypes) (err error) { - campaignTypesMap, err := utilSvc.StructToMap(campaignTypes) - if err != nil { - return err - } - query := _i.DB.DB.Model(&entity.CampaignTypes{}).Where(&entity.CampaignTypes{ID: id}) - return query.Updates(campaignTypesMap).Error -} - -func (_i *campaignTypesRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.CampaignTypes{}, id).Error -} diff --git a/app/module/campaign_types/request/campaign_types.request.go b/app/module/campaign_types/request/campaign_types.request.go deleted file mode 100644 index cdf5849..0000000 --- a/app/module/campaign_types/request/campaign_types.request.go +++ /dev/null @@ -1,54 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "time" -) - -type CampaignTypesQueryRequest struct { - Name *string `json:"name"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type CampaignTypesCreateRequest struct { - Name string `json:"name" validate:"required"` - Description *string `json:"description"` - CreatedById *uint `json:"createdById"` -} - -func (req CampaignTypesCreateRequest) ToEntity() *entity.CampaignTypes { - return &entity.CampaignTypes{ - Name: req.Name, - Description: req.Description, - CreatedAt: time.Now(), - UpdatedAt: time.Now(), - } -} - -type CampaignTypesUpdateRequest struct { - Name string `json:"name" validate:"required"` - Description *string `json:"description"` -} - -func (req CampaignTypesUpdateRequest) ToEntity() *entity.CampaignTypes { - return &entity.CampaignTypes{ - Name: req.Name, - Description: req.Description, - UpdatedAt: time.Now(), - } -} - -type CampaignTypesQueryRequestContext struct { - Name string `json:"name"` -} - -func (req CampaignTypesQueryRequestContext) ToParamRequest() CampaignTypesQueryRequest { - var request CampaignTypesQueryRequest - - if name := req.Name; name != "" { - request.Name = &name - } - - return request -} diff --git a/app/module/campaign_types/response/campaign_types.response.go b/app/module/campaign_types/response/campaign_types.response.go deleted file mode 100644 index 2addfca..0000000 --- a/app/module/campaign_types/response/campaign_types.response.go +++ /dev/null @@ -1,13 +0,0 @@ -package response - -import "time" - -type CampaignTypesResponse struct { - ID uint `json:"id"` - Name string `json:"name"` - Description *string `json:"description"` - IsActive *bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - diff --git a/app/module/campaign_types/service/campaign_types.service.go b/app/module/campaign_types/service/campaign_types.service.go deleted file mode 100644 index b5d030a..0000000 --- a/app/module/campaign_types/service/campaign_types.service.go +++ /dev/null @@ -1,95 +0,0 @@ -package service - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/campaign_types/mapper" - "jaecoo-be/app/module/campaign_types/repository" - "jaecoo-be/app/module/campaign_types/request" - "jaecoo-be/app/module/campaign_types/response" - usersRepository "jaecoo-be/app/module/users/repository" - config "jaecoo-be/config/config" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - - "github.com/rs/zerolog" -) - -// CampaignTypesService -type campaignTypesService struct { - Repo repository.CampaignTypesRepository - UsersRepo usersRepository.UsersRepository - Log zerolog.Logger - Cfg *config.Config -} - -// CampaignTypesService define interface of ICampaignTypesService -type CampaignTypesService interface { - All(req request.CampaignTypesQueryRequest, authToken string) (campaignTypes []*response.CampaignTypesResponse, paging paginator.Pagination, err error) - Show(id uint) (campaignTypes *response.CampaignTypesResponse, err error) - Save(req request.CampaignTypesCreateRequest, authToken string) (campaignTypes *entity.CampaignTypes, err error) - Update(id uint, req request.CampaignTypesUpdateRequest) (err error) - Delete(id uint) error -} - -// NewCampaignTypesService init CampaignTypesService -func NewCampaignTypesService(repo repository.CampaignTypesRepository, usersRepo usersRepository.UsersRepository, log zerolog.Logger, cfg *config.Config) CampaignTypesService { - return &campaignTypesService{ - Repo: repo, - UsersRepo: usersRepo, - Log: log, - Cfg: cfg, - } -} - -// All implement interface of CampaignTypesService -func (_i *campaignTypesService) All(req request.CampaignTypesQueryRequest, authToken string) (campaignTypess []*response.CampaignTypesResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req) - if err != nil { - return - } - - for _, result := range results { - campaignTypess = append(campaignTypess, mapper.CampaignTypesResponseMapper(result)) - } - - return -} - -func (_i *campaignTypesService) Show(id uint) (campaignTypes *response.CampaignTypesResponse, err error) { - result, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - return mapper.CampaignTypesResponseMapper(result), nil -} - -func (_i *campaignTypesService) Save(req request.CampaignTypesCreateRequest, authToken string) (campaignTypes *entity.CampaignTypes, err error) { - _i.Log.Info().Interface("data", req).Msg("") - newReq := req.ToEntity() - - if req.CreatedById != nil { - createdBy, err := _i.UsersRepo.FindOne(*req.CreatedById) - if err != nil { - return nil, err - } - newReq.CreatedAt = createdBy.CreatedAt - } else { - createdBy := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if createdBy != nil { - // User info available if needed - } - } - - return _i.Repo.Create(newReq) -} - -func (_i *campaignTypesService) Update(id uint, req request.CampaignTypesUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - - newReq := req.ToEntity() - return _i.Repo.Update(id, newReq) -} - -func (_i *campaignTypesService) Delete(id uint) error { - return _i.Repo.Delete(id) -} diff --git a/app/module/campaigns/campaigns.module.go b/app/module/campaigns/campaigns.module.go deleted file mode 100644 index 401a4d2..0000000 --- a/app/module/campaigns/campaigns.module.go +++ /dev/null @@ -1,54 +0,0 @@ -package campaigns - -import ( - "jaecoo-be/app/module/campaigns/controller" - "jaecoo-be/app/module/campaigns/repository" - "jaecoo-be/app/module/campaigns/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// CampaignsRouter struct of CampaignsRouter -type CampaignsRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// NewCampaignsModule register bulky of Campaigns module -var NewCampaignsModule = fx.Options( - // register repository of Campaigns module - fx.Provide(repository.NewCampaignsRepository), - - // register service of Campaigns module - fx.Provide(service.NewCampaignsService), - - // register controller of Campaigns module - fx.Provide(controller.NewController), - - // register router of Campaigns module - fx.Provide(NewCampaignsRouter), -) - -// NewCampaignsRouter init CampaignsRouter -func NewCampaignsRouter(fiber *fiber.App, controller *controller.Controller) *CampaignsRouter { - return &CampaignsRouter{ - App: fiber, - Controller: controller, - } -} - -// RegisterCampaignsRoutes register routes of Campaigns module -func (_i *CampaignsRouter) RegisterCampaignsRoutes() { - // define controllers - campaignsController := _i.Controller.Campaigns - - // define routes - _i.App.Route("/campaigns", func(router fiber.Router) { - router.Get("/", campaignsController.All) - router.Get("/:id", campaignsController.Show) - router.Post("/", campaignsController.Save) - router.Put("/:id", campaignsController.Update) - router.Delete("/:id", campaignsController.Delete) - }) -} diff --git a/app/module/campaigns/controller/campaigns.controller.go b/app/module/campaigns/controller/campaigns.controller.go deleted file mode 100644 index b4ae686..0000000 --- a/app/module/campaigns/controller/campaigns.controller.go +++ /dev/null @@ -1,202 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/campaigns/request" - "jaecoo-be/app/module/campaigns/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type campaignsController struct { - campaignsService service.CampaignsService - Log zerolog.Logger -} - -type CampaignsController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error -} - -func NewCampaignsController(campaignsService service.CampaignsService, log zerolog.Logger) CampaignsController { - return &campaignsController{ - campaignsService: campaignsService, - Log: log, - } -} - -// All Campaigns -// @Summary Get all Campaigns -// @Description API for getting all Campaigns -// @Tags Campaigns -// @Security Bearer -// @Param X-Client-Key header string true "Insert the X-Client-Key" -// @Param req query request.CampaignsQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaigns [get] -func (_i *campaignsController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.CampaignsQueryRequestContext{ - Title: c.Query("title"), - CampaignTypeID: c.Query("campaignTypeId"), - Status: c.Query("status"), - CreatorID: c.Query("creatorId"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - authToken := c.Get("Authorization") - campaignsData, paging, err := _i.campaignsService.All(req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Campaigns list successfully retrieved"}, - Data: campaignsData, - Meta: paging, - }) -} - -// Show Campaigns -// @Summary Get one Campaigns -// @Description API for getting one Campaigns -// @Tags Campaigns -// @Security Bearer -// @Param id path int true "Campaigns ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaigns/{id} [get] -func (_i *campaignsController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - campaignsData, err := _i.campaignsService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Campaigns successfully retrieved"}, - Data: campaignsData, - }) -} - -// Save Campaigns -// @Summary Create Campaigns -// @Description API for create Campaigns -// @Tags Campaigns -// @Security Bearer -// @Param X-Csrf-Token header string false "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.CampaignsCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaigns [post] -func (_i *campaignsController) Save(c *fiber.Ctx) error { - req := new(request.CampaignsCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authToken := c.Get("Authorization") - - dataResult, err := _i.campaignsService.Save(*req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Campaigns successfully created"}, - Data: dataResult, - }) -} - -// Update Campaigns -// @Summary Update Campaigns -// @Description API for update Campaigns -// @Tags Campaigns -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param payload body request.CampaignsUpdateRequest true "Required payload" -// @Param id path int true "Campaigns ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaigns/{id} [put] -func (_i *campaignsController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.CampaignsUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.campaignsService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Campaigns successfully updated"}, - }) -} - -// Delete Campaigns -// @Summary Delete Campaigns -// @Description API for delete Campaigns -// @Tags Campaigns -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Campaigns ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /campaigns/{id} [delete] -func (_i *campaignsController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.campaignsService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Campaigns successfully deleted"}, - }) -} diff --git a/app/module/campaigns/controller/controller.go b/app/module/campaigns/controller/controller.go deleted file mode 100644 index 3674872..0000000 --- a/app/module/campaigns/controller/controller.go +++ /dev/null @@ -1,17 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/campaigns/service" - - "github.com/rs/zerolog" -) - -type Controller struct { - Campaigns CampaignsController -} - -func NewController(CampaignsService service.CampaignsService, log zerolog.Logger) *Controller { - return &Controller{ - Campaigns: NewCampaignsController(CampaignsService, log), - } -} diff --git a/app/module/campaigns/mapper/campaigns.mapper.go b/app/module/campaigns/mapper/campaigns.mapper.go deleted file mode 100644 index 575e3a7..0000000 --- a/app/module/campaigns/mapper/campaigns.mapper.go +++ /dev/null @@ -1,45 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - res "jaecoo-be/app/module/campaigns/response" -) - -func CampaignsResponseMapper(campaignsReq *entity.Campaigns, host string) (campaignsRes *res.CampaignsResponse) { - if campaignsReq != nil { - campaignsRes = &res.CampaignsResponse{ - ID: campaignsReq.ID, - Title: campaignsReq.Title, - CampaignTypeID: campaignsReq.CampaignTypeID, - StartDate: campaignsReq.StartDate, - EndDate: campaignsReq.EndDate, - MediaTypeSelected: campaignsReq.MediaTypeSelected, - MediaItemSelected: campaignsReq.MediaItemSelected, - Purpose: campaignsReq.Purpose, - MediaPromote: campaignsReq.MediaPromote, - Description: campaignsReq.Description, - CreatorID: campaignsReq.CreatorID, - Status: campaignsReq.Status, - IsActive: campaignsReq.IsActive, - CreatedAt: campaignsReq.CreatedAt, - UpdatedAt: campaignsReq.UpdatedAt, - } - - if campaignsReq.CampaignType.ID > 0 { - campaignsRes.CampaignType = &res.CampaignTypeInfo{ - ID: campaignsReq.CampaignType.ID, - Name: campaignsReq.CampaignType.Name, - Description: campaignsReq.CampaignType.Description, - } - } - - if campaignsReq.Creator.ID > 0 { - campaignsRes.Creator = &res.CreatorInfo{ - ID: campaignsReq.Creator.ID, - Fullname: campaignsReq.Creator.Fullname, - Email: campaignsReq.Creator.Email, - } - } - } - return campaignsRes -} diff --git a/app/module/campaigns/repository/campaigns.repository.go b/app/module/campaigns/repository/campaigns.repository.go deleted file mode 100644 index a6dfb55..0000000 --- a/app/module/campaigns/repository/campaigns.repository.go +++ /dev/null @@ -1,108 +0,0 @@ -package repository - -import ( - "fmt" - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/campaigns/request" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "strings" - - "github.com/rs/zerolog" -) - -type campaignsRepository struct { - DB *database.Database - Log zerolog.Logger -} - -// CampaignsRepository define interface of ICampaignsRepository -type CampaignsRepository interface { - GetAll(req request.CampaignsQueryRequest) (campaignss []*entity.Campaigns, paging paginator.Pagination, err error) - FindOne(id uint) (campaigns *entity.Campaigns, err error) - Create(campaigns *entity.Campaigns) (campaignsReturn *entity.Campaigns, err error) - Update(id uint, campaigns *entity.Campaigns) (err error) - Delete(id uint) (err error) -} - -func NewCampaignsRepository(db *database.Database, log zerolog.Logger) CampaignsRepository { - return &campaignsRepository{ - DB: db, - Log: log, - } -} - -// implement interface of ICampaignsRepository -func (_i *campaignsRepository) GetAll(req request.CampaignsQueryRequest) (campaignss []*entity.Campaigns, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.Campaigns{}).Preload("CampaignType").Preload("Creator") - - if req.Title != nil && *req.Title != "" { - title := strings.ToLower(*req.Title) - query = query.Where("LOWER(title) LIKE ?", "%"+strings.ToLower(title)+"%") - } - if req.CampaignTypeID != nil { - query = query.Where("campaign_type_id = ?", req.CampaignTypeID) - } - if req.Status != nil && *req.Status != "" { - query = query.Where("status = ?", req.Status) - } - if req.CreatorID != nil { - query = query.Where("creator_id = ?", req.CreatorID) - } - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction)) - } else { - direction := "DESC" - sortBy := "created_at" - query.Order(fmt.Sprintf("%s %s", sortBy, direction)) - } - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&campaignss).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *campaignsRepository) FindOne(id uint) (campaigns *entity.Campaigns, err error) { - query := _i.DB.DB.Where("id = ?", id).Preload("CampaignType").Preload("Creator") - - if err := query.First(&campaigns).Error; err != nil { - return nil, err - } - - return campaigns, nil -} - -func (_i *campaignsRepository) Create(campaigns *entity.Campaigns) (campaignsReturn *entity.Campaigns, err error) { - result := _i.DB.DB.Create(campaigns) - return campaigns, result.Error -} - -func (_i *campaignsRepository) Update(id uint, campaigns *entity.Campaigns) (err error) { - campaignsMap, err := utilSvc.StructToMap(campaigns) - if err != nil { - return err - } - query := _i.DB.DB.Model(&entity.Campaigns{}).Where(&entity.Campaigns{ID: id}) - return query.Updates(campaignsMap).Error -} - -func (_i *campaignsRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.Campaigns{}, id).Error -} diff --git a/app/module/campaigns/request/campaigns.request.go b/app/module/campaigns/request/campaigns.request.go deleted file mode 100644 index b891f30..0000000 --- a/app/module/campaigns/request/campaigns.request.go +++ /dev/null @@ -1,138 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -type CampaignsQueryRequest struct { - Title *string `json:"title"` - CampaignTypeID *uint `json:"campaignTypeId"` - Status *string `json:"status"` - CreatorID *uint `json:"creatorId"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type CampaignsCreateRequest struct { - Title string `json:"title" validate:"required"` - CampaignTypeID uint `json:"campaignTypeId" validate:"required"` - StartDate *string `json:"startDate"` - EndDate *string `json:"endDate"` - MediaTypeSelected *string `json:"mediaTypeSelected"` - MediaItemSelected *string `json:"mediaItemSelected"` - Purpose *string `json:"purpose"` - MediaPromote *bool `json:"mediaPromote"` - Description *string `json:"description"` - CreatorID *uint `json:"creatorId"` - Status *string `json:"status"` -} - -func (req CampaignsCreateRequest) ToEntity() *entity.Campaigns { - campaign := &entity.Campaigns{ - Title: req.Title, - CampaignTypeID: req.CampaignTypeID, - MediaTypeSelected: req.MediaTypeSelected, - MediaItemSelected: req.MediaItemSelected, - Purpose: req.Purpose, - MediaPromote: req.MediaPromote, - Description: req.Description, - CreatedAt: time.Now(), - UpdatedAt: time.Now(), - } - - if req.StartDate != nil && *req.StartDate != "" { - if startDate, err := time.Parse("2006-01-02", *req.StartDate); err == nil { - campaign.StartDate = &startDate - } - } - if req.EndDate != nil && *req.EndDate != "" { - if endDate, err := time.Parse("2006-01-02", *req.EndDate); err == nil { - campaign.EndDate = &endDate - } - } - if req.Status != nil { - campaign.Status = *req.Status - } else { - campaign.Status = "draft" - } - - return campaign -} - -type CampaignsUpdateRequest struct { - Title string `json:"title" validate:"required"` - CampaignTypeID uint `json:"campaignTypeId" validate:"required"` - StartDate *string `json:"startDate"` - EndDate *string `json:"endDate"` - MediaTypeSelected *string `json:"mediaTypeSelected"` - MediaItemSelected *string `json:"mediaItemSelected"` - Purpose *string `json:"purpose"` - MediaPromote *bool `json:"mediaPromote"` - Description *string `json:"description"` - Status *string `json:"status"` -} - -func (req CampaignsUpdateRequest) ToEntity() *entity.Campaigns { - campaign := &entity.Campaigns{ - Title: req.Title, - CampaignTypeID: req.CampaignTypeID, - MediaTypeSelected: req.MediaTypeSelected, - MediaItemSelected: req.MediaItemSelected, - Purpose: req.Purpose, - MediaPromote: req.MediaPromote, - Description: req.Description, - UpdatedAt: time.Now(), - } - - if req.StartDate != nil && *req.StartDate != "" { - if startDate, err := time.Parse("2006-01-02", *req.StartDate); err == nil { - campaign.StartDate = &startDate - } - } - if req.EndDate != nil && *req.EndDate != "" { - if endDate, err := time.Parse("2006-01-02", *req.EndDate); err == nil { - campaign.EndDate = &endDate - } - } - if req.Status != nil { - campaign.Status = *req.Status - } - - return campaign -} - -type CampaignsQueryRequestContext struct { - Title string `json:"title"` - CampaignTypeID string `json:"campaignTypeId"` - Status string `json:"status"` - CreatorID string `json:"creatorId"` -} - -func (req CampaignsQueryRequestContext) ToParamRequest() CampaignsQueryRequest { - var request CampaignsQueryRequest - - if title := req.Title; title != "" { - request.Title = &title - } - if campaignTypeIDStr := req.CampaignTypeID; campaignTypeIDStr != "" { - campaignTypeID, err := strconv.ParseUint(campaignTypeIDStr, 10, 32) - if err == nil { - campaignTypeIDUint := uint(campaignTypeID) - request.CampaignTypeID = &campaignTypeIDUint - } - } - if status := req.Status; status != "" { - request.Status = &status - } - if creatorIDStr := req.CreatorID; creatorIDStr != "" { - creatorID, err := strconv.ParseUint(creatorIDStr, 10, 32) - if err == nil { - creatorIDUint := uint(creatorID) - request.CreatorID = &creatorIDUint - } - } - - return request -} diff --git a/app/module/campaigns/response/campaigns.response.go b/app/module/campaigns/response/campaigns.response.go deleted file mode 100644 index 026907a..0000000 --- a/app/module/campaigns/response/campaigns.response.go +++ /dev/null @@ -1,36 +0,0 @@ -package response - -import "time" - -type CampaignsResponse struct { - ID uint `json:"id"` - Title string `json:"title"` - CampaignTypeID uint `json:"campaignTypeId"` - CampaignType *CampaignTypeInfo `json:"campaignType,omitempty"` - StartDate *time.Time `json:"startDate"` - EndDate *time.Time `json:"endDate"` - MediaTypeSelected *string `json:"mediaTypeSelected"` - MediaItemSelected *string `json:"mediaItemSelected"` - Purpose *string `json:"purpose"` - MediaPromote *bool `json:"mediaPromote"` - Description *string `json:"description"` - CreatorID uint `json:"creatorId"` - Creator *CreatorInfo `json:"creator,omitempty"` - Status string `json:"status"` - IsActive *bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - -type CampaignTypeInfo struct { - ID uint `json:"id"` - Name string `json:"name"` - Description *string `json:"description"` -} - -type CreatorInfo struct { - ID uint `json:"id"` - Fullname string `json:"fullname"` - Email string `json:"email"` -} - diff --git a/app/module/campaigns/service/campaigns.service.go b/app/module/campaigns/service/campaigns.service.go deleted file mode 100644 index 104895d..0000000 --- a/app/module/campaigns/service/campaigns.service.go +++ /dev/null @@ -1,103 +0,0 @@ -package service - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/campaigns/mapper" - "jaecoo-be/app/module/campaigns/repository" - "jaecoo-be/app/module/campaigns/request" - "jaecoo-be/app/module/campaigns/response" - usersRepository "jaecoo-be/app/module/users/repository" - config "jaecoo-be/config/config" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - - "github.com/rs/zerolog" -) - -// CampaignsService -type campaignsService struct { - Repo repository.CampaignsRepository - UsersRepo usersRepository.UsersRepository - Log zerolog.Logger - Cfg *config.Config -} - -// CampaignsService define interface of ICampaignsService -type CampaignsService interface { - All(req request.CampaignsQueryRequest, authToken string) (campaigns []*response.CampaignsResponse, paging paginator.Pagination, err error) - Show(id uint) (campaigns *response.CampaignsResponse, err error) - Save(req request.CampaignsCreateRequest, authToken string) (campaigns *entity.Campaigns, err error) - Update(id uint, req request.CampaignsUpdateRequest) (err error) - Delete(id uint) error -} - -// NewCampaignsService init CampaignsService -func NewCampaignsService(repo repository.CampaignsRepository, usersRepo usersRepository.UsersRepository, log zerolog.Logger, cfg *config.Config) CampaignsService { - return &campaignsService{ - Repo: repo, - UsersRepo: usersRepo, - Log: log, - Cfg: cfg, - } -} - -// All implement interface of CampaignsService -func (_i *campaignsService) All(req request.CampaignsQueryRequest, authToken string) (campaignss []*response.CampaignsResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req) - if err != nil { - return - } - - host := _i.Cfg.App.Domain - for _, result := range results { - campaignss = append(campaignss, mapper.CampaignsResponseMapper(result, host)) - } - - return -} - -func (_i *campaignsService) Show(id uint) (campaigns *response.CampaignsResponse, err error) { - result, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - - host := _i.Cfg.App.Domain - return mapper.CampaignsResponseMapper(result, host), nil -} - -func (_i *campaignsService) Save(req request.CampaignsCreateRequest, authToken string) (campaigns *entity.Campaigns, err error) { - _i.Log.Info().Interface("data", req).Msg("") - newReq := req.ToEntity() - - if req.CreatorID != nil { - creator, err := _i.UsersRepo.FindOne(*req.CreatorID) - if err != nil { - return nil, err - } - newReq.CreatorID = creator.ID - } else { - creator := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if creator != nil { - newReq.CreatorID = creator.ID - } - } - - // Set default status if not provided - if newReq.Status == "" { - newReq.Status = "draft" - } - - return _i.Repo.Create(newReq) -} - -func (_i *campaignsService) Update(id uint, req request.CampaignsUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - - newReq := req.ToEntity() - return _i.Repo.Update(id, newReq) -} - -func (_i *campaignsService) Delete(id uint) error { - return _i.Repo.Delete(id) -} diff --git a/app/module/chat/chat.module.go b/app/module/chat/chat.module.go deleted file mode 100644 index 743fc5b..0000000 --- a/app/module/chat/chat.module.go +++ /dev/null @@ -1,100 +0,0 @@ -package chat - -import ( - "jaecoo-be/app/module/chat/controller" - "jaecoo-be/app/module/chat/repository" - "jaecoo-be/app/module/chat/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of ChatRouter -type ChatRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// register bulky of Chat module -var NewChatModule = fx.Options( - // register repository of Chat module - fx.Provide(repository.NewChatRepository), - fx.Provide(repository.NewChatScheduleRepository), - fx.Provide(repository.NewChatScheduleFileRepository), - - // register service of Chat module - fx.Provide(service.NewChatService), - fx.Provide(service.NewChatScheduleService), - fx.Provide(service.NewChatScheduleFileService), - - // register controller of Chat module - fx.Provide(controller.NewController), - fx.Provide(controller.NewChatScheduleController), - fx.Provide(controller.NewChatScheduleFileController), - - // register router of Chat module - fx.Provide(NewChatRouter), -) - -// init ChatRouter -func NewChatRouter(fiber *fiber.App, controller *controller.Controller) *ChatRouter { - return &ChatRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of Chat module -func (_i *ChatRouter) RegisterChatRoutes() { - // define controllers - chatController := _i.Controller.Chat - chatScheduleController := _i.Controller.ChatSchedule - chatScheduleFileController := _i.Controller.ChatScheduleFile - - // define routes - _i.App.Route("/chat", func(router fiber.Router) { - // Chat Session routes - router.Route("/sessions", func(sessionRouter fiber.Router) { - sessionRouter.Get("/", chatController.GetAllChatSessions) - sessionRouter.Get("/:id", chatController.GetChatSessionByID) - sessionRouter.Post("/", chatController.CreateChatSession) - sessionRouter.Put("/:id", chatController.UpdateChatSession) - sessionRouter.Delete("/:id", chatController.DeleteChatSession) - - // Chat Participant routes - sessionRouter.Post("/:chatSessionId/participants", chatController.AddParticipantToChat) - sessionRouter.Delete("/:chatSessionId/participants", chatController.RemoveParticipantFromChat) - }) - - // Chat Message routes - router.Route("/messages", func(messageRouter fiber.Router) { - messageRouter.Get("/", chatController.GetAllChatMessages) - messageRouter.Get("/:id", chatController.GetChatMessageByID) - messageRouter.Post("/", chatController.CreateChatMessage) - messageRouter.Put("/:id", chatController.UpdateChatMessage) - messageRouter.Delete("/:id", chatController.DeleteChatMessage) - }) - - // Chat Schedule routes - router.Route("/schedules", func(scheduleRouter fiber.Router) { - scheduleRouter.Get("/", chatScheduleController.GetAllChatSchedules) - scheduleRouter.Get("/upcoming", chatScheduleController.GetUpcomingSchedules) - scheduleRouter.Get("/status/:status", chatScheduleController.GetSchedulesByStatus) - scheduleRouter.Get("/:id", chatScheduleController.GetChatScheduleByID) - scheduleRouter.Post("/", chatScheduleController.CreateChatSchedule) - scheduleRouter.Put("/:id", chatScheduleController.UpdateChatSchedule) - scheduleRouter.Delete("/:id", chatScheduleController.DeleteChatSchedule) - scheduleRouter.Post("/:id/reminder", chatScheduleController.SendScheduleReminder) - }) - - // Chat Schedule File routes - router.Route("/schedule-files", func(fileRouter fiber.Router) { - fileRouter.Get("/", chatScheduleFileController.GetChatScheduleFiles) - fileRouter.Get("/:id", chatScheduleFileController.GetChatScheduleFileByID) - fileRouter.Post("/:chatScheduleId", chatScheduleFileController.UploadChatScheduleFile) - fileRouter.Put("/:id", chatScheduleFileController.UpdateChatScheduleFile) - fileRouter.Delete("/:id", chatScheduleFileController.DeleteChatScheduleFile) - fileRouter.Get("/viewer/:filename", chatScheduleFileController.Viewer) - }) - }) -} diff --git a/app/module/chat/controller/chat.controller.go b/app/module/chat/controller/chat.controller.go deleted file mode 100644 index 7716452..0000000 --- a/app/module/chat/controller/chat.controller.go +++ /dev/null @@ -1,474 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/chat/request" - "jaecoo-be/app/module/chat/service" - "jaecoo-be/utils/paginator" - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" - "strconv" - - "github.com/gofiber/fiber/v2" -) - -type chatController struct { - chatService service.ChatService -} - -type ChatController interface { - // Chat Session endpoints - GetAllChatSessions(c *fiber.Ctx) error - GetChatSessionByID(c *fiber.Ctx) error - CreateChatSession(c *fiber.Ctx) error - UpdateChatSession(c *fiber.Ctx) error - DeleteChatSession(c *fiber.Ctx) error - - // Chat Message endpoints - GetAllChatMessages(c *fiber.Ctx) error - GetChatMessageByID(c *fiber.Ctx) error - CreateChatMessage(c *fiber.Ctx) error - UpdateChatMessage(c *fiber.Ctx) error - DeleteChatMessage(c *fiber.Ctx) error - - // Chat Participant endpoints - AddParticipantToChat(c *fiber.Ctx) error - RemoveParticipantFromChat(c *fiber.Ctx) error -} - -func NewChatController(chatService service.ChatService) ChatController { - return &chatController{ - chatService: chatService, - } -} - -// GetAllChatSessions - Get all chat sessions for a user -// @Summary Get all chat sessions -// @Description API for getting all chat sessions for authenticated user -// @Tags Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param type query string false "Chat type (personal or group)" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/sessions [get] -func (_i *chatController) GetAllChatSessions(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - reqContext := request.ChatSessionQueryRequestContext{ - Type: c.Query("type"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - chatSessions, paging, err := _i.chatService.GetAllChatSessions(authToken, req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat sessions successfully retrieved"}, - Data: chatSessions, - Meta: paging, - }) -} - -// GetChatSessionByID - Get one chat session -// @Summary Get one chat session -// @Description API for getting one chat session -// @Tags Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Session ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/sessions/{id} [get] -func (_i *chatController) GetChatSessionByID(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - chatSession, err := _i.chatService.GetChatSessionByID(authToken, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat session successfully retrieved"}, - Data: chatSession, - }) -} - -// CreateChatSession - Create chat session -// @Summary Create chat session -// @Description API for creating a new chat session (personal or group) -// @Tags Chat -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.ChatSessionCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/sessions [post] -func (_i *chatController) CreateChatSession(c *fiber.Ctx) error { - authToken := c.Get("Authorization") - - req := new(request.ChatSessionCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - dataResult, err := _i.chatService.CreateChatSession(authToken, *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat session successfully created"}, - Data: dataResult, - }) -} - -// UpdateChatSession - Update chat session -// @Summary Update chat session -// @Description API for updating chat session (only creator can update) -// @Tags Chat -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Session ID" -// @Param payload body request.ChatSessionUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/sessions/{id} [put] -func (_i *chatController) UpdateChatSession(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - req := new(request.ChatSessionUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.chatService.UpdateChatSession(authToken, uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat session successfully updated"}, - }) -} - -// DeleteChatSession - Delete chat session -// @Summary Delete chat session -// @Description API for deleting chat session (only creator can delete) -// @Tags Chat -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Session ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/sessions/{id} [delete] -func (_i *chatController) DeleteChatSession(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - err = _i.chatService.DeleteChatSession(authToken, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat session successfully deleted"}, - }) -} - -// GetAllChatMessages - Get all messages in a chat session -// @Summary Get all chat messages -// @Description API for getting all messages in a specific chat session -// @Tags Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param chatSessionId query uint true "Chat Session ID" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/messages [get] -func (_i *chatController) GetAllChatMessages(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - reqContext := request.ChatMessageQueryRequestContext{ - ChatSessionID: c.Query("chatSessionId"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - chatMessages, paging, err := _i.chatService.GetAllChatMessages(authToken, req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat messages successfully retrieved"}, - Data: chatMessages, - Meta: paging, - }) -} - -// GetChatMessageByID - Get one chat message -// @Summary Get one chat message -// @Description API for getting one chat message -// @Tags Chat -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Message ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/messages/{id} [get] -func (_i *chatController) GetChatMessageByID(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - chatMessage, err := _i.chatService.GetChatMessageByID(authToken, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat message successfully retrieved"}, - Data: chatMessage, - }) -} - -// CreateChatMessage - Create chat message -// @Summary Create chat message -// @Description API for creating a new chat message -// @Tags Chat -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.ChatMessageCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/messages [post] -func (_i *chatController) CreateChatMessage(c *fiber.Ctx) error { - authToken := c.Get("Authorization") - - req := new(request.ChatMessageCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - dataResult, err := _i.chatService.CreateChatMessage(authToken, *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat message successfully created"}, - Data: dataResult, - }) -} - -// UpdateChatMessage - Update chat message -// @Summary Update chat message -// @Description API for updating chat message (only sender can update) -// @Tags Chat -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Message ID" -// @Param payload body request.ChatMessageUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/messages/{id} [put] -func (_i *chatController) UpdateChatMessage(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - req := new(request.ChatMessageUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.chatService.UpdateChatMessage(authToken, uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat message successfully updated"}, - }) -} - -// DeleteChatMessage - Delete chat message -// @Summary Delete chat message -// @Description API for deleting chat message (only sender can delete) -// @Tags Chat -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Message ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/messages/{id} [delete] -func (_i *chatController) DeleteChatMessage(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - err = _i.chatService.DeleteChatMessage(authToken, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat message successfully deleted"}, - }) -} - -// AddParticipantToChat - Add participant to chat session -// @Summary Add participant to chat session -// @Description API for adding a participant to a chat session (only creator can add) -// @Tags Chat -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param chatSessionId path int true "Chat Session ID" -// @Param participantUserId query uint true "Participant User ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/sessions/{chatSessionId}/participants [post] -func (_i *chatController) AddParticipantToChat(c *fiber.Ctx) error { - chatSessionId, err := strconv.ParseUint(c.Params("chatSessionId"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - participantUserId, err := strconv.ParseUint(c.Query("participantUserId"), 10, 0) - if err != nil { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"participantUserId parameter is required and must be a valid number"}, - }) - } - - err = _i.chatService.AddParticipantToChat(authToken, uint(chatSessionId), uint(participantUserId)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Participant successfully added to chat session"}, - }) -} - -// RemoveParticipantFromChat - Remove participant from chat session -// @Summary Remove participant from chat session -// @Description API for removing a participant from a chat session (creator can remove anyone, user can remove themselves) -// @Tags Chat -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param chatSessionId path int true "Chat Session ID" -// @Param participantUserId query uint true "Participant User ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/sessions/{chatSessionId}/participants [delete] -func (_i *chatController) RemoveParticipantFromChat(c *fiber.Ctx) error { - chatSessionId, err := strconv.ParseUint(c.Params("chatSessionId"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - participantUserId, err := strconv.ParseUint(c.Query("participantUserId"), 10, 0) - if err != nil { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"participantUserId parameter is required and must be a valid number"}, - }) - } - - err = _i.chatService.RemoveParticipantFromChat(authToken, uint(chatSessionId), uint(participantUserId)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Participant successfully removed from chat session"}, - }) -} diff --git a/app/module/chat/controller/chat_schedule.controller.go b/app/module/chat/controller/chat_schedule.controller.go deleted file mode 100644 index a30215b..0000000 --- a/app/module/chat/controller/chat_schedule.controller.go +++ /dev/null @@ -1,320 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/chat/request" - "jaecoo-be/app/module/chat/service" - "jaecoo-be/utils/paginator" - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" - "strconv" - - "github.com/gofiber/fiber/v2" -) - -type chatScheduleController struct { - chatScheduleService service.ChatScheduleService -} - -type ChatScheduleController interface { - // Chat Schedule endpoints - GetAllChatSchedules(c *fiber.Ctx) error - GetChatScheduleByID(c *fiber.Ctx) error - CreateChatSchedule(c *fiber.Ctx) error - UpdateChatSchedule(c *fiber.Ctx) error - DeleteChatSchedule(c *fiber.Ctx) error - - // Additional schedule endpoints - GetUpcomingSchedules(c *fiber.Ctx) error - GetSchedulesByStatus(c *fiber.Ctx) error - SendScheduleReminder(c *fiber.Ctx) error -} - -func NewChatScheduleController(chatScheduleService service.ChatScheduleService) ChatScheduleController { - return &chatScheduleController{ - chatScheduleService: chatScheduleService, - } -} - -// GetAllChatSchedules - Get all chat schedules for a user -// @Summary Get all chat schedules -// @Description API for getting all chat schedules for authenticated user -// @Tags Chat Schedule -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param chatSessionId query string false "Chat Session ID" -// @Param status query string false "Schedule status (scheduled, ongoing, completed, cancelled)" -// @Param createdBy query string false "Created by user ID" -// @Param dateFrom query string false "Date from (YYYY-MM-DD)" -// @Param dateTo query string false "Date to (YYYY-MM-DD)" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedules [get] -func (_i *chatScheduleController) GetAllChatSchedules(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - reqContext := request.ChatScheduleQueryRequestContext{ - ChatSessionID: c.Query("chatSessionId"), - Status: c.Query("status"), - CreatedBy: c.Query("createdBy"), - DateFrom: c.Query("dateFrom"), - DateTo: c.Query("dateTo"), - } - req := reqContext.ToParamRequest() - req.Pagination = *paginate - - chatSchedules, paging, err := _i.chatScheduleService.GetAllChatSchedules(authToken, req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat schedules successfully retrieved"}, - Data: chatSchedules, - Meta: paging, - }) -} - -// GetChatScheduleByID - Get one chat schedule -// @Summary Get one chat schedule -// @Description API for getting one chat schedule -// @Tags Chat Schedule -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Schedule ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedules/{id} [get] -func (_i *chatScheduleController) GetChatScheduleByID(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - chatSchedule, err := _i.chatScheduleService.GetChatScheduleByID(authToken, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat schedule successfully retrieved"}, - Data: chatSchedule, - }) -} - -// CreateChatSchedule - Create chat schedule -// @Summary Create chat schedule -// @Description API for creating a new chat schedule -// @Tags Chat Schedule -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.ChatScheduleCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedules [post] -func (_i *chatScheduleController) CreateChatSchedule(c *fiber.Ctx) error { - authToken := c.Get("Authorization") - - req := new(request.ChatScheduleCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - dataResult, err := _i.chatScheduleService.CreateChatSchedule(authToken, *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat schedule successfully created"}, - Data: dataResult, - }) -} - -// UpdateChatSchedule - Update chat schedule -// @Summary Update chat schedule -// @Description API for updating chat schedule (only creator can update) -// @Tags Chat Schedule -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Schedule ID" -// @Param payload body request.ChatScheduleUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedules/{id} [put] -func (_i *chatScheduleController) UpdateChatSchedule(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - req := new(request.ChatScheduleUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.chatScheduleService.UpdateChatSchedule(authToken, uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat schedule successfully updated"}, - }) -} - -// DeleteChatSchedule - Delete chat schedule -// @Summary Delete chat schedule -// @Description API for deleting chat schedule (only creator can delete) -// @Tags Chat Schedule -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Schedule ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedules/{id} [delete] -func (_i *chatScheduleController) DeleteChatSchedule(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - err = _i.chatScheduleService.DeleteChatSchedule(authToken, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat schedule successfully deleted"}, - }) -} - -// GetUpcomingSchedules - Get upcoming schedules for a user -// @Summary Get upcoming schedules -// @Description API for getting upcoming chat schedules for authenticated user -// @Tags Chat Schedule -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param limit query int false "Limit number of results" default(10) -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedules/upcoming [get] -func (_i *chatScheduleController) GetUpcomingSchedules(c *fiber.Ctx) error { - authToken := c.Get("Authorization") - - limit := 10 // default limit - if limitStr := c.Query("limit"); limitStr != "" { - if parsedLimit, err := strconv.Atoi(limitStr); err == nil && parsedLimit > 0 { - limit = parsedLimit - } - } - - chatSchedules, err := _i.chatScheduleService.GetUpcomingSchedules(authToken, limit) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Upcoming chat schedules successfully retrieved"}, - Data: chatSchedules, - }) -} - -// GetSchedulesByStatus - Get schedules by status -// @Summary Get schedules by status -// @Description API for getting chat schedules by status -// @Tags Chat Schedule -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param status path string true "Schedule status (scheduled, ongoing, completed, cancelled)" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedules/status/{status} [get] -func (_i *chatScheduleController) GetSchedulesByStatus(c *fiber.Ctx) error { - status := c.Params("status") - if status == "" { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"Status parameter is required"}, - }) - } - - authToken := c.Get("Authorization") - - chatSchedules, err := _i.chatScheduleService.GetSchedulesByStatus(authToken, status) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat schedules by status successfully retrieved"}, - Data: chatSchedules, - }) -} - -// SendScheduleReminder - Send reminder for a schedule -// @Summary Send schedule reminder -// @Description API for sending reminder for a chat schedule (only creator can send) -// @Tags Chat Schedule -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Schedule ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedules/{id}/reminder [post] -func (_i *chatScheduleController) SendScheduleReminder(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - err = _i.chatScheduleService.SendScheduleReminder(authToken, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Schedule reminder successfully sent"}, - }) -} diff --git a/app/module/chat/controller/chat_schedule_file.controller.go b/app/module/chat/controller/chat_schedule_file.controller.go deleted file mode 100644 index 6b6f1f4..0000000 --- a/app/module/chat/controller/chat_schedule_file.controller.go +++ /dev/null @@ -1,233 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/chat/request" - "jaecoo-be/app/module/chat/service" - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" - "strconv" - - "github.com/gofiber/fiber/v2" -) - -type chatScheduleFileController struct { - chatScheduleFileService service.ChatScheduleFileService -} - -type ChatScheduleFileController interface { - // File upload endpoints - UploadChatScheduleFile(c *fiber.Ctx) error - GetChatScheduleFiles(c *fiber.Ctx) error - GetChatScheduleFileByID(c *fiber.Ctx) error - UpdateChatScheduleFile(c *fiber.Ctx) error - DeleteChatScheduleFile(c *fiber.Ctx) error - Viewer(c *fiber.Ctx) error -} - -func NewChatScheduleFileController(chatScheduleFileService service.ChatScheduleFileService) ChatScheduleFileController { - return &chatScheduleFileController{ - chatScheduleFileService: chatScheduleFileService, - } -} - -// UploadChatScheduleFile - Upload file for chat schedule -// @Summary Upload chat schedule file -// @Description API for uploading file for chat schedule -// @Tags Chat Schedule File -// @Security Bearer -// @Produce json -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param files formData file true "Upload file" multiple true -// @Param chatScheduleId path int true "Chat Schedule ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedule-files/{chatScheduleId} [post] -func (_i *chatScheduleFileController) UploadChatScheduleFile(c *fiber.Ctx) error { - // Get chat schedule ID from path - id, err := strconv.ParseUint(c.Params("chatScheduleId"), 10, 0) - if err != nil { - return err - } - - err = _i.chatScheduleFileService.UploadChatScheduleFile(c, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat schedule files successfully uploaded"}, - }) -} - -// GetChatScheduleFiles - Get files for a chat schedule -// @Summary Get chat schedule files -// @Description API for getting files for a specific chat schedule -// @Tags Chat Schedule File -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param chatScheduleId query uint true "Chat Schedule ID" -// @Param fileType query string false "File type filter" -// @Param isRequired query bool false "Required file filter" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedule-files [get] -func (_i *chatScheduleFileController) GetChatScheduleFiles(c *fiber.Ctx) error { - authToken := c.Get("Authorization") - - req := request.ChatScheduleFileQueryRequest{} - - // Parse chat schedule ID - if chatScheduleIdStr := c.Query("chatScheduleId"); chatScheduleIdStr != "" { - if chatScheduleId, err := strconv.ParseUint(chatScheduleIdStr, 10, 0); err == nil { - chatScheduleIdUint := uint(chatScheduleId) - req.ChatScheduleID = &chatScheduleIdUint - } - } - - // Parse file type - if fileType := c.Query("fileType"); fileType != "" { - req.FileType = &fileType - } - - // Parse is required - if isRequiredStr := c.Query("isRequired"); isRequiredStr != "" { - if isRequired, err := strconv.ParseBool(isRequiredStr); err == nil { - req.IsRequired = &isRequired - } - } - - files, err := _i.chatScheduleFileService.GetChatScheduleFiles(authToken, req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat schedule files successfully retrieved"}, - Data: files, - }) -} - -// GetChatScheduleFileByID - Get one chat schedule file -// @Summary Get one chat schedule file -// @Description API for getting one chat schedule file -// @Tags Chat Schedule File -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Schedule File ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedule-files/{id} [get] -func (_i *chatScheduleFileController) GetChatScheduleFileByID(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - file, err := _i.chatScheduleFileService.GetChatScheduleFileByID(authToken, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat schedule file successfully retrieved"}, - Data: file, - }) -} - -// UpdateChatScheduleFile - Update chat schedule file -// @Summary Update chat schedule file -// @Description API for updating chat schedule file -// @Tags Chat Schedule File -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Schedule File ID" -// @Param payload body request.ChatScheduleFileUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedule-files/{id} [put] -func (_i *chatScheduleFileController) UpdateChatScheduleFile(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - req := new(request.ChatScheduleFileUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.chatScheduleFileService.UpdateChatScheduleFile(authToken, uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat schedule file successfully updated"}, - }) -} - -// DeleteChatScheduleFile - Delete chat schedule file -// @Summary Delete chat schedule file -// @Description API for deleting chat schedule file -// @Tags Chat Schedule File -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Chat Schedule File ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedule-files/{id} [delete] -func (_i *chatScheduleFileController) DeleteChatScheduleFile(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - err = _i.chatScheduleFileService.DeleteChatScheduleFile(authToken, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Chat schedule file successfully deleted"}, - }) -} - -// Viewer - View chat schedule file -// @Summary View chat schedule file -// @Description API for viewing chat schedule file -// @Tags Chat Schedule File -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param filename path string true "Chat Schedule File Name" -// @Success 200 {file} file -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /chat/schedule-files/viewer/{filename} [get] -func (_i *chatScheduleFileController) Viewer(c *fiber.Ctx) error { - return _i.chatScheduleFileService.Viewer(c) -} diff --git a/app/module/chat/controller/controller.go b/app/module/chat/controller/controller.go deleted file mode 100644 index 33343ff..0000000 --- a/app/module/chat/controller/controller.go +++ /dev/null @@ -1,17 +0,0 @@ -package controller - -import "jaecoo-be/app/module/chat/service" - -type Controller struct { - Chat ChatController - ChatSchedule ChatScheduleController - ChatScheduleFile ChatScheduleFileController -} - -func NewController(ChatService service.ChatService, ChatScheduleService service.ChatScheduleService, ChatScheduleFileService service.ChatScheduleFileService) *Controller { - return &Controller{ - Chat: NewChatController(ChatService), - ChatSchedule: NewChatScheduleController(ChatScheduleService), - ChatScheduleFile: NewChatScheduleFileController(ChatScheduleFileService), - } -} diff --git a/app/module/chat/mapper/chat.mapper.go b/app/module/chat/mapper/chat.mapper.go deleted file mode 100644 index f0f8477..0000000 --- a/app/module/chat/mapper/chat.mapper.go +++ /dev/null @@ -1,105 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/chat/response" -) - -// Chat Session Mapper -func ChatSessionResponseMapper(chatSession *entity.ChatSessions) *response.ChatSessionResponse { - result := &response.ChatSessionResponse{ - ID: chatSession.ID, - Name: chatSession.Name, - Type: chatSession.Type, - CreatedBy: chatSession.CreatedBy, - CreatedAt: chatSession.CreatedAt, - UpdatedAt: chatSession.UpdatedAt, - } - - if chatSession.Creator != nil { - result.Creator = &response.UserBasicInfo{ - ID: chatSession.Creator.ID, - Username: chatSession.Creator.Username, - Fullname: chatSession.Creator.Fullname, - Email: chatSession.Creator.Email, - } - } - - // Map participants - if len(chatSession.Participants) > 0 { - for _, participant := range chatSession.Participants { - if participant.IsActive { - result.Participants = append(result.Participants, ChatParticipantResponseMapper(participant)) - } - } - } - - // Map last message - if len(chatSession.Messages) > 0 { - // Find the latest message that is not deleted - var lastMessage *entity.ChatMessages - for _, message := range chatSession.Messages { - if !message.IsDeleted && (lastMessage == nil || message.CreatedAt.After(lastMessage.CreatedAt)) { - lastMessage = message - } - } - if lastMessage != nil { - result.LastMessage = ChatMessageResponseMapper(lastMessage) - } - } - - return result -} - -// Chat Message Mapper -func ChatMessageResponseMapper(chatMessage *entity.ChatMessages) *response.ChatMessageResponse { - result := &response.ChatMessageResponse{ - ID: chatMessage.ID, - ChatSessionID: chatMessage.ChatSessionID, - SenderID: chatMessage.SenderID, - Message: chatMessage.Message, - MessageType: chatMessage.MessageType, - IsEdited: chatMessage.IsEdited, - EditedAt: chatMessage.EditedAt, - IsDeleted: chatMessage.IsDeleted, - DeletedAt: chatMessage.DeletedAt, - CreatedAt: chatMessage.CreatedAt, - UpdatedAt: chatMessage.UpdatedAt, - } - - if chatMessage.Sender != nil { - result.Sender = &response.UserBasicInfo{ - ID: chatMessage.Sender.ID, - Username: chatMessage.Sender.Username, - Fullname: chatMessage.Sender.Fullname, - Email: chatMessage.Sender.Email, - } - } - - return result -} - -// Chat Participant Mapper -func ChatParticipantResponseMapper(chatParticipant *entity.ChatParticipants) *response.ChatParticipantResponse { - result := &response.ChatParticipantResponse{ - ID: chatParticipant.ID, - ChatSessionID: chatParticipant.ChatSessionID, - UserID: chatParticipant.UserID, - JoinedAt: chatParticipant.JoinedAt, - LeftAt: chatParticipant.LeftAt, - IsActive: chatParticipant.IsActive, - CreatedAt: chatParticipant.CreatedAt, - UpdatedAt: chatParticipant.UpdatedAt, - } - - if chatParticipant.User != nil { - result.User = &response.UserBasicInfo{ - ID: chatParticipant.User.ID, - Username: chatParticipant.User.Username, - Fullname: chatParticipant.User.Fullname, - Email: chatParticipant.User.Email, - } - } - - return result -} diff --git a/app/module/chat/mapper/chat_schedule.mapper.go b/app/module/chat/mapper/chat_schedule.mapper.go deleted file mode 100644 index 9845fea..0000000 --- a/app/module/chat/mapper/chat_schedule.mapper.go +++ /dev/null @@ -1,177 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/chat/request" - "jaecoo-be/app/module/chat/response" -) - -// ChatScheduleResponse - Response structure for chat schedule -type ChatScheduleResponse struct { - ID uint `json:"id"` - ChatSessionID uint `json:"chat_session_id"` - Title string `json:"title"` - Description string `json:"description"` - Summary string `json:"summary"` - ScheduledAt string `json:"scheduled_at"` - Duration int `json:"duration"` - Status string `json:"status"` - IsReminderSent bool `json:"is_reminder_sent"` - ReminderSentAt *string `json:"reminder_sent_at"` - CreatedBy uint `json:"created_by"` - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` - ChatSession *response.ChatSessionResponse `json:"chat_session,omitempty"` - Creator *response.UserBasicInfo `json:"creator,omitempty"` - Files []*response.ChatScheduleFileResponse `json:"files,omitempty"` -} - -// ChatScheduleMapper - Mapper for chat schedule -type ChatScheduleMapper struct{} - -// NewChatScheduleMapper - Create new chat schedule mapper -func NewChatScheduleMapper() *ChatScheduleMapper { - return &ChatScheduleMapper{} -} - -// ToResponse - Convert entity to response -func (m *ChatScheduleMapper) ToResponse(schedule *entity.ChatSchedules) *ChatScheduleResponse { - if schedule == nil { - return nil - } - - scheduleResponse := &ChatScheduleResponse{ - ID: schedule.ID, - ChatSessionID: schedule.ChatSessionID, - Title: schedule.Title, - Description: schedule.Description, - Summary: schedule.Summary, - ScheduledAt: schedule.ScheduledAt.Format("2006-01-02T15:04:05Z07:00"), - Duration: schedule.Duration, - Status: schedule.Status, - IsReminderSent: schedule.IsReminderSent, - CreatedBy: schedule.CreatedBy, - CreatedAt: schedule.CreatedAt.Format("2006-01-02T15:04:05Z07:00"), - UpdatedAt: schedule.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"), - } - - if schedule.ReminderSentAt != nil { - reminderSentAt := schedule.ReminderSentAt.Format("2006-01-02T15:04:05Z07:00") - scheduleResponse.ReminderSentAt = &reminderSentAt - } - - // Map chat session - if schedule.ChatSession != nil { - scheduleResponse.ChatSession = ChatSessionResponseMapper(schedule.ChatSession) - } - - // Map creator - if schedule.Creator != nil { - scheduleResponse.Creator = &response.UserBasicInfo{ - ID: schedule.Creator.ID, - Username: schedule.Creator.Username, - Fullname: schedule.Creator.Fullname, - Email: schedule.Creator.Email, - } - } - - // Map files - if len(schedule.Files) > 0 { - scheduleResponse.Files = make([]*response.ChatScheduleFileResponse, len(schedule.Files)) - for i, file := range schedule.Files { - scheduleResponse.Files[i] = m.ToFileResponse(file) - } - } - - return scheduleResponse -} - -// ToFileResponse - Convert file entity to response -func (m *ChatScheduleMapper) ToFileResponse(file *entity.ChatScheduleFiles) *response.ChatScheduleFileResponse { - if file == nil { - return nil - } - - return &response.ChatScheduleFileResponse{ - ID: file.ID, - ChatScheduleID: file.ChatScheduleID, - FileName: file.FileName, - OriginalName: file.OriginalName, - FilePath: file.FilePath, - FileSize: file.FileSize, - MimeType: file.MimeType, - FileType: file.FileType, - Description: file.Description, - IsRequired: file.IsRequired, - CreatedAt: file.CreatedAt.Format("2006-01-02T15:04:05Z07:00"), - UpdatedAt: file.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"), - } -} - -// ToEntity - Convert request to entity -func (m *ChatScheduleMapper) ToEntity(req request.ChatScheduleCreateRequest) *entity.ChatSchedules { - schedule := &entity.ChatSchedules{ - Title: req.Title, - Description: req.Description, - Summary: req.Summary, - ScheduledAt: req.ScheduledAt, - Duration: req.Duration, - Status: "scheduled", - } - - // Handle ChatSessionID pointer - if req.ChatSessionID != nil { - schedule.ChatSessionID = *req.ChatSessionID - } - - // Files will be attached separately using file IDs - - return schedule -} - -// ToUpdateEntity - Convert update request to entity -func (m *ChatScheduleMapper) ToUpdateEntity(req request.ChatScheduleUpdateRequest) *entity.ChatSchedules { - schedule := &entity.ChatSchedules{} - - if req.Title != "" { - schedule.Title = req.Title - } - - if req.Description != "" { - schedule.Description = req.Description - } - - if req.Summary != "" { - schedule.Summary = req.Summary - } - - if !req.ScheduledAt.IsZero() { - schedule.ScheduledAt = req.ScheduledAt - } - - if req.Duration > 0 { - schedule.Duration = req.Duration - } - - if req.Status != "" { - schedule.Status = req.Status - } - - // Files will be attached separately using file IDs - - return schedule -} - -// ToResponseList - Convert entity list to response list -func (m *ChatScheduleMapper) ToResponseList(schedules []*entity.ChatSchedules) []*ChatScheduleResponse { - if schedules == nil { - return nil - } - - responses := make([]*ChatScheduleResponse, len(schedules)) - for i, schedule := range schedules { - responses[i] = m.ToResponse(schedule) - } - - return responses -} diff --git a/app/module/chat/mapper/chat_schedule_file.mapper.go b/app/module/chat/mapper/chat_schedule_file.mapper.go deleted file mode 100644 index dbfc77f..0000000 --- a/app/module/chat/mapper/chat_schedule_file.mapper.go +++ /dev/null @@ -1,100 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/chat/request" - "jaecoo-be/app/module/chat/response" -) - -// ChatScheduleFileMapper - Mapper for chat schedule file -type ChatScheduleFileMapper struct{} - -// NewChatScheduleFileMapper - Create new chat schedule file mapper -func NewChatScheduleFileMapper() *ChatScheduleFileMapper { - return &ChatScheduleFileMapper{} -} - -// ToResponse - Convert entity to response -func (m *ChatScheduleFileMapper) ToResponse(file *entity.ChatScheduleFiles) *response.ChatScheduleFileResponse { - if file == nil { - return nil - } - - return &response.ChatScheduleFileResponse{ - ID: file.ID, - ChatScheduleID: file.ChatScheduleID, - FileName: file.FileName, - OriginalName: file.OriginalName, - FilePath: file.FilePath, - FileSize: file.FileSize, - MimeType: file.MimeType, - FileType: file.FileType, - Description: file.Description, - IsRequired: file.IsRequired, - CreatedAt: file.CreatedAt.Format("2006-01-02T15:04:05Z07:00"), - UpdatedAt: file.UpdatedAt.Format("2006-01-02T15:04:05Z07:00"), - } -} - -// ToEntity - Convert upload request to entity -func (m *ChatScheduleFileMapper) ToEntity(req request.ChatScheduleFileUploadRequest) *entity.ChatScheduleFiles { - return &entity.ChatScheduleFiles{ - ChatScheduleID: req.ChatScheduleID, - FileType: req.FileType, - Description: req.Description, - IsRequired: req.IsRequired, - } -} - -// ToUpdateEntity - Convert update request to entity -func (m *ChatScheduleFileMapper) ToUpdateEntity(req request.ChatScheduleFileUpdateRequest) *entity.ChatScheduleFiles { - file := &entity.ChatScheduleFiles{} - - if req.FileName != "" { - file.FileName = req.FileName - } - - if req.OriginalName != "" { - file.OriginalName = req.OriginalName - } - - if req.FilePath != "" { - file.FilePath = req.FilePath - } - - if req.FileSize > 0 { - file.FileSize = req.FileSize - } - - if req.MimeType != "" { - file.MimeType = req.MimeType - } - - if req.FileType != "" { - file.FileType = req.FileType - } - - if req.Description != "" { - file.Description = req.Description - } - - if req.IsRequired != nil { - file.IsRequired = *req.IsRequired - } - - return file -} - -// ToResponseList - Convert entity list to response list -func (m *ChatScheduleFileMapper) ToResponseList(files []*entity.ChatScheduleFiles) []*response.ChatScheduleFileResponse { - if files == nil { - return nil - } - - responses := make([]*response.ChatScheduleFileResponse, len(files)) - for i, file := range files { - responses[i] = m.ToResponse(file) - } - - return responses -} diff --git a/app/module/chat/repository/chat.repository.go b/app/module/chat/repository/chat.repository.go deleted file mode 100644 index 362353b..0000000 --- a/app/module/chat/repository/chat.repository.go +++ /dev/null @@ -1,272 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/chat/request" - "jaecoo-be/utils/paginator" -) - -type chatRepository struct { - DB *database.Database -} - -type ChatRepository interface { - // Chat Session methods - GetAllChatSessions(userId uint, req request.ChatSessionQueryRequest) (chatSessions []*entity.ChatSessions, paging paginator.Pagination, err error) - FindChatSessionByID(id uint) (chatSession *entity.ChatSessions, err error) - FindChatSessionByUserAndID(userId uint, id uint) (chatSession *entity.ChatSessions, err error) - CreateChatSession(chatSession *entity.ChatSessions) (result *entity.ChatSessions, err error) - UpdateChatSession(id uint, chatSession *entity.ChatSessions) (err error) - DeleteChatSession(id uint) (err error) - - // Chat Message methods - GetAllChatMessages(req request.ChatMessageQueryRequest) (chatMessages []*entity.ChatMessages, paging paginator.Pagination, err error) - FindChatMessageByID(id uint) (chatMessage *entity.ChatMessages, err error) - FindChatMessageByUserAndID(userId uint, id uint) (chatMessage *entity.ChatMessages, err error) - CreateChatMessage(chatMessage *entity.ChatMessages) (result *entity.ChatMessages, err error) - UpdateChatMessage(id uint, chatMessage *entity.ChatMessages) (err error) - DeleteChatMessage(id uint) (err error) - - // Chat Participant methods - CreateChatParticipant(chatParticipant *entity.ChatParticipants) (result *entity.ChatParticipants, err error) - FindChatParticipantsBySessionID(chatSessionID uint) (participants []*entity.ChatParticipants, err error) - UpdateChatParticipant(id uint, chatParticipant *entity.ChatParticipants) (err error) - DeleteChatParticipant(id uint) (err error) - - // Utility methods - FindPersonalChatSession(userId1 uint, userId2 uint) (chatSession *entity.ChatSessions, err error) - CheckUserInChatSession(userId uint, chatSessionID uint) (isParticipant bool, err error) -} - -func NewChatRepository(db *database.Database) ChatRepository { - return &chatRepository{ - DB: db, - } -} - -// Chat Session Repository Methods -func (_i *chatRepository) GetAllChatSessions(userId uint, req request.ChatSessionQueryRequest) (chatSessions []*entity.ChatSessions, paging paginator.Pagination, err error) { - // Get chat sessions where user is a participant - query := _i.DB.DB.Model(&entity.ChatSessions{}). - Joins("INNER JOIN chat_participants cp ON chat_sessions.id = cp.chat_session_id"). - Where("cp.user_id = ? AND cp.is_active = true", userId) - - // Apply filters - if req.Type != nil { - query = query.Where("chat_sessions.type = ?", *req.Type) - } - - // Include relationships - query = query.Preload("Creator"). - Preload("Participants", "is_active = true"). - Preload("Participants.User"). - Preload("Messages", "is_deleted = false"). - Preload("Messages.Sender") - - // Order by updated_at desc (most recent first) - query = query.Order("chat_sessions.updated_at DESC") - - // Apply pagination - var count int64 - query.Count(&count) - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&chatSessions).Error - paging = *req.Pagination - - return -} - -func (_i *chatRepository) FindChatSessionByID(id uint) (chatSession *entity.ChatSessions, err error) { - err = _i.DB.DB.Preload("Creator"). - Preload("Participants", "is_active = true"). - Preload("Participants.User"). - Preload("Messages", "is_deleted = false"). - Preload("Messages.Sender"). - First(&chatSession, id).Error - return -} - -func (_i *chatRepository) FindChatSessionByUserAndID(userId uint, id uint) (chatSession *entity.ChatSessions, err error) { - // Check if user is participant in this chat session - var isParticipant bool - err = _i.DB.DB.Table("chat_participants"). - Select("COUNT(*) > 0"). - Where("chat_session_id = ? AND user_id = ? AND is_active = true", id, userId). - Scan(&isParticipant).Error - - if err != nil { - return nil, err - } - - if !isParticipant { - return nil, nil - } - - err = _i.DB.DB.Preload("Creator"). - Preload("Participants", "is_active = true"). - Preload("Participants.User"). - Preload("Messages", "is_deleted = false"). - Preload("Messages.Sender"). - First(&chatSession, id).Error - return -} - -func (_i *chatRepository) CreateChatSession(chatSession *entity.ChatSessions) (result *entity.ChatSessions, err error) { - err = _i.DB.DB.Create(chatSession).Error - if err != nil { - return nil, err - } - - // Reload with relationships - err = _i.DB.DB.Preload("Creator"). - Preload("Participants", "is_active = true"). - Preload("Participants.User"). - First(&result, chatSession.ID).Error - return -} - -func (_i *chatRepository) UpdateChatSession(id uint, chatSession *entity.ChatSessions) (err error) { - err = _i.DB.DB.Model(&entity.ChatSessions{}).Where("id = ?", id).Updates(chatSession).Error - return -} - -func (_i *chatRepository) DeleteChatSession(id uint) (err error) { - err = _i.DB.DB.Delete(&entity.ChatSessions{}, id).Error - return -} - -// Chat Message Repository Methods -func (_i *chatRepository) GetAllChatMessages(req request.ChatMessageQueryRequest) (chatMessages []*entity.ChatMessages, paging paginator.Pagination, err error) { - // Check if user is participant in this chat session - var isParticipant bool - err = _i.DB.DB.Table("chat_participants"). - Select("COUNT(*) > 0"). - Where("chat_session_id = ? AND user_id = ? AND is_active = true", req.ChatSessionID, req.UserID). - Scan(&isParticipant).Error - - if err != nil { - return nil, paginator.Pagination{}, err - } - - if !isParticipant { - return nil, paginator.Pagination{}, nil - } - - query := _i.DB.DB.Model(&entity.ChatMessages{}).Where("chat_session_id = ? AND is_deleted = false", req.ChatSessionID) - - // Include relationships - query = query.Preload("Sender") - - // Order by created_at desc (most recent first) - query = query.Order("created_at DESC") - - // Apply pagination - var count int64 - query.Count(&count) - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&chatMessages).Error - paging = *req.Pagination - - return -} - -func (_i *chatRepository) FindChatMessageByID(id uint) (chatMessage *entity.ChatMessages, err error) { - err = _i.DB.DB.Preload("Sender").First(&chatMessage, id).Error - return -} - -func (_i *chatRepository) FindChatMessageByUserAndID(userId uint, id uint) (chatMessage *entity.ChatMessages, err error) { - // Check if user is participant in the chat session of this message - var isParticipant bool - err = _i.DB.DB.Table("chat_messages cm"). - Joins("INNER JOIN chat_participants cp ON cm.chat_session_id = cp.chat_session_id"). - Select("COUNT(*) > 0"). - Where("cm.id = ? AND cp.user_id = ? AND cp.is_active = true", id, userId). - Scan(&isParticipant).Error - - if err != nil { - return nil, err - } - - if !isParticipant { - return nil, nil - } - - err = _i.DB.DB.Preload("Sender").First(&chatMessage, id).Error - return -} - -func (_i *chatRepository) CreateChatMessage(chatMessage *entity.ChatMessages) (result *entity.ChatMessages, err error) { - err = _i.DB.DB.Create(chatMessage).Error - if err != nil { - return nil, err - } - - // Reload with relationships - err = _i.DB.DB.Preload("Sender").First(&result, chatMessage.ID).Error - return -} - -func (_i *chatRepository) UpdateChatMessage(id uint, chatMessage *entity.ChatMessages) (err error) { - err = _i.DB.DB.Model(&entity.ChatMessages{}).Where("id = ?", id).Updates(chatMessage).Error - return -} - -func (_i *chatRepository) DeleteChatMessage(id uint) (err error) { - err = _i.DB.DB.Delete(&entity.ChatMessages{}, id).Error - return -} - -// Chat Participant Repository Methods -func (_i *chatRepository) CreateChatParticipant(chatParticipant *entity.ChatParticipants) (result *entity.ChatParticipants, err error) { - err = _i.DB.DB.Create(chatParticipant).Error - if err != nil { - return nil, err - } - - // Reload with relationships - err = _i.DB.DB.Preload("User").First(&result, chatParticipant.ID).Error - return -} - -func (_i *chatRepository) FindChatParticipantsBySessionID(chatSessionID uint) (participants []*entity.ChatParticipants, err error) { - err = _i.DB.DB.Model(&entity.ChatParticipants{}).Where("chat_session_id = ? AND is_active = true", chatSessionID). - Preload("User").Find(&participants).Error - return -} - -func (_i *chatRepository) UpdateChatParticipant(id uint, chatParticipant *entity.ChatParticipants) (err error) { - err = _i.DB.DB.Model(&entity.ChatParticipants{}).Where("id = ?", id).Updates(chatParticipant).Error - return -} - -func (_i *chatRepository) DeleteChatParticipant(id uint) (err error) { - err = _i.DB.DB.Delete(&entity.ChatParticipants{}, id).Error - return -} - -// Utility Methods -func (_i *chatRepository) FindPersonalChatSession(userId1 uint, userId2 uint) (chatSession *entity.ChatSessions, err error) { - err = _i.DB.DB.Model(&entity.ChatSessions{}). - Joins("INNER JOIN chat_participants cp1 ON chat_sessions.id = cp1.chat_session_id"). - Joins("INNER JOIN chat_participants cp2 ON chat_sessions.id = cp2.chat_session_id"). - Where("chat_sessions.type = 'personal' AND cp1.user_id = ? AND cp2.user_id = ? AND cp1.is_active = true AND cp2.is_active = true", userId1, userId2). - Preload("Creator"). - Preload("Participants", "is_active = true"). - Preload("Participants.User"). - First(&chatSession).Error - return -} - -func (_i *chatRepository) CheckUserInChatSession(userId uint, chatSessionID uint) (isParticipant bool, err error) { - err = _i.DB.DB.Table("chat_participants"). - Select("COUNT(*) > 0"). - Where("chat_session_id = ? AND user_id = ? AND is_active = true", chatSessionID, userId). - Scan(&isParticipant).Error - return -} diff --git a/app/module/chat/repository/chat_schedule.repository.go b/app/module/chat/repository/chat_schedule.repository.go deleted file mode 100644 index 999e9a4..0000000 --- a/app/module/chat/repository/chat_schedule.repository.go +++ /dev/null @@ -1,179 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/chat/request" - "jaecoo-be/utils/paginator" -) - -type chatScheduleRepository struct { - DB *database.Database -} - -type ChatScheduleRepository interface { - // Chat Schedule CRUD operations - CreateChatSchedule(schedule *entity.ChatSchedules) (result *entity.ChatSchedules, err error) - GetAllChatSchedules(userId uint, req request.ChatScheduleQueryRequest) (schedules []*entity.ChatSchedules, paging paginator.Pagination, err error) - GetChatScheduleByID(id uint) (schedule *entity.ChatSchedules, err error) - UpdateChatSchedule(id uint, schedule *entity.ChatSchedules) (err error) - DeleteChatSchedule(id uint) (err error) - - // Chat Schedule File operations - CreateChatScheduleFile(file *entity.ChatScheduleFiles) (result *entity.ChatScheduleFiles, err error) - GetChatScheduleFilesByScheduleID(scheduleID uint) (files []*entity.ChatScheduleFiles, err error) - UpdateChatScheduleFile(id uint, file *entity.ChatScheduleFiles) (err error) - DeleteChatScheduleFile(id uint) (err error) - - // Utility methods - CheckUserInChatSchedule(userId uint, scheduleID uint) (isParticipant bool, err error) - GetUpcomingSchedules(userId uint, limit int) (schedules []*entity.ChatSchedules, err error) - GetSchedulesByStatus(status string) (schedules []*entity.ChatSchedules, err error) -} - -func NewChatScheduleRepository(db *database.Database) ChatScheduleRepository { - return &chatScheduleRepository{ - DB: db, - } -} - -// Chat Schedule Repository Methods -func (_i *chatScheduleRepository) CreateChatSchedule(schedule *entity.ChatSchedules) (result *entity.ChatSchedules, err error) { - err = _i.DB.DB.Create(schedule).Error - if err != nil { - return nil, err - } - - err = _i.DB.DB.Preload("Creator"). - Preload("ChatSession"). - Preload("Files"). - First(&result, schedule.ID).Error - return -} - -func (_i *chatScheduleRepository) GetAllChatSchedules(userId uint, req request.ChatScheduleQueryRequest) (schedules []*entity.ChatSchedules, paging paginator.Pagination, err error) { - // Get chat schedules where user is a participant in the chat session - query := _i.DB.DB.Model(&entity.ChatSchedules{}). - Joins("INNER JOIN chat_sessions cs ON chat_schedules.chat_session_id = cs.id"). - Joins("INNER JOIN chat_participants cp ON cs.id = cp.chat_session_id"). - Where("cp.user_id = ? AND cp.is_active = true", userId) - - // Apply filters - if req.ChatSessionID != nil { - query = query.Where("chat_schedules.chat_session_id = ?", *req.ChatSessionID) - } - - if req.Status != nil { - query = query.Where("chat_schedules.status = ?", *req.Status) - } - - if req.CreatedBy != nil { - query = query.Where("chat_schedules.created_by = ?", *req.CreatedBy) - } - - if req.DateFrom != nil { - query = query.Where("DATE(chat_schedules.scheduled_at) >= ?", req.DateFrom.Format("2006-01-02")) - } - - if req.DateTo != nil { - query = query.Where("DATE(chat_schedules.scheduled_at) <= ?", req.DateTo.Format("2006-01-02")) - } - - // Include relationships - query = query.Preload("Creator"). - Preload("ChatSession"). - Preload("Files") - - // Order by scheduled_at asc (upcoming first) - query = query.Order("chat_schedules.scheduled_at ASC") - - // Apply pagination - var count int64 - query.Count(&count) - req.Pagination.Count = count - pagingResult := paginator.Paging(&req.Pagination) - - err = query.Offset(pagingResult.Offset).Limit(pagingResult.Limit).Find(&schedules).Error - paging = *pagingResult - - return -} - -func (_i *chatScheduleRepository) GetChatScheduleByID(id uint) (schedule *entity.ChatSchedules, err error) { - err = _i.DB.DB.Preload("Creator"). - Preload("ChatSession"). - Preload("Files"). - First(&schedule, id).Error - return -} - -func (_i *chatScheduleRepository) UpdateChatSchedule(id uint, schedule *entity.ChatSchedules) (err error) { - err = _i.DB.DB.Model(&entity.ChatSchedules{}).Where("id = ?", id).Updates(schedule).Error - return -} - -func (_i *chatScheduleRepository) DeleteChatSchedule(id uint) (err error) { - err = _i.DB.DB.Delete(&entity.ChatSchedules{}, id).Error - return -} - -// Chat Schedule File Repository Methods -func (_i *chatScheduleRepository) CreateChatScheduleFile(file *entity.ChatScheduleFiles) (result *entity.ChatScheduleFiles, err error) { - err = _i.DB.DB.Create(file).Error - if err != nil { - return nil, err - } - - err = _i.DB.DB.First(&result, file.ID).Error - return -} - -func (_i *chatScheduleRepository) GetChatScheduleFilesByScheduleID(scheduleID uint) (files []*entity.ChatScheduleFiles, err error) { - err = _i.DB.DB.Model(&entity.ChatScheduleFiles{}).Where("chat_schedule_id = ?", scheduleID).Find(&files).Error - return -} - -func (_i *chatScheduleRepository) UpdateChatScheduleFile(id uint, file *entity.ChatScheduleFiles) (err error) { - err = _i.DB.DB.Model(&entity.ChatScheduleFiles{}).Where("id = ?", id).Updates(file).Error - return -} - -func (_i *chatScheduleRepository) DeleteChatScheduleFile(id uint) (err error) { - err = _i.DB.DB.Delete(&entity.ChatScheduleFiles{}, id).Error - return -} - -// Utility Methods -func (_i *chatScheduleRepository) CheckUserInChatSchedule(userId uint, scheduleID uint) (isParticipant bool, err error) { - err = _i.DB.DB.Model(&entity.ChatParticipants{}). - Select("COUNT(*) > 0"). - Joins("INNER JOIN chat_sessions cs ON chat_participants.chat_session_id = cs.id"). - Where("cs.id = ? AND chat_participants.user_id = ? AND chat_participants.is_active = true", scheduleID, userId). - Scan(&isParticipant).Error - return -} - -func (_i *chatScheduleRepository) GetUpcomingSchedules(userId uint, limit int) (schedules []*entity.ChatSchedules, err error) { - err = _i.DB.DB.Model(&entity.ChatSchedules{}). - Joins("INNER JOIN chat_sessions cs ON chat_schedules.chat_session_id = cs.id"). - Joins("INNER JOIN chat_participants cp ON cs.id = cp.chat_session_id"). - Where("cp.user_id = ? AND cp.is_active = true AND chat_schedules.scheduled_at > NOW() AND chat_schedules.status = 'scheduled'", userId). - Preload("Creator"). - Preload("ChatSession"). - Preload("Files"). - Order("chat_schedules.scheduled_at ASC"). - Limit(limit). - Find(&schedules).Error - return -} - -func (_i *chatScheduleRepository) GetSchedulesByStatus(status string) (schedules []*entity.ChatSchedules, err error) { - err = _i.DB.DB.Model(&entity.ChatSchedules{}). - Where("status = ?", status). - Preload("Creator"). - Preload("ChatSession"). - Preload("Files"). - Order("scheduled_at ASC"). - Find(&schedules).Error - return -} diff --git a/app/module/chat/repository/chat_schedule_file.repository.go b/app/module/chat/repository/chat_schedule_file.repository.go deleted file mode 100644 index c6d514e..0000000 --- a/app/module/chat/repository/chat_schedule_file.repository.go +++ /dev/null @@ -1,86 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/chat/request" -) - -type chatScheduleFileRepository struct { - DB *database.Database -} - -type ChatScheduleFileRepository interface { - // File CRUD operations - CreateChatScheduleFile(file *entity.ChatScheduleFiles) (result *entity.ChatScheduleFiles, err error) - GetChatScheduleFiles(req request.ChatScheduleFileQueryRequest) (files []*entity.ChatScheduleFiles, err error) - GetChatScheduleFileByID(id uint) (file *entity.ChatScheduleFiles, err error) - GetChatScheduleFileByFilename(filename string) (file *entity.ChatScheduleFiles, err error) - UpdateChatScheduleFile(id uint, file *entity.ChatScheduleFiles) (err error) - DeleteChatScheduleFile(id uint) (err error) -} - -func NewChatScheduleFileRepository(db *database.Database) ChatScheduleFileRepository { - return &chatScheduleFileRepository{ - DB: db, - } -} - -// CreateChatScheduleFile - Create a new chat schedule file -func (_i *chatScheduleFileRepository) CreateChatScheduleFile(file *entity.ChatScheduleFiles) (result *entity.ChatScheduleFiles, err error) { - err = _i.DB.DB.Create(file).Error - if err != nil { - return nil, err - } - - err = _i.DB.DB.First(&result, file.ID).Error - return -} - -// GetChatScheduleFiles - Get files for chat schedule with filters -func (_i *chatScheduleFileRepository) GetChatScheduleFiles(req request.ChatScheduleFileQueryRequest) (files []*entity.ChatScheduleFiles, err error) { - query := _i.DB.DB.Model(&entity.ChatScheduleFiles{}) - - // Apply filters - if req.ChatScheduleID != nil { - query = query.Where("chat_schedule_id = ?", *req.ChatScheduleID) - } - - if req.FileType != nil { - query = query.Where("file_type = ?", *req.FileType) - } - - if req.IsRequired != nil { - query = query.Where("is_required = ?", *req.IsRequired) - } - - // Order by created_at desc (newest first) - query = query.Order("created_at DESC") - - err = query.Find(&files).Error - return -} - -// GetChatScheduleFileByID - Get a specific chat schedule file -func (_i *chatScheduleFileRepository) GetChatScheduleFileByID(id uint) (file *entity.ChatScheduleFiles, err error) { - err = _i.DB.DB.First(&file, id).Error - return -} - -// UpdateChatScheduleFile - Update a chat schedule file -func (_i *chatScheduleFileRepository) UpdateChatScheduleFile(id uint, file *entity.ChatScheduleFiles) (err error) { - err = _i.DB.DB.Model(&entity.ChatScheduleFiles{}).Where("id = ?", id).Updates(file).Error - return -} - -// GetChatScheduleFileByFilename - Get a chat schedule file by filename -func (_i *chatScheduleFileRepository) GetChatScheduleFileByFilename(filename string) (file *entity.ChatScheduleFiles, err error) { - err = _i.DB.DB.Where("file_name = ?", filename).First(&file).Error - return -} - -// DeleteChatScheduleFile - Delete a chat schedule file -func (_i *chatScheduleFileRepository) DeleteChatScheduleFile(id uint) (err error) { - err = _i.DB.DB.Delete(&entity.ChatScheduleFiles{}, id).Error - return -} diff --git a/app/module/chat/request/chat.request.go b/app/module/chat/request/chat.request.go deleted file mode 100644 index 3d496d2..0000000 --- a/app/module/chat/request/chat.request.go +++ /dev/null @@ -1,122 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -// Chat Session Requests -type ChatSessionQueryRequest struct { - Type *string `json:"type"` // 'personal' or 'group' - Pagination *paginator.Pagination `json:"pagination"` -} - -type ChatSessionCreateRequest struct { - Name *string `json:"name" validate:"omitempty,min=2,max=255"` // null for personal chat - Type string `json:"type" validate:"required,oneof=personal group"` - UserIDs []uint `json:"userIds" validate:"required,min=1"` // participants (excluding creator) -} - -func (req ChatSessionCreateRequest) ToEntity(createdBy uint) *entity.ChatSessions { - return &entity.ChatSessions{ - Name: req.Name, - Type: req.Type, - CreatedBy: createdBy, - } -} - -type ChatSessionUpdateRequest struct { - Name *string `json:"name" validate:"omitempty,min=2,max=255"` -} - -func (req ChatSessionUpdateRequest) ToEntity() *entity.ChatSessions { - return &entity.ChatSessions{ - Name: req.Name, - } -} - -type ChatSessionQueryRequestContext struct { - Type string `json:"type"` -} - -func (req ChatSessionQueryRequestContext) ToParamRequest() ChatSessionQueryRequest { - var request ChatSessionQueryRequest - - if chatType := req.Type; chatType != "" { - request.Type = &chatType - } - - return request -} - -// Chat Message Requests -type ChatMessageQueryRequest struct { - ChatSessionID uint `json:"chatSessionId" validate:"required"` - UserID uint `json:"userId"` // Will be set in service layer - Pagination *paginator.Pagination `json:"pagination"` -} - -type ChatMessageCreateRequest struct { - ChatSessionID uint `json:"chatSessionId" validate:"required"` - Message string `json:"message" validate:"required,min=1,max=1000"` - MessageType string `json:"messageType" validate:"omitempty,oneof=text image file user assistant"` -} - -func (req ChatMessageCreateRequest) ToEntity(senderID uint) *entity.ChatMessages { - messageType := req.MessageType - if messageType == "" { - messageType = "text" - } - - return &entity.ChatMessages{ - ChatSessionID: req.ChatSessionID, - SenderID: senderID, - Message: req.Message, - MessageType: messageType, - } -} - -type ChatMessageUpdateRequest struct { - Message string `json:"message" validate:"required,min=1,max=1000"` -} - -func (req ChatMessageUpdateRequest) ToEntity() *entity.ChatMessages { - return &entity.ChatMessages{ - Message: req.Message, - IsEdited: true, - EditedAt: &time.Time{}, - } -} - -type ChatMessageQueryRequestContext struct { - ChatSessionID string `json:"chatSessionId"` -} - -func (req ChatMessageQueryRequestContext) ToParamRequest() ChatMessageQueryRequest { - var request ChatMessageQueryRequest - - if chatSessionId := req.ChatSessionID; chatSessionId != "" { - chatSessionIdUint, err := strconv.ParseUint(chatSessionId, 10, 0) - if err == nil { - request.ChatSessionID = uint(chatSessionIdUint) - } - } - - return request -} - -// Chat Participant Requests -type ChatParticipantCreateRequest struct { - ChatSessionID uint `json:"chatSessionId" validate:"required"` - UserID uint `json:"userId" validate:"required"` -} - -func (req ChatParticipantCreateRequest) ToEntity() *entity.ChatParticipants { - return &entity.ChatParticipants{ - ChatSessionID: req.ChatSessionID, - UserID: req.UserID, - IsActive: true, - } -} diff --git a/app/module/chat/request/chat_schedule.request.go b/app/module/chat/request/chat_schedule.request.go deleted file mode 100644 index c9244f7..0000000 --- a/app/module/chat/request/chat_schedule.request.go +++ /dev/null @@ -1,89 +0,0 @@ -package request - -import ( - "jaecoo-be/utils/paginator" - "time" -) - -// ChatScheduleCreateRequest - Request for creating chat schedule -type ChatScheduleCreateRequest struct { - ChatSessionID *uint `json:"chat_session_id" validate:"omitempty"` // Optional - if empty, will create new chat session - 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 -} diff --git a/app/module/chat/request/chat_schedule_file.request.go b/app/module/chat/request/chat_schedule_file.request.go deleted file mode 100644 index 714d038..0000000 --- a/app/module/chat/request/chat_schedule_file.request.go +++ /dev/null @@ -1,28 +0,0 @@ -package request - -// ChatScheduleFileUploadRequest - Request for uploading chat schedule file -type ChatScheduleFileUploadRequest struct { - ChatScheduleID uint `form:"chat_schedule_id" validate:"required"` - FileType string `form:"file_type" validate:"required,oneof=article journal video audio document other"` - Description string `form:"description" validate:"max=500"` - IsRequired bool `form:"is_required"` -} - -// ChatScheduleFileUpdateRequest - Request for updating chat schedule file -type ChatScheduleFileUpdateRequest struct { - FileName string `json:"file_name" validate:"omitempty,max=255"` - OriginalName string `json:"original_name" validate:"omitempty,max=255"` - FilePath string `json:"file_path" validate:"omitempty,max=500"` - FileSize int64 `json:"file_size" validate:"omitempty,min=0"` - MimeType string `json:"mime_type" validate:"omitempty,max=100"` - FileType string `json:"file_type" validate:"omitempty,oneof=article journal video audio document other"` - Description string `json:"description" validate:"omitempty,max=500"` - IsRequired *bool `json:"is_required"` -} - -// ChatScheduleFileQueryRequest - Request for querying chat schedule files -type ChatScheduleFileQueryRequest struct { - ChatScheduleID *uint `json:"chat_schedule_id"` - FileType *string `json:"file_type"` - IsRequired *bool `json:"is_required"` -} diff --git a/app/module/chat/response/chat.response.go b/app/module/chat/response/chat.response.go deleted file mode 100644 index f4ed0d0..0000000 --- a/app/module/chat/response/chat.response.go +++ /dev/null @@ -1,56 +0,0 @@ -package response - -import ( - "time" -) - -// Chat Session Response -type ChatSessionResponse struct { - ID uint `json:"id"` - Name *string `json:"name"` - Type string `json:"type"` - CreatedBy uint `json:"createdBy"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - Creator *UserBasicInfo `json:"creator,omitempty"` - Participants []*ChatParticipantResponse `json:"participants,omitempty"` - LastMessage *ChatMessageResponse `json:"lastMessage,omitempty"` - UnreadCount int `json:"unreadCount"` -} - -// Chat Message Response -type ChatMessageResponse struct { - ID uint `json:"id"` - ChatSessionID uint `json:"chatSessionId"` - SenderID uint `json:"senderId"` - Message string `json:"message"` - MessageType string `json:"messageType"` - IsEdited bool `json:"isEdited"` - EditedAt *time.Time `json:"editedAt"` - IsDeleted bool `json:"isDeleted"` - DeletedAt *time.Time `json:"deletedAt"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - Sender *UserBasicInfo `json:"sender,omitempty"` -} - -// Chat Participant Response -type ChatParticipantResponse struct { - ID uint `json:"id"` - ChatSessionID uint `json:"chatSessionId"` - UserID uint `json:"userId"` - JoinedAt time.Time `json:"joinedAt"` - LeftAt *time.Time `json:"leftAt"` - IsActive bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - User *UserBasicInfo `json:"user,omitempty"` -} - -// User Basic Info (reused from work_history) -type UserBasicInfo struct { - ID uint `json:"id"` - Username string `json:"username"` - Fullname string `json:"fullname"` - Email string `json:"email"` -} diff --git a/app/module/chat/response/chat_schedule_file.response.go b/app/module/chat/response/chat_schedule_file.response.go deleted file mode 100644 index 5c88e47..0000000 --- a/app/module/chat/response/chat_schedule_file.response.go +++ /dev/null @@ -1,17 +0,0 @@ -package response - -// ChatScheduleFileResponse - Response structure for chat schedule file -type ChatScheduleFileResponse struct { - ID uint `json:"id"` - ChatScheduleID uint `json:"chat_schedule_id"` - FileName string `json:"file_name"` - OriginalName string `json:"original_name"` - FilePath string `json:"file_path"` - FileSize int64 `json:"file_size"` - MimeType string `json:"mime_type"` - FileType string `json:"file_type"` - Description string `json:"description"` - IsRequired bool `json:"is_required"` - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` -} diff --git a/app/module/chat/service/chat.service.go b/app/module/chat/service/chat.service.go deleted file mode 100644 index 8b45b16..0000000 --- a/app/module/chat/service/chat.service.go +++ /dev/null @@ -1,418 +0,0 @@ -package service - -import ( - "errors" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/chat/mapper" - "jaecoo-be/app/module/chat/repository" - "jaecoo-be/app/module/chat/request" - "jaecoo-be/app/module/chat/response" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "time" - - "github.com/rs/zerolog" -) - -type chatService struct { - Repo repository.ChatRepository - UsersRepo usersRepository.UsersRepository - Log zerolog.Logger -} - -type ChatService interface { - // Chat Session methods - GetAllChatSessions(authToken string, req request.ChatSessionQueryRequest) (chatSessions []*response.ChatSessionResponse, paging paginator.Pagination, err error) - GetChatSessionByID(authToken string, id uint) (chatSession *response.ChatSessionResponse, err error) - CreateChatSession(authToken string, req request.ChatSessionCreateRequest) (chatSession *response.ChatSessionResponse, err error) - UpdateChatSession(authToken string, id uint, req request.ChatSessionUpdateRequest) (err error) - DeleteChatSession(authToken string, id uint) error - - // Chat Message methods - GetAllChatMessages(authToken string, req request.ChatMessageQueryRequest) (chatMessages []*response.ChatMessageResponse, paging paginator.Pagination, err error) - GetChatMessageByID(authToken string, id uint) (chatMessage *response.ChatMessageResponse, err error) - CreateChatMessage(authToken string, req request.ChatMessageCreateRequest) (chatMessage *response.ChatMessageResponse, err error) - UpdateChatMessage(authToken string, id uint, req request.ChatMessageUpdateRequest) (err error) - DeleteChatMessage(authToken string, id uint) error - - // Chat Participant methods - AddParticipantToChat(authToken string, chatSessionID uint, participantUserID uint) error - RemoveParticipantFromChat(authToken string, chatSessionID uint, participantUserID uint) error -} - -func NewChatService(repo repository.ChatRepository, usersRepo usersRepository.UsersRepository, log zerolog.Logger) ChatService { - return &chatService{ - Repo: repo, - UsersRepo: usersRepo, - Log: log, - } -} - -// Chat Session Service Methods -func (_i *chatService) GetAllChatSessions(authToken string, req request.ChatSessionQueryRequest) (chatSessions []*response.ChatSessionResponse, paging paginator.Pagination, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, paginator.Pagination{}, errors.New("user not found") - } - - results, paging, err := _i.Repo.GetAllChatSessions(userInfo.ID, req) - if err != nil { - return - } - - for _, result := range results { - chatSessions = append(chatSessions, mapper.ChatSessionResponseMapper(result)) - } - - return -} - -func (_i *chatService) GetChatSessionByID(authToken string, id uint) (chatSession *response.ChatSessionResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, errors.New("user not found") - } - - result, err := _i.Repo.FindChatSessionByUserAndID(userInfo.ID, id) - if err != nil { - return nil, err - } - if result == nil { - return nil, errors.New("chat session not found or access denied") - } - - return mapper.ChatSessionResponseMapper(result), nil -} - -func (_i *chatService) CreateChatSession(authToken string, req request.ChatSessionCreateRequest) (chatSession *response.ChatSessionResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, errors.New("user not found") - } - - _i.Log.Info().Interface("data", req).Msg("Creating chat session") - - // Validate business rules - if req.Type == "personal" && len(req.UserIDs) != 1 { - return nil, errors.New("personal chat must have exactly one other participant") - } - if req.Type == "group" && len(req.UserIDs) < 1 { - return nil, errors.New("group chat must have at least one participant") - } - - // Check if personal chat already exists - if req.Type == "personal" { - existingChat, err := _i.Repo.FindPersonalChatSession(userInfo.ID, req.UserIDs[0]) - if err == nil && existingChat != nil { - return mapper.ChatSessionResponseMapper(existingChat), nil - } - } - - // Validate all user IDs exist - for _, userID := range req.UserIDs { - user, err := _i.UsersRepo.FindOne(userID) - if err != nil || user == nil { - return nil, errors.New("invalid user ID: " + string(rune(userID))) - } - } - - // Create chat session - entity := req.ToEntity(userInfo.ID) - result, err := _i.Repo.CreateChatSession(entity) - if err != nil { - return nil, err - } - - // Add creator as participant - creatorParticipant := &request.ChatParticipantCreateRequest{ - ChatSessionID: result.ID, - UserID: userInfo.ID, - } - _, err = _i.Repo.CreateChatParticipant(creatorParticipant.ToEntity()) - if err != nil { - return nil, err - } - - // Add other participants - for _, userID := range req.UserIDs { - participant := &request.ChatParticipantCreateRequest{ - ChatSessionID: result.ID, - UserID: userID, - } - _, err = _i.Repo.CreateChatParticipant(participant.ToEntity()) - if err != nil { - return nil, err - } - } - - // Reload with all relationships - finalResult, err := _i.Repo.FindChatSessionByID(result.ID) - if err != nil { - return nil, err - } - - return mapper.ChatSessionResponseMapper(finalResult), nil -} - -func (_i *chatService) UpdateChatSession(authToken string, id uint, req request.ChatSessionUpdateRequest) (err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("user not found") - } - - _i.Log.Info().Interface("data", req).Msg("Updating chat session") - - // Check if chat session exists and user has access - existing, err := _i.Repo.FindChatSessionByUserAndID(userInfo.ID, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("chat session not found or access denied") - } - - // Only creator can update chat session - if existing.CreatedBy != userInfo.ID { - return errors.New("only chat creator can update chat session") - } - - entity := req.ToEntity() - return _i.Repo.UpdateChatSession(id, entity) -} - -func (_i *chatService) DeleteChatSession(authToken string, id uint) error { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("user not found") - } - - _i.Log.Info().Uint("userId", userInfo.ID).Uint("id", id).Msg("Deleting chat session") - - // Check if chat session exists and user has access - existing, err := _i.Repo.FindChatSessionByUserAndID(userInfo.ID, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("chat session not found or access denied") - } - - // Only creator can delete chat session - if existing.CreatedBy != userInfo.ID { - return errors.New("only chat creator can delete chat session") - } - - return _i.Repo.DeleteChatSession(id) -} - -// Chat Message Service Methods -func (_i *chatService) GetAllChatMessages(authToken string, req request.ChatMessageQueryRequest) (chatMessages []*response.ChatMessageResponse, paging paginator.Pagination, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, paginator.Pagination{}, errors.New("user not found") - } - - // Set user ID in request for repository - req.UserID = userInfo.ID - - results, paging, err := _i.Repo.GetAllChatMessages(req) - if err != nil { - return - } - - for _, result := range results { - chatMessages = append(chatMessages, mapper.ChatMessageResponseMapper(result)) - } - - return -} - -func (_i *chatService) GetChatMessageByID(authToken string, id uint) (chatMessage *response.ChatMessageResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, errors.New("user not found") - } - - result, err := _i.Repo.FindChatMessageByUserAndID(userInfo.ID, id) - if err != nil { - return nil, err - } - if result == nil { - return nil, errors.New("chat message not found or access denied") - } - - return mapper.ChatMessageResponseMapper(result), nil -} - -func (_i *chatService) CreateChatMessage(authToken string, req request.ChatMessageCreateRequest) (chatMessage *response.ChatMessageResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, errors.New("user not found") - } - - _i.Log.Info().Interface("data", req).Msg("Creating chat message") - - // Check if user is participant in the chat session - isParticipant, err := _i.Repo.CheckUserInChatSession(userInfo.ID, req.ChatSessionID) - if err != nil { - return nil, err - } - if !isParticipant { - return nil, errors.New("user is not a participant in this chat session") - } - - entity := req.ToEntity(userInfo.ID) - result, err := _i.Repo.CreateChatMessage(entity) - if err != nil { - return nil, err - } - - return mapper.ChatMessageResponseMapper(result), nil -} - -func (_i *chatService) UpdateChatMessage(authToken string, id uint, req request.ChatMessageUpdateRequest) (err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("user not found") - } - - _i.Log.Info().Interface("data", req).Msg("Updating chat message") - - // Check if message exists and user has access - existing, err := _i.Repo.FindChatMessageByUserAndID(userInfo.ID, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("chat message not found or access denied") - } - - // Only sender can update message - if existing.SenderID != userInfo.ID { - return errors.New("only message sender can update message") - } - - now := time.Now() - entity := req.ToEntity() - entity.EditedAt = &now - return _i.Repo.UpdateChatMessage(id, entity) -} - -func (_i *chatService) DeleteChatMessage(authToken string, id uint) error { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("user not found") - } - - _i.Log.Info().Uint("userId", userInfo.ID).Uint("id", id).Msg("Deleting chat message") - - // Check if message exists and user has access - existing, err := _i.Repo.FindChatMessageByUserAndID(userInfo.ID, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("chat message not found or access denied") - } - - // Only sender can delete message - if existing.SenderID != userInfo.ID { - return errors.New("only message sender can delete message") - } - - return _i.Repo.DeleteChatMessage(id) -} - -// Chat Participant Service Methods -func (_i *chatService) AddParticipantToChat(authToken string, chatSessionID uint, participantUserID uint) error { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("user not found") - } - - _i.Log.Info().Uint("userId", userInfo.ID).Uint("chatSessionID", chatSessionID).Uint("participantUserID", participantUserID).Msg("Adding participant to chat") - - // Check if user has access to chat session - existing, err := _i.Repo.FindChatSessionByUserAndID(userInfo.ID, chatSessionID) - if err != nil { - return err - } - if existing == nil { - return errors.New("chat session not found or access denied") - } - - // Only creator can add participants - if existing.CreatedBy != userInfo.ID { - return errors.New("only chat creator can add participants") - } - - // Validate participant user exists - user, err := _i.UsersRepo.FindOne(participantUserID) - if err != nil || user == nil { - return errors.New("invalid user ID") - } - - // Check if user is already a participant - isParticipant, err := _i.Repo.CheckUserInChatSession(participantUserID, chatSessionID) - if err != nil { - return err - } - if isParticipant { - return errors.New("user is already a participant in this chat") - } - - participant := &request.ChatParticipantCreateRequest{ - ChatSessionID: chatSessionID, - UserID: participantUserID, - } - _, err = _i.Repo.CreateChatParticipant(participant.ToEntity()) - return err -} - -func (_i *chatService) RemoveParticipantFromChat(authToken string, chatSessionID uint, participantUserID uint) error { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("user not found") - } - - _i.Log.Info().Uint("userId", userInfo.ID).Uint("chatSessionID", chatSessionID).Uint("participantUserID", participantUserID).Msg("Removing participant from chat") - - // Check if user has access to chat session - existing, err := _i.Repo.FindChatSessionByUserAndID(userInfo.ID, chatSessionID) - if err != nil { - return err - } - if existing == nil { - return errors.New("chat session not found or access denied") - } - - // Only creator can remove participants (or user can remove themselves) - if existing.CreatedBy != userInfo.ID && userInfo.ID != participantUserID { - return errors.New("only chat creator can remove participants or user can remove themselves") - } - - // Find participant - participants, err := _i.Repo.FindChatParticipantsBySessionID(chatSessionID) - if err != nil { - return err - } - - var participantToRemove *entity.ChatParticipants - for _, participant := range participants { - if participant.UserID == participantUserID { - participantToRemove = participant - break - } - } - - if participantToRemove == nil { - return errors.New("participant not found") - } - - // Soft delete by setting is_active to false - now := time.Now() - participantToRemove.IsActive = false - participantToRemove.LeftAt = &now - return _i.Repo.UpdateChatParticipant(participantToRemove.ID, participantToRemove) -} diff --git a/app/module/chat/service/chat_schedule.service.go b/app/module/chat/service/chat_schedule.service.go deleted file mode 100644 index 0f2d39e..0000000 --- a/app/module/chat/service/chat_schedule.service.go +++ /dev/null @@ -1,311 +0,0 @@ -package service - -import ( - "errors" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/chat/mapper" - "jaecoo-be/app/module/chat/repository" - "jaecoo-be/app/module/chat/request" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "time" - - "github.com/rs/zerolog" -) - -type chatScheduleService struct { - chatScheduleRepository repository.ChatScheduleRepository - chatRepository repository.ChatRepository - chatService ChatService - chatScheduleMapper *mapper.ChatScheduleMapper - Log zerolog.Logger - UsersRepo usersRepository.UsersRepository -} - -type ChatScheduleService interface { - // Chat Schedule CRUD operations - CreateChatSchedule(authToken string, req request.ChatScheduleCreateRequest) (dataResult *mapper.ChatScheduleResponse, err error) - GetAllChatSchedules(authToken string, req request.ChatScheduleQueryRequest) (schedules []*mapper.ChatScheduleResponse, paging paginator.Pagination, err error) - GetChatScheduleByID(authToken string, id uint) (schedule *mapper.ChatScheduleResponse, err error) - UpdateChatSchedule(authToken string, id uint, req request.ChatScheduleUpdateRequest) (err error) - DeleteChatSchedule(authToken string, id uint) (err error) - - // Additional schedule operations - GetUpcomingSchedules(authToken string, limit int) (schedules []*mapper.ChatScheduleResponse, err error) - GetSchedulesByStatus(authToken string, status string) (schedules []*mapper.ChatScheduleResponse, err error) - SendScheduleReminder(authToken string, scheduleID uint) (err error) -} - -func NewChatScheduleService( - chatScheduleRepository repository.ChatScheduleRepository, - chatRepository repository.ChatRepository, - chatService ChatService, - log zerolog.Logger, - usersRepo usersRepository.UsersRepository, -) ChatScheduleService { - return &chatScheduleService{ - chatScheduleRepository: chatScheduleRepository, - chatRepository: chatRepository, - chatService: chatService, - chatScheduleMapper: mapper.NewChatScheduleMapper(), - Log: log, - UsersRepo: usersRepo, - } -} - -// CreateChatSchedule - Create a new chat schedule -func (_i *chatScheduleService) CreateChatSchedule(authToken string, req request.ChatScheduleCreateRequest) (dataResult *mapper.ChatScheduleResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, errors.New("user not found") - } - userID := userInfo.ID - - // Validate that the scheduled time is in the future - if req.ScheduledAt.Before(time.Now()) { - return nil, errors.New("scheduled time must be in the future") - } - - var chatSessionID uint - - // If ChatSessionID is not provided, create a new chat session - if req.ChatSessionID == nil { - // Create a new personal chat session for the schedule - chatSessionReq := request.ChatSessionCreateRequest{ - Name: &req.Title, // Use schedule title as chat session name - Type: "group", // Default to group chat for schedules - UserIDs: []uint{}, // Empty for now, can be populated later - } - - chatSession, err := _i.chatService.CreateChatSession(authToken, chatSessionReq) - if err != nil { - return nil, errors.New("failed to create chat session: " + err.Error()) - } - - chatSessionID = chatSession.ID - } else { - chatSessionID = *req.ChatSessionID - - // Check if user is participant in the existing chat session - isParticipant, err := _i.chatRepository.CheckUserInChatSession(userID, chatSessionID) - if err != nil { - return nil, err - } - - if !isParticipant { - return nil, errors.New("user is not a participant in this chat session") - } - } - - // Convert request to entity - schedule := _i.chatScheduleMapper.ToEntity(req) - schedule.ChatSessionID = chatSessionID - schedule.CreatedBy = userID - - // Create schedule - result, err := _i.chatScheduleRepository.CreateChatSchedule(schedule) - if err != nil { - return nil, err - } - - // Convert to response - dataResult = _i.chatScheduleMapper.ToResponse(result) - return -} - -// GetAllChatSchedules - Get all chat schedules for a user -func (_i *chatScheduleService) GetAllChatSchedules(authToken string, req request.ChatScheduleQueryRequest) (schedules []*mapper.ChatScheduleResponse, paging paginator.Pagination, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, paginator.Pagination{}, errors.New("user not found") - } - userID := userInfo.ID - - // Get schedules from repository - scheduleEntities, paging, err := _i.chatScheduleRepository.GetAllChatSchedules(userID, req) - if err != nil { - return nil, paginator.Pagination{}, err - } - - // Convert to response - schedules = _i.chatScheduleMapper.ToResponseList(scheduleEntities) - return -} - -// GetChatScheduleByID - Get a specific chat schedule -func (_i *chatScheduleService) GetChatScheduleByID(authToken string, id uint) (schedule *mapper.ChatScheduleResponse, err error) { - // Get schedule from repository - scheduleEntity, err := _i.chatScheduleRepository.GetChatScheduleByID(id) - if err != nil { - return nil, err - } - - // Convert to response - schedule = _i.chatScheduleMapper.ToResponse(scheduleEntity) - return -} - -// UpdateChatSchedule - Update a chat schedule -func (_i *chatScheduleService) UpdateChatSchedule(authToken string, id uint, req request.ChatScheduleUpdateRequest) (err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("user not found") - } - userID := userInfo.ID - - // Check if user is participant in the chat session - isParticipant, err := _i.chatScheduleRepository.CheckUserInChatSchedule(userID, id) - if err != nil { - return err - } - - if !isParticipant { - return errors.New("user is not a participant in this chat session") - } - - // Get existing schedule to check if user is the creator - existingSchedule, err := _i.chatScheduleRepository.GetChatScheduleByID(id) - if err != nil { - return err - } - - // Only creator can update the schedule - if existingSchedule.CreatedBy != userID { - return errors.New("only the creator can update this schedule") - } - - // Validate scheduled time if provided - if !req.ScheduledAt.IsZero() && req.ScheduledAt.Before(time.Now()) { - return errors.New("scheduled time must be in the future") - } - - // Convert request to entity - schedule := _i.chatScheduleMapper.ToUpdateEntity(req) - - // Update schedule - err = _i.chatScheduleRepository.UpdateChatSchedule(id, schedule) - return -} - -// DeleteChatSchedule - Delete a chat schedule -func (_i *chatScheduleService) DeleteChatSchedule(authToken string, id uint) (err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("user not found") - } - userID := userInfo.ID - - // Get existing schedule to check if user is the creator - existingSchedule, err := _i.chatScheduleRepository.GetChatScheduleByID(id) - if err != nil { - return err - } - - // Only creator can delete the schedule - if existingSchedule.CreatedBy != userID { - return errors.New("only the creator can delete this schedule") - } - - // Delete schedule - err = _i.chatScheduleRepository.DeleteChatSchedule(id) - return -} - -// GetUpcomingSchedules - Get upcoming schedules for a user -func (_i *chatScheduleService) GetUpcomingSchedules(authToken string, limit int) (schedules []*mapper.ChatScheduleResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, errors.New("user not found") - } - userID := userInfo.ID - - // Get upcoming schedules from repository - scheduleEntities, err := _i.chatScheduleRepository.GetUpcomingSchedules(userID, limit) - if err != nil { - return nil, err - } - - // Convert to response - schedules = _i.chatScheduleMapper.ToResponseList(scheduleEntities) - return -} - -// GetSchedulesByStatus - Get schedules by status -func (_i *chatScheduleService) GetSchedulesByStatus(authToken string, status string) (schedules []*mapper.ChatScheduleResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, errors.New("user not found") - } - userID := userInfo.ID - - // Validate status - validStatuses := []string{"scheduled", "ongoing", "completed", "cancelled"} - isValidStatus := false - for _, validStatus := range validStatuses { - if status == validStatus { - isValidStatus = true - break - } - } - - if !isValidStatus { - return nil, errors.New("invalid status") - } - - // Get schedules by status from repository - scheduleEntities, err := _i.chatScheduleRepository.GetSchedulesByStatus(status) - if err != nil { - return nil, err - } - - // Filter by user participation - var userSchedules []*entity.ChatSchedules - for _, schedule := range scheduleEntities { - isParticipant, err := _i.chatScheduleRepository.CheckUserInChatSchedule(userID, schedule.ID) - if err != nil { - continue - } - if isParticipant { - userSchedules = append(userSchedules, schedule) - } - } - - // Convert to response - schedules = _i.chatScheduleMapper.ToResponseList(userSchedules) - return -} - -// SendScheduleReminder - Send reminder for a schedule -func (_i *chatScheduleService) SendScheduleReminder(authToken string, scheduleID uint) (err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("user not found") - } - userID := userInfo.ID - - // Get schedule - schedule, err := _i.chatScheduleRepository.GetChatScheduleByID(scheduleID) - if err != nil { - return err - } - - // Only creator can send reminders - if schedule.CreatedBy != userID { - return errors.New("only the creator can send reminders") - } - - // Check if reminder was already sent - if schedule.IsReminderSent { - return errors.New("reminder has already been sent") - } - - // TODO: Implement actual reminder sending logic (email, push notification, etc.) - // For now, just update the reminder status - now := time.Now() - schedule.IsReminderSent = true - schedule.ReminderSentAt = &now - - err = _i.chatScheduleRepository.UpdateChatSchedule(scheduleID, schedule) - return -} diff --git a/app/module/chat/service/chat_schedule_file.service.go b/app/module/chat/service/chat_schedule_file.service.go deleted file mode 100644 index 86bfd88..0000000 --- a/app/module/chat/service/chat_schedule_file.service.go +++ /dev/null @@ -1,337 +0,0 @@ -package service - -import ( - "context" - "errors" - "fmt" - "io" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/chat/mapper" - "jaecoo-be/app/module/chat/repository" - "jaecoo-be/app/module/chat/request" - "jaecoo-be/app/module/chat/response" - usersRepository "jaecoo-be/app/module/users/repository" - config "jaecoo-be/config/config" - minioStorage "jaecoo-be/config/config" - utilSvc "jaecoo-be/utils/service" - "math/rand" - "mime" - "path/filepath" - "strconv" - "strings" - "time" - - "github.com/gofiber/fiber/v2" - "github.com/minio/minio-go/v7" - "github.com/rs/zerolog" -) - -type chatScheduleFileService struct { - chatScheduleFileRepository repository.ChatScheduleFileRepository - chatScheduleRepository repository.ChatScheduleRepository - chatScheduleFileMapper *mapper.ChatScheduleFileMapper - Log zerolog.Logger - Cfg *config.Config - MinioStorage *minioStorage.MinioStorage - UsersRepo usersRepository.UsersRepository -} - -type ChatScheduleFileService interface { - // File management operations - UploadChatScheduleFile(c *fiber.Ctx, chatScheduleID uint) error - GetChatScheduleFiles(authToken string, req request.ChatScheduleFileQueryRequest) (files []*response.ChatScheduleFileResponse, err error) - GetChatScheduleFileByID(authToken string, id uint) (file *response.ChatScheduleFileResponse, err error) - UpdateChatScheduleFile(authToken string, id uint, req request.ChatScheduleFileUpdateRequest) (err error) - DeleteChatScheduleFile(authToken string, id uint) (err error) - Viewer(c *fiber.Ctx) error -} - -func NewChatScheduleFileService( - chatScheduleFileRepository repository.ChatScheduleFileRepository, - chatScheduleRepository repository.ChatScheduleRepository, - log zerolog.Logger, - cfg *config.Config, - minioStorage *minioStorage.MinioStorage, - usersRepo usersRepository.UsersRepository, -) ChatScheduleFileService { - return &chatScheduleFileService{ - chatScheduleFileRepository: chatScheduleFileRepository, - chatScheduleRepository: chatScheduleRepository, - chatScheduleFileMapper: mapper.NewChatScheduleFileMapper(), - Log: log, - Cfg: cfg, - MinioStorage: minioStorage, - UsersRepo: usersRepo, - } -} - -// UploadChatScheduleFile - Upload files for chat schedule -func (_i *chatScheduleFileService) UploadChatScheduleFile(c *fiber.Ctx, chatScheduleID uint) error { - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - - form, err := c.MultipartForm() - if err != nil { - return err - } - - // Create minio connection - minioClient, err := _i.MinioStorage.ConnectMinio() - if err != nil { - return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ - "error": true, - "msg": err.Error(), - }) - } - - for _, files := range form.File { - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "ChatScheduleFile::Upload"). - Interface("files", files).Msg("") - - for _, fileHeader := range files { - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "ChatScheduleFile::Upload"). - Interface("data", fileHeader).Msg("") - - src, err := fileHeader.Open() - if err != nil { - return err - } - defer src.Close() - - filename := filepath.Base(fileHeader.Filename) - filenameAlt := filepath.Clean(filename[:len(filename)-len(filepath.Ext(filename))]) - filename = strings.ReplaceAll(filename, " ", "") - filenameWithoutExt := filepath.Clean(filename[:len(filename)-len(filepath.Ext(filename))]) - extension := filepath.Ext(fileHeader.Filename)[1:] - - now := time.Now() - rand.New(rand.NewSource(now.UnixNano())) - randUniqueId := rand.Intn(1000000) - - newFilenameWithoutExt := filenameWithoutExt + "_" + strconv.Itoa(randUniqueId) - newFilename := newFilenameWithoutExt + "." + extension - - objectName := fmt.Sprintf("chat-schedules/upload/%d/%d/%s", now.Year(), now.Month(), newFilename) - - // Get file type from form data - fileType := c.FormValue("file_type", "other") - description := c.FormValue("description", "") - isRequired := c.FormValue("is_required") == "true" - - // Create file entity - fileEntity := &entity.ChatScheduleFiles{ - ChatScheduleID: chatScheduleID, - FileName: newFilename, - OriginalName: filenameAlt, - FilePath: objectName, - FileSize: fileHeader.Size, - MimeType: fileHeader.Header.Get("Content-Type"), - FileType: fileType, - Description: description, - IsRequired: isRequired, - } - - // Save to database - _, err = _i.chatScheduleFileRepository.CreateChatScheduleFile(fileEntity) - if err != nil { - return err - } - - // Upload file to MinIO - _, err = minioClient.PutObject(context.Background(), bucketName, objectName, src, fileHeader.Size, minio.PutObjectOptions{}) - if err != nil { - return err - } - } - } - - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "ChatScheduleFile::Upload"). - Interface("data", "Successfully uploaded").Msg("") - - return nil -} - -// GetChatScheduleFiles - Get files for a chat schedule -func (_i *chatScheduleFileService) GetChatScheduleFiles(authToken string, req request.ChatScheduleFileQueryRequest) (files []*response.ChatScheduleFileResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, errors.New("user not found") - } - userID := userInfo.ID - - // If chat schedule ID is provided, check if user has access - if req.ChatScheduleID != nil { - isParticipant, err := _i.chatScheduleRepository.CheckUserInChatSchedule(userID, *req.ChatScheduleID) - if err != nil { - return nil, err - } - - if !isParticipant { - return nil, errors.New("user is not a participant in this chat session") - } - } - - // Get files from repository - fileEntities, err := _i.chatScheduleFileRepository.GetChatScheduleFiles(req) - if err != nil { - return nil, err - } - - // Convert to response - files = _i.chatScheduleFileMapper.ToResponseList(fileEntities) - return -} - -// GetChatScheduleFileByID - Get a specific chat schedule file -func (_i *chatScheduleFileService) GetChatScheduleFileByID(authToken string, id uint) (file *response.ChatScheduleFileResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, errors.New("user not found") - } - userID := userInfo.ID - - // Get file from repository - fileEntity, err := _i.chatScheduleFileRepository.GetChatScheduleFileByID(id) - if err != nil { - return nil, err - } - - // Check if user has access to the chat schedule - isParticipant, err := _i.chatScheduleRepository.CheckUserInChatSchedule(userID, fileEntity.ChatScheduleID) - if err != nil { - return nil, err - } - - if !isParticipant { - return nil, errors.New("user is not a participant in this chat session") - } - - // Convert to response - file = _i.chatScheduleFileMapper.ToResponse(fileEntity) - return -} - -// UpdateChatScheduleFile - Update a chat schedule file -func (_i *chatScheduleFileService) UpdateChatScheduleFile(authToken string, id uint, req request.ChatScheduleFileUpdateRequest) (err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("user not found") - } - userID := userInfo.ID - - // Get existing file to check access - existingFile, err := _i.chatScheduleFileRepository.GetChatScheduleFileByID(id) - if err != nil { - return err - } - - // Check if user has access to the chat schedule - isParticipant, err := _i.chatScheduleRepository.CheckUserInChatSchedule(userID, existingFile.ChatScheduleID) - if err != nil { - return err - } - - if !isParticipant { - return errors.New("user is not a participant in this chat session") - } - - // Convert request to entity - file := _i.chatScheduleFileMapper.ToUpdateEntity(req) - - // Update file - err = _i.chatScheduleFileRepository.UpdateChatScheduleFile(id, file) - return -} - -// DeleteChatScheduleFile - Delete a chat schedule file -func (_i *chatScheduleFileService) DeleteChatScheduleFile(authToken string, id uint) (err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("user not found") - } - userID := userInfo.ID - - // Get existing file to check access - existingFile, err := _i.chatScheduleFileRepository.GetChatScheduleFileByID(id) - if err != nil { - return err - } - - // Check if user has access to the chat schedule - isParticipant, err := _i.chatScheduleRepository.CheckUserInChatSchedule(userID, existingFile.ChatScheduleID) - if err != nil { - return err - } - - if !isParticipant { - return errors.New("user is not a participant in this chat session") - } - - // Delete file - err = _i.chatScheduleFileRepository.DeleteChatScheduleFile(id) - return -} - -// Viewer - View chat schedule file -func (_i *chatScheduleFileService) Viewer(c *fiber.Ctx) error { - filename := c.Params("filename") - - // Find file by filename - fileEntity, err := _i.chatScheduleFileRepository.GetChatScheduleFileByFilename(filename) - if err != nil { - return err - } - - ctx := context.Background() - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - objectName := fileEntity.FilePath - - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "ChatScheduleFile::Viewer"). - Interface("data", objectName).Msg("") - - // Create minio connection - minioClient, err := _i.MinioStorage.ConnectMinio() - if err != nil { - return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ - "error": true, - "msg": err.Error(), - }) - } - - fileContent, err := minioClient.GetObject(ctx, bucketName, objectName, minio.GetObjectOptions{}) - if err != nil { - return err - } - defer fileContent.Close() - - // Determine Content-Type based on file extension - contentType := mime.TypeByExtension("." + getFileExtension(objectName)) - if contentType == "" { - contentType = "application/octet-stream" // fallback if no MIME type matches - } - - c.Set("Content-Type", contentType) - - if _, err := io.Copy(c.Response().BodyWriter(), fileContent); err != nil { - return err - } - - return nil -} - -// getFileExtension - Extract file extension from filename -func getFileExtension(filename string) string { - // split file name - parts := strings.Split(filename, ".") - - // if no extension, return empty string - if len(parts) == 1 || (len(parts) == 2 && parts[0] == "") { - return "" - } - - // get last extension - return parts[len(parts)-1] -} diff --git a/app/module/chat/service/file_upload.service.go b/app/module/chat/service/file_upload.service.go deleted file mode 100644 index 7fc050a..0000000 --- a/app/module/chat/service/file_upload.service.go +++ /dev/null @@ -1,143 +0,0 @@ -package service - -import ( - "context" - "crypto/md5" - "fmt" - "mime/multipart" - "path/filepath" - "strings" - "time" - - "github.com/minio/minio-go/v7" -) - -type fileUploadService struct { - minioClient *minio.Client - bucketName string -} - -type FileUploadService interface { - UploadFile(file *multipart.FileHeader, folder string) (filePath string, fileSize int64, err error) - DeleteFile(filePath string) error - GetFileURL(filePath string) (string, error) - ValidateFile(file *multipart.FileHeader) error -} - -func NewFileUploadService(minioClient *minio.Client, bucketName string) FileUploadService { - return &fileUploadService{ - minioClient: minioClient, - bucketName: bucketName, - } -} - -// UploadFile - Upload file to MinIO -func (f *fileUploadService) UploadFile(file *multipart.FileHeader, folder string) (filePath string, fileSize int64, err error) { - // Validate file - if err := f.ValidateFile(file); err != nil { - return "", 0, err - } - - // Open file - src, err := file.Open() - if err != nil { - return "", 0, err - } - defer src.Close() - - // Generate unique filename - ext := filepath.Ext(file.Filename) - fileName := strings.TrimSuffix(file.Filename, ext) - hasher := md5.New() - hasher.Write([]byte(fmt.Sprintf("%s-%d", fileName, time.Now().UnixNano()))) - uniqueFileName := fmt.Sprintf("%x%s", hasher.Sum(nil), ext) - - // Create file path - filePath = fmt.Sprintf("%s/%s", folder, uniqueFileName) - - // Upload file to MinIO - ctx := context.Background() - _, err = f.minioClient.PutObject(ctx, f.bucketName, filePath, src, file.Size, minio.PutObjectOptions{ - ContentType: file.Header.Get("Content-Type"), - }) - if err != nil { - return "", 0, err - } - - return filePath, file.Size, nil -} - -// DeleteFile - Delete file from MinIO -func (f *fileUploadService) DeleteFile(filePath string) error { - ctx := context.Background() - return f.minioClient.RemoveObject(ctx, f.bucketName, filePath, minio.RemoveObjectOptions{}) -} - -// GetFileURL - Get file URL from MinIO -func (f *fileUploadService) GetFileURL(filePath string) (string, error) { - ctx := context.Background() - - // Generate presigned URL (valid for 7 days) - url, err := f.minioClient.PresignedGetObject(ctx, f.bucketName, filePath, 7*24*time.Hour, nil) - if err != nil { - return "", err - } - - return url.String(), nil -} - -// ValidateFile - Validate uploaded file -func (f *fileUploadService) ValidateFile(file *multipart.FileHeader) error { - // Check file size (max 50MB) - const maxFileSize = 50 * 1024 * 1024 // 50MB - if file.Size > maxFileSize { - return fmt.Errorf("file size exceeds maximum limit of 50MB") - } - - // Check file extension - ext := strings.ToLower(filepath.Ext(file.Filename)) - allowedExts := []string{".pdf", ".doc", ".docx", ".txt", ".mp4", ".avi", ".mov", ".mp3", ".wav", ".jpg", ".jpeg", ".png", ".gif"} - - isAllowed := false - for _, allowedExt := range allowedExts { - if ext == allowedExt { - isAllowed = true - break - } - } - - if !isAllowed { - return fmt.Errorf("file type not allowed. Allowed types: %s", strings.Join(allowedExts, ", ")) - } - - // Check MIME type - contentType := file.Header.Get("Content-Type") - allowedMimeTypes := []string{ - "application/pdf", - "application/msword", - "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - "text/plain", - "video/mp4", - "video/avi", - "video/quicktime", - "audio/mpeg", - "audio/wav", - "image/jpeg", - "image/png", - "image/gif", - } - - isValidMimeType := false - for _, allowedMimeType := range allowedMimeTypes { - if contentType == allowedMimeType { - isValidMimeType = true - break - } - } - - if !isValidMimeType { - return fmt.Errorf("invalid file type. Content-Type: %s", contentType) - } - - return nil -} diff --git a/app/module/communications/mapper/communications.mapper.go b/app/module/communications/mapper/communications.mapper.go deleted file mode 100644 index b0e9d98..0000000 --- a/app/module/communications/mapper/communications.mapper.go +++ /dev/null @@ -1,78 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/communications/response" -) - -func ConversationsResponseMapper(conversation *entity.Conversations) *response.ConversationsResponse { - result := &response.ConversationsResponse{ - ID: conversation.ID, - Participant1ID: conversation.Participant1ID, - Participant2ID: conversation.Participant2ID, - LastMessageAt: conversation.LastMessageAt, - CreatedAt: conversation.CreatedAt, - UpdatedAt: conversation.UpdatedAt, - } - - if conversation.Participant1 != nil { - result.Participant1 = &response.UserBasicInfo{ - ID: conversation.Participant1.ID, - Username: conversation.Participant1.Username, - Fullname: conversation.Participant1.Fullname, - Email: conversation.Participant1.Email, - } - } - - if conversation.Participant2 != nil { - result.Participant2 = &response.UserBasicInfo{ - ID: conversation.Participant2.ID, - Username: conversation.Participant2.Username, - Fullname: conversation.Participant2.Fullname, - Email: conversation.Participant2.Email, - } - } - - return result -} - -func ChatMessagesResponseMapper(chatMessage *entity.ChatMessages) *response.ChatMessagesResponse { - result := &response.ChatMessagesResponse{ - ID: chatMessage.ID, - ConversationID: chatMessage.ChatSessionID, - SenderID: chatMessage.SenderID, - MessageText: &chatMessage.Message, - MessageType: chatMessage.MessageType, - FileURL: nil, // Not available in entity - FileName: nil, // Not available in entity - FileSize: nil, // Not available in entity - IsRead: false, // Not available in entity, default to false - CreatedAt: chatMessage.CreatedAt, - } - - if chatMessage.Sender != nil { - result.Sender = &response.UserBasicInfo{ - ID: chatMessage.Sender.ID, - Username: chatMessage.Sender.Username, - Fullname: chatMessage.Sender.Fullname, - Email: chatMessage.Sender.Email, - } - } - - return result -} - -func ConversationWithMessagesResponseMapper(conversation *entity.Conversations, messages []*entity.ChatMessages, unreadCount int) *response.ConversationWithMessagesResponse { - conversationResponse := ConversationsResponseMapper(conversation) - conversationResponse.UnreadCount = unreadCount - - var messagesResponse []*response.ChatMessagesResponse - for _, message := range messages { - messagesResponse = append(messagesResponse, ChatMessagesResponseMapper(message)) - } - - return &response.ConversationWithMessagesResponse{ - Conversation: conversationResponse, - Messages: messagesResponse, - } -} diff --git a/app/module/communications/repository/communications.repository.go b/app/module/communications/repository/communications.repository.go deleted file mode 100644 index e44b273..0000000 --- a/app/module/communications/repository/communications.repository.go +++ /dev/null @@ -1,130 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/communications/request" - "jaecoo-be/utils/paginator" - "time" - - "gorm.io/gorm" -) - -type communicationsRepository struct { - DB *gorm.DB -} - -type CommunicationsRepository interface { - // Conversations - GetUserConversations(userId uint, req request.ConversationsQueryRequest) (conversations []*entity.Conversations, paging paginator.Pagination, err error) - FindConversationByParticipants(participant1ID, participant2ID uint) (conversation *entity.Conversations, err error) - FindConversationByUserAndId(userId uint, conversationId uint) (conversation *entity.Conversations, err error) - CreateConversation(conversation *entity.Conversations) (result *entity.Conversations, err error) - UpdateConversationLastMessage(conversationId uint, lastMessageAt *time.Time) (err error) - - // Chat Messages - GetConversationMessages(conversationId uint, req request.ChatMessagesQueryRequest) (messages []*entity.ChatMessages, paging paginator.Pagination, err error) - CreateChatMessage(message *entity.ChatMessages) (result *entity.ChatMessages, err error) - MarkMessageAsRead(messageId uint, userId uint) (err error) - GetUnreadCount(conversationId uint, userId uint) (count int64, err error) -} - -func NewCommunicationsRepository(db *gorm.DB) CommunicationsRepository { - return &communicationsRepository{ - DB: db, - } -} - -// Conversations methods -func (_i *communicationsRepository) GetUserConversations(userId uint, req request.ConversationsQueryRequest) (conversations []*entity.Conversations, paging paginator.Pagination, err error) { - query := _i.DB.Where("participant1_id = ? OR participant2_id = ?", userId, userId) - - // Include relationships - query = query.Preload("Participant1").Preload("Participant2") - - // Order by last message time desc, then by created_at desc - query = query.Order("last_message_at DESC NULLS LAST, created_at DESC") - - // Apply pagination - var count int64 - query.Count(&count) - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&conversations).Error - paging = *req.Pagination - - return -} - -func (_i *communicationsRepository) FindConversationByParticipants(participant1ID, participant2ID uint) (conversation *entity.Conversations, err error) { - err = _i.DB.Where( - "(participant1_id = ? AND participant2_id = ?) OR (participant1_id = ? AND participant2_id = ?)", - participant1ID, participant2ID, participant2ID, participant1ID).Preload("Participant1").Preload("Participant2").First(&conversation).Error - return -} - -func (_i *communicationsRepository) FindConversationByUserAndId(userId uint, conversationId uint) (conversation *entity.Conversations, err error) { - err = _i.DB.Where( - "id = ? AND (participant1_id = ? OR participant2_id = ?)", - conversationId, userId, userId).Preload("Participant1").Preload("Participant2").First(&conversation).Error - return -} - -func (_i *communicationsRepository) CreateConversation(conversation *entity.Conversations) (result *entity.Conversations, err error) { - err = _i.DB.Create(conversation).Error - if err != nil { - return nil, err - } - - // Reload with relationships - err = _i.DB.Preload("Participant1").Preload("Participant2").First(&result, conversation.ID).Error - return -} - -func (_i *communicationsRepository) UpdateConversationLastMessage(conversationId uint, lastMessageAt *time.Time) (err error) { - err = _i.DB.Model(&entity.Conversations{}).Where("id = ?", conversationId).Update("last_message_at", lastMessageAt).Error - return -} - -// Chat Messages methods -func (_i *communicationsRepository) GetConversationMessages(conversationId uint, req request.ChatMessagesQueryRequest) (messages []*entity.ChatMessages, paging paginator.Pagination, err error) { - query := _i.DB.Where("conversation_id = ?", conversationId) - - // Include sender relationship - query = query.Preload("Sender") - - // Order by created_at asc (oldest first for chat) - query = query.Order("created_at ASC") - - // Apply pagination - var count int64 - query.Count(&count) - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&messages).Error - paging = *req.Pagination - - return -} - -func (_i *communicationsRepository) CreateChatMessage(message *entity.ChatMessages) (result *entity.ChatMessages, err error) { - err = _i.DB.Create(message).Error - if err != nil { - return nil, err - } - - // Reload with relationships - err = _i.DB.Preload("Sender").First(&result, message.ID).Error - return -} - -func (_i *communicationsRepository) MarkMessageAsRead(messageId uint, userId uint) (err error) { - err = _i.DB.Model(&entity.ChatMessages{}).Where("id = ? AND sender_id != ?", messageId, userId).Update("is_read", true).Error - return -} - -func (_i *communicationsRepository) GetUnreadCount(conversationId uint, userId uint) (count int64, err error) { - err = _i.DB.Model(&entity.ChatMessages{}).Where("conversation_id = ? AND sender_id != ? AND is_read = false", conversationId, userId).Count(&count).Error - return -} diff --git a/app/module/communications/request/communications.request.go b/app/module/communications/request/communications.request.go deleted file mode 100644 index 8719614..0000000 --- a/app/module/communications/request/communications.request.go +++ /dev/null @@ -1,88 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" -) - -// Conversations Request DTOs -type ConversationsQueryRequest struct { - Pagination *paginator.Pagination `json:"pagination"` -} - -type ConversationsCreateRequest struct { - Participant2ID uint `json:"participant2Id" validate:"required"` -} - -func (req ConversationsCreateRequest) ToEntity() *entity.Conversations { - return &entity.Conversations{ - Participant1ID: 0, // Will be set in service layer - Participant2ID: req.Participant2ID, - } -} - -// Chat Messages Request DTOs -type ChatMessagesQueryRequest struct { - ChatSessionID uint `json:"chatSessionId" validate:"required"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type ChatMessagesCreateRequest struct { - ChatSessionID uint `json:"chatSessionId" validate:"required"` - Message string `json:"message"` - MessageType string `json:"messageType" validate:"required,oneof=text image file audio"` -} - -func (req ChatMessagesCreateRequest) ToEntity() *entity.ChatMessages { - return &entity.ChatMessages{ - ChatSessionID: req.ChatSessionID, - SenderID: 0, // Will be set in service layer - Message: req.Message, - MessageType: req.MessageType, - } -} - -type ChatMessagesFileUploadRequest struct { - ChatSessionID uint `json:"chatSessionId" validate:"required"` - MessageType string `json:"messageType" validate:"required,oneof=image file audio"` - FileName string `json:"fileName"` - FileSize int64 `json:"fileSize"` -} - -func (req ChatMessagesFileUploadRequest) ToEntity(fileURL string) *entity.ChatMessages { - return &entity.ChatMessages{ - ChatSessionID: req.ChatSessionID, - SenderID: 0, // Will be set in service layer - Message: "", // File messages might not have text content - MessageType: req.MessageType, - // Note: FileURL, FileName, FileSize, IsRead fields are not available in the entity - // These would need to be stored separately or the entity needs to be updated - } -} - -type ChatMessagesMarkReadRequest struct { - MessageID uint `json:"messageId" validate:"required"` -} - -type ConversationsQueryRequestContext struct { - // No specific query parameters for conversations list -} - -func (req ConversationsQueryRequestContext) ToParamRequest() ConversationsQueryRequest { - return ConversationsQueryRequest{} -} - -type ChatMessagesQueryRequestContext struct { - ChatSessionID string `json:"chatSessionId"` -} - -func (req ChatMessagesQueryRequestContext) ToParamRequest() ChatMessagesQueryRequest { - var request ChatMessagesQueryRequest - - if chatSessionIDStr := req.ChatSessionID; chatSessionIDStr != "" { - // Parse chat session ID from string to uint - // This will be handled in the controller - } - - return request -} diff --git a/app/module/communications/response/communications.response.go b/app/module/communications/response/communications.response.go deleted file mode 100644 index 4bdeee6..0000000 --- a/app/module/communications/response/communications.response.go +++ /dev/null @@ -1,56 +0,0 @@ -package response - -import ( - "time" -) - -// Conversations Response DTOs -type ConversationsResponse struct { - ID uint `json:"id"` - Participant1ID uint `json:"participant1Id"` - Participant2ID uint `json:"participant2Id"` - LastMessageAt *time.Time `json:"lastMessageAt"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - - // Nested user info - Participant1 *UserBasicInfo `json:"participant1,omitempty"` - Participant2 *UserBasicInfo `json:"participant2,omitempty"` - - // Last message preview - LastMessage *ChatMessagesResponse `json:"lastMessage,omitempty"` - - // Unread count - UnreadCount int `json:"unreadCount"` -} - -// Chat Messages Response DTOs -type ChatMessagesResponse struct { - ID uint `json:"id"` - ConversationID uint `json:"conversationId"` - SenderID uint `json:"senderId"` - MessageText *string `json:"messageText"` - MessageType string `json:"messageType"` - FileURL *string `json:"fileUrl"` - FileName *string `json:"fileName"` - FileSize *int64 `json:"fileSize"` - IsRead bool `json:"isRead"` - CreatedAt time.Time `json:"createdAt"` - - // Nested user info - Sender *UserBasicInfo `json:"sender,omitempty"` -} - -type UserBasicInfo struct { - ID uint `json:"id"` - Username string `json:"username"` - Fullname string `json:"fullname"` - Email string `json:"email"` -} - -// Conversation with messages -type ConversationWithMessagesResponse struct { - Conversation *ConversationsResponse `json:"conversation"` - Messages []*ChatMessagesResponse `json:"messages"` - Pagination interface{} `json:"pagination"` -} diff --git a/app/module/ebooks/controller/ebook_purchases.controller.go b/app/module/ebooks/controller/ebook_purchases.controller.go deleted file mode 100644 index fee6654..0000000 --- a/app/module/ebooks/controller/ebook_purchases.controller.go +++ /dev/null @@ -1,210 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/ebooks/service" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type ebookPurchasesController struct { - purchaseService service.EbookPurchasesService - usersRepo usersRepository.UsersRepository - Log zerolog.Logger -} - -type EbookPurchasesController interface { - GetByBuyerId(c *fiber.Ctx) error - PurchaseEbook(c *fiber.Ctx) error - UpdatePaymentStatus(c *fiber.Ctx) error - GetPurchaseById(c *fiber.Ctx) error - ConfirmPayment(c *fiber.Ctx) error -} - -func NewEbookPurchasesController(purchaseService service.EbookPurchasesService, usersRepo usersRepository.UsersRepository, log zerolog.Logger) EbookPurchasesController { - return &ebookPurchasesController{ - purchaseService: purchaseService, - usersRepo: usersRepo, - Log: log, - } -} - -// GetByBuyerId Purchase -// @Summary Get user purchases -// @Description API for getting user purchases -// @Tags Ebook Purchase -// @Security Bearer -// @Param X-Client-Key header string true "Insert the X-Client-Key" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/purchases [get] -func (_i *ebookPurchasesController) GetByBuyerId(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - purchasesData, paging, err := _i.purchaseService.GetByBuyerId(authToken, paginate) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Purchases successfully retrieved"}, - Data: purchasesData, - Meta: paging, - }) -} - -// PurchaseEbook Purchase -// @Summary Purchase ebook -// @Description API for purchasing ebook -// @Tags Ebook Purchase -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param ebookId path int true "Ebook ID" -// @Param paymentMethod query string true "Payment Method" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/purchase/{ebookId} [post] -func (_i *ebookPurchasesController) PurchaseEbook(c *fiber.Ctx) error { - ebookId, err := strconv.ParseUint(c.Params("ebookId"), 10, 0) - if err != nil { - return err - } - - paymentMethod := c.Query("paymentMethod") - if paymentMethod == "" { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"Payment method is required"}, - }) - } - - authToken := c.Get("Authorization") - - purchase, err := _i.purchaseService.PurchaseEbook(authToken, uint(ebookId), paymentMethod) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook purchase successfully created"}, - Data: purchase, - }) -} - -// UpdatePaymentStatus Purchase -// @Summary Update payment status -// @Description API for updating payment status -// @Tags Ebook Purchase -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Purchase ID" -// @Param payload body PaymentStatusUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/purchases/{id}/payment [put] -func (_i *ebookPurchasesController) UpdatePaymentStatus(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(PaymentStatusUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.purchaseService.UpdatePaymentStatus(uint(id), req.PaymentStatus, req.TransactionId, req.PaymentProof) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Payment status successfully updated"}, - }) -} - -// GetPurchaseById Purchase -// @Summary Get purchase by ID -// @Description API for getting purchase by ID -// @Tags Ebook Purchase -// @Security Bearer -// @Param id path int true "Purchase ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/purchases/{id} [get] -func (_i *ebookPurchasesController) GetPurchaseById(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - purchaseData, err := _i.purchaseService.GetPurchaseById(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Purchase successfully retrieved"}, - Data: purchaseData, - }) -} - -// ConfirmPayment Purchase -// @Summary Confirm payment -// @Description API for confirming payment -// @Tags Ebook Purchase -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Purchase ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/purchases/{id}/confirm [put] -func (_i *ebookPurchasesController) ConfirmPayment(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.purchaseService.ConfirmPayment(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Payment successfully confirmed"}, - }) -} - -// PaymentStatusUpdateRequest struct for payment status update -type PaymentStatusUpdateRequest struct { - PaymentStatus string `json:"paymentStatus" validate:"required"` - TransactionId string `json:"transactionId"` - PaymentProof string `json:"paymentProof"` -} diff --git a/app/module/ebooks/controller/ebook_ratings.controller.go b/app/module/ebooks/controller/ebook_ratings.controller.go deleted file mode 100644 index da9e685..0000000 --- a/app/module/ebooks/controller/ebook_ratings.controller.go +++ /dev/null @@ -1,313 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/ebooks/request" - "jaecoo-be/app/module/ebooks/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type ebookRatingsController struct { - ratingsService service.EbookRatingsService - Log zerolog.Logger -} - -type EbookRatingsController interface { - GetAll(c *fiber.Ctx) error - GetByEbookId(c *fiber.Ctx) error - GetByUserId(c *fiber.Ctx) error - GetEbookRatingSummary(c *fiber.Ctx) error - Create(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error - GetRatingStats(c *fiber.Ctx) error -} - -func NewEbookRatingsController(ratingsService service.EbookRatingsService, log zerolog.Logger) EbookRatingsController { - return &ebookRatingsController{ - ratingsService: ratingsService, - Log: log, - } -} - -// GetAll Ratings -// @Summary Get all Ebook Ratings -// @Description API for getting all Ebook Ratings -// @Tags Ebook Ratings -// @Security Bearer -// @Param X-Client-Key header string true "Insert the X-Client-Key" -// @Param req query request.EbookRatingsQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebook-ratings [get] -func (_i *ebookRatingsController) GetAll(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.EbookRatingsQueryRequestContext{ - EbookId: c.Query("ebookId"), - UserId: c.Query("userId"), - Rating: c.Query("rating"), - IsVerified: c.Query("isVerified"), - StatusId: c.Query("statusId"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - ratingsData, paging, err := _i.ratingsService.GetAll(req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook ratings list successfully retrieved"}, - Data: ratingsData, - Meta: paging, - }) -} - -// GetByEbookId Ratings -// @Summary Get ratings by ebook ID -// @Description API for getting ratings by ebook ID -// @Tags Ebook Ratings -// @Security Bearer -// @Param X-Client-Key header string true "Insert the X-Client-Key" -// @Param id path int true "Ebook ID" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebook-ratings/ebook/{id} [get] -func (_i *ebookRatingsController) GetByEbookId(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - ratingsData, paging, err := _i.ratingsService.GetByEbookId(uint(id), paginate) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook ratings successfully retrieved"}, - Data: ratingsData, - Meta: paging, - }) -} - -// GetByUserId Ratings -// @Summary Get user ratings -// @Description API for getting user ratings -// @Tags Ebook Ratings -// @Security Bearer -// @Param X-Client-Key header string true "Insert the X-Client-Key" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebook-ratings/user [get] -func (_i *ebookRatingsController) GetByUserId(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - ratingsData, paging, err := _i.ratingsService.GetByUserId(authToken, paginate) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"User ratings successfully retrieved"}, - Data: ratingsData, - Meta: paging, - }) -} - -// GetEbookRatingSummary Ratings -// @Summary Get ebook rating summary -// @Description API for getting ebook rating summary with stats and recent reviews -// @Tags Ebook Ratings -// @Security Bearer -// @Param X-Client-Key header string true "Insert the X-Client-Key" -// @Param id path int true "Ebook ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebook-ratings/summary/{id} [get] -func (_i *ebookRatingsController) GetEbookRatingSummary(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - summaryData, err := _i.ratingsService.GetEbookRatingSummary(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook rating summary successfully retrieved"}, - Data: summaryData, - }) -} - -// Create Rating -// @Summary Create ebook rating -// @Description API for creating ebook rating -// @Tags Ebook Ratings -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.EbookRatingsCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebook-ratings [post] -func (_i *ebookRatingsController) Create(c *fiber.Ctx) error { - req := new(request.EbookRatingsCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authToken := c.Get("Authorization") - - dataResult, err := _i.ratingsService.Create(*req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook rating successfully created"}, - Data: dataResult, - }) -} - -// Update Rating -// @Summary Update ebook rating -// @Description API for updating ebook rating -// @Tags Ebook Ratings -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.EbookRatingsUpdateRequest true "Required payload" -// @Param id path int true "Rating ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebook-ratings/{id} [put] -func (_i *ebookRatingsController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.EbookRatingsUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authToken := c.Get("Authorization") - - err = _i.ratingsService.Update(uint(id), *req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook rating successfully updated"}, - }) -} - -// Delete Rating -// @Summary Delete ebook rating -// @Description API for deleting ebook rating -// @Tags Ebook Ratings -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param id path int true "Rating ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebook-ratings/{id} [delete] -func (_i *ebookRatingsController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - err = _i.ratingsService.Delete(uint(id), authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook rating successfully deleted"}, - }) -} - -// GetRatingStats Ratings -// @Summary Get ebook rating statistics -// @Description API for getting ebook rating statistics -// @Tags Ebook Ratings -// @Security Bearer -// @Param X-Client-Key header string true "Insert the X-Client-Key" -// @Param id path int true "Ebook ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebook-ratings/stats/{id} [get] -func (_i *ebookRatingsController) GetRatingStats(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - statsData, err := _i.ratingsService.GetRatingStats(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook rating statistics successfully retrieved"}, - Data: statsData, - }) -} diff --git a/app/module/ebooks/controller/ebook_wishlists.controller.go b/app/module/ebooks/controller/ebook_wishlists.controller.go deleted file mode 100644 index fb3701d..0000000 --- a/app/module/ebooks/controller/ebook_wishlists.controller.go +++ /dev/null @@ -1,160 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/ebooks/service" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog" - - utilRes "jaecoo-be/utils/response" -) - -type ebookWishlistsController struct { - wishlistService service.EbookWishlistsService - usersRepo usersRepository.UsersRepository - Log zerolog.Logger -} - -type EbookWishlistsController interface { - GetByUserId(c *fiber.Ctx) error - AddToWishlist(c *fiber.Ctx) error - RemoveFromWishlist(c *fiber.Ctx) error - IsInWishlist(c *fiber.Ctx) error -} - -func NewEbookWishlistsController(wishlistService service.EbookWishlistsService, usersRepo usersRepository.UsersRepository, log zerolog.Logger) EbookWishlistsController { - return &ebookWishlistsController{ - wishlistService: wishlistService, - usersRepo: usersRepo, - Log: log, - } -} - -// GetByUserId Wishlist -// @Summary Get user wishlist -// @Description API for getting user wishlist -// @Tags Ebook Wishlist -// @Security Bearer -// @Param X-Client-Key header string true "Insert the X-Client-Key" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/wishlist [get] -func (_i *ebookWishlistsController) GetByUserId(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - wishlistsData, paging, err := _i.wishlistService.GetByUserId(authToken, paginate) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Wishlist successfully retrieved"}, - Data: wishlistsData, - Meta: paging, - }) -} - -// AddToWishlist Wishlist -// @Summary Add ebook to wishlist -// @Description API for adding ebook to wishlist -// @Tags Ebook Wishlist -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param ebookId path int true "Ebook ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/wishlist/{ebookId} [post] -func (_i *ebookWishlistsController) AddToWishlist(c *fiber.Ctx) error { - ebookId, err := strconv.ParseUint(c.Params("ebookId"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - err = _i.wishlistService.AddToWishlist(authToken, uint(ebookId)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook successfully added to wishlist"}, - }) -} - -// RemoveFromWishlist Wishlist -// @Summary Remove ebook from wishlist -// @Description API for removing ebook from wishlist -// @Tags Ebook Wishlist -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param ebookId path int true "Ebook ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/wishlist/{ebookId} [delete] -func (_i *ebookWishlistsController) RemoveFromWishlist(c *fiber.Ctx) error { - ebookId, err := strconv.ParseUint(c.Params("ebookId"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - err = _i.wishlistService.RemoveFromWishlist(authToken, uint(ebookId)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook successfully removed from wishlist"}, - }) -} - -// IsInWishlist Wishlist -// @Summary Check if ebook is in wishlist -// @Description API for checking if ebook is in wishlist -// @Tags Ebook Wishlist -// @Security Bearer -// @Param ebookId path int true "Ebook ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/wishlist/check/{ebookId} [get] -func (_i *ebookWishlistsController) IsInWishlist(c *fiber.Ctx) error { - ebookId, err := strconv.ParseUint(c.Params("ebookId"), 10, 0) - if err != nil { - return err - } - - authToken := c.Get("Authorization") - - isInWishlist, err := _i.wishlistService.IsInWishlist(authToken, uint(ebookId)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Wishlist status successfully retrieved"}, - Data: map[string]bool{"isInWishlist": isInWishlist}, - }) -} diff --git a/app/module/ebooks/controller/ebooks.controller.go b/app/module/ebooks/controller/ebooks.controller.go deleted file mode 100644 index c576e09..0000000 --- a/app/module/ebooks/controller/ebooks.controller.go +++ /dev/null @@ -1,350 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/ebooks/request" - "jaecoo-be/app/module/ebooks/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type ebooksController struct { - ebooksService service.EbooksService - Log zerolog.Logger -} - -type EbooksController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - ShowBySlug(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - SavePdfFile(c *fiber.Ctx) error - SaveThumbnail(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error - SummaryStats(c *fiber.Ctx) error - DownloadPdf(c *fiber.Ctx) error -} - -func NewEbooksController(ebooksService service.EbooksService, log zerolog.Logger) EbooksController { - return &ebooksController{ - ebooksService: ebooksService, - Log: log, - } -} - -// All Ebooks -// @Summary Get all Ebooks -// @Description API for getting all Ebooks -// @Tags Ebooks -// @Security Bearer -// @Param X-Client-Key header string true "Insert the X-Client-Key" -// @Param req query request.EbooksQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks [get] -func (_i *ebooksController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.EbooksQueryRequestContext{ - Title: c.Query("title"), - Description: c.Query("description"), - AuthorId: c.Query("authorId"), - Category: c.Query("category"), - Tags: c.Query("tags"), - MinPrice: c.Query("minPrice"), - MaxPrice: c.Query("maxPrice"), - StatusId: c.Query("statusId"), - IsPublished: c.Query("isPublished"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - ebooksData, paging, err := _i.ebooksService.All(req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebooks list successfully retrieved"}, - Data: ebooksData, - Meta: paging, - }) -} - -// Show Ebook -// @Summary Get one Ebook -// @Description API for getting one Ebook -// @Tags Ebooks -// @Security Bearer -// @Param id path int true "Ebook ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/{id} [get] -func (_i *ebooksController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - ebookData, err := _i.ebooksService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook successfully retrieved"}, - Data: ebookData, - }) -} - -// ShowBySlug Ebook -// @Summary Get one Ebook by slug -// @Description API for getting one Ebook by slug -// @Tags Ebooks -// @Security Bearer -// @Param slug path string true "Ebook Slug" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/slug/{slug} [get] -func (_i *ebooksController) ShowBySlug(c *fiber.Ctx) error { - slug := c.Params("slug") - - ebookData, err := _i.ebooksService.ShowBySlug(slug) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook successfully retrieved"}, - Data: ebookData, - }) -} - -// Save Ebook -// @Summary Create Ebook -// @Description API for create Ebook -// @Tags Ebooks -// @Security Bearer -// @Param X-Csrf-Token header string false "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.EbooksCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks [post] -func (_i *ebooksController) Save(c *fiber.Ctx) error { - req := new(request.EbooksCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authToken := c.Get("Authorization") - - dataResult, err := _i.ebooksService.Save(*req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook successfully created"}, - Data: dataResult, - }) -} - -// SavePdfFile Ebook -// @Summary Save PDF File Ebook -// @Description API for Save PDF File of Ebook -// @Tags Ebooks -// @Security Bearer -// @Produce json -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param file formData file true "Upload PDF file" -// @Param id path int true "Ebook ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/pdf/{id} [post] -func (_i *ebooksController) SavePdfFile(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.ebooksService.SavePdfFile(c, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"PDF file of Ebook successfully uploaded"}, - }) -} - -// SaveThumbnail Ebook -// @Summary Save Thumbnail Ebook -// @Description API for Save Thumbnail of Ebook -// @Tags Ebooks -// @Security Bearer -// @Produce json -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param files formData file true "Upload thumbnail" -// @Param id path int true "Ebook ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/thumbnail/{id} [post] -func (_i *ebooksController) SaveThumbnail(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.ebooksService.SaveThumbnail(c, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Thumbnail of Ebook successfully uploaded"}, - }) -} - -// Update Ebook -// @Summary Update Ebook -// @Description API for update Ebook -// @Tags Ebooks -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param payload body request.EbooksUpdateRequest true "Required payload" -// @Param id path int true "Ebook ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/{id} [put] -func (_i *ebooksController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.EbooksUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.ebooksService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook successfully updated"}, - }) -} - -// Delete Ebook -// @Summary Delete Ebook -// @Description API for delete Ebook -// @Tags Ebooks -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Ebook ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/{id} [delete] -func (_i *ebooksController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.ebooksService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Ebook successfully deleted"}, - }) -} - -// SummaryStats Ebook -// @Summary SummaryStats Ebook -// @Description API for Summary Stats of Ebook -// @Tags Ebooks -// @Security Bearer -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/statistic/summary [get] -func (_i *ebooksController) SummaryStats(c *fiber.Ctx) error { - authToken := c.Get("Authorization") - - response, err := _i.ebooksService.SummaryStats(authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Summary Stats of Ebooks successfully retrieved"}, - Data: response, - }) -} - -// DownloadPdf Ebook -// @Summary Download PDF Ebook -// @Description API for Download PDF of Ebook -// @Tags Ebooks -// @Security Bearer -// @Param id path int true "Ebook ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /ebooks/download/{id} [get] -func (_i *ebooksController) DownloadPdf(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.ebooksService.DownloadPdf(c, uint(id)) - if err != nil { - return err - } - - return nil -} diff --git a/app/module/ebooks/ebooks.module.go b/app/module/ebooks/ebooks.module.go deleted file mode 100644 index e272105..0000000 --- a/app/module/ebooks/ebooks.module.go +++ /dev/null @@ -1,125 +0,0 @@ -package ebooks - -import ( - "jaecoo-be/app/module/ebooks/controller" - "jaecoo-be/app/module/ebooks/repository" - "jaecoo-be/app/module/ebooks/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// EbooksRouter struct of EbooksRouter -type EbooksRouter struct { - App fiber.Router - Controller *Controller -} - -// Controller struct for all controllers -type Controller struct { - Ebooks controller.EbooksController - Wishlists controller.EbookWishlistsController - Purchases controller.EbookPurchasesController - Ratings controller.EbookRatingsController -} - -// NewEbooksModule register bulky of Ebooks module -var NewEbooksModule = fx.Options( - // register repository of Ebooks module - fx.Provide(repository.NewEbooksRepository), - fx.Provide(repository.NewEbookWishlistsRepository), - fx.Provide(repository.NewEbookPurchasesRepository), - fx.Provide(repository.NewEbookRatingsRepository), - - // register service of Ebooks module - fx.Provide(service.NewEbooksService), - fx.Provide(service.NewEbookWishlistsService), - fx.Provide(service.NewEbookPurchasesService), - fx.Provide(service.NewEbookRatingsService), - - // register controller of Ebooks module - fx.Provide(controller.NewEbooksController), - fx.Provide(controller.NewEbookWishlistsController), - fx.Provide(controller.NewEbookPurchasesController), - fx.Provide(controller.NewEbookRatingsController), - fx.Provide(NewController), - - // register router of Ebooks module - fx.Provide(NewEbooksRouter), -) - -// NewController init Controller -func NewController( - ebooksController controller.EbooksController, - wishlistsController controller.EbookWishlistsController, - purchasesController controller.EbookPurchasesController, - ratingsController controller.EbookRatingsController, -) *Controller { - return &Controller{ - Ebooks: ebooksController, - Wishlists: wishlistsController, - Purchases: purchasesController, - Ratings: ratingsController, - } -} - -// NewEbooksRouter init EbooksRouter -func NewEbooksRouter(fiber *fiber.App, controller *Controller) *EbooksRouter { - return &EbooksRouter{ - App: fiber, - Controller: controller, - } -} - -// RegisterEbooksRoutes register routes of Ebooks module -func (_i *EbooksRouter) RegisterEbooksRoutes() { - // define controllers - ebooksController := _i.Controller.Ebooks - wishlistsController := _i.Controller.Wishlists - purchasesController := _i.Controller.Purchases - ratingsController := _i.Controller.Ratings - - // define routes - _i.App.Route("/ebooks", func(router fiber.Router) { - // Ebook CRUD routes - router.Get("/", ebooksController.All) - router.Get("/slug/:slug", ebooksController.ShowBySlug) - router.Get("/:id", ebooksController.Show) - router.Post("/", ebooksController.Save) - router.Put("/:id", ebooksController.Update) - router.Delete("/:id", ebooksController.Delete) - - // File upload routes - router.Post("/pdf/:id", ebooksController.SavePdfFile) - router.Post("/thumbnail/:id", ebooksController.SaveThumbnail) - - // Download route - router.Get("/download/:id", ebooksController.DownloadPdf) - - // Statistics route - router.Get("/statistic/summary", ebooksController.SummaryStats) - - // Wishlist routes - router.Get("/wishlist", wishlistsController.GetByUserId) - router.Post("/wishlist/:ebookId", wishlistsController.AddToWishlist) - router.Delete("/wishlist/:ebookId", wishlistsController.RemoveFromWishlist) - router.Get("/wishlist/check/:ebookId", wishlistsController.IsInWishlist) - - // Purchase routes - router.Get("/purchases", purchasesController.GetByBuyerId) - router.Post("/purchase/:ebookId", purchasesController.PurchaseEbook) - router.Get("/purchases/:id", purchasesController.GetPurchaseById) - router.Put("/purchases/:id/payment", purchasesController.UpdatePaymentStatus) - router.Put("/purchases/:id/confirm", purchasesController.ConfirmPayment) - - // Rating routes - router.Get("/ratings", ratingsController.GetAll) - router.Post("/ratings", ratingsController.Create) - router.Put("/ratings/:id", ratingsController.Update) - router.Delete("/ratings/:id", ratingsController.Delete) - router.Get("/ratings/ebook/:id", ratingsController.GetByEbookId) - router.Get("/ratings/user", ratingsController.GetByUserId) - router.Get("/ratings/summary/:id", ratingsController.GetEbookRatingSummary) - router.Get("/ratings/stats/:id", ratingsController.GetRatingStats) - }) -} diff --git a/app/module/ebooks/mapper/ebook_ratings.mapper.go b/app/module/ebooks/mapper/ebook_ratings.mapper.go deleted file mode 100644 index c61449c..0000000 --- a/app/module/ebooks/mapper/ebook_ratings.mapper.go +++ /dev/null @@ -1,94 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - ebookRatingsResponse "jaecoo-be/app/module/ebooks/response" -) - -func ToEbookRatingsResponse(rating *entity.EbookRatings) *ebookRatingsResponse.EbookRatingsResponse { - if rating == nil { - return nil - } - - var userName, userEmail *string - if rating.User != nil { - if rating.IsAnonymous != nil && *rating.IsAnonymous { - userName = stringPtr("Anonymous") - userEmail = nil - } else { - userName = &rating.User.Fullname - userEmail = &rating.User.Email - } - } - - var ebookTitle *string - if rating.Ebook != nil { - ebookTitle = &rating.Ebook.Title - } - - return &ebookRatingsResponse.EbookRatingsResponse{ - ID: rating.ID, - UserId: rating.UserId, - UserName: userName, - UserEmail: userEmail, - EbookId: rating.EbookId, - EbookTitle: ebookTitle, - PurchaseId: rating.PurchaseId, - Rating: rating.Rating, - Review: rating.Review, - IsAnonymous: rating.IsAnonymous, - IsVerified: rating.IsVerified, - StatusId: rating.StatusId, - IsActive: rating.IsActive, - CreatedAt: rating.CreatedAt, - UpdatedAt: rating.UpdatedAt, - } -} - -func ToEbookRatingsResponseList(ratings []*entity.EbookRatings) []*ebookRatingsResponse.EbookRatingsResponse { - if ratings == nil { - return nil - } - - var responses []*ebookRatingsResponse.EbookRatingsResponse - for _, rating := range ratings { - responses = append(responses, ToEbookRatingsResponse(rating)) - } - - return responses -} - -func ToEbookRatingSummaryResponse(ebookId uint, ebookTitle string, averageRating float64, totalRatings int, ratingCounts map[int]int, recentReviews []*entity.EbookRatings) *ebookRatingsResponse.EbookRatingSummaryResponse { - reviews := ToEbookRatingsResponseList(recentReviews) - var reviewsList []ebookRatingsResponse.EbookRatingsResponse - for _, review := range reviews { - reviewsList = append(reviewsList, *review) - } - - return &ebookRatingsResponse.EbookRatingSummaryResponse{ - EbookId: ebookId, - EbookTitle: ebookTitle, - AverageRating: averageRating, - TotalRatings: totalRatings, - RatingCounts: ratingCounts, - RecentReviews: reviewsList, - } -} - -func ToEbookRatingStatsResponse(totalRatings int, averageRating float64, ratingCounts map[int]int) *ebookRatingsResponse.EbookRatingStatsResponse { - return &ebookRatingsResponse.EbookRatingStatsResponse{ - TotalRatings: totalRatings, - AverageRating: averageRating, - RatingCounts: ratingCounts, - FiveStarCount: ratingCounts[5], - FourStarCount: ratingCounts[4], - ThreeStarCount: ratingCounts[3], - TwoStarCount: ratingCounts[2], - OneStarCount: ratingCounts[1], - } -} - -// Helper function -func stringPtr(s string) *string { - return &s -} diff --git a/app/module/ebooks/mapper/ebooks.mapper.go b/app/module/ebooks/mapper/ebooks.mapper.go deleted file mode 100644 index aa783f1..0000000 --- a/app/module/ebooks/mapper/ebooks.mapper.go +++ /dev/null @@ -1,140 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - ebooksResponse "jaecoo-be/app/module/ebooks/response" -) - -func ToEbooksResponse(ebook *entity.Ebooks) *ebooksResponse.EbooksResponse { - if ebook == nil { - return nil - } - - var authorName, authorEmail *string - if ebook.Author != nil { - authorName = &ebook.Author.Fullname - authorEmail = &ebook.Author.Email - } - - return &ebooksResponse.EbooksResponse{ - ID: ebook.ID, - Title: ebook.Title, - Slug: ebook.Slug, - Description: ebook.Description, - Price: ebook.Price, - PdfFilePath: ebook.PdfFilePath, - PdfFileName: ebook.PdfFileName, - PdfFileSize: ebook.PdfFileSize, - ThumbnailPath: ebook.ThumbnailPath, - ThumbnailName: ebook.ThumbnailName, - AuthorId: ebook.AuthorId, - AuthorName: authorName, - AuthorEmail: authorEmail, - Category: ebook.Category, - Tags: ebook.Tags, - PageCount: ebook.PageCount, - Language: ebook.Language, - Isbn: ebook.Isbn, - Publisher: ebook.Publisher, - PublishedYear: ebook.PublishedYear, - DownloadCount: ebook.DownloadCount, - PurchaseCount: ebook.PurchaseCount, - WishlistCount: ebook.WishlistCount, - Rating: ebook.Rating, - ReviewCount: ebook.ReviewCount, - StatusId: ebook.StatusId, - IsActive: ebook.IsActive, - IsPublished: ebook.IsPublished, - PublishedAt: ebook.PublishedAt, - CreatedById: ebook.CreatedById, - CreatedAt: ebook.CreatedAt, - UpdatedAt: ebook.UpdatedAt, - } -} - -func ToEbooksResponseList(ebooks []*entity.Ebooks) []*ebooksResponse.EbooksResponse { - if ebooks == nil { - return nil - } - - var responses []*ebooksResponse.EbooksResponse - for _, ebook := range ebooks { - responses = append(responses, ToEbooksResponse(ebook)) - } - - return responses -} - -func ToEbookWishlistResponse(wishlist *entity.EbookWishlists) *ebooksResponse.EbookWishlistResponse { - if wishlist == nil { - return nil - } - - return &ebooksResponse.EbookWishlistResponse{ - ID: wishlist.ID, - UserId: wishlist.UserId, - EbookId: wishlist.EbookId, - Ebook: ToEbooksResponse(wishlist.Ebook), - CreatedAt: wishlist.CreatedAt, - UpdatedAt: wishlist.UpdatedAt, - } -} - -func ToEbookWishlistResponseList(wishlists []*entity.EbookWishlists) []*ebooksResponse.EbookWishlistResponse { - if wishlists == nil { - return nil - } - - var responses []*ebooksResponse.EbookWishlistResponse - for _, wishlist := range wishlists { - responses = append(responses, ToEbookWishlistResponse(wishlist)) - } - - return responses -} - -func ToEbookPurchaseResponse(purchase *entity.EbookPurchases) *ebooksResponse.EbookPurchaseResponse { - if purchase == nil { - return nil - } - - var buyerName, buyerEmail *string - if purchase.Buyer != nil { - buyerName = &purchase.Buyer.Fullname - buyerEmail = &purchase.Buyer.Email - } - - return &ebooksResponse.EbookPurchaseResponse{ - ID: purchase.ID, - BuyerId: purchase.BuyerId, - BuyerName: buyerName, - BuyerEmail: buyerEmail, - EbookId: purchase.EbookId, - Ebook: ToEbooksResponse(purchase.Ebook), - PurchasePrice: purchase.PurchasePrice, - PaymentMethod: purchase.PaymentMethod, - PaymentStatus: purchase.PaymentStatus, - TransactionId: purchase.TransactionId, - PaymentProof: purchase.PaymentProof, - PaymentDate: purchase.PaymentDate, - DownloadCount: purchase.DownloadCount, - LastDownloadAt: purchase.LastDownloadAt, - StatusId: purchase.StatusId, - IsActive: purchase.IsActive, - CreatedAt: purchase.CreatedAt, - UpdatedAt: purchase.UpdatedAt, - } -} - -func ToEbookPurchaseResponseList(purchases []*entity.EbookPurchases) []*ebooksResponse.EbookPurchaseResponse { - if purchases == nil { - return nil - } - - var responses []*ebooksResponse.EbookPurchaseResponse - for _, purchase := range purchases { - responses = append(responses, ToEbookPurchaseResponse(purchase)) - } - - return responses -} diff --git a/app/module/ebooks/repository/ebook_purchases.repository.go b/app/module/ebooks/repository/ebook_purchases.repository.go deleted file mode 100644 index 4104b47..0000000 --- a/app/module/ebooks/repository/ebook_purchases.repository.go +++ /dev/null @@ -1,98 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - - "github.com/rs/zerolog" -) - -type ebookPurchasesRepository struct { - DB *database.Database - Log zerolog.Logger -} - -// EbookPurchasesRepository define interface of IEbookPurchasesRepository -type EbookPurchasesRepository interface { - GetByBuyerId(buyerId uint, pagination *paginator.Pagination) (purchases []*entity.EbookPurchases, paging paginator.Pagination, err error) - FindByBuyerAndEbook(buyerId uint, ebookId uint) (purchase *entity.EbookPurchases, err error) - FindOne(id uint) (purchase *entity.EbookPurchases, err error) - Create(purchase *entity.EbookPurchases) (purchaseReturn *entity.EbookPurchases, err error) - Update(id uint, purchase *entity.EbookPurchases) (err error) - UpdateDownloadCount(id uint) (err error) - Delete(id uint) (err error) -} - -func NewEbookPurchasesRepository(db *database.Database, log zerolog.Logger) EbookPurchasesRepository { - return &ebookPurchasesRepository{ - DB: db, - Log: log, - } -} - -func (_i *ebookPurchasesRepository) GetByBuyerId(buyerId uint, pagination *paginator.Pagination) (purchases []*entity.EbookPurchases, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.EbookPurchases{}). - Preload("Ebook"). - Preload("Ebook.Author"). - Preload("Buyer"). - Where("buyer_id = ?", buyerId) - - query.Count(&count) - - pagination.Count = count - pagination = paginator.Paging(pagination) - - err = query.Offset(pagination.Offset).Limit(pagination.Limit). - Order("created_at DESC"). - Find(&purchases).Error - if err != nil { - return - } - - paging = *pagination - - return -} - -func (_i *ebookPurchasesRepository) FindByBuyerAndEbook(buyerId uint, ebookId uint) (purchase *entity.EbookPurchases, err error) { - query := _i.DB.DB.Where("buyer_id = ? AND ebook_id = ?", buyerId, ebookId) - - if err := query.First(&purchase).Error; err != nil { - return nil, err - } - - return purchase, nil -} - -func (_i *ebookPurchasesRepository) FindOne(id uint) (purchase *entity.EbookPurchases, err error) { - query := _i.DB.DB.Preload("Ebook").Preload("Buyer") - if err := query.First(&purchase, id).Error; err != nil { - return nil, err - } - - return purchase, nil -} - -func (_i *ebookPurchasesRepository) Create(purchase *entity.EbookPurchases) (purchaseReturn *entity.EbookPurchases, err error) { - result := _i.DB.DB.Create(purchase) - return purchase, result.Error -} - -func (_i *ebookPurchasesRepository) Update(id uint, purchase *entity.EbookPurchases) (err error) { - return _i.DB.DB.Model(&entity.EbookPurchases{}). - Where(&entity.EbookPurchases{ID: id}). - Updates(purchase).Error -} - -func (_i *ebookPurchasesRepository) UpdateDownloadCount(id uint) (err error) { - return _i.DB.DB.Model(&entity.EbookPurchases{}). - Where("id = ?", id). - Update("download_count", "download_count + 1").Error -} - -func (_i *ebookPurchasesRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.EbookPurchases{}, id).Error -} diff --git a/app/module/ebooks/repository/ebook_ratings.repository.go b/app/module/ebooks/repository/ebook_ratings.repository.go deleted file mode 100644 index 8e92ecf..0000000 --- a/app/module/ebooks/repository/ebook_ratings.repository.go +++ /dev/null @@ -1,243 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/ebooks/request" - "jaecoo-be/utils/paginator" - - "github.com/rs/zerolog" -) - -type ebookRatingsRepository struct { - DB *database.Database - Log zerolog.Logger -} - -// EbookRatingsRepository define interface of IEbookRatingsRepository -type EbookRatingsRepository interface { - GetAll(req request.EbookRatingsQueryRequest) (ratings []*entity.EbookRatings, paging paginator.Pagination, err error) - GetByEbookId(ebookId uint, pagination *paginator.Pagination) (ratings []*entity.EbookRatings, paging paginator.Pagination, err error) - GetByUserId(userId uint, pagination *paginator.Pagination) (ratings []*entity.EbookRatings, paging paginator.Pagination, err error) - FindOne(id uint) (rating *entity.EbookRatings, err error) - FindByUserAndEbook(userId uint, ebookId uint) (rating *entity.EbookRatings, err error) - FindByPurchaseId(purchaseId uint) (rating *entity.EbookRatings, err error) - Create(rating *entity.EbookRatings) (ratingReturn *entity.EbookRatings, err error) - Update(id uint, rating *entity.EbookRatings) (err error) - Delete(id uint) (err error) - GetEbookRatingStats(ebookId uint) (totalRatings int, averageRating float64, ratingCounts map[int]int, err error) - GetRecentReviews(ebookId uint, limit int) (reviews []*entity.EbookRatings, err error) -} - -func NewEbookRatingsRepository(db *database.Database, log zerolog.Logger) EbookRatingsRepository { - return &ebookRatingsRepository{ - DB: db, - Log: log, - } -} - -// implement interface of IEbookRatingsRepository -func (_i *ebookRatingsRepository) GetAll(req request.EbookRatingsQueryRequest) (ratings []*entity.EbookRatings, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.EbookRatings{}). - Preload("User"). - Preload("Ebook"). - Preload("Purchase"). - Where("ebook_ratings.is_active = ?", true) - - if req.EbookId != nil { - query = query.Where("ebook_ratings.ebook_id = ?", req.EbookId) - } - if req.UserId != nil { - query = query.Where("ebook_ratings.user_id = ?", req.UserId) - } - if req.Rating != nil { - query = query.Where("ebook_ratings.rating = ?", req.Rating) - } - if req.IsVerified != nil { - query = query.Where("ebook_ratings.is_verified = ?", req.IsVerified) - } - if req.StatusId != nil { - query = query.Where("ebook_ratings.status_id = ?", req.StatusId) - } - - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order("ebook_ratings." + req.Pagination.SortBy + " " + direction) - } else { - query.Order("ebook_ratings.created_at DESC") - } - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&ratings).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *ebookRatingsRepository) GetByEbookId(ebookId uint, pagination *paginator.Pagination) (ratings []*entity.EbookRatings, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.EbookRatings{}). - Preload("User"). - Preload("Ebook"). - Preload("Purchase"). - Where("ebook_ratings.ebook_id = ? AND ebook_ratings.is_active = ?", ebookId, true) - - query.Count(&count) - - pagination.Count = count - pagination = paginator.Paging(pagination) - - err = query.Offset(pagination.Offset).Limit(pagination.Limit). - Order("ebook_ratings.created_at DESC"). - Find(&ratings).Error - if err != nil { - return - } - - paging = *pagination - - return -} - -func (_i *ebookRatingsRepository) GetByUserId(userId uint, pagination *paginator.Pagination) (ratings []*entity.EbookRatings, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.EbookRatings{}). - Preload("User"). - Preload("Ebook"). - Preload("Purchase"). - Where("ebook_ratings.user_id = ? AND ebook_ratings.is_active = ?", userId, true) - - query.Count(&count) - - pagination.Count = count - pagination = paginator.Paging(pagination) - - err = query.Offset(pagination.Offset).Limit(pagination.Limit). - Order("ebook_ratings.created_at DESC"). - Find(&ratings).Error - if err != nil { - return - } - - paging = *pagination - - return -} - -func (_i *ebookRatingsRepository) FindOne(id uint) (rating *entity.EbookRatings, err error) { - query := _i.DB.DB.Preload("User").Preload("Ebook").Preload("Purchase") - if err := query.First(&rating, id).Error; err != nil { - return nil, err - } - - return rating, nil -} - -func (_i *ebookRatingsRepository) FindByUserAndEbook(userId uint, ebookId uint) (rating *entity.EbookRatings, err error) { - query := _i.DB.DB.Where("user_id = ? AND ebook_id = ?", userId, ebookId) - - if err := query.First(&rating).Error; err != nil { - return nil, err - } - - return rating, nil -} - -func (_i *ebookRatingsRepository) FindByPurchaseId(purchaseId uint) (rating *entity.EbookRatings, err error) { - query := _i.DB.DB.Where("purchase_id = ?", purchaseId) - - if err := query.First(&rating).Error; err != nil { - return nil, err - } - - return rating, nil -} - -func (_i *ebookRatingsRepository) Create(rating *entity.EbookRatings) (ratingReturn *entity.EbookRatings, err error) { - result := _i.DB.DB.Create(rating) - return rating, result.Error -} - -func (_i *ebookRatingsRepository) Update(id uint, rating *entity.EbookRatings) (err error) { - return _i.DB.DB.Model(&entity.EbookRatings{}). - Where(&entity.EbookRatings{ID: id}). - Updates(rating).Error -} - -func (_i *ebookRatingsRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.EbookRatings{}, id).Error -} - -func (_i *ebookRatingsRepository) GetEbookRatingStats(ebookId uint) (totalRatings int, averageRating float64, ratingCounts map[int]int, err error) { - var stats struct { - TotalRatings int `json:"totalRatings"` - AverageRating float64 `json:"averageRating"` - } - - // Get total ratings and average - err = _i.DB.DB.Model(&entity.EbookRatings{}). - Select("COUNT(*) as total_ratings, COALESCE(AVG(rating), 0) as average_rating"). - Where("ebook_id = ? AND is_active = ? AND is_verified = ?", ebookId, true, true). - Scan(&stats).Error - if err != nil { - return 0, 0, nil, err - } - - // Get rating counts - var ratingCountsData []struct { - Rating int `json:"rating"` - Count int `json:"count"` - } - - err = _i.DB.DB.Model(&entity.EbookRatings{}). - Select("rating, COUNT(*) as count"). - Where("ebook_id = ? AND is_active = ? AND is_verified = ?", ebookId, true, true). - Group("rating"). - Scan(&ratingCountsData).Error - if err != nil { - return 0, 0, nil, err - } - - // Convert to map - ratingCounts = make(map[int]int) - for _, rc := range ratingCountsData { - ratingCounts[rc.Rating] = rc.Count - } - - // Ensure all ratings 1-5 are present - for i := 1; i <= 5; i++ { - if _, exists := ratingCounts[i]; !exists { - ratingCounts[i] = 0 - } - } - - return stats.TotalRatings, stats.AverageRating, ratingCounts, nil -} - -func (_i *ebookRatingsRepository) GetRecentReviews(ebookId uint, limit int) (reviews []*entity.EbookRatings, err error) { - query := _i.DB.DB.Model(&entity.EbookRatings{}). - Preload("User"). - Preload("Ebook"). - Preload("Purchase"). - Where("ebook_id = ? AND is_active = ? AND is_verified = ? AND review IS NOT NULL AND review != ''", ebookId, true, true). - Order("created_at DESC"). - Limit(limit) - - err = query.Find(&reviews).Error - return reviews, err -} diff --git a/app/module/ebooks/repository/ebook_wishlists.repository.go b/app/module/ebooks/repository/ebook_wishlists.repository.go deleted file mode 100644 index 6411c05..0000000 --- a/app/module/ebooks/repository/ebook_wishlists.repository.go +++ /dev/null @@ -1,79 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - - "github.com/rs/zerolog" -) - -type ebookWishlistsRepository struct { - DB *database.Database - Log zerolog.Logger -} - -// EbookWishlistsRepository define interface of IEbookWishlistsRepository -type EbookWishlistsRepository interface { - GetByUserId(userId uint, pagination *paginator.Pagination) (wishlists []*entity.EbookWishlists, paging paginator.Pagination, err error) - FindByUserAndEbook(userId uint, ebookId uint) (wishlist *entity.EbookWishlists, err error) - Create(wishlist *entity.EbookWishlists) (wishlistReturn *entity.EbookWishlists, err error) - Delete(id uint) (err error) - DeleteByUserAndEbook(userId uint, ebookId uint) (err error) -} - -func NewEbookWishlistsRepository(db *database.Database, log zerolog.Logger) EbookWishlistsRepository { - return &ebookWishlistsRepository{ - DB: db, - Log: log, - } -} - -func (_i *ebookWishlistsRepository) GetByUserId(userId uint, pagination *paginator.Pagination) (wishlists []*entity.EbookWishlists, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.EbookWishlists{}). - Preload("Ebook"). - Preload("Ebook.Author"). - Where("user_id = ?", userId) - - query.Count(&count) - - pagination.Count = count - pagination = paginator.Paging(pagination) - - err = query.Offset(pagination.Offset).Limit(pagination.Limit). - Order("created_at DESC"). - Find(&wishlists).Error - if err != nil { - return - } - - paging = *pagination - - return -} - -func (_i *ebookWishlistsRepository) FindByUserAndEbook(userId uint, ebookId uint) (wishlist *entity.EbookWishlists, err error) { - query := _i.DB.DB.Where("user_id = ? AND ebook_id = ?", userId, ebookId) - - if err := query.First(&wishlist).Error; err != nil { - return nil, err - } - - return wishlist, nil -} - -func (_i *ebookWishlistsRepository) Create(wishlist *entity.EbookWishlists) (wishlistReturn *entity.EbookWishlists, err error) { - result := _i.DB.DB.Create(wishlist) - return wishlist, result.Error -} - -func (_i *ebookWishlistsRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.EbookWishlists{}, id).Error -} - -func (_i *ebookWishlistsRepository) DeleteByUserAndEbook(userId uint, ebookId uint) error { - return _i.DB.DB.Where("user_id = ? AND ebook_id = ?", userId, ebookId). - Delete(&entity.EbookWishlists{}).Error -} diff --git a/app/module/ebooks/repository/ebooks.repository.go b/app/module/ebooks/repository/ebooks.repository.go deleted file mode 100644 index 8ac724a..0000000 --- a/app/module/ebooks/repository/ebooks.repository.go +++ /dev/null @@ -1,186 +0,0 @@ -package repository - -import ( - "fmt" - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/ebooks/request" - "jaecoo-be/app/module/ebooks/response" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "strings" - - "github.com/rs/zerolog" -) - -type ebooksRepository struct { - DB *database.Database - Log zerolog.Logger -} - -// EbooksRepository define interface of IEbooksRepository -type EbooksRepository interface { - GetAll(req request.EbooksQueryRequest) (ebooks []*entity.Ebooks, paging paginator.Pagination, err error) - FindOne(id uint) (ebook *entity.Ebooks, err error) - FindBySlug(slug string) (ebook *entity.Ebooks, err error) - Create(ebook *entity.Ebooks) (ebookReturn *entity.Ebooks, err error) - Update(id uint, ebook *entity.Ebooks) (err error) - UpdateSkipNull(id uint, ebook *entity.Ebooks) (err error) - Delete(id uint) (err error) - UpdateDownloadCount(id uint) (err error) - UpdatePurchaseCount(id uint) (err error) - UpdateWishlistCount(id uint) (err error) - SummaryStats(authorId uint) (ebookSummaryStats *response.EbookSummaryStats, err error) -} - -func NewEbooksRepository(db *database.Database, log zerolog.Logger) EbooksRepository { - return &ebooksRepository{ - DB: db, - Log: log, - } -} - -// implement interface of IEbooksRepository -func (_i *ebooksRepository) GetAll(req request.EbooksQueryRequest) (ebooks []*entity.Ebooks, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.Ebooks{}). - Preload("Author"). - Where("ebooks.is_active = ?", true) - - if req.Title != nil && *req.Title != "" { - title := strings.ToLower(*req.Title) - query = query.Where("LOWER(ebooks.title) LIKE ?", "%"+strings.ToLower(title)+"%") - } - if req.Description != nil && *req.Description != "" { - description := strings.ToLower(*req.Description) - query = query.Where("LOWER(ebooks.description) LIKE ?", "%"+strings.ToLower(description)+"%") - } - if req.AuthorId != nil { - query = query.Where("ebooks.author_id = ?", req.AuthorId) - } - if req.Category != nil && *req.Category != "" { - category := strings.ToLower(*req.Category) - query = query.Where("LOWER(ebooks.category) LIKE ?", "%"+strings.ToLower(category)+"%") - } - if req.Tags != nil && *req.Tags != "" { - tags := strings.ToLower(*req.Tags) - query = query.Where("LOWER(ebooks.tags) LIKE ?", "%"+strings.ToLower(tags)+"%") - } - if req.MinPrice != nil { - query = query.Where("ebooks.price >= ?", req.MinPrice) - } - if req.MaxPrice != nil { - query = query.Where("ebooks.price <= ?", req.MaxPrice) - } - if req.IsPublished != nil { - query = query.Where("ebooks.is_published = ?", req.IsPublished) - } - if req.StatusId != nil { - query = query.Where("ebooks.status_id = ?", req.StatusId) - } - - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction)) - } else { - direction := "DESC" - sortBy := "ebooks.created_at" - query.Order(fmt.Sprintf("%s %s", sortBy, direction)) - } - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&ebooks).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *ebooksRepository) FindOne(id uint) (ebook *entity.Ebooks, err error) { - query := _i.DB.DB.Preload("Author") - if err := query.First(&ebook, id).Error; err != nil { - return nil, err - } - - return ebook, nil -} - -func (_i *ebooksRepository) FindBySlug(slug string) (ebook *entity.Ebooks, err error) { - query := _i.DB.DB.Preload("Author").Where("slug = ?", slug) - - if err := query.First(&ebook).Error; err != nil { - return nil, err - } - - return ebook, nil -} - -func (_i *ebooksRepository) Create(ebook *entity.Ebooks) (ebookReturn *entity.Ebooks, err error) { - result := _i.DB.DB.Create(ebook) - return ebook, result.Error -} - -func (_i *ebooksRepository) Update(id uint, ebook *entity.Ebooks) (err error) { - ebookMap, err := utilSvc.StructToMap(ebook) - if err != nil { - return err - } - return _i.DB.DB.Model(&entity.Ebooks{}). - Where(&entity.Ebooks{ID: id}). - Updates(ebookMap).Error -} - -func (_i *ebooksRepository) UpdateSkipNull(id uint, ebook *entity.Ebooks) (err error) { - return _i.DB.DB.Model(&entity.Ebooks{}). - Where(&entity.Ebooks{ID: id}). - Updates(ebook).Error -} - -func (_i *ebooksRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.Ebooks{}, id).Error -} - -func (_i *ebooksRepository) UpdateDownloadCount(id uint) (err error) { - return _i.DB.DB.Model(&entity.Ebooks{}). - Where("id = ?", id). - Update("download_count", "download_count + 1").Error -} - -func (_i *ebooksRepository) UpdatePurchaseCount(id uint) (err error) { - return _i.DB.DB.Model(&entity.Ebooks{}). - Where("id = ?", id). - Update("purchase_count", "purchase_count + 1").Error -} - -func (_i *ebooksRepository) UpdateWishlistCount(id uint) (err error) { - return _i.DB.DB.Model(&entity.Ebooks{}). - Where("id = ?", id). - Update("wishlist_count", "wishlist_count + 1").Error -} - -func (_i *ebooksRepository) SummaryStats(authorId uint) (ebookSummaryStats *response.EbookSummaryStats, err error) { - query := _i.DB.DB.Model(&entity.Ebooks{}). - Select( - "COUNT(*) AS total_ebooks, "+ - "COALESCE(SUM(purchase_count), 0) AS total_sales, "+ - "COALESCE(SUM(price * purchase_count), 0) AS total_revenue, "+ - "COALESCE(SUM(download_count), 0) AS total_downloads, "+ - "COALESCE(SUM(wishlist_count), 0) AS total_wishlists, "+ - "COALESCE(AVG(rating), 0) AS average_rating"). - Where("author_id = ?", authorId) - - err = query.Scan(&ebookSummaryStats).Error - - return ebookSummaryStats, err -} diff --git a/app/module/ebooks/request/ebook_ratings.request.go b/app/module/ebooks/request/ebook_ratings.request.go deleted file mode 100644 index 1dd63eb..0000000 --- a/app/module/ebooks/request/ebook_ratings.request.go +++ /dev/null @@ -1,113 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -type EbookRatingsGeneric interface { - ToEntity() -} - -type EbookRatingsQueryRequest struct { - EbookId *uint `json:"ebookId"` - UserId *uint `json:"userId"` - Rating *int `json:"rating"` - IsVerified *bool `json:"isVerified"` - StatusId *int `json:"statusId"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type EbookRatingsCreateRequest struct { - EbookId uint `json:"ebookId" validate:"required"` - PurchaseId uint `json:"purchaseId" validate:"required"` - Rating int `json:"rating" validate:"required,min=1,max=5"` - Review *string `json:"review"` - IsAnonymous *bool `json:"isAnonymous"` -} - -func (req EbookRatingsCreateRequest) ToEntity() *entity.EbookRatings { - return &entity.EbookRatings{ - EbookId: req.EbookId, - PurchaseId: req.PurchaseId, - Rating: req.Rating, - Review: req.Review, - IsAnonymous: req.IsAnonymous, - IsVerified: boolPtr(true), - StatusId: intPtr(1), - IsActive: boolPtr(true), - } -} - -type EbookRatingsUpdateRequest struct { - Rating int `json:"rating" validate:"required,min=1,max=5"` - Review *string `json:"review"` - IsAnonymous *bool `json:"isAnonymous"` -} - -func (req EbookRatingsUpdateRequest) ToEntity() *entity.EbookRatings { - return &entity.EbookRatings{ - Rating: req.Rating, - Review: req.Review, - IsAnonymous: req.IsAnonymous, - UpdatedAt: time.Now(), - } -} - -type EbookRatingsQueryRequestContext struct { - EbookId string `json:"ebookId"` - UserId string `json:"userId"` - Rating string `json:"rating"` - IsVerified string `json:"isVerified"` - StatusId string `json:"statusId"` -} - -func (req EbookRatingsQueryRequestContext) ToParamRequest() EbookRatingsQueryRequest { - var request EbookRatingsQueryRequest - - if ebookIdStr := req.EbookId; ebookIdStr != "" { - ebookId, err := strconv.Atoi(ebookIdStr) - if err == nil { - ebookIdUint := uint(ebookId) - request.EbookId = &ebookIdUint - } - } - if userIdStr := req.UserId; userIdStr != "" { - userId, err := strconv.Atoi(userIdStr) - if err == nil { - userIdUint := uint(userId) - request.UserId = &userIdUint - } - } - if ratingStr := req.Rating; ratingStr != "" { - rating, err := strconv.Atoi(ratingStr) - if err == nil { - request.Rating = &rating - } - } - if isVerifiedStr := req.IsVerified; isVerifiedStr != "" { - isVerified, err := strconv.ParseBool(isVerifiedStr) - if err == nil { - request.IsVerified = &isVerified - } - } - if statusIdStr := req.StatusId; statusIdStr != "" { - statusId, err := strconv.Atoi(statusIdStr) - if err == nil { - request.StatusId = &statusId - } - } - - return request -} - -// Helper functions -func boolPtr(b bool) *bool { - return &b -} - -func intPtr(i int) *int { - return &i -} diff --git a/app/module/ebooks/request/ebooks.request.go b/app/module/ebooks/request/ebooks.request.go deleted file mode 100644 index 08cefa9..0000000 --- a/app/module/ebooks/request/ebooks.request.go +++ /dev/null @@ -1,178 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -type EbooksGeneric interface { - ToEntity() -} - -type EbooksQueryRequest struct { - Title *string `json:"title"` - Description *string `json:"description"` - AuthorId *uint `json:"authorId"` - Category *string `json:"category"` - Tags *string `json:"tags"` - MinPrice *float64 `json:"minPrice"` - MaxPrice *float64 `json:"maxPrice"` - StatusId *int `json:"statusId"` - IsPublished *bool `json:"isPublished"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type EbooksCreateRequest struct { - Title string `json:"title" validate:"required"` - Slug string `json:"slug" validate:"required"` - Description string `json:"description" validate:"required"` - Price float64 `json:"price" validate:"required,min=0"` - Category *string `json:"category"` - Tags *string `json:"tags"` - PageCount *int `json:"pageCount"` - Language *string `json:"language"` - Isbn *string `json:"isbn"` - Publisher *string `json:"publisher"` - PublishedYear *int `json:"publishedYear"` - IsPublished *bool `json:"isPublished"` - CreatedAt *string `json:"createdAt"` - CreatedById *uint `json:"createdById"` -} - -func (req EbooksCreateRequest) ToEntity() *entity.Ebooks { - return &entity.Ebooks{ - Title: req.Title, - Slug: req.Slug, - Description: req.Description, - Price: req.Price, - Category: req.Category, - Tags: req.Tags, - PageCount: req.PageCount, - Language: req.Language, - Isbn: req.Isbn, - Publisher: req.Publisher, - PublishedYear: req.PublishedYear, - IsPublished: req.IsPublished, - } -} - -type EbooksUpdateRequest struct { - Title string `json:"title" validate:"required"` - Slug string `json:"slug" validate:"required"` - Description string `json:"description" validate:"required"` - Price float64 `json:"price" validate:"required,min=0"` - Category *string `json:"category"` - Tags *string `json:"tags"` - PageCount *int `json:"pageCount"` - Language *string `json:"language"` - Isbn *string `json:"isbn"` - Publisher *string `json:"publisher"` - PublishedYear *int `json:"publishedYear"` - IsPublished *bool `json:"isPublished"` - StatusId *int `json:"statusId"` - CreatedAt *string `json:"createdAt"` - CreatedById *uint `json:"createdById"` -} - -func (req EbooksUpdateRequest) ToEntity() *entity.Ebooks { - if req.CreatedById == nil { - return &entity.Ebooks{ - Title: req.Title, - Slug: req.Slug, - Description: req.Description, - Price: req.Price, - Category: req.Category, - Tags: req.Tags, - PageCount: req.PageCount, - Language: req.Language, - Isbn: req.Isbn, - Publisher: req.Publisher, - PublishedYear: req.PublishedYear, - IsPublished: req.IsPublished, - StatusId: req.StatusId, - UpdatedAt: time.Now(), - } - } else { - return &entity.Ebooks{ - Title: req.Title, - Slug: req.Slug, - Description: req.Description, - Price: req.Price, - Category: req.Category, - Tags: req.Tags, - PageCount: req.PageCount, - Language: req.Language, - Isbn: req.Isbn, - Publisher: req.Publisher, - PublishedYear: req.PublishedYear, - IsPublished: req.IsPublished, - StatusId: req.StatusId, - CreatedById: req.CreatedById, - UpdatedAt: time.Now(), - } - } -} - -type EbooksQueryRequestContext struct { - Title string `json:"title"` - Description string `json:"description"` - AuthorId string `json:"authorId"` - Category string `json:"category"` - Tags string `json:"tags"` - MinPrice string `json:"minPrice"` - MaxPrice string `json:"maxPrice"` - StatusId string `json:"statusId"` - IsPublished string `json:"isPublished"` -} - -func (req EbooksQueryRequestContext) ToParamRequest() EbooksQueryRequest { - var request EbooksQueryRequest - - if title := req.Title; title != "" { - request.Title = &title - } - if description := req.Description; description != "" { - request.Description = &description - } - if category := req.Category; category != "" { - request.Category = &category - } - if tags := req.Tags; tags != "" { - request.Tags = &tags - } - if authorIdStr := req.AuthorId; authorIdStr != "" { - authorId, err := strconv.Atoi(authorIdStr) - if err == nil { - authorIdUint := uint(authorId) - request.AuthorId = &authorIdUint - } - } - if minPriceStr := req.MinPrice; minPriceStr != "" { - minPrice, err := strconv.ParseFloat(minPriceStr, 64) - if err == nil { - request.MinPrice = &minPrice - } - } - if maxPriceStr := req.MaxPrice; maxPriceStr != "" { - maxPrice, err := strconv.ParseFloat(maxPriceStr, 64) - if err == nil { - request.MaxPrice = &maxPrice - } - } - if isPublishedStr := req.IsPublished; isPublishedStr != "" { - isPublished, err := strconv.ParseBool(isPublishedStr) - if err == nil { - request.IsPublished = &isPublished - } - } - if statusIdStr := req.StatusId; statusIdStr != "" { - statusId, err := strconv.Atoi(statusIdStr) - if err == nil { - request.StatusId = &statusId - } - } - - return request -} diff --git a/app/module/ebooks/response/ebook_ratings.response.go b/app/module/ebooks/response/ebook_ratings.response.go deleted file mode 100644 index 124f466..0000000 --- a/app/module/ebooks/response/ebook_ratings.response.go +++ /dev/null @@ -1,43 +0,0 @@ -package response - -import ( - "time" -) - -type EbookRatingsResponse struct { - ID uint `json:"id"` - UserId uint `json:"userId"` - UserName *string `json:"userName"` - UserEmail *string `json:"userEmail"` - EbookId uint `json:"ebookId"` - EbookTitle *string `json:"ebookTitle"` - PurchaseId uint `json:"purchaseId"` - Rating int `json:"rating"` - Review *string `json:"review"` - IsAnonymous *bool `json:"isAnonymous"` - IsVerified *bool `json:"isVerified"` - StatusId *int `json:"statusId"` - IsActive *bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - -type EbookRatingSummaryResponse struct { - EbookId uint `json:"ebookId"` - EbookTitle string `json:"ebookTitle"` - AverageRating float64 `json:"averageRating"` - TotalRatings int `json:"totalRatings"` - RatingCounts map[int]int `json:"ratingCounts"` - RecentReviews []EbookRatingsResponse `json:"recentReviews"` -} - -type EbookRatingStatsResponse struct { - TotalRatings int `json:"totalRatings"` - AverageRating float64 `json:"averageRating"` - RatingCounts map[int]int `json:"ratingCounts"` - FiveStarCount int `json:"fiveStarCount"` - FourStarCount int `json:"fourStarCount"` - ThreeStarCount int `json:"threeStarCount"` - TwoStarCount int `json:"twoStarCount"` - OneStarCount int `json:"oneStarCount"` -} diff --git a/app/module/ebooks/response/ebooks.response.go b/app/module/ebooks/response/ebooks.response.go deleted file mode 100644 index 714e258..0000000 --- a/app/module/ebooks/response/ebooks.response.go +++ /dev/null @@ -1,79 +0,0 @@ -package response - -import ( - "time" -) - -type EbooksResponse struct { - ID uint `json:"id"` - Title string `json:"title"` - Slug string `json:"slug"` - Description string `json:"description"` - Price float64 `json:"price"` - PdfFilePath *string `json:"pdfFilePath"` - PdfFileName *string `json:"pdfFileName"` - PdfFileSize *int64 `json:"pdfFileSize"` - ThumbnailPath *string `json:"thumbnailPath"` - ThumbnailName *string `json:"thumbnailName"` - AuthorId uint `json:"authorId"` - AuthorName *string `json:"authorName"` - AuthorEmail *string `json:"authorEmail"` - Category *string `json:"category"` - Tags *string `json:"tags"` - PageCount *int `json:"pageCount"` - Language *string `json:"language"` - Isbn *string `json:"isbn"` - Publisher *string `json:"publisher"` - PublishedYear *int `json:"publishedYear"` - DownloadCount *int `json:"downloadCount"` - PurchaseCount *int `json:"purchaseCount"` - WishlistCount *int `json:"wishlistCount"` - Rating *float64 `json:"rating"` - ReviewCount *int `json:"reviewCount"` - StatusId *int `json:"statusId"` - IsActive *bool `json:"isActive"` - IsPublished *bool `json:"isPublished"` - PublishedAt *time.Time `json:"publishedAt"` - CreatedById *uint `json:"createdById"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - -type EbookWishlistResponse struct { - ID uint `json:"id"` - UserId uint `json:"userId"` - EbookId uint `json:"ebookId"` - Ebook *EbooksResponse `json:"ebook"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - -type EbookPurchaseResponse struct { - ID uint `json:"id"` - BuyerId uint `json:"buyerId"` - BuyerName *string `json:"buyerName"` - BuyerEmail *string `json:"buyerEmail"` - EbookId uint `json:"ebookId"` - Ebook *EbooksResponse `json:"ebook"` - PurchasePrice float64 `json:"purchasePrice"` - PaymentMethod *string `json:"paymentMethod"` - PaymentStatus *string `json:"paymentStatus"` - TransactionId *string `json:"transactionId"` - PaymentProof *string `json:"paymentProof"` - PaymentDate *time.Time `json:"paymentDate"` - DownloadCount *int `json:"downloadCount"` - LastDownloadAt *time.Time `json:"lastDownloadAt"` - StatusId *int `json:"statusId"` - IsActive *bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} - -type EbookSummaryStats struct { - TotalEbooks int `json:"totalEbooks"` - TotalSales int `json:"totalSales"` - TotalRevenue float64 `json:"totalRevenue"` - TotalDownloads int `json:"totalDownloads"` - TotalWishlists int `json:"totalWishlists"` - AverageRating float64 `json:"averageRating"` -} diff --git a/app/module/ebooks/service/ebook_purchases.service.go b/app/module/ebooks/service/ebook_purchases.service.go deleted file mode 100644 index 1e70c19..0000000 --- a/app/module/ebooks/service/ebook_purchases.service.go +++ /dev/null @@ -1,185 +0,0 @@ -package service - -import ( - "errors" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/ebooks/mapper" - "jaecoo-be/app/module/ebooks/repository" - "jaecoo-be/app/module/ebooks/response" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "time" - - "github.com/rs/zerolog" -) - -// EbookPurchasesService -type ebookPurchasesService struct { - Repo repository.EbookPurchasesRepository - EbooksRepo repository.EbooksRepository - Log zerolog.Logger - UsersRepo usersRepository.UsersRepository -} - -// EbookPurchasesService define interface of IEbookPurchasesService -type EbookPurchasesService interface { - GetByBuyerId(authToken string, pagination *paginator.Pagination) (purchases []*response.EbookPurchaseResponse, paging paginator.Pagination, err error) - PurchaseEbook(authToken string, ebookId uint, paymentMethod string) (purchase *response.EbookPurchaseResponse, err error) - UpdatePaymentStatus(purchaseId uint, paymentStatus string, transactionId string, paymentProof string) (err error) - GetPurchaseById(purchaseId uint) (purchase *response.EbookPurchaseResponse, err error) - ConfirmPayment(purchaseId uint) (err error) -} - -// NewEbookPurchasesService init EbookPurchasesService -func NewEbookPurchasesService( - repo repository.EbookPurchasesRepository, - ebooksRepo repository.EbooksRepository, - log zerolog.Logger, - usersRepo usersRepository.UsersRepository) EbookPurchasesService { - - return &ebookPurchasesService{ - Repo: repo, - EbooksRepo: ebooksRepo, - Log: log, - UsersRepo: usersRepo, - } -} - -// GetByBuyerId implement interface of EbookPurchasesService -func (_i *ebookPurchasesService) GetByBuyerId(authToken string, pagination *paginator.Pagination) (purchases []*response.EbookPurchaseResponse, paging paginator.Pagination, err error) { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return nil, paginator.Pagination{}, errors.New("user not found") - } - - purchasesData, paging, err := _i.Repo.GetByBuyerId(user.ID, pagination) - if err != nil { - return nil, paging, err - } - - purchases = mapper.ToEbookPurchaseResponseList(purchasesData) - - return purchases, paging, nil -} - -// PurchaseEbook implement interface of EbookPurchasesService -func (_i *ebookPurchasesService) PurchaseEbook(authToken string, ebookId uint, paymentMethod string) (purchase *response.EbookPurchaseResponse, err error) { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return nil, errors.New("user not found") - } - - // Check if ebook exists - ebook, err := _i.EbooksRepo.FindOne(ebookId) - if err != nil { - return nil, errors.New("ebook not found") - } - - // Check if already purchased - existingPurchase, err := _i.Repo.FindByBuyerAndEbook(user.ID, ebookId) - if err == nil && existingPurchase != nil { - return nil, errors.New("ebook already purchased") - } - - // Create purchase record - purchaseEntity := &entity.EbookPurchases{ - BuyerId: user.ID, - EbookId: ebookId, - PurchasePrice: ebook.Price, - PaymentMethod: &paymentMethod, - PaymentStatus: stringPtr("pending"), - StatusId: intPtr(1), - IsActive: boolPtr(true), - } - - purchaseData, err := _i.Repo.Create(purchaseEntity) - if err != nil { - return nil, err - } - - // Update purchase count - err = _i.EbooksRepo.UpdatePurchaseCount(ebookId) - if err != nil { - _i.Log.Error().Err(err).Msg("Failed to update purchase count") - } - - purchase = mapper.ToEbookPurchaseResponse(purchaseData) - - return purchase, nil -} - -// UpdatePaymentStatus implement interface of EbookPurchasesService -func (_i *ebookPurchasesService) UpdatePaymentStatus(purchaseId uint, paymentStatus string, transactionId string, paymentProof string) (err error) { - _, err = _i.Repo.FindOne(purchaseId) - if err != nil { - return errors.New("purchase not found") - } - - updateData := &entity.EbookPurchases{ - PaymentStatus: &paymentStatus, - TransactionId: &transactionId, - PaymentProof: &paymentProof, - } - - if paymentStatus == "paid" { - now := time.Now() - updateData.PaymentDate = &now - } - - err = _i.Repo.Update(purchaseId, updateData) - if err != nil { - return err - } - - return nil -} - -// GetPurchaseById implement interface of EbookPurchasesService -func (_i *ebookPurchasesService) GetPurchaseById(purchaseId uint) (purchase *response.EbookPurchaseResponse, err error) { - purchaseData, err := _i.Repo.FindOne(purchaseId) - if err != nil { - return nil, err - } - - purchase = mapper.ToEbookPurchaseResponse(purchaseData) - - return purchase, nil -} - -// ConfirmPayment implement interface of EbookPurchasesService -func (_i *ebookPurchasesService) ConfirmPayment(purchaseId uint) (err error) { - purchase, err := _i.Repo.FindOne(purchaseId) - if err != nil { - return errors.New("purchase not found") - } - - if purchase.PaymentStatus == nil || *purchase.PaymentStatus != "paid" { - return errors.New("payment not completed") - } - - // Update status to confirmed - updateData := &entity.EbookPurchases{ - StatusId: intPtr(2), // Assuming 2 is confirmed status - } - - err = _i.Repo.Update(purchaseId, updateData) - if err != nil { - return err - } - - return nil -} - -// Helper functions -func stringPtr(s string) *string { - return &s -} - -func intPtr(i int) *int { - return &i -} - -func boolPtr(b bool) *bool { - return &b -} diff --git a/app/module/ebooks/service/ebook_ratings.service.go b/app/module/ebooks/service/ebook_ratings.service.go deleted file mode 100644 index 07ff87d..0000000 --- a/app/module/ebooks/service/ebook_ratings.service.go +++ /dev/null @@ -1,280 +0,0 @@ -package service - -import ( - "errors" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/ebooks/mapper" - "jaecoo-be/app/module/ebooks/repository" - "jaecoo-be/app/module/ebooks/request" - "jaecoo-be/app/module/ebooks/response" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - - "github.com/rs/zerolog" -) - -// EbookRatingsService -type ebookRatingsService struct { - Repo repository.EbookRatingsRepository - EbooksRepo repository.EbooksRepository - EbookPurchasesRepo repository.EbookPurchasesRepository - Log zerolog.Logger - UsersRepo usersRepository.UsersRepository -} - -// EbookRatingsService define interface of IEbookRatingsService -type EbookRatingsService interface { - GetAll(req request.EbookRatingsQueryRequest) (ratings []*response.EbookRatingsResponse, paging paginator.Pagination, err error) - GetByEbookId(ebookId uint, pagination *paginator.Pagination) (ratings []*response.EbookRatingsResponse, paging paginator.Pagination, err error) - GetByUserId(authToken string, pagination *paginator.Pagination) (ratings []*response.EbookRatingsResponse, paging paginator.Pagination, err error) - GetEbookRatingSummary(ebookId uint) (summary *response.EbookRatingSummaryResponse, err error) - Create(req request.EbookRatingsCreateRequest, authToken string) (rating *response.EbookRatingsResponse, err error) - Update(id uint, req request.EbookRatingsUpdateRequest, authToken string) (err error) - Delete(id uint, authToken string) error - GetRatingStats(ebookId uint) (stats *response.EbookRatingStatsResponse, err error) -} - -// NewEbookRatingsService init EbookRatingsService -func NewEbookRatingsService( - repo repository.EbookRatingsRepository, - ebooksRepo repository.EbooksRepository, - ebookPurchasesRepo repository.EbookPurchasesRepository, - log zerolog.Logger, - usersRepo usersRepository.UsersRepository) EbookRatingsService { - - return &ebookRatingsService{ - Repo: repo, - EbooksRepo: ebooksRepo, - EbookPurchasesRepo: ebookPurchasesRepo, - Log: log, - UsersRepo: usersRepo, - } -} - -// GetAll implement interface of EbookRatingsService -func (_i *ebookRatingsService) GetAll(req request.EbookRatingsQueryRequest) (ratings []*response.EbookRatingsResponse, paging paginator.Pagination, err error) { - ratingsData, paging, err := _i.Repo.GetAll(req) - if err != nil { - return nil, paging, err - } - - ratings = mapper.ToEbookRatingsResponseList(ratingsData) - - return ratings, paging, nil -} - -// GetByEbookId implement interface of EbookRatingsService -func (_i *ebookRatingsService) GetByEbookId(ebookId uint, pagination *paginator.Pagination) (ratings []*response.EbookRatingsResponse, paging paginator.Pagination, err error) { - ratingsData, paging, err := _i.Repo.GetByEbookId(ebookId, pagination) - if err != nil { - return nil, paging, err - } - - ratings = mapper.ToEbookRatingsResponseList(ratingsData) - - return ratings, paging, nil -} - -// GetByUserId implement interface of EbookRatingsService -func (_i *ebookRatingsService) GetByUserId(authToken string, pagination *paginator.Pagination) (ratings []*response.EbookRatingsResponse, paging paginator.Pagination, err error) { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return nil, paginator.Pagination{}, errors.New("user not found") - } - - ratingsData, paging, err := _i.Repo.GetByUserId(user.ID, pagination) - if err != nil { - return nil, paging, err - } - - ratings = mapper.ToEbookRatingsResponseList(ratingsData) - - return ratings, paging, nil -} - -// GetEbookRatingSummary implement interface of EbookRatingsService -func (_i *ebookRatingsService) GetEbookRatingSummary(ebookId uint) (summary *response.EbookRatingSummaryResponse, err error) { - // Get ebook info - ebook, err := _i.EbooksRepo.FindOne(ebookId) - if err != nil { - return nil, errors.New("ebook not found") - } - - // Get rating stats - totalRatings, averageRating, ratingCounts, err := _i.Repo.GetEbookRatingStats(ebookId) - if err != nil { - return nil, err - } - - // Get recent reviews - recentReviews, err := _i.Repo.GetRecentReviews(ebookId, 5) - if err != nil { - return nil, err - } - - summary = mapper.ToEbookRatingSummaryResponse(ebookId, ebook.Title, averageRating, totalRatings, ratingCounts, recentReviews) - - return summary, nil -} - -// Create implement interface of EbookRatingsService -func (_i *ebookRatingsService) Create(req request.EbookRatingsCreateRequest, authToken string) (rating *response.EbookRatingsResponse, err error) { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return nil, errors.New("user not found") - } - - // Check if ebook exists - _, err = _i.EbooksRepo.FindOne(req.EbookId) - if err != nil { - return nil, errors.New("ebook not found") - } - - // Check if purchase exists and belongs to user - purchase, err := _i.EbookPurchasesRepo.FindOne(req.PurchaseId) - if err != nil { - return nil, errors.New("purchase not found") - } - - if purchase.BuyerId != user.ID { - return nil, errors.New("purchase does not belong to user") - } - - if purchase.EbookId != req.EbookId { - return nil, errors.New("purchase does not match ebook") - } - - if purchase.PaymentStatus == nil || *purchase.PaymentStatus != "paid" { - return nil, errors.New("payment not completed") - } - - // Check if user already rated this ebook - existingRating, err := _i.Repo.FindByUserAndEbook(user.ID, req.EbookId) - if err == nil && existingRating != nil { - return nil, errors.New("user already rated this ebook") - } - - // Check if user already rated this purchase - existingPurchaseRating, err := _i.Repo.FindByPurchaseId(req.PurchaseId) - if err == nil && existingPurchaseRating != nil { - return nil, errors.New("user already rated this purchase") - } - - // Create rating - ratingEntity := req.ToEntity() - ratingEntity.UserId = user.ID - - ratingData, err := _i.Repo.Create(ratingEntity) - if err != nil { - return nil, err - } - - // Update ebook rating stats - err = _i.updateEbookRatingStats(req.EbookId) - if err != nil { - _i.Log.Error().Err(err).Msg("Failed to update ebook rating stats") - } - - rating = mapper.ToEbookRatingsResponse(ratingData) - - return rating, nil -} - -// Update implement interface of EbookRatingsService -func (_i *ebookRatingsService) Update(id uint, req request.EbookRatingsUpdateRequest, authToken string) (err error) { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return errors.New("user not found") - } - - // Check if rating exists and belongs to user - existingRating, err := _i.Repo.FindOne(id) - if err != nil { - return errors.New("rating not found") - } - - if existingRating.UserId != user.ID { - return errors.New("rating does not belong to user") - } - - // Update rating - ratingEntity := req.ToEntity() - err = _i.Repo.Update(id, ratingEntity) - if err != nil { - return err - } - - // Update ebook rating stats - err = _i.updateEbookRatingStats(existingRating.EbookId) - if err != nil { - _i.Log.Error().Err(err).Msg("Failed to update ebook rating stats") - } - - return nil -} - -// Delete implement interface of EbookRatingsService -func (_i *ebookRatingsService) Delete(id uint, authToken string) error { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return errors.New("user not found") - } - - // Check if rating exists and belongs to user - existingRating, err := _i.Repo.FindOne(id) - if err != nil { - return errors.New("rating not found") - } - - if existingRating.UserId != user.ID { - return errors.New("rating does not belong to user") - } - - // Delete rating - err = _i.Repo.Delete(id) - if err != nil { - return err - } - - // Update ebook rating stats - err = _i.updateEbookRatingStats(existingRating.EbookId) - if err != nil { - _i.Log.Error().Err(err).Msg("Failed to update ebook rating stats") - } - - return nil -} - -// GetRatingStats implement interface of EbookRatingsService -func (_i *ebookRatingsService) GetRatingStats(ebookId uint) (stats *response.EbookRatingStatsResponse, err error) { - totalRatings, averageRating, ratingCounts, err := _i.Repo.GetEbookRatingStats(ebookId) - if err != nil { - return nil, err - } - - stats = mapper.ToEbookRatingStatsResponse(totalRatings, averageRating, ratingCounts) - - return stats, nil -} - -// updateEbookRatingStats updates the rating statistics in the ebook table -func (_i *ebookRatingsService) updateEbookRatingStats(ebookId uint) error { - totalRatings, averageRating, _, err := _i.Repo.GetEbookRatingStats(ebookId) - if err != nil { - return err - } - - // Update ebook with new rating stats - ebookUpdate := &entity.Ebooks{ - Rating: &averageRating, - ReviewCount: &totalRatings, - } - - err = _i.EbooksRepo.UpdateSkipNull(ebookId, ebookUpdate) - if err != nil { - return err - } - - return nil -} diff --git a/app/module/ebooks/service/ebook_wishlists.service.go b/app/module/ebooks/service/ebook_wishlists.service.go deleted file mode 100644 index 8864cf8..0000000 --- a/app/module/ebooks/service/ebook_wishlists.service.go +++ /dev/null @@ -1,138 +0,0 @@ -package service - -import ( - "errors" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/ebooks/mapper" - "jaecoo-be/app/module/ebooks/repository" - "jaecoo-be/app/module/ebooks/response" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - - "github.com/rs/zerolog" -) - -// EbookWishlistsService -type ebookWishlistsService struct { - Repo repository.EbookWishlistsRepository - EbooksRepo repository.EbooksRepository - Log zerolog.Logger - UsersRepo usersRepository.UsersRepository -} - -// EbookWishlistsService define interface of IEbookWishlistsService -type EbookWishlistsService interface { - GetByUserId(authToken string, pagination *paginator.Pagination) (wishlists []*response.EbookWishlistResponse, paging paginator.Pagination, err error) - AddToWishlist(authToken string, ebookId uint) (err error) - RemoveFromWishlist(authToken string, ebookId uint) (err error) - IsInWishlist(authToken string, ebookId uint) (isInWishlist bool, err error) -} - -// NewEbookWishlistsService init EbookWishlistsService -func NewEbookWishlistsService( - repo repository.EbookWishlistsRepository, - ebooksRepo repository.EbooksRepository, - log zerolog.Logger, - usersRepo usersRepository.UsersRepository) EbookWishlistsService { - - return &ebookWishlistsService{ - Repo: repo, - EbooksRepo: ebooksRepo, - Log: log, - UsersRepo: usersRepo, - } -} - -// GetByUserId implement interface of EbookWishlistsService -func (_i *ebookWishlistsService) GetByUserId(authToken string, pagination *paginator.Pagination) (wishlists []*response.EbookWishlistResponse, paging paginator.Pagination, err error) { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return nil, paginator.Pagination{}, errors.New("user not found") - } - - wishlistsData, paging, err := _i.Repo.GetByUserId(user.ID, pagination) - if err != nil { - return nil, paging, err - } - - wishlists = mapper.ToEbookWishlistResponseList(wishlistsData) - - return wishlists, paging, nil -} - -// AddToWishlist implement interface of EbookWishlistsService -func (_i *ebookWishlistsService) AddToWishlist(authToken string, ebookId uint) (err error) { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return errors.New("user not found") - } - - // Check if ebook exists - _, err = _i.EbooksRepo.FindOne(ebookId) - if err != nil { - return errors.New("ebook not found") - } - - // Check if already in wishlist - existingWishlist, err := _i.Repo.FindByUserAndEbook(user.ID, ebookId) - if err == nil && existingWishlist != nil { - return errors.New("ebook already in wishlist") - } - - // Add to wishlist - wishlist := &entity.EbookWishlists{ - UserId: user.ID, - EbookId: ebookId, - } - - _, err = _i.Repo.Create(wishlist) - if err != nil { - return err - } - - // Update wishlist count - err = _i.EbooksRepo.UpdateWishlistCount(ebookId) - if err != nil { - _i.Log.Error().Err(err).Msg("Failed to update wishlist count") - } - - return nil -} - -// RemoveFromWishlist implement interface of EbookWishlistsService -func (_i *ebookWishlistsService) RemoveFromWishlist(authToken string, ebookId uint) (err error) { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return errors.New("user not found") - } - - // Check if in wishlist - existingWishlist, err := _i.Repo.FindByUserAndEbook(user.ID, ebookId) - if err != nil || existingWishlist == nil { - return errors.New("ebook not in wishlist") - } - - // Remove from wishlist - err = _i.Repo.Delete(existingWishlist.ID) - if err != nil { - return err - } - - return nil -} - -// IsInWishlist implement interface of EbookWishlistsService -func (_i *ebookWishlistsService) IsInWishlist(authToken string, ebookId uint) (isInWishlist bool, err error) { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return false, errors.New("user not found") - } - - existingWishlist, err := _i.Repo.FindByUserAndEbook(user.ID, ebookId) - if err != nil { - return false, nil // Not in wishlist - } - - return existingWishlist != nil, nil -} diff --git a/app/module/ebooks/service/ebooks.service.go b/app/module/ebooks/service/ebooks.service.go deleted file mode 100644 index 3e6b844..0000000 --- a/app/module/ebooks/service/ebooks.service.go +++ /dev/null @@ -1,365 +0,0 @@ -package service - -import ( - "context" - "errors" - "fmt" - "io" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/ebooks/mapper" - "jaecoo-be/app/module/ebooks/repository" - "jaecoo-be/app/module/ebooks/request" - "jaecoo-be/app/module/ebooks/response" - usersRepository "jaecoo-be/app/module/users/repository" - config "jaecoo-be/config/config" - minioStorage "jaecoo-be/config/config" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "path/filepath" - "strconv" - "strings" - "time" - - "github.com/gofiber/fiber/v2" - "github.com/minio/minio-go/v7" - "github.com/rs/zerolog" -) - -// EbooksService -type ebooksService struct { - Repo repository.EbooksRepository - WishlistRepo repository.EbookWishlistsRepository - PurchaseRepo repository.EbookPurchasesRepository - Log zerolog.Logger - Cfg *config.Config - UsersRepo usersRepository.UsersRepository - MinioStorage *minioStorage.MinioStorage -} - -// EbooksService define interface of IEbooksService -type EbooksService interface { - All(req request.EbooksQueryRequest) (ebooks []*response.EbooksResponse, paging paginator.Pagination, err error) - Show(id uint) (ebook *response.EbooksResponse, err error) - ShowBySlug(slug string) (ebook *response.EbooksResponse, err error) - Save(req request.EbooksCreateRequest, authToken string) (ebook *entity.Ebooks, err error) - SavePdfFile(c *fiber.Ctx, ebookId uint) (err error) - SaveThumbnail(c *fiber.Ctx, ebookId uint) (err error) - Update(id uint, req request.EbooksUpdateRequest) (err error) - Delete(id uint) error - SummaryStats(authToken string) (summaryStats *response.EbookSummaryStats, err error) - DownloadPdf(c *fiber.Ctx, ebookId uint) error -} - -// NewEbooksService init EbooksService -func NewEbooksService( - repo repository.EbooksRepository, - wishlistRepo repository.EbookWishlistsRepository, - purchaseRepo repository.EbookPurchasesRepository, - log zerolog.Logger, - cfg *config.Config, - usersRepo usersRepository.UsersRepository, - minioStorage *minioStorage.MinioStorage) EbooksService { - - return &ebooksService{ - Repo: repo, - WishlistRepo: wishlistRepo, - PurchaseRepo: purchaseRepo, - Log: log, - UsersRepo: usersRepo, - MinioStorage: minioStorage, - Cfg: cfg, - } -} - -// All implement interface of EbooksService -func (_i *ebooksService) All(req request.EbooksQueryRequest) (ebooks []*response.EbooksResponse, paging paginator.Pagination, err error) { - ebooksData, paging, err := _i.Repo.GetAll(req) - if err != nil { - return nil, paging, err - } - - ebooks = mapper.ToEbooksResponseList(ebooksData) - - return ebooks, paging, nil -} - -// Show implement interface of EbooksService -func (_i *ebooksService) Show(id uint) (ebook *response.EbooksResponse, err error) { - ebookData, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - - ebook = mapper.ToEbooksResponse(ebookData) - - return ebook, nil -} - -// ShowBySlug implement interface of EbooksService -func (_i *ebooksService) ShowBySlug(slug string) (ebook *response.EbooksResponse, err error) { - ebookData, err := _i.Repo.FindBySlug(slug) - if err != nil { - return nil, err - } - - ebook = mapper.ToEbooksResponse(ebookData) - - return ebook, nil -} - -// Save implement interface of EbooksService -func (_i *ebooksService) Save(req request.EbooksCreateRequest, authToken string) (ebook *entity.Ebooks, err error) { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return nil, errors.New("user not found") - } - - ebookEntity := req.ToEntity() - ebookEntity.AuthorId = user.ID - ebookEntity.CreatedById = &user.ID - - ebookData, err := _i.Repo.Create(ebookEntity) - if err != nil { - return nil, err - } - - return ebookData, nil -} - -// SavePdfFile implement interface of EbooksService -func (_i *ebooksService) SavePdfFile(c *fiber.Ctx, ebookId uint) (err error) { - // Get the uploaded file - file, err := c.FormFile("file") - if err != nil { - return errors.New("file is required") - } - - // Validate file type - contentType := file.Header.Get("Content-Type") - if contentType != "application/pdf" { - return errors.New("only PDF files are allowed") - } - - // Validate file size (max 50MB) - if file.Size > 50*1024*1024 { - return errors.New("file size must be less than 50MB") - } - - // Generate unique filename - ext := filepath.Ext(file.Filename) - filename := fmt.Sprintf("ebook_%d_%d%s", ebookId, time.Now().Unix(), ext) - - // Upload to MinIO - fileReader, err := file.Open() - if err != nil { - return err - } - defer fileReader.Close() - - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - minioClient, err := _i.MinioStorage.ConnectMinio() - if err != nil { - return err - } - - objectName := fmt.Sprintf("ebooks/pdfs/%s", filename) - _, err = minioClient.PutObject( - context.Background(), - bucketName, - objectName, - fileReader, - file.Size, - minio.PutObjectOptions{ - ContentType: contentType, - }, - ) - if err != nil { - return err - } - - // Update ebook record with file info - ebookUpdate := &entity.Ebooks{ - PdfFilePath: &objectName, - PdfFileName: &filename, - PdfFileSize: &file.Size, - } - - err = _i.Repo.UpdateSkipNull(ebookId, ebookUpdate) - if err != nil { - return err - } - - return nil -} - -// SaveThumbnail implement interface of EbooksService -func (_i *ebooksService) SaveThumbnail(c *fiber.Ctx, ebookId uint) (err error) { - // Get the uploaded file - file, err := c.FormFile("file") - if err != nil { - return errors.New("file is required") - } - - // Validate file type - contentType := file.Header.Get("Content-Type") - if !strings.HasPrefix(contentType, "image/") { - return errors.New("only image files are allowed") - } - - // Validate file size (max 5MB) - if file.Size > 5*1024*1024 { - return errors.New("file size must be less than 5MB") - } - - // Generate unique filename - ext := filepath.Ext(file.Filename) - filename := fmt.Sprintf("ebook_thumbnail_%d_%d%s", ebookId, time.Now().Unix(), ext) - - // Upload to MinIO - fileReader, err := file.Open() - if err != nil { - return err - } - defer fileReader.Close() - - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - minioClient, err := _i.MinioStorage.ConnectMinio() - if err != nil { - return err - } - - objectName := fmt.Sprintf("ebooks/thumbnails/%s", filename) - _, err = minioClient.PutObject( - context.Background(), - bucketName, - objectName, - fileReader, - file.Size, - minio.PutObjectOptions{ - ContentType: contentType, - }, - ) - if err != nil { - return err - } - - // Update ebook record with thumbnail info - ebookUpdate := &entity.Ebooks{ - ThumbnailPath: &objectName, - ThumbnailName: &filename, - } - - err = _i.Repo.UpdateSkipNull(ebookId, ebookUpdate) - if err != nil { - return err - } - - return nil -} - -// Update implement interface of EbooksService -func (_i *ebooksService) Update(id uint, req request.EbooksUpdateRequest) (err error) { - ebookEntity := req.ToEntity() - err = _i.Repo.Update(id, ebookEntity) - if err != nil { - return err - } - - return nil -} - -// Delete implement interface of EbooksService -func (_i *ebooksService) Delete(id uint) error { - err := _i.Repo.Delete(id) - if err != nil { - return err - } - - return nil -} - -// SummaryStats implement interface of EbooksService -func (_i *ebooksService) SummaryStats(authToken string) (summaryStats *response.EbookSummaryStats, err error) { - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return nil, errors.New("user not found") - } - - summaryStats, err = _i.Repo.SummaryStats(user.ID) - if err != nil { - return nil, err - } - - return summaryStats, nil -} - -// DownloadPdf implement interface of EbooksService -func (_i *ebooksService) DownloadPdf(c *fiber.Ctx, ebookId uint) error { - // Get ebook data - ebook, err := _i.Repo.FindOne(ebookId) - if err != nil { - return err - } - - if ebook.PdfFilePath == nil { - return errors.New("PDF file not found") - } - - // Check if user has purchased this ebook - authToken := c.Get("Authorization") - user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if user == nil { - return errors.New("user not found") - } - - purchase, err := _i.PurchaseRepo.FindByBuyerAndEbook(user.ID, ebookId) - if err != nil { - return errors.New("you must purchase this ebook before downloading") - } - - if purchase.PaymentStatus == nil || *purchase.PaymentStatus != "paid" { - return errors.New("payment not completed") - } - - // Get file from MinIO - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - minioClient, err := _i.MinioStorage.ConnectMinio() - if err != nil { - return err - } - - object, err := minioClient.GetObject( - context.Background(), - bucketName, - *ebook.PdfFilePath, - minio.GetObjectOptions{}, - ) - if err != nil { - return err - } - defer object.Close() - - // Read file content - fileContent, err := io.ReadAll(object) - if err != nil { - return err - } - - // Update download count - err = _i.Repo.UpdateDownloadCount(ebookId) - if err != nil { - _i.Log.Error().Err(err).Msg("Failed to update download count") - } - - err = _i.PurchaseRepo.UpdateDownloadCount(purchase.ID) - if err != nil { - _i.Log.Error().Err(err).Msg("Failed to update purchase download count") - } - - // Set response headers - c.Set("Content-Type", "application/pdf") - c.Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", *ebook.PdfFileName)) - c.Set("Content-Length", strconv.Itoa(len(fileContent))) - - return c.Send(fileContent) -} diff --git a/app/module/education_history/controller/controller.go b/app/module/education_history/controller/controller.go deleted file mode 100644 index 93c1fd8..0000000 --- a/app/module/education_history/controller/controller.go +++ /dev/null @@ -1,13 +0,0 @@ -package controller - -import "jaecoo-be/app/module/education_history/service" - -type Controller struct { - EducationHistory EducationHistoryController -} - -func NewController(EducationHistoryService service.EducationHistoryService) *Controller { - return &Controller{ - EducationHistory: NewEducationHistoryController(EducationHistoryService), - } -} diff --git a/app/module/education_history/controller/education_history.controller.go b/app/module/education_history/controller/education_history.controller.go deleted file mode 100644 index 854c96d..0000000 --- a/app/module/education_history/controller/education_history.controller.go +++ /dev/null @@ -1,257 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/education_history/request" - "jaecoo-be/app/module/education_history/service" - "jaecoo-be/utils/paginator" - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" - "strconv" - - "github.com/gofiber/fiber/v2" -) - -type educationHistoryController struct { - educationHistoryService service.EducationHistoryService -} - -type EducationHistoryController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error - UploadCertificate(c *fiber.Ctx) error -} - -func NewEducationHistoryController(educationHistoryService service.EducationHistoryService) EducationHistoryController { - return &educationHistoryController{ - educationHistoryService: educationHistoryService, - } -} - -// All Education History -// @Summary Get all Education History -// @Description API for getting all Education History for specific user -// @Tags Education History -// @Param req query request.EducationHistoryQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 500 {object} response.InternalServerError -// @Router /education-history [get] -func (_i *educationHistoryController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - reqContext := request.EducationHistoryQueryRequestContext{ - UserID: c.Query("userId"), - SchoolName: c.Query("schoolName"), - Major: c.Query("major"), - EducationLevel: c.Query("educationLevel"), - GraduationYear: c.Query("graduationYear"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - educationData, paging, err := _i.educationHistoryService.All(req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Education history list successfully retrieved"}, - Data: educationData, - Meta: paging, - }) -} - -// Show Education History -// @Summary Get one Education History -// @Description API for getting one Education History -// @Tags Education History -// @Param id path int true "Education History ID" -// @Param userId query uint true "User ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 500 {object} response.InternalServerError -// @Router /education-history/{id} [get] -func (_i *educationHistoryController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - userId, err := strconv.ParseUint(c.Query("userId"), 10, 0) - if err != nil { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"userId parameter is required and must be a valid number"}, - }) - } - - educationData, err := _i.educationHistoryService.Show(uint(userId), uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Education history successfully retrieved"}, - Data: educationData, - }) -} - -// Save Education History -// @Summary Create Education History -// @Description API for create Education History -// @Tags Education History -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param userId query uint true "User ID" -// @Param payload body request.EducationHistoryCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 500 {object} response.InternalServerError -// @Router /education-history [post] -func (_i *educationHistoryController) Save(c *fiber.Ctx) error { - userId, err := strconv.ParseUint(c.Query("userId"), 10, 0) - if err != nil { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"userId parameter is required and must be a valid number"}, - }) - } - - req := new(request.EducationHistoryCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - dataResult, err := _i.educationHistoryService.Save(uint(userId), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Education history successfully created"}, - Data: dataResult, - }) -} - -// Update Education History -// @Summary Update Education History -// @Description API for update Education History -// @Tags Education History -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Education History ID" -// @Param userId query uint true "User ID" -// @Param payload body request.EducationHistoryUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 500 {object} response.InternalServerError -// @Router /education-history/{id} [put] -func (_i *educationHistoryController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - userId, err := strconv.ParseUint(c.Query("userId"), 10, 0) - if err != nil { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"userId parameter is required and must be a valid number"}, - }) - } - - req := new(request.EducationHistoryUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.educationHistoryService.Update(uint(userId), uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Education history successfully updated"}, - }) -} - -// Delete Education History -// @Summary Delete Education History -// @Description API for delete Education History -// @Tags Education History -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Education History ID" -// @Param userId query uint true "User ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 500 {object} response.InternalServerError -// @Router /education-history/{id} [delete] -func (_i *educationHistoryController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - userId, err := strconv.ParseUint(c.Query("userId"), 10, 0) - if err != nil { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"userId parameter is required and must be a valid number"}, - }) - } - - err = _i.educationHistoryService.Delete(uint(userId), uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Education history successfully deleted"}, - }) -} - -// UploadCertificate Education History -// @Summary Upload Certificate for Education History -// @Description API for upload certificate image for Education History -// @Tags Education History -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Education History ID" -// @Param userId query uint true "User ID" -// @Param certificate formData file true "Certificate image file" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 500 {object} response.InternalServerError -// @Router /education-history/{id}/certificate [post] -func (_i *educationHistoryController) UploadCertificate(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - userId, err := strconv.ParseUint(c.Query("userId"), 10, 0) - if err != nil { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"userId parameter is required and must be a valid number"}, - }) - } - - err = _i.educationHistoryService.UploadCertificate(uint(userId), uint(id), c) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Certificate successfully uploaded"}, - }) -} diff --git a/app/module/education_history/education_history.module.go b/app/module/education_history/education_history.module.go deleted file mode 100644 index f8b95bd..0000000 --- a/app/module/education_history/education_history.module.go +++ /dev/null @@ -1,55 +0,0 @@ -package education_history - -import ( - "jaecoo-be/app/module/education_history/controller" - "jaecoo-be/app/module/education_history/repository" - "jaecoo-be/app/module/education_history/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of EducationHistoryRouter -type EducationHistoryRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// register bulky of EducationHistory module -var NewEducationHistoryModule = fx.Options( - // register repository of EducationHistory module - fx.Provide(repository.NewEducationHistoryRepository), - - // register service of EducationHistory module - fx.Provide(service.NewEducationHistoryService), - - // register controller of EducationHistory module - fx.Provide(controller.NewController), - - // register router of EducationHistory module - fx.Provide(NewEducationHistoryRouter), -) - -// init EducationHistoryRouter -func NewEducationHistoryRouter(fiber *fiber.App, controller *controller.Controller) *EducationHistoryRouter { - return &EducationHistoryRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of EducationHistory module -func (_i *EducationHistoryRouter) RegisterEducationHistoryRoutes() { - // define controllers - educationHistoryController := _i.Controller.EducationHistory - - // define routes - _i.App.Route("/education-history", func(router fiber.Router) { - router.Get("/", educationHistoryController.All) - router.Get("/:id", educationHistoryController.Show) - router.Post("/", educationHistoryController.Save) - router.Put("/:id", educationHistoryController.Update) - router.Delete("/:id", educationHistoryController.Delete) - router.Post("/:id/certificate", educationHistoryController.UploadCertificate) - }) -} diff --git a/app/module/education_history/mapper/education_history.mapper.go b/app/module/education_history/mapper/education_history.mapper.go deleted file mode 100644 index ac94a74..0000000 --- a/app/module/education_history/mapper/education_history.mapper.go +++ /dev/null @@ -1,31 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/education_history/response" -) - -func EducationHistoryResponseMapper(educationHistory *entity.EducationHistory) *response.EducationHistoryResponse { - result := &response.EducationHistoryResponse{ - ID: educationHistory.ID, - UserID: educationHistory.UserID, - SchoolName: educationHistory.SchoolName, - Major: educationHistory.Major, - EducationLevel: educationHistory.EducationLevel, - GraduationYear: educationHistory.GraduationYear, - CertificateImage: educationHistory.CertificateImage, - CreatedAt: educationHistory.CreatedAt, - UpdatedAt: educationHistory.UpdatedAt, - } - - if educationHistory.User != nil { - result.User = &response.UserBasicInfo{ - ID: educationHistory.User.ID, - Username: educationHistory.User.Username, - Fullname: educationHistory.User.Fullname, - Email: educationHistory.User.Email, - } - } - - return result -} diff --git a/app/module/education_history/repository/education_history.repository.go b/app/module/education_history/repository/education_history.repository.go deleted file mode 100644 index 9f9c6c5..0000000 --- a/app/module/education_history/repository/education_history.repository.go +++ /dev/null @@ -1,87 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/education_history/request" - "jaecoo-be/utils/paginator" -) - -type educationHistoryRepository struct { - DB *database.Database -} - -type EducationHistoryRepository interface { - GetAll(userId uint, req request.EducationHistoryQueryRequest) (educationHistories []*entity.EducationHistory, paging paginator.Pagination, err error) - FindOneByUserAndId(userId uint, id uint) (educationHistory *entity.EducationHistory, err error) - Create(educationHistory *entity.EducationHistory) (result *entity.EducationHistory, err error) - Update(userId uint, id uint, educationHistory *entity.EducationHistory) (err error) - Delete(userId uint, id uint) (err error) -} - -func NewEducationHistoryRepository(db *database.Database) EducationHistoryRepository { - return &educationHistoryRepository{ - DB: db, - } -} - -func (_i *educationHistoryRepository) GetAll(userId uint, req request.EducationHistoryQueryRequest) (educationHistories []*entity.EducationHistory, paging paginator.Pagination, err error) { - query := _i.DB.DB.Where("user_id = ?", userId) - - // Apply filters - if req.SchoolName != nil { - query = query.Where("school_name ILIKE ?", "%"+*req.SchoolName+"%") - } - if req.Major != nil { - query = query.Where("major ILIKE ?", "%"+*req.Major+"%") - } - if req.EducationLevel != nil { - query = query.Where("education_level = ?", *req.EducationLevel) - } - if req.GraduationYear != nil { - query = query.Where("graduation_year = ?", *req.GraduationYear) - } - - // Include user relationship - query = query.Preload("User") - - // Order by graduation year desc - query = query.Order("graduation_year DESC") - - // Apply pagination - var count int64 - query.Count(&count) - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&educationHistories).Error - paging = *req.Pagination - - return -} - -func (_i *educationHistoryRepository) FindOneByUserAndId(userId uint, id uint) (educationHistory *entity.EducationHistory, err error) { - err = _i.DB.DB.Where("user_id = ? AND id = ?", userId, id).Preload("User").First(&educationHistory).Error - return -} - -func (_i *educationHistoryRepository) Create(educationHistory *entity.EducationHistory) (result *entity.EducationHistory, err error) { - err = _i.DB.DB.Create(educationHistory).Error - if err != nil { - return nil, err - } - - // Reload with relationships - err = _i.DB.DB.Preload("User").First(&result, educationHistory.ID).Error - return -} - -func (_i *educationHistoryRepository) Update(userId uint, id uint, educationHistory *entity.EducationHistory) (err error) { - err = _i.DB.DB.Where("user_id = ? AND id = ?", userId, id).Updates(educationHistory).Error - return -} - -func (_i *educationHistoryRepository) Delete(userId uint, id uint) (err error) { - err = _i.DB.DB.Where("user_id = ? AND id = ?", userId, id).Delete(&entity.EducationHistory{}).Error - return -} diff --git a/app/module/education_history/request/education_history.request.go b/app/module/education_history/request/education_history.request.go deleted file mode 100644 index 4d17a51..0000000 --- a/app/module/education_history/request/education_history.request.go +++ /dev/null @@ -1,100 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" -) - -type EducationHistoryQueryRequest struct { - UserID uint `json:"userId" validate:"required"` - SchoolName *string `json:"schoolName"` - Major *string `json:"major"` - EducationLevel *string `json:"educationLevel"` - GraduationYear *int `json:"graduationYear"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type EducationHistoryCreateRequest struct { - SchoolName string `json:"schoolName" validate:"required,min=2,max=255"` - Major string `json:"major" validate:"required,min=2,max=255"` - EducationLevel string `json:"educationLevel" validate:"required,min=2,max=100"` - GraduationYear int `json:"graduationYear" validate:"required,min=1950,max=2030"` - CertificateImage string `json:"certificateImage,omitempty"` -} - -func (req EducationHistoryCreateRequest) ToEntity(userId uint) *entity.EducationHistory { - certificateImage := &req.CertificateImage - if req.CertificateImage == "" { - certificateImage = nil - } - - return &entity.EducationHistory{ - UserID: userId, - SchoolName: req.SchoolName, - Major: req.Major, - EducationLevel: req.EducationLevel, - GraduationYear: req.GraduationYear, - CertificateImage: certificateImage, - } -} - -type EducationHistoryUpdateRequest struct { - SchoolName string `json:"schoolName" validate:"required,min=2,max=255"` - Major string `json:"major" validate:"required,min=2,max=255"` - EducationLevel string `json:"educationLevel" validate:"required,min=2,max=100"` - GraduationYear int `json:"graduationYear" validate:"required,min=1950,max=2030"` - CertificateImage string `json:"certificateImage,omitempty"` -} - -func (req EducationHistoryUpdateRequest) ToEntity(userId uint) *entity.EducationHistory { - certificateImage := &req.CertificateImage - if req.CertificateImage == "" { - certificateImage = nil - } - - return &entity.EducationHistory{ - UserID: userId, - SchoolName: req.SchoolName, - Major: req.Major, - EducationLevel: req.EducationLevel, - GraduationYear: req.GraduationYear, - CertificateImage: certificateImage, - } -} - -type EducationHistoryQueryRequestContext struct { - UserID string `json:"userId"` - SchoolName string `json:"schoolName"` - Major string `json:"major"` - EducationLevel string `json:"educationLevel"` - GraduationYear string `json:"graduationYear"` -} - -func (req EducationHistoryQueryRequestContext) ToParamRequest() EducationHistoryQueryRequest { - var request EducationHistoryQueryRequest - - if userId := req.UserID; userId != "" { - userIdUint, err := strconv.ParseUint(userId, 10, 0) - if err == nil { - request.UserID = uint(userIdUint) - } - } - if schoolName := req.SchoolName; schoolName != "" { - request.SchoolName = &schoolName - } - if major := req.Major; major != "" { - request.Major = &major - } - if educationLevel := req.EducationLevel; educationLevel != "" { - request.EducationLevel = &educationLevel - } - if graduationYearStr := req.GraduationYear; graduationYearStr != "" { - graduationYear, err := strconv.Atoi(graduationYearStr) - if err == nil { - request.GraduationYear = &graduationYear - } - } - - return request -} diff --git a/app/module/education_history/response/education_history.response.go b/app/module/education_history/response/education_history.response.go deleted file mode 100644 index a6940c5..0000000 --- a/app/module/education_history/response/education_history.response.go +++ /dev/null @@ -1,25 +0,0 @@ -package response - -import ( - "time" -) - -type EducationHistoryResponse struct { - ID uint `json:"id"` - UserID uint `json:"userId"` - SchoolName string `json:"schoolName"` - Major string `json:"major"` - EducationLevel string `json:"educationLevel"` - GraduationYear int `json:"graduationYear"` - CertificateImage *string `json:"certificateImage"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - User *UserBasicInfo `json:"user,omitempty"` -} - -type UserBasicInfo struct { - ID uint `json:"id"` - Username string `json:"username"` - Fullname string `json:"fullname"` - Email string `json:"email"` -} diff --git a/app/module/education_history/service/education_history.service.go b/app/module/education_history/service/education_history.service.go deleted file mode 100644 index 081d845..0000000 --- a/app/module/education_history/service/education_history.service.go +++ /dev/null @@ -1,186 +0,0 @@ -package service - -import ( - "context" - "errors" - "fmt" - "math/rand" - "path/filepath" - "strconv" - "strings" - "time" - - "jaecoo-be/app/module/education_history/mapper" - "jaecoo-be/app/module/education_history/repository" - "jaecoo-be/app/module/education_history/request" - "jaecoo-be/app/module/education_history/response" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/config/config" - minioStorage "jaecoo-be/config/config" - "jaecoo-be/utils/paginator" - - "github.com/gofiber/fiber/v2" - "github.com/minio/minio-go/v7" - "github.com/rs/zerolog" -) - -type educationHistoryService struct { - Repo repository.EducationHistoryRepository - UsersRepo usersRepository.UsersRepository - Log zerolog.Logger - Cfg *config.Config - MinioStorage *minioStorage.MinioStorage -} - -type EducationHistoryService interface { - All(req request.EducationHistoryQueryRequest) (educationHistories []*response.EducationHistoryResponse, paging paginator.Pagination, err error) - Show(userId uint, id uint) (educationHistory *response.EducationHistoryResponse, err error) - Save(userId uint, req request.EducationHistoryCreateRequest) (educationHistory *response.EducationHistoryResponse, err error) - Update(userId uint, id uint, req request.EducationHistoryUpdateRequest) (err error) - Delete(userId uint, id uint) error - UploadCertificate(userId uint, id uint, c *fiber.Ctx) error -} - -func NewEducationHistoryService(repo repository.EducationHistoryRepository, usersRepo usersRepository.UsersRepository, log zerolog.Logger, cfg *config.Config, minioStorage *minioStorage.MinioStorage) EducationHistoryService { - return &educationHistoryService{ - Repo: repo, - UsersRepo: usersRepo, - Log: log, - Cfg: cfg, - MinioStorage: minioStorage, - } -} - -func (_i *educationHistoryService) All(req request.EducationHistoryQueryRequest) (educationHistories []*response.EducationHistoryResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req.UserID, req) - if err != nil { - return - } - - for _, result := range results { - educationHistories = append(educationHistories, mapper.EducationHistoryResponseMapper(result)) - } - - return -} - -func (_i *educationHistoryService) Show(userId uint, id uint) (educationHistory *response.EducationHistoryResponse, err error) { - result, err := _i.Repo.FindOneByUserAndId(userId, id) - if err != nil { - return nil, err - } - - return mapper.EducationHistoryResponseMapper(result), nil -} - -func (_i *educationHistoryService) Save(userId uint, req request.EducationHistoryCreateRequest) (educationHistory *response.EducationHistoryResponse, err error) { - _i.Log.Info().Interface("data", req).Msg("Creating education history") - - entity := req.ToEntity(userId) - - result, err := _i.Repo.Create(entity) - if err != nil { - return nil, err - } - - return mapper.EducationHistoryResponseMapper(result), nil -} - -func (_i *educationHistoryService) Update(userId uint, id uint, req request.EducationHistoryUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("Updating education history") - - // Check if record exists and belongs to user - existing, err := _i.Repo.FindOneByUserAndId(userId, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("education history not found") - } - - entity := req.ToEntity(userId) - return _i.Repo.Update(userId, id, entity) -} - -func (_i *educationHistoryService) Delete(userId uint, id uint) error { - _i.Log.Info().Uint("userId", userId).Uint("id", id).Msg("Deleting education history") - - // Check if record exists and belongs to user - existing, err := _i.Repo.FindOneByUserAndId(userId, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("education history not found") - } - - return _i.Repo.Delete(userId, id) -} - -func (_i *educationHistoryService) UploadCertificate(userId uint, id uint, c *fiber.Ctx) error { - _i.Log.Info().Uint("userId", userId).Uint("id", id).Msg("Uploading certificate") - - // Check if record exists and belongs to user - existing, err := _i.Repo.FindOneByUserAndId(userId, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("education history not found") - } - - // Get multipart form - form, err := c.MultipartForm() - if err != nil { - return err - } - - // Get file from form - files := form.File["certificate"] - if len(files) == 0 { - return errors.New("no certificate file provided") - } - - fileHeader := files[0] - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - - // Create minio connection - minioClient, err := _i.MinioStorage.ConnectMinio() - if err != nil { - return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ - "error": true, - "msg": err.Error(), - }) - } - - // Process file - src, err := fileHeader.Open() - if err != nil { - return err - } - defer src.Close() - - filename := filepath.Base(fileHeader.Filename) - filename = strings.ReplaceAll(filename, " ", "") - filenameWithoutExt := filepath.Clean(filename[:len(filename)-len(filepath.Ext(filename))]) - extension := filepath.Ext(fileHeader.Filename)[1:] - - now := time.Now() - rand.New(rand.NewSource(now.UnixNano())) - randUniqueId := rand.Intn(1000000) - - newFilenameWithoutExt := filenameWithoutExt + "_" + strconv.Itoa(randUniqueId) - newFilename := newFilenameWithoutExt + "." + extension - - objectName := fmt.Sprintf("education-history/certificates/%d/%d/%s", now.Year(), now.Month(), newFilename) - - // Upload file to MinIO - _, err = minioClient.PutObject(context.Background(), bucketName, objectName, src, fileHeader.Size, minio.PutObjectOptions{}) - if err != nil { - return err - } - - // Update certificate image path with MinIO object name - existing.CertificateImage = &objectName - return _i.Repo.Update(userId, id, existing) -} diff --git a/app/module/magazine_files/controller/controller.go b/app/module/magazine_files/controller/controller.go deleted file mode 100644 index 013319f..0000000 --- a/app/module/magazine_files/controller/controller.go +++ /dev/null @@ -1,13 +0,0 @@ -package controller - -import "jaecoo-be/app/module/magazine_files/service" - -type Controller struct { - MagazineFiles MagazineFilesController -} - -func NewController(MagazineFilesService service.MagazineFilesService) *Controller { - return &Controller{ - MagazineFiles: NewMagazineFilesController(MagazineFilesService), - } -} diff --git a/app/module/magazine_files/controller/magazine_files.controller.go b/app/module/magazine_files/controller/magazine_files.controller.go deleted file mode 100644 index 5a07a68..0000000 --- a/app/module/magazine_files/controller/magazine_files.controller.go +++ /dev/null @@ -1,209 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/magazine_files/request" - "jaecoo-be/app/module/magazine_files/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type magazineFilesController struct { - magazineFilesService service.MagazineFilesService -} - -type MagazineFilesController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error - Viewer(c *fiber.Ctx) error -} - -func NewMagazineFilesController(magazineFilesService service.MagazineFilesService) MagazineFilesController { - return &magazineFilesController{ - magazineFilesService: magazineFilesService, - } -} - -// All MagazineFiles -// @Summary Get all MagazineFiles -// @Description API for getting all MagazineFiles -// @Tags Magazine Files -// @Security Bearer -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazine-files [get] -func (_i *magazineFilesController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.MagazineFilesQueryRequestContext{ - Title: c.Query("title"), - Description: c.Query("description"), - MagazineId: c.Query("magazineId"), - StatusId: c.Query("statusId"), - IsPublish: c.Query("isPublish"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - magazineFilesData, paging, err := _i.magazineFilesService.All(req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"MagazineFiles list successfully retrieved"}, - Data: magazineFilesData, - Meta: paging, - }) -} - -// Show MagazineFiles -// @Summary Get one MagazineFiles -// @Description API for getting one MagazineFiles -// @Tags Magazine Files -// @Security Bearer -// @Param id path int true "MagazineFiles ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazine-files/{id} [get] -func (_i *magazineFilesController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - magazineFilesData, err := _i.magazineFilesService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"MagazineFiles successfully retrieved"}, - Data: magazineFilesData, - }) -} - -// Save MagazineFiles -// @Summary Create MagazineFiles -// @Description API for create MagazineFiles -// @Tags Magazine Files -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param files formData file true "Upload file" multiple true -// @Param title formData string true "Magazine file title" -// @Param description formData string true "Magazine file description" -// @Param magazineId path int true "Magazine ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazine-files/{magazineId} [post] -func (_i *magazineFilesController) Save(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("magazineId"), 10, 0) - if err != nil { - return err - } - title := c.Params("title") - description := c.Params("description") - - err = _i.magazineFilesService.Save(c, uint(id), title, description) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"MagazineFiles successfully created"}, - }) -} - -// Update MagazineFiles -// @Summary Update MagazineFiles -// @Description API for update MagazineFiles -// @Tags Magazine Files -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "MagazineFiles ID" -// @Body request.MagazineFilesUpdateRequest -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazine-files/{id} [put] -func (_i *magazineFilesController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.MagazineFilesUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.magazineFilesService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"MagazineFiles successfully updated"}, - }) -} - -// Delete MagazineFiles -// @Summary delete MagazineFiles -// @Description API for delete MagazineFiles -// @Tags Magazine Files -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "MagazineFiles ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazine-files/{id} [delete] -func (_i *magazineFilesController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.magazineFilesService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"MagazineFiles successfully deleted"}, - }) -} - -// Viewer MagazineFiles -// @Summary Create MagazineFiles -// @Description API for create MagazineFiles -// @Tags Magazine Files -// @Security Bearer -// @Param filename path string true "Magazine File Name" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazine-files/viewer/{filename} [get] -func (_i *magazineFilesController) Viewer(c *fiber.Ctx) error { - return _i.magazineFilesService.Viewer(c) -} diff --git a/app/module/magazine_files/magazine_files.module.go b/app/module/magazine_files/magazine_files.module.go deleted file mode 100644 index 5ffdc8e..0000000 --- a/app/module/magazine_files/magazine_files.module.go +++ /dev/null @@ -1,55 +0,0 @@ -package magazine_files - -import ( - "jaecoo-be/app/module/magazine_files/controller" - "jaecoo-be/app/module/magazine_files/repository" - "jaecoo-be/app/module/magazine_files/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of MagazineFilesRouter -type MagazineFilesRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// register bulky of MagazineFiles module -var NewMagazineFilesModule = fx.Options( - // register repository of MagazineFiles module - fx.Provide(repository.NewMagazineFilesRepository), - - // register service of MagazineFiles module - fx.Provide(service.NewMagazineFilesService), - - // register controller of MagazineFiles module - fx.Provide(controller.NewController), - - // register router of MagazineFiles module - fx.Provide(NewMagazineFilesRouter), -) - -// init MagazineFilesRouter -func NewMagazineFilesRouter(fiber *fiber.App, controller *controller.Controller) *MagazineFilesRouter { - return &MagazineFilesRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of MagazineFiles module -func (_i *MagazineFilesRouter) RegisterMagazineFilesRoutes() { - // define controllers - magazineFilesController := _i.Controller.MagazineFiles - - // define routes - _i.App.Route("/magazine-files", func(router fiber.Router) { - router.Get("/", magazineFilesController.All) - router.Get("/:id", magazineFilesController.Show) - router.Post("/:magazineId", magazineFilesController.Save) - router.Put("/:id", magazineFilesController.Update) - router.Delete("/:id", magazineFilesController.Delete) - router.Get("/viewer/:filename", magazineFilesController.Viewer) - }) -} diff --git a/app/module/magazine_files/mapper/magazine_files.mapper.go b/app/module/magazine_files/mapper/magazine_files.mapper.go deleted file mode 100644 index 10365b9..0000000 --- a/app/module/magazine_files/mapper/magazine_files.mapper.go +++ /dev/null @@ -1,37 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - res "jaecoo-be/app/module/magazine_files/response" -) - -func MagazineFilesResponseMapper(magazineFilesReq *entity.MagazineFiles, host string) (magazineFilesRes *res.MagazineFilesResponse) { - fileUrl := host + "/magazine-files/viewer/" - if magazineFilesReq.FileName != nil { - fileUrl += *magazineFilesReq.FileName - } - - if magazineFilesReq != nil { - magazineFilesRes = &res.MagazineFilesResponse{ - ID: magazineFilesReq.ID, - Title: magazineFilesReq.Title, - Description: magazineFilesReq.Description, - MagazineId: magazineFilesReq.MagazineId, - DownloadCount: magazineFilesReq.DownloadCount, - FilePath: magazineFilesReq.FilePath, - FileUrl: &fileUrl, - FileName: magazineFilesReq.FileName, - FileAlt: magazineFilesReq.FileAlt, - WidthPixel: magazineFilesReq.WidthPixel, - HeightPixel: magazineFilesReq.HeightPixel, - Size: magazineFilesReq.Size, - StatusId: magazineFilesReq.StatusId, - IsPublish: magazineFilesReq.IsPublish, - PublishedAt: magazineFilesReq.PublishedAt, - IsActive: magazineFilesReq.IsActive, - CreatedAt: magazineFilesReq.CreatedAt, - UpdatedAt: magazineFilesReq.UpdatedAt, - } - } - return magazineFilesRes -} diff --git a/app/module/magazine_files/repository/magazine_files.repository.go b/app/module/magazine_files/repository/magazine_files.repository.go deleted file mode 100644 index 73d07c6..0000000 --- a/app/module/magazine_files/repository/magazine_files.repository.go +++ /dev/null @@ -1,121 +0,0 @@ -package repository - -import ( - "fmt" - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/magazine_files/request" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "strings" -) - -type magazineFilesRepository struct { - DB *database.Database -} - -// MagazineFilesRepository define interface of IMagazineFilesRepository -type MagazineFilesRepository interface { - GetAll(req request.MagazineFilesQueryRequest) (magazineFiless []*entity.MagazineFiles, paging paginator.Pagination, err error) - FindOne(id uint) (magazineFiles *entity.MagazineFiles, err error) - FindByMagazine(magazineId uint) (magazineFiles []*entity.MagazineFiles, err error) - FindByFilename(filename string) (magazineFiles *entity.MagazineFiles, err error) - Create(magazineFiles *entity.MagazineFiles) (err error) - Update(id uint, magazineFiles *entity.MagazineFiles) (err error) - Delete(id uint) (err error) -} - -func NewMagazineFilesRepository(db *database.Database) MagazineFilesRepository { - return &magazineFilesRepository{ - DB: db, - } -} - -// implement interface of IMagazineFilesRepository -func (_i *magazineFilesRepository) GetAll(req request.MagazineFilesQueryRequest) (magazineFiless []*entity.MagazineFiles, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.MagazineFiles{}) - query = query.Where("is_active = ?", true) - - if req.Title != nil && *req.Title != "" { - title := strings.ToLower(*req.Title) - query = query.Where("LOWER(title) LIKE ?", "%"+strings.ToLower(title)+"%") - } - if req.Description != nil && *req.Description != "" { - description := strings.ToLower(*req.Description) - query = query.Where("LOWER(description) LIKE ?", "%"+strings.ToLower(description)+"%") - } - if req.MagazineId != nil { - query = query.Where("magazine_id = ?", req.MagazineId) - } - if req.IsPublish != nil { - query = query.Where("is_publish = ?", req.IsPublish) - } - if req.StatusId != nil { - query = query.Where("status_id = ?", req.StatusId) - } - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction)) - } - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&magazineFiless).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *magazineFilesRepository) FindByMagazine(magazineId uint) (magazineFiles []*entity.MagazineFiles, err error) { - if err := _i.DB.DB.Where("magazine_id = ?", magazineId).Find(&magazineFiles).Error; err != nil { - return nil, err - } - - return magazineFiles, nil -} - -func (_i *magazineFilesRepository) FindByFilename(magazineFilename string) (magazineFiles *entity.MagazineFiles, err error) { - - if err := _i.DB.DB.Where("file_name = ?", magazineFilename).First(&magazineFiles).Error; err != nil { - return nil, err - } - - return magazineFiles, nil -} - -func (_i *magazineFilesRepository) FindOne(id uint) (magazineFiles *entity.MagazineFiles, err error) { - if err := _i.DB.DB.First(&magazineFiles, id).Error; err != nil { - return nil, err - } - - return magazineFiles, nil -} - -func (_i *magazineFilesRepository) Create(magazineFiles *entity.MagazineFiles) (err error) { - return _i.DB.DB.Create(magazineFiles).Error -} - -func (_i *magazineFilesRepository) Update(id uint, magazineFiles *entity.MagazineFiles) (err error) { - magazineFilesMap, err := utilSvc.StructToMap(magazineFiles) - if err != nil { - return err - } - return _i.DB.DB.Model(&entity.MagazineFiles{}). - Where(&entity.MagazineFiles{ID: id}). - Updates(magazineFilesMap).Error -} - -func (_i *magazineFilesRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.MagazineFiles{}, id).Error -} diff --git a/app/module/magazine_files/request/magazine_files.request.go b/app/module/magazine_files/request/magazine_files.request.go deleted file mode 100644 index e1197ac..0000000 --- a/app/module/magazine_files/request/magazine_files.request.go +++ /dev/null @@ -1,137 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -type MagazineFilesGeneric interface { - ToEntity() -} - -type MagazineFilesQueryRequest struct { - Title *string `json:"title"` - Description *string `json:"description"` - MagazineId *int `json:"magazineId"` - DownloadCount *int `json:"downloadCount"` - StatusId *int `json:"statusId"` - IsPublish *bool `json:"isPublish"` - PublishedAt *time.Time `json:"publishedAt"` - IsActive *bool `json:"isActive"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type MagazineFilesCreateRequest struct { - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - MagazineId uint `json:"magazineId" validate:"required"` - StatusId int `json:"statusId" validate:"required"` - DownloadCount *int `json:"downloadCount"` - FilePath *string `json:"filePath"` - FileUrl *string `json:"fileUrl"` - FileName *string `json:"fileName"` - FileAlt *string `json:"fileAlt"` - WidthPixel *string `json:"widthPixel"` - HeightPixel *string `json:"heightPixel"` - Size *string `json:"size"` - IsPublish *bool `json:"isPublish"` - PublishedAt *time.Time `json:"publishedAt"` -} - -func (req MagazineFilesCreateRequest) ToEntity() *entity.MagazineFiles { - return &entity.MagazineFiles{ - Title: req.Title, - Description: req.Description, - MagazineId: req.MagazineId, - DownloadCount: req.DownloadCount, - FilePath: req.FilePath, - FileUrl: req.FileUrl, - FileName: req.FileName, - FileAlt: req.FileAlt, - WidthPixel: req.WidthPixel, - HeightPixel: req.HeightPixel, - Size: req.Size, - StatusId: req.StatusId, - IsPublish: req.IsPublish, - PublishedAt: req.PublishedAt, - } -} - -type MagazineFilesUpdateRequest struct { - ID uint `json:"id" validate:"required"` - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - MagazineId uint `json:"magazineId" validate:"required"` - StatusId int `json:"statusId" validate:"required"` - DownloadCount *int `json:"downloadCount"` - FilePath *string `json:"filePath"` - FileUrl *string `json:"fileUrl"` - FileName *string `json:"fileName"` - FileAlt *string `json:"fileAlt"` - WidthPixel *string `json:"widthPixel"` - HeightPixel *string `json:"heightPixel"` - Size *string `json:"size"` - IsPublish *bool `json:"isPublish"` - PublishedAt *time.Time `json:"publishedAt"` -} - -func (req MagazineFilesUpdateRequest) ToEntity() *entity.MagazineFiles { - return &entity.MagazineFiles{ - ID: req.ID, - Title: req.Title, - Description: req.Description, - MagazineId: req.MagazineId, - DownloadCount: req.DownloadCount, - FilePath: req.FilePath, - FileUrl: req.FileUrl, - FileName: req.FileName, - FileAlt: req.FileAlt, - WidthPixel: req.WidthPixel, - HeightPixel: req.HeightPixel, - Size: req.Size, - StatusId: req.StatusId, - IsPublish: req.IsPublish, - PublishedAt: req.PublishedAt, - } -} - -type MagazineFilesQueryRequestContext struct { - Title string `json:"title"` - Description string `json:"description"` - MagazineId string `json:"magazineId"` - IsPublish string `json:"isPublish"` - StatusId string `json:"statusId"` -} - -func (req MagazineFilesQueryRequestContext) ToParamRequest() MagazineFilesQueryRequest { - var request MagazineFilesQueryRequest - - if title := req.Title; title != "" { - request.Title = &title - } - if description := req.Description; description != "" { - request.Description = &description - } - if magazineIdStr := req.MagazineId; magazineIdStr != "" { - magazineId, err := strconv.Atoi(magazineIdStr) - if err == nil { - request.MagazineId = &magazineId - } - } - if isPublishStr := req.IsPublish; isPublishStr != "" { - isPublish, err := strconv.ParseBool(isPublishStr) - if err == nil { - request.IsPublish = &isPublish - } - } - if statusIdStr := req.StatusId; statusIdStr != "" { - statusId, err := strconv.Atoi(statusIdStr) - if err == nil { - request.StatusId = &statusId - } - } - - return request -} diff --git a/app/module/magazine_files/response/magazine_files.response.go b/app/module/magazine_files/response/magazine_files.response.go deleted file mode 100644 index 5b46c07..0000000 --- a/app/module/magazine_files/response/magazine_files.response.go +++ /dev/null @@ -1,24 +0,0 @@ -package response - -import "time" - -type MagazineFilesResponse struct { - ID uint `json:"id"` - Title string `json:"title"` - Description string `json:"description"` - MagazineId uint `json:"magazineId"` - DownloadCount *int `json:"downloadCount"` - FilePath *string `json:"filePath"` - FileUrl *string `json:"fileUrl"` - FileName *string `json:"fileName"` - FileAlt *string `json:"fileAlt"` - WidthPixel *string `json:"widthPixel"` - HeightPixel *string `json:"heightPixel"` - Size *string `json:"size"` - StatusId int `json:"statusId"` - IsPublish *bool `json:"isPublish"` - PublishedAt *time.Time `json:"publishedAt"` - IsActive bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} diff --git a/app/module/magazine_files/service/magazine_files.service.go b/app/module/magazine_files/service/magazine_files.service.go deleted file mode 100644 index 576e12f..0000000 --- a/app/module/magazine_files/service/magazine_files.service.go +++ /dev/null @@ -1,228 +0,0 @@ -package service - -import ( - "context" - "fmt" - "io" - "jaecoo-be/app/module/magazine_files/mapper" - "jaecoo-be/app/module/magazine_files/repository" - "jaecoo-be/app/module/magazine_files/request" - "jaecoo-be/app/module/magazine_files/response" - config "jaecoo-be/config/config" - minioStorage "jaecoo-be/config/config" - "jaecoo-be/utils/paginator" - "log" - "math/rand" - "mime" - "path/filepath" - "strconv" - "strings" - "time" - - "github.com/gofiber/fiber/v2" - "github.com/minio/minio-go/v7" - "github.com/rs/zerolog" -) - -// MagazineFilesService -type magazineFilesService struct { - Repo repository.MagazineFilesRepository - Log zerolog.Logger - Cfg *config.Config - MinioStorage *minioStorage.MinioStorage -} - -// MagazineFilesService define interface of IMagazineFilesService -type MagazineFilesService interface { - All(req request.MagazineFilesQueryRequest) (magazineFiles []*response.MagazineFilesResponse, paging paginator.Pagination, err error) - Show(id uint) (magazineFiles *response.MagazineFilesResponse, err error) - Save(c *fiber.Ctx, id uint, title string, description string) (err error) - Update(id uint, req request.MagazineFilesUpdateRequest) (err error) - Delete(id uint) error - Viewer(c *fiber.Ctx) error -} - -// NewMagazineFilesService init MagazineFilesService -func NewMagazineFilesService(repo repository.MagazineFilesRepository, log zerolog.Logger, cfg *config.Config, minioStorage *minioStorage.MinioStorage) MagazineFilesService { - - return &magazineFilesService{ - Repo: repo, - Log: log, - Cfg: cfg, - MinioStorage: minioStorage, - } -} - -// All implement interface of MagazineFilesService -func (_i *magazineFilesService) All(req request.MagazineFilesQueryRequest) (magazineFiless []*response.MagazineFilesResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req) - if err != nil { - return - } - host := _i.Cfg.App.Domain - for _, result := range results { - magazineFiless = append(magazineFiless, mapper.MagazineFilesResponseMapper(result, host)) - } - return -} - -func (_i *magazineFilesService) Show(id uint) (magazineFiles *response.MagazineFilesResponse, err error) { - result, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - host := _i.Cfg.App.Domain - return mapper.MagazineFilesResponseMapper(result, host), nil -} - -func (_i *magazineFilesService) Save(c *fiber.Ctx, id uint, title string, description string) (err error) { - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - - form, err := c.MultipartForm() - - if err != nil { - return err - } - //filess := form.File["files"] - - // Create minio connection. - minioClient, err := _i.MinioStorage.ConnectMinio() - - if err != nil { - // Return status 500 and minio connection error. - return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ - "error": true, - "msg": err.Error(), - }) - } - - for _, files := range form.File { - - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "Uploader:: top"). - Interface("files", files).Msg("") - - for _, fileHeader := range files { - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "Uploader:: loop"). - Interface("data", fileHeader).Msg("") - - src, err := fileHeader.Open() - if err != nil { - return err - } - defer src.Close() - - filename := filepath.Base(fileHeader.Filename) - filenameAlt := filepath.Clean(filename[:len(filename)-len(filepath.Ext(filename))]) - filename = strings.ReplaceAll(filename, " ", "") - filenameWithoutExt := filepath.Clean(filename[:len(filename)-len(filepath.Ext(filename))]) - extension := filepath.Ext(fileHeader.Filename)[1:] - - now := time.Now() - rand.New(rand.NewSource(now.UnixNano())) - randUniqueId := rand.Intn(1000000) - - newFilenameWithoutExt := filenameWithoutExt + "_" + strconv.Itoa(randUniqueId) - newFilename := newFilenameWithoutExt + "." + extension - objectName := fmt.Sprintf("magazines/upload/%d/%d/%s", now.Year(), now.Month(), newFilename) - - fileSize := strconv.FormatInt(fileHeader.Size, 10) - - req := request.MagazineFilesCreateRequest{ - MagazineId: id, - Title: title, - Description: description, - FilePath: &objectName, - FileName: &newFilename, - FileAlt: &filenameAlt, - Size: &fileSize, - } - - err = _i.Repo.Create(req.ToEntity()) - if err != nil { - return err - } - - // Upload file ke MinIO - _, err = minioClient.PutObject(context.Background(), bucketName, objectName, src, fileHeader.Size, minio.PutObjectOptions{}) - if err != nil { - return err - } - } - } - - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "User:All"). - Interface("data", "Successfully uploaded").Msg("") - - return -} - -func (_i *magazineFilesService) Viewer(c *fiber.Ctx) (err error) { - filename := c.Params("filename") - result, err := _i.Repo.FindByFilename(filename) - if err != nil { - return err - } - - ctx := context.Background() - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - objectName := *result.FilePath - - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "Article:Uploads"). - Interface("data", objectName).Msg("") - - // Create minio connection. - minioClient, err := _i.MinioStorage.ConnectMinio() - if err != nil { - // Return status 500 and minio connection error. - return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ - "error": true, - "msg": err.Error(), - }) - } - - fileContent, err := minioClient.GetObject(ctx, bucketName, objectName, minio.GetObjectOptions{}) - if err != nil { - log.Fatalln(err) - } - defer fileContent.Close() - - // Tentukan Content-Type berdasarkan ekstensi file - contentType := mime.TypeByExtension("." + getFileExtension(objectName)) - if contentType == "" { - contentType = "application/octet-stream" // fallback jika tidak ada tipe MIME yang cocok - } - - c.Set("Content-Type", contentType) - - if _, err := io.Copy(c.Response().BodyWriter(), fileContent); err != nil { - return err - } - - return -} - -func getFileExtension(filename string) string { - // split file name - parts := strings.Split(filename, ".") - - // jika tidak ada ekstensi, kembalikan string kosong - if len(parts) == 1 || (len(parts) == 2 && parts[0] == "") { - return "" - } - - // ambil ekstensi terakhir - return parts[len(parts)-1] -} - -func (_i *magazineFilesService) Update(id uint, req request.MagazineFilesUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - return _i.Repo.Update(id, req.ToEntity()) -} - -func (_i *magazineFilesService) Delete(id uint) error { - return _i.Repo.Delete(id) -} diff --git a/app/module/magazines/controller/controller.go b/app/module/magazines/controller/controller.go deleted file mode 100644 index 7d4a927..0000000 --- a/app/module/magazines/controller/controller.go +++ /dev/null @@ -1,13 +0,0 @@ -package controller - -import "jaecoo-be/app/module/magazines/service" - -type Controller struct { - Magazines MagazinesController -} - -func NewController(MagazinesService service.MagazinesService) *Controller { - return &Controller{ - Magazines: NewMagazinesController(MagazinesService), - } -} diff --git a/app/module/magazines/controller/magazines.controller.go b/app/module/magazines/controller/magazines.controller.go deleted file mode 100644 index b6e9da4..0000000 --- a/app/module/magazines/controller/magazines.controller.go +++ /dev/null @@ -1,237 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/magazines/request" - "jaecoo-be/app/module/magazines/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type magazinesController struct { - magazinesService service.MagazinesService -} - -type MagazinesController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - SaveThumbnail(c *fiber.Ctx) error - Viewer(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error -} - -func NewMagazinesController(magazinesService service.MagazinesService) MagazinesController { - return &magazinesController{ - magazinesService: magazinesService, - } -} - -// All Magazines -// @Summary Get all Magazines -// @Description API for getting all Magazines -// @Tags Magazines -// @Security Bearer -// @Param req query request.MagazinesQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazines [get] -func (_i *magazinesController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.MagazinesQueryRequestContext{ - Title: c.Query("title"), - Description: c.Query("description"), - CreatedById: c.Query("createdById"), - StatusId: c.Query("statusId"), - IsPublish: c.Query("isPublish"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - magazinesData, paging, err := _i.magazinesService.All(req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"Magazines list successfully retrieved"}, - Data: magazinesData, - Meta: paging, - }) -} - -// Show Magazines -// @Summary Get one Magazines -// @Description API for getting one Magazines -// @Tags Magazines -// @Security Bearer -// @Param id path int true "Magazines ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazines/{id} [get] -func (_i *magazinesController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - magazinesData, err := _i.magazinesService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"Magazines successfully retrieved"}, - Data: magazinesData, - }) -} - -// Save Magazines -// @Summary Create Magazines -// @Description API for create Magazines -// @Tags Magazines -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.MagazinesCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazines [post] -func (_i *magazinesController) Save(c *fiber.Ctx) error { - req := new(request.MagazinesCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authToken := c.Get("Authorization") - - dataResult, err := _i.magazinesService.Save(*req, authToken) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Magazines successfully created"}, - Data: dataResult, - }) -} - -// Update Magazines -// @Summary Update Magazines -// @Description API for update Magazines -// @Tags Magazines -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Magazines ID" -// @Param payload body request.MagazinesUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazines/{id} [put] -func (_i *magazinesController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.MagazinesUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.magazinesService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"Magazines successfully updated"}, - }) -} - -// SaveThumbnail Magazines -// @Summary Save Thumbnail Magazines -// @Description API for Save Thumbnail of Magazines -// @Tags Magazines -// @Security Bearer -// @Produce json -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Magazine ID" -// @Param files formData file true "Upload thumbnail" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazines/thumbnail/{id} [post] -func (_i *magazinesController) SaveThumbnail(c *fiber.Ctx) error { - err := _i.magazinesService.SaveThumbnail(c) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Thumbnail of Magazines successfully created"}, - }) -} - -// Viewer Magazines -// @Summary Viewer Magazines Thumbnail -// @Description API for View Thumbnail of Magazines -// @Tags Magazines -// @Security Bearer -// @Param thumbnailName path string true "Magazines Thumbnail Name" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazines/thumbnail/viewer/{thumbnailName} [get] -func (_i *magazinesController) Viewer(c *fiber.Ctx) error { - return _i.magazinesService.Viewer(c) -} - -// Delete Magazines -// @Summary Delete Magazines -// @Description API for delete Magazines -// @Tags Magazines -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Magazines ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /magazines/{id} [delete] -func (_i *magazinesController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.magazinesService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"Magazines successfully deleted"}, - }) -} diff --git a/app/module/magazines/magazines.module.go b/app/module/magazines/magazines.module.go deleted file mode 100644 index 8af700a..0000000 --- a/app/module/magazines/magazines.module.go +++ /dev/null @@ -1,56 +0,0 @@ -package magazines - -import ( - "jaecoo-be/app/module/magazines/controller" - "jaecoo-be/app/module/magazines/repository" - "jaecoo-be/app/module/magazines/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of MagazinesRouter -type MagazinesRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// register bulky of Magazines module -var NewMagazinesModule = fx.Options( - // register repository of Magazines module - fx.Provide(repository.NewMagazinesRepository), - - // register service of Magazines module - fx.Provide(service.NewMagazinesService), - - // register controller of Magazines module - fx.Provide(controller.NewController), - - // register router of Magazines module - fx.Provide(NewMagazinesRouter), -) - -// init MagazinesRouter -func NewMagazinesRouter(fiber *fiber.App, controller *controller.Controller) *MagazinesRouter { - return &MagazinesRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of Magazines module -func (_i *MagazinesRouter) RegisterMagazinesRoutes() { - // define controllers - magazinesController := _i.Controller.Magazines - - // define routes - _i.App.Route("/magazines", func(router fiber.Router) { - router.Get("/", magazinesController.All) - router.Get("/:id", magazinesController.Show) - router.Post("/", magazinesController.Save) - router.Put("/:id", magazinesController.Update) - router.Post("/thumbnail/:id", magazinesController.SaveThumbnail) - router.Get("/thumbnail/viewer/:thumbnailName", magazinesController.Viewer) - router.Delete("/:id", magazinesController.Delete) - }) -} diff --git a/app/module/magazines/mapper/magazines.mapper.go b/app/module/magazines/mapper/magazines.mapper.go deleted file mode 100644 index 39332fc..0000000 --- a/app/module/magazines/mapper/magazines.mapper.go +++ /dev/null @@ -1,42 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - magazineFilesMapper "jaecoo-be/app/module/magazine_files/mapper" - magazineFilesRepository "jaecoo-be/app/module/magazine_files/repository" - magazineFilesResponse "jaecoo-be/app/module/magazine_files/response" - res "jaecoo-be/app/module/magazines/response" -) - -func MagazinesResponseMapper(magazinesReq *entity.Magazines, magazineFilesRepo magazineFilesRepository.MagazineFilesRepository, host string) (magazinesRes *res.MagazinesResponse) { - magazineFiles, _ := magazineFilesRepo.FindByMagazine(magazinesReq.ID) - var magazineFilesArr []*magazineFilesResponse.MagazineFilesResponse - if magazineFiles != nil && len(magazineFiles) > 0 { - for _, result := range magazineFiles { - magazineFilesArr = append(magazineFilesArr, magazineFilesMapper.MagazineFilesResponseMapper(result, host)) - } - } - - if magazinesReq != nil { - magazinesRes = &res.MagazinesResponse{ - ID: magazinesReq.ID, - Title: magazinesReq.Title, - Description: magazinesReq.Description, - ThumbnailPath: magazinesReq.ThumbnailPath, - PageUrl: magazinesReq.PageUrl, - CreatedById: magazinesReq.CreatedById, - StatusId: magazinesReq.StatusId, - IsPublish: magazinesReq.IsPublish, - PublishedAt: magazinesReq.PublishedAt, - IsActive: magazinesReq.IsActive, - CreatedAt: magazinesReq.CreatedAt, - UpdatedAt: magazinesReq.UpdatedAt, - MagazineFiles: magazineFilesArr, - } - - if magazinesReq.ThumbnailPath != nil { - magazinesRes.ThumbnailUrl = host + "/magazines/thumbnail/viewer/" + *magazinesReq.ThumbnailName - } - } - return magazinesRes -} diff --git a/app/module/magazines/repository/magazines.repository.go b/app/module/magazines/repository/magazines.repository.go deleted file mode 100644 index cfbfd7d..0000000 --- a/app/module/magazines/repository/magazines.repository.go +++ /dev/null @@ -1,118 +0,0 @@ -package repository - -import ( - "fmt" - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/magazines/request" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "strings" -) - -type magazinesRepository struct { - DB *database.Database -} - -// MagazinesRepository define interface of IMagazinesRepository -type MagazinesRepository interface { - GetAll(req request.MagazinesQueryRequest) (magaziness []*entity.Magazines, paging paginator.Pagination, err error) - FindOne(id uint) (magazines *entity.Magazines, err error) - FindByFilename(thumbnailName string) (magazineReturn *entity.Magazines, err error) - Create(magazines *entity.Magazines) (magazineReturn *entity.Magazines, err error) - Update(id uint, magazines *entity.Magazines) (err error) - Delete(id uint) (err error) -} - -func NewMagazinesRepository(db *database.Database) MagazinesRepository { - return &magazinesRepository{ - DB: db, - } -} - -// implement interface of IMagazinesRepository -func (_i *magazinesRepository) GetAll(req request.MagazinesQueryRequest) (magaziness []*entity.Magazines, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.Magazines{}) - - query = query.Where("is_active = ?", true) - - if req.Title != nil && *req.Title != "" { - title := strings.ToLower(*req.Title) - query = query.Where("LOWER(title) LIKE ?", "%"+strings.ToLower(title)+"%") - } - if req.Description != nil && *req.Description != "" { - description := strings.ToLower(*req.Description) - query = query.Where("LOWER(description) LIKE ?", "%"+strings.ToLower(description)+"%") - } - if req.CreatedById != nil { - query = query.Where("created_by_id = ?", req.CreatedById) - } - if req.IsPublish != nil { - query = query.Where("is_publish = ?", req.IsPublish) - } - if req.StatusId != nil { - query = query.Where("status_id = ?", req.StatusId) - } - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction)) - } - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&magaziness).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *magazinesRepository) FindOne(id uint) (magazines *entity.Magazines, err error) { - query := _i.DB.DB.Where("id = ?", id) - - if err := query.First(&magazines).Error; err != nil { - return nil, err - } - - return magazines, nil -} - -func (_i *magazinesRepository) FindByFilename(thumbnailName string) (magazines *entity.Magazines, err error) { - query := _i.DB.DB.Where("thumbnail_name = ?", thumbnailName) - - if err := query.First(&magazines).Error; err != nil { - return nil, err - } - - return magazines, nil -} - -func (_i *magazinesRepository) Create(magazines *entity.Magazines) (magazineReturn *entity.Magazines, err error) { - result := _i.DB.DB.Create(magazines) - return magazines, result.Error -} - -func (_i *magazinesRepository) Update(id uint, magazines *entity.Magazines) (err error) { - magazinesMap, err := utilSvc.StructToMap(magazines) - if err != nil { - return err - } - query := _i.DB.DB.Model(&entity.Magazines{}).Where(&entity.Magazines{ID: id}) - return query.Updates(magazinesMap).Error -} - -func (_i *magazinesRepository) Delete(id uint) error { - query := _i.DB.DB.Model(&entity.Magazines{}).Where("id = ?", id) - return query.Delete(&entity.Magazines{}).Error -} diff --git a/app/module/magazines/request/magazines.request.go b/app/module/magazines/request/magazines.request.go deleted file mode 100644 index 17a9a4d..0000000 --- a/app/module/magazines/request/magazines.request.go +++ /dev/null @@ -1,119 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -type MagazinesGeneric interface { - ToEntity() -} - -type MagazinesQueryRequest struct { - Title *string `json:"title"` - Description *string `json:"description"` - ThumbnailPath *string `json:"thumbnailPath"` - ThumbnailUrl *string `json:"thumbnailUrl"` - PageUrl *string `json:"pageUrl"` - CreatedById *int `json:"createdById"` - StatusId *int `json:"statusId"` - IsPublish *bool `json:"isPublish"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type MagazinesCreateRequest struct { - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - StatusId int `json:"statusId" validate:"required"` - ThumbnailPath *string `json:"thumbnailPath"` - ThumbnailUrl *string `json:"thumbnailUrl"` - PageUrl *string `json:"pageUrl"` - CreatedById *uint `json:"createdById"` - IsPublish *bool `json:"isPublish"` - PublishedAt *time.Time `json:"publishedAt"` -} - -func (req MagazinesCreateRequest) ToEntity() *entity.Magazines { - return &entity.Magazines{ - Title: req.Title, - Description: req.Description, - ThumbnailPath: req.ThumbnailPath, - ThumbnailUrl: req.ThumbnailUrl, - PageUrl: req.PageUrl, - CreatedById: req.CreatedById, - StatusId: req.StatusId, - IsPublish: req.IsPublish, - PublishedAt: req.PublishedAt, - IsActive: true, - } -} - -type MagazinesUpdateRequest struct { - ID uint `json:"id" validate:"required"` - Title string `json:"title" validate:"required"` - Description string `json:"description" validate:"required"` - StatusId int `json:"statusId" validate:"required"` - ThumbnailPath *string `json:"thumbnailPath"` - ThumbnailUrl *string `json:"thumbnailUrl"` - PageUrl *string `json:"pageUrl"` - CreatedById *uint `json:"createdById"` - IsPublish *bool `json:"isPublish"` - PublishedAt *time.Time `json:"publishedAt"` -} - -func (req MagazinesUpdateRequest) ToEntity() *entity.Magazines { - return &entity.Magazines{ - ID: req.ID, - Title: req.Title, - Description: req.Description, - ThumbnailPath: req.ThumbnailPath, - ThumbnailUrl: req.ThumbnailUrl, - PageUrl: req.PageUrl, - CreatedById: req.CreatedById, - StatusId: req.StatusId, - IsPublish: req.IsPublish, - PublishedAt: req.PublishedAt, - UpdatedAt: time.Now(), - } -} - -type MagazinesQueryRequestContext struct { - Title string `json:"title"` - Description string `json:"description"` - CreatedById string `json:"createdById"` - IsPublish string `json:"isPublish"` - StatusId string `json:"statusId"` -} - -func (req MagazinesQueryRequestContext) ToParamRequest() MagazinesQueryRequest { - var request MagazinesQueryRequest - - if title := req.Title; title != "" { - request.Title = &title - } - if description := req.Description; description != "" { - request.Description = &description - } - if isPublishStr := req.IsPublish; isPublishStr != "" { - isPublish, err := strconv.ParseBool(isPublishStr) - if err == nil { - request.IsPublish = &isPublish - } - } - if statusIdStr := req.StatusId; statusIdStr != "" { - statusId, err := strconv.Atoi(statusIdStr) - if err == nil { - request.StatusId = &statusId - } - } - if createdByIdStr := req.CreatedById; createdByIdStr != "" { - createdById, err := strconv.Atoi(createdByIdStr) - if err == nil { - request.CreatedById = &createdById - } - } - - return request -} diff --git a/app/module/magazines/response/magazines.response.go b/app/module/magazines/response/magazines.response.go deleted file mode 100644 index 918d4da..0000000 --- a/app/module/magazines/response/magazines.response.go +++ /dev/null @@ -1,24 +0,0 @@ -package response - -import ( - magazineFilesResponse "jaecoo-be/app/module/magazine_files/response" - "time" -) - -type MagazinesResponse struct { - ID uint `json:"id"` - Title string `json:"title"` - Description string `json:"description"` - ThumbnailPath *string `json:"thumbnailPath"` - ThumbnailUrl string `json:"thumbnailUrl"` - PageUrl *string `json:"pageUrl"` - CreatedById *uint `json:"createdById"` - StatusId int `json:"statusId"` - IsPublish *bool `json:"isPublish"` - PublishedAt *time.Time `json:"publishedAt"` - IsActive bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - - MagazineFiles []*magazineFilesResponse.MagazineFilesResponse `json:"files"` -} diff --git a/app/module/magazines/service/magazines.service.go b/app/module/magazines/service/magazines.service.go deleted file mode 100644 index 4788dbf..0000000 --- a/app/module/magazines/service/magazines.service.go +++ /dev/null @@ -1,257 +0,0 @@ -package service - -import ( - "context" - "fmt" - "io" - "jaecoo-be/app/database/entity" - magazineFilesRepository "jaecoo-be/app/module/magazine_files/repository" - "jaecoo-be/app/module/magazines/mapper" - "jaecoo-be/app/module/magazines/repository" - "jaecoo-be/app/module/magazines/request" - "jaecoo-be/app/module/magazines/response" - usersRepository "jaecoo-be/app/module/users/repository" - config "jaecoo-be/config/config" - minioStorage "jaecoo-be/config/config" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - "log" - "math/rand" - "mime" - "path/filepath" - "strconv" - "strings" - "time" - - "github.com/gofiber/fiber/v2" - "github.com/minio/minio-go/v7" - "github.com/rs/zerolog" -) - -// MagazinesService -type magazinesService struct { - Repo repository.MagazinesRepository - UsersRepo usersRepository.UsersRepository - MagazineFilesRepo magazineFilesRepository.MagazineFilesRepository - MinioStorage *minioStorage.MinioStorage - Log zerolog.Logger - Cfg *config.Config -} - -// MagazinesService define interface of IMagazinesService -type MagazinesService interface { - All(req request.MagazinesQueryRequest) (magazines []*response.MagazinesResponse, paging paginator.Pagination, err error) - Show(id uint) (magazines *response.MagazinesResponse, err error) - Save(req request.MagazinesCreateRequest, authToken string) (magazines *entity.Magazines, err error) - Update(id uint, req request.MagazinesUpdateRequest) (err error) - SaveThumbnail(c *fiber.Ctx) (err error) - Viewer(c *fiber.Ctx) (err error) - Delete(id uint) error -} - -// NewMagazinesService init MagazinesService -func NewMagazinesService(repo repository.MagazinesRepository, magazineFilesRepo magazineFilesRepository.MagazineFilesRepository, usersRepo usersRepository.UsersRepository, minioStorage *minioStorage.MinioStorage, log zerolog.Logger, cfg *config.Config) MagazinesService { - - return &magazinesService{ - Repo: repo, - MagazineFilesRepo: magazineFilesRepo, - UsersRepo: usersRepo, - MinioStorage: minioStorage, - Log: log, - Cfg: cfg, - } -} - -// All implement interface of MagazinesService -func (_i *magazinesService) All(req request.MagazinesQueryRequest) (magaziness []*response.MagazinesResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req) - if err != nil { - return - } - - host := _i.Cfg.App.Domain - for _, result := range results { - magaziness = append(magaziness, mapper.MagazinesResponseMapper(result, _i.MagazineFilesRepo, host)) - } - - return -} - -func (_i *magazinesService) Show(id uint) (magazines *response.MagazinesResponse, err error) { - result, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - host := _i.Cfg.App.Domain - return mapper.MagazinesResponseMapper(result, _i.MagazineFilesRepo, host), nil -} - -func (_i *magazinesService) Save(req request.MagazinesCreateRequest, authToken string) (magazines *entity.Magazines, err error) { - _i.Log.Info().Interface("data", req).Msg("") - newReq := req.ToEntity() - - createdBy := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - newReq.CreatedById = &createdBy.ID - - saveMagazineResponse, err := _i.Repo.Create(newReq) - if err != nil { - return nil, err - } - - return saveMagazineResponse, nil -} - -func (_i *magazinesService) SaveThumbnail(c *fiber.Ctx) (err error) { - - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:magazinesService", "Methods:SaveThumbnail"). - Interface("id", id).Msg("") - - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - - form, err := c.MultipartForm() - if err != nil { - return err - } - files := form.File["files"] - - // Create minio connection. - minioClient, err := _i.MinioStorage.ConnectMinio() - if err != nil { - // Return status 500 and minio connection error. - return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ - "error": true, - "msg": err.Error(), - }) - } - - // Iterasi semua file yang diunggah - for _, file := range files { - - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "Uploader:: loop1"). - Interface("data", file).Msg("") - - src, err := file.Open() - if err != nil { - return err - } - defer src.Close() - - filename := filepath.Base(file.Filename) - filename = strings.ReplaceAll(filename, " ", "") - filenameWithoutExt := filepath.Clean(filename[:len(filename)-len(filepath.Ext(filename))]) - extension := filepath.Ext(file.Filename)[1:] - - now := time.Now() - rand.New(rand.NewSource(now.UnixNano())) - randUniqueId := rand.Intn(1000000) - - newFilenameWithoutExt := filenameWithoutExt + "_" + strconv.Itoa(randUniqueId) - newFilename := newFilenameWithoutExt + "." + extension - objectName := fmt.Sprintf("magazines/thumbnail/%d/%d/%s", now.Year(), now.Month(), newFilename) - - findCategory, err := _i.Repo.FindOne(uint(id)) - findCategory.ThumbnailName = &newFilename - findCategory.ThumbnailPath = &objectName - err = _i.Repo.Update(uint(id), findCategory) - if err != nil { - return err - } - - // Upload file ke MinIO - _, err = minioClient.PutObject(context.Background(), bucketName, objectName, src, file.Size, minio.PutObjectOptions{}) - if err != nil { - return err - } - } - - return -} - -func (_i *magazinesService) Update(id uint, req request.MagazinesUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - - entity := req.ToEntity() - - return _i.Repo.Update(id, entity) -} - -func (_i *magazinesService) Delete(id uint) error { - return _i.Repo.Delete(id) -} - -func (_i *magazinesService) Viewer(c *fiber.Ctx) (err error) { - thumbnailName := c.Params("thumbnailName") - - emptyImage := "empty-image.jpg" - searchThumbnail := emptyImage - if thumbnailName != emptyImage { - result, err := _i.Repo.FindByFilename(thumbnailName) - if err != nil { - return err - } - _i.Log.Info().Str("timestamp", time.Now(). - Format(time.RFC3339)).Str("Service:Resource", "magazinesService:Viewer"). - Interface("resultThumbnail", result.ThumbnailPath).Msg("") - - if result.ThumbnailPath != nil { - searchThumbnail = *result.ThumbnailPath - } else { - searchThumbnail = "magazines/thumbnail/" + emptyImage - } - } else { - searchThumbnail = "magazines/thumbnail/" + emptyImage - } - - ctx := context.Background() - bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName - objectName := searchThumbnail - - // Create minio connection. - minioClient, err := _i.MinioStorage.ConnectMinio() - if err != nil { - // Return status 500 and minio connection error. - return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ - "error": true, - "msg": err.Error(), - }) - } - - fileContent, err := minioClient.GetObject(ctx, bucketName, objectName, minio.GetObjectOptions{}) - if err != nil { - log.Fatalln(err) - } - defer fileContent.Close() - - contentType := mime.TypeByExtension("." + getFileExtension(objectName)) - if contentType == "" { - contentType = "application/octet-stream" - } - - c.Set("Content-Type", contentType) - - if _, err := io.Copy(c.Response().BodyWriter(), fileContent); err != nil { - return err - } - - return -} - -func getFileExtension(filename string) string { - // split file name - parts := strings.Split(filename, ".") - - // jika tidak ada ekstensi, kembalikan string kosong - if len(parts) == 1 || (len(parts) == 2 && parts[0] == "") { - return "" - } - - // ambil ekstensi terakhir - return parts[len(parts)-1] -} diff --git a/app/module/master_menus/controller/controller.go b/app/module/master_menus/controller/controller.go deleted file mode 100644 index 0710875..0000000 --- a/app/module/master_menus/controller/controller.go +++ /dev/null @@ -1,13 +0,0 @@ -package controller - -import "jaecoo-be/app/module/master_menus/service" - -type Controller struct { - MasterMenus MasterMenusController -} - -func NewController(MasterMenusService service.MasterMenusService) *Controller { - return &Controller{ - MasterMenus: NewMasterMenusController(MasterMenusService), - } -} diff --git a/app/module/master_menus/controller/master_menus.controller.go b/app/module/master_menus/controller/master_menus.controller.go deleted file mode 100644 index 2e80958..0000000 --- a/app/module/master_menus/controller/master_menus.controller.go +++ /dev/null @@ -1,195 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/master_menus/request" - "jaecoo-be/app/module/master_menus/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type masterMenusController struct { - masterMenusService service.MasterMenusService -} - -type MasterMenusController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error -} - -func NewMasterMenusController(masterMenusService service.MasterMenusService) MasterMenusController { - return &masterMenusController{ - masterMenusService: masterMenusService, - } -} - -// All MasterMenus -// @Summary Get all MasterMenus -// @Description API for getting all MasterMenus -// @Tags MasterMenus -// @Security Bearer -// @Param req query request.MasterMenusQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /master-menus [get] -func (_i *masterMenusController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.MasterMenusQueryRequestContext{ - Name: c.Query("name"), - Description: c.Query("description"), - ParentMenuId: c.Query("parentMenuId"), - ModuleId: c.Query("moduleId"), - StatusId: c.Query("statusId"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - masterMenusData, paging, err := _i.masterMenusService.All(req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"MasterMenus list successfully retrieved"}, - Data: masterMenusData, - Meta: paging, - }) -} - -// Show get one MasterMenus -// @Summary Get one MasterMenus -// @Description API for getting one MasterMenus -// @Tags MasterMenus -// @Security Bearer -// @Param id path int true "MasterMenus ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /master-menus/{id} [get] -func (_i *masterMenusController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - masterMenusData, err := _i.masterMenusService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"MasterMenus successfully retrieved"}, - Data: masterMenusData, - }) -} - -// Save create MasterMenus -// @Summary Create MasterMenus -// @Description API for create MasterMenus -// @Tags MasterMenus -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param payload body request.MasterMenusCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /master-menus [post] -func (_i *masterMenusController) Save(c *fiber.Ctx) error { - req := new(request.MasterMenusCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err := _i.masterMenusService.Save(*req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"MasterMenus successfully created"}, - }) -} - -// Update MasterMenus -// @Summary Update MasterMenus -// @Description API for update MasterMenus -// @Tags MasterMenus -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Body request.MasterMenusUpdateRequest -// @Param id path int true "MasterMenus ID" -// @Success 200 {object} response.Response -// @Failure 401 {object} response.Response -// @Failure 404 {object} response.Response -// @Failure 422 {object} response.Response -// @Failure 500 {object} response.Response -// @Router /master-menus/{id} [put] -func (_i *masterMenusController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.MasterMenusUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.masterMenusService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"MasterMenus successfully updated"}, - }) -} - -// Delete MasterMenus -// @Summary Delete MasterMenus -// @Description API for delete MasterMenus -// @Tags MasterMenus -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "MasterMenus ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /master-menus/{id} [delete] -func (_i *masterMenusController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.masterMenusService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"MasterMenus successfully deleted"}, - }) -} diff --git a/app/module/master_menus/mapper/master_menus.mapper.go b/app/module/master_menus/mapper/master_menus.mapper.go deleted file mode 100644 index 449ec7c..0000000 --- a/app/module/master_menus/mapper/master_menus.mapper.go +++ /dev/null @@ -1,25 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - res "jaecoo-be/app/module/master_menus/response" -) - -func MasterMenusResponseMapper(masterMenusReq *entity.MasterMenus) (masterMenusRes *res.MasterMenusResponse) { - if masterMenusReq != nil { - masterMenusRes = &res.MasterMenusResponse{ - ID: masterMenusReq.ID, - Name: masterMenusReq.Name, - Description: masterMenusReq.Description, - ModuleId: masterMenusReq.ModuleId, - ParentMenuId: masterMenusReq.ParentMenuId, - Icon: masterMenusReq.Icon, - Position: masterMenusReq.Position, - StatusId: masterMenusReq.StatusId, - IsActive: masterMenusReq.IsActive, - CreatedAt: masterMenusReq.CreatedAt, - UpdatedAt: masterMenusReq.UpdatedAt, - } - } - return masterMenusRes -} diff --git a/app/module/master_menus/master_menus.module.go b/app/module/master_menus/master_menus.module.go deleted file mode 100644 index 344f539..0000000 --- a/app/module/master_menus/master_menus.module.go +++ /dev/null @@ -1,54 +0,0 @@ -package master_menus - -import ( - "jaecoo-be/app/module/master_menus/controller" - "jaecoo-be/app/module/master_menus/repository" - "jaecoo-be/app/module/master_menus/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of MasterMenusRouter -type MasterMenusRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// register bulky of MasterMenus module -var NewMasterMenusModule = fx.Options( - // register repository of MasterMenus module - fx.Provide(repository.NewMasterMenusRepository), - - // register service of MasterMenus module - fx.Provide(service.NewMasterMenusService), - - // register controller of MasterMenus module - fx.Provide(controller.NewController), - - // register router of MasterMenus module - fx.Provide(NewMasterMenusRouter), -) - -// init MasterMenusRouter -func NewMasterMenusRouter(fiber *fiber.App, controller *controller.Controller) *MasterMenusRouter { - return &MasterMenusRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of MasterMenus module -func (_i *MasterMenusRouter) RegisterMasterMenusRoutes() { - // define controllers - masterMenusController := _i.Controller.MasterMenus - - // define routes - _i.App.Route("/master-menus", func(router fiber.Router) { - router.Get("/", masterMenusController.All) - router.Get("/:id", masterMenusController.Show) - router.Post("/", masterMenusController.Save) - router.Put("/:id", masterMenusController.Update) - router.Delete("/:id", masterMenusController.Delete) - }) -} diff --git a/app/module/master_menus/repository/master_menus.repository.go b/app/module/master_menus/repository/master_menus.repository.go deleted file mode 100644 index 8743a96..0000000 --- a/app/module/master_menus/repository/master_menus.repository.go +++ /dev/null @@ -1,108 +0,0 @@ -package repository - -import ( - "fmt" - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/master_menus/request" - "jaecoo-be/utils/paginator" - "strings" -) - -type masterMenusRepository struct { - DB *database.Database -} - -// MasterMenusRepository define interface of IMasterMenusRepository -type MasterMenusRepository interface { - GetAll(req request.MasterMenusQueryRequest) (masterMenuss []*entity.MasterMenus, paging paginator.Pagination, err error) - FindOne(id uint) (masterMenus *entity.MasterMenus, err error) - FindLastMenuPosition() (position *int, err error) - Create(masterMenus *entity.MasterMenus) (err error) - Update(id uint, masterMenus *entity.MasterMenus) (err error) - Delete(id uint) (err error) -} - -func NewMasterMenusRepository(db *database.Database) MasterMenusRepository { - return &masterMenusRepository{ - DB: db, - } -} - -// implement interface of IMasterMenusRepository -func (_i *masterMenusRepository) GetAll(req request.MasterMenusQueryRequest) (masterMenuss []*entity.MasterMenus, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.MasterMenus{}) - query = query.Where("is_active = ?", true) - - if req.Name != nil && *req.Name != "" { - name := strings.ToLower(*req.Name) - query = query.Where("LOWER(name) LIKE ?", "%"+strings.ToLower(name)+"%") - } - if req.Description != nil && *req.Description != "" { - description := strings.ToLower(*req.Description) - query = query.Where("LOWER(description) LIKE ?", "%"+strings.ToLower(description)+"%") - } - if req.ModuleId != nil { - query = query.Where("module_id = ?", req.ModuleId) - } - if req.ParentMenuId != nil { - query = query.Where("parent_menu_id = ?", req.ParentMenuId) - } - if req.StatusId != nil { - query = query.Where("status_id = ?", req.StatusId) - } - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction)) - } - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&masterMenuss).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *masterMenusRepository) FindOne(id uint) (masterMenus *entity.MasterMenus, err error) { - if err := _i.DB.DB.First(&masterMenus, id).Error; err != nil { - return nil, err - } - - return masterMenus, nil -} - -func (_i *masterMenusRepository) FindLastMenuPosition() (position *int, err error) { - var masterMenus *entity.MasterMenus - if err := _i.DB.DB.Where("position IS NOT NULL").Order(fmt.Sprintf("%s %s", "position", "DESC")).First(&masterMenus).Error; err != nil { - return nil, err - } - - return masterMenus.Position, nil -} - -func (_i *masterMenusRepository) Create(masterMenus *entity.MasterMenus) (err error) { - return _i.DB.DB.Create(masterMenus).Error -} - -func (_i *masterMenusRepository) Update(id uint, masterMenus *entity.MasterMenus) (err error) { - return _i.DB.DB.Model(&entity.MasterMenus{}). - Where(&entity.MasterMenus{ID: id}). - Updates(masterMenus).Error -} - -func (_i *masterMenusRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.MasterMenus{}, id).Error -} diff --git a/app/module/master_menus/request/master_menus.request.go b/app/module/master_menus/request/master_menus.request.go deleted file mode 100644 index ceeb495..0000000 --- a/app/module/master_menus/request/master_menus.request.go +++ /dev/null @@ -1,108 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -type MasterMenusGeneric interface { - ToEntity() -} - -type MasterMenusQueryRequest struct { - Name *string `json:"name"` - Description *string `json:"description"` - ModuleId *int `json:"moduleId"` - ParentMenuId *int `json:"parentMenuId"` - StatusId *int `json:"statusId"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type MasterMenusCreateRequest struct { - Name string `json:"name" validate:"required"` - Description string `json:"description" validate:"required"` - ModuleId int `json:"moduleId" validate:"required"` - Group string `json:"group" validate:"required"` - StatusId int `json:"statusId" validate:"required"` - ParentMenuId *int `json:"parentMenuId"` - Icon *string `json:"icon"` -} - -func (req MasterMenusCreateRequest) ToEntity() *entity.MasterMenus { - return &entity.MasterMenus{ - Name: req.Name, - Description: req.Description, - ModuleId: req.ModuleId, - ParentMenuId: req.ParentMenuId, - Icon: req.Icon, - Group: req.Group, - StatusId: req.StatusId, - } -} - -type MasterMenusUpdateRequest struct { - ID uint `json:"id" validate:"required"` - Name string `json:"name" validate:"required"` - Description string `json:"description" validate:"required"` - ModuleId int `json:"moduleId" validate:"required"` - Group string `json:"group" validate:"required"` - StatusId int `json:"statusId" validate:"required"` - ParentMenuId *int `json:"parentMenuId"` - Icon *string `json:"icon"` - UpdatedAt time.Time `json:"updatedAt"` -} - -func (req MasterMenusUpdateRequest) ToEntity() *entity.MasterMenus { - return &entity.MasterMenus{ - ID: req.ID, - Name: req.Name, - Description: req.Description, - ModuleId: req.ModuleId, - ParentMenuId: req.ParentMenuId, - Icon: req.Icon, - Group: req.Group, - StatusId: req.StatusId, - UpdatedAt: time.Now(), - } -} - -type MasterMenusQueryRequestContext struct { - Name string `json:"name"` - Description string `json:"description"` - ModuleId string `json:"moduleId"` - ParentMenuId string `json:"parentMenuId"` - StatusId string `json:"statusId"` -} - -func (req MasterMenusQueryRequestContext) ToParamRequest() MasterMenusQueryRequest { - var request MasterMenusQueryRequest - - if name := req.Name; name != "" { - request.Name = &name - } - if description := req.Description; description != "" { - request.Description = &description - } - if moduleIdStr := req.ModuleId; moduleIdStr != "" { - moduleId, err := strconv.Atoi(moduleIdStr) - if err == nil { - request.ModuleId = &moduleId - } - } - if parentMenuIdStr := req.ParentMenuId; parentMenuIdStr != "" { - parentMenuId, err := strconv.Atoi(parentMenuIdStr) - if err == nil { - request.ParentMenuId = &parentMenuId - } - } - if statusIdStr := req.StatusId; statusIdStr != "" { - statusId, err := strconv.Atoi(statusIdStr) - if err == nil { - request.StatusId = &statusId - } - } - - return request -} diff --git a/app/module/master_menus/response/master_menus.response.go b/app/module/master_menus/response/master_menus.response.go deleted file mode 100644 index 9ff070c..0000000 --- a/app/module/master_menus/response/master_menus.response.go +++ /dev/null @@ -1,17 +0,0 @@ -package response - -import "time" - -type MasterMenusResponse struct { - ID uint `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - ModuleId int `json:"moduleId"` - ParentMenuId *int `json:"parentMenuId"` - Icon *string `json:"icon"` - Position *int `json:"position"` - StatusId int `json:"statusId"` - IsActive *bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} diff --git a/app/module/master_menus/service/master_menus.service.go b/app/module/master_menus/service/master_menus.service.go deleted file mode 100644 index 3debbcd..0000000 --- a/app/module/master_menus/service/master_menus.service.go +++ /dev/null @@ -1,91 +0,0 @@ -package service - -import ( - "jaecoo-be/app/module/master_menus/mapper" - "jaecoo-be/app/module/master_menus/repository" - "jaecoo-be/app/module/master_menus/request" - "jaecoo-be/app/module/master_menus/response" - "jaecoo-be/utils/paginator" - - "github.com/rs/zerolog" -) - -// MasterMenusService -type masterMenusService struct { - Repo repository.MasterMenusRepository - Log zerolog.Logger -} - -// MasterMenusService define interface of IMasterMenusService -type MasterMenusService interface { - All(req request.MasterMenusQueryRequest) (masterMenus []*response.MasterMenusResponse, paging paginator.Pagination, err error) - Show(id uint) (masterMenus *response.MasterMenusResponse, err error) - Save(req request.MasterMenusCreateRequest) (err error) - Update(id uint, req request.MasterMenusUpdateRequest) (err error) - Delete(id uint) error -} - -// NewMasterMenusService init MasterMenusService -func NewMasterMenusService(repo repository.MasterMenusRepository, log zerolog.Logger) MasterMenusService { - - return &masterMenusService{ - Repo: repo, - Log: log, - } -} - -// All implement interface of MasterMenusService -func (_i *masterMenusService) All(req request.MasterMenusQueryRequest) (masterMenuss []*response.MasterMenusResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req) - if err != nil { - return - } - - for _, result := range results { - masterMenuss = append(masterMenuss, mapper.MasterMenusResponseMapper(result)) - } - - return -} - -func (_i *masterMenusService) Show(id uint) (masterMenus *response.MasterMenusResponse, err error) { - result, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - - return mapper.MasterMenusResponseMapper(result), nil -} - -func (_i *masterMenusService) Save(req request.MasterMenusCreateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - - newReq := req.ToEntity() - var latestPosition, _ = _i.Repo.FindLastMenuPosition() - if err != nil { - return err - } - *latestPosition = *latestPosition + 1 - - if latestPosition != nil { - newReq.Position = latestPosition - } - - return _i.Repo.Create(newReq) -} - -func (_i *masterMenusService) Update(id uint, req request.MasterMenusUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - return _i.Repo.Update(id, req.ToEntity()) -} - -func (_i *masterMenusService) Delete(id uint) error { - result, err := _i.Repo.FindOne(id) - if err != nil { - return err - } - - isActive := false - result.IsActive = &isActive - return _i.Repo.Update(id, result) -} diff --git a/app/module/master_modules/controller/controller.go b/app/module/master_modules/controller/controller.go deleted file mode 100644 index 9dc5a64..0000000 --- a/app/module/master_modules/controller/controller.go +++ /dev/null @@ -1,13 +0,0 @@ -package controller - -import "jaecoo-be/app/module/master_modules/service" - -type Controller struct { - MasterModules MasterModulesController -} - -func NewController(MasterModulesService service.MasterModulesService) *Controller { - return &Controller{ - MasterModules: NewMasterModulesController(MasterModulesService), - } -} diff --git a/app/module/master_modules/controller/master_modules.controller.go b/app/module/master_modules/controller/master_modules.controller.go deleted file mode 100644 index 2508e21..0000000 --- a/app/module/master_modules/controller/master_modules.controller.go +++ /dev/null @@ -1,192 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/master_modules/request" - "jaecoo-be/app/module/master_modules/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type masterModulesController struct { - masterModulesService service.MasterModulesService -} - -type MasterModulesController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error -} - -func NewMasterModulesController(masterModulesService service.MasterModulesService) MasterModulesController { - return &masterModulesController{ - masterModulesService: masterModulesService, - } -} - -// All MasterModules -// @Summary Get all MasterModules -// @Description API for getting all MasterModules -// @Tags MasterModules -// @Security Bearer -// @Param req query request.MasterModulesQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /master-modules [get] -func (_i *masterModulesController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.MasterModulesQueryRequestContext{ - Name: c.Query("name"), - Description: c.Query("description"), - StatusId: c.Query("statusId"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - masterModulesData, paging, err := _i.masterModulesService.All(req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"MasterModules list successfully retrieved"}, - Data: masterModulesData, - Meta: paging, - }) -} - -// Show MasterModules -// @Summary Get one MasterModules -// @Description API for getting one MasterModules -// @Tags MasterModules -// @Security Bearer -// @Param id path int true "MasterModules ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /master-modules/{id} [get] -func (_i *masterModulesController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - masterModulesData, err := _i.masterModulesService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"MasterModules successfully retrieved"}, - Data: masterModulesData, - }) -} - -// Save MasterModules -// @Summary Create MasterModules -// @Description API for create MasterModules -// @Tags MasterModules -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param payload body request.MasterModulesCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /master-modules [post] -func (_i *masterModulesController) Save(c *fiber.Ctx) error { - req := new(request.MasterModulesCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err := _i.masterModulesService.Save(*req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"MasterModules successfully created"}, - }) -} - -// Update MasterModules -// @Summary Update MasterModules -// @Description API for update MasterModules -// @Tags MasterModules -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "MasterModules ID" -// @Param payload body request.MasterModulesUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /master-modules/{id} [put] -func (_i *masterModulesController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.MasterModulesUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.masterModulesService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"MasterModules successfully updated"}, - }) -} - -// Delete MasterModules -// @Summary Delete MasterModules -// @Description API for delete MasterModules -// @Tags MasterModules -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "MasterModules ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /master-modules/{id} [delete] -func (_i *masterModulesController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.masterModulesService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"MasterModules successfully deleted"}, - }) -} diff --git a/app/module/master_modules/mapper/master_modules.mapper.go b/app/module/master_modules/mapper/master_modules.mapper.go deleted file mode 100644 index 1c42234..0000000 --- a/app/module/master_modules/mapper/master_modules.mapper.go +++ /dev/null @@ -1,22 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - res "jaecoo-be/app/module/master_modules/response" -) - -func MasterModulesResponseMapper(masterModulesReq *entity.MasterModules) (masterModulesRes *res.MasterModulesResponse) { - if masterModulesReq != nil { - masterModulesRes = &res.MasterModulesResponse{ - ID: masterModulesReq.ID, - Name: masterModulesReq.Name, - Description: masterModulesReq.Description, - PathUrl: masterModulesReq.PathUrl, - StatusId: masterModulesReq.StatusId, - IsActive: masterModulesReq.IsActive, - CreatedAt: masterModulesReq.CreatedAt, - UpdatedAt: masterModulesReq.UpdatedAt, - } - } - return masterModulesRes -} diff --git a/app/module/master_modules/master_modules.module.go b/app/module/master_modules/master_modules.module.go deleted file mode 100644 index 11bb97d..0000000 --- a/app/module/master_modules/master_modules.module.go +++ /dev/null @@ -1,54 +0,0 @@ -package master_modules - -import ( - "jaecoo-be/app/module/master_modules/controller" - "jaecoo-be/app/module/master_modules/repository" - "jaecoo-be/app/module/master_modules/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of MasterModulesRouter -type MasterModulesRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// register bulky of MasterModules module -var NewMasterModulesModule = fx.Options( - // register repository of MasterModules module - fx.Provide(repository.NewMasterModulesRepository), - - // register service of MasterModules module - fx.Provide(service.NewMasterModulesService), - - // register controller of MasterModules module - fx.Provide(controller.NewController), - - // register router of MasterModules module - fx.Provide(NewMasterModulesRouter), -) - -// init MasterModulesRouter -func NewMasterModulesRouter(fiber *fiber.App, controller *controller.Controller) *MasterModulesRouter { - return &MasterModulesRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of MasterModules module -func (_i *MasterModulesRouter) RegisterMasterModulesRoutes() { - // define controllers - masterModulesController := _i.Controller.MasterModules - - // define routes - _i.App.Route("/master-modules", func(router fiber.Router) { - router.Get("/", masterModulesController.All) - router.Get("/:id", masterModulesController.Show) - router.Post("/", masterModulesController.Save) - router.Put("/:id", masterModulesController.Update) - router.Delete("/:id", masterModulesController.Delete) - }) -} diff --git a/app/module/master_modules/repository/master_modules.repository.go b/app/module/master_modules/repository/master_modules.repository.go deleted file mode 100644 index 03b1269..0000000 --- a/app/module/master_modules/repository/master_modules.repository.go +++ /dev/null @@ -1,92 +0,0 @@ -package repository - -import ( - "fmt" - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/master_modules/request" - "jaecoo-be/utils/paginator" - "strings" -) - -type masterModulesRepository struct { - DB *database.Database -} - -// MasterModulesRepository define interface of IMasterModulesRepository -type MasterModulesRepository interface { - GetAll(req request.MasterModulesQueryRequest) (masterModuless []*entity.MasterModules, paging paginator.Pagination, err error) - FindOne(id uint) (masterModules *entity.MasterModules, err error) - Create(masterModules *entity.MasterModules) (err error) - Update(id uint, masterModules *entity.MasterModules) (err error) - Delete(id uint) (err error) -} - -func NewMasterModulesRepository(db *database.Database) MasterModulesRepository { - return &masterModulesRepository{ - DB: db, - } -} - -// implement interface of IMasterModulesRepository -func (_i *masterModulesRepository) GetAll(req request.MasterModulesQueryRequest) (masterModuless []*entity.MasterModules, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.MasterModules{}) - query = query.Where("is_active = ?", true) - - if req.Name != nil && *req.Name != "" { - name := strings.ToLower(*req.Name) - query = query.Where("LOWER(name) LIKE ?", "%"+strings.ToLower(name)+"%") - } - if req.Description != nil && *req.Description != "" { - description := strings.ToLower(*req.Description) - query = query.Where("LOWER(description) LIKE ?", "%"+strings.ToLower(description)+"%") - } - if req.StatusId != nil { - query = query.Where("status_id = ?", req.StatusId) - } - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction)) - } - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&masterModuless).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *masterModulesRepository) FindOne(id uint) (masterModules *entity.MasterModules, err error) { - if err := _i.DB.DB.First(&masterModules, id).Error; err != nil { - return nil, err - } - - return masterModules, nil -} - -func (_i *masterModulesRepository) Create(masterModules *entity.MasterModules) (err error) { - return _i.DB.DB.Create(masterModules).Error -} - -func (_i *masterModulesRepository) Update(id uint, masterModules *entity.MasterModules) (err error) { - return _i.DB.DB.Model(&entity.MasterModules{}). - Where(&entity.MasterModules{ID: id}). - Updates(masterModules).Error -} - -func (_i *masterModulesRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.MasterModules{}, id).Error -} diff --git a/app/module/master_modules/request/master_modules.request.go b/app/module/master_modules/request/master_modules.request.go deleted file mode 100644 index bbdb287..0000000 --- a/app/module/master_modules/request/master_modules.request.go +++ /dev/null @@ -1,79 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -type MasterModulesGeneric interface { - ToEntity() -} - -type MasterModulesQueryRequest struct { - Name *string `json:"name"` - Description *string `json:"description"` - StatusId *int `json:"statusId"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type MasterModulesCreateRequest struct { - Name string `json:"name" validate:"required"` - Description string `json:"description" validate:"required"` - PathUrl string `json:"pathUrl" validate:"required"` - StatusId int `json:"statusId" validate:"required"` -} - -func (req MasterModulesCreateRequest) ToEntity() *entity.MasterModules { - return &entity.MasterModules{ - Name: req.Name, - Description: req.Description, - PathUrl: req.PathUrl, - StatusId: req.StatusId, - } -} - -type MasterModulesUpdateRequest struct { - ID uint `json:"id" validate:"required"` - Name string `json:"name" validate:"required"` - Description string `json:"description" validate:"required"` - PathUrl string `json:"pathUrl" validate:"required"` - StatusId int `json:"statusId" validate:"required"` -} - -func (req MasterModulesUpdateRequest) ToEntity() *entity.MasterModules { - return &entity.MasterModules{ - ID: req.ID, - Name: req.Name, - Description: req.Description, - PathUrl: req.PathUrl, - StatusId: req.StatusId, - UpdatedAt: time.Now(), - } -} - -type MasterModulesQueryRequestContext struct { - Name string `json:"name"` - Description string `json:"description"` - StatusId string `json:"statusId"` -} - -func (req MasterModulesQueryRequestContext) ToParamRequest() MasterModulesQueryRequest { - var request MasterModulesQueryRequest - - if name := req.Name; name != "" { - request.Name = &name - } - if description := req.Description; description != "" { - request.Description = &description - } - if statusIdStr := req.StatusId; statusIdStr != "" { - statusId, err := strconv.Atoi(statusIdStr) - if err == nil { - request.StatusId = &statusId - } - } - - return request -} diff --git a/app/module/master_modules/response/master_modules.response.go b/app/module/master_modules/response/master_modules.response.go deleted file mode 100644 index edfa5b2..0000000 --- a/app/module/master_modules/response/master_modules.response.go +++ /dev/null @@ -1,14 +0,0 @@ -package response - -import "time" - -type MasterModulesResponse struct { - ID uint `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - PathUrl string `json:"pathUrl"` - StatusId int `json:"statusId"` - IsActive *bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} diff --git a/app/module/master_modules/service/master_modules.service.go b/app/module/master_modules/service/master_modules.service.go deleted file mode 100644 index b1e763e..0000000 --- a/app/module/master_modules/service/master_modules.service.go +++ /dev/null @@ -1,80 +0,0 @@ -package service - -import ( - "jaecoo-be/app/module/master_modules/mapper" - "jaecoo-be/app/module/master_modules/repository" - "jaecoo-be/app/module/master_modules/request" - "jaecoo-be/app/module/master_modules/response" - "jaecoo-be/utils/paginator" - - "github.com/rs/zerolog" -) - -// MasterModulesService -type masterModulesService struct { - Repo repository.MasterModulesRepository - Log zerolog.Logger -} - -// MasterModulesService define interface of IMasterModulesService -type MasterModulesService interface { - All(req request.MasterModulesQueryRequest) (masterModules []*response.MasterModulesResponse, paging paginator.Pagination, err error) - Show(id uint) (masterModules *response.MasterModulesResponse, err error) - Save(req request.MasterModulesCreateRequest) (err error) - Update(id uint, req request.MasterModulesUpdateRequest) (err error) - Delete(id uint) error -} - -// NewMasterModulesService init MasterModulesService -func NewMasterModulesService(repo repository.MasterModulesRepository, log zerolog.Logger) MasterModulesService { - - return &masterModulesService{ - Repo: repo, - Log: log, - } -} - -// All implement interface of MasterModulesService -func (_i *masterModulesService) All(req request.MasterModulesQueryRequest) (masterModuless []*response.MasterModulesResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req) - if err != nil { - return - } - - for _, result := range results { - masterModuless = append(masterModuless, mapper.MasterModulesResponseMapper(result)) - } - - return -} - -func (_i *masterModulesService) Show(id uint) (masterModules *response.MasterModulesResponse, err error) { - result, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - - return mapper.MasterModulesResponseMapper(result), nil -} - -func (_i *masterModulesService) Save(req request.MasterModulesCreateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - - return _i.Repo.Create(req.ToEntity()) -} - -func (_i *masterModulesService) Update(id uint, req request.MasterModulesUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - return _i.Repo.Update(id, req.ToEntity()) -} - -func (_i *masterModulesService) Delete(id uint) error { - result, err := _i.Repo.FindOne(id) - if err != nil { - return err - } - - isActive := false - result.IsActive = &isActive - return _i.Repo.Update(id, result) -} diff --git a/app/module/master_statuses/controller/controller.go b/app/module/master_statuses/controller/controller.go deleted file mode 100644 index d58566b..0000000 --- a/app/module/master_statuses/controller/controller.go +++ /dev/null @@ -1,13 +0,0 @@ -package controller - -import "jaecoo-be/app/module/master_statuses/service" - -type Controller struct { - MasterStatuses MasterStatusesController -} - -func NewController(MasterStatusesService service.MasterStatusesService) *Controller { - return &Controller{ - MasterStatuses: NewMasterStatusesController(MasterStatusesService), - } -} diff --git a/app/module/master_statuses/controller/master_statuses.controller.go b/app/module/master_statuses/controller/master_statuses.controller.go deleted file mode 100644 index 6606536..0000000 --- a/app/module/master_statuses/controller/master_statuses.controller.go +++ /dev/null @@ -1,182 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/master_statuses/request" - "jaecoo-be/app/module/master_statuses/service" - "jaecoo-be/utils/paginator" - "strconv" - - "github.com/gofiber/fiber/v2" - - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" -) - -type masterStatusesController struct { - masterStatusesService service.MasterStatusesService -} - -type MasterStatusesController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error -} - -func NewMasterStatusesController(masterStatusesService service.MasterStatusesService) MasterStatusesController { - return &masterStatusesController{ - masterStatusesService: masterStatusesService, - } -} - -// All MasterStatuses -// @Summary Get all MasterStatuses -// @Description API for getting all MasterStatuses -// @Tags Untags -// @Security Bearer -// @Success 200 {object} response.Response -// @Failure 401 {object} response.Response -// @Failure 404 {object} response.Response -// @Failure 422 {object} response.Response -// @Failure 500 {object} response.Response -// @Router /master-statuses [get] -func (_i *masterStatusesController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - var req request.MasterStatusesQueryRequest - req.Pagination = paginate - - masterStatusesData, paging, err := _i.masterStatusesService.All(req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"MasterStatuses list successfully retrieved"}, - Data: masterStatusesData, - Meta: paging, - }) -} - -// Show MasterStatuses -// @Summary Get one MasterStatuses -// @Description API for getting one MasterStatuses -// @Tags Untags -// @Security Bearer -// @Param id path int true "MasterStatuses ID" -// @Success 200 {object} response.Response -// @Failure 401 {object} response.Response -// @Failure 404 {object} response.Response -// @Failure 422 {object} response.Response -// @Failure 500 {object} response.Response -// @Router /master-statuses/{id} [get] -func (_i *masterStatusesController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - masterStatusesData, err := _i.masterStatusesService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"MasterStatuses successfully retrieved"}, - Data: masterStatusesData, - }) -} - -// Save MasterStatuses -// @Summary Create MasterStatuses -// @Description API for create MasterStatuses -// @Tags Untags -// @Security Bearer -// @Body request.MasterStatusesCreateRequest -// @Success 200 {object} response.Response -// @Failure 401 {object} response.Response -// @Failure 404 {object} response.Response -// @Failure 422 {object} response.Response -// @Failure 500 {object} response.Response -// @Router /master-statuses [post] -func (_i *masterStatusesController) Save(c *fiber.Ctx) error { - req := new(request.MasterStatusesCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err := _i.masterStatusesService.Save(*req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"MasterStatuses successfully created"}, - }) -} - -// Update MasterStatuses -// @Summary Update MasterStatuses -// @Description API for update MasterStatuses -// @Tags Untags -// @Security Bearer -// @Body request.MasterStatusesUpdateRequest -// @Param id path int true "MasterStatuses ID" -// @Success 200 {object} response.Response -// @Failure 401 {object} response.Response -// @Failure 404 {object} response.Response -// @Failure 422 {object} response.Response -// @Failure 500 {object} response.Response -// @Router /master-statuses/{id} [put] -func (_i *masterStatusesController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.MasterStatusesUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.masterStatusesService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"MasterStatuses successfully updated"}, - }) -} - -// Delete MasterStatuses -// @Summary Delete MasterStatuses -// @Description API for delete MasterStatuses -// @Tags Untags -// @Security Bearer -// @Param id path int true "MasterStatuses ID" -// @Success 200 {object} response.Response -// @Failure 401 {object} response.Response -// @Failure 404 {object} response.Response -// @Failure 422 {object} response.Response -// @Failure 500 {object} response.Response -// @Router /master-statuses/{id} [delete] -func (_i *masterStatusesController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.masterStatusesService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Messages: utilRes.Messages{"MasterStatuses successfully deleted"}, - }) -} diff --git a/app/module/master_statuses/mapper/master_statuses.mapper.go b/app/module/master_statuses/mapper/master_statuses.mapper.go deleted file mode 100644 index 39dd6c7..0000000 --- a/app/module/master_statuses/mapper/master_statuses.mapper.go +++ /dev/null @@ -1,17 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - res "jaecoo-be/app/module/master_statuses/response" -) - -func MasterStatusesResponseMapper(masterStatusesReq *entity.MasterStatuses) (masterStatusesRes *res.MasterStatusesResponse) { - if masterStatusesReq != nil { - masterStatusesRes = &res.MasterStatusesResponse{ - ID: masterStatusesReq.ID, - Name: masterStatusesReq.Name, - IsActive: masterStatusesReq.IsActive, - } - } - return masterStatusesRes -} diff --git a/app/module/master_statuses/master_statuses.module.go b/app/module/master_statuses/master_statuses.module.go deleted file mode 100644 index 0b9a410..0000000 --- a/app/module/master_statuses/master_statuses.module.go +++ /dev/null @@ -1,54 +0,0 @@ -package master_statuses - -import ( - "jaecoo-be/app/module/master_statuses/controller" - "jaecoo-be/app/module/master_statuses/repository" - "jaecoo-be/app/module/master_statuses/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of MasterStatusesRouter -type MasterStatusesRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// register bulky of MasterStatuses module -var NewMasterStatusesModule = fx.Options( - // register repository of MasterStatuses module - fx.Provide(repository.NewMasterStatusesRepository), - - // register service of MasterStatuses module - fx.Provide(service.NewMasterStatusesService), - - // register controller of MasterStatuses module - fx.Provide(controller.NewController), - - // register router of MasterStatuses module - fx.Provide(NewMasterStatusesRouter), -) - -// init MasterStatusesRouter -func NewMasterStatusesRouter(fiber *fiber.App, controller *controller.Controller) *MasterStatusesRouter { - return &MasterStatusesRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of MasterStatuses module -func (_i *MasterStatusesRouter) RegisterMasterStatusesRoutes() { - // define controllers - masterStatusesController := _i.Controller.MasterStatuses - - // define routes - _i.App.Route("/master-statuses", func(router fiber.Router) { - router.Get("/", masterStatusesController.All) - router.Get("/:id", masterStatusesController.Show) - router.Post("/", masterStatusesController.Save) - router.Put("/:id", masterStatusesController.Update) - router.Delete("/:id", masterStatusesController.Delete) - }) -} diff --git a/app/module/master_statuses/repository/master_statuses.repository.go b/app/module/master_statuses/repository/master_statuses.repository.go deleted file mode 100644 index a3f1d6e..0000000 --- a/app/module/master_statuses/repository/master_statuses.repository.go +++ /dev/null @@ -1,69 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/master_statuses/request" - "jaecoo-be/utils/paginator" -) - -type masterStatusesRepository struct { - DB *database.Database -} - -// MasterStatusesRepository define interface of IMasterStatusesRepository -type MasterStatusesRepository interface { - GetAll(req request.MasterStatusesQueryRequest) (masterStatusess []*entity.MasterStatuses, paging paginator.Pagination, err error) - FindOne(id uint) (masterStatuses *entity.MasterStatuses, err error) - Create(masterStatuses *entity.MasterStatuses) (err error) - Update(id uint, masterStatuses *entity.MasterStatuses) (err error) - Delete(id uint) (err error) -} - -func NewMasterStatusesRepository(db *database.Database) MasterStatusesRepository { - return &masterStatusesRepository{ - DB: db, - } -} - -// implement interface of IMasterStatusesRepository -func (_i *masterStatusesRepository) GetAll(req request.MasterStatusesQueryRequest) (masterStatusess []*entity.MasterStatuses, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.MasterStatuses{}) - query.Count(&count) - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&masterStatusess).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *masterStatusesRepository) FindOne(id uint) (masterStatuses *entity.MasterStatuses, err error) { - if err := _i.DB.DB.First(&masterStatuses, id).Error; err != nil { - return nil, err - } - - return masterStatuses, nil -} - -func (_i *masterStatusesRepository) Create(masterStatuses *entity.MasterStatuses) (err error) { - return _i.DB.DB.Create(masterStatuses).Error -} - -func (_i *masterStatusesRepository) Update(id uint, masterStatuses *entity.MasterStatuses) (err error) { - return _i.DB.DB.Model(&entity.MasterStatuses{}). - Where(&entity.MasterStatuses{ID: id}). - Updates(masterStatuses).Error -} - -func (_i *masterStatusesRepository) Delete(id uint) error { - return _i.DB.DB.Delete(&entity.MasterStatuses{}, id).Error -} diff --git a/app/module/master_statuses/request/master_statuses.request.go b/app/module/master_statuses/request/master_statuses.request.go deleted file mode 100644 index 014ab39..0000000 --- a/app/module/master_statuses/request/master_statuses.request.go +++ /dev/null @@ -1,42 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" -) - -type MasterStatusesGeneric interface { - ToEntity() -} - -type MasterStatusesQueryRequest struct { - Name string `json:"name" validate:"required"` - IsActive bool `json:"isActive" validate:"required"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type MasterStatusesCreateRequest struct { - Name string `json:"name" validate:"required"` - IsActive bool `json:"isActive" validate:"required"` -} - -func (req MasterStatusesCreateRequest) ToEntity() *entity.MasterStatuses { - return &entity.MasterStatuses{ - Name: req.Name, - IsActive: req.IsActive, - } -} - -type MasterStatusesUpdateRequest struct { - ID uint `json:"id" validate:"required"` - Name string `json:"name" validate:"required"` - IsActive bool `json:"isActive" validate:"required"` -} - -func (req MasterStatusesUpdateRequest) ToEntity() *entity.MasterStatuses { - return &entity.MasterStatuses{ - ID: req.ID, - Name: req.Name, - IsActive: req.IsActive, - } -} diff --git a/app/module/master_statuses/response/master_statuses.response.go b/app/module/master_statuses/response/master_statuses.response.go deleted file mode 100644 index 5aa8f64..0000000 --- a/app/module/master_statuses/response/master_statuses.response.go +++ /dev/null @@ -1,7 +0,0 @@ -package response - -type MasterStatusesResponse struct { - ID uint `json:"id"` - Name string `json:"name"` - IsActive bool `json:"isActive"` -} diff --git a/app/module/master_statuses/service/master_statuses.service.go b/app/module/master_statuses/service/master_statuses.service.go deleted file mode 100644 index 7df9028..0000000 --- a/app/module/master_statuses/service/master_statuses.service.go +++ /dev/null @@ -1,73 +0,0 @@ -package service - -import ( - "jaecoo-be/app/module/master_statuses/mapper" - "jaecoo-be/app/module/master_statuses/repository" - "jaecoo-be/app/module/master_statuses/request" - "jaecoo-be/app/module/master_statuses/response" - "jaecoo-be/utils/paginator" - - "github.com/rs/zerolog" -) - -// MasterStatusesService -type masterStatusesService struct { - Repo repository.MasterStatusesRepository - Log zerolog.Logger -} - -// MasterStatusesService define interface of IMasterStatusesService -type MasterStatusesService interface { - All(req request.MasterStatusesQueryRequest) (masterStatuses []*response.MasterStatusesResponse, paging paginator.Pagination, err error) - Show(id uint) (masterStatuses *response.MasterStatusesResponse, err error) - Save(req request.MasterStatusesCreateRequest) (err error) - Update(id uint, req request.MasterStatusesUpdateRequest) (err error) - Delete(id uint) error -} - -// NewMasterStatusesService init MasterStatusesService -func NewMasterStatusesService(repo repository.MasterStatusesRepository, log zerolog.Logger) MasterStatusesService { - - return &masterStatusesService{ - Repo: repo, - Log: log, - } -} - -// All implement interface of MasterStatusesService -func (_i *masterStatusesService) All(req request.MasterStatusesQueryRequest) (masterStatusess []*response.MasterStatusesResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req) - if err != nil { - return - } - - for _, result := range results { - masterStatusess = append(masterStatusess, mapper.MasterStatusesResponseMapper(result)) - } - - return -} - -func (_i *masterStatusesService) Show(id uint) (masterStatuses *response.MasterStatusesResponse, err error) { - result, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - - return mapper.MasterStatusesResponseMapper(result), nil -} - -func (_i *masterStatusesService) Save(req request.MasterStatusesCreateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - - return _i.Repo.Create(req.ToEntity()) -} - -func (_i *masterStatusesService) Update(id uint, req request.MasterStatusesUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - return _i.Repo.Update(id, req.ToEntity()) -} - -func (_i *masterStatusesService) Delete(id uint) error { - return _i.Repo.Delete(id) -} diff --git a/app/module/research_journals/controller/controller.go b/app/module/research_journals/controller/controller.go deleted file mode 100644 index e6472f7..0000000 --- a/app/module/research_journals/controller/controller.go +++ /dev/null @@ -1,13 +0,0 @@ -package controller - -import "jaecoo-be/app/module/research_journals/service" - -type Controller struct { - ResearchJournals ResearchJournalsController -} - -func NewController(ResearchJournalsService service.ResearchJournalsService) *Controller { - return &Controller{ - ResearchJournals: NewResearchJournalsController(ResearchJournalsService), - } -} diff --git a/app/module/research_journals/controller/research_journals.controller.go b/app/module/research_journals/controller/research_journals.controller.go deleted file mode 100644 index 8724a21..0000000 --- a/app/module/research_journals/controller/research_journals.controller.go +++ /dev/null @@ -1,210 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/research_journals/request" - "jaecoo-be/app/module/research_journals/service" - "jaecoo-be/utils/paginator" - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" - "strconv" - - "github.com/gofiber/fiber/v2" -) - -type researchJournalsController struct { - researchJournalsService service.ResearchJournalsService -} - -type ResearchJournalsController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error -} - -func NewResearchJournalsController(researchJournalsService service.ResearchJournalsService) ResearchJournalsController { - return &researchJournalsController{ - researchJournalsService: researchJournalsService, - } -} - -// All Research Journals -// @Summary Get all Research Journals -// @Description API for getting all Research Journals for authenticated user -// @Tags Research Journals -// @Security Bearer -// @Param req query request.ResearchJournalsQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /research-journals [get] -func (_i *researchJournalsController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - authHeader := c.Get("Authorization") - - reqContext := request.ResearchJournalsQueryRequestContext{ - JournalTitle: c.Query("journalTitle"), - Publisher: c.Query("publisher"), - PublishedYear: c.Query("publishedYear"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - // Handle publishedYear filter - if publishedYearStr := c.Query("publishedYear"); publishedYearStr != "" { - if publishedYear, err := strconv.Atoi(publishedYearStr); err == nil { - req.PublishedYear = &publishedYear - } - } - - journalsData, paging, err := _i.researchJournalsService.All(authHeader, req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Research journals list successfully retrieved"}, - Data: journalsData, - Meta: paging, - }) -} - -// Show Research Journal -// @Summary Get one Research Journal -// @Description API for getting one Research Journal -// @Tags Research Journals -// @Security Bearer -// @Param id path int true "Research Journal ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /research-journals/{id} [get] -func (_i *researchJournalsController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authHeader := c.Get("Authorization") - - journalData, err := _i.researchJournalsService.Show(authHeader, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Research journal successfully retrieved"}, - Data: journalData, - }) -} - -// Save Research Journal -// @Summary Create Research Journal -// @Description API for create Research Journal -// @Tags Research Journals -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param Authorization header string false "Insert your access token" default(Bearer ) -// @Param payload body request.ResearchJournalsCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /research-journals [post] -func (_i *researchJournalsController) Save(c *fiber.Ctx) error { - req := new(request.ResearchJournalsCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authHeader := c.Get("Authorization") - - dataResult, err := _i.researchJournalsService.Save(authHeader, *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Research journal successfully created"}, - Data: dataResult, - }) -} - -// Update Research Journal -// @Summary Update Research Journal -// @Description API for update Research Journal -// @Tags Research Journals -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Research Journal ID" -// @Param payload body request.ResearchJournalsUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /research-journals/{id} [put] -func (_i *researchJournalsController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.ResearchJournalsUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - authHeader := c.Get("Authorization") - - err = _i.researchJournalsService.Update(authHeader, uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Research journal successfully updated"}, - }) -} - -// Delete Research Journal -// @Summary Delete Research Journal -// @Description API for delete Research Journal -// @Tags Research Journals -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Research Journal ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /research-journals/{id} [delete] -func (_i *researchJournalsController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - authHeader := c.Get("Authorization") - - err = _i.researchJournalsService.Delete(authHeader, uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Research journal successfully deleted"}, - }) -} diff --git a/app/module/research_journals/mapper/research_journals.mapper.go b/app/module/research_journals/mapper/research_journals.mapper.go deleted file mode 100644 index 679cf42..0000000 --- a/app/module/research_journals/mapper/research_journals.mapper.go +++ /dev/null @@ -1,36 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/research_journals/response" -) - -func ResearchJournalsResponseMapper(researchJournal *entity.ResearchJournals) *response.ResearchJournalsResponse { - result := &response.ResearchJournalsResponse{ - ID: researchJournal.ID, - UserID: researchJournal.UserID, - JournalTitle: researchJournal.JournalTitle, - Publisher: researchJournal.Publisher, - JournalURL: researchJournal.JournalURL, - PublishedDate: researchJournal.PublishedDate, - CreatedAt: researchJournal.CreatedAt, - UpdatedAt: researchJournal.UpdatedAt, - } - - // Extract year from PublishedDate - if researchJournal.PublishedDate != nil { - year := researchJournal.PublishedDate.Year() - result.PublishedYear = &year - } - - if researchJournal.User != nil { - result.User = &response.UserBasicInfo{ - ID: researchJournal.User.ID, - Username: researchJournal.User.Username, - Fullname: researchJournal.User.Fullname, - Email: researchJournal.User.Email, - } - } - - return result -} diff --git a/app/module/research_journals/repository/research_journals.repository.go b/app/module/research_journals/repository/research_journals.repository.go deleted file mode 100644 index fc3281d..0000000 --- a/app/module/research_journals/repository/research_journals.repository.go +++ /dev/null @@ -1,84 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/research_journals/request" - "jaecoo-be/utils/paginator" -) - -type researchJournalsRepository struct { - DB *database.Database -} - -type ResearchJournalsRepository interface { - GetAll(userId uint, req request.ResearchJournalsQueryRequest) (researchJournals []*entity.ResearchJournals, paging paginator.Pagination, err error) - FindOneByUserAndId(userId uint, id uint) (researchJournal *entity.ResearchJournals, err error) - Create(researchJournal *entity.ResearchJournals) (result *entity.ResearchJournals, err error) - Update(userId uint, id uint, researchJournal *entity.ResearchJournals) (err error) - Delete(userId uint, id uint) (err error) -} - -func NewResearchJournalsRepository(db *database.Database) ResearchJournalsRepository { - return &researchJournalsRepository{ - DB: db, - } -} - -func (_i *researchJournalsRepository) GetAll(userId uint, req request.ResearchJournalsQueryRequest) (researchJournals []*entity.ResearchJournals, paging paginator.Pagination, err error) { - query := _i.DB.DB.Where("user_id = ?", userId) - - // Apply filters - if req.JournalTitle != nil { - query = query.Where("journal_title ILIKE ?", "%"+*req.JournalTitle+"%") - } - if req.Publisher != nil { - query = query.Where("publisher ILIKE ?", "%"+*req.Publisher+"%") - } - if req.PublishedYear != nil { - query = query.Where("EXTRACT(YEAR FROM published_date) = ?", *req.PublishedYear) - } - - // Include user relationship - query = query.Preload("User") - - // Order by published date desc (most recent first), then by created_at desc - query = query.Order("published_date DESC NULLS LAST, created_at DESC") - - // Apply pagination - var count int64 - query.Count(&count) - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&researchJournals).Error - paging = *req.Pagination - - return -} - -func (_i *researchJournalsRepository) FindOneByUserAndId(userId uint, id uint) (researchJournal *entity.ResearchJournals, err error) { - err = _i.DB.DB.Where("user_id = ? AND id = ?", userId, id).Preload("User").First(&researchJournal).Error - return -} - -func (_i *researchJournalsRepository) Create(researchJournal *entity.ResearchJournals) (result *entity.ResearchJournals, err error) { - err = _i.DB.DB.Create(researchJournal).Error - if err != nil { - return nil, err - } - - // Reload with relationships - err = _i.DB.DB.Preload("User").First(&result, researchJournal.ID).Error - return -} - -func (_i *researchJournalsRepository) Update(userId uint, id uint, researchJournal *entity.ResearchJournals) (err error) { - err = _i.DB.DB.Where("user_id = ? AND id = ?", userId, id).Updates(researchJournal).Error - return -} - -func (_i *researchJournalsRepository) Delete(userId uint, id uint) (err error) { - err = _i.DB.DB.Where("user_id = ? AND id = ?", userId, id).Delete(&entity.ResearchJournals{}).Error - return -} diff --git a/app/module/research_journals/request/research_journals.request.go b/app/module/research_journals/request/research_journals.request.go deleted file mode 100644 index f760b7c..0000000 --- a/app/module/research_journals/request/research_journals.request.go +++ /dev/null @@ -1,72 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-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 -} diff --git a/app/module/research_journals/research_journals.module.go b/app/module/research_journals/research_journals.module.go deleted file mode 100644 index 5500ee2..0000000 --- a/app/module/research_journals/research_journals.module.go +++ /dev/null @@ -1,54 +0,0 @@ -package research_journals - -import ( - "jaecoo-be/app/module/research_journals/controller" - "jaecoo-be/app/module/research_journals/repository" - "jaecoo-be/app/module/research_journals/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of ResearchJournalsRouter -type ResearchJournalsRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// register bulky of ResearchJournals module -var NewResearchJournalsModule = fx.Options( - // register repository of ResearchJournals module - fx.Provide(repository.NewResearchJournalsRepository), - - // register service of ResearchJournals module - fx.Provide(service.NewResearchJournalsService), - - // register controller of ResearchJournals module - fx.Provide(controller.NewController), - - // register router of ResearchJournals module - fx.Provide(NewResearchJournalsRouter), -) - -// init ResearchJournalsRouter -func NewResearchJournalsRouter(fiber *fiber.App, controller *controller.Controller) *ResearchJournalsRouter { - return &ResearchJournalsRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of ResearchJournals module -func (_i *ResearchJournalsRouter) RegisterResearchJournalsRoutes() { - // define controllers - researchJournalsController := _i.Controller.ResearchJournals - - // define routes - _i.App.Route("/research-journals", func(router fiber.Router) { - router.Get("/", researchJournalsController.All) - router.Get("/:id", researchJournalsController.Show) - router.Post("/", researchJournalsController.Save) - router.Put("/:id", researchJournalsController.Update) - router.Delete("/:id", researchJournalsController.Delete) - }) -} diff --git a/app/module/research_journals/response/research_journals.response.go b/app/module/research_journals/response/research_journals.response.go deleted file mode 100644 index b5ae911..0000000 --- a/app/module/research_journals/response/research_journals.response.go +++ /dev/null @@ -1,25 +0,0 @@ -package response - -import ( - "time" -) - -type ResearchJournalsResponse struct { - ID uint `json:"id"` - UserID uint `json:"userId"` - JournalTitle string `json:"journalTitle"` - Publisher string `json:"publisher"` - JournalURL string `json:"journalUrl"` - PublishedDate *time.Time `json:"publishedDate"` - PublishedYear *int `json:"publishedYear"` // extracted from PublishedDate - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - User *UserBasicInfo `json:"user,omitempty"` -} - -type UserBasicInfo struct { - ID uint `json:"id"` - Username string `json:"username"` - Fullname string `json:"fullname"` - Email string `json:"email"` -} diff --git a/app/module/research_journals/service/research_journals.service.go b/app/module/research_journals/service/research_journals.service.go deleted file mode 100644 index 3171884..0000000 --- a/app/module/research_journals/service/research_journals.service.go +++ /dev/null @@ -1,128 +0,0 @@ -package service - -import ( - "errors" - "jaecoo-be/app/module/research_journals/mapper" - "jaecoo-be/app/module/research_journals/repository" - "jaecoo-be/app/module/research_journals/request" - "jaecoo-be/app/module/research_journals/response" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/utils/paginator" - utilSvc "jaecoo-be/utils/service" - - "github.com/rs/zerolog" -) - -type researchJournalsService struct { - Repo repository.ResearchJournalsRepository - UsersRepo usersRepository.UsersRepository - Log zerolog.Logger -} - -type ResearchJournalsService interface { - All(authToken string, req request.ResearchJournalsQueryRequest) (researchJournals []*response.ResearchJournalsResponse, paging paginator.Pagination, err error) - Show(authToken string, id uint) (researchJournal *response.ResearchJournalsResponse, err error) - Save(authToken string, req request.ResearchJournalsCreateRequest) (researchJournal *response.ResearchJournalsResponse, err error) - Update(authToken string, id uint, req request.ResearchJournalsUpdateRequest) (err error) - Delete(authToken string, id uint) error -} - -func NewResearchJournalsService(repo repository.ResearchJournalsRepository, usersRepo usersRepository.UsersRepository, log zerolog.Logger) ResearchJournalsService { - return &researchJournalsService{ - Repo: repo, - UsersRepo: usersRepo, - Log: log, - } -} - -func (_i *researchJournalsService) All(authToken string, req request.ResearchJournalsQueryRequest) (researchJournals []*response.ResearchJournalsResponse, paging paginator.Pagination, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, paginator.Pagination{}, errors.New("unauthorized") - } - - results, paging, err := _i.Repo.GetAll(userInfo.ID, req) - if err != nil { - return - } - - for _, result := range results { - researchJournals = append(researchJournals, mapper.ResearchJournalsResponseMapper(result)) - } - - return -} - -func (_i *researchJournalsService) Show(authToken string, id uint) (researchJournal *response.ResearchJournalsResponse, err error) { - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, errors.New("unauthorized") - } - - result, err := _i.Repo.FindOneByUserAndId(userInfo.ID, id) - if err != nil { - return nil, err - } - - return mapper.ResearchJournalsResponseMapper(result), nil -} - -func (_i *researchJournalsService) Save(authToken string, req request.ResearchJournalsCreateRequest) (researchJournal *response.ResearchJournalsResponse, err error) { - _i.Log.Info().Interface("data", req).Msg("Creating research journal") - - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return nil, errors.New("unauthorized") - } - - entity := req.ToEntity() - entity.UserID = userInfo.ID - - result, err := _i.Repo.Create(entity) - if err != nil { - return nil, err - } - - return mapper.ResearchJournalsResponseMapper(result), nil -} - -func (_i *researchJournalsService) Update(authToken string, id uint, req request.ResearchJournalsUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("Updating research journal") - - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("unauthorized") - } - - // Check if record exists and belongs to user - existing, err := _i.Repo.FindOneByUserAndId(userInfo.ID, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("research journal not found") - } - - entity := req.ToEntity() - return _i.Repo.Update(userInfo.ID, id, entity) -} - -func (_i *researchJournalsService) Delete(authToken string, id uint) error { - _i.Log.Info().Str("authToken", authToken).Uint("id", id).Msg("Deleting research journal") - - userInfo := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken) - if userInfo == nil { - return errors.New("unauthorized") - } - - // Check if record exists and belongs to user - existing, err := _i.Repo.FindOneByUserAndId(userInfo.ID, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("research journal not found") - } - - return _i.Repo.Delete(userInfo.ID, id) -} diff --git a/app/module/subscription/controller/controller.go b/app/module/subscription/controller/controller.go deleted file mode 100644 index 919424b..0000000 --- a/app/module/subscription/controller/controller.go +++ /dev/null @@ -1,17 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/subscription/service" - - "github.com/rs/zerolog" -) - -type Controller struct { - Subscription SubscriptionController -} - -func NewController(SubscriptionService service.SubscriptionService, log zerolog.Logger) *Controller { - return &Controller{ - Subscription: NewSubscriptionController(SubscriptionService, log), - } -} diff --git a/app/module/subscription/controller/subscription.controller.go b/app/module/subscription/controller/subscription.controller.go deleted file mode 100644 index 72b85b6..0000000 --- a/app/module/subscription/controller/subscription.controller.go +++ /dev/null @@ -1,193 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/subscription/request" - "jaecoo-be/app/module/subscription/service" - "jaecoo-be/utils/paginator" - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" - "strconv" - - "github.com/gofiber/fiber/v2" - "github.com/rs/zerolog" -) - -type subscriptionController struct { - subscriptionService service.SubscriptionService - Log zerolog.Logger -} - -type SubscriptionController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error -} - -func NewSubscriptionController(subscriptionService service.SubscriptionService, log zerolog.Logger) SubscriptionController { - return &subscriptionController{ - subscriptionService: subscriptionService, - Log: log, - } -} - -// All get all Subscription -// @Summary Get all Subscription -// @Description API for getting all Subscription -// @Tags Subscription -// @Security Bearer -// @Param req query request.SubscriptionQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /subscription [get] -func (_i *subscriptionController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - - reqContext := request.SubscriptionQueryRequestContext{ - Email: c.Query("email"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - subscriptionData, paging, err := _i.subscriptionService.All(req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Subscription list successfully retrieved"}, - Data: subscriptionData, - Meta: paging, - }) -} - -// Show get one Subscription -// @Summary Get one Subscription -// @Description API for getting one Subscription -// @Tags Subscription -// @Security Bearer -// @Param id path int true "Subscription ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /subscription/{id} [get] -func (_i *subscriptionController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - subscriptionData, err := _i.subscriptionService.Show(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Subscription successfully retrieved"}, - Data: subscriptionData, - }) -} - -// Save create Subscription -// @Summary Create Subscription -// @Description API for create Subscription -// @Tags Subscription -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param payload body request.SubscriptionCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /subscription [post] -func (_i *subscriptionController) Save(c *fiber.Ctx) error { - req := new(request.SubscriptionCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - dataResult, err := _i.subscriptionService.Save(*req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Subscription successfully created"}, - Data: dataResult, - }) -} - -// Update update Subscription -// @Summary update Subscription -// @Description API for update Subscription -// @Tags Subscription -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param payload body request.SubscriptionUpdateRequest true "Required payload" -// @Param id path int true "Subscription ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /subscription/{id} [put] -func (_i *subscriptionController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - req := new(request.SubscriptionUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.subscriptionService.Update(uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Subscription successfully updated"}, - }) -} - -// Delete delete Subscription -// @Summary delete Subscription -// @Description API for delete Subscription -// @Tags Subscription -// @Security Bearer -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Subscription ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 401 {object} response.UnauthorizedError -// @Failure 500 {object} response.InternalServerError -// @Router /subscription/{id} [delete] -func (_i *subscriptionController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - err = _i.subscriptionService.Delete(uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Subscription successfully deleted"}, - }) -} diff --git a/app/module/subscription/mapper/subscription.mapper.go b/app/module/subscription/mapper/subscription.mapper.go deleted file mode 100644 index 1ff1697..0000000 --- a/app/module/subscription/mapper/subscription.mapper.go +++ /dev/null @@ -1,19 +0,0 @@ -package mapper - -import ( - "jaecoo-be/app/database/entity" - res "jaecoo-be/app/module/subscription/response" -) - -func SubscriptionResponseMapper(subscriptionReq *entity.Subscription) (subscriptionRes *res.SubscriptionResponse) { - if subscriptionReq != nil { - subscriptionRes = &res.SubscriptionResponse{ - ID: subscriptionReq.ID, - Email: subscriptionReq.Email, - IsActive: subscriptionReq.IsActive, - CreatedAt: subscriptionReq.CreatedAt, - UpdatedAt: subscriptionReq.UpdatedAt, - } - } - return subscriptionRes -} diff --git a/app/module/subscription/repository/subscription.repository.go b/app/module/subscription/repository/subscription.repository.go deleted file mode 100644 index 0f76991..0000000 --- a/app/module/subscription/repository/subscription.repository.go +++ /dev/null @@ -1,93 +0,0 @@ -package repository - -import ( - "fmt" - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/subscription/request" - "jaecoo-be/utils/paginator" - "strings" - - "github.com/rs/zerolog" -) - -type subscriptionRepository struct { - DB *database.Database - Log zerolog.Logger -} - -// SubscriptionRepository define interface of ISubscriptionRepository -type SubscriptionRepository interface { - GetAll(req request.SubscriptionQueryRequest) (subscriptions []*entity.Subscription, paging paginator.Pagination, err error) - FindOne(id uint) (subscription *entity.Subscription, err error) - Create(subscription *entity.Subscription) (subscriptionReturn *entity.Subscription, err error) - Update(id uint, subscription *entity.Subscription) (err error) - Delete(id uint) (err error) -} - -func NewSubscriptionRepository(db *database.Database, logger zerolog.Logger) SubscriptionRepository { - return &subscriptionRepository{ - DB: db, - Log: logger, - } -} - -// implement interface of ISubscriptionRepository -func (_i *subscriptionRepository) GetAll(req request.SubscriptionQueryRequest) (subscriptions []*entity.Subscription, paging paginator.Pagination, err error) { - var count int64 - - query := _i.DB.DB.Model(&entity.Subscription{}) - - query = query.Where("is_active = ?", true) - - if req.Email != nil && *req.Email != "" { - email := strings.ToLower(*req.Email) - query = query.Where("LOWER(email) LIKE ?", "%"+strings.ToLower(email)+"%") - } - query.Count(&count) - - if req.Pagination.SortBy != "" { - direction := "ASC" - if req.Pagination.Sort == "desc" { - direction = "DESC" - } - query.Order(fmt.Sprintf("%s %s", req.Pagination.SortBy, direction)) - } - - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&subscriptions).Error - if err != nil { - return - } - - paging = *req.Pagination - - return -} - -func (_i *subscriptionRepository) FindOne(id uint) (subscription *entity.Subscription, err error) { - query := _i.DB.DB.Where("id = ?", id) - - if err := query.First(&subscription).Error; err != nil { - return nil, err - } - - return subscription, nil -} - -func (_i *subscriptionRepository) Create(subscription *entity.Subscription) (subscriptionReturn *entity.Subscription, err error) { - result := _i.DB.DB.Create(subscription) - return subscription, result.Error -} - -func (_i *subscriptionRepository) Update(id uint, subscription *entity.Subscription) (err error) { - query := _i.DB.DB.Model(&entity.Subscription{}).Where(&entity.Subscription{ID: id}) - return query.Updates(subscription).Error -} - -func (_i *subscriptionRepository) Delete(id uint) error { - query := _i.DB.DB.Model(&entity.Subscription{}).Where("id = ?", id) - return query.Delete(&entity.Subscription{}).Error -} diff --git a/app/module/subscription/request/subscription.request.go b/app/module/subscription/request/subscription.request.go deleted file mode 100644 index f7b157d..0000000 --- a/app/module/subscription/request/subscription.request.go +++ /dev/null @@ -1,53 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "time" -) - -type SubscriptionGeneric interface { - ToEntity() -} - -type SubscriptionQueryRequest struct { - Email *string `json:"email"` - Pagination *paginator.Pagination `json:"pagination"` -} - -type SubscriptionCreateRequest struct { - Email string `json:"email" validate:"required,email"` -} - -func (req SubscriptionCreateRequest) ToEntity() *entity.Subscription { - return &entity.Subscription{ - Email: req.Email, - } -} - -type SubscriptionUpdateRequest struct { - ID uint `json:"id" validate:"required"` - Email string `json:"email" validate:"required,email"` -} - -func (req SubscriptionUpdateRequest) ToEntity() *entity.Subscription { - return &entity.Subscription{ - ID: req.ID, - Email: req.Email, - UpdatedAt: time.Now(), - } -} - -type SubscriptionQueryRequestContext struct { - Email string `json:"email"` -} - -func (req SubscriptionQueryRequestContext) ToParamRequest() SubscriptionQueryRequest { - var request SubscriptionQueryRequest - - if email := req.Email; email != "" { - request.Email = &email - } - - return request -} diff --git a/app/module/subscription/response/subscription.response.go b/app/module/subscription/response/subscription.response.go deleted file mode 100644 index b25d2d1..0000000 --- a/app/module/subscription/response/subscription.response.go +++ /dev/null @@ -1,11 +0,0 @@ -package response - -import "time" - -type SubscriptionResponse struct { - ID uint `json:"id"` - Email string `json:"email"` - IsActive bool `json:"isActive"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` -} diff --git a/app/module/subscription/service/subscription.service.go b/app/module/subscription/service/subscription.service.go deleted file mode 100644 index a836946..0000000 --- a/app/module/subscription/service/subscription.service.go +++ /dev/null @@ -1,87 +0,0 @@ -package service - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/subscription/mapper" - "jaecoo-be/app/module/subscription/repository" - "jaecoo-be/app/module/subscription/request" - "jaecoo-be/app/module/subscription/response" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/utils/paginator" - - "github.com/rs/zerolog" -) - -// SubscriptionService -type subscriptionService struct { - Repo repository.SubscriptionRepository - UsersRepo usersRepository.UsersRepository - Log zerolog.Logger -} - -// SubscriptionService define interface of ISubscriptionService -type SubscriptionService interface { - All(req request.SubscriptionQueryRequest) (subscription []*response.SubscriptionResponse, paging paginator.Pagination, err error) - Show(id uint) (subscription *response.SubscriptionResponse, err error) - Save(req request.SubscriptionCreateRequest) (subscription *entity.Subscription, err error) - Update(id uint, req request.SubscriptionUpdateRequest) (err error) - Delete(id uint) error -} - -// NewSubscriptionService init SubscriptionService -func NewSubscriptionService(repo repository.SubscriptionRepository, log zerolog.Logger, usersRepo usersRepository.UsersRepository) SubscriptionService { - - return &subscriptionService{ - Repo: repo, - Log: log, - UsersRepo: usersRepo, - } -} - -// All implement interface of SubscriptionService -func (_i *subscriptionService) All(req request.SubscriptionQueryRequest) (subscriptions []*response.SubscriptionResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req) - if err != nil { - return - } - - for _, result := range results { - subscriptions = append(subscriptions, mapper.SubscriptionResponseMapper(result)) - } - - return -} - -func (_i *subscriptionService) Show(id uint) (subscription *response.SubscriptionResponse, err error) { - result, err := _i.Repo.FindOne(id) - if err != nil { - return nil, err - } - - return mapper.SubscriptionResponseMapper(result), nil -} - -func (_i *subscriptionService) Save(req request.SubscriptionCreateRequest) (subscription *entity.Subscription, err error) { - _i.Log.Info().Interface("data", req).Msg("") - newReq := req.ToEntity() - - return _i.Repo.Create(newReq) -} - -func (_i *subscriptionService) Update(id uint, req request.SubscriptionUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("") - - entity := req.ToEntity() - - return _i.Repo.Update(id, entity) -} - -func (_i *subscriptionService) Delete(id uint) error { - result, err := _i.Repo.FindOne(id) - if err != nil { - return err - } - - result.IsActive = false - return _i.Repo.Update(id, result) -} diff --git a/app/module/subscription/subscription.module.go b/app/module/subscription/subscription.module.go deleted file mode 100644 index c827e6d..0000000 --- a/app/module/subscription/subscription.module.go +++ /dev/null @@ -1,54 +0,0 @@ -package subscription - -import ( - "jaecoo-be/app/module/subscription/controller" - "jaecoo-be/app/module/subscription/repository" - "jaecoo-be/app/module/subscription/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of SubscriptionRouter -type SubscriptionRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// register bulky of Subscription module -var NewSubscriptionModule = fx.Options( - // register repository of Subscription module - fx.Provide(repository.NewSubscriptionRepository), - - // register service of Subscription module - fx.Provide(service.NewSubscriptionService), - - // register controller of Subscription module - fx.Provide(controller.NewController), - - // register router of Subscription module - fx.Provide(NewSubscriptionRouter), -) - -// init SubscriptionRouter -func NewSubscriptionRouter(fiber *fiber.App, controller *controller.Controller) *SubscriptionRouter { - return &SubscriptionRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of Subscription module -func (_i *SubscriptionRouter) RegisterSubscriptionRoutes() { - // define controllers - subscriptionController := _i.Controller.Subscription - - // define routes - _i.App.Route("/subscription", func(router fiber.Router) { - router.Get("/", subscriptionController.All) - router.Get("/:id", subscriptionController.Show) - router.Post("/", subscriptionController.Save) - router.Put("/:id", subscriptionController.Update) - router.Delete("/:id", subscriptionController.Delete) - }) -} diff --git a/app/module/users/service/users.service.go b/app/module/users/service/users.service.go index ddcdeff..fbadfe4 100644 --- a/app/module/users/service/users.service.go +++ b/app/module/users/service/users.service.go @@ -329,7 +329,7 @@ func (_i *usersService) ForgotPassword(req request.UserForgotPassword) (err erro } // send email forgot password - url := fmt.Sprintf("https://kontenhumas.com/setup-password?userId=%s&code=%s", *user.KeycloakId, codeRequest) + url := fmt.Sprintf("https://jaecoocihampelasbdg.com/setup-password?userId=%s&code=%s", *user.KeycloakId, codeRequest) subject := "[HUMAS POLRI] Forgot Password" htmlBody := "

Anda telah mengirimkan permintaan untuk melakukan reset password.

" diff --git a/app/module/work_history/controller/controller.go b/app/module/work_history/controller/controller.go deleted file mode 100644 index 435b27c..0000000 --- a/app/module/work_history/controller/controller.go +++ /dev/null @@ -1,13 +0,0 @@ -package controller - -import "jaecoo-be/app/module/work_history/service" - -type Controller struct { - WorkHistory WorkHistoryController -} - -func NewController(WorkHistoryService service.WorkHistoryService) *Controller { - return &Controller{ - WorkHistory: NewWorkHistoryController(WorkHistoryService), - } -} diff --git a/app/module/work_history/controller/work_history.controller.go b/app/module/work_history/controller/work_history.controller.go deleted file mode 100644 index 7d9138b..0000000 --- a/app/module/work_history/controller/work_history.controller.go +++ /dev/null @@ -1,218 +0,0 @@ -package controller - -import ( - "jaecoo-be/app/module/work_history/request" - "jaecoo-be/app/module/work_history/service" - "jaecoo-be/utils/paginator" - utilRes "jaecoo-be/utils/response" - utilVal "jaecoo-be/utils/validator" - "strconv" - - "github.com/gofiber/fiber/v2" -) - -type workHistoryController struct { - workHistoryService service.WorkHistoryService -} - -type WorkHistoryController interface { - All(c *fiber.Ctx) error - Show(c *fiber.Ctx) error - Save(c *fiber.Ctx) error - Update(c *fiber.Ctx) error - Delete(c *fiber.Ctx) error -} - -func NewWorkHistoryController(workHistoryService service.WorkHistoryService) WorkHistoryController { - return &workHistoryController{ - workHistoryService: workHistoryService, - } -} - -// All Work History -// @Summary Get all Work History -// @Description API for getting all Work History for specific user -// @Tags Work History -// @Param req query request.WorkHistoryQueryRequest false "query parameters" -// @Param req query paginator.Pagination false "pagination parameters" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 500 {object} response.InternalServerError -// @Router /work-history [get] -func (_i *workHistoryController) All(c *fiber.Ctx) error { - paginate, err := paginator.Paginate(c) - if err != nil { - return err - } - reqContext := request.WorkHistoryQueryRequestContext{ - JobTitle: c.Query("jobTitle"), - CompanyName: c.Query("companyName"), - IsCurrent: c.Query("isCurrent"), - UserID: c.Query("userId"), - } - req := reqContext.ToParamRequest() - req.Pagination = paginate - - workData, paging, err := _i.workHistoryService.All(req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Work history list successfully retrieved"}, - Data: workData, - Meta: paging, - }) -} - -// Show Work History -// @Summary Get one Work History -// @Description API for getting one Work History -// @Tags Work History -// @Param id path int true "Work History ID" -// @Param userId query uint true "User ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 500 {object} response.InternalServerError -// @Router /work-history/{id} [get] -func (_i *workHistoryController) Show(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - userId, err := strconv.ParseUint(c.Query("userId"), 10, 0) - if err != nil { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"userId parameter is required and must be a valid number"}, - }) - } - - workData, err := _i.workHistoryService.Show(uint(userId), uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Work history successfully retrieved"}, - Data: workData, - }) -} - -// Save Work History -// @Summary Create Work History -// @Description API for create Work History -// @Tags Work History -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param userId query uint true "User ID" -// @Param payload body request.WorkHistoryCreateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 500 {object} response.InternalServerError -// @Router /work-history [post] -func (_i *workHistoryController) Save(c *fiber.Ctx) error { - userId, err := strconv.ParseUint(c.Query("userId"), 10, 0) - if err != nil { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"userId parameter is required and must be a valid number"}, - }) - } - - req := new(request.WorkHistoryCreateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - dataResult, err := _i.workHistoryService.Save(uint(userId), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Work history successfully created"}, - Data: dataResult, - }) -} - -// Update Work History -// @Summary Update Work History -// @Description API for update Work History -// @Tags Work History -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Work History ID" -// @Param userId query uint true "User ID" -// @Param payload body request.WorkHistoryUpdateRequest true "Required payload" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 500 {object} response.InternalServerError -// @Router /work-history/{id} [put] -func (_i *workHistoryController) Update(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - userId, err := strconv.ParseUint(c.Query("userId"), 10, 0) - if err != nil { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"userId parameter is required and must be a valid number"}, - }) - } - - req := new(request.WorkHistoryUpdateRequest) - if err := utilVal.ParseAndValidate(c, req); err != nil { - return err - } - - err = _i.workHistoryService.Update(uint(userId), uint(id), *req) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Work history successfully updated"}, - }) -} - -// Delete Work History -// @Summary Delete Work History -// @Description API for delete Work History -// @Tags Work History -// @Param X-Csrf-Token header string true "Insert the X-Csrf-Token" -// @Param id path int true "Work History ID" -// @Param userId query uint true "User ID" -// @Success 200 {object} response.Response -// @Failure 400 {object} response.BadRequestError -// @Failure 500 {object} response.InternalServerError -// @Router /work-history/{id} [delete] -func (_i *workHistoryController) Delete(c *fiber.Ctx) error { - id, err := strconv.ParseUint(c.Params("id"), 10, 0) - if err != nil { - return err - } - - userId, err := strconv.ParseUint(c.Query("userId"), 10, 0) - if err != nil { - return utilRes.Resp(c, utilRes.Response{ - Success: false, - Messages: utilRes.Messages{"userId parameter is required and must be a valid number"}, - }) - } - - err = _i.workHistoryService.Delete(uint(userId), uint(id)) - if err != nil { - return err - } - - return utilRes.Resp(c, utilRes.Response{ - Success: true, - Messages: utilRes.Messages{"Work history successfully deleted"}, - }) -} diff --git a/app/module/work_history/mapper/work_history.mapper.go b/app/module/work_history/mapper/work_history.mapper.go deleted file mode 100644 index a2c0928..0000000 --- a/app/module/work_history/mapper/work_history.mapper.go +++ /dev/null @@ -1,59 +0,0 @@ -package mapper - -import ( - "fmt" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/work_history/response" - "time" -) - -func WorkHistoryResponseMapper(workHistory *entity.WorkHistory) *response.WorkHistoryResponse { - result := &response.WorkHistoryResponse{ - ID: workHistory.ID, - UserID: workHistory.UserID, - JobTitle: workHistory.JobTitle, - CompanyName: workHistory.CompanyName, - StartDate: workHistory.StartDate, - EndDate: workHistory.EndDate, - IsCurrent: workHistory.EndDate == nil, - Duration: calculateDuration(workHistory.StartDate, workHistory.EndDate), - CreatedAt: workHistory.CreatedAt, - UpdatedAt: workHistory.UpdatedAt, - } - - if workHistory.User != nil { - result.User = &response.UserBasicInfo{ - ID: workHistory.User.ID, - Username: workHistory.User.Username, - Fullname: workHistory.User.Fullname, - Email: workHistory.User.Email, - } - } - - return result -} - -func calculateDuration(startDate time.Time, endDate *time.Time) string { - var end time.Time - if endDate == nil { - end = time.Now() - } else { - end = *endDate - } - - duration := end.Sub(startDate) - days := int(duration.Hours() / 24) - years := days / 365 - months := (days % 365) / 30 - - if years > 0 { - if months > 0 { - return fmt.Sprintf("%d tahun %d bulan", years, months) - } - return fmt.Sprintf("%d tahun", years) - } else if months > 0 { - return fmt.Sprintf("%d bulan", months) - } else { - return fmt.Sprintf("%d hari", days) - } -} diff --git a/app/module/work_history/repository/work_history.repository.go b/app/module/work_history/repository/work_history.repository.go deleted file mode 100644 index b40bac4..0000000 --- a/app/module/work_history/repository/work_history.repository.go +++ /dev/null @@ -1,88 +0,0 @@ -package repository - -import ( - "jaecoo-be/app/database" - "jaecoo-be/app/database/entity" - "jaecoo-be/app/module/work_history/request" - "jaecoo-be/utils/paginator" -) - -type workHistoryRepository struct { - DB *database.Database -} - -type WorkHistoryRepository interface { - GetAll(userId uint, req request.WorkHistoryQueryRequest) (workHistories []*entity.WorkHistory, paging paginator.Pagination, err error) - FindOneByUserAndId(userId uint, id uint) (workHistory *entity.WorkHistory, err error) - Create(workHistory *entity.WorkHistory) (result *entity.WorkHistory, err error) - Update(userId uint, id uint, workHistory *entity.WorkHistory) (err error) - Delete(userId uint, id uint) (err error) -} - -func NewWorkHistoryRepository(db *database.Database) WorkHistoryRepository { - return &workHistoryRepository{ - DB: db, - } -} - -func (_i *workHistoryRepository) GetAll(userId uint, req request.WorkHistoryQueryRequest) (workHistories []*entity.WorkHistory, paging paginator.Pagination, err error) { - query := _i.DB.DB.Where("user_id = ?", userId) - - // Apply filters - if req.JobTitle != nil { - query = query.Where("job_title ILIKE ?", "%"+*req.JobTitle+"%") - } - if req.CompanyName != nil { - query = query.Where("company_name ILIKE ?", "%"+*req.CompanyName+"%") - } - if req.IsCurrent != nil { - if *req.IsCurrent { - query = query.Where("end_date IS NULL") - } else { - query = query.Where("end_date IS NOT NULL") - } - } - - // Include user relationship - query = query.Preload("User") - - // Order by start date desc (most recent first) - query = query.Order("start_date DESC") - - // Apply pagination - var count int64 - query.Count(&count) - req.Pagination.Count = count - req.Pagination = paginator.Paging(req.Pagination) - - err = query.Offset(req.Pagination.Offset).Limit(req.Pagination.Limit).Find(&workHistories).Error - paging = *req.Pagination - - return -} - -func (_i *workHistoryRepository) FindOneByUserAndId(userId uint, id uint) (workHistory *entity.WorkHistory, err error) { - err = _i.DB.DB.Where("user_id = ? AND id = ?", userId, id).Preload("User").First(&workHistory).Error - return -} - -func (_i *workHistoryRepository) Create(workHistory *entity.WorkHistory) (result *entity.WorkHistory, err error) { - err = _i.DB.DB.Create(workHistory).Error - if err != nil { - return nil, err - } - - // Reload with relationships - err = _i.DB.DB.Preload("User").First(&result, workHistory.ID).Error - return -} - -func (_i *workHistoryRepository) Update(userId uint, id uint, workHistory *entity.WorkHistory) (err error) { - err = _i.DB.DB.Where("user_id = ? AND id = ?", userId, id).Updates(workHistory).Error - return -} - -func (_i *workHistoryRepository) Delete(userId uint, id uint) (err error) { - err = _i.DB.DB.Where("user_id = ? AND id = ?", userId, id).Delete(&entity.WorkHistory{}).Error - return -} diff --git a/app/module/work_history/request/work_history.request.go b/app/module/work_history/request/work_history.request.go deleted file mode 100644 index a81463d..0000000 --- a/app/module/work_history/request/work_history.request.go +++ /dev/null @@ -1,85 +0,0 @@ -package request - -import ( - "jaecoo-be/app/database/entity" - "jaecoo-be/utils/paginator" - "strconv" - "time" -) - -type WorkHistoryQueryRequest struct { - UserID uint `json:"userId" validate:"required"` - JobTitle *string `json:"jobTitle"` - CompanyName *string `json:"companyName"` - IsCurrent *bool `json:"isCurrent"` // filter for current job (EndDate is null) - Pagination *paginator.Pagination `json:"pagination"` -} - -type WorkHistoryCreateRequest struct { - JobTitle string `json:"jobTitle" validate:"required,min=2,max=255"` - CompanyName string `json:"companyName" validate:"required,min=2,max=255"` - StartDate time.Time `json:"startDate" validate:"required"` - EndDate *time.Time `json:"endDate"` -} - -func (req WorkHistoryCreateRequest) ToEntity(userId uint) *entity.WorkHistory { - return &entity.WorkHistory{ - UserID: userId, - JobTitle: req.JobTitle, - CompanyName: req.CompanyName, - StartDate: req.StartDate, - EndDate: req.EndDate, - } -} - -type WorkHistoryUpdateRequest struct { - JobTitle string `json:"jobTitle" validate:"required,min=2,max=255"` - CompanyName string `json:"companyName" validate:"required,min=2,max=255"` - StartDate time.Time `json:"startDate" validate:"required"` - EndDate *time.Time `json:"endDate"` -} - -func (req WorkHistoryUpdateRequest) ToEntity(userId uint) *entity.WorkHistory { - return &entity.WorkHistory{ - UserID: userId, - JobTitle: req.JobTitle, - CompanyName: req.CompanyName, - StartDate: req.StartDate, - EndDate: req.EndDate, - } -} - -type WorkHistoryQueryRequestContext struct { - UserID string `json:"userId"` - JobTitle string `json:"jobTitle"` - CompanyName string `json:"companyName"` - IsCurrent string `json:"isCurrent"` -} - -func (req WorkHistoryQueryRequestContext) ToParamRequest() WorkHistoryQueryRequest { - var request WorkHistoryQueryRequest - - if userId := req.UserID; userId != "" { - userIdUint, err := strconv.ParseUint(userId, 10, 0) - if err == nil { - request.UserID = uint(userIdUint) - } - } - if jobTitle := req.JobTitle; jobTitle != "" { - request.JobTitle = &jobTitle - } - if companyName := req.CompanyName; companyName != "" { - request.CompanyName = &companyName - } - if isCurrent := req.IsCurrent; isCurrent != "" { - if isCurrent == "true" { - isCurrentBool := true - request.IsCurrent = &isCurrentBool - } else if isCurrent == "false" { - isCurrentBool := false - request.IsCurrent = &isCurrentBool - } - } - - return request -} diff --git a/app/module/work_history/response/work_history.response.go b/app/module/work_history/response/work_history.response.go deleted file mode 100644 index e8be493..0000000 --- a/app/module/work_history/response/work_history.response.go +++ /dev/null @@ -1,26 +0,0 @@ -package response - -import ( - "time" -) - -type WorkHistoryResponse struct { - ID uint `json:"id"` - UserID uint `json:"userId"` - JobTitle string `json:"jobTitle"` - CompanyName string `json:"companyName"` - StartDate time.Time `json:"startDate"` - EndDate *time.Time `json:"endDate"` - IsCurrent bool `json:"isCurrent"` // true if EndDate is null - Duration string `json:"duration"` // calculated duration string - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - User *UserBasicInfo `json:"user,omitempty"` -} - -type UserBasicInfo struct { - ID uint `json:"id"` - Username string `json:"username"` - Fullname string `json:"fullname"` - Email string `json:"email"` -} diff --git a/app/module/work_history/service/work_history.service.go b/app/module/work_history/service/work_history.service.go deleted file mode 100644 index ea8f23a..0000000 --- a/app/module/work_history/service/work_history.service.go +++ /dev/null @@ -1,111 +0,0 @@ -package service - -import ( - "errors" - usersRepository "jaecoo-be/app/module/users/repository" - "jaecoo-be/app/module/work_history/mapper" - "jaecoo-be/app/module/work_history/repository" - "jaecoo-be/app/module/work_history/request" - "jaecoo-be/app/module/work_history/response" - "jaecoo-be/utils/paginator" - - "github.com/rs/zerolog" -) - -type workHistoryService struct { - Repo repository.WorkHistoryRepository - UsersRepo usersRepository.UsersRepository - Log zerolog.Logger -} - -type WorkHistoryService interface { - All(req request.WorkHistoryQueryRequest) (workHistories []*response.WorkHistoryResponse, paging paginator.Pagination, err error) - Show(userId uint, id uint) (workHistory *response.WorkHistoryResponse, err error) - Save(userId uint, req request.WorkHistoryCreateRequest) (workHistory *response.WorkHistoryResponse, err error) - Update(userId uint, id uint, req request.WorkHistoryUpdateRequest) (err error) - Delete(userId uint, id uint) error -} - -func NewWorkHistoryService(repo repository.WorkHistoryRepository, usersRepo usersRepository.UsersRepository, log zerolog.Logger) WorkHistoryService { - return &workHistoryService{ - Repo: repo, - UsersRepo: usersRepo, - Log: log, - } -} - -func (_i *workHistoryService) All(req request.WorkHistoryQueryRequest) (workHistories []*response.WorkHistoryResponse, paging paginator.Pagination, err error) { - results, paging, err := _i.Repo.GetAll(req.UserID, req) - if err != nil { - return - } - - for _, result := range results { - workHistories = append(workHistories, mapper.WorkHistoryResponseMapper(result)) - } - - return -} - -func (_i *workHistoryService) Show(userId uint, id uint) (workHistory *response.WorkHistoryResponse, err error) { - result, err := _i.Repo.FindOneByUserAndId(userId, id) - if err != nil { - return nil, err - } - - return mapper.WorkHistoryResponseMapper(result), nil -} - -func (_i *workHistoryService) Save(userId uint, req request.WorkHistoryCreateRequest) (workHistory *response.WorkHistoryResponse, err error) { - _i.Log.Info().Interface("data", req).Msg("Creating work history") - - // Validate business rules - if req.EndDate != nil && req.EndDate.Before(req.StartDate) { - return nil, errors.New("end date cannot be before start date") - } - - entity := req.ToEntity(userId) - - result, err := _i.Repo.Create(entity) - if err != nil { - return nil, err - } - - return mapper.WorkHistoryResponseMapper(result), nil -} - -func (_i *workHistoryService) Update(userId uint, id uint, req request.WorkHistoryUpdateRequest) (err error) { - _i.Log.Info().Interface("data", req).Msg("Updating work history") - - // Check if record exists and belongs to user - existing, err := _i.Repo.FindOneByUserAndId(userId, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("work history not found") - } - - // Validate business rules - if req.EndDate != nil && req.EndDate.Before(req.StartDate) { - return errors.New("end date cannot be before start date") - } - - entity := req.ToEntity(userId) - return _i.Repo.Update(userId, id, entity) -} - -func (_i *workHistoryService) Delete(userId uint, id uint) error { - _i.Log.Info().Uint("userId", userId).Uint("id", id).Msg("Deleting work history") - - // Check if record exists and belongs to user - existing, err := _i.Repo.FindOneByUserAndId(userId, id) - if err != nil { - return err - } - if existing == nil { - return errors.New("work history not found") - } - - return _i.Repo.Delete(userId, id) -} diff --git a/app/module/work_history/work_history.module.go b/app/module/work_history/work_history.module.go deleted file mode 100644 index e7a2926..0000000 --- a/app/module/work_history/work_history.module.go +++ /dev/null @@ -1,54 +0,0 @@ -package work_history - -import ( - "jaecoo-be/app/module/work_history/controller" - "jaecoo-be/app/module/work_history/repository" - "jaecoo-be/app/module/work_history/service" - - "github.com/gofiber/fiber/v2" - "go.uber.org/fx" -) - -// struct of WorkHistoryRouter -type WorkHistoryRouter struct { - App fiber.Router - Controller *controller.Controller -} - -// register bulky of WorkHistory module -var NewWorkHistoryModule = fx.Options( - // register repository of WorkHistory module - fx.Provide(repository.NewWorkHistoryRepository), - - // register service of WorkHistory module - fx.Provide(service.NewWorkHistoryService), - - // register controller of WorkHistory module - fx.Provide(controller.NewController), - - // register router of WorkHistory module - fx.Provide(NewWorkHistoryRouter), -) - -// init WorkHistoryRouter -func NewWorkHistoryRouter(fiber *fiber.App, controller *controller.Controller) *WorkHistoryRouter { - return &WorkHistoryRouter{ - App: fiber, - Controller: controller, - } -} - -// register routes of WorkHistory module -func (_i *WorkHistoryRouter) RegisterWorkHistoryRoutes() { - // define controllers - workHistoryController := _i.Controller.WorkHistory - - // define routes - _i.App.Route("/work-history", func(router fiber.Router) { - router.Get("/", workHistoryController.All) - router.Get("/:id", workHistoryController.Show) - router.Post("/", workHistoryController.Save) - router.Put("/:id", workHistoryController.Update) - router.Delete("/:id", workHistoryController.Delete) - }) -} diff --git a/app/router/api.go b/app/router/api.go index 9162eb5..28ed7ce 100644 --- a/app/router/api.go +++ b/app/router/api.go @@ -2,37 +2,21 @@ package router import ( "jaecoo-be/app/module/activity_logs" - "jaecoo-be/app/module/advertisement" - "jaecoo-be/app/module/ai_chat" "jaecoo-be/app/module/article_approvals" "jaecoo-be/app/module/article_categories" "jaecoo-be/app/module/article_category_details" "jaecoo-be/app/module/article_comments" "jaecoo-be/app/module/article_files" "jaecoo-be/app/module/articles" - "jaecoo-be/app/module/campaign_destinations" - "jaecoo-be/app/module/campaign_files" - "jaecoo-be/app/module/campaign_types" - "jaecoo-be/app/module/campaigns" - "jaecoo-be/app/module/chat" "jaecoo-be/app/module/cities" "jaecoo-be/app/module/custom_static_pages" "jaecoo-be/app/module/districts" - "jaecoo-be/app/module/ebooks" - "jaecoo-be/app/module/education_history" "jaecoo-be/app/module/feedbacks" - "jaecoo-be/app/module/magazine_files" - "jaecoo-be/app/module/magazines" - "jaecoo-be/app/module/master_menus" - "jaecoo-be/app/module/master_modules" "jaecoo-be/app/module/provinces" - "jaecoo-be/app/module/research_journals" - "jaecoo-be/app/module/subscription" "jaecoo-be/app/module/user_levels" "jaecoo-be/app/module/user_role_accesses" "jaecoo-be/app/module/user_roles" "jaecoo-be/app/module/users" - "jaecoo-be/app/module/work_history" "jaecoo-be/config/config" _ "jaecoo-be/docs/swagger" @@ -45,37 +29,21 @@ type Router struct { Cfg *config.Config ActivityLogsRouter *activity_logs.ActivityLogsRouter - AdvertisementRouter *advertisement.AdvertisementRouter - AIChatRouter *ai_chat.AIChatRouter ArticleCategoriesRouter *article_categories.ArticleCategoriesRouter ArticleCategoryDetailsRouter *article_category_details.ArticleCategoryDetailsRouter ArticleFilesRouter *article_files.ArticleFilesRouter ArticleCommentsRouter *article_comments.ArticleCommentsRouter ArticleApprovalsRouter *article_approvals.ArticleApprovalsRouter ArticlesRouter *articles.ArticlesRouter - ChatRouter *chat.ChatRouter CitiesRouter *cities.CitiesRouter CustomStaticPagesRouter *custom_static_pages.CustomStaticPagesRouter DistrictsRouter *districts.DistrictsRouter - EbooksRouter *ebooks.EbooksRouter FeedbacksRouter *feedbacks.FeedbacksRouter - MagazineFilesRouter *magazine_files.MagazineFilesRouter - MagazinesRouter *magazines.MagazinesRouter - MasterMenusRouter *master_menus.MasterMenusRouter - MasterModulesRouter *master_modules.MasterModulesRouter ProvincesRouter *provinces.ProvincesRouter - SubscriptionRouter *subscription.SubscriptionRouter UserLevelsRouter *user_levels.UserLevelsRouter UserRoleAccessesRouter *user_role_accesses.UserRoleAccessesRouter UserRolesRouter *user_roles.UserRolesRouter UsersRouter *users.UsersRouter - EducationHistoryRouter *education_history.EducationHistoryRouter - WorkHistoryRouter *work_history.WorkHistoryRouter - ResearchJournalsRouter *research_journals.ResearchJournalsRouter - CampaignTypesRouter *campaign_types.CampaignTypesRouter - CampaignDestinationsRouter *campaign_destinations.CampaignDestinationsRouter - CampaignsRouter *campaigns.CampaignsRouter - CampaignFilesRouter *campaign_files.CampaignFilesRouter } func NewRouter( @@ -83,73 +51,41 @@ func NewRouter( cfg *config.Config, activityLogsRouter *activity_logs.ActivityLogsRouter, - advertisementRouter *advertisement.AdvertisementRouter, - aiChatRouter *ai_chat.AIChatRouter, articleCategoriesRouter *article_categories.ArticleCategoriesRouter, articleCategoryDetailsRouter *article_category_details.ArticleCategoryDetailsRouter, articleFilesRouter *article_files.ArticleFilesRouter, articleCommentsRouter *article_comments.ArticleCommentsRouter, articleApprovalsRouter *article_approvals.ArticleApprovalsRouter, articlesRouter *articles.ArticlesRouter, - chatRouter *chat.ChatRouter, citiesRouter *cities.CitiesRouter, customStaticPagesRouter *custom_static_pages.CustomStaticPagesRouter, districtsRouter *districts.DistrictsRouter, - ebooksRouter *ebooks.EbooksRouter, feedbacksRouter *feedbacks.FeedbacksRouter, - magazineFilesRouter *magazine_files.MagazineFilesRouter, - magazinesRouter *magazines.MagazinesRouter, - masterMenuRouter *master_menus.MasterMenusRouter, - masterModuleRouter *master_modules.MasterModulesRouter, provincesRouter *provinces.ProvincesRouter, - subscriptionRouter *subscription.SubscriptionRouter, userLevelsRouter *user_levels.UserLevelsRouter, userRoleAccessesRouter *user_role_accesses.UserRoleAccessesRouter, userRolesRouter *user_roles.UserRolesRouter, usersRouter *users.UsersRouter, - educationHistoryRouter *education_history.EducationHistoryRouter, - workHistoryRouter *work_history.WorkHistoryRouter, - researchJournalsRouter *research_journals.ResearchJournalsRouter, - campaignTypesRouter *campaign_types.CampaignTypesRouter, - campaignDestinationsRouter *campaign_destinations.CampaignDestinationsRouter, - campaignsRouter *campaigns.CampaignsRouter, - campaignFilesRouter *campaign_files.CampaignFilesRouter, ) *Router { return &Router{ App: fiber, Cfg: cfg, ActivityLogsRouter: activityLogsRouter, - AdvertisementRouter: advertisementRouter, - AIChatRouter: aiChatRouter, ArticleCategoriesRouter: articleCategoriesRouter, ArticleCategoryDetailsRouter: articleCategoryDetailsRouter, ArticleFilesRouter: articleFilesRouter, ArticleCommentsRouter: articleCommentsRouter, ArticleApprovalsRouter: articleApprovalsRouter, ArticlesRouter: articlesRouter, - ChatRouter: chatRouter, CitiesRouter: citiesRouter, CustomStaticPagesRouter: customStaticPagesRouter, DistrictsRouter: districtsRouter, - EbooksRouter: ebooksRouter, FeedbacksRouter: feedbacksRouter, - MagazineFilesRouter: magazineFilesRouter, - MagazinesRouter: magazinesRouter, - MasterMenusRouter: masterMenuRouter, - MasterModulesRouter: masterModuleRouter, ProvincesRouter: provincesRouter, - SubscriptionRouter: subscriptionRouter, UserLevelsRouter: userLevelsRouter, UserRoleAccessesRouter: userRoleAccessesRouter, UserRolesRouter: userRolesRouter, UsersRouter: usersRouter, - EducationHistoryRouter: educationHistoryRouter, - WorkHistoryRouter: workHistoryRouter, - ResearchJournalsRouter: researchJournalsRouter, - CampaignTypesRouter: campaignTypesRouter, - CampaignDestinationsRouter: campaignDestinationsRouter, - CampaignsRouter: campaignsRouter, - CampaignFilesRouter: campaignFilesRouter, } } @@ -165,35 +101,19 @@ func (r *Router) Register() { // Register routes of modules r.ActivityLogsRouter.RegisterActivityLogsRoutes() - r.AdvertisementRouter.RegisterAdvertisementRoutes() - r.AIChatRouter.RegisterAIChatRoutes() r.ArticleCategoriesRouter.RegisterArticleCategoriesRoutes() r.ArticleCategoryDetailsRouter.RegisterArticleCategoryDetailsRoutes() r.ArticleFilesRouter.RegisterArticleFilesRoutes() r.ArticleApprovalsRouter.RegisterArticleApprovalsRoutes() r.ArticlesRouter.RegisterArticlesRoutes() r.ArticleCommentsRouter.RegisterArticleCommentsRoutes() - r.ChatRouter.RegisterChatRoutes() r.CitiesRouter.RegisterCitiesRoutes() r.CustomStaticPagesRouter.RegisterCustomStaticPagesRoutes() r.DistrictsRouter.RegisterDistrictsRoutes() - r.EbooksRouter.RegisterEbooksRoutes() r.FeedbacksRouter.RegisterFeedbacksRoutes() - r.MagazinesRouter.RegisterMagazinesRoutes() - r.MagazineFilesRouter.RegisterMagazineFilesRoutes() - r.MasterMenusRouter.RegisterMasterMenusRoutes() - r.MasterModulesRouter.RegisterMasterModulesRoutes() r.ProvincesRouter.RegisterProvincesRoutes() - r.SubscriptionRouter.RegisterSubscriptionRoutes() r.UserLevelsRouter.RegisterUserLevelsRoutes() r.UserRoleAccessesRouter.RegisterUserRoleAccessesRoutes() r.UsersRouter.RegisterUsersRoutes() r.UserRolesRouter.RegisterUserRolesRoutes() - r.EducationHistoryRouter.RegisterEducationHistoryRoutes() - r.WorkHistoryRouter.RegisterWorkHistoryRoutes() - r.ResearchJournalsRouter.RegisterResearchJournalsRoutes() - r.CampaignTypesRouter.RegisterCampaignTypesRoutes() - r.CampaignDestinationsRouter.RegisterCampaignDestinationsRoutes() - r.CampaignsRouter.RegisterCampaignsRoutes() - r.CampaignFilesRouter.RegisterCampaignFilesRoutes() } diff --git a/config/config/index.config.go b/config/config/index.config.go index 5f2d2e4..7f05c79 100644 --- a/config/config/index.config.go +++ b/config/config/index.config.go @@ -1,16 +1,17 @@ package config import ( - "github.com/gofiber/fiber/v2" - "github.com/gofiber/fiber/v2/middleware/compress" - "github.com/pelletier/go-toml/v2" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" "os" "path/filepath" "runtime" "strings" "time" + + "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v2/middleware/compress" + "github.com/pelletier/go-toml/v2" + "github.com/rs/zerolog" + "github.com/rs/zerolog/log" ) type app = struct { @@ -107,6 +108,7 @@ type keycloak = struct { ClientSecret string `toml:"client-secret"` AdminUsername string `toml:"admin-username"` AdminPassword string `toml:"admin-password"` + Group string `toml:"group"` } type smtp = struct { diff --git a/config/config/keycloak.config.go b/config/config/keycloak.config.go index 0ccdfc8..17fd77d 100644 --- a/config/config/keycloak.config.go +++ b/config/config/keycloak.config.go @@ -71,7 +71,7 @@ func (_keycloak *KeycloakConfig) CreateUser(fullname string, email string, usern } var group []string - group = append(group, "narasi-ahli") + group = append(group, _keycloak.Cfg.Keycloak.Group) user := gocloak.User{ FirstName: gocloak.StringP(fullname), LastName: gocloak.StringP(fullname), @@ -110,7 +110,7 @@ func (_keycloak *KeycloakConfig) UpdateUser(keycloakId *string, fullname string, } var group []string - group = append(group, "narasi-ahli") + group = append(group, _keycloak.Cfg.Keycloak.Group) user := gocloak.User{ ID: keycloakId, FirstName: gocloak.StringP(fullname), diff --git a/config/toml/config.toml b/config/toml/config.toml index a45da24..5a3bd43 100644 --- a/config/toml/config.toml +++ b/config/toml/config.toml @@ -3,8 +3,8 @@ name = "Fiber starter" host = "http://38.47.180.165" port = ":8800" -domain = "https://campaignpool.id/api" -external-port = ":8807" +domain = "https://jaecoocihampelasbdg.com/api" +external-port = ":8810" idle-timeout = 5 # As seconds print-routes = false prefork = true @@ -12,8 +12,7 @@ production = false body-limit = 1048576000 # "100 * 1024 * 1024" [db.postgres] -dsn = "postgresql://campaign_pool_user:CampaignPoolDB@2025@38.47.180.165:5432/campaign_pool_db" # ://:@:/ -log-mode = "NONE" +dsn = "postgresql://jaecoo_user:JaecooDB@2025@38.47.180.165:5432/jaecoo_db" migrate = true seed = true @@ -28,7 +27,7 @@ endpoint = "38.47.180.165:9009" access-key-id = "lBtjqWidHz1ktBbduwGy" secret-access-key = "nsedJIa2FI7SqsEVcSFqJrlP4JuFRWGLauNpzD0i" use-ssl = false -bucket-name = "campaign-pool" +bucket-name = "jaecoo" location = "us-east-1" [middleware.compress] @@ -67,11 +66,12 @@ retention = 30 [keycloak] endpoint = "http://38.47.180.165:8008" -realm = "campaign-pool" -client-id = "campaign-pool-app" -client-secret = "Im3rutPrquNULGmzPegmvxKyzeDYe6Vl" -admin-username = "developer-admin" +realm = "medols" +client-id = "medols-app" +client-secret = "iyonEpZbAUs20quwaNFLMwRX7MUgPRlS" +admin-username = "developer-admin" admin-password = "P@ssw0rd.1" +group = "jaecoo" [smtp] host = "mail.polri.go.id" diff --git a/config/webserver/webserver.config.go b/config/webserver/webserver.config.go index cd26086..12dd1c0 100644 --- a/config/webserver/webserver.config.go +++ b/config/webserver/webserver.config.go @@ -127,10 +127,9 @@ func Start(lifecycle fx.Lifecycle, cfg *config.Config, fiber *fiber.App, router if *seedFlag { // init seed models - masterStatusSeeder := seeds.MasterStatusesSeeder{} masterApprovalStatusSeeder := seeds.MasterApprovalStatusesSeeder{} activityLogsSeeder := seeds.ActivityLogsSeeder{} - allSeeders := []database.Seeder{masterStatusSeeder, masterApprovalStatusSeeder, activityLogsSeeder} + allSeeders := []database.Seeder{masterApprovalStatusSeeder, activityLogsSeeder} db.SeedModels(allSeeders) } diff --git a/docs/swagger/docs.go b/docs/swagger/docs.go index 892b020..ab0e77c 100644 --- a/docs/swagger/docs.go +++ b/docs/swagger/docs.go @@ -388,1318 +388,6 @@ const docTemplate = `{ } } }, - "/advertisement": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "Get all Advertisement", - "parameters": [ - { - "type": "string", - "name": "description", - "in": "query" - }, - { - "type": "boolean", - "name": "isPublish", - "in": "query" - }, - { - "type": "string", - "name": "placement", - "in": "query" - }, - { - "type": "string", - "name": "redirectLink", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "string", - "name": "title", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "Create Advertisement", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AdvertisementCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/advertisement/publish/{id}": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Update Publish Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "Update Publish Advertisement", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Advertisement ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "boolean", - "description": "Advertisement Publish Status", - "name": "isPublish", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/advertisement/upload/{id}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Upload File Advertisement", - "produces": [ - "application/json" - ], - "tags": [ - "Advertisement" - ], - "summary": "Upload Advertisement", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "file", - "description": "Upload file", - "name": "file", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Advertisement ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/advertisement/viewer/{filename}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Viewer Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "Viewer Advertisement", - "parameters": [ - { - "type": "string", - "description": "Content File Name", - "name": "filename", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/advertisement/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "Get one Advertisement", - "parameters": [ - { - "type": "integer", - "description": "Advertisement ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "update Advertisement", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AdvertisementUpdateRequest" - } - }, - { - "type": "integer", - "description": "Advertisement ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "delete Advertisement", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Advertisement ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/logs": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all AI chat logs for authenticated user", - "tags": [ - "AI Chat" - ], - "summary": "Get user AI chat logs", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "name": "logType", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/logs/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one AI chat log", - "tags": [ - "AI Chat" - ], - "summary": "Get one AI chat log", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Log ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/sessions": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all AI chat sessions for authenticated user", - "tags": [ - "AI Chat" - ], - "summary": "Get user AI chat sessions", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "boolean", - "name": "isActive", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Create AI chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AIChatSessionsCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/sessions/messages": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for sending a message to an AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Send message to AI chat session", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AIChatMessagesCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/sessions/messages/{messageId}": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update AI chat message", - "tags": [ - "AI Chat" - ], - "summary": "Update AI chat message", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Message ID", - "name": "messageId", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AIChatMessagesUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete AI chat message", - "tags": [ - "AI Chat" - ], - "summary": "Delete AI chat message", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Message ID", - "name": "messageId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/sessions/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Get one AI chat session", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Session ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Update AI chat session", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "integer", - "description": "Session ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AIChatSessionsUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Delete AI chat session", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Session ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/sessions/{id}/messages": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all messages in an AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Get AI chat session messages", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Session ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, "/article-approvals": { "get": { "security": [ @@ -4534,2754 +3222,6 @@ const docTemplate = `{ } } }, - "/campaign-destinations": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all CampaignDestinations", - "tags": [ - "CampaignDestinations" - ], - "summary": "Get all CampaignDestinations", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "campaignTypeId", - "in": "query" - }, - { - "type": "boolean", - "name": "isActive", - "in": "query" - }, - { - "type": "string", - "name": "name", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create CampaignDestinations", - "tags": [ - "CampaignDestinations" - ], - "summary": "Create CampaignDestinations", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignDestinationsCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/campaign-destinations/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one CampaignDestinations", - "tags": [ - "CampaignDestinations" - ], - "summary": "Get one CampaignDestinations", - "parameters": [ - { - "type": "integer", - "description": "CampaignDestinations ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update CampaignDestinations", - "tags": [ - "CampaignDestinations" - ], - "summary": "Update CampaignDestinations", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignDestinationsUpdateRequest" - } - }, - { - "type": "integer", - "description": "CampaignDestinations ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete CampaignDestinations", - "tags": [ - "CampaignDestinations" - ], - "summary": "Delete CampaignDestinations", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "CampaignDestinations ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/campaign-types": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all CampaignTypes", - "tags": [ - "CampaignTypes" - ], - "summary": "Get all CampaignTypes", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "string", - "name": "name", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create CampaignTypes", - "tags": [ - "CampaignTypes" - ], - "summary": "Create CampaignTypes", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignTypesCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/campaign-types/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one CampaignTypes", - "tags": [ - "CampaignTypes" - ], - "summary": "Get one CampaignTypes", - "parameters": [ - { - "type": "integer", - "description": "CampaignTypes ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update CampaignTypes", - "tags": [ - "CampaignTypes" - ], - "summary": "Update CampaignTypes", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignTypesUpdateRequest" - } - }, - { - "type": "integer", - "description": "CampaignTypes ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete CampaignTypes", - "tags": [ - "CampaignTypes" - ], - "summary": "Delete CampaignTypes", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "CampaignTypes ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/campaigns": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Campaigns", - "tags": [ - "Campaigns" - ], - "summary": "Get all Campaigns", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "campaignTypeId", - "in": "query" - }, - { - "type": "integer", - "name": "creatorId", - "in": "query" - }, - { - "type": "string", - "name": "status", - "in": "query" - }, - { - "type": "string", - "name": "title", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Campaigns", - "tags": [ - "Campaigns" - ], - "summary": "Create Campaigns", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignsCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/campaigns/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Campaigns", - "tags": [ - "Campaigns" - ], - "summary": "Get one Campaigns", - "parameters": [ - { - "type": "integer", - "description": "Campaigns ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Campaigns", - "tags": [ - "Campaigns" - ], - "summary": "Update Campaigns", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignsUpdateRequest" - } - }, - { - "type": "integer", - "description": "Campaigns ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Campaigns", - "tags": [ - "Campaigns" - ], - "summary": "Delete Campaigns", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Campaigns ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/messages": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all messages in a specific chat session", - "tags": [ - "Chat" - ], - "summary": "Get all chat messages", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "chatSessionId", - "in": "query", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for creating a new chat message", - "tags": [ - "Chat" - ], - "summary": "Create chat message", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatMessageCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/messages/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one chat message", - "tags": [ - "Chat" - ], - "summary": "Get one chat message", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Message ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating chat message (only sender can update)", - "tags": [ - "Chat" - ], - "summary": "Update chat message", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Message ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatMessageUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for deleting chat message (only sender can delete)", - "tags": [ - "Chat" - ], - "summary": "Delete chat message", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Message ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedule-files": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting files for a specific chat schedule", - "tags": [ - "Chat Schedule File" - ], - "summary": "Get chat schedule files", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "chatScheduleId", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "File type filter", - "name": "fileType", - "in": "query" - }, - { - "type": "boolean", - "description": "Required file filter", - "name": "isRequired", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedule-files/viewer/{filename}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for viewing chat schedule file", - "tags": [ - "Chat Schedule File" - ], - "summary": "View chat schedule file", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Chat Schedule File Name", - "name": "filename", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "file" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedule-files/{chatScheduleId}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for uploading file for chat schedule", - "produces": [ - "application/json" - ], - "tags": [ - "Chat Schedule File" - ], - "summary": "Upload chat schedule file", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "file", - "description": "Upload file", - "name": "files", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "chatScheduleId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedule-files/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one chat schedule file", - "tags": [ - "Chat Schedule File" - ], - "summary": "Get one chat schedule file", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule File ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating chat schedule file", - "tags": [ - "Chat Schedule File" - ], - "summary": "Update chat schedule file", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule File ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatScheduleFileUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for deleting chat schedule file", - "tags": [ - "Chat Schedule File" - ], - "summary": "Delete chat schedule file", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule File ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedules": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all chat schedules for authenticated user", - "tags": [ - "Chat Schedule" - ], - "summary": "Get all chat schedules", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Chat Session ID", - "name": "chatSessionId", - "in": "query" - }, - { - "type": "string", - "description": "Schedule status (scheduled, ongoing, completed, cancelled)", - "name": "status", - "in": "query" - }, - { - "type": "string", - "description": "Created by user ID", - "name": "createdBy", - "in": "query" - }, - { - "type": "string", - "description": "Date from (YYYY-MM-DD)", - "name": "dateFrom", - "in": "query" - }, - { - "type": "string", - "description": "Date to (YYYY-MM-DD)", - "name": "dateTo", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for creating a new chat schedule", - "tags": [ - "Chat Schedule" - ], - "summary": "Create chat schedule", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatScheduleCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedules/status/{status}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting chat schedules by status", - "tags": [ - "Chat Schedule" - ], - "summary": "Get schedules by status", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Schedule status (scheduled, ongoing, completed, cancelled)", - "name": "status", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedules/upcoming": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting upcoming chat schedules for authenticated user", - "tags": [ - "Chat Schedule" - ], - "summary": "Get upcoming schedules", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "default": 10, - "description": "Limit number of results", - "name": "limit", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedules/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one chat schedule", - "tags": [ - "Chat Schedule" - ], - "summary": "Get one chat schedule", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating chat schedule (only creator can update)", - "tags": [ - "Chat Schedule" - ], - "summary": "Update chat schedule", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatScheduleUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for deleting chat schedule (only creator can delete)", - "tags": [ - "Chat Schedule" - ], - "summary": "Delete chat schedule", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedules/{id}/reminder": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for sending reminder for a chat schedule (only creator can send)", - "tags": [ - "Chat Schedule" - ], - "summary": "Send schedule reminder", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/sessions": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all chat sessions for authenticated user", - "tags": [ - "Chat" - ], - "summary": "Get all chat sessions", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Chat type (personal or group)", - "name": "type", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for creating a new chat session (personal or group)", - "tags": [ - "Chat" - ], - "summary": "Create chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatSessionCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/sessions/{chatSessionId}/participants": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for adding a participant to a chat session (only creator can add)", - "tags": [ - "Chat" - ], - "summary": "Add participant to chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "chatSessionId", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Participant User ID", - "name": "participantUserId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for removing a participant from a chat session (creator can remove anyone, user can remove themselves)", - "tags": [ - "Chat" - ], - "summary": "Remove participant from chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "chatSessionId", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Participant User ID", - "name": "participantUserId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/sessions/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one chat session", - "tags": [ - "Chat" - ], - "summary": "Get one chat session", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating chat session (only creator can update)", - "tags": [ - "Chat" - ], - "summary": "Update chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatSessionUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for deleting chat session (only creator can delete)", - "tags": [ - "Chat" - ], - "summary": "Delete chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, "/cities": { "get": { "security": [ @@ -8183,2193 +4123,6 @@ const docTemplate = `{ } } }, - "/ebook-ratings": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Ebook Ratings", - "tags": [ - "Ebook Ratings" - ], - "summary": "Get all Ebook Ratings", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "ebookId", - "in": "query" - }, - { - "type": "boolean", - "name": "isVerified", - "in": "query" - }, - { - "type": "integer", - "name": "rating", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "integer", - "name": "userId", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for creating ebook rating", - "tags": [ - "Ebook Ratings" - ], - "summary": "Create ebook rating", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EbookRatingsCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebook-ratings/ebook/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting ratings by ebook ID", - "tags": [ - "Ebook Ratings" - ], - "summary": "Get ratings by ebook ID", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebook-ratings/stats/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting ebook rating statistics", - "tags": [ - "Ebook Ratings" - ], - "summary": "Get ebook rating statistics", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebook-ratings/summary/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting ebook rating summary with stats and recent reviews", - "tags": [ - "Ebook Ratings" - ], - "summary": "Get ebook rating summary", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebook-ratings/user": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting user ratings", - "tags": [ - "Ebook Ratings" - ], - "summary": "Get user ratings", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebook-ratings/{id}": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating ebook rating", - "tags": [ - "Ebook Ratings" - ], - "summary": "Update ebook rating", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EbookRatingsUpdateRequest" - } - }, - { - "type": "integer", - "description": "Rating ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for deleting ebook rating", - "tags": [ - "Ebook Ratings" - ], - "summary": "Delete ebook rating", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Rating ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Ebooks", - "tags": [ - "Ebooks" - ], - "summary": "Get all Ebooks", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "authorId", - "in": "query" - }, - { - "type": "string", - "name": "category", - "in": "query" - }, - { - "type": "string", - "name": "description", - "in": "query" - }, - { - "type": "boolean", - "name": "isPublished", - "in": "query" - }, - { - "type": "number", - "name": "maxPrice", - "in": "query" - }, - { - "type": "number", - "name": "minPrice", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "string", - "name": "tags", - "in": "query" - }, - { - "type": "string", - "name": "title", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Ebook", - "tags": [ - "Ebooks" - ], - "summary": "Create Ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EbooksCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/download/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Download PDF of Ebook", - "tags": [ - "Ebooks" - ], - "summary": "Download PDF Ebook", - "parameters": [ - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/pdf/{id}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Save PDF File of Ebook", - "produces": [ - "application/json" - ], - "tags": [ - "Ebooks" - ], - "summary": "Save PDF File Ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "file", - "description": "Upload PDF file", - "name": "file", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/purchase/{ebookId}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for purchasing ebook", - "tags": [ - "Ebook Purchase" - ], - "summary": "Purchase ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "ebookId", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Payment Method", - "name": "paymentMethod", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/purchases": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting user purchases", - "tags": [ - "Ebook Purchase" - ], - "summary": "Get user purchases", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/purchases/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting purchase by ID", - "tags": [ - "Ebook Purchase" - ], - "summary": "Get purchase by ID", - "parameters": [ - { - "type": "integer", - "description": "Purchase ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/purchases/{id}/confirm": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for confirming payment", - "tags": [ - "Ebook Purchase" - ], - "summary": "Confirm payment", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Purchase ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/purchases/{id}/payment": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating payment status", - "tags": [ - "Ebook Purchase" - ], - "summary": "Update payment status", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Purchase ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/controller.PaymentStatusUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/slug/{slug}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Ebook by slug", - "tags": [ - "Ebooks" - ], - "summary": "Get one Ebook by slug", - "parameters": [ - { - "type": "string", - "description": "Ebook Slug", - "name": "slug", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/statistic/summary": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Summary Stats of Ebook", - "tags": [ - "Ebooks" - ], - "summary": "SummaryStats Ebook", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/thumbnail/{id}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Save Thumbnail of Ebook", - "produces": [ - "application/json" - ], - "tags": [ - "Ebooks" - ], - "summary": "Save Thumbnail Ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "file", - "description": "Upload thumbnail", - "name": "files", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/wishlist": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting user wishlist", - "tags": [ - "Ebook Wishlist" - ], - "summary": "Get user wishlist", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/wishlist/check/{ebookId}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for checking if ebook is in wishlist", - "tags": [ - "Ebook Wishlist" - ], - "summary": "Check if ebook is in wishlist", - "parameters": [ - { - "type": "integer", - "description": "Ebook ID", - "name": "ebookId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/wishlist/{ebookId}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for adding ebook to wishlist", - "tags": [ - "Ebook Wishlist" - ], - "summary": "Add ebook to wishlist", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "ebookId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for removing ebook from wishlist", - "tags": [ - "Ebook Wishlist" - ], - "summary": "Remove ebook from wishlist", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "ebookId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Ebook", - "tags": [ - "Ebooks" - ], - "summary": "Get one Ebook", - "parameters": [ - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Ebook", - "tags": [ - "Ebooks" - ], - "summary": "Update Ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EbooksUpdateRequest" - } - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Ebook", - "tags": [ - "Ebooks" - ], - "summary": "Delete Ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/education-history": { - "get": { - "description": "API for getting all Education History for specific user", - "tags": [ - "Education History" - ], - "summary": "Get all Education History", - "parameters": [ - { - "type": "string", - "name": "educationLevel", - "in": "query" - }, - { - "type": "integer", - "name": "graduationYear", - "in": "query" - }, - { - "type": "string", - "name": "major", - "in": "query" - }, - { - "type": "string", - "name": "schoolName", - "in": "query" - }, - { - "type": "integer", - "name": "userId", - "in": "query", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "description": "API for create Education History", - "tags": [ - "Education History" - ], - "summary": "Create Education History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EducationHistoryCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/education-history/{id}": { - "get": { - "description": "API for getting one Education History", - "tags": [ - "Education History" - ], - "summary": "Get one Education History", - "parameters": [ - { - "type": "integer", - "description": "Education History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "description": "API for update Education History", - "tags": [ - "Education History" - ], - "summary": "Update Education History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Education History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EducationHistoryUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "description": "API for delete Education History", - "tags": [ - "Education History" - ], - "summary": "Delete Education History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Education History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/education-history/{id}/certificate": { - "post": { - "description": "API for upload certificate image for Education History", - "tags": [ - "Education History" - ], - "summary": "Upload Certificate for Education History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Education History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - }, - { - "type": "file", - "description": "Certificate image file", - "name": "certificate", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, "/feedbacks": { "get": { "security": [ @@ -10766,1691 +4519,6 @@ const docTemplate = `{ } } }, - "/magazine-files": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "Get all MagazineFiles", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazine-files/viewer/{filename}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "Create MagazineFiles", - "parameters": [ - { - "type": "string", - "description": "Magazine File Name", - "name": "filename", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazine-files/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "Get one MagazineFiles", - "parameters": [ - { - "type": "integer", - "description": "MagazineFiles ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "Update MagazineFiles", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MagazineFiles ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "delete MagazineFiles", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MagazineFiles ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazine-files/{magazineId}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "Create MagazineFiles", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "file", - "description": "Upload file", - "name": "files", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "Magazine file title", - "name": "title", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "Magazine file description", - "name": "description", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Magazine ID", - "name": "magazineId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazines": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Magazines", - "tags": [ - "Magazines" - ], - "summary": "Get all Magazines", - "parameters": [ - { - "type": "integer", - "name": "createdById", - "in": "query" - }, - { - "type": "string", - "name": "description", - "in": "query" - }, - { - "type": "boolean", - "name": "isPublish", - "in": "query" - }, - { - "type": "string", - "name": "pageUrl", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "string", - "name": "thumbnailPath", - "in": "query" - }, - { - "type": "string", - "name": "thumbnailUrl", - "in": "query" - }, - { - "type": "string", - "name": "title", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Magazines", - "tags": [ - "Magazines" - ], - "summary": "Create Magazines", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.MagazinesCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazines/thumbnail/viewer/{thumbnailName}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for View Thumbnail of Magazines", - "tags": [ - "Magazines" - ], - "summary": "Viewer Magazines Thumbnail", - "parameters": [ - { - "type": "string", - "description": "Magazines Thumbnail Name", - "name": "thumbnailName", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazines/thumbnail/{id}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Save Thumbnail of Magazines", - "produces": [ - "application/json" - ], - "tags": [ - "Magazines" - ], - "summary": "Save Thumbnail Magazines", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Magazine ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "file", - "description": "Upload thumbnail", - "name": "files", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazines/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Magazines", - "tags": [ - "Magazines" - ], - "summary": "Get one Magazines", - "parameters": [ - { - "type": "integer", - "description": "Magazines ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Magazines", - "tags": [ - "Magazines" - ], - "summary": "Update Magazines", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Magazines ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.MagazinesUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Magazines", - "tags": [ - "Magazines" - ], - "summary": "Delete Magazines", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Magazines ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/master-menus": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all MasterMenus", - "tags": [ - "MasterMenus" - ], - "summary": "Get all MasterMenus", - "parameters": [ - { - "type": "string", - "name": "description", - "in": "query" - }, - { - "type": "integer", - "name": "moduleId", - "in": "query" - }, - { - "type": "string", - "name": "name", - "in": "query" - }, - { - "type": "integer", - "name": "parentMenuId", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create MasterMenus", - "tags": [ - "MasterMenus" - ], - "summary": "Create MasterMenus", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.MasterMenusCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/master-menus/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one MasterMenus", - "tags": [ - "MasterMenus" - ], - "summary": "Get one MasterMenus", - "parameters": [ - { - "type": "integer", - "description": "MasterMenus ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update MasterMenus", - "tags": [ - "MasterMenus" - ], - "summary": "Update MasterMenus", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MasterMenus ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete MasterMenus", - "tags": [ - "MasterMenus" - ], - "summary": "Delete MasterMenus", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MasterMenus ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/master-modules": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all MasterModules", - "tags": [ - "MasterModules" - ], - "summary": "Get all MasterModules", - "parameters": [ - { - "type": "string", - "name": "description", - "in": "query" - }, - { - "type": "string", - "name": "name", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create MasterModules", - "tags": [ - "MasterModules" - ], - "summary": "Create MasterModules", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.MasterModulesCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/master-modules/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one MasterModules", - "tags": [ - "MasterModules" - ], - "summary": "Get one MasterModules", - "parameters": [ - { - "type": "integer", - "description": "MasterModules ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update MasterModules", - "tags": [ - "MasterModules" - ], - "summary": "Update MasterModules", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MasterModules ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.MasterModulesUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete MasterModules", - "tags": [ - "MasterModules" - ], - "summary": "Delete MasterModules", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MasterModules ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/master-statuses": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all MasterStatuses", - "tags": [ - "Untags" - ], - "summary": "Get all MasterStatuses", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create MasterStatuses", - "tags": [ - "Untags" - ], - "summary": "Create MasterStatuses", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - } - }, - "/master-statuses/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one MasterStatuses", - "tags": [ - "Untags" - ], - "summary": "Get one MasterStatuses", - "parameters": [ - { - "type": "integer", - "description": "MasterStatuses ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update MasterStatuses", - "tags": [ - "Untags" - ], - "summary": "Update MasterStatuses", - "parameters": [ - { - "type": "integer", - "description": "MasterStatuses ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete MasterStatuses", - "tags": [ - "Untags" - ], - "summary": "Delete MasterStatuses", - "parameters": [ - { - "type": "integer", - "description": "MasterStatuses ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - } - }, "/provinces": { "get": { "security": [ @@ -12702,641 +4770,6 @@ const docTemplate = `{ } } }, - "/research-journals": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Research Journals for authenticated user", - "tags": [ - "Research Journals" - ], - "summary": "Get all Research Journals", - "parameters": [ - { - "type": "string", - "name": "journalTitle", - "in": "query" - }, - { - "type": "integer", - "name": "publishedYear", - "in": "query" - }, - { - "type": "string", - "name": "publisher", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Research Journal", - "tags": [ - "Research Journals" - ], - "summary": "Create Research Journal", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ResearchJournalsCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/research-journals/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Research Journal", - "tags": [ - "Research Journals" - ], - "summary": "Get one Research Journal", - "parameters": [ - { - "type": "integer", - "description": "Research Journal ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Research Journal", - "tags": [ - "Research Journals" - ], - "summary": "Update Research Journal", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Research Journal ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ResearchJournalsUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Research Journal", - "tags": [ - "Research Journals" - ], - "summary": "Delete Research Journal", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Research Journal ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/subscription": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Subscription", - "tags": [ - "Subscription" - ], - "summary": "Get all Subscription", - "parameters": [ - { - "type": "string", - "name": "email", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Subscription", - "tags": [ - "Subscription" - ], - "summary": "Create Subscription", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SubscriptionCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/subscription/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Subscription", - "tags": [ - "Subscription" - ], - "summary": "Get one Subscription", - "parameters": [ - { - "type": "integer", - "description": "Subscription ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Subscription", - "tags": [ - "Subscription" - ], - "summary": "update Subscription", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SubscriptionUpdateRequest" - } - }, - { - "type": "integer", - "description": "Subscription ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Subscription", - "tags": [ - "Subscription" - ], - "summary": "delete Subscription", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Subscription ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, "/user-levels": { "get": { "security": [ @@ -15675,325 +7108,9 @@ const docTemplate = `{ } } } - }, - "/work-history": { - "get": { - "description": "API for getting all Work History for specific user", - "tags": [ - "Work History" - ], - "summary": "Get all Work History", - "parameters": [ - { - "type": "string", - "name": "companyName", - "in": "query" - }, - { - "type": "boolean", - "description": "filter for current job (EndDate is null)", - "name": "isCurrent", - "in": "query" - }, - { - "type": "string", - "name": "jobTitle", - "in": "query" - }, - { - "type": "integer", - "name": "userId", - "in": "query", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "description": "API for create Work History", - "tags": [ - "Work History" - ], - "summary": "Create Work History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.WorkHistoryCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/work-history/{id}": { - "get": { - "description": "API for getting one Work History", - "tags": [ - "Work History" - ], - "summary": "Get one Work History", - "parameters": [ - { - "type": "integer", - "description": "Work History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "description": "API for update Work History", - "tags": [ - "Work History" - ], - "summary": "Update Work History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Work History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.WorkHistoryUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "description": "API for delete Work History", - "tags": [ - "Work History" - ], - "summary": "Delete Work History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Work History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } } }, "definitions": { - "controller.PaymentStatusUpdateRequest": { - "type": "object", - "required": [ - "paymentStatus" - ], - "properties": { - "paymentProof": { - "type": "string" - }, - "paymentStatus": { - "type": "string" - }, - "transactionId": { - "type": "string" - } - } - }, "paginator.Pagination": { "type": "object", "properties": { @@ -16023,79 +7140,6 @@ const docTemplate = `{ } } }, - "request.AIChatMessagesCreateRequest": { - "type": "object", - "required": [ - "content", - "messageType", - "sessionId" - ], - "properties": { - "content": { - "type": "string", - "minLength": 1 - }, - "messageType": { - "type": "string", - "enum": [ - "user", - "assistant" - ] - }, - "sessionId": { - "type": "string" - } - } - }, - "request.AIChatMessagesUpdateRequest": { - "type": "object", - "required": [ - "content" - ], - "properties": { - "content": { - "type": "string", - "minLength": 1 - } - } - }, - "request.AIChatSessionsCreateRequest": { - "type": "object", - "required": [ - "agentId", - "sessionId", - "title" - ], - "properties": { - "agentId": { - "type": "string" - }, - "sessionId": { - "type": "string" - }, - "title": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, - "request.AIChatSessionsUpdateRequest": { - "type": "object", - "required": [ - "title" - ], - "properties": { - "isActive": { - "type": "boolean" - }, - "title": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, "request.ActivityLogsCreateRequest": { "type": "object", "required": [ @@ -16145,56 +7189,6 @@ const docTemplate = `{ } } }, - "request.AdvertisementCreateRequest": { - "type": "object", - "required": [ - "description", - "placement", - "redirectLink", - "title" - ], - "properties": { - "description": { - "type": "string" - }, - "placement": { - "type": "string" - }, - "redirectLink": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.AdvertisementUpdateRequest": { - "type": "object", - "required": [ - "description", - "id", - "placement", - "redirectLink", - "title" - ], - "properties": { - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "placement": { - "type": "string" - }, - "redirectLink": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, "request.ArticleApprovalsCreateRequest": { "type": "object", "required": [ @@ -16530,382 +7524,6 @@ const docTemplate = `{ } } }, - "request.CampaignDestinationsCreateRequest": { - "type": "object", - "required": [ - "campaignTypeId", - "name" - ], - "properties": { - "campaignTypeId": { - "type": "integer" - }, - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "isActive": { - "type": "boolean" - }, - "name": { - "type": "string" - }, - "subType": { - "type": "string" - }, - "url": { - "type": "string" - } - } - }, - "request.CampaignDestinationsUpdateRequest": { - "type": "object", - "required": [ - "campaignTypeId", - "name" - ], - "properties": { - "campaignTypeId": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "isActive": { - "type": "boolean" - }, - "name": { - "type": "string" - }, - "subType": { - "type": "string" - }, - "url": { - "type": "string" - } - } - }, - "request.CampaignTypesCreateRequest": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "request.CampaignTypesUpdateRequest": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "description": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "request.CampaignsCreateRequest": { - "type": "object", - "required": [ - "campaignTypeId", - "title" - ], - "properties": { - "campaignTypeId": { - "type": "integer" - }, - "creatorId": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "endDate": { - "type": "string" - }, - "mediaItemSelected": { - "type": "string" - }, - "mediaPromote": { - "type": "boolean" - }, - "mediaTypeSelected": { - "type": "string" - }, - "purpose": { - "type": "string" - }, - "startDate": { - "type": "string" - }, - "status": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.CampaignsUpdateRequest": { - "type": "object", - "required": [ - "campaignTypeId", - "title" - ], - "properties": { - "campaignTypeId": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "endDate": { - "type": "string" - }, - "mediaItemSelected": { - "type": "string" - }, - "mediaPromote": { - "type": "boolean" - }, - "mediaTypeSelected": { - "type": "string" - }, - "purpose": { - "type": "string" - }, - "startDate": { - "type": "string" - }, - "status": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.ChatMessageCreateRequest": { - "type": "object", - "required": [ - "chatSessionId", - "message" - ], - "properties": { - "chatSessionId": { - "type": "integer" - }, - "message": { - "type": "string", - "maxLength": 1000, - "minLength": 1 - }, - "messageType": { - "type": "string", - "enum": [ - "text", - "image", - "file", - "user", - "assistant" - ] - } - } - }, - "request.ChatMessageUpdateRequest": { - "type": "object", - "required": [ - "message" - ], - "properties": { - "message": { - "type": "string", - "maxLength": 1000, - "minLength": 1 - } - } - }, - "request.ChatScheduleCreateRequest": { - "type": "object", - "required": [ - "scheduled_at", - "title" - ], - "properties": { - "chat_session_id": { - "description": "Optional - if empty, will create new chat session", - "type": "integer" - }, - "description": { - "type": "string", - "maxLength": 1000 - }, - "duration": { - "description": "15 minutes to 8 hours", - "type": "integer", - "maximum": 480, - "minimum": 15 - }, - "file_ids": { - "description": "Array of file IDs to attach to schedule", - "type": "array", - "items": { - "type": "integer" - } - }, - "scheduled_at": { - "type": "string" - }, - "summary": { - "type": "string", - "maxLength": 2000 - }, - "title": { - "type": "string", - "maxLength": 255, - "minLength": 3 - } - } - }, - "request.ChatScheduleFileUpdateRequest": { - "type": "object", - "properties": { - "description": { - "type": "string", - "maxLength": 500 - }, - "file_name": { - "type": "string", - "maxLength": 255 - }, - "file_path": { - "type": "string", - "maxLength": 500 - }, - "file_size": { - "type": "integer", - "minimum": 0 - }, - "file_type": { - "type": "string", - "enum": [ - "article", - "journal", - "video", - "audio", - "document", - "other" - ] - }, - "is_required": { - "type": "boolean" - }, - "mime_type": { - "type": "string", - "maxLength": 100 - }, - "original_name": { - "type": "string", - "maxLength": 255 - } - } - }, - "request.ChatScheduleUpdateRequest": { - "type": "object", - "properties": { - "description": { - "type": "string", - "maxLength": 1000 - }, - "duration": { - "type": "integer", - "maximum": 480, - "minimum": 15 - }, - "file_ids": { - "description": "Array of file IDs to attach to schedule", - "type": "array", - "items": { - "type": "integer" - } - }, - "scheduled_at": { - "type": "string" - }, - "status": { - "type": "string", - "enum": [ - "scheduled", - "ongoing", - "completed", - "cancelled" - ] - }, - "summary": { - "type": "string", - "maxLength": 2000 - }, - "title": { - "type": "string", - "maxLength": 255, - "minLength": 3 - } - } - }, - "request.ChatSessionCreateRequest": { - "type": "object", - "required": [ - "type", - "userIds" - ], - "properties": { - "name": { - "description": "null for personal chat", - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "type": { - "type": "string", - "enum": [ - "personal", - "group" - ] - }, - "userIds": { - "description": "participants (excluding creator)", - "type": "array", - "minItems": 1, - "items": { - "type": "integer" - } - } - } - }, - "request.ChatSessionUpdateRequest": { - "type": "object", - "properties": { - "name": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, "request.CitiesCreateRequest": { "type": "object", "required": [ @@ -16991,231 +7609,6 @@ const docTemplate = `{ } } }, - "request.EbookRatingsCreateRequest": { - "type": "object", - "required": [ - "ebookId", - "purchaseId", - "rating" - ], - "properties": { - "ebookId": { - "type": "integer" - }, - "isAnonymous": { - "type": "boolean" - }, - "purchaseId": { - "type": "integer" - }, - "rating": { - "type": "integer", - "maximum": 5, - "minimum": 1 - }, - "review": { - "type": "string" - } - } - }, - "request.EbookRatingsUpdateRequest": { - "type": "object", - "required": [ - "rating" - ], - "properties": { - "isAnonymous": { - "type": "boolean" - }, - "rating": { - "type": "integer", - "maximum": 5, - "minimum": 1 - }, - "review": { - "type": "string" - } - } - }, - "request.EbooksCreateRequest": { - "type": "object", - "required": [ - "description", - "price", - "slug", - "title" - ], - "properties": { - "category": { - "type": "string" - }, - "createdAt": { - "type": "string" - }, - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "isPublished": { - "type": "boolean" - }, - "isbn": { - "type": "string" - }, - "language": { - "type": "string" - }, - "pageCount": { - "type": "integer" - }, - "price": { - "type": "number", - "minimum": 0 - }, - "publishedYear": { - "type": "integer" - }, - "publisher": { - "type": "string" - }, - "slug": { - "type": "string" - }, - "tags": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.EbooksUpdateRequest": { - "type": "object", - "required": [ - "description", - "price", - "slug", - "title" - ], - "properties": { - "category": { - "type": "string" - }, - "createdAt": { - "type": "string" - }, - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "isPublished": { - "type": "boolean" - }, - "isbn": { - "type": "string" - }, - "language": { - "type": "string" - }, - "pageCount": { - "type": "integer" - }, - "price": { - "type": "number", - "minimum": 0 - }, - "publishedYear": { - "type": "integer" - }, - "publisher": { - "type": "string" - }, - "slug": { - "type": "string" - }, - "statusId": { - "type": "integer" - }, - "tags": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.EducationHistoryCreateRequest": { - "type": "object", - "required": [ - "educationLevel", - "graduationYear", - "major", - "schoolName" - ], - "properties": { - "certificateImage": { - "type": "string" - }, - "educationLevel": { - "type": "string", - "maxLength": 100, - "minLength": 2 - }, - "graduationYear": { - "type": "integer", - "maximum": 2030, - "minimum": 1950 - }, - "major": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "schoolName": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, - "request.EducationHistoryUpdateRequest": { - "type": "object", - "required": [ - "educationLevel", - "graduationYear", - "major", - "schoolName" - ], - "properties": { - "certificateImage": { - "type": "string" - }, - "educationLevel": { - "type": "string", - "maxLength": 100, - "minLength": 2 - }, - "graduationYear": { - "type": "integer", - "maximum": 2030, - "minimum": 1950 - }, - "major": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "schoolName": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, "request.FeedbacksCreateRequest": { "type": "object", "required": [ @@ -17258,245 +7651,6 @@ const docTemplate = `{ } } }, - "request.MagazinesCreateRequest": { - "type": "object", - "required": [ - "description", - "statusId", - "title" - ], - "properties": { - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "isPublish": { - "type": "boolean" - }, - "pageUrl": { - "type": "string" - }, - "publishedAt": { - "type": "string" - }, - "statusId": { - "type": "integer" - }, - "thumbnailPath": { - "type": "string" - }, - "thumbnailUrl": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.MagazinesUpdateRequest": { - "type": "object", - "required": [ - "description", - "id", - "statusId", - "title" - ], - "properties": { - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "isPublish": { - "type": "boolean" - }, - "pageUrl": { - "type": "string" - }, - "publishedAt": { - "type": "string" - }, - "statusId": { - "type": "integer" - }, - "thumbnailPath": { - "type": "string" - }, - "thumbnailUrl": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.MasterMenusCreateRequest": { - "type": "object", - "required": [ - "description", - "group", - "moduleId", - "name", - "statusId" - ], - "properties": { - "description": { - "type": "string" - }, - "group": { - "type": "string" - }, - "icon": { - "type": "string" - }, - "moduleId": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "parentMenuId": { - "type": "integer" - }, - "statusId": { - "type": "integer" - } - } - }, - "request.MasterModulesCreateRequest": { - "type": "object", - "required": [ - "description", - "name", - "pathUrl", - "statusId" - ], - "properties": { - "description": { - "type": "string" - }, - "name": { - "type": "string" - }, - "pathUrl": { - "type": "string" - }, - "statusId": { - "type": "integer" - } - } - }, - "request.MasterModulesUpdateRequest": { - "type": "object", - "required": [ - "description", - "id", - "name", - "pathUrl", - "statusId" - ], - "properties": { - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "pathUrl": { - "type": "string" - }, - "statusId": { - "type": "integer" - } - } - }, - "request.ResearchJournalsCreateRequest": { - "type": "object", - "required": [ - "journalTitle", - "journalUrl", - "publisher" - ], - "properties": { - "journalTitle": { - "type": "string", - "maxLength": 500, - "minLength": 2 - }, - "journalUrl": { - "type": "string" - }, - "publishedDate": { - "type": "string" - }, - "publisher": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, - "request.ResearchJournalsUpdateRequest": { - "type": "object", - "required": [ - "journalTitle", - "journalUrl", - "publisher" - ], - "properties": { - "journalTitle": { - "type": "string", - "maxLength": 500, - "minLength": 2 - }, - "journalUrl": { - "type": "string" - }, - "publishedDate": { - "type": "string" - }, - "publisher": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, - "request.SubscriptionCreateRequest": { - "type": "object", - "required": [ - "email" - ], - "properties": { - "email": { - "type": "string" - } - } - }, - "request.SubscriptionUpdateRequest": { - "type": "object", - "required": [ - "email", - "id" - ], - "properties": { - "email": { - "type": "string" - }, - "id": { - "type": "integer" - } - } - }, "request.UserEmailValidationRequest": { "type": "object", "properties": { @@ -17960,58 +8114,6 @@ const docTemplate = `{ } } }, - "request.WorkHistoryCreateRequest": { - "type": "object", - "required": [ - "companyName", - "jobTitle", - "startDate" - ], - "properties": { - "companyName": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "endDate": { - "type": "string" - }, - "jobTitle": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "startDate": { - "type": "string" - } - } - }, - "request.WorkHistoryUpdateRequest": { - "type": "object", - "required": [ - "companyName", - "jobTitle", - "startDate" - ], - "properties": { - "companyName": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "endDate": { - "type": "string" - }, - "jobTitle": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "startDate": { - "type": "string" - } - } - }, "response.BadRequestError": { "type": "object", "properties": { diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index c551734..2c80e60 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -377,1318 +377,6 @@ } } }, - "/advertisement": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "Get all Advertisement", - "parameters": [ - { - "type": "string", - "name": "description", - "in": "query" - }, - { - "type": "boolean", - "name": "isPublish", - "in": "query" - }, - { - "type": "string", - "name": "placement", - "in": "query" - }, - { - "type": "string", - "name": "redirectLink", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "string", - "name": "title", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "Create Advertisement", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AdvertisementCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/advertisement/publish/{id}": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Update Publish Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "Update Publish Advertisement", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Advertisement ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "boolean", - "description": "Advertisement Publish Status", - "name": "isPublish", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/advertisement/upload/{id}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Upload File Advertisement", - "produces": [ - "application/json" - ], - "tags": [ - "Advertisement" - ], - "summary": "Upload Advertisement", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "file", - "description": "Upload file", - "name": "file", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Advertisement ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/advertisement/viewer/{filename}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Viewer Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "Viewer Advertisement", - "parameters": [ - { - "type": "string", - "description": "Content File Name", - "name": "filename", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/advertisement/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "Get one Advertisement", - "parameters": [ - { - "type": "integer", - "description": "Advertisement ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "update Advertisement", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AdvertisementUpdateRequest" - } - }, - { - "type": "integer", - "description": "Advertisement ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Advertisement", - "tags": [ - "Advertisement" - ], - "summary": "delete Advertisement", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Advertisement ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/logs": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all AI chat logs for authenticated user", - "tags": [ - "AI Chat" - ], - "summary": "Get user AI chat logs", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "name": "logType", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/logs/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one AI chat log", - "tags": [ - "AI Chat" - ], - "summary": "Get one AI chat log", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Log ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/sessions": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all AI chat sessions for authenticated user", - "tags": [ - "AI Chat" - ], - "summary": "Get user AI chat sessions", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "boolean", - "name": "isActive", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Create AI chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AIChatSessionsCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/sessions/messages": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for sending a message to an AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Send message to AI chat session", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AIChatMessagesCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/sessions/messages/{messageId}": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update AI chat message", - "tags": [ - "AI Chat" - ], - "summary": "Update AI chat message", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Message ID", - "name": "messageId", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AIChatMessagesUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete AI chat message", - "tags": [ - "AI Chat" - ], - "summary": "Delete AI chat message", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Message ID", - "name": "messageId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/sessions/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Get one AI chat session", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Session ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Update AI chat session", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "integer", - "description": "Session ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.AIChatSessionsUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Delete AI chat session", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Session ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ai-chat/sessions/{id}/messages": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all messages in an AI chat session", - "tags": [ - "AI Chat" - ], - "summary": "Get AI chat session messages", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Session ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, "/article-approvals": { "get": { "security": [ @@ -4523,2754 +3211,6 @@ } } }, - "/campaign-destinations": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all CampaignDestinations", - "tags": [ - "CampaignDestinations" - ], - "summary": "Get all CampaignDestinations", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "campaignTypeId", - "in": "query" - }, - { - "type": "boolean", - "name": "isActive", - "in": "query" - }, - { - "type": "string", - "name": "name", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create CampaignDestinations", - "tags": [ - "CampaignDestinations" - ], - "summary": "Create CampaignDestinations", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignDestinationsCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/campaign-destinations/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one CampaignDestinations", - "tags": [ - "CampaignDestinations" - ], - "summary": "Get one CampaignDestinations", - "parameters": [ - { - "type": "integer", - "description": "CampaignDestinations ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update CampaignDestinations", - "tags": [ - "CampaignDestinations" - ], - "summary": "Update CampaignDestinations", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignDestinationsUpdateRequest" - } - }, - { - "type": "integer", - "description": "CampaignDestinations ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete CampaignDestinations", - "tags": [ - "CampaignDestinations" - ], - "summary": "Delete CampaignDestinations", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "CampaignDestinations ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/campaign-types": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all CampaignTypes", - "tags": [ - "CampaignTypes" - ], - "summary": "Get all CampaignTypes", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "string", - "name": "name", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create CampaignTypes", - "tags": [ - "CampaignTypes" - ], - "summary": "Create CampaignTypes", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignTypesCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/campaign-types/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one CampaignTypes", - "tags": [ - "CampaignTypes" - ], - "summary": "Get one CampaignTypes", - "parameters": [ - { - "type": "integer", - "description": "CampaignTypes ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update CampaignTypes", - "tags": [ - "CampaignTypes" - ], - "summary": "Update CampaignTypes", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignTypesUpdateRequest" - } - }, - { - "type": "integer", - "description": "CampaignTypes ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete CampaignTypes", - "tags": [ - "CampaignTypes" - ], - "summary": "Delete CampaignTypes", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "CampaignTypes ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/campaigns": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Campaigns", - "tags": [ - "Campaigns" - ], - "summary": "Get all Campaigns", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "campaignTypeId", - "in": "query" - }, - { - "type": "integer", - "name": "creatorId", - "in": "query" - }, - { - "type": "string", - "name": "status", - "in": "query" - }, - { - "type": "string", - "name": "title", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Campaigns", - "tags": [ - "Campaigns" - ], - "summary": "Create Campaigns", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignsCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/campaigns/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Campaigns", - "tags": [ - "Campaigns" - ], - "summary": "Get one Campaigns", - "parameters": [ - { - "type": "integer", - "description": "Campaigns ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Campaigns", - "tags": [ - "Campaigns" - ], - "summary": "Update Campaigns", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.CampaignsUpdateRequest" - } - }, - { - "type": "integer", - "description": "Campaigns ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Campaigns", - "tags": [ - "Campaigns" - ], - "summary": "Delete Campaigns", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Campaigns ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/messages": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all messages in a specific chat session", - "tags": [ - "Chat" - ], - "summary": "Get all chat messages", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "chatSessionId", - "in": "query", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for creating a new chat message", - "tags": [ - "Chat" - ], - "summary": "Create chat message", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatMessageCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/messages/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one chat message", - "tags": [ - "Chat" - ], - "summary": "Get one chat message", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Message ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating chat message (only sender can update)", - "tags": [ - "Chat" - ], - "summary": "Update chat message", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Message ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatMessageUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for deleting chat message (only sender can delete)", - "tags": [ - "Chat" - ], - "summary": "Delete chat message", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Message ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedule-files": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting files for a specific chat schedule", - "tags": [ - "Chat Schedule File" - ], - "summary": "Get chat schedule files", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "chatScheduleId", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "File type filter", - "name": "fileType", - "in": "query" - }, - { - "type": "boolean", - "description": "Required file filter", - "name": "isRequired", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedule-files/viewer/{filename}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for viewing chat schedule file", - "tags": [ - "Chat Schedule File" - ], - "summary": "View chat schedule file", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Chat Schedule File Name", - "name": "filename", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "file" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedule-files/{chatScheduleId}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for uploading file for chat schedule", - "produces": [ - "application/json" - ], - "tags": [ - "Chat Schedule File" - ], - "summary": "Upload chat schedule file", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "file", - "description": "Upload file", - "name": "files", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "chatScheduleId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedule-files/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one chat schedule file", - "tags": [ - "Chat Schedule File" - ], - "summary": "Get one chat schedule file", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule File ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating chat schedule file", - "tags": [ - "Chat Schedule File" - ], - "summary": "Update chat schedule file", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule File ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatScheduleFileUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for deleting chat schedule file", - "tags": [ - "Chat Schedule File" - ], - "summary": "Delete chat schedule file", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule File ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedules": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all chat schedules for authenticated user", - "tags": [ - "Chat Schedule" - ], - "summary": "Get all chat schedules", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Chat Session ID", - "name": "chatSessionId", - "in": "query" - }, - { - "type": "string", - "description": "Schedule status (scheduled, ongoing, completed, cancelled)", - "name": "status", - "in": "query" - }, - { - "type": "string", - "description": "Created by user ID", - "name": "createdBy", - "in": "query" - }, - { - "type": "string", - "description": "Date from (YYYY-MM-DD)", - "name": "dateFrom", - "in": "query" - }, - { - "type": "string", - "description": "Date to (YYYY-MM-DD)", - "name": "dateTo", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for creating a new chat schedule", - "tags": [ - "Chat Schedule" - ], - "summary": "Create chat schedule", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatScheduleCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedules/status/{status}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting chat schedules by status", - "tags": [ - "Chat Schedule" - ], - "summary": "Get schedules by status", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Schedule status (scheduled, ongoing, completed, cancelled)", - "name": "status", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedules/upcoming": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting upcoming chat schedules for authenticated user", - "tags": [ - "Chat Schedule" - ], - "summary": "Get upcoming schedules", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "default": 10, - "description": "Limit number of results", - "name": "limit", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedules/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one chat schedule", - "tags": [ - "Chat Schedule" - ], - "summary": "Get one chat schedule", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating chat schedule (only creator can update)", - "tags": [ - "Chat Schedule" - ], - "summary": "Update chat schedule", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatScheduleUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for deleting chat schedule (only creator can delete)", - "tags": [ - "Chat Schedule" - ], - "summary": "Delete chat schedule", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/schedules/{id}/reminder": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for sending reminder for a chat schedule (only creator can send)", - "tags": [ - "Chat Schedule" - ], - "summary": "Send schedule reminder", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Schedule ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/sessions": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all chat sessions for authenticated user", - "tags": [ - "Chat" - ], - "summary": "Get all chat sessions", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "string", - "description": "Chat type (personal or group)", - "name": "type", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for creating a new chat session (personal or group)", - "tags": [ - "Chat" - ], - "summary": "Create chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatSessionCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/sessions/{chatSessionId}/participants": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for adding a participant to a chat session (only creator can add)", - "tags": [ - "Chat" - ], - "summary": "Add participant to chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "chatSessionId", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Participant User ID", - "name": "participantUserId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for removing a participant from a chat session (creator can remove anyone, user can remove themselves)", - "tags": [ - "Chat" - ], - "summary": "Remove participant from chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "chatSessionId", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "Participant User ID", - "name": "participantUserId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/chat/sessions/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one chat session", - "tags": [ - "Chat" - ], - "summary": "Get one chat session", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating chat session (only creator can update)", - "tags": [ - "Chat" - ], - "summary": "Update chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ChatSessionUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for deleting chat session (only creator can delete)", - "tags": [ - "Chat" - ], - "summary": "Delete chat session", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Chat Session ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, "/cities": { "get": { "security": [ @@ -8172,2193 +4112,6 @@ } } }, - "/ebook-ratings": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Ebook Ratings", - "tags": [ - "Ebook Ratings" - ], - "summary": "Get all Ebook Ratings", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "ebookId", - "in": "query" - }, - { - "type": "boolean", - "name": "isVerified", - "in": "query" - }, - { - "type": "integer", - "name": "rating", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "integer", - "name": "userId", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for creating ebook rating", - "tags": [ - "Ebook Ratings" - ], - "summary": "Create ebook rating", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EbookRatingsCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebook-ratings/ebook/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting ratings by ebook ID", - "tags": [ - "Ebook Ratings" - ], - "summary": "Get ratings by ebook ID", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebook-ratings/stats/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting ebook rating statistics", - "tags": [ - "Ebook Ratings" - ], - "summary": "Get ebook rating statistics", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebook-ratings/summary/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting ebook rating summary with stats and recent reviews", - "tags": [ - "Ebook Ratings" - ], - "summary": "Get ebook rating summary", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebook-ratings/user": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting user ratings", - "tags": [ - "Ebook Ratings" - ], - "summary": "Get user ratings", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebook-ratings/{id}": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating ebook rating", - "tags": [ - "Ebook Ratings" - ], - "summary": "Update ebook rating", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EbookRatingsUpdateRequest" - } - }, - { - "type": "integer", - "description": "Rating ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for deleting ebook rating", - "tags": [ - "Ebook Ratings" - ], - "summary": "Delete ebook rating", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "type": "integer", - "description": "Rating ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Ebooks", - "tags": [ - "Ebooks" - ], - "summary": "Get all Ebooks", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "authorId", - "in": "query" - }, - { - "type": "string", - "name": "category", - "in": "query" - }, - { - "type": "string", - "name": "description", - "in": "query" - }, - { - "type": "boolean", - "name": "isPublished", - "in": "query" - }, - { - "type": "number", - "name": "maxPrice", - "in": "query" - }, - { - "type": "number", - "name": "minPrice", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "string", - "name": "tags", - "in": "query" - }, - { - "type": "string", - "name": "title", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Ebook", - "tags": [ - "Ebooks" - ], - "summary": "Create Ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header" - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EbooksCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/download/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Download PDF of Ebook", - "tags": [ - "Ebooks" - ], - "summary": "Download PDF Ebook", - "parameters": [ - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/pdf/{id}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Save PDF File of Ebook", - "produces": [ - "application/json" - ], - "tags": [ - "Ebooks" - ], - "summary": "Save PDF File Ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "file", - "description": "Upload PDF file", - "name": "file", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/purchase/{ebookId}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for purchasing ebook", - "tags": [ - "Ebook Purchase" - ], - "summary": "Purchase ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "ebookId", - "in": "path", - "required": true - }, - { - "type": "string", - "description": "Payment Method", - "name": "paymentMethod", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/purchases": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting user purchases", - "tags": [ - "Ebook Purchase" - ], - "summary": "Get user purchases", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/purchases/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting purchase by ID", - "tags": [ - "Ebook Purchase" - ], - "summary": "Get purchase by ID", - "parameters": [ - { - "type": "integer", - "description": "Purchase ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/purchases/{id}/confirm": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for confirming payment", - "tags": [ - "Ebook Purchase" - ], - "summary": "Confirm payment", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Purchase ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/purchases/{id}/payment": { - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for updating payment status", - "tags": [ - "Ebook Purchase" - ], - "summary": "Update payment status", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Purchase ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/controller.PaymentStatusUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/slug/{slug}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Ebook by slug", - "tags": [ - "Ebooks" - ], - "summary": "Get one Ebook by slug", - "parameters": [ - { - "type": "string", - "description": "Ebook Slug", - "name": "slug", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/statistic/summary": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Summary Stats of Ebook", - "tags": [ - "Ebooks" - ], - "summary": "SummaryStats Ebook", - "parameters": [ - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/thumbnail/{id}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Save Thumbnail of Ebook", - "produces": [ - "application/json" - ], - "tags": [ - "Ebooks" - ], - "summary": "Save Thumbnail Ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "file", - "description": "Upload thumbnail", - "name": "files", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/wishlist": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting user wishlist", - "tags": [ - "Ebook Wishlist" - ], - "summary": "Get user wishlist", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Client-Key", - "name": "X-Client-Key", - "in": "header", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/wishlist/check/{ebookId}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for checking if ebook is in wishlist", - "tags": [ - "Ebook Wishlist" - ], - "summary": "Check if ebook is in wishlist", - "parameters": [ - { - "type": "integer", - "description": "Ebook ID", - "name": "ebookId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/wishlist/{ebookId}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for adding ebook to wishlist", - "tags": [ - "Ebook Wishlist" - ], - "summary": "Add ebook to wishlist", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "ebookId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for removing ebook from wishlist", - "tags": [ - "Ebook Wishlist" - ], - "summary": "Remove ebook from wishlist", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "ebookId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/ebooks/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Ebook", - "tags": [ - "Ebooks" - ], - "summary": "Get one Ebook", - "parameters": [ - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Ebook", - "tags": [ - "Ebooks" - ], - "summary": "Update Ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EbooksUpdateRequest" - } - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Ebook", - "tags": [ - "Ebooks" - ], - "summary": "Delete Ebook", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Ebook ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/education-history": { - "get": { - "description": "API for getting all Education History for specific user", - "tags": [ - "Education History" - ], - "summary": "Get all Education History", - "parameters": [ - { - "type": "string", - "name": "educationLevel", - "in": "query" - }, - { - "type": "integer", - "name": "graduationYear", - "in": "query" - }, - { - "type": "string", - "name": "major", - "in": "query" - }, - { - "type": "string", - "name": "schoolName", - "in": "query" - }, - { - "type": "integer", - "name": "userId", - "in": "query", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "description": "API for create Education History", - "tags": [ - "Education History" - ], - "summary": "Create Education History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EducationHistoryCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/education-history/{id}": { - "get": { - "description": "API for getting one Education History", - "tags": [ - "Education History" - ], - "summary": "Get one Education History", - "parameters": [ - { - "type": "integer", - "description": "Education History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "description": "API for update Education History", - "tags": [ - "Education History" - ], - "summary": "Update Education History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Education History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.EducationHistoryUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "description": "API for delete Education History", - "tags": [ - "Education History" - ], - "summary": "Delete Education History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Education History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/education-history/{id}/certificate": { - "post": { - "description": "API for upload certificate image for Education History", - "tags": [ - "Education History" - ], - "summary": "Upload Certificate for Education History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Education History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - }, - { - "type": "file", - "description": "Certificate image file", - "name": "certificate", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, "/feedbacks": { "get": { "security": [ @@ -10755,1691 +4508,6 @@ } } }, - "/magazine-files": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "Get all MagazineFiles", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazine-files/viewer/{filename}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "Create MagazineFiles", - "parameters": [ - { - "type": "string", - "description": "Magazine File Name", - "name": "filename", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazine-files/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "Get one MagazineFiles", - "parameters": [ - { - "type": "integer", - "description": "MagazineFiles ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "Update MagazineFiles", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MagazineFiles ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "delete MagazineFiles", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MagazineFiles ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazine-files/{magazineId}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create MagazineFiles", - "tags": [ - "Magazine Files" - ], - "summary": "Create MagazineFiles", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "file", - "description": "Upload file", - "name": "files", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "Magazine file title", - "name": "title", - "in": "formData", - "required": true - }, - { - "type": "string", - "description": "Magazine file description", - "name": "description", - "in": "formData", - "required": true - }, - { - "type": "integer", - "description": "Magazine ID", - "name": "magazineId", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazines": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Magazines", - "tags": [ - "Magazines" - ], - "summary": "Get all Magazines", - "parameters": [ - { - "type": "integer", - "name": "createdById", - "in": "query" - }, - { - "type": "string", - "name": "description", - "in": "query" - }, - { - "type": "boolean", - "name": "isPublish", - "in": "query" - }, - { - "type": "string", - "name": "pageUrl", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "string", - "name": "thumbnailPath", - "in": "query" - }, - { - "type": "string", - "name": "thumbnailUrl", - "in": "query" - }, - { - "type": "string", - "name": "title", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Magazines", - "tags": [ - "Magazines" - ], - "summary": "Create Magazines", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.MagazinesCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazines/thumbnail/viewer/{thumbnailName}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for View Thumbnail of Magazines", - "tags": [ - "Magazines" - ], - "summary": "Viewer Magazines Thumbnail", - "parameters": [ - { - "type": "string", - "description": "Magazines Thumbnail Name", - "name": "thumbnailName", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazines/thumbnail/{id}": { - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for Save Thumbnail of Magazines", - "produces": [ - "application/json" - ], - "tags": [ - "Magazines" - ], - "summary": "Save Thumbnail Magazines", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Magazine ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "file", - "description": "Upload thumbnail", - "name": "files", - "in": "formData", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/magazines/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Magazines", - "tags": [ - "Magazines" - ], - "summary": "Get one Magazines", - "parameters": [ - { - "type": "integer", - "description": "Magazines ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Magazines", - "tags": [ - "Magazines" - ], - "summary": "Update Magazines", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Magazines ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.MagazinesUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Magazines", - "tags": [ - "Magazines" - ], - "summary": "Delete Magazines", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Magazines ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/master-menus": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all MasterMenus", - "tags": [ - "MasterMenus" - ], - "summary": "Get all MasterMenus", - "parameters": [ - { - "type": "string", - "name": "description", - "in": "query" - }, - { - "type": "integer", - "name": "moduleId", - "in": "query" - }, - { - "type": "string", - "name": "name", - "in": "query" - }, - { - "type": "integer", - "name": "parentMenuId", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create MasterMenus", - "tags": [ - "MasterMenus" - ], - "summary": "Create MasterMenus", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.MasterMenusCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/master-menus/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one MasterMenus", - "tags": [ - "MasterMenus" - ], - "summary": "Get one MasterMenus", - "parameters": [ - { - "type": "integer", - "description": "MasterMenus ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update MasterMenus", - "tags": [ - "MasterMenus" - ], - "summary": "Update MasterMenus", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MasterMenus ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete MasterMenus", - "tags": [ - "MasterMenus" - ], - "summary": "Delete MasterMenus", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MasterMenus ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/master-modules": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all MasterModules", - "tags": [ - "MasterModules" - ], - "summary": "Get all MasterModules", - "parameters": [ - { - "type": "string", - "name": "description", - "in": "query" - }, - { - "type": "string", - "name": "name", - "in": "query" - }, - { - "type": "integer", - "name": "statusId", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create MasterModules", - "tags": [ - "MasterModules" - ], - "summary": "Create MasterModules", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.MasterModulesCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/master-modules/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one MasterModules", - "tags": [ - "MasterModules" - ], - "summary": "Get one MasterModules", - "parameters": [ - { - "type": "integer", - "description": "MasterModules ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update MasterModules", - "tags": [ - "MasterModules" - ], - "summary": "Update MasterModules", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MasterModules ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.MasterModulesUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete MasterModules", - "tags": [ - "MasterModules" - ], - "summary": "Delete MasterModules", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "MasterModules ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/master-statuses": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all MasterStatuses", - "tags": [ - "Untags" - ], - "summary": "Get all MasterStatuses", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create MasterStatuses", - "tags": [ - "Untags" - ], - "summary": "Create MasterStatuses", - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - } - }, - "/master-statuses/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one MasterStatuses", - "tags": [ - "Untags" - ], - "summary": "Get one MasterStatuses", - "parameters": [ - { - "type": "integer", - "description": "MasterStatuses ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update MasterStatuses", - "tags": [ - "Untags" - ], - "summary": "Update MasterStatuses", - "parameters": [ - { - "type": "integer", - "description": "MasterStatuses ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete MasterStatuses", - "tags": [ - "Untags" - ], - "summary": "Delete MasterStatuses", - "parameters": [ - { - "type": "integer", - "description": "MasterStatuses ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "422": { - "description": "Unprocessable Entity", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.Response" - } - } - } - } - }, "/provinces": { "get": { "security": [ @@ -12691,641 +4759,6 @@ } } }, - "/research-journals": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Research Journals for authenticated user", - "tags": [ - "Research Journals" - ], - "summary": "Get all Research Journals", - "parameters": [ - { - "type": "string", - "name": "journalTitle", - "in": "query" - }, - { - "type": "integer", - "name": "publishedYear", - "in": "query" - }, - { - "type": "string", - "name": "publisher", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Research Journal", - "tags": [ - "Research Journals" - ], - "summary": "Create Research Journal", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "string", - "default": "Bearer \u003cAdd access token here\u003e", - "description": "Insert your access token", - "name": "Authorization", - "in": "header" - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ResearchJournalsCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/research-journals/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Research Journal", - "tags": [ - "Research Journals" - ], - "summary": "Get one Research Journal", - "parameters": [ - { - "type": "integer", - "description": "Research Journal ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Research Journal", - "tags": [ - "Research Journals" - ], - "summary": "Update Research Journal", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Research Journal ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.ResearchJournalsUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Research Journal", - "tags": [ - "Research Journals" - ], - "summary": "Delete Research Journal", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Research Journal ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/subscription": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting all Subscription", - "tags": [ - "Subscription" - ], - "summary": "Get all Subscription", - "parameters": [ - { - "type": "string", - "name": "email", - "in": "query" - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for create Subscription", - "tags": [ - "Subscription" - ], - "summary": "Create Subscription", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SubscriptionCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/subscription/{id}": { - "get": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for getting one Subscription", - "tags": [ - "Subscription" - ], - "summary": "Get one Subscription", - "parameters": [ - { - "type": "integer", - "description": "Subscription ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for update Subscription", - "tags": [ - "Subscription" - ], - "summary": "update Subscription", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.SubscriptionUpdateRequest" - } - }, - { - "type": "integer", - "description": "Subscription ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "security": [ - { - "Bearer": [] - } - ], - "description": "API for delete Subscription", - "tags": [ - "Subscription" - ], - "summary": "delete Subscription", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Subscription ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/response.UnauthorizedError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, "/user-levels": { "get": { "security": [ @@ -15664,325 +7097,9 @@ } } } - }, - "/work-history": { - "get": { - "description": "API for getting all Work History for specific user", - "tags": [ - "Work History" - ], - "summary": "Get all Work History", - "parameters": [ - { - "type": "string", - "name": "companyName", - "in": "query" - }, - { - "type": "boolean", - "description": "filter for current job (EndDate is null)", - "name": "isCurrent", - "in": "query" - }, - { - "type": "string", - "name": "jobTitle", - "in": "query" - }, - { - "type": "integer", - "name": "userId", - "in": "query", - "required": true - }, - { - "type": "integer", - "name": "count", - "in": "query" - }, - { - "type": "integer", - "name": "limit", - "in": "query" - }, - { - "type": "integer", - "name": "nextPage", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "name": "previousPage", - "in": "query" - }, - { - "type": "string", - "name": "sort", - "in": "query" - }, - { - "type": "string", - "name": "sortBy", - "in": "query" - }, - { - "type": "integer", - "name": "totalPage", - "in": "query" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "post": { - "description": "API for create Work History", - "tags": [ - "Work History" - ], - "summary": "Create Work History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.WorkHistoryCreateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } - }, - "/work-history/{id}": { - "get": { - "description": "API for getting one Work History", - "tags": [ - "Work History" - ], - "summary": "Get one Work History", - "parameters": [ - { - "type": "integer", - "description": "Work History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "put": { - "description": "API for update Work History", - "tags": [ - "Work History" - ], - "summary": "Update Work History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Work History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - }, - { - "description": "Required payload", - "name": "payload", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.WorkHistoryUpdateRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - }, - "delete": { - "description": "API for delete Work History", - "tags": [ - "Work History" - ], - "summary": "Delete Work History", - "parameters": [ - { - "type": "string", - "description": "Insert the X-Csrf-Token", - "name": "X-Csrf-Token", - "in": "header", - "required": true - }, - { - "type": "integer", - "description": "Work History ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "description": "User ID", - "name": "userId", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/response.Response" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/response.BadRequestError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/response.InternalServerError" - } - } - } - } } }, "definitions": { - "controller.PaymentStatusUpdateRequest": { - "type": "object", - "required": [ - "paymentStatus" - ], - "properties": { - "paymentProof": { - "type": "string" - }, - "paymentStatus": { - "type": "string" - }, - "transactionId": { - "type": "string" - } - } - }, "paginator.Pagination": { "type": "object", "properties": { @@ -16012,79 +7129,6 @@ } } }, - "request.AIChatMessagesCreateRequest": { - "type": "object", - "required": [ - "content", - "messageType", - "sessionId" - ], - "properties": { - "content": { - "type": "string", - "minLength": 1 - }, - "messageType": { - "type": "string", - "enum": [ - "user", - "assistant" - ] - }, - "sessionId": { - "type": "string" - } - } - }, - "request.AIChatMessagesUpdateRequest": { - "type": "object", - "required": [ - "content" - ], - "properties": { - "content": { - "type": "string", - "minLength": 1 - } - } - }, - "request.AIChatSessionsCreateRequest": { - "type": "object", - "required": [ - "agentId", - "sessionId", - "title" - ], - "properties": { - "agentId": { - "type": "string" - }, - "sessionId": { - "type": "string" - }, - "title": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, - "request.AIChatSessionsUpdateRequest": { - "type": "object", - "required": [ - "title" - ], - "properties": { - "isActive": { - "type": "boolean" - }, - "title": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, "request.ActivityLogsCreateRequest": { "type": "object", "required": [ @@ -16134,56 +7178,6 @@ } } }, - "request.AdvertisementCreateRequest": { - "type": "object", - "required": [ - "description", - "placement", - "redirectLink", - "title" - ], - "properties": { - "description": { - "type": "string" - }, - "placement": { - "type": "string" - }, - "redirectLink": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.AdvertisementUpdateRequest": { - "type": "object", - "required": [ - "description", - "id", - "placement", - "redirectLink", - "title" - ], - "properties": { - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "placement": { - "type": "string" - }, - "redirectLink": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, "request.ArticleApprovalsCreateRequest": { "type": "object", "required": [ @@ -16519,382 +7513,6 @@ } } }, - "request.CampaignDestinationsCreateRequest": { - "type": "object", - "required": [ - "campaignTypeId", - "name" - ], - "properties": { - "campaignTypeId": { - "type": "integer" - }, - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "isActive": { - "type": "boolean" - }, - "name": { - "type": "string" - }, - "subType": { - "type": "string" - }, - "url": { - "type": "string" - } - } - }, - "request.CampaignDestinationsUpdateRequest": { - "type": "object", - "required": [ - "campaignTypeId", - "name" - ], - "properties": { - "campaignTypeId": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "isActive": { - "type": "boolean" - }, - "name": { - "type": "string" - }, - "subType": { - "type": "string" - }, - "url": { - "type": "string" - } - } - }, - "request.CampaignTypesCreateRequest": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "request.CampaignTypesUpdateRequest": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "description": { - "type": "string" - }, - "name": { - "type": "string" - } - } - }, - "request.CampaignsCreateRequest": { - "type": "object", - "required": [ - "campaignTypeId", - "title" - ], - "properties": { - "campaignTypeId": { - "type": "integer" - }, - "creatorId": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "endDate": { - "type": "string" - }, - "mediaItemSelected": { - "type": "string" - }, - "mediaPromote": { - "type": "boolean" - }, - "mediaTypeSelected": { - "type": "string" - }, - "purpose": { - "type": "string" - }, - "startDate": { - "type": "string" - }, - "status": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.CampaignsUpdateRequest": { - "type": "object", - "required": [ - "campaignTypeId", - "title" - ], - "properties": { - "campaignTypeId": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "endDate": { - "type": "string" - }, - "mediaItemSelected": { - "type": "string" - }, - "mediaPromote": { - "type": "boolean" - }, - "mediaTypeSelected": { - "type": "string" - }, - "purpose": { - "type": "string" - }, - "startDate": { - "type": "string" - }, - "status": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.ChatMessageCreateRequest": { - "type": "object", - "required": [ - "chatSessionId", - "message" - ], - "properties": { - "chatSessionId": { - "type": "integer" - }, - "message": { - "type": "string", - "maxLength": 1000, - "minLength": 1 - }, - "messageType": { - "type": "string", - "enum": [ - "text", - "image", - "file", - "user", - "assistant" - ] - } - } - }, - "request.ChatMessageUpdateRequest": { - "type": "object", - "required": [ - "message" - ], - "properties": { - "message": { - "type": "string", - "maxLength": 1000, - "minLength": 1 - } - } - }, - "request.ChatScheduleCreateRequest": { - "type": "object", - "required": [ - "scheduled_at", - "title" - ], - "properties": { - "chat_session_id": { - "description": "Optional - if empty, will create new chat session", - "type": "integer" - }, - "description": { - "type": "string", - "maxLength": 1000 - }, - "duration": { - "description": "15 minutes to 8 hours", - "type": "integer", - "maximum": 480, - "minimum": 15 - }, - "file_ids": { - "description": "Array of file IDs to attach to schedule", - "type": "array", - "items": { - "type": "integer" - } - }, - "scheduled_at": { - "type": "string" - }, - "summary": { - "type": "string", - "maxLength": 2000 - }, - "title": { - "type": "string", - "maxLength": 255, - "minLength": 3 - } - } - }, - "request.ChatScheduleFileUpdateRequest": { - "type": "object", - "properties": { - "description": { - "type": "string", - "maxLength": 500 - }, - "file_name": { - "type": "string", - "maxLength": 255 - }, - "file_path": { - "type": "string", - "maxLength": 500 - }, - "file_size": { - "type": "integer", - "minimum": 0 - }, - "file_type": { - "type": "string", - "enum": [ - "article", - "journal", - "video", - "audio", - "document", - "other" - ] - }, - "is_required": { - "type": "boolean" - }, - "mime_type": { - "type": "string", - "maxLength": 100 - }, - "original_name": { - "type": "string", - "maxLength": 255 - } - } - }, - "request.ChatScheduleUpdateRequest": { - "type": "object", - "properties": { - "description": { - "type": "string", - "maxLength": 1000 - }, - "duration": { - "type": "integer", - "maximum": 480, - "minimum": 15 - }, - "file_ids": { - "description": "Array of file IDs to attach to schedule", - "type": "array", - "items": { - "type": "integer" - } - }, - "scheduled_at": { - "type": "string" - }, - "status": { - "type": "string", - "enum": [ - "scheduled", - "ongoing", - "completed", - "cancelled" - ] - }, - "summary": { - "type": "string", - "maxLength": 2000 - }, - "title": { - "type": "string", - "maxLength": 255, - "minLength": 3 - } - } - }, - "request.ChatSessionCreateRequest": { - "type": "object", - "required": [ - "type", - "userIds" - ], - "properties": { - "name": { - "description": "null for personal chat", - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "type": { - "type": "string", - "enum": [ - "personal", - "group" - ] - }, - "userIds": { - "description": "participants (excluding creator)", - "type": "array", - "minItems": 1, - "items": { - "type": "integer" - } - } - } - }, - "request.ChatSessionUpdateRequest": { - "type": "object", - "properties": { - "name": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, "request.CitiesCreateRequest": { "type": "object", "required": [ @@ -16980,231 +7598,6 @@ } } }, - "request.EbookRatingsCreateRequest": { - "type": "object", - "required": [ - "ebookId", - "purchaseId", - "rating" - ], - "properties": { - "ebookId": { - "type": "integer" - }, - "isAnonymous": { - "type": "boolean" - }, - "purchaseId": { - "type": "integer" - }, - "rating": { - "type": "integer", - "maximum": 5, - "minimum": 1 - }, - "review": { - "type": "string" - } - } - }, - "request.EbookRatingsUpdateRequest": { - "type": "object", - "required": [ - "rating" - ], - "properties": { - "isAnonymous": { - "type": "boolean" - }, - "rating": { - "type": "integer", - "maximum": 5, - "minimum": 1 - }, - "review": { - "type": "string" - } - } - }, - "request.EbooksCreateRequest": { - "type": "object", - "required": [ - "description", - "price", - "slug", - "title" - ], - "properties": { - "category": { - "type": "string" - }, - "createdAt": { - "type": "string" - }, - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "isPublished": { - "type": "boolean" - }, - "isbn": { - "type": "string" - }, - "language": { - "type": "string" - }, - "pageCount": { - "type": "integer" - }, - "price": { - "type": "number", - "minimum": 0 - }, - "publishedYear": { - "type": "integer" - }, - "publisher": { - "type": "string" - }, - "slug": { - "type": "string" - }, - "tags": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.EbooksUpdateRequest": { - "type": "object", - "required": [ - "description", - "price", - "slug", - "title" - ], - "properties": { - "category": { - "type": "string" - }, - "createdAt": { - "type": "string" - }, - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "isPublished": { - "type": "boolean" - }, - "isbn": { - "type": "string" - }, - "language": { - "type": "string" - }, - "pageCount": { - "type": "integer" - }, - "price": { - "type": "number", - "minimum": 0 - }, - "publishedYear": { - "type": "integer" - }, - "publisher": { - "type": "string" - }, - "slug": { - "type": "string" - }, - "statusId": { - "type": "integer" - }, - "tags": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.EducationHistoryCreateRequest": { - "type": "object", - "required": [ - "educationLevel", - "graduationYear", - "major", - "schoolName" - ], - "properties": { - "certificateImage": { - "type": "string" - }, - "educationLevel": { - "type": "string", - "maxLength": 100, - "minLength": 2 - }, - "graduationYear": { - "type": "integer", - "maximum": 2030, - "minimum": 1950 - }, - "major": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "schoolName": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, - "request.EducationHistoryUpdateRequest": { - "type": "object", - "required": [ - "educationLevel", - "graduationYear", - "major", - "schoolName" - ], - "properties": { - "certificateImage": { - "type": "string" - }, - "educationLevel": { - "type": "string", - "maxLength": 100, - "minLength": 2 - }, - "graduationYear": { - "type": "integer", - "maximum": 2030, - "minimum": 1950 - }, - "major": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "schoolName": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, "request.FeedbacksCreateRequest": { "type": "object", "required": [ @@ -17247,245 +7640,6 @@ } } }, - "request.MagazinesCreateRequest": { - "type": "object", - "required": [ - "description", - "statusId", - "title" - ], - "properties": { - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "isPublish": { - "type": "boolean" - }, - "pageUrl": { - "type": "string" - }, - "publishedAt": { - "type": "string" - }, - "statusId": { - "type": "integer" - }, - "thumbnailPath": { - "type": "string" - }, - "thumbnailUrl": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.MagazinesUpdateRequest": { - "type": "object", - "required": [ - "description", - "id", - "statusId", - "title" - ], - "properties": { - "createdById": { - "type": "integer" - }, - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "isPublish": { - "type": "boolean" - }, - "pageUrl": { - "type": "string" - }, - "publishedAt": { - "type": "string" - }, - "statusId": { - "type": "integer" - }, - "thumbnailPath": { - "type": "string" - }, - "thumbnailUrl": { - "type": "string" - }, - "title": { - "type": "string" - } - } - }, - "request.MasterMenusCreateRequest": { - "type": "object", - "required": [ - "description", - "group", - "moduleId", - "name", - "statusId" - ], - "properties": { - "description": { - "type": "string" - }, - "group": { - "type": "string" - }, - "icon": { - "type": "string" - }, - "moduleId": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "parentMenuId": { - "type": "integer" - }, - "statusId": { - "type": "integer" - } - } - }, - "request.MasterModulesCreateRequest": { - "type": "object", - "required": [ - "description", - "name", - "pathUrl", - "statusId" - ], - "properties": { - "description": { - "type": "string" - }, - "name": { - "type": "string" - }, - "pathUrl": { - "type": "string" - }, - "statusId": { - "type": "integer" - } - } - }, - "request.MasterModulesUpdateRequest": { - "type": "object", - "required": [ - "description", - "id", - "name", - "pathUrl", - "statusId" - ], - "properties": { - "description": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - }, - "pathUrl": { - "type": "string" - }, - "statusId": { - "type": "integer" - } - } - }, - "request.ResearchJournalsCreateRequest": { - "type": "object", - "required": [ - "journalTitle", - "journalUrl", - "publisher" - ], - "properties": { - "journalTitle": { - "type": "string", - "maxLength": 500, - "minLength": 2 - }, - "journalUrl": { - "type": "string" - }, - "publishedDate": { - "type": "string" - }, - "publisher": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, - "request.ResearchJournalsUpdateRequest": { - "type": "object", - "required": [ - "journalTitle", - "journalUrl", - "publisher" - ], - "properties": { - "journalTitle": { - "type": "string", - "maxLength": 500, - "minLength": 2 - }, - "journalUrl": { - "type": "string" - }, - "publishedDate": { - "type": "string" - }, - "publisher": { - "type": "string", - "maxLength": 255, - "minLength": 2 - } - } - }, - "request.SubscriptionCreateRequest": { - "type": "object", - "required": [ - "email" - ], - "properties": { - "email": { - "type": "string" - } - } - }, - "request.SubscriptionUpdateRequest": { - "type": "object", - "required": [ - "email", - "id" - ], - "properties": { - "email": { - "type": "string" - }, - "id": { - "type": "integer" - } - } - }, "request.UserEmailValidationRequest": { "type": "object", "properties": { @@ -17949,58 +8103,6 @@ } } }, - "request.WorkHistoryCreateRequest": { - "type": "object", - "required": [ - "companyName", - "jobTitle", - "startDate" - ], - "properties": { - "companyName": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "endDate": { - "type": "string" - }, - "jobTitle": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "startDate": { - "type": "string" - } - } - }, - "request.WorkHistoryUpdateRequest": { - "type": "object", - "required": [ - "companyName", - "jobTitle", - "startDate" - ], - "properties": { - "companyName": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "endDate": { - "type": "string" - }, - "jobTitle": { - "type": "string", - "maxLength": 255, - "minLength": 2 - }, - "startDate": { - "type": "string" - } - } - }, "response.BadRequestError": { "type": "object", "properties": { diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index e320f75..8fcc22d 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -1,15 +1,4 @@ definitions: - controller.PaymentStatusUpdateRequest: - properties: - paymentProof: - type: string - paymentStatus: - type: string - transactionId: - type: string - required: - - paymentStatus - type: object paginator.Pagination: properties: count: @@ -29,57 +18,6 @@ definitions: totalPage: type: integer type: object - request.AIChatMessagesCreateRequest: - properties: - content: - minLength: 1 - type: string - messageType: - enum: - - user - - assistant - type: string - sessionId: - type: string - required: - - content - - messageType - - sessionId - type: object - request.AIChatMessagesUpdateRequest: - properties: - content: - minLength: 1 - type: string - required: - - content - type: object - request.AIChatSessionsCreateRequest: - properties: - agentId: - type: string - sessionId: - type: string - title: - maxLength: 255 - minLength: 2 - type: string - required: - - agentId - - sessionId - - title - type: object - request.AIChatSessionsUpdateRequest: - properties: - isActive: - type: boolean - title: - maxLength: 255 - minLength: 2 - type: string - required: - - title - type: object request.ActivityLogsCreateRequest: properties: activityTypeId: @@ -113,41 +51,6 @@ definitions: - id - url type: object - request.AdvertisementCreateRequest: - properties: - description: - type: string - placement: - type: string - redirectLink: - type: string - title: - type: string - required: - - description - - placement - - redirectLink - - title - type: object - request.AdvertisementUpdateRequest: - properties: - description: - type: string - id: - type: integer - placement: - type: string - redirectLink: - type: string - title: - type: string - required: - - description - - id - - placement - - redirectLink - - title - type: object request.ArticleApprovalsCreateRequest: properties: articleId: @@ -378,270 +281,6 @@ definitions: - title - typeId type: object - request.CampaignDestinationsCreateRequest: - properties: - campaignTypeId: - type: integer - createdById: - type: integer - description: - type: string - isActive: - type: boolean - name: - type: string - subType: - type: string - url: - type: string - required: - - campaignTypeId - - name - type: object - request.CampaignDestinationsUpdateRequest: - properties: - campaignTypeId: - type: integer - description: - type: string - isActive: - type: boolean - name: - type: string - subType: - type: string - url: - type: string - required: - - campaignTypeId - - name - type: object - request.CampaignTypesCreateRequest: - properties: - createdById: - type: integer - description: - type: string - name: - type: string - required: - - name - type: object - request.CampaignTypesUpdateRequest: - properties: - description: - type: string - name: - type: string - required: - - name - type: object - request.CampaignsCreateRequest: - properties: - campaignTypeId: - type: integer - creatorId: - type: integer - description: - type: string - endDate: - type: string - mediaItemSelected: - type: string - mediaPromote: - type: boolean - mediaTypeSelected: - type: string - purpose: - type: string - startDate: - type: string - status: - type: string - title: - type: string - required: - - campaignTypeId - - title - type: object - request.CampaignsUpdateRequest: - properties: - campaignTypeId: - type: integer - description: - type: string - endDate: - type: string - mediaItemSelected: - type: string - mediaPromote: - type: boolean - mediaTypeSelected: - type: string - purpose: - type: string - startDate: - type: string - status: - type: string - title: - type: string - required: - - campaignTypeId - - title - type: object - request.ChatMessageCreateRequest: - properties: - chatSessionId: - type: integer - message: - maxLength: 1000 - minLength: 1 - type: string - messageType: - enum: - - text - - image - - file - - user - - assistant - type: string - required: - - chatSessionId - - message - type: object - request.ChatMessageUpdateRequest: - properties: - message: - maxLength: 1000 - minLength: 1 - type: string - required: - - message - type: object - request.ChatScheduleCreateRequest: - properties: - chat_session_id: - description: Optional - if empty, will create new chat session - type: integer - description: - maxLength: 1000 - type: string - duration: - description: 15 minutes to 8 hours - maximum: 480 - minimum: 15 - type: integer - file_ids: - description: Array of file IDs to attach to schedule - items: - type: integer - type: array - scheduled_at: - type: string - summary: - maxLength: 2000 - type: string - title: - maxLength: 255 - minLength: 3 - type: string - required: - - scheduled_at - - title - type: object - request.ChatScheduleFileUpdateRequest: - properties: - description: - maxLength: 500 - type: string - file_name: - maxLength: 255 - type: string - file_path: - maxLength: 500 - type: string - file_size: - minimum: 0 - type: integer - file_type: - enum: - - article - - journal - - video - - audio - - document - - other - type: string - is_required: - type: boolean - mime_type: - maxLength: 100 - type: string - original_name: - maxLength: 255 - type: string - type: object - request.ChatScheduleUpdateRequest: - properties: - description: - maxLength: 1000 - type: string - duration: - maximum: 480 - minimum: 15 - type: integer - file_ids: - description: Array of file IDs to attach to schedule - items: - type: integer - type: array - scheduled_at: - type: string - status: - enum: - - scheduled - - ongoing - - completed - - cancelled - type: string - summary: - maxLength: 2000 - type: string - title: - maxLength: 255 - minLength: 3 - type: string - type: object - request.ChatSessionCreateRequest: - properties: - name: - description: null for personal chat - maxLength: 255 - minLength: 2 - type: string - type: - enum: - - personal - - group - type: string - userIds: - description: participants (excluding creator) - items: - type: integer - minItems: 1 - type: array - required: - - type - - userIds - type: object - request.ChatSessionUpdateRequest: - properties: - name: - maxLength: 255 - minLength: 2 - type: string - type: object request.CitiesCreateRequest: properties: cityName: @@ -700,166 +339,6 @@ definitions: - slug - title type: object - request.EbookRatingsCreateRequest: - properties: - ebookId: - type: integer - isAnonymous: - type: boolean - purchaseId: - type: integer - rating: - maximum: 5 - minimum: 1 - type: integer - review: - type: string - required: - - ebookId - - purchaseId - - rating - type: object - request.EbookRatingsUpdateRequest: - properties: - isAnonymous: - type: boolean - rating: - maximum: 5 - minimum: 1 - type: integer - review: - type: string - required: - - rating - type: object - request.EbooksCreateRequest: - properties: - category: - type: string - createdAt: - type: string - createdById: - type: integer - description: - type: string - isPublished: - type: boolean - isbn: - type: string - language: - type: string - pageCount: - type: integer - price: - minimum: 0 - type: number - publishedYear: - type: integer - publisher: - type: string - slug: - type: string - tags: - type: string - title: - type: string - required: - - description - - price - - slug - - title - type: object - request.EbooksUpdateRequest: - properties: - category: - type: string - createdAt: - type: string - createdById: - type: integer - description: - type: string - isPublished: - type: boolean - isbn: - type: string - language: - type: string - pageCount: - type: integer - price: - minimum: 0 - type: number - publishedYear: - type: integer - publisher: - type: string - slug: - type: string - statusId: - type: integer - tags: - type: string - title: - type: string - required: - - description - - price - - slug - - title - type: object - request.EducationHistoryCreateRequest: - properties: - certificateImage: - type: string - educationLevel: - maxLength: 100 - minLength: 2 - type: string - graduationYear: - maximum: 2030 - minimum: 1950 - type: integer - major: - maxLength: 255 - minLength: 2 - type: string - schoolName: - maxLength: 255 - minLength: 2 - type: string - required: - - educationLevel - - graduationYear - - major - - schoolName - type: object - request.EducationHistoryUpdateRequest: - properties: - certificateImage: - type: string - educationLevel: - maxLength: 100 - minLength: 2 - type: string - graduationYear: - maximum: 2030 - minimum: 1950 - type: integer - major: - maxLength: 255 - minLength: 2 - type: string - schoolName: - maxLength: 255 - minLength: 2 - type: string - required: - - educationLevel - - graduationYear - - major - - schoolName - type: object request.FeedbacksCreateRequest: properties: commentFromEmail: @@ -889,172 +368,6 @@ definitions: - id - message type: object - request.MagazinesCreateRequest: - properties: - createdById: - type: integer - description: - type: string - isPublish: - type: boolean - pageUrl: - type: string - publishedAt: - type: string - statusId: - type: integer - thumbnailPath: - type: string - thumbnailUrl: - type: string - title: - type: string - required: - - description - - statusId - - title - type: object - request.MagazinesUpdateRequest: - properties: - createdById: - type: integer - description: - type: string - id: - type: integer - isPublish: - type: boolean - pageUrl: - type: string - publishedAt: - type: string - statusId: - type: integer - thumbnailPath: - type: string - thumbnailUrl: - type: string - title: - type: string - required: - - description - - id - - statusId - - title - type: object - request.MasterMenusCreateRequest: - properties: - description: - type: string - group: - type: string - icon: - type: string - moduleId: - type: integer - name: - type: string - parentMenuId: - type: integer - statusId: - type: integer - required: - - description - - group - - moduleId - - name - - statusId - type: object - request.MasterModulesCreateRequest: - properties: - description: - type: string - name: - type: string - pathUrl: - type: string - statusId: - type: integer - required: - - description - - name - - pathUrl - - statusId - type: object - request.MasterModulesUpdateRequest: - properties: - description: - type: string - id: - type: integer - name: - type: string - pathUrl: - type: string - statusId: - type: integer - required: - - description - - id - - name - - pathUrl - - statusId - type: object - request.ResearchJournalsCreateRequest: - properties: - journalTitle: - maxLength: 500 - minLength: 2 - type: string - journalUrl: - type: string - publishedDate: - type: string - publisher: - maxLength: 255 - minLength: 2 - type: string - required: - - journalTitle - - journalUrl - - publisher - type: object - request.ResearchJournalsUpdateRequest: - properties: - journalTitle: - maxLength: 500 - minLength: 2 - type: string - journalUrl: - type: string - publishedDate: - type: string - publisher: - maxLength: 255 - minLength: 2 - type: string - required: - - journalTitle - - journalUrl - - publisher - type: object - request.SubscriptionCreateRequest: - properties: - email: - type: string - required: - - email - type: object - request.SubscriptionUpdateRequest: - properties: - email: - type: string - id: - type: integer - required: - - email - - id - type: object request.UserEmailValidationRequest: properties: newEmail: @@ -1371,44 +684,6 @@ definitions: - userRoleId - username type: object - request.WorkHistoryCreateRequest: - properties: - companyName: - maxLength: 255 - minLength: 2 - type: string - endDate: - type: string - jobTitle: - maxLength: 255 - minLength: 2 - type: string - startDate: - type: string - required: - - companyName - - jobTitle - - startDate - type: object - request.WorkHistoryUpdateRequest: - properties: - companyName: - maxLength: 255 - minLength: 2 - type: string - endDate: - type: string - jobTitle: - maxLength: 255 - minLength: 2 - type: string - startDate: - type: string - required: - - companyName - - jobTitle - - startDate - type: object response.BadRequestError: properties: code: @@ -1698,844 +973,6 @@ paths: summary: Get activity stats ActivityLogs tags: - ActivityLogs - /advertisement: - get: - description: API for getting all Advertisement - parameters: - - in: query - name: description - type: string - - in: query - name: isPublish - type: boolean - - in: query - name: placement - type: string - - in: query - name: redirectLink - type: string - - in: query - name: statusId - type: integer - - in: query - name: title - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all Advertisement - tags: - - Advertisement - post: - description: API for create Advertisement - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.AdvertisementCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create Advertisement - tags: - - Advertisement - /advertisement/{id}: - delete: - description: API for delete Advertisement - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Advertisement ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: delete Advertisement - tags: - - Advertisement - get: - description: API for getting one Advertisement - parameters: - - description: Advertisement ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one Advertisement - tags: - - Advertisement - put: - description: API for update Advertisement - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.AdvertisementUpdateRequest' - - description: Advertisement ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: update Advertisement - tags: - - Advertisement - /advertisement/publish/{id}: - put: - description: API for Update Publish Advertisement - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Advertisement ID - in: path - name: id - required: true - type: integer - - description: Advertisement Publish Status - in: query - name: isPublish - required: true - type: boolean - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update Publish Advertisement - tags: - - Advertisement - /advertisement/upload/{id}: - post: - description: API for Upload File Advertisement - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Upload file - in: formData - name: file - required: true - type: file - - description: Advertisement ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Upload Advertisement - tags: - - Advertisement - /advertisement/viewer/{filename}: - get: - description: API for Viewer Advertisement - parameters: - - description: Content File Name - in: path - name: filename - required: true - type: string - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Viewer Advertisement - tags: - - Advertisement - /ai-chat/logs: - get: - description: API for getting all AI chat logs for authenticated user - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - in: query - name: logType - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get user AI chat logs - tags: - - AI Chat - /ai-chat/logs/{id}: - get: - description: API for getting one AI chat log - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Log ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one AI chat log - tags: - - AI Chat - /ai-chat/sessions: - get: - description: API for getting all AI chat sessions for authenticated user - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - in: query - name: isActive - type: boolean - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get user AI chat sessions - tags: - - AI Chat - post: - description: API for create AI chat session - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.AIChatSessionsCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create AI chat session - tags: - - AI Chat - /ai-chat/sessions/{id}: - delete: - description: API for delete AI chat session - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Session ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete AI chat session - tags: - - AI Chat - get: - description: API for getting one AI chat session - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Session ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one AI chat session - tags: - - AI Chat - put: - description: API for update AI chat session - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - type: string - - description: Session ID - in: path - name: id - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.AIChatSessionsUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update AI chat session - tags: - - AI Chat - /ai-chat/sessions/{id}/messages: - get: - description: API for getting all messages in an AI chat session - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Session ID - in: path - name: id - required: true - type: integer - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get AI chat session messages - tags: - - AI Chat - /ai-chat/sessions/messages: - post: - description: API for sending a message to an AI chat session - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.AIChatMessagesCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Send message to AI chat session - tags: - - AI Chat - /ai-chat/sessions/messages/{messageId}: - delete: - description: API for delete AI chat message - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Message ID - in: path - name: messageId - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete AI chat message - tags: - - AI Chat - put: - description: API for update AI chat message - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Message ID - in: path - name: messageId - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.AIChatMessagesUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update AI chat message - tags: - - AI Chat /article-approvals: get: description: API for getting all ArticleApprovals @@ -4339,1776 +2776,6 @@ paths: summary: Viewer Articles Thumbnail tags: - Articles - /campaign-destinations: - get: - description: API for getting all CampaignDestinations - parameters: - - description: Insert the X-Client-Key - in: header - name: X-Client-Key - required: true - type: string - - in: query - name: campaignTypeId - type: integer - - in: query - name: isActive - type: boolean - - in: query - name: name - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all CampaignDestinations - tags: - - CampaignDestinations - post: - description: API for create CampaignDestinations - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.CampaignDestinationsCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create CampaignDestinations - tags: - - CampaignDestinations - /campaign-destinations/{id}: - delete: - description: API for delete CampaignDestinations - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: CampaignDestinations ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete CampaignDestinations - tags: - - CampaignDestinations - get: - description: API for getting one CampaignDestinations - parameters: - - description: CampaignDestinations ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one CampaignDestinations - tags: - - CampaignDestinations - put: - description: API for update CampaignDestinations - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.CampaignDestinationsUpdateRequest' - - description: CampaignDestinations ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update CampaignDestinations - tags: - - CampaignDestinations - /campaign-types: - get: - description: API for getting all CampaignTypes - parameters: - - description: Insert the X-Client-Key - in: header - name: X-Client-Key - required: true - type: string - - in: query - name: name - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all CampaignTypes - tags: - - CampaignTypes - post: - description: API for create CampaignTypes - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.CampaignTypesCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create CampaignTypes - tags: - - CampaignTypes - /campaign-types/{id}: - delete: - description: API for delete CampaignTypes - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: CampaignTypes ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete CampaignTypes - tags: - - CampaignTypes - get: - description: API for getting one CampaignTypes - parameters: - - description: CampaignTypes ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one CampaignTypes - tags: - - CampaignTypes - put: - description: API for update CampaignTypes - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.CampaignTypesUpdateRequest' - - description: CampaignTypes ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update CampaignTypes - tags: - - CampaignTypes - /campaigns: - get: - description: API for getting all Campaigns - parameters: - - description: Insert the X-Client-Key - in: header - name: X-Client-Key - required: true - type: string - - in: query - name: campaignTypeId - type: integer - - in: query - name: creatorId - type: integer - - in: query - name: status - type: string - - in: query - name: title - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all Campaigns - tags: - - Campaigns - post: - description: API for create Campaigns - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.CampaignsCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create Campaigns - tags: - - Campaigns - /campaigns/{id}: - delete: - description: API for delete Campaigns - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Campaigns ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete Campaigns - tags: - - Campaigns - get: - description: API for getting one Campaigns - parameters: - - description: Campaigns ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one Campaigns - tags: - - Campaigns - put: - description: API for update Campaigns - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.CampaignsUpdateRequest' - - description: Campaigns ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update Campaigns - tags: - - Campaigns - /chat/messages: - get: - description: API for getting all messages in a specific chat session - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Session ID - in: query - name: chatSessionId - required: true - type: integer - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all chat messages - tags: - - Chat - post: - description: API for creating a new chat message - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.ChatMessageCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create chat message - tags: - - Chat - /chat/messages/{id}: - delete: - description: API for deleting chat message (only sender can delete) - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Message ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete chat message - tags: - - Chat - get: - description: API for getting one chat message - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Message ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one chat message - tags: - - Chat - put: - description: API for updating chat message (only sender can update) - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Message ID - in: path - name: id - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.ChatMessageUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update chat message - tags: - - Chat - /chat/schedule-files: - get: - description: API for getting files for a specific chat schedule - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Schedule ID - in: query - name: chatScheduleId - required: true - type: integer - - description: File type filter - in: query - name: fileType - type: string - - description: Required file filter - in: query - name: isRequired - type: boolean - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get chat schedule files - tags: - - Chat Schedule File - /chat/schedule-files/{chatScheduleId}: - post: - description: API for uploading file for chat schedule - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Upload file - in: formData - name: files - required: true - type: file - - description: Chat Schedule ID - in: path - name: chatScheduleId - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Upload chat schedule file - tags: - - Chat Schedule File - /chat/schedule-files/{id}: - delete: - description: API for deleting chat schedule file - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Schedule File ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete chat schedule file - tags: - - Chat Schedule File - get: - description: API for getting one chat schedule file - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Schedule File ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one chat schedule file - tags: - - Chat Schedule File - put: - description: API for updating chat schedule file - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Schedule File ID - in: path - name: id - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.ChatScheduleFileUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update chat schedule file - tags: - - Chat Schedule File - /chat/schedule-files/viewer/{filename}: - get: - description: API for viewing chat schedule file - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Schedule File Name - in: path - name: filename - required: true - type: string - responses: - "200": - description: OK - schema: - type: file - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: View chat schedule file - tags: - - Chat Schedule File - /chat/schedules: - get: - description: API for getting all chat schedules for authenticated user - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Session ID - in: query - name: chatSessionId - type: string - - description: Schedule status (scheduled, ongoing, completed, cancelled) - in: query - name: status - type: string - - description: Created by user ID - in: query - name: createdBy - type: string - - description: Date from (YYYY-MM-DD) - in: query - name: dateFrom - type: string - - description: Date to (YYYY-MM-DD) - in: query - name: dateTo - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all chat schedules - tags: - - Chat Schedule - post: - description: API for creating a new chat schedule - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.ChatScheduleCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create chat schedule - tags: - - Chat Schedule - /chat/schedules/{id}: - delete: - description: API for deleting chat schedule (only creator can delete) - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Schedule ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete chat schedule - tags: - - Chat Schedule - get: - description: API for getting one chat schedule - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Schedule ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one chat schedule - tags: - - Chat Schedule - put: - description: API for updating chat schedule (only creator can update) - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Schedule ID - in: path - name: id - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.ChatScheduleUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update chat schedule - tags: - - Chat Schedule - /chat/schedules/{id}/reminder: - post: - description: API for sending reminder for a chat schedule (only creator can - send) - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Schedule ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Send schedule reminder - tags: - - Chat Schedule - /chat/schedules/status/{status}: - get: - description: API for getting chat schedules by status - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Schedule status (scheduled, ongoing, completed, cancelled) - in: path - name: status - required: true - type: string - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get schedules by status - tags: - - Chat Schedule - /chat/schedules/upcoming: - get: - description: API for getting upcoming chat schedules for authenticated user - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - default: 10 - description: Limit number of results - in: query - name: limit - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get upcoming schedules - tags: - - Chat Schedule - /chat/sessions: - get: - description: API for getting all chat sessions for authenticated user - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat type (personal or group) - in: query - name: type - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all chat sessions - tags: - - Chat - post: - description: API for creating a new chat session (personal or group) - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.ChatSessionCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create chat session - tags: - - Chat - /chat/sessions/{chatSessionId}/participants: - delete: - description: API for removing a participant from a chat session (creator can - remove anyone, user can remove themselves) - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Session ID - in: path - name: chatSessionId - required: true - type: integer - - description: Participant User ID - in: query - name: participantUserId - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Remove participant from chat session - tags: - - Chat - post: - description: API for adding a participant to a chat session (only creator can - add) - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Session ID - in: path - name: chatSessionId - required: true - type: integer - - description: Participant User ID - in: query - name: participantUserId - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Add participant to chat session - tags: - - Chat - /chat/sessions/{id}: - delete: - description: API for deleting chat session (only creator can delete) - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Session ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete chat session - tags: - - Chat - get: - description: API for getting one chat session - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Session ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one chat session - tags: - - Chat - put: - description: API for updating chat session (only creator can update) - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Chat Session ID - in: path - name: id - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.ChatSessionUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update chat session - tags: - - Chat /cities: get: description: API for getting all Cities @@ -6682,1405 +3349,6 @@ paths: summary: Update Districts tags: - Untags - /ebook-ratings: - get: - description: API for getting all Ebook Ratings - parameters: - - description: Insert the X-Client-Key - in: header - name: X-Client-Key - required: true - type: string - - in: query - name: ebookId - type: integer - - in: query - name: isVerified - type: boolean - - in: query - name: rating - type: integer - - in: query - name: statusId - type: integer - - in: query - name: userId - type: integer - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all Ebook Ratings - tags: - - Ebook Ratings - post: - description: API for creating ebook rating - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.EbookRatingsCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create ebook rating - tags: - - Ebook Ratings - /ebook-ratings/{id}: - delete: - description: API for deleting ebook rating - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Rating ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete ebook rating - tags: - - Ebook Ratings - put: - description: API for updating ebook rating - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.EbookRatingsUpdateRequest' - - description: Rating ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update ebook rating - tags: - - Ebook Ratings - /ebook-ratings/ebook/{id}: - get: - description: API for getting ratings by ebook ID - parameters: - - description: Insert the X-Client-Key - in: header - name: X-Client-Key - required: true - type: string - - description: Ebook ID - in: path - name: id - required: true - type: integer - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get ratings by ebook ID - tags: - - Ebook Ratings - /ebook-ratings/stats/{id}: - get: - description: API for getting ebook rating statistics - parameters: - - description: Insert the X-Client-Key - in: header - name: X-Client-Key - required: true - type: string - - description: Ebook ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get ebook rating statistics - tags: - - Ebook Ratings - /ebook-ratings/summary/{id}: - get: - description: API for getting ebook rating summary with stats and recent reviews - parameters: - - description: Insert the X-Client-Key - in: header - name: X-Client-Key - required: true - type: string - - description: Ebook ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get ebook rating summary - tags: - - Ebook Ratings - /ebook-ratings/user: - get: - description: API for getting user ratings - parameters: - - description: Insert the X-Client-Key - in: header - name: X-Client-Key - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get user ratings - tags: - - Ebook Ratings - /ebooks: - get: - description: API for getting all Ebooks - parameters: - - description: Insert the X-Client-Key - in: header - name: X-Client-Key - required: true - type: string - - in: query - name: authorId - type: integer - - in: query - name: category - type: string - - in: query - name: description - type: string - - in: query - name: isPublished - type: boolean - - in: query - name: maxPrice - type: number - - in: query - name: minPrice - type: number - - in: query - name: statusId - type: integer - - in: query - name: tags - type: string - - in: query - name: title - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all Ebooks - tags: - - Ebooks - post: - description: API for create Ebook - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.EbooksCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create Ebook - tags: - - Ebooks - /ebooks/{id}: - delete: - description: API for delete Ebook - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Ebook ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete Ebook - tags: - - Ebooks - get: - description: API for getting one Ebook - parameters: - - description: Ebook ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one Ebook - tags: - - Ebooks - put: - description: API for update Ebook - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.EbooksUpdateRequest' - - description: Ebook ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update Ebook - tags: - - Ebooks - /ebooks/download/{id}: - get: - description: API for Download PDF of Ebook - parameters: - - description: Ebook ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Download PDF Ebook - tags: - - Ebooks - /ebooks/pdf/{id}: - post: - description: API for Save PDF File of Ebook - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Upload PDF file - in: formData - name: file - required: true - type: file - - description: Ebook ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Save PDF File Ebook - tags: - - Ebooks - /ebooks/purchase/{ebookId}: - post: - description: API for purchasing ebook - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Ebook ID - in: path - name: ebookId - required: true - type: integer - - description: Payment Method - in: query - name: paymentMethod - required: true - type: string - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Purchase ebook - tags: - - Ebook Purchase - /ebooks/purchases: - get: - description: API for getting user purchases - parameters: - - description: Insert the X-Client-Key - in: header - name: X-Client-Key - required: true - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get user purchases - tags: - - Ebook Purchase - /ebooks/purchases/{id}: - get: - description: API for getting purchase by ID - parameters: - - description: Purchase ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get purchase by ID - tags: - - Ebook Purchase - /ebooks/purchases/{id}/confirm: - put: - description: API for confirming payment - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Purchase ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Confirm payment - tags: - - Ebook Purchase - /ebooks/purchases/{id}/payment: - put: - description: API for updating payment status - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Purchase ID - in: path - name: id - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/controller.PaymentStatusUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update payment status - tags: - - Ebook Purchase - /ebooks/slug/{slug}: - get: - description: API for getting one Ebook by slug - parameters: - - description: Ebook Slug - in: path - name: slug - required: true - type: string - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one Ebook by slug - tags: - - Ebooks - /ebooks/statistic/summary: - get: - description: API for Summary Stats of Ebook - parameters: - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: SummaryStats Ebook - tags: - - Ebooks - /ebooks/thumbnail/{id}: - post: - description: API for Save Thumbnail of Ebook - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Upload thumbnail - in: formData - name: files - required: true - type: file - - description: Ebook ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Save Thumbnail Ebook - tags: - - Ebooks - /ebooks/wishlist: - get: - description: API for getting user wishlist - parameters: - - description: Insert the X-Client-Key - in: header - name: X-Client-Key - required: true - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get user wishlist - tags: - - Ebook Wishlist - /ebooks/wishlist/{ebookId}: - delete: - description: API for removing ebook from wishlist - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Ebook ID - in: path - name: ebookId - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Remove ebook from wishlist - tags: - - Ebook Wishlist - post: - description: API for adding ebook to wishlist - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Ebook ID - in: path - name: ebookId - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Add ebook to wishlist - tags: - - Ebook Wishlist - /ebooks/wishlist/check/{ebookId}: - get: - description: API for checking if ebook is in wishlist - parameters: - - description: Ebook ID - in: path - name: ebookId - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Check if ebook is in wishlist - tags: - - Ebook Wishlist - /education-history: - get: - description: API for getting all Education History for specific user - parameters: - - in: query - name: educationLevel - type: string - - in: query - name: graduationYear - type: integer - - in: query - name: major - type: string - - in: query - name: schoolName - type: string - - in: query - name: userId - required: true - type: integer - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - summary: Get all Education History - tags: - - Education History - post: - description: API for create Education History - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: User ID - in: query - name: userId - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.EducationHistoryCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - summary: Create Education History - tags: - - Education History - /education-history/{id}: - delete: - description: API for delete Education History - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Education History ID - in: path - name: id - required: true - type: integer - - description: User ID - in: query - name: userId - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - summary: Delete Education History - tags: - - Education History - get: - description: API for getting one Education History - parameters: - - description: Education History ID - in: path - name: id - required: true - type: integer - - description: User ID - in: query - name: userId - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - summary: Get one Education History - tags: - - Education History - put: - description: API for update Education History - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Education History ID - in: path - name: id - required: true - type: integer - - description: User ID - in: query - name: userId - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.EducationHistoryUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - summary: Update Education History - tags: - - Education History - /education-history/{id}/certificate: - post: - description: API for upload certificate image for Education History - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Education History ID - in: path - name: id - required: true - type: integer - - description: User ID - in: query - name: userId - required: true - type: integer - - description: Certificate image file - in: formData - name: certificate - required: true - type: file - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - summary: Upload Certificate for Education History - tags: - - Education History /feedbacks: get: description: API for getting all Feedbacks @@ -8332,1078 +3600,6 @@ paths: summary: FeedbackMonthlyStats Feedbacks tags: - Feedbacks - /magazine-files: - get: - description: API for getting all MagazineFiles - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all MagazineFiles - tags: - - Magazine Files - /magazine-files/{id}: - delete: - description: API for delete MagazineFiles - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: MagazineFiles ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: delete MagazineFiles - tags: - - Magazine Files - get: - description: API for getting one MagazineFiles - parameters: - - description: MagazineFiles ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one MagazineFiles - tags: - - Magazine Files - put: - description: API for update MagazineFiles - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: MagazineFiles ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update MagazineFiles - tags: - - Magazine Files - /magazine-files/{magazineId}: - post: - description: API for create MagazineFiles - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Upload file - in: formData - name: files - required: true - type: file - - description: Magazine file title - in: formData - name: title - required: true - type: string - - description: Magazine file description - in: formData - name: description - required: true - type: string - - description: Magazine ID - in: path - name: magazineId - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create MagazineFiles - tags: - - Magazine Files - /magazine-files/viewer/{filename}: - get: - description: API for create MagazineFiles - parameters: - - description: Magazine File Name - in: path - name: filename - required: true - type: string - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create MagazineFiles - tags: - - Magazine Files - /magazines: - get: - description: API for getting all Magazines - parameters: - - in: query - name: createdById - type: integer - - in: query - name: description - type: string - - in: query - name: isPublish - type: boolean - - in: query - name: pageUrl - type: string - - in: query - name: statusId - type: integer - - in: query - name: thumbnailPath - type: string - - in: query - name: thumbnailUrl - type: string - - in: query - name: title - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all Magazines - tags: - - Magazines - post: - description: API for create Magazines - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.MagazinesCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create Magazines - tags: - - Magazines - /magazines/{id}: - delete: - description: API for delete Magazines - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Magazines ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete Magazines - tags: - - Magazines - get: - description: API for getting one Magazines - parameters: - - description: Magazines ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one Magazines - tags: - - Magazines - put: - description: API for update Magazines - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Magazines ID - in: path - name: id - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.MagazinesUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update Magazines - tags: - - Magazines - /magazines/thumbnail/{id}: - post: - description: API for Save Thumbnail of Magazines - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Magazine ID - in: path - name: id - required: true - type: integer - - description: Upload thumbnail - in: formData - name: files - required: true - type: file - produces: - - application/json - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Save Thumbnail Magazines - tags: - - Magazines - /magazines/thumbnail/viewer/{thumbnailName}: - get: - description: API for View Thumbnail of Magazines - parameters: - - description: Magazines Thumbnail Name - in: path - name: thumbnailName - required: true - type: string - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Viewer Magazines Thumbnail - tags: - - Magazines - /master-menus: - get: - description: API for getting all MasterMenus - parameters: - - in: query - name: description - type: string - - in: query - name: moduleId - type: integer - - in: query - name: name - type: string - - in: query - name: parentMenuId - type: integer - - in: query - name: statusId - type: integer - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all MasterMenus - tags: - - MasterMenus - post: - description: API for create MasterMenus - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.MasterMenusCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create MasterMenus - tags: - - MasterMenus - /master-menus/{id}: - delete: - description: API for delete MasterMenus - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: MasterMenus ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete MasterMenus - tags: - - MasterMenus - get: - description: API for getting one MasterMenus - parameters: - - description: MasterMenus ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one MasterMenus - tags: - - MasterMenus - put: - description: API for update MasterMenus - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: MasterMenus ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/response.Response' - "422": - description: Unprocessable Entity - schema: - $ref: '#/definitions/response.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.Response' - security: - - Bearer: [] - summary: Update MasterMenus - tags: - - MasterMenus - /master-modules: - get: - description: API for getting all MasterModules - parameters: - - in: query - name: description - type: string - - in: query - name: name - type: string - - in: query - name: statusId - type: integer - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all MasterModules - tags: - - MasterModules - post: - description: API for create MasterModules - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.MasterModulesCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create MasterModules - tags: - - MasterModules - /master-modules/{id}: - delete: - description: API for delete MasterModules - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: MasterModules ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete MasterModules - tags: - - MasterModules - get: - description: API for getting one MasterModules - parameters: - - description: MasterModules ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one MasterModules - tags: - - MasterModules - put: - description: API for update MasterModules - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: MasterModules ID - in: path - name: id - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.MasterModulesUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update MasterModules - tags: - - MasterModules - /master-statuses: - get: - description: API for getting all MasterStatuses - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/response.Response' - "422": - description: Unprocessable Entity - schema: - $ref: '#/definitions/response.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.Response' - security: - - Bearer: [] - summary: Get all MasterStatuses - tags: - - Untags - post: - description: API for create MasterStatuses - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/response.Response' - "422": - description: Unprocessable Entity - schema: - $ref: '#/definitions/response.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.Response' - security: - - Bearer: [] - summary: Create MasterStatuses - tags: - - Untags - /master-statuses/{id}: - delete: - description: API for delete MasterStatuses - parameters: - - description: MasterStatuses ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/response.Response' - "422": - description: Unprocessable Entity - schema: - $ref: '#/definitions/response.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.Response' - security: - - Bearer: [] - summary: Delete MasterStatuses - tags: - - Untags - get: - description: API for getting one MasterStatuses - parameters: - - description: MasterStatuses ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/response.Response' - "422": - description: Unprocessable Entity - schema: - $ref: '#/definitions/response.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.Response' - security: - - Bearer: [] - summary: Get one MasterStatuses - tags: - - Untags - put: - description: API for update MasterStatuses - parameters: - - description: MasterStatuses ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/response.Response' - "422": - description: Unprocessable Entity - schema: - $ref: '#/definitions/response.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.Response' - security: - - Bearer: [] - summary: Update MasterStatuses - tags: - - Untags /provinces: get: description: API for getting all Provinces @@ -9564,409 +3760,6 @@ paths: summary: Update Provinces tags: - Untags - /research-journals: - get: - description: API for getting all Research Journals for authenticated user - parameters: - - in: query - name: journalTitle - type: string - - in: query - name: publishedYear - type: integer - - in: query - name: publisher - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all Research Journals - tags: - - Research Journals - post: - description: API for create Research Journal - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - default: Bearer - description: Insert your access token - in: header - name: Authorization - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.ResearchJournalsCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create Research Journal - tags: - - Research Journals - /research-journals/{id}: - delete: - description: API for delete Research Journal - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Research Journal ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Delete Research Journal - tags: - - Research Journals - get: - description: API for getting one Research Journal - parameters: - - description: Research Journal ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one Research Journal - tags: - - Research Journals - put: - description: API for update Research Journal - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Research Journal ID - in: path - name: id - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.ResearchJournalsUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Update Research Journal - tags: - - Research Journals - /subscription: - get: - description: API for getting all Subscription - parameters: - - in: query - name: email - type: string - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get all Subscription - tags: - - Subscription - post: - description: API for create Subscription - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.SubscriptionCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Create Subscription - tags: - - Subscription - /subscription/{id}: - delete: - description: API for delete Subscription - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Subscription ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: delete Subscription - tags: - - Subscription - get: - description: API for getting one Subscription - parameters: - - description: Subscription ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: Get one Subscription - tags: - - Subscription - put: - description: API for update Subscription - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.SubscriptionUpdateRequest' - - description: Subscription ID - in: path - name: id - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/response.UnauthorizedError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - security: - - Bearer: [] - summary: update Subscription - tags: - - Subscription /user-levels: get: description: API for getting all UserLevels @@ -11456,201 +5249,4 @@ paths: summary: Get one Users tags: - Users - /work-history: - get: - description: API for getting all Work History for specific user - parameters: - - in: query - name: companyName - type: string - - description: filter for current job (EndDate is null) - in: query - name: isCurrent - type: boolean - - in: query - name: jobTitle - type: string - - in: query - name: userId - required: true - type: integer - - in: query - name: count - type: integer - - in: query - name: limit - type: integer - - in: query - name: nextPage - type: integer - - in: query - name: page - type: integer - - in: query - name: previousPage - type: integer - - in: query - name: sort - type: string - - in: query - name: sortBy - type: string - - in: query - name: totalPage - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - summary: Get all Work History - tags: - - Work History - post: - description: API for create Work History - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: User ID - in: query - name: userId - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.WorkHistoryCreateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - summary: Create Work History - tags: - - Work History - /work-history/{id}: - delete: - description: API for delete Work History - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Work History ID - in: path - name: id - required: true - type: integer - - description: User ID - in: query - name: userId - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - summary: Delete Work History - tags: - - Work History - get: - description: API for getting one Work History - parameters: - - description: Work History ID - in: path - name: id - required: true - type: integer - - description: User ID - in: query - name: userId - required: true - type: integer - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - summary: Get one Work History - tags: - - Work History - put: - description: API for update Work History - parameters: - - description: Insert the X-Csrf-Token - in: header - name: X-Csrf-Token - required: true - type: string - - description: Work History ID - in: path - name: id - required: true - type: integer - - description: User ID - in: query - name: userId - required: true - type: integer - - description: Required payload - in: body - name: payload - required: true - schema: - $ref: '#/definitions/request.WorkHistoryUpdateRequest' - responses: - "200": - description: OK - schema: - $ref: '#/definitions/response.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/response.BadRequestError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/response.InternalServerError' - summary: Update Work History - tags: - - Work History swagger: "2.0" diff --git a/main.go b/main.go index 51855cd..908a478 100644 --- a/main.go +++ b/main.go @@ -4,38 +4,22 @@ import ( "jaecoo-be/app/database" "jaecoo-be/app/middleware" "jaecoo-be/app/module/activity_logs" - "jaecoo-be/app/module/advertisement" - "jaecoo-be/app/module/ai_chat" "jaecoo-be/app/module/article_approvals" "jaecoo-be/app/module/article_categories" "jaecoo-be/app/module/article_category_details" "jaecoo-be/app/module/article_comments" "jaecoo-be/app/module/article_files" "jaecoo-be/app/module/articles" - "jaecoo-be/app/module/campaign_destinations" - "jaecoo-be/app/module/campaign_files" - "jaecoo-be/app/module/campaign_types" - "jaecoo-be/app/module/campaigns" - "jaecoo-be/app/module/chat" "jaecoo-be/app/module/cities" "jaecoo-be/app/module/custom_static_pages" "jaecoo-be/app/module/districts" - "jaecoo-be/app/module/ebooks" - "jaecoo-be/app/module/education_history" "jaecoo-be/app/module/feedbacks" - "jaecoo-be/app/module/magazine_files" - "jaecoo-be/app/module/magazines" - "jaecoo-be/app/module/master_menus" - "jaecoo-be/app/module/master_modules" "jaecoo-be/app/module/provinces" - "jaecoo-be/app/module/research_journals" - "jaecoo-be/app/module/subscription" "jaecoo-be/app/module/user_levels" "jaecoo-be/app/module/user_role_accesses" "jaecoo-be/app/module/user_role_level_details" "jaecoo-be/app/module/user_roles" "jaecoo-be/app/module/users" - "jaecoo-be/app/module/work_history" "jaecoo-be/app/router" "jaecoo-be/config/config" "jaecoo-be/config/logger" @@ -71,40 +55,22 @@ func main() { // provide modules activity_logs.NewActivityLogsModule, - advertisement.NewAdvertisementModule, - ai_chat.NewAIChatModule, article_categories.NewArticleCategoriesModule, article_category_details.NewArticleCategoryDetailsModule, article_files.NewArticleFilesModule, article_approvals.NewArticleApprovalsModule, articles.NewArticlesModule, article_comments.NewArticleCommentsModule, - chat.NewChatModule, cities.NewCitiesModule, custom_static_pages.NewCustomStaticPagesModule, districts.NewDistrictsModule, - ebooks.NewEbooksModule, feedbacks.NewFeedbacksModule, - magazines.NewMagazinesModule, - magazine_files.NewMagazineFilesModule, - master_menus.NewMasterMenusModule, - master_modules.NewMasterModulesModule, provinces.NewProvincesModule, - subscription.NewSubscriptionModule, user_levels.NewUserLevelsModule, user_roles.NewUserRolesModule, user_role_accesses.NewUserRoleAccessesModule, users.NewUsersModule, user_role_level_details.NewUserRoleLevelDetailsModule, - education_history.NewEducationHistoryModule, - work_history.NewWorkHistoryModule, - research_journals.NewResearchJournalsModule, - - // Campaign modules - campaign_types.NewCampaignTypesModule, - campaign_destinations.NewCampaignDestinationsModule, - campaigns.NewCampaignsModule, - campaign_files.NewCampaignFilesModule, // start aplication fx.Invoke(webserver.Start),