From 273356cd837268053455abc8cabb658358db71cb Mon Sep 17 00:00:00 2001 From: Mark Struchkov Date: Wed, 9 Jan 2019 11:09:00 +0300 Subject: [PATCH] Refactoring: Code Style and Optimize import --- .../org/sadtech/consultant/database/entity/Person.java | 10 ++++------ .../sadtech/consultant/database/entity/SaveUnit.java | 1 - .../org/sadtech/consultant/database/entity/Unit.java | 1 - .../consultant/database/service/PersonService.java | 4 ++++ .../consultant/database/service/UnitService.java | 1 + .../database/service/impl/MessageServiceImpl.java | 1 - .../consultant/processing/MessageLogicService.java | 1 - vk-bot/src/main/java/org/sadtech/vkbot/Main.java | 4 ++-- vk-bot/src/main/java/org/sadtech/vkbot/VkApi.java | 7 ------- .../sadtech/vkbot/handlers/impl/MessageHandlerVk.java | 6 ------ .../main/java/org/sadtech/vkbot/listener/Observer.java | 2 -- .../sadtech/vkbot/listener/impl/EventListenerVk.java | 4 ---- 12 files changed, 11 insertions(+), 31 deletions(-) diff --git a/core/src/main/java/org/sadtech/consultant/database/entity/Person.java b/core/src/main/java/org/sadtech/consultant/database/entity/Person.java index 7ab5275..cf92adf 100644 --- a/core/src/main/java/org/sadtech/consultant/database/entity/Person.java +++ b/core/src/main/java/org/sadtech/consultant/database/entity/Person.java @@ -3,7 +3,8 @@ package org.sadtech.consultant.database.entity; import lombok.Data; import javax.persistence.*; -import java.util.*; +import java.util.HashMap; +import java.util.Map; @Entity @Data @@ -25,11 +26,8 @@ public class Person { private String token; @ElementCollection - @CollectionTable(name="PersonSocialNetworks") - @MapKeyColumn(name="KeysSocialNetworks", length = 20) + @CollectionTable(name = "PersonSocialNetworks") + @MapKeyColumn(name = "KeysSocialNetworks", length = 20) private Map socialNetworks = new HashMap<>(); -// @OneToMany(fetch=FetchType.LAZY, cascade = CascadeType.ALL, mappedBy="idMess") -// private List messages; - } diff --git a/core/src/main/java/org/sadtech/consultant/database/entity/SaveUnit.java b/core/src/main/java/org/sadtech/consultant/database/entity/SaveUnit.java index 68c696c..b5df08e 100644 --- a/core/src/main/java/org/sadtech/consultant/database/entity/SaveUnit.java +++ b/core/src/main/java/org/sadtech/consultant/database/entity/SaveUnit.java @@ -4,7 +4,6 @@ import lombok.Data; import javax.persistence.Entity; import javax.persistence.Id; -import javax.persistence.Table; @Entity @Data diff --git a/core/src/main/java/org/sadtech/consultant/database/entity/Unit.java b/core/src/main/java/org/sadtech/consultant/database/entity/Unit.java index 247df8b..a267686 100644 --- a/core/src/main/java/org/sadtech/consultant/database/entity/Unit.java +++ b/core/src/main/java/org/sadtech/consultant/database/entity/Unit.java @@ -4,7 +4,6 @@ import lombok.Data; import javax.persistence.Entity; import javax.persistence.Id; -import javax.persistence.Table; @Entity @Data diff --git a/core/src/main/java/org/sadtech/consultant/database/service/PersonService.java b/core/src/main/java/org/sadtech/consultant/database/service/PersonService.java index db476ea..0872760 100644 --- a/core/src/main/java/org/sadtech/consultant/database/service/PersonService.java +++ b/core/src/main/java/org/sadtech/consultant/database/service/PersonService.java @@ -7,8 +7,12 @@ import java.util.Map; public interface PersonService { void addUser(Person user); + void removeUser(Long id); + Person getUserByID(Long id); + Map getSocialNetwork(Long id); + Person getUserBySocialNetworksId(String type, Integer socialNetworksId); } diff --git a/core/src/main/java/org/sadtech/consultant/database/service/UnitService.java b/core/src/main/java/org/sadtech/consultant/database/service/UnitService.java index 9de39e8..eafedba 100644 --- a/core/src/main/java/org/sadtech/consultant/database/service/UnitService.java +++ b/core/src/main/java/org/sadtech/consultant/database/service/UnitService.java @@ -5,6 +5,7 @@ import org.sadtech.consultant.database.entity.Unit; public interface UnitService { void addUnit(Unit unit); + void removeUnit(Long id); } diff --git a/core/src/main/java/org/sadtech/consultant/database/service/impl/MessageServiceImpl.java b/core/src/main/java/org/sadtech/consultant/database/service/impl/MessageServiceImpl.java index 284a997..f5d967b 100644 --- a/core/src/main/java/org/sadtech/consultant/database/service/impl/MessageServiceImpl.java +++ b/core/src/main/java/org/sadtech/consultant/database/service/impl/MessageServiceImpl.java @@ -5,7 +5,6 @@ import org.sadtech.consultant.database.repository.MessageRepository; import org.sadtech.consultant.database.service.MessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.List; diff --git a/core/src/main/java/org/sadtech/consultant/processing/MessageLogicService.java b/core/src/main/java/org/sadtech/consultant/processing/MessageLogicService.java index 7b37ba7..1ed910a 100644 --- a/core/src/main/java/org/sadtech/consultant/processing/MessageLogicService.java +++ b/core/src/main/java/org/sadtech/consultant/processing/MessageLogicService.java @@ -1,7 +1,6 @@ package org.sadtech.consultant.processing; import org.sadtech.consultant.database.entity.Message; -import org.sadtech.consultant.database.entity.Person; import org.sadtech.consultant.database.service.MessageService; import org.springframework.stereotype.Component; diff --git a/vk-bot/src/main/java/org/sadtech/vkbot/Main.java b/vk-bot/src/main/java/org/sadtech/vkbot/Main.java index 801fc20..cbddefb 100644 --- a/vk-bot/src/main/java/org/sadtech/vkbot/Main.java +++ b/vk-bot/src/main/java/org/sadtech/vkbot/Main.java @@ -11,8 +11,8 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext public class Main { public static void main(String[] args) throws Exception { - Main main = new Main(); - main.run(); + Main main = new Main(); + main.run(); } public void run() throws Exception { diff --git a/vk-bot/src/main/java/org/sadtech/vkbot/VkApi.java b/vk-bot/src/main/java/org/sadtech/vkbot/VkApi.java index 960820b..2d436c5 100644 --- a/vk-bot/src/main/java/org/sadtech/vkbot/VkApi.java +++ b/vk-bot/src/main/java/org/sadtech/vkbot/VkApi.java @@ -1,21 +1,14 @@ package org.sadtech.vkbot; -import com.google.gson.Gson; import com.vk.api.sdk.client.VkApiClient; import com.vk.api.sdk.client.actors.GroupActor; import com.vk.api.sdk.exceptions.ApiException; import com.vk.api.sdk.exceptions.ClientException; -import com.vk.api.sdk.objects.users.User; -import com.vk.api.sdk.objects.users.UserMin; import com.vk.api.sdk.objects.users.UserXtrCounters; -import com.vk.api.sdk.queries.users.UserField; import lombok.extern.log4j.Log4j; import org.springframework.stereotype.Component; -import java.lang.reflect.Field; -import java.util.HashMap; import java.util.List; -import java.util.Map; @Log4j @Component diff --git a/vk-bot/src/main/java/org/sadtech/vkbot/handlers/impl/MessageHandlerVk.java b/vk-bot/src/main/java/org/sadtech/vkbot/handlers/impl/MessageHandlerVk.java index 04c25ac..936af0e 100644 --- a/vk-bot/src/main/java/org/sadtech/vkbot/handlers/impl/MessageHandlerVk.java +++ b/vk-bot/src/main/java/org/sadtech/vkbot/handlers/impl/MessageHandlerVk.java @@ -3,7 +3,6 @@ package org.sadtech.vkbot.handlers.impl; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.vk.api.sdk.objects.users.UserXtrCounters; -import com.vk.api.sdk.queries.users.UserField; import lombok.extern.log4j.Log4j; import org.sadtech.consultant.database.entity.Message; import org.sadtech.consultant.database.entity.Person; @@ -15,11 +14,6 @@ import org.sadtech.vkbot.listener.Observable; import org.sadtech.vkbot.listener.Observer; import org.springframework.stereotype.Component; -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - @Log4j @Component public class MessageHandlerVk implements Observer { diff --git a/vk-bot/src/main/java/org/sadtech/vkbot/listener/Observer.java b/vk-bot/src/main/java/org/sadtech/vkbot/listener/Observer.java index 57a9b15..cdc652e 100644 --- a/vk-bot/src/main/java/org/sadtech/vkbot/listener/Observer.java +++ b/vk-bot/src/main/java/org/sadtech/vkbot/listener/Observer.java @@ -2,8 +2,6 @@ package org.sadtech.vkbot.listener; import com.google.gson.JsonObject; -import java.util.List; - public interface Observer { void update(JsonObject object); } diff --git a/vk-bot/src/main/java/org/sadtech/vkbot/listener/impl/EventListenerVk.java b/vk-bot/src/main/java/org/sadtech/vkbot/listener/impl/EventListenerVk.java index 3c2cfa5..eb590f9 100644 --- a/vk-bot/src/main/java/org/sadtech/vkbot/listener/impl/EventListenerVk.java +++ b/vk-bot/src/main/java/org/sadtech/vkbot/listener/impl/EventListenerVk.java @@ -9,14 +9,11 @@ import com.vk.api.sdk.exceptions.ApiException; import com.vk.api.sdk.exceptions.ClientException; import com.vk.api.sdk.objects.groups.responses.GetLongPollServerResponse; import lombok.extern.log4j.Log4j; -import org.sadtech.vkbot.VkApi; import org.sadtech.vkbot.listener.EventListenable; import org.sadtech.vkbot.listener.data.ResponsibleData; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; -import java.util.Date; - @Log4j @Component public class EventListenerVk implements EventListenable { @@ -61,5 +58,4 @@ public class EventListenerVk implements EventListenable { } - }