Очистка от лишних файлов

This commit is contained in:
Mark Struchkov 2019-01-09 18:39:51 +03:00
parent 00a964a9fd
commit c0a58e61e1
25 changed files with 0 additions and 531 deletions

65
pom.xml
View File

@ -1,65 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>consultant</artifactId>
<groupId>org.sadtech</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>consultant-core</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<persistence.ver>1.0.2</persistence.ver>
<lombok.ver>1.18.4</lombok.ver>
<log4j>1.2.17</log4j>
<spring.data>2.1.3.RELEASE</spring.data>
</properties>
<dependencies>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>${persistence.ver}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.ver}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${spring.data}</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</project>

View File

@ -1,7 +0,0 @@
package org.sadtech.consultant;
public interface MessageSender {
void send(Integer idNetSoc, String text);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<String, Integer> socialNetworks = new HashMap<>();
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<Mail, Long> {
@Query("SELECT u FROM Mail u WHERE u.date > :date")
Collection<Mail> getMessagesByRange(@Param("date") Long date);
}

View File

@ -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<NextUnit, Long> {
}

View File

@ -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<Person, Long> {
@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);
}

View File

@ -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<SaveUnit, Long> {
}

View File

@ -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<Unit, Long> {
}

View File

@ -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<Mail> getMessageRange(Long date);
}

View File

@ -1,4 +0,0 @@
package org.sadtech.consultant.database.service;
public interface NextUnitService {
}

View File

@ -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<String, Integer> getSocialNetwork(Long id);
Person getUserBySocialNetworksId(String type, Integer socialNetworksId);
}

View File

@ -1,4 +0,0 @@
package org.sadtech.consultant.database.service;
public interface SaveUnitService {
}

View File

@ -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);
}

View File

@ -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<Mail> getMessageRange(Long date) {
return (List<Mail>) repository.getMessagesByRange(date);
}
}

View File

@ -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;
}

View File

@ -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<String, Integer> getSocialNetwork(Long id) {
return repositoriy.getOne(id).getSocialNetworks();
}
@Override
public Person getUserBySocialNetworksId(String type, Integer socialNetworksId) {
return repositoriy.getUserBySocialNetworksId(type, socialNetworksId);
}
}

View File

@ -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;
}

View File

@ -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) {
}
}

View File

@ -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<String, MessageSender> 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<Mail> 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();
}
}
}
}
}

View File

@ -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<Mail> getMessageRange(long data) {
return messageService.getMessageRange(data);
}
}

View File

@ -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);
}
}