add: query commodity prices api
This commit is contained in:
parent
4fd6a57215
commit
ad591921f7
|
|
@ -75,7 +75,7 @@ func RegisterRouter(router *gin.Engine) {
|
||||||
authorized.GET("/stats/account/trend", service.StatsAccountTrend)
|
authorized.GET("/stats/account/trend", service.StatsAccountTrend)
|
||||||
authorized.GET("/stats/account/balance", service.StatsAccountBalance)
|
authorized.GET("/stats/account/balance", service.StatsAccountBalance)
|
||||||
authorized.GET("/stats/month/total", service.StatsMonthTotal)
|
authorized.GET("/stats/month/total", service.StatsMonthTotal)
|
||||||
authorized.GET("/stats/prices", service.StatsPrices)
|
authorized.GET("/stats/commodity/price", service.StatsCommodityPrice)
|
||||||
authorized.GET("/transaction", service.QueryTransactions)
|
authorized.GET("/transaction", service.QueryTransactions)
|
||||||
authorized.POST("/transaction", service.AddTransactions)
|
authorized.POST("/transaction", service.AddTransactions)
|
||||||
authorized.POST("/transaction/batch", service.AddBatchTransactions)
|
authorized.POST("/transaction/batch", service.AddBatchTransactions)
|
||||||
|
|
|
||||||
|
|
@ -408,13 +408,13 @@ func StatsPayee(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type StatsPricesResult struct {
|
type StatsPricesResult struct {
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
Price string `json:"price"`
|
Commodity string `json:"commodity"`
|
||||||
Currency string `json:"operatingCurrency"`
|
Currency string `json:"operatingCurrency"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func StatsPrices(c *gin.Context) {
|
func StatsCommodityPrice(c *gin.Context) {
|
||||||
ledgerConfig := script.GetLedgerConfigFromContext(c)
|
ledgerConfig := script.GetLedgerConfigFromContext(c)
|
||||||
output := script.BeanReportAllPrices(ledgerConfig)
|
output := script.BeanReportAllPrices(ledgerConfig)
|
||||||
script.LogInfo(ledgerConfig.Mail, output)
|
script.LogInfo(ledgerConfig.Mail, output)
|
||||||
|
|
@ -429,10 +429,10 @@ func StatsPrices(c *gin.Context) {
|
||||||
// split line by " "
|
// split line by " "
|
||||||
words := strings.Fields(line)
|
words := strings.Fields(line)
|
||||||
statsPricesResultList = append(statsPricesResultList, StatsPricesResult{
|
statsPricesResultList = append(statsPricesResultList, StatsPricesResult{
|
||||||
Date: words[0],
|
Date: words[0],
|
||||||
Price: words[2],
|
Commodity: words[2],
|
||||||
Value: words[3],
|
Value: words[3],
|
||||||
Currency: words[4],
|
Currency: words[4],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
OK(c, statsPricesResultList)
|
OK(c, statsPricesResultList)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue