Работа с базой и перемещение файлов

This commit is contained in:
Mark Struchkov 2018-12-31 12:35:16 +03:00
parent f022b2df1a
commit 1a19f1f88d
31 changed files with 99 additions and 93 deletions

View File

@ -1,8 +1,9 @@
package org.sadtech.consultant.entity; package org.sadtech.consultant.database.entity;
import lombok.Data; import lombok.Data;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
@Data @Data
@ -10,9 +11,11 @@ import javax.persistence.Id;
public class Message { public class Message {
@Id @Id
@GeneratedValue
private Long idMess; private Long idMess;
private Long idUser; private Long idUser;
private String text; private String text;
private String date;
} }

View File

@ -1,13 +1,15 @@
package org.sadtech.consultant.entity; package org.sadtech.consultant.database.entity;
import lombok.Data; import lombok.Data;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id;
@Entity @Entity
@Data @Data
public class NextUnit { public class NextUnit {
@Id
private Long id; private Long id;
private Long idNext; private Long idNext;

View File

@ -1,4 +1,4 @@
package org.sadtech.consultant.entity; package org.sadtech.consultant.database.entity;
import lombok.Data; import lombok.Data;

View File

@ -1,4 +1,4 @@
package org.sadtech.consultant.entity; package org.sadtech.consultant.database.entity;
import lombok.Data; import lombok.Data;

View File

@ -1,4 +1,4 @@
package org.sadtech.consultant.entity; package org.sadtech.consultant.database.entity;
import lombok.Data; import lombok.Data;

View File

@ -1,9 +1,8 @@
package org.sadtech.consultant.entity; package org.sadtech.consultant.database.entity;
import lombok.Data; import lombok.Data;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import java.util.List; import java.util.List;
@ -17,7 +16,7 @@ public class User {
private String token; private String token;
private String lastName; private String lastName;
private String city; private String city;
private List<SocialNetworks> socialNetworks; // private List<SocialNetworks> socialNetworks;
} }

View File

@ -1,6 +1,6 @@
package org.sadtech.consultant.repository; package org.sadtech.consultant.database.repository;
import org.sadtech.consultant.entity.Message; import org.sadtech.consultant.database.entity.Message;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
public interface MessageRepository extends JpaRepository<Message, Long> { public interface MessageRepository extends JpaRepository<Message, Long> {

View File

@ -1,6 +1,6 @@
package org.sadtech.consultant.repository; package org.sadtech.consultant.database.repository;
import org.sadtech.consultant.entity.NextUnit; import org.sadtech.consultant.database.entity.NextUnit;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
public interface NextUnitRepositoriy extends JpaRepository<NextUnit, Long> { public interface NextUnitRepositoriy extends JpaRepository<NextUnit, Long> {

View File

@ -1,6 +1,6 @@
package org.sadtech.consultant.repository; package org.sadtech.consultant.database.repository;
import org.sadtech.consultant.entity.SaveUnit; import org.sadtech.consultant.database.entity.SaveUnit;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
public interface SaveUnitRepositoriy extends JpaRepository<SaveUnit, Long> { public interface SaveUnitRepositoriy extends JpaRepository<SaveUnit, Long> {

View File

@ -1,6 +1,6 @@
package org.sadtech.consultant.repository; package org.sadtech.consultant.database.repository;
import org.sadtech.consultant.entity.SocialNetworks; import org.sadtech.consultant.database.entity.SocialNetworks;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
public interface SocialNetworksRepositoriy extends JpaRepository<SocialNetworks, Long> { public interface SocialNetworksRepositoriy extends JpaRepository<SocialNetworks, Long> {

View File

@ -1,6 +1,6 @@
package org.sadtech.consultant.repository; package org.sadtech.consultant.database.repository;
import org.sadtech.consultant.entity.Unit; import org.sadtech.consultant.database.entity.Unit;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
public interface UnitRepositoriy extends JpaRepository<Unit, Long> { public interface UnitRepositoriy extends JpaRepository<Unit, Long> {

View File

@ -1,6 +1,6 @@
package org.sadtech.consultant.repository; package org.sadtech.consultant.database.repository;
import org.sadtech.consultant.entity.User; import org.sadtech.consultant.database.entity.User;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
public interface UserRepositoriy extends JpaRepository<User, Long> { public interface UserRepositoriy extends JpaRepository<User, Long> {

View File

@ -0,0 +1,8 @@
package org.sadtech.consultant.database.service;
import org.sadtech.consultant.database.entity.Message;
public interface MessageService {
void addMessage(Message message);
}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,10 @@
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

@ -0,0 +1,10 @@
package org.sadtech.consultant.database.service;
import org.sadtech.consultant.database.entity.User;
public interface UserService {
void addUser(User user);
void removeUser(Long id);
}

View File

@ -0,0 +1,18 @@
package org.sadtech.consultant.database.service.impl;
import org.sadtech.consultant.database.entity.Message;
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;
@Service
public class MessageServiceImpl implements MessageService {
@Autowired
private MessageRepository repository;
public void addMessage(Message message) {
repository.saveAndFlush(message);
}
}

View File

@ -1,7 +1,7 @@
package org.sadtech.consultant.service.impl; package org.sadtech.consultant.database.service.impl;
import org.sadtech.consultant.repository.NextUnitRepositoriy; import org.sadtech.consultant.database.repository.NextUnitRepositoriy;
import org.sadtech.consultant.service.NextUnitService; import org.sadtech.consultant.database.service.NextUnitService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,7 +1,7 @@
package org.sadtech.consultant.service.impl; package org.sadtech.consultant.database.service.impl;
import org.sadtech.consultant.repository.SaveUnitRepositoriy; import org.sadtech.consultant.database.repository.SaveUnitRepositoriy;
import org.sadtech.consultant.service.SaveUnitService; import org.sadtech.consultant.database.service.SaveUnitService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,7 +1,7 @@
package org.sadtech.consultant.service.impl; package org.sadtech.consultant.database.service.impl;
import org.sadtech.consultant.repository.SocialNetworksRepositoriy; import org.sadtech.consultant.database.repository.SocialNetworksRepositoriy;
import org.sadtech.consultant.service.SocialNetworksService; import org.sadtech.consultant.database.service.SocialNetworksService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,8 +1,8 @@
package org.sadtech.consultant.service.impl; package org.sadtech.consultant.database.service.impl;
import org.sadtech.consultant.entity.Unit; import org.sadtech.consultant.database.entity.Unit;
import org.sadtech.consultant.repository.UnitRepositoriy; import org.sadtech.consultant.database.repository.UnitRepositoriy;
import org.sadtech.consultant.service.UnitService; import org.sadtech.consultant.database.service.UnitService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,8 +1,8 @@
package org.sadtech.consultant.service.impl; package org.sadtech.consultant.database.service.impl;
import org.sadtech.consultant.entity.User; import org.sadtech.consultant.database.entity.User;
import org.sadtech.consultant.repository.UserRepositoriy; import org.sadtech.consultant.database.repository.UserRepositoriy;
import org.sadtech.consultant.service.UserService; import org.sadtech.consultant.database.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,8 +0,0 @@
package org.sadtech.consultant.service;
import org.sadtech.consultant.entity.Message;
public interface MessageService {
void addMessage(Message message);
}

View File

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

View File

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

View File

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

View File

@ -1,10 +0,0 @@
package org.sadtech.consultant.service;
import org.sadtech.consultant.entity.Unit;
public interface UnitService {
void addUnit(Unit unit);
void removeUnit(Long id);
}

View File

@ -1,10 +0,0 @@
package org.sadtech.consultant.service;
import org.sadtech.consultant.entity.User;
public interface UserService {
void addUser(User user);
void removeUser(Long id);
}

View File

@ -1,16 +0,0 @@
package org.sadtech.consultant.service.impl;
import org.sadtech.consultant.entity.Message;
import org.sadtech.consultant.repository.MessageRepository;
import org.sadtech.consultant.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
public class MessageServiceImpl implements MessageService {
@Autowired
private MessageRepository repository;
public void addMessage(Message message) {
repository.saveAndFlush(message);
}
}