diff --git a/server.go b/server.go index f050500..de039e6 100644 --- a/server.go +++ b/server.go @@ -66,6 +66,7 @@ func RegisterRouter(router *gin.Engine) { authorized.POST("/account/close", service.CloseAccount) authorized.POST("/account/icon", service.ChangeAccountIcon) authorized.POST("/account/balance", service.BalanceAccount) + authorized.POST("/account/refresh", service.RefreshAccountCache) authorized.POST("/commodity/price", service.SyncCommodityPrice) authorized.GET("/stats/months", service.MonthsList) authorized.GET("/stats/total", service.StatsTotal) diff --git a/service/accounts.go b/service/accounts.go index e127ff8..487ca79 100644 --- a/service/accounts.go +++ b/service/accounts.go @@ -253,3 +253,14 @@ func BalanceAccount(c *gin.Context) { result["marketCurrencySymbol"] = script.GetCommoditySymbol(ledgerConfig.OperatingCurrency) OK(c, result) } + +func RefreshAccountCache(c *gin.Context) { + ledgerConfig := script.GetLedgerConfigFromContext(c) + // 加载账户缓存 + err := script.LoadLedgerAccounts(ledgerConfig.Id) + if err != nil { + InternalError(c, err.Error()) + return + } + OK(c, nil) +}