package com.youchain.Netty;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Component
@Service
public class JdbcQueryExample {
    private final JdbcTemplate jdbcTemplate;

    @Autowired
    public JdbcQueryExample(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public List<Map<String, Object>> sqlQuery(String sql, Object... params) {
        return jdbcTemplate.queryForList(sql, params);
    }
    public List<Map<String, Object>> sqlQuery(String sql) {
        return jdbcTemplate.queryForList(sql);
    }
    public int executeUpdate(String sql, Object... params) {
        return jdbcTemplate.update(sql, params);
    }

}
