package api.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import api.domain.City;
import api.domain.Article;
import api.ApplicationConfiguration;
import api.repository.CityRepository;
import api.repository.ArticleRepository;
import api.service.TestService;
@Controller
public class IndexController {
@Autowired
private CityRepository repository;
@Autowired
private TestService testService;
@Autowired
private ApplicationConfiguration propertie;
@Autowired
private JdbcTemplate jdbcTemplate;
@RequestMapping(value = "/article")
public @ResponseBody String dailyStats(@RequestParam Integer id) {
String query = "SELECT id, title, content from article where id = " + id;
return jdbcTemplate.queryForObject(query, (resultSet, i) -> {
System.out.println(resultSet.getLong(1)+","+ resultSet.getString(2)+","+ resultSet.getString(3));
return (resultSet.getLong(1)+","+ resultSet.getString(2)+","+ resultSet.getString(3));
});
}
}