From 0d02eca76eae2bd73c77e70e4f47639717be2f31 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 26 Jun 2024 11:11:23 +0800 Subject: [PATCH] :wastebasket: Remove the personal page --- .idea/workspace.xml | 71 +++++++++++++-------------- pkg/internal/database/migrator.go | 1 - pkg/internal/models/accounts.go | 1 - pkg/internal/models/profiles.go | 16 ------ pkg/internal/server/api/index.go | 3 -- pkg/internal/server/api/page_api.go | 76 ----------------------------- web/src/layouts/user-center.vue | 1 - web/src/router/index.ts | 6 --- web/src/views/personal-page.vue | 71 --------------------------- 9 files changed, 33 insertions(+), 213 deletions(-) delete mode 100644 pkg/internal/server/api/page_api.go delete mode 100755 web/src/views/personal-page.vue diff --git a/.idea/workspace.xml b/.idea/workspace.xml index fca4e41..db8f3bf 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,20 +4,15 @@ - @@ -180,7 +174,8 @@ - true diff --git a/pkg/internal/database/migrator.go b/pkg/internal/database/migrator.go index febeaf2..61592eb 100644 --- a/pkg/internal/database/migrator.go +++ b/pkg/internal/database/migrator.go @@ -9,7 +9,6 @@ var AutoMaintainRange = []any{ &models.Account{}, &models.AuthFactor{}, &models.AccountProfile{}, - &models.AccountPage{}, &models.AccountContact{}, &models.AccountFriendship{}, &models.Badge{}, diff --git a/pkg/internal/models/accounts.go b/pkg/internal/models/accounts.go index 49bff98..df188a8 100644 --- a/pkg/internal/models/accounts.go +++ b/pkg/internal/models/accounts.go @@ -21,7 +21,6 @@ type Account struct { PermNodes datatypes.JSONMap `json:"perm_nodes"` Profile AccountProfile `json:"profile"` - PersonalPage AccountPage `json:"personal_page"` Badges []Badge `json:"badges"` Contacts []AccountContact `json:"contacts"` RealmIdentities []RealmMember `json:"realm_identities"` diff --git a/pkg/internal/models/profiles.go b/pkg/internal/models/profiles.go index 1800953..1aa5452 100644 --- a/pkg/internal/models/profiles.go +++ b/pkg/internal/models/profiles.go @@ -1,7 +1,6 @@ package models import ( - "gorm.io/datatypes" "time" ) @@ -14,18 +13,3 @@ type AccountProfile struct { Birthday *time.Time `json:"birthday"` AccountID uint `json:"account_id"` } - -type AccountPage struct { - BaseModel - - Content string `json:"content"` - Script string `json:"script"` - Style string `json:"style"` - Links datatypes.JSONSlice[AccountPageLinks] `json:"links"` - AccountID uint `json:"account_id"` -} - -type AccountPageLinks struct { - Label string `json:"label"` - Url string `json:"url"` -} diff --git a/pkg/internal/server/api/index.go b/pkg/internal/server/api/index.go index 9dbbcc1..71a28f5 100644 --- a/pkg/internal/server/api/index.go +++ b/pkg/internal/server/api/index.go @@ -26,9 +26,7 @@ func MapAPIs(app *fiber.App) { me.Put("/banner", setBanner) me.Get("/", getUserinfo) - me.Get("/page", getOwnPersonalPage) me.Put("/", editUserinfo) - me.Put("/page", editPersonalPage) me.Get("/events", getEvents) me.Get("/tickets", getTickets) me.Delete("/tickets/:ticketId", killSession) @@ -49,7 +47,6 @@ func MapAPIs(app *fiber.App) { directory := api.Group("/users/:alias").Name("User Directory") { directory.Get("/", getOtherUserinfo) - directory.Get("/page", getPersonalPage) } api.Post("/users", doRegister) diff --git a/pkg/internal/server/api/page_api.go b/pkg/internal/server/api/page_api.go deleted file mode 100644 index 77c7c43..0000000 --- a/pkg/internal/server/api/page_api.go +++ /dev/null @@ -1,76 +0,0 @@ -package api - -import ( - "git.solsynth.dev/hydrogen/passport/pkg/internal/database" - "git.solsynth.dev/hydrogen/passport/pkg/internal/models" - "git.solsynth.dev/hydrogen/passport/pkg/internal/server/exts" - "github.com/gofiber/fiber/v2" -) - -func getPersonalPage(c *fiber.Ctx) error { - alias := c.Params("alias") - - var account models.Account - if err := database.C. - Where(&models.Account{Name: alias}). - First(&account).Error; err != nil { - return fiber.NewError(fiber.StatusBadRequest, err.Error()) - } - - var page models.AccountPage - if err := database.C. - Where(&models.AccountPage{AccountID: account.ID}). - First(&page).Error; err != nil { - return fiber.NewError(fiber.StatusBadRequest, err.Error()) - } - - return c.JSON(page) -} - -func getOwnPersonalPage(c *fiber.Ctx) error { - if err := exts.EnsureAuthenticated(c); err != nil { - return err - } - user := c.Locals("user").(models.Account) - - var page models.AccountPage - if err := database.C. - Where(&models.AccountPage{AccountID: user.ID}). - FirstOrCreate(&page, &models.AccountPage{AccountID: user.ID}).Error; err != nil { - return fiber.NewError(fiber.StatusBadRequest, err.Error()) - } - - return c.JSON(page) -} - -func editPersonalPage(c *fiber.Ctx) error { - if err := exts.EnsureAuthenticated(c); err != nil { - return err - } - user := c.Locals("user").(models.Account) - - var data struct { - Content string `json:"content"` - Links []models.AccountPageLinks `json:"links"` - } - - if err := exts.BindAndValidate(c, &data); err != nil { - return err - } - - var page models.AccountPage - if err := database.C. - Where(&models.AccountPage{AccountID: user.ID}). - FirstOrInit(&page).Error; err != nil { - return fiber.NewError(fiber.StatusInternalServerError, err.Error()) - } - - page.Content = data.Content - page.Links = data.Links - - if err := database.C.Save(&page).Error; err != nil { - return fiber.NewError(fiber.StatusInternalServerError, err.Error()) - } - - return c.SendStatus(fiber.StatusOK) -} diff --git a/web/src/layouts/user-center.vue b/web/src/layouts/user-center.vue index ddb0690..ca74d7e 100755 --- a/web/src/layouts/user-center.vue +++ b/web/src/layouts/user-center.vue @@ -6,7 +6,6 @@ - diff --git a/web/src/router/index.ts b/web/src/router/index.ts index c31653d..f652ab3 100755 --- a/web/src/router/index.ts +++ b/web/src/router/index.ts @@ -30,12 +30,6 @@ const router = createRouter({ component: () => import("@/views/personalize.vue"), meta: { title: "Your personality" }, }, - { - path: "/me/personal-page", - name: "personal-page", - component: () => import("@/views/personal-page.vue"), - meta: { title: "Your personal page" }, - }, { path: "/me/security", name: "security", diff --git a/web/src/views/personal-page.vue b/web/src/views/personal-page.vue deleted file mode 100755 index 782b1df..0000000 --- a/web/src/views/personal-page.vue +++ /dev/null @@ -1,71 +0,0 @@ - - -