|
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,13 @@ public class JdbcCountryDao implements CountryDao { |
76 | 76 |
|
77 | 77 | @Value("${country.find_country_link_info_by_slug}") |
78 | 78 | private String findCountryLinkEntityBySlugSql; |
| 79 | + |
| 80 | + @Value("${country.find_last_created_by_user}") |
| 81 | + private String findLastCreatedByUserSql; |
| 82 | + |
| 83 | + @SuppressWarnings("PMD.LongVariable") |
| 84 | + @Value("${country.find_popular_country_from_user_collection}") |
| 85 | + private String findPopularCountryInCollectionSql; |
79 | 86 |
|
80 | 87 | @Override |
81 | 88 | public Integer add(AddCountryDbDto country) { |
@@ -206,5 +213,37 @@ public LinkEntityDto findOneAsLinkEntity(String slug, String lang) { |
206 | 213 | return null; |
207 | 214 | } |
208 | 215 | } |
| 216 | + |
| 217 | + /** |
| 218 | + * @author Shkarin John |
| 219 | + */ |
| 220 | + @Override |
| 221 | + public String findLastCreatedByUser(Integer userId) { |
| 222 | + try { |
| 223 | + return jdbcTemplate.queryForObject( |
| 224 | + findLastCreatedByUserSql, |
| 225 | + Collections.singletonMap("created_by", userId), |
| 226 | + String.class |
| 227 | + ); |
| 228 | + } catch (EmptyResultDataAccessException ignored) { |
| 229 | + return null; |
| 230 | + } |
| 231 | + } |
| 232 | + |
| 233 | + /** |
| 234 | + * @author Shkarin John |
| 235 | + */ |
| 236 | + @Override |
| 237 | + public String findPopularCountryInCollection(Integer userId) { |
| 238 | + try { |
| 239 | + return jdbcTemplate.queryForObject( |
| 240 | + findPopularCountryInCollectionSql, |
| 241 | + Collections.singletonMap("user_id", userId), |
| 242 | + String.class |
| 243 | + ); |
| 244 | + } catch (EmptyResultDataAccessException ignored) { |
| 245 | + return null; |
| 246 | + } |
| 247 | + } |
209 | 248 |
|
210 | 249 | } |
0 commit comments