diff options
author | Vitaly Takmazov | 2024-02-09 16:02:43 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2024-02-09 16:02:43 +0300 |
commit | 8289a0b1097f02a99d62f4f7750e6b46a54a54fc (patch) | |
tree | be0e04b409757be58d5a39fbde93ce3d96b02142 /src/main/java/com/juick/service | |
parent | b11525961a8bf68355f3e4728375b209a91f6787 (diff) |
Append IDEA code suggestions
Diffstat (limited to 'src/main/java/com/juick/service')
5 files changed, 8 insertions, 11 deletions
diff --git a/src/main/java/com/juick/service/ChatServiceImpl.java b/src/main/java/com/juick/service/ChatServiceImpl.java index c0d2f17b..4247e49a 100644 --- a/src/main/java/com/juick/service/ChatServiceImpl.java +++ b/src/main/java/com/juick/service/ChatServiceImpl.java @@ -47,7 +47,6 @@ public class ChatServiceImpl extends BaseJdbcService implements ChatService { return getJdbcTemplate().query( "SELECT l.user_id, users.nick, l.last, pm.txt FROM pm " + "INNER JOIN users ON users.id = pm.user_id " - + "" + "INNER JOIN (SELECT user_id, MAX(ts) AS last FROM pm " + "WHERE user_id_to=? GROUP BY user_id) l ON l.last = pm.ts " + "WHERE pm.user_id_to=? " diff --git a/src/main/java/com/juick/service/FileSystemStorageService.java b/src/main/java/com/juick/service/FileSystemStorageService.java index 89669283..c3ec9333 100644 --- a/src/main/java/com/juick/service/FileSystemStorageService.java +++ b/src/main/java/com/juick/service/FileSystemStorageService.java @@ -145,8 +145,7 @@ public class FileSystemStorageService implements StorageService { try { ImageMetadata metadata = Imaging.getMetadata(imageFile); - if (metadata instanceof JpegImageMetadata) { - JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata; + if (metadata instanceof JpegImageMetadata jpegMetadata) { TiffField orientationField = jpegMetadata.findEXIFValue(TiffTagConstants.TIFF_TAG_ORIENTATION); if (orientationField != null) { @@ -228,10 +227,10 @@ public class FileSystemStorageService implements StorageService { String targetExt = "png"; if (ImageIO.write(Scalr.resize(originalImage, 96), targetExt, tmpPath.toFile())) { Files.move(tmpPath, getAvatarPath(user), copyOptions); - }; + } if (ImageIO.write(Scalr.resize(originalImage, 32), targetExt, tmpPath.toFile())) { Files.move(tmpPath, Paths.get(avatarSmallDir, getAvatarFileName(user, targetExt)), copyOptions); - }; + } } public Attachment getAttachment(File imgFile) throws IOException { diff --git a/src/main/java/com/juick/service/InfoService.java b/src/main/java/com/juick/service/InfoService.java index b10e325e..9540243e 100644 --- a/src/main/java/com/juick/service/InfoService.java +++ b/src/main/java/com/juick/service/InfoService.java @@ -58,9 +58,9 @@ public class InfoService { UserStats userStats = new UserStats(); userStats.setTotal(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM users WHERE banned=0", Integer.class)); userStats.setActiveMonth(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM users WHERE banned=0 AND last_seen > ?", - Integer.class, ZonedDateTime.now().minus(1, ChronoUnit.MONTHS).toLocalDateTime())); + Integer.class, ZonedDateTime.now().minusMonths(1).toLocalDateTime())); userStats.setActiveHalfyear(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM users WHERE banned=0 AND last_seen > ?", - Integer.class, ZonedDateTime.now().minus(6, ChronoUnit.MONTHS).toLocalDateTime())); + Integer.class, ZonedDateTime.now().minusMonths(6).toLocalDateTime())); Usage usage = new Usage(); usage.setUsers(userStats); usage.setLocalPosts(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM messages WHERE privacy=1", diff --git a/src/main/java/com/juick/service/StorageService.java b/src/main/java/com/juick/service/StorageService.java index f1f72a60..1574c809 100644 --- a/src/main/java/com/juick/service/StorageService.java +++ b/src/main/java/com/juick/service/StorageService.java @@ -43,9 +43,9 @@ public interface StorageService { */ void saveAvatar(String tempFilename, User user) throws IOException; - public Attachment getAttachment(File imgFile) throws IOException; + Attachment getAttachment(File imgFile) throws IOException; - public Attachment getAvatarMetadata(User user) throws IOException; + Attachment getAvatarMetadata(User user) throws IOException; String getBaseDirectory(); diff --git a/src/main/java/com/juick/service/TelegramServiceImpl.java b/src/main/java/com/juick/service/TelegramServiceImpl.java index 3cd6c27d..3f11a47a 100644 --- a/src/main/java/com/juick/service/TelegramServiceImpl.java +++ b/src/main/java/com/juick/service/TelegramServiceImpl.java @@ -65,8 +65,7 @@ public class TelegramServiceImpl extends BaseJdbcService implements TelegramServ if (uids.isEmpty()) { return Collections.emptyList(); } - return getNamedParameterJdbcTemplate().queryForList("" + - "SELECT tg_id FROM telegram WHERE user_id IN(:uids)", new MapSqlParameterSource() + return getNamedParameterJdbcTemplate().queryForList("SELECT tg_id FROM telegram WHERE user_id IN(:uids)", new MapSqlParameterSource() .addValue("uids", uids), Long.class); } } |