This commit is contained in:
parent
c2233e0e6a
commit
3e04a6dd24
@ -246,7 +246,7 @@ components:
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
name:
|
||||
title:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
@ -3,6 +3,7 @@ package app
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"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) {
|
||||
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) {
|
||||
var task tasks.Task
|
||||
|
Loading…
Reference in New Issue
Block a user