From ee9e092129ec26ba9f4505e219ef627a5d6eb8fd Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 4 Jul 2023 21:22:47 +0800 Subject: [PATCH] chore: code clean --- api/v1/url_util.go | 1 + api/v1/user.go | 5 ----- api/v1/user_setting.go | 9 +++------ 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/api/v1/url_util.go b/api/v1/url_util.go index 8e65e6d..6e6d64c 100644 --- a/api/v1/url_util.go +++ b/api/v1/url_util.go @@ -9,6 +9,7 @@ import ( ) func (*APIV1Service) registerURLUtilRoutes(g *echo.Group) { + // GET /url/favicon?url=... g.GET("/url/favicon", func(c echo.Context) error { url := c.QueryParam("url") icons, err := favicon.Find(url) diff --git a/api/v1/user.go b/api/v1/user.go index d10e683..4530aab 100644 --- a/api/v1/user.go +++ b/api/v1/user.go @@ -80,10 +80,6 @@ type PatchUserRequest struct { Password *string `json:"password"` } -type UserDelete struct { - ID int -} - func (s *APIV1Service) registerUserRoutes(g *echo.Group) { g.GET("/user", func(c echo.Context) error { ctx := c.Request().Context() @@ -160,7 +156,6 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) { if !validateEmail(*userPatch.Email) { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("invalid email format: %s", *userPatch.Email)) } - updateUser.Email = userPatch.Email } if userPatch.Nickname != nil { diff --git a/api/v1/user_setting.go b/api/v1/user_setting.go index b0c8d91..6dfa1fc 100644 --- a/api/v1/user_setting.go +++ b/api/v1/user_setting.go @@ -13,11 +13,8 @@ const ( ) // String returns the string format of UserSettingKey type. -func (key UserSettingKey) String() string { - if key == UserSettingLocaleKey { - return "locale" - } - return "" +func (k UserSettingKey) String() string { + return string(k) } var ( @@ -27,7 +24,7 @@ var ( type UserSetting struct { UserID int Key UserSettingKey `json:"key"` - // Value is a JSON string with basic value + // Value is a JSON string with basic value. Value string `json:"value"` }