|
39 | 39 | import ru.mystamps.web.dao.dto.LinkEntityDto; |
40 | 40 |
|
41 | 41 | @RequiredArgsConstructor |
42 | | -@SuppressWarnings("PMD.AvoidDuplicateLiterals") |
| 42 | +@SuppressWarnings({"PMD.AvoidDuplicateLiterals", "PMD.TooManyMethods"}) |
43 | 43 | public class JdbcCountryDao implements CountryDao { |
44 | 44 |
|
45 | 45 | private final NamedParameterJdbcTemplate jdbcTemplate; |
@@ -76,6 +76,14 @@ public class JdbcCountryDao implements CountryDao { |
76 | 76 |
|
77 | 77 | @Value("${country.find_country_link_info_by_slug}") |
78 | 78 | private String findCountryLinkEntityBySlugSql; |
| 79 | + |
| 80 | + @SuppressWarnings("PMD.LongVariable") |
| 81 | + @Value("${country.find_from_last_created_series_by_user}") |
| 82 | + private String findFromLastCreatedSeriesByUserSql; |
| 83 | + |
| 84 | + @SuppressWarnings("PMD.LongVariable") |
| 85 | + @Value("${country.find_popular_country_from_user_collection}") |
| 86 | + private String findPopularCountryInCollectionSql; |
79 | 87 |
|
80 | 88 | @Override |
81 | 89 | public Integer add(AddCountryDbDto country) { |
@@ -206,5 +214,38 @@ public LinkEntityDto findOneAsLinkEntity(String slug, String lang) { |
206 | 214 | return null; |
207 | 215 | } |
208 | 216 | } |
| 217 | + |
| 218 | + /** |
| 219 | + * @author Shkarin John |
| 220 | + * @author Slava Semushin |
| 221 | + */ |
| 222 | + @Override |
| 223 | + public String findCountryOfLastCreatedSeriesByUser(Integer userId) { |
| 224 | + try { |
| 225 | + return jdbcTemplate.queryForObject( |
| 226 | + findFromLastCreatedSeriesByUserSql, |
| 227 | + Collections.singletonMap("created_by", userId), |
| 228 | + String.class |
| 229 | + ); |
| 230 | + } catch (EmptyResultDataAccessException ignored) { |
| 231 | + return null; |
| 232 | + } |
| 233 | + } |
| 234 | + |
| 235 | + /** |
| 236 | + * @author Shkarin John |
| 237 | + */ |
| 238 | + @Override |
| 239 | + public String findPopularCountryInCollection(Integer userId) { |
| 240 | + try { |
| 241 | + return jdbcTemplate.queryForObject( |
| 242 | + findPopularCountryInCollectionSql, |
| 243 | + Collections.singletonMap("user_id", userId), |
| 244 | + String.class |
| 245 | + ); |
| 246 | + } catch (EmptyResultDataAccessException ignored) { |
| 247 | + return null; |
| 248 | + } |
| 249 | + } |
209 | 250 |
|
210 | 251 | } |
0 commit comments