🐛 Fix list user relative return wrong data

This commit is contained in:
LittleSheep 2024-12-11 23:58:19 +08:00
parent 573ccc0478
commit afc2ec80e9
2 changed files with 8 additions and 7 deletions

8
.idea/workspace.xml generated
View File

@ -4,9 +4,9 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":zap: A separate API to only get notification count"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Bug fixes on notifications">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/notifications_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/notifications_api.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/grpc/user.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/user.go" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -159,7 +159,6 @@
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" /> <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<MESSAGE value=":sparkles: Support jwks.json according OIDC stranded" />
<MESSAGE value=":bug: Fix get user grpc method didn't extend group's permission" /> <MESSAGE value=":bug: Fix get user grpc method didn't extend group's permission" />
<MESSAGE value=":bug: Fix unable get user full perm node" /> <MESSAGE value=":bug: Fix unable get user full perm node" />
<MESSAGE value=":loud_sound: Add verbose permission logging" /> <MESSAGE value=":loud_sound: Add verbose permission logging" />
@ -184,7 +183,8 @@
<MESSAGE value=":zap: Add cache into querying user" /> <MESSAGE value=":zap: Add cache into querying user" />
<MESSAGE value=":bug: Fix missing api endpoint" /> <MESSAGE value=":bug: Fix missing api endpoint" />
<MESSAGE value=":zap: A separate API to only get notification count" /> <MESSAGE value=":zap: A separate API to only get notification count" />
<option name="LAST_COMMIT_MESSAGE" value=":zap: A separate API to only get notification count" /> <MESSAGE value=":bug: Bug fixes on notifications" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Bug fixes on notifications" />
<option name="GROUP_MULTIFILE_MERGE_BY_DIRECTORY" value="true" /> <option name="GROUP_MULTIFILE_MERGE_BY_DIRECTORY" value="true" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">

View File

@ -91,7 +91,7 @@ func (v *App) ListUser(ctx context.Context, request *proto.ListUserRequest) (*pr
} }
func (v *App) ListUserRelative(ctx context.Context, request *proto.ListUserRelativeRequest) (*proto.ListUserRelativeResponse, error) { func (v *App) ListUserRelative(ctx context.Context, request *proto.ListUserRelativeRequest) (*proto.ListUserRelativeResponse, error) {
tx := database.C.Preload("Account").Where("status = ?", request.GetStatus()) tx := database.C.Preload("Account").Preload("Related").Where("status = ?", request.GetStatus())
if request.GetIsRelated() { if request.GetIsRelated() {
tx = tx.Where("related_id = ?", request.GetUserId()) tx = tx.Where("related_id = ?", request.GetUserId())
@ -106,9 +106,10 @@ func (v *App) ListUserRelative(ctx context.Context, request *proto.ListUserRelat
return &proto.ListUserRelativeResponse{ return &proto.ListUserRelativeResponse{
Data: lo.Map(data, func(item models.AccountRelationship, index int) *proto.UserInfo { Data: lo.Map(data, func(item models.AccountRelationship, index int) *proto.UserInfo {
account := lo.Ternary(request.GetIsRelated(), item.Account, item.Related)
val := &proto.UserInfo{ val := &proto.UserInfo{
Id: uint64(item.AccountID), Id: uint64(account.ID),
Name: item.Account.Name, Name: account.Name,
} }
return val return val