17
17
*/
18
18
package ru .mystamps .web .feature .collection ;
19
19
20
- import lombok .RequiredArgsConstructor ;
21
20
import org .apache .commons .lang3 .Validate ;
22
21
import org .slf4j .Logger ;
23
22
import org .slf4j .LoggerFactory ;
24
- import org .springframework .beans . factory . annotation . Value ;
23
+ import org .springframework .core . env . Environment ;
25
24
import org .springframework .dao .EmptyResultDataAccessException ;
26
25
import org .springframework .jdbc .core .ResultSetExtractor ;
27
26
import org .springframework .jdbc .core .namedparam .MapSqlParameterSource ;
38
37
import java .util .List ;
39
38
import java .util .Map ;
40
39
41
- @ RequiredArgsConstructor
42
40
@ SuppressWarnings ({ "PMD.AvoidDuplicateLiterals" , "PMD.TooManyMethods" })
43
41
public class JdbcCollectionDao implements CollectionDao {
44
42
private static final Logger LOG = LoggerFactory .getLogger (JdbcCollectionDao .class );
@@ -47,48 +45,39 @@ public class JdbcCollectionDao implements CollectionDao {
47
45
new MapIntegerIntegerResultSetExtractor ("id" , "number_of_stamps" );
48
46
49
47
private final NamedParameterJdbcTemplate jdbcTemplate ;
48
+ private final String findLastCreatedCollectionsSql ;
49
+ private final String findSeriesByCollectionIdSql ;
50
+ private final String findSeriesWithPricesBySlugSql ;
51
+ private final String countCollectionsOfUsersSql ;
52
+ private final String countUpdatedSinceSql ;
53
+ private final String countSeriesOfCollectionSql ;
54
+ private final String countStampsOfCollectionSql ;
55
+ private final String addCollectionSql ;
56
+ private final String markAsModifiedSql ;
57
+ private final String isSeriesInUserCollectionSql ;
58
+ private final String findSeriesInstancesSql ;
59
+ private final String addSeriesToCollectionSql ;
60
+ private final String removeSeriesInstanceSql ;
61
+ private final String findCollectionInfoBySlugSql ;
50
62
51
- @ Value ("${collection.find_last_created}" )
52
- private String findLastCreatedCollectionsSql ;
53
-
54
- @ Value ("${collection.find_series_by_collection_id}" )
55
- private String findSeriesByCollectionIdSql ;
56
-
57
- @ Value ("${collection.find_series_with_prices_by_slug}" )
58
- private String findSeriesWithPricesBySlugSql ;
59
-
60
- @ Value ("${collection.count_collections_of_users}" )
61
- private String countCollectionsOfUsersSql ;
62
-
63
- @ Value ("${collection.count_updated_since}" )
64
- private String countUpdatedSinceSql ;
65
-
66
- @ Value ("${collection.count_series_of_collection}" )
67
- private String countSeriesOfCollectionSql ;
68
-
69
- @ Value ("${collection.count_stamps_of_collection}" )
70
- private String countStampsOfCollectionSql ;
71
-
72
- @ Value ("${collection.create}" )
73
- private String addCollectionSql ;
74
-
75
- @ Value ("${collection.mark_as_modified}" )
76
- private String markAsModifiedSql ;
77
-
78
- @ Value ("${collection.is_series_in_collection}" )
79
- private String isSeriesInUserCollectionSql ;
80
-
81
- @ Value ("${collection.find_series_instances}" )
82
- private String findSeriesInstancesSql ;
83
-
84
- @ Value ("${collection.add_series_to_collection}" )
85
- private String addSeriesToCollectionSql ;
86
-
87
- @ Value ("${collection.remove_series_instance_from_collection}" )
88
- private String removeSeriesInstanceSql ;
89
-
90
- @ Value ("${collection.find_info_by_slug}" )
91
- private String findCollectionInfoBySlugSql ;
63
+ @ SuppressWarnings ("checkstyle:linelength" )
64
+ public JdbcCollectionDao (Environment env ,NamedParameterJdbcTemplate jdbcTemplate ) {
65
+ this .jdbcTemplate = jdbcTemplate ;
66
+ this .findLastCreatedCollectionsSql = env .getRequiredProperty ("collection.find_last_created" );
67
+ this .findSeriesByCollectionIdSql = env .getRequiredProperty ("collection.find_series_by_collection_id" );
68
+ this .findSeriesWithPricesBySlugSql = env .getRequiredProperty ("collection.find_series_with_prices_by_slug" );
69
+ this .countCollectionsOfUsersSql = env .getRequiredProperty ("collection.count_collections_of_users" );
70
+ this .countUpdatedSinceSql = env .getRequiredProperty ("collection.count_updated_since" );
71
+ this .countSeriesOfCollectionSql = env .getRequiredProperty ("collection.count_series_of_collection" );
72
+ this .countStampsOfCollectionSql = env .getRequiredProperty ("collection.count_stamps_of_collection" );
73
+ this .addCollectionSql = env .getRequiredProperty ("collection.create" );
74
+ this .markAsModifiedSql = env .getRequiredProperty ("collection.mark_as_modified" );
75
+ this .isSeriesInUserCollectionSql = env .getRequiredProperty ("collection.is_series_in_collection" );
76
+ this .findSeriesInstancesSql = env .getRequiredProperty ("collection.find_series_instances" );
77
+ this .addSeriesToCollectionSql = env .getRequiredProperty ("collection.add_series_to_collection" );
78
+ this .removeSeriesInstanceSql = env .getRequiredProperty ("collection.remove_series_instance_from_collection" );
79
+ this .findCollectionInfoBySlugSql = env .getRequiredProperty ("collection.find_info_by_slug" );
80
+ }
92
81
93
82
@ Override
94
83
public List <LinkEntityDto > findLastCreated (int quantity ) {
0 commit comments