-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from GenerateNU/feat/handle-file-dups
Feat/handle file dups
- Loading branch information
Showing
9 changed files
with
176 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* API_BASE_URL is a constant that is used to determine the base URL for the API. | ||
*/ | ||
export const API_BASE_URL = true | ||
export const API_BASE_URL = false | ||
? 'http://localhost:8080/api' | ||
: 'https://legacy.loca.lt/api'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package controllers | ||
|
||
import ( | ||
"net/http" | ||
"server/src/services" | ||
|
||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
type ProgressController struct { | ||
progressService services.ProgressServiceInterface | ||
} | ||
|
||
func NewProgressController(progressService services.ProgressServiceInterface) *ProgressController { | ||
return &ProgressController{progressService: progressService} | ||
} | ||
|
||
func (p *ProgressController) GetTaskProgress(c echo.Context) error { | ||
userID := c.Param("uid") | ||
taskID := c.Param("tid") | ||
taskProgress, err := p.progressService.GetTaskProgress(userID, taskID) | ||
|
||
if err != nil { | ||
return c.JSON(http.StatusNotFound, "failed to fetch task progress") | ||
} | ||
|
||
return c.JSON(http.StatusOK, taskProgress) | ||
} | ||
|
||
func (p *ProgressController) GetSubTaskProgress(c echo.Context) error { | ||
userID := c.Param("uid") | ||
subTaskID := c.Param("sid") | ||
subTaskProgress, err := p.progressService.GetSubTaskProgress(userID, subTaskID) | ||
|
||
if err != nil { | ||
return c.JSON(http.StatusNotFound, "failed to fetch subtask progress") | ||
} | ||
|
||
return c.JSON(http.StatusOK, subTaskProgress) | ||
} | ||
|
||
func (p *ProgressController) CompleteTaskProgress(c echo.Context) error { | ||
userID := c.Param("uid") | ||
taskID := c.Param("tid") | ||
taskProgress, err := p.progressService.CompleteTaskProgress(userID, taskID) | ||
|
||
if err != nil { | ||
return c.JSON(http.StatusNotFound, "failed to complete task progress") | ||
} | ||
|
||
return c.JSON(http.StatusOK, taskProgress) | ||
} | ||
|
||
func (p *ProgressController) CompleteSubTaskProgress(c echo.Context) error { | ||
userID := c.Param("uid") | ||
subTaskID := c.Param("sid") | ||
subTaskProgress, err := p.progressService.CompleteSubTaskProgress(userID, subTaskID) | ||
|
||
if err != nil { | ||
return c.JSON(http.StatusNotFound, "failed to complete subtask progress") | ||
} | ||
|
||
return c.JSON(http.StatusOK, subTaskProgress) | ||
} | ||
|
||
func (p *ProgressController) GetAllSubTaskProgressOfTask(c echo.Context) error { | ||
userID := c.Param("uid") | ||
taskID := c.Param("tid") | ||
subTaskProgress, err := p.progressService.GetAllSubTaskProgressOfTask(userID, taskID) | ||
|
||
if err != nil { | ||
return c.JSON(http.StatusNotFound, "failed to fetch all subtask progresses of task") | ||
} | ||
|
||
return c.JSON(http.StatusOK, subTaskProgress) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package routes | ||
|
||
import ( | ||
"server/src/controllers" | ||
"server/src/services" | ||
|
||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
func ProgressRoutes(g *echo.Group, progressService services.ProgressServiceInterface) { | ||
progressController := controllers.NewProgressController(progressService) | ||
|
||
g.GET("/task/:uid/:tid", progressController.GetTaskProgress) | ||
g.GET("/subtask/:uid/:sid", progressController.GetSubTaskProgress) | ||
g.GET("/:uid/:tid", progressController.GetAllSubTaskProgressOfTask) | ||
g.POST("/task/:uid/:tid", progressController.CompleteTaskProgress) | ||
g.POST("/subtask/:uid/:sid", progressController.CompleteSubTaskProgress) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters