File tree Expand file tree Collapse file tree 3 files changed +14
-10
lines changed
src/main/java/ru/mystamps/web Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ public static PropertySourcesPlaceholderConfigurer getPropertySourcesPlaceholder
44
44
new PropertySourcesPlaceholderConfigurer ();
45
45
configurer .setLocations (
46
46
new ClassPathResource ("sql/series_dao_queries.properties" ),
47
- new ClassPathResource ("sql/series_sales_dao_queries.properties" ),
48
47
new ClassPathResource ("sql/transaction_participants_dao_queries.properties" )
49
48
);
50
49
return configurer ;
Original file line number Diff line number Diff line change 17
17
*/
18
18
package ru .mystamps .web .feature .series .sale ;
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 .jdbc .core .namedparam .NamedParameterJdbcTemplate ;
24
23
25
24
import java .util .Collections ;
26
25
import java .util .HashMap ;
27
26
import java .util .List ;
28
27
import java .util .Map ;
29
28
30
- @ RequiredArgsConstructor
31
29
public class JdbcSeriesSalesDao implements SeriesSalesDao {
32
30
33
31
private final NamedParameterJdbcTemplate jdbcTemplate ;
32
+ private final String addSeriesSaleSql ;
33
+ private final String findSeriesSalesBySeriesIdSql ;
34
34
35
- @ Value ("${series_sales.add}" )
36
- private String addSeriesSaleSql ;
37
-
38
- @ Value ("${series_sales.find_sales_by_series_id}" )
39
- private String findSeriesSalesBySeriesIdSql ;
35
+ @ SuppressWarnings ("checkstyle:linelength" )
36
+ public JdbcSeriesSalesDao (Environment env , NamedParameterJdbcTemplate jdbcTemplate ) {
37
+ this .jdbcTemplate = jdbcTemplate ;
38
+ this .addSeriesSaleSql = env .getRequiredProperty ("series_sales.add" );
39
+ this .findSeriesSalesBySeriesIdSql = env .getRequiredProperty ("series_sales.find_sales_by_series_id" );
40
+ }
40
41
41
42
@ Override
42
43
public void add (AddSeriesSalesDbDto sale ) {
Original file line number Diff line number Diff line change 21
21
import org .slf4j .LoggerFactory ;
22
22
import org .springframework .context .annotation .Bean ;
23
23
import org .springframework .context .annotation .Configuration ;
24
+ import org .springframework .context .annotation .PropertySource ;
25
+ import org .springframework .core .env .Environment ;
24
26
import org .springframework .jdbc .core .namedparam .NamedParameterJdbcTemplate ;
25
27
26
28
/**
30
32
public class SeriesSalesConfig {
31
33
32
34
@ RequiredArgsConstructor
35
+ @ PropertySource ("classpath:sql/series_sales_dao_queries.properties" )
33
36
public static class Services {
34
37
38
+ private final Environment env ;
35
39
private final NamedParameterJdbcTemplate jdbcTemplate ;
36
40
37
41
@ Bean
@@ -44,7 +48,7 @@ public SeriesSalesService seriesSalesService(SeriesSalesDao seriesSalesDao) {
44
48
45
49
@ Bean
46
50
public SeriesSalesDao seriesSalesDao () {
47
- return new JdbcSeriesSalesDao (jdbcTemplate );
51
+ return new JdbcSeriesSalesDao (env , jdbcTemplate );
48
52
}
49
53
50
54
}
You can’t perform that action at this time.
0 commit comments