Skip to content

Commit

Permalink
fix: test v0.2.0 features
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Jan 11, 2024
1 parent b51b660 commit 0170e80
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/sephirah/internal/biz/bizangela/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func NewPullSteamAppTopic(
}
app := converter.ToBizApp(resp.GetApp())
app.ID = r.ID
app.Internal = false
app.Source = r.Source
internalApp := new(modelgebura.App)
internalApp.ID = id
Expand Down
3 changes: 2 additions & 1 deletion app/sephirah/internal/biz/biztiphereth/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func (t *Tiphereth) LinkAccount(
return nil, pb.ErrorErrorReasonUnspecified("%s", err)
}
a.ID = id
if err = t.repo.LinkAccount(ctx, a, claims.UserID); err != nil {
a.ID, err = t.repo.LinkAccount(ctx, a, claims.UserID)
if err != nil {
return nil, pb.ErrorErrorReasonUnspecified("%s", err.Error())
}
if err = t.pullAccount.Publish(ctx, modeltiphereth.PullAccountInfo{
Expand Down
2 changes: 1 addition & 1 deletion app/sephirah/internal/biz/biztiphereth/tiphereth.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type TipherethRepo interface {
ListUsers(context.Context, model.Paging, []model.InternalID,
[]libauth.UserType, []modeltiphereth.UserStatus, []model.InternalID,
model.InternalID) ([]*modeltiphereth.User, int64, error)
LinkAccount(context.Context, modeltiphereth.Account, model.InternalID) error
LinkAccount(context.Context, modeltiphereth.Account, model.InternalID) (model.InternalID, error)
UnLinkAccount(context.Context, modeltiphereth.Account, model.InternalID) error
ListLinkAccounts(context.Context, model.InternalID) ([]*modeltiphereth.Account, error)
GetUser(context.Context, model.InternalID) (*modeltiphereth.User, error)
Expand Down
1 change: 1 addition & 0 deletions app/sephirah/internal/data/angela.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (a *angelaRepo) UpdateApp( //nolint:gocognit //TODO
if count == 0 {
err = tx.App.Create().
SetID(internal.ID).
SetInternal(true).
SetSource(internal.Source).
SetSourceAppID(internal.SourceAppID).
SetName(internal.Name).
Expand Down
28 changes: 22 additions & 6 deletions app/sephirah/internal/data/tiphereth.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,13 @@ func (t tipherethRepo) GetUser(ctx context.Context, id model.InternalID) (*model
return converter.ToBizUser(u), nil
}

func (t tipherethRepo) LinkAccount(ctx context.Context, a modeltiphereth.Account, userID model.InternalID) error {
return t.data.WithTx(ctx, func(tx *ent.Tx) error {
func (t tipherethRepo) LinkAccount(
ctx context.Context,
a modeltiphereth.Account,
userID model.InternalID,
) (model.InternalID, error) {
accountID := a.ID
err := t.data.WithTx(ctx, func(tx *ent.Tx) error {
u, err := tx.User.Get(ctx, userID)
if err != nil {
return err
Expand Down Expand Up @@ -156,10 +161,15 @@ func (t tipherethRepo) LinkAccount(ctx context.Context, a modeltiphereth.Account
if exist {
return errors.New("account already bound to an user")
}
accountID = acc.ID
return tx.Account.UpdateOneID(acc.ID).
SetBindUserID(userID).
Exec(ctx)
})
if err != nil {
return 0, err
}
return accountID, nil
}

func (t tipherethRepo) UnLinkAccount(ctx context.Context, a modeltiphereth.Account, u model.InternalID) error {
Expand Down Expand Up @@ -255,9 +265,15 @@ func (t tipherethRepo) UpdatePorterPrivilege(
}
func (t tipherethRepo) FetchPorterPrivilege(
ctx context.Context,
id model.InternalID,
id2 model.InternalID,
porterID model.InternalID,
userID model.InternalID,
) (*modeltiphereth.PorterInstancePrivilege, error) {
// TODO implement me
panic("implement me")
res, err := t.data.db.PorterPrivilege.Query().Where(
porterprivilege.PorterIDEQ(porterID),
porterprivilege.UserID(userID),
).Only(ctx)
if err != nil {
return nil, err
}
return res.Privilege, nil
}

0 comments on commit 0170e80

Please sign in to comment.