Небольшие доработки обработки сообщений
This commit is contained in:
parent
0090ab9034
commit
d42ae014e0
@ -14,6 +14,7 @@ public class Message {
|
||||
private String text;
|
||||
private Long date;
|
||||
private String sourceMessage;
|
||||
private String sex;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "idUser", nullable = false)
|
||||
|
@ -3,8 +3,7 @@ package org.sadtech.consultant.database.entity;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@ -30,4 +29,7 @@ public class Person {
|
||||
@MapKeyColumn(name="KeysSocialNetworks", length = 20)
|
||||
private Map<String, Integer> socialNetworks = new HashMap<>();
|
||||
|
||||
// @OneToMany(fetch=FetchType.LAZY, cascade = CascadeType.ALL, mappedBy="idMess")
|
||||
// private List<Message> messages;
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ 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;
|
||||
|
||||
|
@ -27,9 +27,7 @@ public class MessageHandler {
|
||||
while (true) {
|
||||
List<Message> messages = messageLogicService.getMessageRange(data);
|
||||
for (Message message : messages) {
|
||||
System.out.println(message);
|
||||
|
||||
|
||||
log.info(message);
|
||||
data = message.getDate();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
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;
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
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 {
|
||||
|
||||
@ -13,10 +15,31 @@ public class PersonLogicService {
|
||||
this.personService = userService;
|
||||
}
|
||||
|
||||
public boolean addUser(Person user) {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user