package app.services.db; import app.entities.db.CollectableStatistic; import app.updates.BaseUpdater; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; @Service public class CollectStatisticService extends BaseUpdater { @Autowired @Qualifier("jt_rw") private JdbcTemplate jdbcTemplate; private final Logger logger = LoggerFactory.getLogger(this.getClass()); public void add(CollectableStatistic collectableStatistic) { if (collectableStatistic.isServerRequest()) return; if (collectableStatistic.isIgnoreRule()) return; try { if (!collectableStatistic.isStatsRequests()) logger.info(collectableStatistic.toString()); jdbcTemplate.update("INSERT INTO `web_statistic` (`steam64`, `client_ip`, `method`, `path`, `query`, `useragent`) VALUES (?, ?, ?, ?, ?, ?)", collectableStatistic.getSteam64(), collectableStatistic.getClient_ip(), collectableStatistic.getMethod(), collectableStatistic.getPath(), collectableStatistic.getQuery(), collectableStatistic.getUseragent()); } catch (Exception err) { logger.error("Ignoring add stats"); } } }