save
Some checks failed
Deploy to Server (Docker) / deploy (push) Failing after 48s

This commit is contained in:
Ivan Titov 2025-03-22 12:48:21 +03:00
parent c2233e0e6a
commit 3e04a6dd24
2 changed files with 26 additions and 3 deletions

View File

@ -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

View File

@ -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