-
Notifications
You must be signed in to change notification settings - Fork 3
service以下にinterface
#1011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
service以下にinterface
#1011
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
17d4cf9
:sparkles: Add `service.HogeRepository` interfaces
H1rono e2725ab
:recycle: `go generate ./internal/service`
H1rono 7e9d05a
:fire: Delete interfaces under `model/`
H1rono 6d6841a
:truck: Use service interfaces
H1rono 559e46c
:truck: Rename model files
H1rono 0b25539
:adhesive_bandage: Exhaustiveness check
H1rono ef54008
:adhesive_bandage: Fix
H1rono 3725502
:sparkles: Add `services.Storage`
H1rono 7459130
:truck: `{storage -> service}.Storage`
H1rono 0a6925f
:adhesive_bandage: Load user edge
H1rono File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,18 +1,51 @@ | ||
| //go:generate go tool mockgen -source=$GOFILE -destination=mock_$GOPACKAGE/mock_$GOFILE -package=mock_$GOPACKAGE | ||
| package model | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/google/uuid" | ||
| "github.com/samber/lo" | ||
| "github.com/traPtitech/Jomon/internal/ent" | ||
| "github.com/traPtitech/Jomon/internal/ent/user" | ||
| "github.com/traPtitech/Jomon/internal/service" | ||
| ) | ||
|
|
||
| type AccountManager struct { | ||
| ID uuid.UUID `json:"id"` | ||
| func (repo *EntRepository) GetAccountManagers( | ||
| ctx context.Context, | ||
| ) ([]*service.AccountManager, error) { | ||
| users, err := repo.client.User. | ||
| Query(). | ||
| Where(user.AccountManager(true)). | ||
| All(ctx) | ||
| if err != nil { | ||
| return nil, defaultEntErrorConverter.convert(err) | ||
| } | ||
|
|
||
| accountManagers := lo.Map(users, func(u *ent.User, _ int) *service.AccountManager { | ||
| return &service.AccountManager{ | ||
| ID: u.ID, | ||
| } | ||
| }) | ||
|
|
||
| return accountManagers, nil | ||
| } | ||
|
|
||
| func (repo *EntRepository) AddAccountManagers(ctx context.Context, userIDs []uuid.UUID) error { | ||
| _, err := repo.client.User. | ||
| Update(). | ||
| Where(user.IDIn(userIDs...)). | ||
| SetAccountManager(true). | ||
| Save(ctx) | ||
|
|
||
| return defaultEntErrorConverter.convert(err) | ||
| } | ||
|
|
||
| type AccountManagerRepository interface { | ||
| GetAccountManagers(ctx context.Context) ([]*AccountManager, error) | ||
| AddAccountManagers(ctx context.Context, userIDs []uuid.UUID) error | ||
| DeleteAccountManagers(ctx context.Context, userIDs []uuid.UUID) error | ||
| func (repo *EntRepository) DeleteAccountManagers(ctx context.Context, userIDs []uuid.UUID) error { | ||
| _, err := repo.client.User. | ||
| Update(). | ||
| Where(user.IDIn(userIDs...)). | ||
| SetAccountManager(false). | ||
| Save(ctx) | ||
|
|
||
| return defaultEntErrorConverter.convert(err) | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.