From d8051da5ee7d14a98de05b46546b6f8a4ade3cef Mon Sep 17 00:00:00 2001 From: gsd Date: Tue, 4 Feb 2025 19:14:15 +0300 Subject: [PATCH] kamaz fix 4 --- src/main/java/app/services/db/PermitionService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/app/services/db/PermitionService.java b/src/main/java/app/services/db/PermitionService.java index d143d00..689a813 100644 --- a/src/main/java/app/services/db/PermitionService.java +++ b/src/main/java/app/services/db/PermitionService.java @@ -3,6 +3,8 @@ package app.services.db; import app.entities.db.AdminInfo; import app.entities.db.Permition; import app.entities.other.SteamID; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jdbc.core.JdbcTemplate; @@ -22,6 +24,8 @@ public class PermitionService { @Qualifier("jt_rw") JdbcTemplate jdbcTemplate; + private final Logger logger = LoggerFactory.getLogger(PermitionService.class); + public Permition getPermition(SteamID steamID){ return jdbcTemplate.query("SELECT id, flags, immunity, status, amount, extract(epoch from reg_date) as utime FROM sm_admins WHERE identity LIKE ?", new Object[]{steamID.steam2}, @@ -40,19 +44,22 @@ public class PermitionService { public int addPermition(SteamID steamID, Integer amount, String flags, Integer immunity_level, String status, String comment) { if (getPermition(steamID) != null) return 0; + logger.info("Add new permition to {} with amount: {}", steamID.steam2, amount); return jdbcTemplate.update("INSERT INTO sm_admins (authtype, identity, password, flags, name, immunity, comment, status, reg_date, amount) VALUES ('steam', ?, NULL, ?, '', ?, ?, ?, CURRENT_TIMESTAMP, ?)", steamID.steam2, flags, immunity_level, comment, status, amount); } public boolean removePermition(SteamID steamID, String status) { if (getPermition(steamID) == null) return true; + logger.info("Remove permition with: {}", steamID.steam2); return jdbcTemplate.update("DELETE FROM sm_admins WHERE identity = ? AND status LIKE ?", steamID.steam2, status) > 0; } public int extendPermition(SteamID steamID, Integer amount, String status, Long previousTimestamp) { - return jdbcTemplate.update("UPDATE sm_admins SET amount=amount+?, reg_date = ? WHERE identity LIKE ? AND status LIKE ?", - amount, Timestamp.from(Instant.ofEpochSecond(previousTimestamp)), steamID.steam2, status); + logger.info("Extend permition to {} on amount {}", steamID.steam2, amount); + return jdbcTemplate.update("UPDATE sm_admins SET amount=amount+? WHERE identity LIKE ? AND status LIKE ?", + amount, steamID.steam2, status); } public int addFreeVIP(SteamID steamID, Integer amount) {