✨ Able to list all the friend without status filter
This commit is contained in:
parent
e0d496cc47
commit
3e9c84a284
@ -4,13 +4,8 @@
|
|||||||
<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=":bug: Bug fixes of design">
|
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Bug fixes">
|
||||||
<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/server/auth_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/auth_api.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/server/oauth_api.go" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/server/startup.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/startup.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/views/users/directory/userinfo.gohtml" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/views/users/directory/userinfo.gohtml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/views/users/me.gohtml" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/views/users/me.gohtml" 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" />
|
||||||
@ -142,7 +137,8 @@
|
|||||||
<MESSAGE value=":sparkles: Others userinfo" />
|
<MESSAGE value=":sparkles: Others userinfo" />
|
||||||
<MESSAGE value=":lipstick: Fix ui design" />
|
<MESSAGE value=":lipstick: Fix ui design" />
|
||||||
<MESSAGE value=":bug: Bug fixes of design" />
|
<MESSAGE value=":bug: Bug fixes of design" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value=":bug: Bug fixes of design" />
|
<MESSAGE value=":sparkles: Bug fixes" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Bug fixes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
<settings-migrated>true</settings-migrated>
|
<settings-migrated>true</settings-migrated>
|
||||||
|
@ -9,13 +9,21 @@ import (
|
|||||||
|
|
||||||
func listFriendship(c *fiber.Ctx) error {
|
func listFriendship(c *fiber.Ctx) error {
|
||||||
user := c.Locals("principal").(models.Account)
|
user := c.Locals("principal").(models.Account)
|
||||||
status := c.QueryInt("status", int(models.FriendshipActive))
|
status := c.QueryInt("status", -1)
|
||||||
|
|
||||||
if friends, err := services.ListFriend(user, models.FriendshipStatus(status)); err != nil {
|
var err error
|
||||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
var friends []models.AccountFriendship
|
||||||
|
if status < 0 {
|
||||||
|
if friends, err = services.ListAllFriend(user); err != nil {
|
||||||
|
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return c.JSON(friends)
|
if friends, err = services.ListFriend(user, models.FriendshipStatus(status)); err != nil {
|
||||||
|
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return c.JSON(friends)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFriendship(c *fiber.Ctx) error {
|
func getFriendship(c *fiber.Ctx) error {
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg"
|
"git.solsynth.dev/hydrogen/passport/pkg"
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg/i18n"
|
"git.solsynth.dev/hydrogen/passport/pkg/i18n"
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg/server/ui"
|
"git.solsynth.dev/hydrogen/passport/pkg/server/ui"
|
||||||
@ -14,8 +17,6 @@ import (
|
|||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var A *fiber.App
|
var A *fiber.App
|
||||||
|
@ -3,11 +3,25 @@ package services
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg/database"
|
"git.solsynth.dev/hydrogen/passport/pkg/database"
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg/models"
|
"git.solsynth.dev/hydrogen/passport/pkg/models"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func ListAllFriend(anyside models.Account) ([]models.AccountFriendship, error) {
|
||||||
|
var relationships []models.AccountFriendship
|
||||||
|
if err := database.C.
|
||||||
|
Where("account_id = ? OR related_id = ?", anyside.ID, anyside.ID).
|
||||||
|
Preload("Account").
|
||||||
|
Preload("Related").
|
||||||
|
Find(&relationships).Error; err != nil {
|
||||||
|
return relationships, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return relationships, nil
|
||||||
|
}
|
||||||
|
|
||||||
func ListFriend(anyside models.Account, status models.FriendshipStatus) ([]models.AccountFriendship, error) {
|
func ListFriend(anyside models.Account, status models.FriendshipStatus) ([]models.AccountFriendship, error) {
|
||||||
var relationships []models.AccountFriendship
|
var relationships []models.AccountFriendship
|
||||||
if err := database.C.
|
if err := database.C.
|
||||||
|
Loading…
Reference in New Issue
Block a user