|
17 | 17 | */
|
18 | 18 | package ru.mystamps.web.feature.image;
|
19 | 19 |
|
20 |
| -import lombok.RequiredArgsConstructor; |
21 | 20 | import org.apache.commons.lang3.Validate;
|
22 |
| -import org.springframework.beans.factory.annotation.Value; |
| 21 | +import org.springframework.core.env.Environment; |
23 | 22 | import org.springframework.dao.EmptyResultDataAccessException;
|
24 | 23 | import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
25 | 24 | import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
32 | 31 | import java.util.List;
|
33 | 32 | import java.util.Map;
|
34 | 33 |
|
35 |
| -@RequiredArgsConstructor |
36 | 34 | public class JdbcImageDao implements ImageDao {
|
37 | 35 |
|
38 | 36 | private final NamedParameterJdbcTemplate jdbcTemplate;
|
| 37 | + private final String addImageSql; |
| 38 | + private final String replaceImageSql; |
| 39 | + private final String addImageToSeriesSql; |
| 40 | + private final String findByIdSql; |
| 41 | + private final String findBySeriesIdSql; |
39 | 42 |
|
40 |
| - @Value("${image.add}") |
41 |
| - private String addImageSql; |
42 |
| - |
43 |
| - @Value("${image.replace}") |
44 |
| - private String replaceImageSql; |
45 |
| - |
46 |
| - @Value("${series_image.add}") |
47 |
| - private String addImageToSeriesSql; |
48 |
| - |
49 |
| - @Value("${image.find_by_id}") |
50 |
| - private String findByIdSql; |
51 |
| - |
52 |
| - @Value("${series_image.find_by_series_id}") |
53 |
| - private String findBySeriesIdSql; |
| 43 | + public JdbcImageDao(Environment env, NamedParameterJdbcTemplate jdbcTemplate) { |
| 44 | + this.jdbcTemplate = jdbcTemplate; |
| 45 | + this.addImageSql = env.getRequiredProperty("image.add"); |
| 46 | + this.replaceImageSql = env.getRequiredProperty("image.replace"); |
| 47 | + this.addImageToSeriesSql = env.getRequiredProperty("series_image.add"); |
| 48 | + this.findByIdSql = env.getRequiredProperty("image.find_by_id"); |
| 49 | + this.findBySeriesIdSql = env.getRequiredProperty("series_image.find_by_series_id"); |
| 50 | + } |
54 | 51 |
|
55 | 52 | @Override
|
56 | 53 | public Integer add(String type, String filename) {
|
|
0 commit comments