This commit is contained in:
@@ -54,9 +54,9 @@ func (h *AuthController) Signin(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.Signin(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
c.Cookie(&fiber.Cookie{
|
||||
@@ -108,9 +108,9 @@ func (h *AuthController) Signup(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.Signup(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -172,9 +172,9 @@ func (h *AuthController) RefreshToken(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.RefreshToken(ctx, c.Locals("uid").(string), tokenJwt)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -227,9 +227,9 @@ func (h *AuthController) VerifyToken(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.VerifyToken(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -264,9 +264,9 @@ func (h *AuthController) CreateToken(c fiber.Ctx) error {
|
||||
|
||||
err := h.service.CreateToken(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -301,9 +301,9 @@ func (h *AuthController) ForgotPassword(c fiber.Ctx) error {
|
||||
|
||||
err := h.service.ForgotPassword(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -411,11 +411,11 @@ func (h *AuthController) GoogleCallback(c fiber.Ctx) error {
|
||||
Picture: payload.Claims["picture"].(string),
|
||||
}
|
||||
|
||||
res, err := h.service.SigninWithGoogle(ctx, &googleUser)
|
||||
if err != nil {
|
||||
return c.Status(500).JSON(response.CommonResponse{
|
||||
res, err2 := h.service.SigninWithGoogle(ctx, &googleUser)
|
||||
if err2 != nil {
|
||||
return c.Status(err2.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err2.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -468,9 +468,9 @@ func (h *AuthController) Logout(c fiber.Ctx) error {
|
||||
|
||||
err := h.service.Logout(ctx, userId)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,9 @@ func (h *CommitController) CreateCommit(c fiber.Ctx) error {
|
||||
uid := c.Locals("uid").(string)
|
||||
res, err := h.service.CreateCommit(ctx, uid, projectID, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -94,9 +94,9 @@ func (h *CommitController) RestoreCommit(c fiber.Ctx) error {
|
||||
uid := c.Locals("uid").(string)
|
||||
err := h.service.RestoreCommit(ctx, uid, projectID, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -125,9 +125,9 @@ func (h *CommitController) GetProjectCommits(c fiber.Ctx) error {
|
||||
projectID := c.Params("id")
|
||||
res, err := h.service.GetProjectCommits(ctx, projectID)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ func (h *EntityController) GetEntityById(c fiber.Ctx) error {
|
||||
id := c.Params("id")
|
||||
res, err := h.service.GetEntityByID(ctx, id)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -70,9 +70,9 @@ func (h *EntityController) SearchEntities(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.SearchEntities(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ func (h *GeometryController) GetGeometryById(c fiber.Ctx) error {
|
||||
id := c.Params("id")
|
||||
res, err := h.service.GetGeometryByID(ctx, id)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -70,9 +70,9 @@ func (h *GeometryController) SearchGeometries(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.SearchGeometries(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ func (m *MediaController) GetMediaByID(c fiber.Ctx) error {
|
||||
mediaId := c.Params("id")
|
||||
res, err := m.service.GetMediaByID(ctx, mediaId)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -66,15 +66,15 @@ func (m *MediaController) SearchMedia(c fiber.Ctx) error {
|
||||
dto := &request.SearchMediaDto{}
|
||||
if err := validator.ValidateQueryDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Status: false,
|
||||
Errors: err,
|
||||
})
|
||||
}
|
||||
res, err := m.service.SearchMedia(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(res)
|
||||
@@ -113,9 +113,9 @@ func (m *MediaController) DeleteMedia(c fiber.Ctx) error {
|
||||
mediaId := c.Params("id")
|
||||
err := m.service.DeleteMedia(ctx, claims, mediaId)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -157,16 +157,16 @@ func (m *MediaController) BulkDeleteMedia(c fiber.Ctx) error {
|
||||
dto := &request.MediaBulkDeleteDto{}
|
||||
if err := validator.ValidateBodyDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Status: false,
|
||||
Errors: err,
|
||||
})
|
||||
}
|
||||
|
||||
err := m.service.BulkDeleteMedia(ctx, claims, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -198,11 +198,11 @@ func (m *MediaController) UploadServerSide(c fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
url, err := m.service.UploadServerSide(ctx, c.Locals("uid").(string), fileHeader)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
url, err2 := m.service.UploadServerSide(ctx, c.Locals("uid").(string), fileHeader)
|
||||
if err2 != nil {
|
||||
return c.Status(err2.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err2.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -232,15 +232,15 @@ func (m *MediaController) GeneratePresignedURL(c fiber.Ctx) error {
|
||||
dto := &request.PreSignedDto{}
|
||||
if err := validator.ValidateQueryDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Status: false,
|
||||
Errors: err,
|
||||
})
|
||||
}
|
||||
res, err := m.service.GeneratePresignedURL(ctx, c.Locals("uid").(string), dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(res)
|
||||
@@ -265,15 +265,15 @@ func (m *MediaController) PreSignedCompleted(c fiber.Ctx) error {
|
||||
dto := &request.PreSignedCompleteDto{}
|
||||
if err := validator.ValidateBodyDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Status: false,
|
||||
Errors: err,
|
||||
})
|
||||
}
|
||||
res, err := m.service.PreSignedCompleted(ctx, c.Locals("uid").(string), dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(res)
|
||||
|
||||
@@ -42,9 +42,9 @@ func (h *ProjectController) GetProjectByID(c fiber.Ctx) error {
|
||||
projectID := c.Params("id")
|
||||
res, err := h.service.GetProjectByID(ctx, projectID)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ func (h *ProjectController) SearchProject(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.SearchProject(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -116,9 +116,9 @@ func (h *ProjectController) CreateProject(c fiber.Ctx) error {
|
||||
uid := c.Locals("uid").(string)
|
||||
res, err := h.service.CreateProject(ctx, uid, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -157,9 +157,9 @@ func (h *ProjectController) UpdateProject(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.UpdateProject(ctx, projectID, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -189,9 +189,9 @@ func (h *ProjectController) DeleteProject(c fiber.Ctx) error {
|
||||
projectID := c.Params("id")
|
||||
err := h.service.DeleteProject(ctx, projectID)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -232,9 +232,9 @@ func (h *ProjectController) AddMember(c fiber.Ctx) error {
|
||||
uid := c.Locals("uid").(string)
|
||||
res, err := h.service.AddMember(ctx, uid, projectID, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -277,9 +277,9 @@ func (h *ProjectController) UpdateMemberRole(c fiber.Ctx) error {
|
||||
uid := c.Locals("uid").(string)
|
||||
res, err := h.service.UpdateMemberRole(ctx, uid, projectID, memberUserID, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -314,9 +314,9 @@ func (h *ProjectController) RemoveMember(c fiber.Ctx) error {
|
||||
|
||||
err := h.service.RemoveMember(ctx, uid, projectID, memberUserID)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -356,9 +356,9 @@ func (h *ProjectController) ChangeOwner(c fiber.Ctx) error {
|
||||
uid := c.Locals("uid").(string)
|
||||
res, err := h.service.ChangeOwner(ctx, uid, projectID, dto.NewOwnerID)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ func (h *RasterTileController) GetMetadata(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.GetMetadata(ctx)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -62,19 +62,19 @@ func (h *RasterTileController) GetTile(c fiber.Ctx) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
z, x, y, err := h.parseTileParams(c)
|
||||
if err != nil {
|
||||
z, x, y, pErr := h.parseTileParams(c)
|
||||
if pErr != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: pErr.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
data, headers, err := h.service.GetTile(ctx, z, x, y)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -88,17 +88,17 @@ func (h *RasterTileController) GetTile(c fiber.Ctx) error {
|
||||
func (h *RasterTileController) parseTileParams(c fiber.Ctx) (int, int, int, error) {
|
||||
z, err := strconv.Atoi(c.Params("z"))
|
||||
if err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("invalid z")
|
||||
return 0, 0, 0, fmt.Errorf("invalid z coordinate")
|
||||
}
|
||||
|
||||
x, err := strconv.Atoi(c.Params("x"))
|
||||
if err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("invalid x")
|
||||
return 0, 0, 0, fmt.Errorf("invalid x coordinate")
|
||||
}
|
||||
|
||||
y, err := strconv.Atoi(c.Params("y"))
|
||||
if err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("invalid y")
|
||||
return 0, 0, 0, fmt.Errorf("invalid y coordinate")
|
||||
}
|
||||
|
||||
if z < 0 || x < 0 || y < 0 {
|
||||
|
||||
@@ -34,9 +34,9 @@ func (h *RoleController) GetRoleById(c fiber.Ctx) error {
|
||||
RoleId := c.Params("id")
|
||||
res, err := h.service.GetRoleByID(ctx, RoleId)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -61,9 +61,9 @@ func (h *RoleController) GetAllRole(c fiber.Ctx) error {
|
||||
defer cancel()
|
||||
res, err := h.service.GetAllRole(ctx)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
|
||||
@@ -53,9 +53,9 @@ func (s *submissionController) CreateSubmission(c fiber.Ctx) error {
|
||||
|
||||
res, err := s.submissionService.CreateSubmission(ctx, c.Locals("uid").(string), dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ func (s *submissionController) UpdateSubmissionStatus(c fiber.Ctx) error {
|
||||
|
||||
res, err := s.submissionService.UpdateSubmissionStatus(ctx, uid, id, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -119,9 +119,9 @@ func (s *submissionController) GetSubmissionByID(c fiber.Ctx) error {
|
||||
id := c.Params("id")
|
||||
res, err := s.submissionService.GetSubmissionByID(ctx, id)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -155,9 +155,9 @@ func (s *submissionController) SearchSubmissions(c fiber.Ctx) error {
|
||||
|
||||
res, err := s.submissionService.SearchSubmissions(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -200,14 +200,14 @@ func (s *submissionController) DeleteSubmission(c fiber.Ctx) error {
|
||||
|
||||
err := s.submissionService.DeleteSubmission(ctx, c.Locals("uid").(string), id, claims)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
Status: true,
|
||||
Status: true,
|
||||
Message: "Submission deleted successfully",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ func (h *TileController) GetMetadata(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.GetMetadata(ctx)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -62,19 +62,19 @@ func (h *TileController) GetTile(c fiber.Ctx) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
z, x, y, err := h.parseTileParams(c)
|
||||
if err != nil {
|
||||
z, x, y, pErr := h.parseTileParams(c)
|
||||
if pErr != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: pErr.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
data, headers, err := h.service.GetTile(ctx, z, x, y)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -88,17 +88,17 @@ func (h *TileController) GetTile(c fiber.Ctx) error {
|
||||
func (h *TileController) parseTileParams(c fiber.Ctx) (int, int, int, error) {
|
||||
z, err := strconv.Atoi(c.Params("z"))
|
||||
if err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("invalid z")
|
||||
return 0, 0, 0, fmt.Errorf("invalid z coordinate")
|
||||
}
|
||||
|
||||
x, err := strconv.Atoi(c.Params("x"))
|
||||
if err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("invalid x")
|
||||
return 0, 0, 0, fmt.Errorf("invalid x coordinate")
|
||||
}
|
||||
|
||||
y, err := strconv.Atoi(c.Params("y"))
|
||||
if err != nil {
|
||||
return 0, 0, 0, fmt.Errorf("invalid y")
|
||||
return 0, 0, 0, fmt.Errorf("invalid y coordinate")
|
||||
}
|
||||
|
||||
if z < 0 || x < 0 || y < 0 {
|
||||
|
||||
@@ -32,6 +32,44 @@ func NewUserController(
|
||||
}
|
||||
}
|
||||
|
||||
// CreateUser godoc
|
||||
// @Summary Create a new user (Admin only)
|
||||
// @Description Create a new user account with specified roles
|
||||
// @Tags Users
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param request body request.CreateUserDto true "Create User request"
|
||||
// @Success 200 {object} response.CommonResponse
|
||||
// @Failure 400 {object} response.CommonResponse
|
||||
// @Failure 500 {object} response.CommonResponse
|
||||
// @Router /users [post]
|
||||
func (h *UserController) CreateUser(c fiber.Ctx) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
dto := &request.CreateUserDto{}
|
||||
if err := validator.ValidateBodyDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Errors: err,
|
||||
})
|
||||
}
|
||||
|
||||
res, err := h.service.CreateUser(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
Status: true,
|
||||
Data: res,
|
||||
})
|
||||
}
|
||||
|
||||
// GetUserCurrent godoc
|
||||
// @Summary Get current user profile
|
||||
// @Description Retrieve the profile information of the currently authenticated user
|
||||
@@ -48,9 +86,9 @@ func (h *UserController) GetUserCurrent(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.GetUserByID(ctx, c.Locals("uid").(string))
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -76,9 +114,9 @@ func (h *UserController) GetUserMedia(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.mediaService.GetMediaByUserID(ctx, c.Locals("uid").(string))
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -104,9 +142,9 @@ func (h *UserController) GetUserApplication(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.verificationService.GetVerificationByUserID(ctx, c.Locals("uid").(string))
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -132,9 +170,9 @@ func (h *UserController) GetMediaByUserID(c fiber.Ctx) error {
|
||||
userId := c.Params("id")
|
||||
res, err := h.mediaService.GetMediaByUserID(ctx, userId)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -159,9 +197,9 @@ func (h *UserController) GetVerificationByUserID(c fiber.Ctx) error {
|
||||
userId := c.Params("id")
|
||||
res, err := h.verificationService.GetVerificationByUserID(ctx, userId)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -196,9 +234,9 @@ func (h *UserController) UpdateProfile(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.UpdateProfile(ctx, c.Locals("uid").(string), dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -231,9 +269,9 @@ func (h *UserController) ChangePassword(c fiber.Ctx) error {
|
||||
}
|
||||
err := h.service.ChangePassword(ctx, c.Locals("uid").(string), dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -259,9 +297,9 @@ func (h *UserController) RestoreUser(c fiber.Ctx) error {
|
||||
userId := c.Params("id")
|
||||
res, err := h.service.RestoreUser(ctx, userId)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -287,9 +325,9 @@ func (h *UserController) DeleteUser(c fiber.Ctx) error {
|
||||
userId := c.Params("id")
|
||||
err := h.service.DeleteUser(ctx, userId)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -340,9 +378,9 @@ func (h *UserController) ChangeRoleUser(c fiber.Ctx) error {
|
||||
userId := c.Params("id")
|
||||
user, err := h.service.ChangeRoleUser(ctx, userId, claims, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -368,9 +406,9 @@ func (h *UserController) GetUserById(c fiber.Ctx) error {
|
||||
userId := c.Params("id")
|
||||
res, err := h.service.GetUserByID(ctx, userId)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -404,9 +442,9 @@ func (h *UserController) SearchUser(c fiber.Ctx) error {
|
||||
}
|
||||
res, err := h.service.SearchUser(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(res)
|
||||
@@ -438,9 +476,9 @@ func (h *UserController) GetUserProject(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.projectService.GetProjectByUserID(ctx, c.Locals("uid").(string), dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -477,9 +515,9 @@ func (h *UserController) GetProjectByUserID(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.projectService.GetProjectByUserID(ctx, userID, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ func (m *VerificationController) GetVerificationByID(c fiber.Ctx) error {
|
||||
verificationId := c.Params("id")
|
||||
res, err := m.service.GetVerificationByID(ctx, verificationId)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -69,9 +69,9 @@ func (m *VerificationController) SearchVerification(c fiber.Ctx) error {
|
||||
}
|
||||
res, err := m.service.SearchVerification(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(res)
|
||||
@@ -108,9 +108,9 @@ func (m *VerificationController) DeleteVerification(c fiber.Ctx) error {
|
||||
verificationId := c.Params("id")
|
||||
err := m.service.DeleteVerification(ctx, claims, verificationId)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -143,9 +143,9 @@ func (m *VerificationController) CreateVerification(c fiber.Ctx) error {
|
||||
}
|
||||
res, err := m.service.CreateVerification(ctx, c.Locals("uid").(string), dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -180,9 +180,9 @@ func (m *VerificationController) UpdateVerificationStatus(c fiber.Ctx) error {
|
||||
verificationId := c.Params("id")
|
||||
res, err := m.service.UpdateStatusVerification(ctx, c.Locals("uid").(string), verificationId, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
|
||||
@@ -35,9 +35,9 @@ func (h *WikiController) GetWikiById(c fiber.Ctx) error {
|
||||
id := c.Params("id")
|
||||
res, err := h.service.GetWikiByID(ctx, id)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
return c.Status(fiber.StatusOK).JSON(response.CommonResponse{
|
||||
@@ -70,9 +70,9 @@ func (h *WikiController) SearchWikis(c fiber.Ctx) error {
|
||||
|
||||
res, err := h.service.SearchWikis(ctx, dto)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(response.CommonResponse{
|
||||
return c.Status(err.Code).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Message: err.Error(),
|
||||
Message: err.Message,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user