Skip to content

Commit 271ece3

Browse files
committed
no message
1 parent 35cc5b6 commit 271ece3

File tree

17 files changed

+64
-76
lines changed

17 files changed

+64
-76
lines changed

docker/Dockerfile.userApi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM openjdk:11-jre
22
ADD ./dist/userMicroservice-1.0.jar app.jar
33
RUN bash -c 'touch /app.jar'
4+
# ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom","-Dserver.port=$PORT","-jar","/app.jar"]
45
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

docker/docker-entrypoint-initdb.d/create_schema.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,9 @@ CREATE TABLE IF NOT EXISTS math.permissions (
7272
-- ------------------------------------------
7373
CREATE TABLE IF NOT EXISTS math.answer (
7474
id SERIAL PRIMARY KEY,
75-
exercise_id INT NOT NULL REFERENCES math.exercise(id),
75+
exercise_id INT REFERENCES math.exercise(id) ON DELETE CASCADE,
7676
user_id INT NOT NULL REFERENCES math.user(id),
7777
correct BOOL NOT NULL
7878
);
7979

80-
-- TODO: unique index on exercise_id and user_id
81-
8280
END;

docker/docker-entrypoint-initdb.d/insert_data.sql

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ INSERT INTO math.permissions(user_id, role_name) VALUES (1, 'teacher');
1717

1818

1919
-- course
20-
INSERT INTO math.course (name, description, image) VALUES ('trygonometria', 'jedynka trygonometryczna $\\\\$ $sin^{2}\alpha + cos^{2}\alpha = 1$ ', 'http://192.168.1.69:8125/images/course/trygonometry.png');
21-
INSERT INTO math.course (name, description, image) VALUES ('stereometria', 'Prostopadłościan: $\\ $ - długości krawędzi: a, b, c$\\ $- pole = 2(ab + bc + ac)$\\ $- objętość = ab$\\ $ Ostrosłup:$\\ $- pole podstawy: P_{p}$\\ $- wysokość: H$\\ $- objętość = $\frac{1}{3}P_{p}H$', 'http://192.168.1.69:8125/images/course/geometry.png');
22-
INSERT INTO math.course (name, description, image) VALUES ('ułamki', 'Jakis opis', 'http://192.168.1.69:8125/images/course/fractions.png');
23-
INSERT INTO math.course (name, description, image) VALUES ('funkcje', 'Jakis opis', 'http://192.168.1.69:8125/images/course/functions.png');
24-
INSERT INTO math.course (name, description, image) VALUES ('probabilistyka', 'Jakis opis', 'http://192.168.1.69:8125/images/course/probability.png');
25-
INSERT INTO math.course (name, description, image) VALUES ('statystyka', 'Jakis opis', 'http://192.168.1.69:8125/images/course/statistics.png');
26-
INSERT INTO math.course (name, description, image) VALUES ('planimetria', 'Jakis opis', 'http://192.168.1.69:8125/images/course/planimetry.png');
27-
INSERT INTO math.course (name, description, image) VALUES ('ciągi liczbowe', 'Jakis opis', 'http://192.168.1.69:8125/images/course/numerical_sequences.png');
28-
INSERT INTO math.course (name, description, image) VALUES ('równania i nierówności', 'Jakis opis', 'http://192.168.1.69:8125/images/course/equations.png');
20+
INSERT INTO math.course (name, description, image) VALUES ('trygonometria', 'jedynka trygonometryczna $\\\\$ $sin^{2}\alpha + cos^{2}\alpha = 1$ ', 'https://math-user-api.herokuapp.com/images/course/trygonometry.png');
21+
INSERT INTO math.course (name, description, image) VALUES ('stereometria', 'Prostopadłościan: $\\ $ - długości krawędzi: a, b, c$\\ $- pole = 2(ab + bc + ac)$\\ $- objętość = ab$\\ $ Ostrosłup:$\\ $- pole podstawy: P_{p}$\\ $- wysokość: H$\\ $- objętość = $\frac{1}{3}P_{p}H$', 'https://math-user-api.herokuapp.com/images/course/geometry.png');
22+
INSERT INTO math.course (name, description, image) VALUES ('ułamki', 'Jakis opis', 'https://math-user-api.herokuapp.com/images/course/fractions.png');
23+
INSERT INTO math.course (name, description, image) VALUES ('funkcje', 'Jakis opis', 'https://math-user-api.herokuapp.com/images/course/functions.png');
24+
INSERT INTO math.course (name, description, image) VALUES ('probabilistyka', 'Jakis opis', 'https://math-user-api.herokuapp.com/images/course/probability.png');
25+
INSERT INTO math.course (name, description, image) VALUES ('statystyka', 'Jakis opis', 'https://math-user-api.herokuapp.com/images/course/statistics.png');
26+
INSERT INTO math.course (name, description, image) VALUES ('planimetria', 'Jakis opis', 'https://math-user-api.herokuapp.com/images/course/planimetry.png');
27+
INSERT INTO math.course (name, description, image) VALUES ('ciągi liczbowe', 'Jakis opis', 'https://math-user-api.herokuapp.com/images/course/numerical_sequences.png');
28+
INSERT INTO math.course (name, description, image) VALUES ('równania i nierówności', 'Jakis opis', 'https://math-user-api.herokuapp.com/images/course/equations.png');
2929

3030

3131
-- course_author
@@ -55,7 +55,7 @@ INSERT INTO math.exercise (question, correct_answers, incorrect_answers, course_
5555

5656
INSERT INTO math.exercise (question, correct_answers, incorrect_answers, course_id, image)
5757
VALUES ('W trójkącie, przedstawionym na rysunku powyżej, sinus kąta ostrego $\alpha$ jest równy',
58-
'{"data": [{"answer":"$\\frac{2\\sqrt{6}}{5}$"}]}', '{"data": [{"answer":" $\\frac{\\sqrt{6}}{12}$"},{"answer":" $\\frac{1}{5}$"},{"answer":" $\\frac{5}{24}$"}]}', 1, 'http://192.168.1.69:8125/images/exercise/img1.png');
58+
'{"data": [{"answer":"$\\frac{2\\sqrt{6}}{5}$"}]}', '{"data": [{"answer":" $\\frac{\\sqrt{6}}{12}$"},{"answer":" $\\frac{1}{5}$"},{"answer":" $\\frac{5}{24}$"}]}', 1, 'https://math-user-api.herokuapp.com/images/exercise/img1.png');
5959

6060
INSERT INTO math.exercise (question, correct_answers, course_id)
6161
VALUES ('$ tg\alpha ctg\alpha $ jest równe','{"data": [{"answer":1}]}','1');
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.example.core.domain.configuration;
2+
3+
4+
import org.springframework.boot.jdbc.DataSourceBuilder;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
7+
8+
import javax.sql.DataSource;
9+
import java.net.URI;
10+
import java.net.URISyntaxException;
11+
12+
/*
13+
@Configuration
14+
public class DbConfig {
15+
16+
17+
@Bean
18+
public DataSource getDataSource() throws URISyntaxException {
19+
20+
URI dbUri = new URI(System.getenv("DATABASE_URL"));
21+
22+
String username = dbUri.getUserInfo().split(":")[0];
23+
String password = dbUri.getUserInfo().split(":")[1];
24+
String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + dbUri.getPath() ;//+ "?sslmode=require";
25+
26+
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
27+
//dataSourceBuilder.driverClassName("org.h2.Driver");
28+
dataSourceBuilder.url(dbUrl);
29+
dataSourceBuilder.username(username);
30+
dataSourceBuilder.password(password);
31+
return dataSourceBuilder.build();
32+
}
33+
34+
35+
}
36+
*/
37+

domain/src/main/java/com/example/core/domain/entity/Answer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import javax.persistence.*;
66

77
@Entity
8+
@Table(name="answer", schema = "math")
89
public class Answer {
910
@Id
1011
@GeneratedValue(strategy=GenerationType.IDENTITY)

domain/src/main/java/com/example/core/domain/entity/Course.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.Set;
1010

1111
@Entity
12+
@Table(name="course", schema = "math")
1213
public class Course {
1314
@Id
1415
@GeneratedValue(strategy= GenerationType.IDENTITY)
@@ -25,7 +26,7 @@ public class Course {
2526

2627
@JsonIgnore
2728
@ManyToMany(fetch = FetchType.EAGER)
28-
@JoinTable(name = "course_author", joinColumns = {
29+
@JoinTable(name = "course_author", schema = "math", joinColumns = {
2930
@JoinColumn(name = "course_id") }, inverseJoinColumns = {
3031
@JoinColumn(name = "author_id") })
3132
private Set<User> authors;

domain/src/main/java/com/example/core/domain/entity/Exercise.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.Set;
1212

1313
@Entity
14+
@Table(name="exercise", schema = "math")
1415
public class Exercise {
1516
@Id
1617
@GeneratedValue(strategy=GenerationType.IDENTITY)

domain/src/main/java/com/example/core/domain/entity/SystemConfig.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

domain/src/main/java/com/example/core/domain/entity/user/Role.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Set;
55

66
@Entity
7+
@Table(name="role", schema = "math")
78
public class Role {
89
@Id
910
@Column(name="name")

domain/src/main/java/com/example/core/domain/entity/user/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class User implements UserDetails {
3030
private String firstName;
3131

3232
@ManyToMany(fetch = FetchType.EAGER)
33-
@JoinTable(name = "permissions", joinColumns = {
33+
@JoinTable(name = "permissions", schema = "math", joinColumns = {
3434
@JoinColumn(name = "user_id") }, inverseJoinColumns = {
3535
@JoinColumn(name = "role_name") })
3636
private Set<Role> roles;

0 commit comments

Comments
 (0)