ConfigParamDao.java
1.21 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
package com.viontech.keliu.dao;
import com.viontech.keliu.entity.SConfigParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created with IntelliJ IDEA.
*
* @author: zhuhai
* Date: 2023-12-23
* Time: 14:29
*/
@Repository
@Slf4j
public class ConfigParamDao {
@Resource
private JdbcTemplate jdbcTemplate;
public String getConfigParamByMallIdAndConfigKey(Long mallId, String configKey) {
String sql = "select mall_id, config_key, config_value from s_config_params where (mall_id = ? or mall_id is null) and config_key = ? order by mall_id asc limit 1;";
SConfigParam configParam = null;
try {
configParam = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(SConfigParam.class), mallId, configKey);
} catch (Exception e) {
log.error("获取配置异常", e);
}
return configParam == null ? null : configParam.getConfigValue();
}
}