maps-service/internal/controller/submissions.go

34 lines
1.0 KiB
Go
Raw Permalink Normal View History

2024-11-26 21:36:40 +00:00
package controller
import (
"context"
2024-11-26 21:38:45 +00:00
"git.itzana.me/strafesnet/maps-service/internal/datastore"
2024-11-26 22:10:30 +00:00
"git.itzana.me/strafesnet/maps-service/api"
2024-11-26 21:36:40 +00:00
)
2024-11-26 22:37:18 +00:00
type Submissions struct {
2024-11-26 21:36:40 +00:00
Store datastore.Datastore
}
2024-11-26 22:37:18 +00:00
func (m Submissions) Get(ctx context.Context, params *api.GetSubmissionParams) (*api.Submission, error) {
item, err := m.Store.Submissions().Get(ctx, params.SubmissionID)
2024-11-26 21:36:40 +00:00
if err != nil {
2024-11-26 22:37:18 +00:00
return nil, err
2024-11-26 21:36:40 +00:00
}
2024-11-26 22:37:18 +00:00
return &api.Submission{
2024-11-26 22:48:31 +00:00
ID: api.NewOptInt64(item.ID),
DisplayName: api.NewOptString(item.DisplayName),
Creator: api.NewOptString(item.Creator),
GameID: api.NewOptInt32(item.GameID),
Date: api.NewOptInt64(item.Date.Unix()),
Submitter: api.NewOptInt64(item.Submitter),
AssetID: api.NewOptInt64(item.AssetID),
AssetVersion: api.NewOptInt64(item.AssetVersion),
Completed: api.NewOptBool(item.Completed),
SubmissionType: api.NewOptInt32(item.SubmissionType),
TargetAssetID: api.NewOptInt64(item.TargetAssetID),
StatusID: api.NewOptInt32(item.StatusID),
2024-11-26 21:36:40 +00:00
}, nil
}