diff --git a/controller/adapter.go b/controller/adapter.go index 051a5a71..b385a31a 100644 --- a/controller/adapter.go +++ b/controller/adapter.go @@ -3,6 +3,7 @@ package controller import ( "strconv" + "github.com/google/uuid" "github.com/labstack/echo/v4" "github.com/traPtitech/anke-to/model" "github.com/traPtitech/anke-to/openapi" @@ -64,10 +65,10 @@ func convertResSharedTo(resSharedTo string) openapi.ResShareType { } -func createUsersAndGroups(users []string, groups []string) openapi.UsersAndGroups { +func createUsersAndGroups(users []string, groups uuid.UUIDs) openapi.UsersAndGroups { res := openapi.UsersAndGroups{ Users: users, - Groups: groups, + Groups: groups.Strings(), } return res } @@ -147,14 +148,14 @@ func convertRespondents(respondents []model.Respondents) []string { return res } -func questionnaire2QuestionnaireDetail(questionnaires model.Questionnaires, adminUsers []string, adminGroups []string, targetUsers []string, targetGroups []string, respondents []string) openapi.QuestionnaireDetail { +func questionnaire2QuestionnaireDetail(questionnaires model.Questionnaires, adminUsers []string, adminGroups []uuid.UUID, targetUsers []string, targetGroups []uuid.UUID, respondents []string) openapi.QuestionnaireDetail { res := openapi.QuestionnaireDetail{ Admins: createUsersAndGroups(adminUsers, adminGroups), CreatedAt: questionnaires.CreatedAt, Description: questionnaires.Description, // IsAllowingMultipleResponses: questionnaires.IsAllowingMultipleResponses, - IsAnonymous: questionnaires.IsAnonymous, - IsPublished: questionnaires.IsPublished, + IsAnonymous: questionnaires.IsAnonymous, + IsPublished: questionnaires.IsPublished, ModifiedAt: questionnaires.ModifiedAt, QuestionnaireId: questionnaires.ID, Questions: convertQuestions(questionnaires.Questions), diff --git a/model/questionnaires.go b/model/questionnaires.go index e6ac50c8..0ed2780b 100644 --- a/model/questionnaires.go +++ b/model/questionnaires.go @@ -5,6 +5,7 @@ package model import ( "context" + "github.com/google/uuid" "gopkg.in/guregu/null.v4" ) @@ -15,7 +16,7 @@ type IQuestionnaire interface { DeleteQuestionnaire(ctx context.Context, questionnaireID int) error GetQuestionnaires(ctx context.Context, userID string, sort string, search string, pageNum int, onlyTargetingMe bool, onlyAdministratedByMe bool) ([]QuestionnaireInfo, int, error) GetAdminQuestionnaires(ctx context.Context, userID string) ([]Questionnaires, error) - GetQuestionnaireInfo(ctx context.Context, questionnaireID int) (*Questionnaires, []string, []string, []string, []string, []string, error) + GetQuestionnaireInfo(ctx context.Context, questionnaireID int) (*Questionnaires, []string, []uuid.UUID, []string, []uuid.UUID, []string, error) GetTargettedQuestionnaires(ctx context.Context, userID string, answered string, sort string) ([]TargettedQuestionnaire, error) GetQuestionnaireLimit(ctx context.Context, questionnaireID int) (null.Time, error) GetQuestionnaireLimitByResponseID(ctx context.Context, responseID int) (null.Time, error)