Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: update id type to int32 (#2076)
boojack7c5296cf35a4
diff --git a/api/v1/activity.go b/api/v1/activity.goindex a5d1bc5b3..ff90bbf06 100644--- a/api/v1/activity.go+++ b/api/v1/activity.go@@ -71,13 +71,13 @@ func (l ActivityLevel) String() string {}type ActivityUserCreatePayload struct {- UserID int `json:"userId"`+ UserID int32 `json:"userId"`Username string `json:"username"`Role Role `json:"role"`}type ActivityUserAuthSignInPayload struct {- UserID int `json:"userId"`+ UserID int32 `json:"userId"`IP string `json:"ip"`}@@ -107,10 +107,10 @@ type ActivityServerStartPayload struct {}type Activity struct {- ID int `json:"id"`+ ID int32 `json:"id"`// Standard fields- CreatorID int `json:"creatorId"`+ CreatorID int32 `json:"creatorId"`CreatedTs int64 `json:"createdTs"`// Domain specific fields@@ -122,7 +122,7 @@ type Activity struct {// ActivityCreate is the API message for creating an activity.type ActivityCreate struct {// Standard fields- CreatorID int+ CreatorID int32// Domain specific fieldsType ActivityType `json:"type"`diff --git a/api/v1/auth.go b/api/v1/auth.goindex cc2030a9d..da9c803e5 100644--- a/api/v1/auth.go+++ b/api/v1/auth.go@@ -21,7 +21,7 @@ type SignIn struct {}type SSOSignIn struct {- IdentityProviderID int `json:"identityProviderId"`+ IdentityProviderID int32 `json:"identityProviderId"`Code string `json:"code"`RedirectURI string `json:"redirectUri"`}diff --git a/api/v1/idp.go b/api/v1/idp.goindex 2580c2e6c..0b63f7496 100644--- a/api/v1/idp.go+++ b/api/v1/idp.go@@ -4,10 +4,10 @@ import ("encoding/json""fmt""net/http"- "strconv""github.com/labstack/echo/v4""github.com/usememos/memos/api/auth"+ "github.com/usememos/memos/common/util""github.com/usememos/memos/store")@@ -42,7 +42,7 @@ type FieldMapping struct {}type IdentityProvider struct {- ID int `json:"id"`+ ID int32 `json:"id"`Name string `json:"name"`Type IdentityProviderType `json:"type"`IdentifierFilter string `json:"identifierFilter"`@@ -57,7 +57,7 @@ type CreateIdentityProviderRequest struct {}type UpdateIdentityProviderRequest struct {- ID int `json:"-"`+ ID int32 `json:"-"`Type IdentityProviderType `json:"type"`Name *string `json:"name"`IdentifierFilter *string `json:"identifierFilter"`@@ -67,7 +67,7 @@ type UpdateIdentityProviderRequest struct {func (s *APIV1Service) registerIdentityProviderRoutes(g *echo.Group) {g.POST("/idp", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -101,7 +101,7 @@ func (s *APIV1Service) registerIdentityProviderRoutes(g *echo.Group) {g.PATCH("/idp/:idpId", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -116,7 +116,7 @@ func (s *APIV1Service) registerIdentityProviderRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusUnauthorized, "Unauthorized")}- identityProviderID, err := strconv.Atoi(c.Param("idpId"))+ identityProviderID, err := util.ConvertStringToInt32(c.Param("idpId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("idpId"))).SetInternal(err)}@@ -148,7 +148,7 @@ func (s *APIV1Service) registerIdentityProviderRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find identity provider list").SetInternal(err)}- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)isHostUser := falseif ok {user, err := s.Store.GetUser(ctx, &store.FindUser{@@ -176,7 +176,7 @@ func (s *APIV1Service) registerIdentityProviderRoutes(g *echo.Group) {g.GET("/idp/:idpId", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -191,7 +191,7 @@ func (s *APIV1Service) registerIdentityProviderRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusUnauthorized, "Unauthorized")}- identityProviderID, err := strconv.Atoi(c.Param("idpId"))+ identityProviderID, err := util.ConvertStringToInt32(c.Param("idpId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("idpId"))).SetInternal(err)}@@ -210,7 +210,7 @@ func (s *APIV1Service) registerIdentityProviderRoutes(g *echo.Group) {g.DELETE("/idp/:idpId", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -225,7 +225,7 @@ func (s *APIV1Service) registerIdentityProviderRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusUnauthorized, "Unauthorized")}- identityProviderID, err := strconv.Atoi(c.Param("idpId"))+ identityProviderID, err := util.ConvertStringToInt32(c.Param("idpId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("idpId"))).SetInternal(err)}diff --git a/api/v1/jwt.go b/api/v1/jwt.goindex a3e1696cd..af07f124b 100644--- a/api/v1/jwt.go+++ b/api/v1/jwt.go@@ -3,7 +3,6 @@ package v1import ("fmt""net/http"- "strconv""strings""time"@@ -21,7 +20,7 @@ type claimsMessage struct {}// GenerateAccessToken generates an access token for web.-func GenerateAccessToken(username string, userID int, secret string) (string, error) {+func GenerateAccessToken(username string, userID int32, secret string) (string, error) {expirationTime := time.Now().Add(auth.AccessTokenDuration)return generateToken(username, userID, auth.AccessTokenAudienceName, expirationTime, []byte(secret))}@@ -58,7 +57,7 @@ func setTokenCookie(c echo.Context, name, token string, expiration time.Time) {}// generateToken generates a jwt token.-func generateToken(username string, userID int, aud string, expirationTime time.Time, secret []byte) (string, error) {+func generateToken(username string, userID int32, aud string, expirationTime time.Time, secret []byte) (string, error) {// Create the JWT claims, which includes the username and expiry time.claims := &claimsMessage{Name: username,@@ -68,7 +67,7 @@ func generateToken(username string, userID int, aud string, expirationTime time.ExpiresAt: jwt.NewNumericDate(expirationTime),IssuedAt: jwt.NewNumericDate(time.Now()),Issuer: auth.Issuer,- Subject: strconv.Itoa(userID),+ Subject: fmt.Sprintf("%d", userID),},}@@ -174,7 +173,7 @@ func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) e}// We either have a valid access token or we will attempt to generate new access token and refresh token- userID, err := strconv.Atoi(claims.Subject)+ userID, err := util.ConvertStringToInt32(claims.Subject)if err != nil {return echo.NewHTTPError(http.StatusUnauthorized, "Malformed ID in the token.")}diff --git a/api/v1/memo.go b/api/v1/memo.goindex 1ce53cb23..ff01c8946 100644--- a/api/v1/memo.go+++ b/api/v1/memo.go@@ -11,6 +11,7 @@ import ("github.com/labstack/echo/v4""github.com/pkg/errors""github.com/usememos/memos/api/auth"+ "github.com/usememos/memos/common/util""github.com/usememos/memos/store")@@ -39,11 +40,11 @@ func (v Visibility) String() string {}type Memo struct {- ID int `json:"id"`+ ID int32 `json:"id"`// Standard fieldsRowStatus RowStatus `json:"rowStatus"`- CreatorID int `json:"creatorId"`+ CreatorID int32 `json:"creatorId"`CreatedTs int64 `json:"createdTs"`UpdatedTs int64 `json:"updatedTs"`@@ -62,7 +63,7 @@ type Memo struct {type CreateMemoRequest struct {// Standard fields- CreatorID int `json:"-"`+ CreatorID int32 `json:"-"`CreatedTs *int64 `json:"createdTs"`// Domain specific fields@@ -70,12 +71,12 @@ type CreateMemoRequest struct {Content string `json:"content"`// Related fields- ResourceIDList []int `json:"resourceIdList"`+ ResourceIDList []int32 `json:"resourceIdList"`RelationList []*UpsertMemoRelationRequest `json:"relationList"`}type PatchMemoRequest struct {- ID int `json:"-"`+ ID int32 `json:"-"`// Standard fieldsCreatedTs *int64 `json:"createdTs"`@@ -87,16 +88,16 @@ type PatchMemoRequest struct {Visibility *Visibility `json:"visibility"`// Related fields- ResourceIDList []int `json:"resourceIdList"`+ ResourceIDList []int32 `json:"resourceIdList"`RelationList []*UpsertMemoRelationRequest `json:"relationList"`}type FindMemoRequest struct {- ID *int+ ID *int32// Standard fieldsRowStatus *RowStatus- CreatorID *int+ CreatorID *int32// Domain specific fieldsPinned *bool@@ -114,7 +115,7 @@ const maxContentLength = 1 << 30func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {g.POST("/memo", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -225,12 +226,12 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {g.PATCH("/memo/:memoId", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}- memoID, err := strconv.Atoi(c.Param("memoId"))+ memoID, err := util.ConvertStringToInt32(c.Param("memoId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("memoId"))).SetInternal(err)}@@ -352,7 +353,7 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {g.GET("/memo", func(c echo.Context) error {ctx := c.Request().Context()findMemoMessage := &store.FindMemo{}- if userID, err := strconv.Atoi(c.QueryParam("creatorId")); err == nil {+ if userID, err := util.ConvertStringToInt32(c.QueryParam("creatorId")); err == nil {findMemoMessage.CreatorID = &userID}@@ -363,7 +364,7 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {}}- currentUserID, ok := c.Get(auth.UserIDContextKey).(int)+ currentUserID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {// Anonymous use should only fetch PUBLIC memos with specified userif findMemoMessage.CreatorID == nil {@@ -435,7 +436,7 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {g.GET("/memo/:memoId", func(c echo.Context) error {ctx := c.Request().Context()- memoID, err := strconv.Atoi(c.Param("memoId"))+ memoID, err := util.ConvertStringToInt32(c.Param("memoId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("memoId"))).SetInternal(err)}@@ -450,7 +451,7 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Memo not found: %d", memoID))}- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if memo.Visibility == store.Private {if !ok || memo.CreatorID != userID {return echo.NewHTTPError(http.StatusForbidden, "this memo is private only")@@ -473,7 +474,7 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {findMemoMessage := &store.FindMemo{RowStatus: &normalStatus,}- if creatorID, err := strconv.Atoi(c.QueryParam("creatorId")); err == nil {+ if creatorID, err := util.ConvertStringToInt32(c.QueryParam("creatorId")); err == nil {findMemoMessage.CreatorID = &creatorID}@@ -488,7 +489,7 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusBadRequest, "Missing user id to find memo")}- currentUserID, ok := c.Get(auth.UserIDContextKey).(int)+ currentUserID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {findMemoMessage.VisibilityList = []store.Visibility{store.Public}} else {@@ -590,11 +591,11 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {g.DELETE("/memo/:memoId", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}- memoID, err := strconv.Atoi(c.Param("memoId"))+ memoID, err := util.ConvertStringToInt32(c.Param("memoId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("memoId"))).SetInternal(err)}@@ -757,12 +758,12 @@ func getMemoRelationListDiff(oldList, newList []*store.MemoRelation) (addedList,return addedList, removedList}-func getIDListDiff(oldList, newList []int) (addedList, removedList []int) {- oldMap := map[int]bool{}+func getIDListDiff(oldList, newList []int32) (addedList, removedList []int32) {+ oldMap := map[int32]bool{}for _, id := range oldList {oldMap[id] = true}- newMap := map[int]bool{}+ newMap := map[int32]bool{}for _, id := range newList {newMap[id] = true}diff --git a/api/v1/memo_organizer.go b/api/v1/memo_organizer.goindex 1e02912ce..a55b7ffde 100644--- a/api/v1/memo_organizer.go+++ b/api/v1/memo_organizer.go@@ -4,17 +4,17 @@ import ("encoding/json""fmt""net/http"- "strconv""github.com/labstack/echo/v4""github.com/usememos/memos/api/auth"+ "github.com/usememos/memos/common/util""github.com/usememos/memos/store")type MemoOrganizer struct {- MemoID int `json:"memoId"`- UserID int `json:"userId"`- Pinned bool `json:"pinned"`+ MemoID int32 `json:"memoId"`+ UserID int32 `json:"userId"`+ Pinned bool `json:"pinned"`}type UpsertMemoOrganizerRequest struct {@@ -24,12 +24,12 @@ type UpsertMemoOrganizerRequest struct {func (s *APIV1Service) registerMemoOrganizerRoutes(g *echo.Group) {g.POST("/memo/:memoId/organizer", func(c echo.Context) error {ctx := c.Request().Context()- memoID, err := strconv.Atoi(c.Param("memoId"))+ memoID, err := util.ConvertStringToInt32(c.Param("memoId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("memoId"))).SetInternal(err)}- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}diff --git a/api/v1/memo_relation.go b/api/v1/memo_relation.goindex 9ab8079a5..63e94d569 100644--- a/api/v1/memo_relation.go+++ b/api/v1/memo_relation.go@@ -4,9 +4,9 @@ import ("encoding/json""fmt""net/http"- "strconv""github.com/labstack/echo/v4"+ "github.com/usememos/memos/common/util""github.com/usememos/memos/store")@@ -18,20 +18,20 @@ const ()type MemoRelation struct {- MemoID int `json:"memoId"`- RelatedMemoID int `json:"relatedMemoId"`+ MemoID int32 `json:"memoId"`+ RelatedMemoID int32 `json:"relatedMemoId"`Type MemoRelationType `json:"type"`}type UpsertMemoRelationRequest struct {- RelatedMemoID int `json:"relatedMemoId"`+ RelatedMemoID int32 `json:"relatedMemoId"`Type MemoRelationType `json:"type"`}func (s *APIV1Service) registerMemoRelationRoutes(g *echo.Group) {g.POST("/memo/:memoId/relation", func(c echo.Context) error {ctx := c.Request().Context()- memoID, err := strconv.Atoi(c.Param("memoId"))+ memoID, err := util.ConvertStringToInt32(c.Param("memoId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("memoId"))).SetInternal(err)}@@ -54,7 +54,7 @@ func (s *APIV1Service) registerMemoRelationRoutes(g *echo.Group) {g.GET("/memo/:memoId/relation", func(c echo.Context) error {ctx := c.Request().Context()- memoID, err := strconv.Atoi(c.Param("memoId"))+ memoID, err := util.ConvertStringToInt32(c.Param("memoId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("memoId"))).SetInternal(err)}@@ -70,11 +70,11 @@ func (s *APIV1Service) registerMemoRelationRoutes(g *echo.Group) {g.DELETE("/memo/:memoId/relation/:relatedMemoId/type/:relationType", func(c echo.Context) error {ctx := c.Request().Context()- memoID, err := strconv.Atoi(c.Param("memoId"))+ memoID, err := util.ConvertStringToInt32(c.Param("memoId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Memo ID is not a number: %s", c.Param("memoId"))).SetInternal(err)}- relatedMemoID, err := strconv.Atoi(c.Param("relatedMemoId"))+ relatedMemoID, err := util.ConvertStringToInt32(c.Param("relatedMemoId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Related memo ID is not a number: %s", c.Param("resourceId"))).SetInternal(err)}diff --git a/api/v1/memo_resource.go b/api/v1/memo_resource.goindex 197cacffb..26fa56922 100644--- a/api/v1/memo_resource.go+++ b/api/v1/memo_resource.go@@ -4,45 +4,45 @@ import ("encoding/json""fmt""net/http"- "strconv""time""github.com/labstack/echo/v4""github.com/usememos/memos/api/auth"+ "github.com/usememos/memos/common/util""github.com/usememos/memos/store")type MemoResource struct {- MemoID int `json:"memoId"`- ResourceID int `json:"resourceId"`+ MemoID int32 `json:"memoId"`+ ResourceID int32 `json:"resourceId"`CreatedTs int64 `json:"createdTs"`UpdatedTs int64 `json:"updatedTs"`}type UpsertMemoResourceRequest struct {- ResourceID int `json:"resourceId"`+ ResourceID int32 `json:"resourceId"`UpdatedTs *int64 `json:"updatedTs"`}type MemoResourceFind struct {- MemoID *int- ResourceID *int+ MemoID *int32+ ResourceID *int32}type MemoResourceDelete struct {- MemoID *int- ResourceID *int+ MemoID *int32+ ResourceID *int32}func (s *APIV1Service) registerMemoResourceRoutes(g *echo.Group) {g.POST("/memo/:memoId/resource", func(c echo.Context) error {ctx := c.Request().Context()- memoID, err := strconv.Atoi(c.Param("memoId"))+ memoID, err := util.ConvertStringToInt32(c.Param("memoId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("memoId"))).SetInternal(err)}- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -78,7 +78,7 @@ func (s *APIV1Service) registerMemoResourceRoutes(g *echo.Group) {g.GET("/memo/:memoId/resource", func(c echo.Context) error {ctx := c.Request().Context()- memoID, err := strconv.Atoi(c.Param("memoId"))+ memoID, err := util.ConvertStringToInt32(c.Param("memoId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("memoId"))).SetInternal(err)}@@ -98,15 +98,15 @@ func (s *APIV1Service) registerMemoResourceRoutes(g *echo.Group) {g.DELETE("/memo/:memoId/resource/:resourceId", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}- memoID, err := strconv.Atoi(c.Param("memoId"))+ memoID, err := util.ConvertStringToInt32(c.Param("memoId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Memo ID is not a number: %s", c.Param("memoId"))).SetInternal(err)}- resourceID, err := strconv.Atoi(c.Param("resourceId"))+ resourceID, err := util.ConvertStringToInt32(c.Param("resourceId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Resource ID is not a number: %s", c.Param("resourceId"))).SetInternal(err)}diff --git a/api/v1/resource.go b/api/v1/resource.goindex b65fb2869..9edb70311 100644--- a/api/v1/resource.go+++ b/api/v1/resource.go@@ -30,10 +30,10 @@ import ()type Resource struct {- ID int `json:"id"`+ ID int32 `json:"id"`// Standard fields- CreatorID int `json:"creatorId"`+ CreatorID int32 `json:"creatorId"`CreatedTs int64 `json:"createdTs"`UpdatedTs int64 `json:"updatedTs"`@@ -58,8 +58,8 @@ type CreateResourceRequest struct {}type FindResourceRequest struct {- ID *int `json:"id"`- CreatorID *int `json:"creatorId"`+ ID *int32 `json:"id"`+ CreatorID *int32 `json:"creatorId"`Filename *string `json:"filename"`}@@ -83,7 +83,7 @@ var fileKeyPattern = regexp.MustCompile(`\{[a-z]{1,9}\}`)func (s *APIV1Service) registerResourceRoutes(g *echo.Group) {g.POST("/resource", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -157,7 +157,7 @@ func (s *APIV1Service) registerResourceRoutes(g *echo.Group) {g.POST("/resource/blob", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -217,7 +217,7 @@ func (s *APIV1Service) registerResourceRoutes(g *echo.Group) {g.GET("/resource", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -244,12 +244,12 @@ func (s *APIV1Service) registerResourceRoutes(g *echo.Group) {g.PATCH("/resource/:resourceId", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}- resourceID, err := strconv.Atoi(c.Param("resourceId"))+ resourceID, err := util.ConvertStringToInt32(c.Param("resourceId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("resourceId"))).SetInternal(err)}@@ -290,12 +290,12 @@ func (s *APIV1Service) registerResourceRoutes(g *echo.Group) {g.DELETE("/resource/:resourceId", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}- resourceID, err := strconv.Atoi(c.Param("resourceId"))+ resourceID, err := util.ConvertStringToInt32(c.Param("resourceId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("resourceId"))).SetInternal(err)}@@ -335,7 +335,7 @@ func (s *APIV1Service) registerResourceRoutes(g *echo.Group) {func (s *APIV1Service) registerResourcePublicRoutes(g *echo.Group) {f := func(c echo.Context) error {ctx := c.Request().Context()- resourceID, err := strconv.Atoi(c.Param("resourceId"))+ resourceID, err := util.ConvertStringToInt32(c.Param("resourceId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("resourceId"))).SetInternal(err)}@@ -346,7 +346,7 @@ func (s *APIV1Service) registerResourcePublicRoutes(g *echo.Group) {}// Protected resource require a logined user- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if resourceVisibility == store.Protected && (!ok || userID <= 0) {return echo.NewHTTPError(http.StatusUnauthorized, "Resource visibility not match").SetInternal(err)}@@ -501,7 +501,7 @@ func getOrGenerateThumbnailImage(srcBlob []byte, dstPath string) ([]byte, error)return dstBlob, nil}-func checkResourceVisibility(ctx context.Context, s *store.Store, resourceID int) (store.Visibility, error) {+func checkResourceVisibility(ctx context.Context, s *store.Store, resourceID int32) (store.Visibility, error) {memoResources, err := s.ListMemoResources(ctx, &store.FindMemoResource{ResourceID: &resourceID,})@@ -514,7 +514,7 @@ func checkResourceVisibility(ctx context.Context, s *store.Store, resourceID intreturn store.Private, nil}- memoIDs := make([]int, 0, len(memoResources))+ memoIDs := make([]int32, 0, len(memoResources))for _, memoResource := range memoResources {memoIDs = append(memoIDs, memoResource.MemoID)}diff --git a/api/v1/rss.go b/api/v1/rss.goindex 7d130cf24..320d39380 100644--- a/api/v1/rss.go+++ b/api/v1/rss.go@@ -49,7 +49,7 @@ func (s *APIV1Service) registerRSSRoutes(g *echo.Group) {g.GET("/u/:id/rss.xml", func(c echo.Context) error {ctx := c.Request().Context()- id, err := strconv.Atoi(c.Param("id"))+ id, err := util.ConvertStringToInt32(c.Param("id"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, "User id is not a number").SetInternal(err)}@@ -94,10 +94,10 @@ func (s *APIV1Service) generateRSSFromMemoList(ctx context.Context, memoList []*memo := memoList[i]feed.Items[i] = &feeds.Item{Title: getRSSItemTitle(memo.Content),- Link: &feeds.Link{Href: baseURL + "/m/" + strconv.Itoa(memo.ID)},+ Link: &feeds.Link{Href: baseURL + "/m/" + fmt.Sprintf("%d", memo.ID)},Description: getRSSItemDescription(memo.Content),Created: time.Unix(memo.CreatedTs, 0),- Enclosure: &feeds.Enclosure{Url: baseURL + "/m/" + strconv.Itoa(memo.ID) + "/image"},+ Enclosure: &feeds.Enclosure{Url: baseURL + "/m/" + fmt.Sprintf("%d", memo.ID) + "/image"},}if len(memo.ResourceIDList) > 0 {resourceID := memo.ResourceIDList[0]@@ -114,7 +114,7 @@ func (s *APIV1Service) generateRSSFromMemoList(ctx context.Context, memoList []*if resource.ExternalLink != "" {enclosure.Url = resource.ExternalLink} else {- enclosure.Url = baseURL + "/o/r/" + strconv.Itoa(resource.ID)+ enclosure.Url = baseURL + "/o/r/" + fmt.Sprintf("%d", resource.ID)}enclosure.Length = strconv.Itoa(int(resource.Size))enclosure.Type = resource.Typediff --git a/api/v1/storage.go b/api/v1/storage.goindex f5b181fcd..e7beba7f8 100644--- a/api/v1/storage.go+++ b/api/v1/storage.go@@ -4,18 +4,18 @@ import ("encoding/json""fmt""net/http"- "strconv""github.com/labstack/echo/v4""github.com/usememos/memos/api/auth"+ "github.com/usememos/memos/common/util""github.com/usememos/memos/store")const (// LocalStorage means the storage service is local file system.- LocalStorage = -1+ LocalStorage int32 = -1// DatabaseStorage means the storage service is database.- DatabaseStorage = 0+ DatabaseStorage int32 = 0)type StorageType string@@ -44,7 +44,7 @@ type StorageS3Config struct {}type Storage struct {- ID int `json:"id"`+ ID int32 `json:"id"`Name string `json:"name"`Type StorageType `json:"type"`Config *StorageConfig `json:"config"`@@ -65,7 +65,7 @@ type UpdateStorageRequest struct {func (s *APIV1Service) registerStorageRoutes(g *echo.Group) {g.POST("/storage", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -111,7 +111,7 @@ func (s *APIV1Service) registerStorageRoutes(g *echo.Group) {g.PATCH("/storage/:storageId", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -126,7 +126,7 @@ func (s *APIV1Service) registerStorageRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusUnauthorized, "Unauthorized")}- storageID, err := strconv.Atoi(c.Param("storageId"))+ storageID, err := util.ConvertStringToInt32(c.Param("storageId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("storageId"))).SetInternal(err)}@@ -165,7 +165,7 @@ func (s *APIV1Service) registerStorageRoutes(g *echo.Group) {g.GET("/storage", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -199,7 +199,7 @@ func (s *APIV1Service) registerStorageRoutes(g *echo.Group) {g.DELETE("/storage/:storageId", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -214,7 +214,7 @@ func (s *APIV1Service) registerStorageRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusUnauthorized, "Unauthorized")}- storageID, err := strconv.Atoi(c.Param("storageId"))+ storageID, err := util.ConvertStringToInt32(c.Param("storageId"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("storageId"))).SetInternal(err)}diff --git a/api/v1/system.go b/api/v1/system.goindex 1f48f1fb5..3c8b2578a 100644--- a/api/v1/system.go+++ b/api/v1/system.go@@ -35,7 +35,7 @@ type SystemStatus struct {// Customized server profile, including server name and external url.CustomizedProfile CustomizedProfile `json:"customizedProfile"`// Storage service ID.- StorageServiceID int `json:"storageServiceId"`+ StorageServiceID int32 `json:"storageServiceId"`// Local storage path.LocalStoragePath string `json:"localStoragePath"`// Memo display with updated timestamp.@@ -126,7 +126,7 @@ func (s *APIV1Service) registerSystemRoutes(g *echo.Group) {}systemStatus.CustomizedProfile = customizedProfilecase SystemSettingStorageServiceIDName.String():- systemStatus.StorageServiceID = int(baseValue.(float64))+ systemStatus.StorageServiceID = int32(baseValue.(float64))case SystemSettingLocalStoragePathName.String():systemStatus.LocalStoragePath = baseValue.(string)case SystemSettingMemoDisplayWithUpdatedTsName.String():@@ -141,7 +141,7 @@ func (s *APIV1Service) registerSystemRoutes(g *echo.Group) {g.POST("/system/vacuum", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}diff --git a/api/v1/system_setting.go b/api/v1/system_setting.goindex cb5f28fd6..6aec4490f 100644--- a/api/v1/system_setting.go+++ b/api/v1/system_setting.go@@ -187,7 +187,7 @@ func (upsert UpsertSystemSettingRequest) Validate() error {func (s *APIV1Service) registerSystemSettingRoutes(g *echo.Group) {g.POST("/system/setting", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -237,7 +237,7 @@ func (s *APIV1Service) registerSystemSettingRoutes(g *echo.Group) {g.GET("/system/setting", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}diff --git a/api/v1/tag.go b/api/v1/tag.goindex 1c4488a44..12d95f573 100644--- a/api/v1/tag.go+++ b/api/v1/tag.go@@ -16,7 +16,7 @@ import (type Tag struct {Name string- CreatorID int+ CreatorID int32}type UpsertTagRequest struct {@@ -30,7 +30,7 @@ type DeleteTagRequest struct {func (s *APIV1Service) registerTagRoutes(g *echo.Group) {g.POST("/tag", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -59,7 +59,7 @@ func (s *APIV1Service) registerTagRoutes(g *echo.Group) {g.GET("/tag", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusBadRequest, "Missing user id to find tag")}@@ -80,7 +80,7 @@ func (s *APIV1Service) registerTagRoutes(g *echo.Group) {g.GET("/tag/suggestion", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusBadRequest, "Missing user session")}@@ -125,7 +125,7 @@ func (s *APIV1Service) registerTagRoutes(g *echo.Group) {g.POST("/tag/delete", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}diff --git a/api/v1/user.go b/api/v1/user.goindex 7fa672e34..51fc863dd 100644--- a/api/v1/user.go+++ b/api/v1/user.go@@ -4,7 +4,6 @@ import ("encoding/json""fmt""net/http"- "strconv""time""github.com/labstack/echo/v4"@@ -32,7 +31,7 @@ func (role Role) String() string {}type User struct {- ID int `json:"id"`+ ID int32 `json:"id"`// Standard fieldsRowStatus RowStatus `json:"rowStatus"`@@ -133,7 +132,7 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) {// POST /user - Create a new user.g.POST("/user", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing auth session")}@@ -208,7 +207,7 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) {// GET /user/me - Get current user.g.GET("/user/me", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing auth session")}@@ -239,7 +238,7 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) {// GET /user/:id - Get user by id.g.GET("/user/:id", func(c echo.Context) error {ctx := c.Request().Context()- id, err := strconv.Atoi(c.Param("id"))+ id, err := util.ConvertStringToInt32(c.Param("id"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformatted user id").SetInternal(err)}@@ -282,12 +281,12 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) {// PUT /user/:id - Update user by id.g.PATCH("/user/:id", func(c echo.Context) error {ctx := c.Request().Context()- userID, err := strconv.Atoi(c.Param("id"))+ userID, err := util.ConvertStringToInt32(c.Param("id"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("id"))).SetInternal(err)}- currentUserID, ok := c.Get(auth.UserIDContextKey).(int)+ currentUserID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -367,7 +366,7 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) {// DELETE /user/:id - Delete user by id.g.DELETE("/user/:id", func(c echo.Context) error {ctx := c.Request().Context()- currentUserID, ok := c.Get(auth.UserIDContextKey).(int)+ currentUserID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")}@@ -383,7 +382,7 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusForbidden, "Unauthorized to delete user").SetInternal(err)}- userID, err := strconv.Atoi(c.Param("id"))+ userID, err := util.ConvertStringToInt32(c.Param("id"))if err != nil {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("id"))).SetInternal(err)}diff --git a/api/v1/user_setting.go b/api/v1/user_setting.goindex cab0f53b5..4ef883f32 100644--- a/api/v1/user_setting.go+++ b/api/v1/user_setting.go@@ -67,13 +67,13 @@ var ()type UserSetting struct {- UserID int `json:"userId"`+ UserID int32 `json:"userId"`Key UserSettingKey `json:"key"`Value string `json:"value"`}type UpsertUserSettingRequest struct {- UserID int `json:"-"`+ UserID int32 `json:"-"`Key UserSettingKey `json:"key"`Value string `json:"value"`}@@ -122,7 +122,7 @@ func (upsert UpsertUserSettingRequest) Validate() error {func (s *APIV1Service) registerUserSettingRoutes(g *echo.Group) {g.POST("/user/setting", func(c echo.Context) error {ctx := c.Request().Context()- userID, ok := c.Get(auth.UserIDContextKey).(int)+ userID, ok := c.Get(auth.UserIDContextKey).(int32)if !ok {return echo.NewHTTPError(http.StatusUnauthorized, "Missing auth session")}diff --git a/api/v2/jwt.go b/api/v2/jwt.goindex 7fdf3cad9..f26eb1a5c 100644--- a/api/v2/jwt.go+++ b/api/v2/jwt.go@@ -10,6 +10,7 @@ import ("github.com/golang-jwt/jwt/v4""github.com/pkg/errors""github.com/usememos/memos/api/auth"+ "github.com/usememos/memos/common/util""github.com/usememos/memos/store""google.golang.org/grpc""google.golang.org/grpc/codes"@@ -76,7 +77,7 @@ func (in *GRPCAuthInterceptor) AuthenticationInterceptor(ctx context.Context, rereturn handler(childCtx, request)}-func (in *GRPCAuthInterceptor) authenticate(ctx context.Context, accessTokenStr string) (int, error) {+func (in *GRPCAuthInterceptor) authenticate(ctx context.Context, accessTokenStr string) (int32, error) {if accessTokenStr == "" {return 0, status.Errorf(codes.Unauthenticated, "access token not found")}@@ -103,7 +104,7 @@ func (in *GRPCAuthInterceptor) authenticate(ctx context.Context, accessTokenStr)}- userID, err := strconv.Atoi(claims.Subject)+ userID, err := util.ConvertStringToInt32(claims.Subject)if err != nil {return 0, status.Errorf(codes.Unauthenticated, "malformed ID %q in the access token", claims.Subject)}diff --git a/api/v2/tag_service.go b/api/v2/tag_service.goindex 3f063fdf7..1a5500d12 100644--- a/api/v2/tag_service.go+++ b/api/v2/tag_service.go@@ -24,7 +24,7 @@ func NewTagService(store *store.Store) *TagService {func (s *TagService) ListTags(ctx context.Context, request *apiv2pb.ListTagsRequest) (*apiv2pb.ListTagsResponse, error) {tags, err := s.Store.ListTags(ctx, &store.FindTag{- CreatorID: int(request.CreatorId),+ CreatorID: request.CreatorId,})if err != nil {return nil, status.Errorf(codes.Internal, "failed to list tags: %v", err)diff --git a/api/v2/user_service.go b/api/v2/user_service.goindex c9b51403d..abd3d0368 100644--- a/api/v2/user_service.go+++ b/api/v2/user_service.go@@ -37,9 +37,8 @@ func (s *UserService) GetUser(ctx context.Context, request *apiv2pb.GetUserReque// Data desensitization.userMessage.OpenId = ""- userUID := int(userMessage.Id)userSettings, err := s.Store.ListUserSettings(ctx, &store.FindUserSetting{- UserID: &userUID,+ UserID: &userMessage.Id,})if err != nil {return nil, status.Errorf(codes.Internal, "failed to list user settings: %v", err)diff --git a/common/util/util.go b/common/util/util.goindex 4ae025d6c..96d2fde82 100644--- a/common/util/util.go+++ b/common/util/util.go@@ -4,11 +4,21 @@ import ("crypto/rand""math/big""net/mail"+ "strconv""strings""github.com/google/uuid")+// ConvertStringToInt32 converts a string to int32.+func ConvertStringToInt32(src string) (int32, error) {+ i, err := strconv.Atoi(src)+ if err != nil {+ return 0, err+ }+ return int32(i), nil+}+// HasPrefixes returns true if the string s has any of the given prefixes.func HasPrefixes(src string, prefixes ...string) bool {for _, prefix := range prefixes {diff --git a/server/telegram.go b/server/telegram.goindex b3b1da1b0..4de2fe742 100644--- a/server/telegram.go+++ b/server/telegram.go@@ -37,7 +37,7 @@ func (t *telegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot,return fmt.Errorf("fail to SendReplyMessage: %s", err)}- var creatorID int+ var creatorID int32userSettingList, err := t.store.ListUserSettings(ctx, &store.FindUserSetting{Key: apiv1.UserSettingTelegramUserIDKey.String(),})@@ -121,7 +121,7 @@ func (t *telegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot,}func (t *telegramHandler) CallbackQueryHandle(ctx context.Context, bot *telegram.Bot, callbackQuery telegram.CallbackQuery) error {- var memoID int+ var memoID int32var visibility store.Visibilityn, err := fmt.Sscanf(callbackQuery.Data, "%s %d", &visibility, &memoID)if err != nil || n != 2 {@@ -146,7 +146,7 @@ func (t *telegramHandler) CallbackQueryHandle(ctx context.Context, bot *telegramreturn bot.AnswerCallbackQuery(ctx, callbackQuery.ID, fmt.Sprintf("Success change Memo %d to %s", memoID, visibility))}-func generateKeyboardForMemoID(id int) [][]telegram.InlineKeyboardButton {+func generateKeyboardForMemoID(id int32) [][]telegram.InlineKeyboardButton {allVisibility := []store.Visibility{store.Public,store.Protected,diff --git a/store/activity.go b/store/activity.goindex 639bb43e6..96c80c5f6 100644--- a/store/activity.go+++ b/store/activity.go@@ -5,10 +5,10 @@ import ()type Activity struct {- ID int+ ID int32// Standard fields- CreatorID int+ CreatorID int32CreatedTs int64// Domain specific fieldsdiff --git a/store/cache.go b/store/cache.goindex 15cd713fa..2a060f9bc 100644--- a/store/cache.go+++ b/store/cache.go@@ -4,6 +4,6 @@ import ("fmt")-func getUserSettingCacheKey(userID int, key string) string {+func getUserSettingCacheKey(userID int32, key string) string {return fmt.Sprintf("%d-%s", userID, key)}diff --git a/store/idp.go b/store/idp.goindex e94eab73f..61a1df8a2 100644--- a/store/idp.go+++ b/store/idp.go@@ -38,7 +38,7 @@ type FieldMapping struct {}type IdentityProvider struct {- ID int+ ID int32Name stringType IdentityProviderTypeIdentifierFilter string@@ -46,11 +46,11 @@ type IdentityProvider struct {}type FindIdentityProvider struct {- ID *int+ ID *int32}type UpdateIdentityProvider struct {- ID int+ ID int32Type IdentityProviderTypeName *stringIdentifierFilter *string@@ -58,7 +58,7 @@ type UpdateIdentityProvider struct {}type DeleteIdentityProvider struct {- ID int+ ID int32}func (s *Store) CreateIdentityProvider(ctx context.Context, create *IdentityProvider) (*IdentityProvider, error) {diff --git a/store/memo.go b/store/memo.goindex 83c7b0f97..af259b728 100644--- a/store/memo.go+++ b/store/memo.go@@ -4,9 +4,10 @@ import ("context""database/sql""fmt"- "strconv""strings""time"++ "github.com/usememos/memos/common/util")// Visibility is the type of a visibility.@@ -34,11 +35,11 @@ func (v Visibility) String() string {}type Memo struct {- ID int+ ID int32// Standard fieldsRowStatus RowStatus- CreatorID int+ CreatorID int32CreatedTs int64UpdatedTs int64@@ -48,16 +49,16 @@ type Memo struct {// Composed fieldsPinned bool- ResourceIDList []int+ ResourceIDList []int32RelationList []*MemoRelation}type FindMemo struct {- ID *int+ ID *int32// Standard fieldsRowStatus *RowStatus- CreatorID *int+ CreatorID *int32// Domain specific fieldsPinned *bool@@ -71,7 +72,7 @@ type FindMemo struct {}type UpdateMemo struct {- ID int+ ID int32CreatedTs *int64UpdatedTs *int64RowStatus *RowStatus@@ -80,7 +81,7 @@ type UpdateMemo struct {}type DeleteMemo struct {- ID int+ ID int32}func (s *Store) CreateMemo(ctx context.Context, create *Memo) (*Memo, error) {@@ -220,9 +221,9 @@ func (s *Store) ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error)if memoResourceIDList.Valid {idStringList := strings.Split(memoResourceIDList.String, ",")- memo.ResourceIDList = make([]int, 0, len(idStringList))+ memo.ResourceIDList = make([]int32, 0, len(idStringList))for _, idString := range idStringList {- id, err := strconv.Atoi(idString)+ id, err := util.ConvertStringToInt32(idString)if err != nil {return nil, err}@@ -237,7 +238,7 @@ func (s *Store) ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error)if len(relatedMemoTypeList) != 2 {return nil, fmt.Errorf("invalid relation format")}- relatedMemoID, err := strconv.Atoi(relatedMemoTypeList[0])+ relatedMemoID, err := util.ConvertStringToInt32(relatedMemoTypeList[0])if err != nil {return nil, err}@@ -318,7 +319,7 @@ func (s *Store) DeleteMemo(ctx context.Context, delete *DeleteMemo) error {return nil}-func (s *Store) FindMemosVisibilityList(ctx context.Context, memoIDs []int) ([]Visibility, error) {+func (s *Store) FindMemosVisibilityList(ctx context.Context, memoIDs []int32) ([]Visibility, error) {args := make([]any, 0, len(memoIDs))list := make([]string, 0, len(memoIDs))for _, memoID := range memoIDs {diff --git a/store/memo_organizer.go b/store/memo_organizer.goindex 910440a8e..9737cffb7 100644--- a/store/memo_organizer.go+++ b/store/memo_organizer.go@@ -8,19 +8,19 @@ import ()type MemoOrganizer struct {- MemoID int- UserID int+ MemoID int32+ UserID int32Pinned bool}type FindMemoOrganizer struct {- MemoID int- UserID int+ MemoID int32+ UserID int32}type DeleteMemoOrganizer struct {- MemoID *int- UserID *int+ MemoID *int32+ UserID *int32}func (s *Store) UpsertMemoOrganizer(ctx context.Context, upsert *MemoOrganizer) (*MemoOrganizer, error) {diff --git a/store/memo_relation.go b/store/memo_relation.goindex d32a7f353..a411a775d 100644--- a/store/memo_relation.go+++ b/store/memo_relation.go@@ -14,20 +14,20 @@ const ()type MemoRelation struct {- MemoID int- RelatedMemoID int+ MemoID int32+ RelatedMemoID int32Type MemoRelationType}type FindMemoRelation struct {- MemoID *int- RelatedMemoID *int+ MemoID *int32+ RelatedMemoID *int32Type *MemoRelationType}type DeleteMemoRelation struct {- MemoID *int- RelatedMemoID *int+ MemoID *int32+ RelatedMemoID *int32Type *MemoRelationType}diff --git a/store/memo_resource.go b/store/memo_resource.goindex 80d993d08..6bde5ee63 100644--- a/store/memo_resource.go+++ b/store/memo_resource.go@@ -7,27 +7,27 @@ import ()type MemoResource struct {- MemoID int- ResourceID int+ MemoID int32+ ResourceID int32CreatedTs int64UpdatedTs int64}type UpsertMemoResource struct {- MemoID int- ResourceID int+ MemoID int32+ ResourceID int32CreatedTs int64UpdatedTs *int64}type FindMemoResource struct {- MemoID *int- ResourceID *int+ MemoID *int32+ ResourceID *int32}type DeleteMemoResource struct {- MemoID *int- ResourceID *int+ MemoID *int32+ ResourceID *int32}func (s *Store) UpsertMemoResource(ctx context.Context, upsert *UpsertMemoResource) (*MemoResource, error) {diff --git a/store/resource.go b/store/resource.goindex 706b6957c..b72c12b66 100644--- a/store/resource.go+++ b/store/resource.go@@ -8,10 +8,10 @@ import ()type Resource struct {- ID int+ ID int32// Standard fields- CreatorID int+ CreatorID int32CreatedTs int64UpdatedTs int64@@ -27,16 +27,16 @@ type Resource struct {type FindResource struct {GetBlob bool- ID *int- CreatorID *int+ ID *int32+ CreatorID *int32Filename *string- MemoID *int+ MemoID *int32Limit *intOffset *int}type UpdateResource struct {- ID int+ ID int32UpdatedTs *int64Filename *stringInternalPath *string@@ -44,7 +44,7 @@ type UpdateResource struct {}type DeleteResource struct {- ID int+ ID int32}func (s *Store) CreateResource(ctx context.Context, create *Resource) (*Resource, error) {diff --git a/store/storage.go b/store/storage.goindex 8e8c7802c..2562c2c8b 100644--- a/store/storage.go+++ b/store/storage.go@@ -6,24 +6,24 @@ import ()type Storage struct {- ID int+ ID int32Name stringType stringConfig string}type FindStorage struct {- ID *int+ ID *int32}type UpdateStorage struct {- ID int+ ID int32Name *stringConfig *string}type DeleteStorage struct {- ID int+ ID int32}func (s *Store) CreateStorage(ctx context.Context, create *Storage) (*Storage, error) {diff --git a/store/tag.go b/store/tag.goindex 37b0077f1..713a076ef 100644--- a/store/tag.go+++ b/store/tag.go@@ -8,16 +8,16 @@ import (type Tag struct {Name string- CreatorID int+ CreatorID int32}type FindTag struct {- CreatorID int+ CreatorID int32}type DeleteTag struct {Name string- CreatorID int+ CreatorID int32}func (s *Store) UpsertTag(ctx context.Context, upsert *Tag) (*Tag, error) {diff --git a/store/user.go b/store/user.goindex 4ce11d707..3c10795b9 100644--- a/store/user.go+++ b/store/user.go@@ -30,7 +30,7 @@ func (e Role) String() string {}type User struct {- ID int+ ID int32// Standard fieldsRowStatus RowStatus@@ -48,7 +48,7 @@ type User struct {}type UpdateUser struct {- ID int+ ID int32UpdatedTs *int64RowStatus *RowStatus@@ -63,7 +63,7 @@ type UpdateUser struct {}type FindUser struct {- ID *int+ ID *int32RowStatus *RowStatusUsername *stringRole *Role@@ -73,7 +73,7 @@ type FindUser struct {}type DeleteUser struct {- ID int+ ID int32}func (s *Store) CreateUser(ctx context.Context, create *User) (*User, error) {diff --git a/store/user_setting.go b/store/user_setting.goindex fa948167d..bd6e38a68 100644--- a/store/user_setting.go+++ b/store/user_setting.go@@ -7,13 +7,13 @@ import ()type UserSetting struct {- UserID int+ UserID int32Key stringValue string}type FindUserSetting struct {- UserID *int+ UserID *int32Key string}diff --git a/test/server/memo_relation_test.go b/test/server/memo_relation_test.goindex a7d705c50..ca4deade1 100644--- a/test/server/memo_relation_test.go+++ b/test/server/memo_relation_test.go@@ -61,7 +61,7 @@ func TestMemoRelationServer(t *testing.T) {require.Len(t, memo2.RelationList, 1)}-func (s *TestingServer) postMemoRelationUpsert(memoID int, memoRelationUpsert *apiv1.UpsertMemoRelationRequest) (*apiv1.MemoRelation, error) {+func (s *TestingServer) postMemoRelationUpsert(memoID int32, memoRelationUpsert *apiv1.UpsertMemoRelationRequest) (*apiv1.MemoRelation, error) {rawData, err := json.Marshal(&memoRelationUpsert)if err != nil {return nil, errors.Wrap(err, "failed to marshal memo relation upsert")@@ -85,7 +85,7 @@ func (s *TestingServer) postMemoRelationUpsert(memoID int, memoRelationUpsert *areturn memoRelation, nil}-func (s *TestingServer) deleteMemoRelation(memoID int, relatedMemoID int, relationType apiv1.MemoRelationType) error {+func (s *TestingServer) deleteMemoRelation(memoID int32, relatedMemoID int32, relationType apiv1.MemoRelationType) error {_, err := s.delete(fmt.Sprintf("/api/v1/memo/%d/relation/%d/type/%s", memoID, relatedMemoID, relationType), nil)return err}diff --git a/test/server/memo_test.go b/test/server/memo_test.goindex 571163f7d..5a24435bd 100644--- a/test/server/memo_test.go+++ b/test/server/memo_test.go@@ -59,7 +59,7 @@ func TestMemoServer(t *testing.T) {require.Len(t, memoList, 0)}-func (s *TestingServer) getMemo(memoID int) (*apiv1.Memo, error) {+func (s *TestingServer) getMemo(memoID int32) (*apiv1.Memo, error) {body, err := s.get(fmt.Sprintf("/api/v1/memo/%d", memoID), nil)if err != nil {return nil, err@@ -145,12 +145,12 @@ func (s *TestingServer) patchMemo(memoPatch *apiv1.PatchMemoRequest) (*apiv1.Memreturn memo, nil}-func (s *TestingServer) deleteMemo(memoID int) error {+func (s *TestingServer) deleteMemo(memoID int32) error {_, err := s.delete(fmt.Sprintf("/api/v1/memo/%d", memoID), nil)return err}-func (s *TestingServer) postMemoOrganizer(memoID int, memosOrganizer *apiv1.UpsertMemoOrganizerRequest) (*apiv1.Memo, error) {+func (s *TestingServer) postMemoOrganizer(memoID int32, memosOrganizer *apiv1.UpsertMemoOrganizerRequest) (*apiv1.Memo, error) {rawData, err := json.Marshal(&memosOrganizer)if err != nil {return nil, errors.Wrap(err, "failed to marshal memos organizer")diff --git a/test/store/resource_test.go b/test/store/resource_test.goindex a861bd396..9a6010769 100644--- a/test/store/resource_test.go+++ b/test/store/resource_test.go@@ -29,15 +29,15 @@ func TestResourceStore(t *testing.T) {})require.NoError(t, err)require.Equal(t, correctFilename, res.Filename)- require.Equal(t, 1, res.ID)+ require.Equal(t, int32(1), res.ID)notFoundResource, err := ts.GetResource(ctx, &store.FindResource{Filename: &incorrectFilename,})require.NoError(t, err)require.Nil(t, notFoundResource)- correctCreatorID := 101- incorrectCreatorID := 102+ var correctCreatorID int32 = 101+ var incorrectCreatorID int32 = 102_, err = ts.GetResource(ctx, &store.FindResource{CreatorID: &correctCreatorID,})