From c0a58e61e1f4b39207a135ed26e0b6560dfba9b4 Mon Sep 17 00:00:00 2001 From: Mark Struchkov Date: Wed, 9 Jan 2019 18:39:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BE=D1=82=20=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D1=85=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 65 ------------------- .../org/sadtech/consultant/MessageSender.java | 7 -- .../consultant/database/entity/Mail.java | 23 ------- .../consultant/database/entity/NextUnit.java | 17 ----- .../consultant/database/entity/Person.java | 36 ---------- .../consultant/database/entity/SaveUnit.java | 19 ------ .../consultant/database/entity/Unit.java | 17 ----- .../database/repository/MailRepository.java | 15 ----- .../repository/NextUnitRepository.java | 9 --- .../database/repository/PersonRepository.java | 13 ---- .../repository/SaveUnitRepositoriy.java | 7 -- .../database/repository/UnitRepositoriy.java | 7 -- .../database/service/MailService.java | 12 ---- .../database/service/NextUnitService.java | 4 -- .../database/service/PersonService.java | 18 ----- .../database/service/SaveUnitService.java | 4 -- .../database/service/UnitService.java | 11 ---- .../service/impl/MailServiceImpl.java | 25 ------- .../service/impl/NextUnitServiceImpl.java | 14 ---- .../service/impl/PersonServiceImpl.java | 41 ------------ .../service/impl/SaveUnitServiceImpl.java | 14 ---- .../service/impl/UnitServiceImpl.java | 22 ------- .../consultant/processing/MessageHandler.java | 54 --------------- .../processing/MessageLogicService.java | 25 ------- .../processing/PersonLogicService.java | 52 --------------- 25 files changed, 531 deletions(-) delete mode 100644 pom.xml delete mode 100644 src/main/java/org/sadtech/consultant/MessageSender.java delete mode 100644 src/main/java/org/sadtech/consultant/database/entity/Mail.java delete mode 100644 src/main/java/org/sadtech/consultant/database/entity/NextUnit.java delete mode 100644 src/main/java/org/sadtech/consultant/database/entity/Person.java delete mode 100644 src/main/java/org/sadtech/consultant/database/entity/SaveUnit.java delete mode 100644 src/main/java/org/sadtech/consultant/database/entity/Unit.java delete mode 100644 src/main/java/org/sadtech/consultant/database/repository/MailRepository.java delete mode 100644 src/main/java/org/sadtech/consultant/database/repository/NextUnitRepository.java delete mode 100644 src/main/java/org/sadtech/consultant/database/repository/PersonRepository.java delete mode 100644 src/main/java/org/sadtech/consultant/database/repository/SaveUnitRepositoriy.java delete mode 100644 src/main/java/org/sadtech/consultant/database/repository/UnitRepositoriy.java delete mode 100644 src/main/java/org/sadtech/consultant/database/service/MailService.java delete mode 100644 src/main/java/org/sadtech/consultant/database/service/NextUnitService.java delete mode 100644 src/main/java/org/sadtech/consultant/database/service/PersonService.java delete mode 100644 src/main/java/org/sadtech/consultant/database/service/SaveUnitService.java delete mode 100644 src/main/java/org/sadtech/consultant/database/service/UnitService.java delete mode 100644 src/main/java/org/sadtech/consultant/database/service/impl/MailServiceImpl.java delete mode 100644 src/main/java/org/sadtech/consultant/database/service/impl/NextUnitServiceImpl.java delete mode 100644 src/main/java/org/sadtech/consultant/database/service/impl/PersonServiceImpl.java delete mode 100644 src/main/java/org/sadtech/consultant/database/service/impl/SaveUnitServiceImpl.java delete mode 100644 src/main/java/org/sadtech/consultant/database/service/impl/UnitServiceImpl.java delete mode 100644 src/main/java/org/sadtech/consultant/processing/MessageHandler.java delete mode 100644 src/main/java/org/sadtech/consultant/processing/MessageLogicService.java delete mode 100644 src/main/java/org/sadtech/consultant/processing/PersonLogicService.java diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 4a34740..0000000 --- a/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - consultant - org.sadtech - 1.0-SNAPSHOT - - 4.0.0 - - consultant-core - - - - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - - - - - - - 1.0.2 - 1.18.4 - 1.2.17 - - 2.1.3.RELEASE - - - - - javax.persistence - persistence-api - ${persistence.ver} - - - - org.projectlombok - lombok - ${lombok.ver} - - - - log4j - log4j - ${log4j} - - - - org.springframework.data - spring-data-jpa - ${spring.data} - - - javax.persistence - javax.persistence-api - 2.2 - - - - \ No newline at end of file diff --git a/src/main/java/org/sadtech/consultant/MessageSender.java b/src/main/java/org/sadtech/consultant/MessageSender.java deleted file mode 100644 index 75ba12e..0000000 --- a/src/main/java/org/sadtech/consultant/MessageSender.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.sadtech.consultant; - -public interface MessageSender { - - void send(Integer idNetSoc, String text); - -} diff --git a/src/main/java/org/sadtech/consultant/database/entity/Mail.java b/src/main/java/org/sadtech/consultant/database/entity/Mail.java deleted file mode 100644 index 5ba4490..0000000 --- a/src/main/java/org/sadtech/consultant/database/entity/Mail.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.sadtech.consultant.database.entity; - -import lombok.Data; - -import javax.persistence.*; - -@Data -@Entity -public class Mail { - - @Id - @GeneratedValue - private Long idMess; - private String text; - private Long date; - private String sourceMessage; - - @ManyToOne - @JoinColumn(name = "idPerson", nullable = false) - private Person person; - - -} diff --git a/src/main/java/org/sadtech/consultant/database/entity/NextUnit.java b/src/main/java/org/sadtech/consultant/database/entity/NextUnit.java deleted file mode 100644 index 5e896fe..0000000 --- a/src/main/java/org/sadtech/consultant/database/entity/NextUnit.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.sadtech.consultant.database.entity; - -import lombok.Data; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Data -public class NextUnit { - - @Id - private Long id; - private Long idNext; - -} diff --git a/src/main/java/org/sadtech/consultant/database/entity/Person.java b/src/main/java/org/sadtech/consultant/database/entity/Person.java deleted file mode 100644 index 847e228..0000000 --- a/src/main/java/org/sadtech/consultant/database/entity/Person.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.sadtech.consultant.database.entity; - -import lombok.Data; - -import javax.persistence.*; -import java.util.HashMap; -import java.util.Map; - -@Entity -@Data -public class Person { - - @Id - @GeneratedValue - private Long id; - - @Column(length = 20) - private String name; - - @Column(length = 20) - private String lastName; - - @Column(length = 20) - private String city; - - private String token; - private String email; - - @ElementCollection - @CollectionTable(name = "PersonSocialNetworks") - @MapKeyColumn(name = "KeysSocialNetworks", length = 20) - private Map socialNetworks = new HashMap<>(); - - - -} diff --git a/src/main/java/org/sadtech/consultant/database/entity/SaveUnit.java b/src/main/java/org/sadtech/consultant/database/entity/SaveUnit.java deleted file mode 100644 index d198992..0000000 --- a/src/main/java/org/sadtech/consultant/database/entity/SaveUnit.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.sadtech.consultant.database.entity; - -import lombok.Data; - -import javax.persistence.*; - -@Entity -@Data -public class SaveUnit { - - @Id - private Long id; - private Long idStage; - - @OneToOne - @JoinColumn(name = "idPerson", nullable = false) - private Person user; - -} diff --git a/src/main/java/org/sadtech/consultant/database/entity/Unit.java b/src/main/java/org/sadtech/consultant/database/entity/Unit.java deleted file mode 100644 index a267686..0000000 --- a/src/main/java/org/sadtech/consultant/database/entity/Unit.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.sadtech.consultant.database.entity; - -import lombok.Data; - -import javax.persistence.Entity; -import javax.persistence.Id; - -@Entity -@Data -public class Unit { - - @Id - private Long id; - private String text; - private String wordKeys; - -} diff --git a/src/main/java/org/sadtech/consultant/database/repository/MailRepository.java b/src/main/java/org/sadtech/consultant/database/repository/MailRepository.java deleted file mode 100644 index 8e5541c..0000000 --- a/src/main/java/org/sadtech/consultant/database/repository/MailRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.sadtech.consultant.database.repository; - -import org.sadtech.consultant.database.entity.Mail; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; - -import java.util.Collection; - -public interface MailRepository extends JpaRepository { - - @Query("SELECT u FROM Mail u WHERE u.date > :date") - Collection getMessagesByRange(@Param("date") Long date); - -} diff --git a/src/main/java/org/sadtech/consultant/database/repository/NextUnitRepository.java b/src/main/java/org/sadtech/consultant/database/repository/NextUnitRepository.java deleted file mode 100644 index 3f3f71f..0000000 --- a/src/main/java/org/sadtech/consultant/database/repository/NextUnitRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.sadtech.consultant.database.repository; - -import org.sadtech.consultant.database.entity.NextUnit; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface NextUnitRepository extends JpaRepository { - - -} diff --git a/src/main/java/org/sadtech/consultant/database/repository/PersonRepository.java b/src/main/java/org/sadtech/consultant/database/repository/PersonRepository.java deleted file mode 100644 index a00fa83..0000000 --- a/src/main/java/org/sadtech/consultant/database/repository/PersonRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.sadtech.consultant.database.repository; - -import org.sadtech.consultant.database.entity.Person; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; - -public interface PersonRepository extends JpaRepository { - - @Query("SELECT u FROM Person u INNER JOIN u.socialNetworks p WHERE KEY(p) = :type2 AND VALUE(p) = :socialId") - Person getUserBySocialNetworksId(@Param("type2") String type, @Param("socialId") Integer socialNetworksId); - -} diff --git a/src/main/java/org/sadtech/consultant/database/repository/SaveUnitRepositoriy.java b/src/main/java/org/sadtech/consultant/database/repository/SaveUnitRepositoriy.java deleted file mode 100644 index 7ff8077..0000000 --- a/src/main/java/org/sadtech/consultant/database/repository/SaveUnitRepositoriy.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.sadtech.consultant.database.repository; - -import org.sadtech.consultant.database.entity.SaveUnit; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface SaveUnitRepositoriy extends JpaRepository { -} diff --git a/src/main/java/org/sadtech/consultant/database/repository/UnitRepositoriy.java b/src/main/java/org/sadtech/consultant/database/repository/UnitRepositoriy.java deleted file mode 100644 index 51e7cca..0000000 --- a/src/main/java/org/sadtech/consultant/database/repository/UnitRepositoriy.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.sadtech.consultant.database.repository; - -import org.sadtech.consultant.database.entity.Unit; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface UnitRepositoriy extends JpaRepository { -} diff --git a/src/main/java/org/sadtech/consultant/database/service/MailService.java b/src/main/java/org/sadtech/consultant/database/service/MailService.java deleted file mode 100644 index 1ca820b..0000000 --- a/src/main/java/org/sadtech/consultant/database/service/MailService.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.sadtech.consultant.database.service; - -import org.sadtech.consultant.database.entity.Mail; - -import java.util.List; - -public interface MailService { - - void addMessage(Mail message); - - List getMessageRange(Long date); -} diff --git a/src/main/java/org/sadtech/consultant/database/service/NextUnitService.java b/src/main/java/org/sadtech/consultant/database/service/NextUnitService.java deleted file mode 100644 index 0106520..0000000 --- a/src/main/java/org/sadtech/consultant/database/service/NextUnitService.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.sadtech.consultant.database.service; - -public interface NextUnitService { -} diff --git a/src/main/java/org/sadtech/consultant/database/service/PersonService.java b/src/main/java/org/sadtech/consultant/database/service/PersonService.java deleted file mode 100644 index 0872760..0000000 --- a/src/main/java/org/sadtech/consultant/database/service/PersonService.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.sadtech.consultant.database.service; - -import org.sadtech.consultant.database.entity.Person; - -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/src/main/java/org/sadtech/consultant/database/service/SaveUnitService.java b/src/main/java/org/sadtech/consultant/database/service/SaveUnitService.java deleted file mode 100644 index 74250ae..0000000 --- a/src/main/java/org/sadtech/consultant/database/service/SaveUnitService.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.sadtech.consultant.database.service; - -public interface SaveUnitService { -} diff --git a/src/main/java/org/sadtech/consultant/database/service/UnitService.java b/src/main/java/org/sadtech/consultant/database/service/UnitService.java deleted file mode 100644 index eafedba..0000000 --- a/src/main/java/org/sadtech/consultant/database/service/UnitService.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.sadtech.consultant.database.service; - -import org.sadtech.consultant.database.entity.Unit; - -public interface UnitService { - - void addUnit(Unit unit); - - void removeUnit(Long id); - -} diff --git a/src/main/java/org/sadtech/consultant/database/service/impl/MailServiceImpl.java b/src/main/java/org/sadtech/consultant/database/service/impl/MailServiceImpl.java deleted file mode 100644 index 6432031..0000000 --- a/src/main/java/org/sadtech/consultant/database/service/impl/MailServiceImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.sadtech.consultant.database.service.impl; - -import org.sadtech.consultant.database.entity.Mail; -import org.sadtech.consultant.database.repository.MailRepository; -import org.sadtech.consultant.database.service.MailService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -public class MailServiceImpl implements MailService { - - @Autowired - private MailRepository repository; - - public void addMessage(Mail message) { - repository.saveAndFlush(message); - } - - @Override - public List getMessageRange(Long date) { - return (List) repository.getMessagesByRange(date); - } -} diff --git a/src/main/java/org/sadtech/consultant/database/service/impl/NextUnitServiceImpl.java b/src/main/java/org/sadtech/consultant/database/service/impl/NextUnitServiceImpl.java deleted file mode 100644 index 1e93a0f..0000000 --- a/src/main/java/org/sadtech/consultant/database/service/impl/NextUnitServiceImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.sadtech.consultant.database.service.impl; - -import org.sadtech.consultant.database.repository.NextUnitRepository; -import org.sadtech.consultant.database.service.NextUnitService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class NextUnitServiceImpl implements NextUnitService { - - @Autowired - private NextUnitRepository repository; - -} diff --git a/src/main/java/org/sadtech/consultant/database/service/impl/PersonServiceImpl.java b/src/main/java/org/sadtech/consultant/database/service/impl/PersonServiceImpl.java deleted file mode 100644 index 936d0d8..0000000 --- a/src/main/java/org/sadtech/consultant/database/service/impl/PersonServiceImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.sadtech.consultant.database.service.impl; - -import org.sadtech.consultant.database.repository.PersonRepository; -import org.sadtech.consultant.database.entity.Person; -import org.sadtech.consultant.database.service.PersonService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Map; - -@Service -public class PersonServiceImpl implements PersonService { - - @Autowired - private PersonRepository repositoriy; - - @Override - public void addUser(Person user) { - repositoriy.saveAndFlush(user); - } - - @Override - public void removeUser(Long id) { - repositoriy.deleteById(id); - } - - @Override - public Person getUserByID(Long id) { - return repositoriy.getOne(id); - } - - @Override - public Map getSocialNetwork(Long id) { - return repositoriy.getOne(id).getSocialNetworks(); - } - - @Override - public Person getUserBySocialNetworksId(String type, Integer socialNetworksId) { - return repositoriy.getUserBySocialNetworksId(type, socialNetworksId); - } -} diff --git a/src/main/java/org/sadtech/consultant/database/service/impl/SaveUnitServiceImpl.java b/src/main/java/org/sadtech/consultant/database/service/impl/SaveUnitServiceImpl.java deleted file mode 100644 index 2524815..0000000 --- a/src/main/java/org/sadtech/consultant/database/service/impl/SaveUnitServiceImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.sadtech.consultant.database.service.impl; - -import org.sadtech.consultant.database.repository.SaveUnitRepositoriy; -import org.sadtech.consultant.database.service.SaveUnitService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class SaveUnitServiceImpl implements SaveUnitService { - - @Autowired - private SaveUnitRepositoriy repositoriy; - -} diff --git a/src/main/java/org/sadtech/consultant/database/service/impl/UnitServiceImpl.java b/src/main/java/org/sadtech/consultant/database/service/impl/UnitServiceImpl.java deleted file mode 100644 index eeec2d8..0000000 --- a/src/main/java/org/sadtech/consultant/database/service/impl/UnitServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.sadtech.consultant.database.service.impl; - -import org.sadtech.consultant.database.repository.UnitRepositoriy; -import org.sadtech.consultant.database.entity.Unit; -import org.sadtech.consultant.database.service.UnitService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class UnitServiceImpl implements UnitService { - - @Autowired - private UnitRepositoriy repositoriy; - - public void addUnit(Unit unit) { - repositoriy.saveAndFlush(unit); - } - - public void removeUnit(Long id) { - - } -} diff --git a/src/main/java/org/sadtech/consultant/processing/MessageHandler.java b/src/main/java/org/sadtech/consultant/processing/MessageHandler.java deleted file mode 100644 index d513930..0000000 --- a/src/main/java/org/sadtech/consultant/processing/MessageHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.sadtech.consultant.processing; - -import lombok.extern.log4j.Log4j; -import org.sadtech.consultant.database.entity.Mail; -import org.sadtech.consultant.MessageSender; -import org.sadtech.consultant.database.entity.Person; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Log4j -@Component -public class MessageHandler { - - private MessageLogicService messageLogicService; - private PersonLogicService userLogicService; - private Map senderHashMap = new HashMap<>(); - private long data; - - public MessageHandler(MessageLogicService messageLogicService, PersonLogicService userLogicService) { - this.messageLogicService = messageLogicService; - this.userLogicService = userLogicService; - data = new Date().getTime() / 1000; - } - - public void addMessageSendler(String type, MessageSender messageSender) { - senderHashMap.put(type, messageSender); - } - - @Async - @Transactional - public void processing() { - log.info("process"); - while (true) { - List messages = messageLogicService.getMessageRange(data); - if (messages.size()>0) { - for (Mail message : messages) { - log.info(message); - Person person = message.getPerson(); - Integer idNetSoc = person.getSocialNetworks().get(message.getSourceMessage()); - senderHashMap.get(message.getSourceMessage()).send(idNetSoc, "Тестовое сообщение"); - - data = message.getDate(); - } - } - } - } - -} diff --git a/src/main/java/org/sadtech/consultant/processing/MessageLogicService.java b/src/main/java/org/sadtech/consultant/processing/MessageLogicService.java deleted file mode 100644 index 3eb2be4..0000000 --- a/src/main/java/org/sadtech/consultant/processing/MessageLogicService.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.sadtech.consultant.processing; - -import org.sadtech.consultant.database.entity.Mail; -import org.sadtech.consultant.database.service.MailService; -import org.springframework.stereotype.Component; - -import java.util.List; - -@Component -public class MessageLogicService { - - private MailService messageService; - - public MessageLogicService(MailService messageService) { - this.messageService = messageService; - } - - public void addMessage(Mail message) { - messageService.addMessage(message); - } - - public List getMessageRange(long data) { - return messageService.getMessageRange(data); - } -} diff --git a/src/main/java/org/sadtech/consultant/processing/PersonLogicService.java b/src/main/java/org/sadtech/consultant/processing/PersonLogicService.java deleted file mode 100644 index 4da66f7..0000000 --- a/src/main/java/org/sadtech/consultant/processing/PersonLogicService.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.sadtech.consultant.processing; - -import lombok.extern.log4j.Log4j; -import org.sadtech.consultant.database.entity.Person; -import org.sadtech.consultant.database.service.PersonService; -import org.springframework.stereotype.Component; - -@Log4j -@Component -public class PersonLogicService { - - private PersonService personService; - - public PersonLogicService(PersonService userService) { - this.personService = userService; - } - - public void addUser(Person user) { - personService.addUser(user); - log.info("Пользователь добавлен в бд"); - } - - public boolean checkPersonBySocialNetworksId(String socType, Integer socId) { - Person checkPerson = personService.getUserBySocialNetworksId(socType, socId); - if (checkPerson != null) { - log.info("Пользователь уже есть в бд"); - return true; - } - log.info("Пользователя нет в бд"); - return false; - } - - public Person getPersonBySocialNetworksId(Person person) { - for (String key : person.getSocialNetworks().keySet()) { - Person getPerson = personService.getUserBySocialNetworksId(key, person.getSocialNetworks().get(key)); - if (getPerson != null) { - log.info("Пользователь уже есть в бд"); - return getPerson; - } - } - return null; - } - - public Person getUserById(Long id) { - return personService.getUserByID(id); - } - - public Person getUserBySocialId(String type, Integer id) { - return personService.getUserBySocialNetworksId(type, id); - } - -}