LineConfigServiceImpl.java
1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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;
}
}