text: package io.spring2go.piggymetrics.statistics.controller;
  
  import io.spring2go.piggymetrics.statistics.domain.Account;
  import io.spring2go.piggymetrics.statistics.domain.timeseries.DataPoint;
  import io.spring2go.piggymetrics.statistics.service.StatisticsService;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.*;
  
  import javax.validation.Valid;
  import java.util.List;
  
  @RestController
  public class StatisticsController {
  
  	@Autowired
  	private StatisticsService statisticsService;
  
  	@RequestMapping(value = "/current", method = RequestMethod.GET)
  	public List<DataPoint> getCurrentAccountStatistics(@RequestHeader("X-S2G-USERNAME") String accountName) {
  		return statisticsService.findByAccountName(accountName);
  	}
  
  	@RequestMapping(value = "/{accountName}", method = RequestMethod.GET)
  	public List<DataPoint> getStatisticsByAccountName(@PathVariable String accountName) {
  		return statisticsService.findByAccountName(accountName);
  	}
  
  	@RequestMapping(value = "/{accountName}", method = RequestMethod.PUT)
  	public void saveAccountStatistics(@PathVariable String accountName, @Valid @RequestBody Account account) {
  		statisticsService.save(accountName, account);
  	}
  }
  