diff --git a/docs/docs.go b/docs/docs.go index c5b288afb7d4ebf65f01ea69ee105082f3eacb9d..b498e6d63e5a425ce81d82d31b1bb7c0acf04c4e 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -2247,7 +2247,7 @@ const docTemplate = `{ "required": true }, { - "description": "Add Course payload", + "description": "Add Quiz payload", "name": "data", "in": "body", "required": true, @@ -2990,11 +2990,15 @@ const docTemplate = `{ "material.CreateMaterialRequest": { "type": "object", "required": [ - "name" + "name", + "week" ], "properties": { "name": { "type": "string" + }, + "week": { + "type": "integer" } } }, diff --git a/docs/swagger.json b/docs/swagger.json index f3f2ef29c3d9a1582156765304d1ce443c097047..35bc431aa7c6d69fd976b5ae111e4f89433befb6 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -2239,7 +2239,7 @@ "required": true }, { - "description": "Add Course payload", + "description": "Add Quiz payload", "name": "data", "in": "body", "required": true, @@ -2982,11 +2982,15 @@ "material.CreateMaterialRequest": { "type": "object", "required": [ - "name" + "name", + "week" ], "properties": { "name": { "type": "string" + }, + "week": { + "type": "integer" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 969534e24ffadab4aa54d3e304a57670f577cc4b..57767453f07d3bc013f4b6df5746e0e9e6afbb92 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -285,8 +285,11 @@ definitions: properties: name: type: string + week: + type: integer required: - name + - week type: object material.CreateMaterialResponse: properties: @@ -2013,7 +2016,7 @@ paths: name: id required: true type: string - - description: Add Course payload + - description: Add Quiz payload in: body name: data required: true diff --git a/handler/material/create_material.go b/handler/material/create_material.go index 55565566908a318265a647ba142e3047d875a003..d0c0e83768c76dbb309ade648ad685ab9c09605b 100644 --- a/handler/material/create_material.go +++ b/handler/material/create_material.go @@ -82,6 +82,7 @@ func (m MaterialHandlerImpl) CreateMaterial(w http.ResponseWriter, r *http.Reque courseId, user.Email, payload.Name, + payload.Week, ) if err != nil { diff --git a/model/web/material/material.go b/model/web/material/material.go index 98f8c6cdae84025cf0079c2df683a3be1767420b..84da097087fd4201689587c35d8f0e962865eca5 100644 --- a/model/web/material/material.go +++ b/model/web/material/material.go @@ -4,6 +4,7 @@ import "github.com/google/uuid" type CreateMaterialRequest struct { Name string `json:"name" validate:"required"` + Week int `json:"week" validate:"required"` } type CreateMaterialResponse struct { diff --git a/repository/material/material.go b/repository/material/material.go index 87cbd435c379d505d4be048f8d1d5e878ffba019..3618779997d7381591c1c6f679b40885a8020dc6 100644 --- a/repository/material/material.go +++ b/repository/material/material.go @@ -35,16 +35,17 @@ func (m MaterialRepositoryImpl) IsUserContributor(id uuid.UUID, email string) (b return true, nil } -func (m MaterialRepositoryImpl) New(courseId string, creatorEmail string, name string) (uuid.UUID, error) { - return m.NewWithTransaction(m.builder.Build(), courseId, creatorEmail, name) +func (m MaterialRepositoryImpl) New(courseId string, creatorEmail string, name string, week int) (uuid.UUID, error) { + return m.NewWithTransaction(m.builder.Build(), courseId, creatorEmail, name, week) } -func (m MaterialRepositoryImpl) NewWithTransaction(tx transaction.Transaction, courseId string, creatorEmail string, name string) (uuid.UUID, error) { +func (m MaterialRepositoryImpl) NewWithTransaction(tx transaction.Transaction, courseId string, creatorEmail string, name string, week int) (uuid.UUID, error) { materialData := &material.Material{ ID: uuid.New(), CourseId: courseId, CreatorEmail: creatorEmail, Name: name, + Week: week, } err := tx.GetTransaction().Create(materialData).Error diff --git a/repository/material/type.go b/repository/material/type.go index 4014763d006c08c2eabeb294a8f043ae023d0b17..6e8ddc93441a80c7b16a52cf756a1e75a0cc5b52 100644 --- a/repository/material/type.go +++ b/repository/material/type.go @@ -7,14 +7,14 @@ import ( ) type MaterialRepository interface { - New(courseId string, creatorEmail string, name string) (uuid.UUID, error) + New(courseId string, creatorEmail string, name string, week int) (uuid.UUID, error) Delete(id uuid.UUID) error Get(materialId uuid.UUID) (*material.Material, error) GetAll(courseId string) ([]material.Material, error) IsUserContributor(id uuid.UUID, email string) (bool, error) - NewWithTransaction(tx transaction.Transaction, courseId string, creatorEmail string, name string) (uuid.UUID, error) + NewWithTransaction(tx transaction.Transaction, courseId string, creatorEmail string, name string, week int) (uuid.UUID, error) DeleteWithTransaction(tx transaction.Transaction, id uuid.UUID) error GetAllWithTransaction(tx transaction.Transaction, courseId string) ([]material.Material, error) } diff --git a/service/material/impl.go b/service/material/impl.go index c50b67586123fcf70acf3c2c0a4ee7f42b53034c..02a5b425925d957d4d5023cf8e3f1050c83814e5 100644 --- a/service/material/impl.go +++ b/service/material/impl.go @@ -32,14 +32,14 @@ func (m MaterialServiceImpl) GetById(materialId uuid.UUID) (*materialDomain.Mate return material, err } -func (m MaterialServiceImpl) Create(courseId string, email string, name string) (uuid.UUID, error) { +func (m MaterialServiceImpl) Create(courseId string, email string, name string, week int) (uuid.UUID, error) { isSuccess := false tx := m.TransactionBuilder.Build() tx.Begin() defer tx.Auto(&isSuccess) - id, err := m.MaterialRepository.NewWithTransaction(tx, courseId, email, name) + id, err := m.MaterialRepository.NewWithTransaction(tx, courseId, email, name, week) if err != nil { return uuid.Nil, err diff --git a/service/material/type.go b/service/material/type.go index ca617ce6fdce82217b439b2f4b1f0a0b58d3545d..9cc1f19497423d3a25cbe4ce0cee8b085b3b5e9e 100644 --- a/service/material/type.go +++ b/service/material/type.go @@ -6,7 +6,7 @@ import ( ) type MaterialService interface { - Create(courseId string, email string, name string) (uuid.UUID, error) + Create(courseId string, email string, name string, week int) (uuid.UUID, error) Delete(materialId uuid.UUID, email string) error Get(courseId string) ([]material.Material, error) GetById(materialId uuid.UUID) (*material.Material, error)