From d5236a30e4702b9f92f267e96dbd8ee6c2019ce4 Mon Sep 17 00:00:00 2001 From: Mark Struchkov Date: Sun, 23 Dec 2018 03:34:18 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB=20ORM=20?= =?UTF-8?q?=D0=BE=D1=81=D0=BD=D0=BE=D0=B2=D1=83=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BE=D1=81=D0=BD=D0=BE=D0=B2=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D1=83=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 15 +++++++++++++ .../org/sadtech/consultant/dao/NextStage.java | 14 ------------ .../sadtech/consultant/entity/NextUnit.java | 14 ++++++++++++ .../SaveStage.java => entity/SaveUnit.java} | 8 +++---- .../{dao => entity}/SocialNetworks.java | 9 ++++---- .../{dao/Stage.java => entity/Unit.java} | 6 ++--- .../consultant/{dao => entity}/User.java | 5 ++--- .../repository/NextUnitRepositoriy.java | 10 +++++++++ .../repository/SaveUnitRepositoriy.java | 7 ++++++ .../repository/SocialNetworksRepositoriy.java | 7 ++++++ .../repository/UnitRepositoriy.java | 7 ++++++ .../repository/UserRepositoriy.java | 8 +++++++ .../consultant/service/NextUnitService.java | 4 ++++ .../consultant/service/SaveUnitService.java | 4 ++++ .../service/SocialNetworksService.java | 4 ++++ .../consultant/service/UnitService.java | 10 +++++++++ .../consultant/service/UserService.java | 10 +++++++++ .../service/impl/NextUnitServiceImpl.java | 14 ++++++++++++ .../service/impl/SaveUnitServiceImpl.java | 14 ++++++++++++ .../impl/SocialNetworksServiceImpl.java | 14 ++++++++++++ .../service/impl/UnitServiceImpl.java | 22 +++++++++++++++++++ .../service/impl/UserServiceImpl.java | 22 +++++++++++++++++++ 22 files changed, 199 insertions(+), 29 deletions(-) delete mode 100644 src/main/java/org/sadtech/consultant/dao/NextStage.java create mode 100644 src/main/java/org/sadtech/consultant/entity/NextUnit.java rename src/main/java/org/sadtech/consultant/{dao/SaveStage.java => entity/SaveUnit.java} (50%) rename src/main/java/org/sadtech/consultant/{dao => entity}/SocialNetworks.java (51%) rename src/main/java/org/sadtech/consultant/{dao/Stage.java => entity/Unit.java} (67%) rename src/main/java/org/sadtech/consultant/{dao => entity}/User.java (81%) create mode 100644 src/main/java/org/sadtech/consultant/repository/NextUnitRepositoriy.java create mode 100644 src/main/java/org/sadtech/consultant/repository/SaveUnitRepositoriy.java create mode 100644 src/main/java/org/sadtech/consultant/repository/SocialNetworksRepositoriy.java create mode 100644 src/main/java/org/sadtech/consultant/repository/UnitRepositoriy.java create mode 100644 src/main/java/org/sadtech/consultant/repository/UserRepositoriy.java create mode 100644 src/main/java/org/sadtech/consultant/service/NextUnitService.java create mode 100644 src/main/java/org/sadtech/consultant/service/SaveUnitService.java create mode 100644 src/main/java/org/sadtech/consultant/service/SocialNetworksService.java create mode 100644 src/main/java/org/sadtech/consultant/service/UnitService.java create mode 100644 src/main/java/org/sadtech/consultant/service/UserService.java create mode 100644 src/main/java/org/sadtech/consultant/service/impl/NextUnitServiceImpl.java create mode 100644 src/main/java/org/sadtech/consultant/service/impl/SaveUnitServiceImpl.java create mode 100644 src/main/java/org/sadtech/consultant/service/impl/SocialNetworksServiceImpl.java create mode 100644 src/main/java/org/sadtech/consultant/service/impl/UnitServiceImpl.java create mode 100644 src/main/java/org/sadtech/consultant/service/impl/UserServiceImpl.java diff --git a/pom.xml b/pom.xml index b500633..5e55758 100644 --- a/pom.xml +++ b/pom.xml @@ -14,6 +14,9 @@ 1.0.2 1.18.4 + 1.2.17 + + 2.1.3.RELEASE @@ -28,6 +31,18 @@ lombok ${lombok.ver} + + + log4j + log4j + ${log4j} + + + + org.springframework.data + spring-data-jpa + ${spring.data} + \ No newline at end of file diff --git a/src/main/java/org/sadtech/consultant/dao/NextStage.java b/src/main/java/org/sadtech/consultant/dao/NextStage.java deleted file mode 100644 index 9a7947d..0000000 --- a/src/main/java/org/sadtech/consultant/dao/NextStage.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.sadtech.consultant.dao; - -import lombok.Data; - -import javax.persistence.Entity; - -@Entity -@Data -public class NextStage { - - private long id; - private long idNext; - -} diff --git a/src/main/java/org/sadtech/consultant/entity/NextUnit.java b/src/main/java/org/sadtech/consultant/entity/NextUnit.java new file mode 100644 index 0000000..922cd20 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/entity/NextUnit.java @@ -0,0 +1,14 @@ +package org.sadtech.consultant.entity; + +import lombok.Data; + +import javax.persistence.Entity; + +@Entity +@Data +public class NextUnit { + + private Long id; + private Long idNext; + +} diff --git a/src/main/java/org/sadtech/consultant/dao/SaveStage.java b/src/main/java/org/sadtech/consultant/entity/SaveUnit.java similarity index 50% rename from src/main/java/org/sadtech/consultant/dao/SaveStage.java rename to src/main/java/org/sadtech/consultant/entity/SaveUnit.java index c80e35e..8e7a447 100644 --- a/src/main/java/org/sadtech/consultant/dao/SaveStage.java +++ b/src/main/java/org/sadtech/consultant/entity/SaveUnit.java @@ -1,4 +1,4 @@ -package org.sadtech.consultant.dao; +package org.sadtech.consultant.entity; import lombok.Data; @@ -7,10 +7,10 @@ import javax.persistence.Id; @Entity @Data -public class SaveStage { +public class SaveUnit { @Id - private long id; - private long idStage; + private Long id; + private Long idStage; } diff --git a/src/main/java/org/sadtech/consultant/dao/SocialNetworks.java b/src/main/java/org/sadtech/consultant/entity/SocialNetworks.java similarity index 51% rename from src/main/java/org/sadtech/consultant/dao/SocialNetworks.java rename to src/main/java/org/sadtech/consultant/entity/SocialNetworks.java index 7dd831a..d167608 100644 --- a/src/main/java/org/sadtech/consultant/dao/SocialNetworks.java +++ b/src/main/java/org/sadtech/consultant/entity/SocialNetworks.java @@ -1,4 +1,4 @@ -package org.sadtech.consultant.dao; +package org.sadtech.consultant.entity; import lombok.Data; @@ -10,9 +10,8 @@ import javax.persistence.Id; public class SocialNetworks { @Id - private long id; - private long idVk; - private long idFacebook; - private long phone; + private Long id; + private Long idVk; + private Long idFacebook; } diff --git a/src/main/java/org/sadtech/consultant/dao/Stage.java b/src/main/java/org/sadtech/consultant/entity/Unit.java similarity index 67% rename from src/main/java/org/sadtech/consultant/dao/Stage.java rename to src/main/java/org/sadtech/consultant/entity/Unit.java index 59aa1d7..0f13505 100644 --- a/src/main/java/org/sadtech/consultant/dao/Stage.java +++ b/src/main/java/org/sadtech/consultant/entity/Unit.java @@ -1,4 +1,4 @@ -package org.sadtech.consultant.dao; +package org.sadtech.consultant.entity; import lombok.Data; @@ -7,10 +7,10 @@ import javax.persistence.Id; @Entity @Data -public class Stage { +public class Unit { @Id - private long id; + private Long id; private String text; private String wordKeys; diff --git a/src/main/java/org/sadtech/consultant/dao/User.java b/src/main/java/org/sadtech/consultant/entity/User.java similarity index 81% rename from src/main/java/org/sadtech/consultant/dao/User.java rename to src/main/java/org/sadtech/consultant/entity/User.java index cf14046..c58617b 100644 --- a/src/main/java/org/sadtech/consultant/dao/User.java +++ b/src/main/java/org/sadtech/consultant/entity/User.java @@ -1,4 +1,4 @@ -package org.sadtech.consultant.dao; +package org.sadtech.consultant.entity; import lombok.Data; @@ -12,8 +12,7 @@ import java.util.List; public class User { @Id - @GeneratedValue - private long id; + private Long id; private String name; private String token; private String lastName; diff --git a/src/main/java/org/sadtech/consultant/repository/NextUnitRepositoriy.java b/src/main/java/org/sadtech/consultant/repository/NextUnitRepositoriy.java new file mode 100644 index 0000000..6cc97d5 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/repository/NextUnitRepositoriy.java @@ -0,0 +1,10 @@ +package org.sadtech.consultant.repository; + +import org.sadtech.consultant.entity.NextUnit; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface NextUnitRepositoriy extends JpaRepository { + + + +} diff --git a/src/main/java/org/sadtech/consultant/repository/SaveUnitRepositoriy.java b/src/main/java/org/sadtech/consultant/repository/SaveUnitRepositoriy.java new file mode 100644 index 0000000..d1cd49a --- /dev/null +++ b/src/main/java/org/sadtech/consultant/repository/SaveUnitRepositoriy.java @@ -0,0 +1,7 @@ +package org.sadtech.consultant.repository; + +import org.sadtech.consultant.entity.SaveUnit; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface SaveUnitRepositoriy extends JpaRepository { +} diff --git a/src/main/java/org/sadtech/consultant/repository/SocialNetworksRepositoriy.java b/src/main/java/org/sadtech/consultant/repository/SocialNetworksRepositoriy.java new file mode 100644 index 0000000..1e9e84a --- /dev/null +++ b/src/main/java/org/sadtech/consultant/repository/SocialNetworksRepositoriy.java @@ -0,0 +1,7 @@ +package org.sadtech.consultant.repository; + +import org.sadtech.consultant.entity.SocialNetworks; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface SocialNetworksRepositoriy extends JpaRepository { +} diff --git a/src/main/java/org/sadtech/consultant/repository/UnitRepositoriy.java b/src/main/java/org/sadtech/consultant/repository/UnitRepositoriy.java new file mode 100644 index 0000000..f804f65 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/repository/UnitRepositoriy.java @@ -0,0 +1,7 @@ +package org.sadtech.consultant.repository; + +import org.sadtech.consultant.entity.Unit; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface UnitRepositoriy extends JpaRepository { +} diff --git a/src/main/java/org/sadtech/consultant/repository/UserRepositoriy.java b/src/main/java/org/sadtech/consultant/repository/UserRepositoriy.java new file mode 100644 index 0000000..25e5e05 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/repository/UserRepositoriy.java @@ -0,0 +1,8 @@ +package org.sadtech.consultant.repository; + +import org.sadtech.consultant.entity.User; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface UserRepositoriy extends JpaRepository { + +} diff --git a/src/main/java/org/sadtech/consultant/service/NextUnitService.java b/src/main/java/org/sadtech/consultant/service/NextUnitService.java new file mode 100644 index 0000000..9ff5ac8 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/service/NextUnitService.java @@ -0,0 +1,4 @@ +package org.sadtech.consultant.service; + +public interface NextUnitService { +} diff --git a/src/main/java/org/sadtech/consultant/service/SaveUnitService.java b/src/main/java/org/sadtech/consultant/service/SaveUnitService.java new file mode 100644 index 0000000..39e76cc --- /dev/null +++ b/src/main/java/org/sadtech/consultant/service/SaveUnitService.java @@ -0,0 +1,4 @@ +package org.sadtech.consultant.service; + +public interface SaveUnitService { +} diff --git a/src/main/java/org/sadtech/consultant/service/SocialNetworksService.java b/src/main/java/org/sadtech/consultant/service/SocialNetworksService.java new file mode 100644 index 0000000..54dab6d --- /dev/null +++ b/src/main/java/org/sadtech/consultant/service/SocialNetworksService.java @@ -0,0 +1,4 @@ +package org.sadtech.consultant.service; + +public interface SocialNetworksService { +} diff --git a/src/main/java/org/sadtech/consultant/service/UnitService.java b/src/main/java/org/sadtech/consultant/service/UnitService.java new file mode 100644 index 0000000..c8e77e9 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/service/UnitService.java @@ -0,0 +1,10 @@ +package org.sadtech.consultant.service; + +import org.sadtech.consultant.entity.Unit; + +public interface UnitService { + + void addUnit(Unit unit); + void removeUnit(Long id); + +} diff --git a/src/main/java/org/sadtech/consultant/service/UserService.java b/src/main/java/org/sadtech/consultant/service/UserService.java new file mode 100644 index 0000000..5018e68 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/service/UserService.java @@ -0,0 +1,10 @@ +package org.sadtech.consultant.service; + +import org.sadtech.consultant.entity.User; + +public interface UserService { + + void addUser(User user); + void removeUser(Long id); + +} diff --git a/src/main/java/org/sadtech/consultant/service/impl/NextUnitServiceImpl.java b/src/main/java/org/sadtech/consultant/service/impl/NextUnitServiceImpl.java new file mode 100644 index 0000000..d06b195 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/service/impl/NextUnitServiceImpl.java @@ -0,0 +1,14 @@ +package org.sadtech.consultant.service.impl; + +import org.sadtech.consultant.repository.NextUnitRepositoriy; +import org.sadtech.consultant.service.NextUnitService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class NextUnitServiceImpl implements NextUnitService { + + @Autowired + private NextUnitRepositoriy repositoriy; + +} diff --git a/src/main/java/org/sadtech/consultant/service/impl/SaveUnitServiceImpl.java b/src/main/java/org/sadtech/consultant/service/impl/SaveUnitServiceImpl.java new file mode 100644 index 0000000..51ef4b6 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/service/impl/SaveUnitServiceImpl.java @@ -0,0 +1,14 @@ +package org.sadtech.consultant.service.impl; + +import org.sadtech.consultant.repository.SaveUnitRepositoriy; +import org.sadtech.consultant.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/service/impl/SocialNetworksServiceImpl.java b/src/main/java/org/sadtech/consultant/service/impl/SocialNetworksServiceImpl.java new file mode 100644 index 0000000..06d5f78 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/service/impl/SocialNetworksServiceImpl.java @@ -0,0 +1,14 @@ +package org.sadtech.consultant.service.impl; + +import org.sadtech.consultant.repository.SocialNetworksRepositoriy; +import org.sadtech.consultant.service.SocialNetworksService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SocialNetworksServiceImpl implements SocialNetworksService { + + @Autowired + private SocialNetworksRepositoriy repositoriy; + +} diff --git a/src/main/java/org/sadtech/consultant/service/impl/UnitServiceImpl.java b/src/main/java/org/sadtech/consultant/service/impl/UnitServiceImpl.java new file mode 100644 index 0000000..14706d9 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/service/impl/UnitServiceImpl.java @@ -0,0 +1,22 @@ +package org.sadtech.consultant.service.impl; + +import org.sadtech.consultant.entity.Unit; +import org.sadtech.consultant.repository.UnitRepositoriy; +import org.sadtech.consultant.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/service/impl/UserServiceImpl.java b/src/main/java/org/sadtech/consultant/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..3535b00 --- /dev/null +++ b/src/main/java/org/sadtech/consultant/service/impl/UserServiceImpl.java @@ -0,0 +1,22 @@ +package org.sadtech.consultant.service.impl; + +import org.sadtech.consultant.entity.User; +import org.sadtech.consultant.repository.UserRepositoriy; +import org.sadtech.consultant.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class UserServiceImpl implements UserService { + + @Autowired + private UserRepositoriy repositoriy; + + public void addUser(User user) { + //@TODO: Написть добавление профиля в бд + } + + public void removeUser(Long id) { + //@TODO: Написать удаление профиля из бд + } +}