This commit is contained in:
parent
c2233e0e6a
commit
3e04a6dd24
@ -246,7 +246,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
type: integer
|
type: integer
|
||||||
name:
|
title:
|
||||||
type: string
|
type: string
|
||||||
description:
|
description:
|
||||||
type: string
|
type: string
|
@ -3,6 +3,7 @@ package app
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"task_manager/internal/domain/project"
|
"task_manager/internal/domain/project"
|
||||||
@ -147,9 +148,31 @@ func (rm *TaskManager) handleAssignUserToProject(w http.ResponseWriter, r *http.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rm *TaskManager) handleCreateProject(w http.ResponseWriter, r *http.Request) {
|
func (rm *TaskManager) handleCreateProject(w http.ResponseWriter, r *http.Request) {
|
||||||
respondWithJSON(w, http.StatusNotImplemented, map[string]string{
|
|
||||||
"message": "Create project not implemented yet",
|
var newProject project.Project
|
||||||
|
|
||||||
|
body, err := io.ReadAll(r.Body)
|
||||||
|
if err != nil {
|
||||||
|
respondWithError(w, http.StatusBadRequest, "Faild read body", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(body, &newProject)
|
||||||
|
if err != nil {
|
||||||
|
respondWithError(w, http.StatusBadRequest, "Faild unmurshal body", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = rm.repo.AddProject(&newProject)
|
||||||
|
if err != nil {
|
||||||
|
respondWithError(w, http.StatusBadRequest, "Faild add project", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
respondWithJSON(w, http.StatusOK, map[string]string{
|
||||||
|
"message": "Project assigned to project successfully",
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
func (rm *TaskManager) handleCreateTask(w http.ResponseWriter, r *http.Request) {
|
func (rm *TaskManager) handleCreateTask(w http.ResponseWriter, r *http.Request) {
|
||||||
var task tasks.Task
|
var task tasks.Task
|
||||||
|
Loading…
Reference in New Issue
Block a user