Skip to content

Commit

Permalink
Merge branch 'fix/openapi' into fix/openapi-reminder
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitoyama committed Dec 1, 2024
2 parents 469e134 + 4ae8961 commit 27edf87
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 101 deletions.
2 changes: 1 addition & 1 deletion controller/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func respondentDetail2Response(ctx echo.Context, respondentDetail model.Responde
IsDraft: respondentDetail.SubmittedAt.Valid,
ModifiedAt: respondentDetail.ModifiedAt,
QuestionnaireId: respondentDetail.QuestionnaireID,
Respondent: respondentDetail.TraqID,
Respondent: &respondentDetail.TraqID,
ResponseId: respondentDetail.ResponseID,
SubmittedAt: respondentDetail.SubmittedAt.Time,
}
Expand Down
2 changes: 1 addition & 1 deletion controller/questionnaire.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ func (q Questionnaire) PostQuestionnaireResponse(c echo.Context, questionnaireID
res = openapi.Response{
QuestionnaireId: questionnaireID,
ResponseId: resopnseID,
Respondent: userID,
Respondent: &userID,
SubmittedAt: submittedAt,
ModifiedAt: modifiedAt,
IsDraft: params.IsDraft,
Expand Down
2 changes: 1 addition & 1 deletion controller/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (r Response) GetMyResponses(ctx echo.Context, params openapi.GetMyResponses
ModifiedAt: response.ModifiedAt,
QuestionnaireId: response.QuestionnaireId,
QuestionnaireInfo: &questionnaireInfo,
Respondent: userID,
Respondent: &userID,
ResponseId: response.ResponseId,
SubmittedAt: response.SubmittedAt,
}
Expand Down
8 changes: 4 additions & 4 deletions docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ components:
- $ref: "#/components/schemas/QuestionBase"
- $ref: "#/components/schemas/QuestionSettingsByType"
- properties:
questionnaire_id:
type: integer
example: 1
question_id:
type: integer
example: 1
Expand All @@ -675,14 +678,12 @@ components:
format: date-time
example: 2020-01-01T00:00:00+09:00
required:
- questionnaire_id
- question_id
- created_at
QuestionBase:
type: object
properties:
questionnaire_id:
type: integer
example: 1
title:
type: string
description:
Expand All @@ -692,7 +693,6 @@ components:
description: |
回答必須かどうか
required:
- questionnaire_id
- title
- description
- is_required
Expand Down
22 changes: 0 additions & 22 deletions handler/questionnaire.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,25 +194,3 @@ func (h Handler) PostQuestionnaireResponse(ctx echo.Context, questionnaireID ope

return ctx.JSON(201, res)
}

// (GET /questionnaires/{questionnaireID}/result)
func (h Handler) GetQuestionnaireResult(ctx echo.Context, questionnaireID openapi.QuestionnaireIDInPath) error {
res := openapi.Result{}
userID, err := getUserID(ctx)
if err != nil {
ctx.Logger().Errorf("failed to get userID: %+v", err)
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("failed to get userID: %w", err))
}

q := controller.NewQuestionnaire()
res, err = q.GetQuestionnaireResult(ctx, questionnaireID, userID)
if err != nil {
if errors.Is(err, echo.ErrNotFound) {
return echo.NewHTTPError(http.StatusNotFound, fmt.Errorf("questionnaire result not found: %w", err))
}
ctx.Logger().Errorf("failed to get questionnaire result: %+v", err)
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("failed to get questionnaire result: %w", err))
}

return ctx.JSON(200, res)
}
106 changes: 53 additions & 53 deletions openapi/spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 5 additions & 19 deletions openapi/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 27edf87

Please sign in to comment.