Создал ORM основу для основного модуля

This commit is contained in:
Mark Struchkov 2018-12-23 03:34:18 +03:00
parent 71ce7af51d
commit d5236a30e4
22 changed files with 199 additions and 29 deletions

15
pom.xml
View File

@ -14,6 +14,9 @@
<properties> <properties>
<persistence.ver>1.0.2</persistence.ver> <persistence.ver>1.0.2</persistence.ver>
<lombok.ver>1.18.4</lombok.ver> <lombok.ver>1.18.4</lombok.ver>
<log4j>1.2.17</log4j>
<spring.data>2.1.3.RELEASE</spring.data>
</properties> </properties>
<dependencies> <dependencies>
@ -28,6 +31,18 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>${lombok.ver}</version> <version>${lombok.ver}</version>
</dependency> </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>
</dependencies> </dependencies>
</project> </project>

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package org.sadtech.consultant.dao; package org.sadtech.consultant.entity;
import lombok.Data; import lombok.Data;
@ -7,10 +7,10 @@ import javax.persistence.Id;
@Entity @Entity
@Data @Data
public class SaveStage { public class SaveUnit {
@Id @Id
private long id; private Long id;
private long idStage; private Long idStage;
} }

View File

@ -1,4 +1,4 @@
package org.sadtech.consultant.dao; package org.sadtech.consultant.entity;
import lombok.Data; import lombok.Data;
@ -10,9 +10,8 @@ import javax.persistence.Id;
public class SocialNetworks { public class SocialNetworks {
@Id @Id
private long id; private Long id;
private long idVk; private Long idVk;
private long idFacebook; private Long idFacebook;
private long phone;
} }

View File

@ -1,4 +1,4 @@
package org.sadtech.consultant.dao; package org.sadtech.consultant.entity;
import lombok.Data; import lombok.Data;
@ -7,10 +7,10 @@ import javax.persistence.Id;
@Entity @Entity
@Data @Data
public class Stage { public class Unit {
@Id @Id
private long id; private Long id;
private String text; private String text;
private String wordKeys; private String wordKeys;

View File

@ -1,4 +1,4 @@
package org.sadtech.consultant.dao; package org.sadtech.consultant.entity;
import lombok.Data; import lombok.Data;
@ -12,8 +12,7 @@ import java.util.List;
public class User { public class User {
@Id @Id
@GeneratedValue private Long id;
private long id;
private String name; private String name;
private String token; private String token;
private String lastName; private String lastName;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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: Написать удаление профиля из бд
}
}