LineConfigServiceImpl.java 1.37 KB
package com.bsth.service.impl;

import com.bsth.entity.LineConfig;
import com.bsth.service.LineConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

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

/**
 * Created by panzhao on 2017/7/27.
 */
@Service
public class LineConfigServiceImpl implements LineConfigService {

    @Autowired
    JdbcTemplate jdbcTemplate;

    @Override
    public Map<String, LineConfig> findAll() {
        String sql = "select c.id,c.out_config,c.start_opt,c.trust,t.line_code from bsth_c_line_config c LEFT JOIN bsth_c_line t on c.line=t.id";
        List<LineConfig> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(LineConfig.class));

        Map<String, LineConfig> rs = new HashMap<>();
        for(LineConfig config : list){
            rs.put(config.getLineCode(), config);
        }
        return rs;
    }
    
    @Override
    public List<LineConfig> findAllList() {
        String sql = "select c.id,c.out_config,c.start_opt,c.trust,t.line_code from bsth_c_line_config c LEFT JOIN bsth_c_line t on c.line=t.id";
        List<LineConfig> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(LineConfig.class));

        return list;
    }
}