diff --git a/.travis.yml b/.travis.yml
index f5c99a7..f464142 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1 +1,28 @@
-language: java
\ No newline at end of file
+language: java
+jdk: oraclejdk9
+spring:
+ datasource:
+ url: ${JDBC_DATABASE_URL}
+ username: ${JDBC_DATABASE_USERNAME}
+ password: ${JDBC_DATABASE_PASSWORD}
+
+addons:
+ postgresql: "9.6"
+
+services:
+ - postgresql
+
+before_install:
+ - psql -c "create user vitalya with password '1324qwer';" -U postgres
+ - psql -c "create database brodb;" -U postgres
+ - psql -c "grant all on database brodb to vitalya;" -U postgres
+
+#deploy:
+# provider: heroku
+# api_key:
+# secure: $HEROKU_API_KEY
+# app: BroForce-02-2018
+# on:
+# repo: BatrSens/BroForce-02-2018
+# branch: master
+# skip_cleanup: true
\ No newline at end of file
diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..8549ebd
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: java -jar ./target/BroForce-02-2018-1.0-SNAPSHOT.jar
diff --git a/README.md b/README.md
index 54fd6db..231278e 100644
--- a/README.md
+++ b/README.md
@@ -4,16 +4,4 @@
- Масягин Михаил АПО-22
- Мельников Владислав АПО-22
- Полещук Виталий АПО-22
-- Саркисян Артур АПО-21
-
-
-| | url | Тело запроса |
-| ------ | ------ | ------ |
-| Зарегистрироваться | /api/signup | ```{"login":"vitalya", "password":"1324qwer", "email":"vitalya@mail.ru"}```
-| Авторизоваться | /api/signin | ```{"login":"vitalya", "password":"1324qwer"}```
-| Запросить пользователя текущей сессии | /api/loginfo | -
-| Изменить пароль | /api/newpassword | ```{"password":"1324qwer", "change":"1234"}```
-| Изменить логин | /api/newlogin | ```{"password":"1324qwer", "change":"vitalik"}```
-| Изменить email | /api/newemail | ```{"password":"1324qwer", "change":"vitalya@yandex.ru"}```
-| Изменить аватар | /api/newavatar | ```{"password":"1324qwer", "change":"_NEW_AVATAR_"}```
-| Разлогиниться | /api/logout | -
+- Саркисян Артур АПО-21
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/park_checks.xml b/park_checks.xml
index ce90222..47cfe4b 100644
--- a/park_checks.xml
+++ b/park_checks.xml
@@ -1,24 +1,17 @@
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
@@ -29,12 +22,11 @@
-
-
-
+
+
+
-
@@ -58,7 +50,9 @@
-
+
+
+
@@ -70,9 +64,9 @@
-
+ value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
+
@@ -95,49 +89,49 @@
+ value="Package name ''{0}'' must match pattern ''{1}''."/>
+ value="Type name ''{0}'' must match pattern ''{1}''."/>
+ value="Member name ''{0}'' must match pattern ''{1}''."/>
+ value="Parameter name ''{0}'' must match pattern ''{1}''."/>
+ value="Local variable name ''{0}'' must match pattern ''{1}''."/>
+ value="Class type name ''{0}'' must match pattern ''{1}''."/>
+ value="Method type name ''{0}'' must match pattern ''{1}''."/>
-
-
-
+ value="GenericWhitespace ''{0}'' is followed by whitespace."/>
+
+
+
@@ -167,7 +161,7 @@
+ value="Method name ''{0}'' must match pattern ''{1}''."/>
@@ -227,6 +221,7 @@
+
@@ -235,6 +230,7 @@
+
@@ -243,7 +239,7 @@
-
+
@@ -252,4 +248,4 @@
-
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 5318e48..15da787 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,20 +5,16 @@
4.0.0
BroForce
- BroForce
+ BroForce-02-2018
1.0-SNAPSHOT
org.springframework.boot
spring-boot-starter-parent
2.0.0.RELEASE
-
-
- UTF-8
- UTF-8
- 1.8
+ 1.9
@@ -35,13 +31,13 @@
org.springframework.boot
- spring-boot-starter-test
- test
+ spring-boot-starter-jetty
- org.springframework.boot
- spring-boot-starter-jetty
+ org.jetbrains
+ annotations
+ 13.0
@@ -60,9 +56,9 @@
- org.jetbrains
- annotations
- 13.0
+ org.springframework.boot
+ spring-boot-starter-test
+ test
@@ -82,13 +78,6 @@
org.apache.maven.plugins
maven-checkstyle-plugin
2.17
-
-
- com.puppycrawl.tools
- checkstyle
- 8.8
-
-
park_checks.xml
true
@@ -106,28 +95,14 @@
org.springframework.boot
spring-boot-maven-plugin
+
+
+ org.flywaydb
+ flyway-maven-plugin
+ 4.1.2
+
+
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
diff --git a/src/main/java/application/Application.java b/src/main/java/application/Application.java
index 55dbb35..29143ae 100644
--- a/src/main/java/application/Application.java
+++ b/src/main/java/application/Application.java
@@ -1,7 +1,8 @@
package application;
-import application.database.DAOi;
-import application.database.DbDAO;
+import application.db.UserDao;
+import application.db.UserDaoImpl;
+
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@@ -10,17 +11,19 @@
@SpringBootApplication
public class Application {
+
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
- public DAOi database() {
- return new DbDAO();
+ public UserDao database() {
+ return new UserDaoImpl();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
+
}
diff --git a/src/main/java/application/controllers/SessionController.java b/src/main/java/application/controllers/SessionController.java
index 8f93fb8..8907942 100644
--- a/src/main/java/application/controllers/SessionController.java
+++ b/src/main/java/application/controllers/SessionController.java
@@ -1,259 +1,174 @@
package application.controllers;
-import application.controllers.requests.ChangeRequest;
-import application.controllers.requests.SigninRequest;
-import application.controllers.requests.SignupRequest;
-import application.controllers.responses.ErrorResponse;
-import application.controllers.responses.MessageResponse;
+import application.models.User;
+import application.services.AccountService;
+import application.utils.Validator;
+import application.utils.requests.SettingsRequest;
+import application.utils.requests.SigninRequest;
+import application.utils.requests.SignupRequest;
+import application.utils.responses.MessageResponse;
+import application.utils.responses.UserResponseWP;
+import application.utils.Messages;
+import application.utils.responses.ValidatorResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
-import application.models.UserService;
-import application.models.User;
+import org.springframework.web.bind.annotation.PostMapping;
import javax.servlet.http.HttpSession;
-
-import static application.controllers.messages.Message.*;
-
+import java.util.ArrayList;
@RestController
+@CrossOrigin(origins = "*", allowCredentials = "true")
public class SessionController {
- private final UserService service;
+ private AccountService service;
public static final String JSON = MediaType.APPLICATION_JSON_UTF8_VALUE;
+ public static final String USER_ID = "userId";
+ public static final Integer DEFAULT_TOP_SIZE = 10;
- public SessionController(UserService service) {
+ public SessionController(AccountService service) {
this.service = service;
}
- @GetMapping("/api/loginfo")
- public ResponseEntity