Skip to content
This repository was archived by the owner on Mar 5, 2020. It is now read-only.

Commit 22fad59

Browse files
committed
SQUISH THAT CAT
1 parent a31537f commit 22fad59

27 files changed

+4911
-3358
lines changed

pom.xml

Lines changed: 107 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,113 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4-
<modelVersion>4.0.0</modelVersion>
5-
<parent>
6-
<groupId>org.springframework.boot</groupId>
7-
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.1.5.RELEASE</version>
9-
<relativePath/> <!-- lookup parent from repository -->
10-
</parent>
11-
<groupId>pl.simplemethod</groupId>
12-
<artifactId>codebin</artifactId>
13-
<version>0.0.1-SNAPSHOT</version>
14-
<name>codebin</name>
15-
<description>Demo project for Spring Boot</description>
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.1.5.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<groupId>pl.simplemethod</groupId>
12+
<artifactId>codebin</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>codebin</name>
15+
<description>Demo project for Spring Boot</description>
1616

17-
<properties>
18-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19-
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
20-
<java.version>1.8</java.version>
21-
</properties>
17+
<properties>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
20+
<java.version>1.8</java.version>
21+
</properties>
2222

23-
<dependencies>
24-
<dependency>
25-
<groupId>com.mashape.unirest</groupId>
26-
<artifactId>unirest-java</artifactId>
27-
<version>1.4.9</version>
28-
</dependency>
29-
<dependency>
30-
<groupId>org.apache.httpcomponents</groupId>
31-
<artifactId>httpclient</artifactId>
32-
<version>4.5.8</version>
33-
</dependency>
34-
<dependency>
35-
<groupId>org.apache.httpcomponents</groupId>
36-
<artifactId>httpasyncclient</artifactId>
37-
<version>4.1.4</version>
38-
</dependency>
39-
<dependency>
40-
<groupId>org.apache.httpcomponents</groupId>
41-
<artifactId>httpmime</artifactId>
42-
<version>4.5.8</version>
43-
</dependency>
44-
<dependency>
45-
<groupId>org.junit.jupiter</groupId>
46-
<artifactId>junit-jupiter-api</artifactId>
47-
<version>5.1.0</version>
48-
<scope>test</scope>
49-
</dependency>
50-
<dependency>
51-
<groupId>org.apache.logging.log4j</groupId>
52-
<artifactId>log4j-core</artifactId>
53-
</dependency>
54-
<dependency>
55-
<groupId>com.googlecode.json-simple</groupId>
56-
<artifactId>json-simple</artifactId>
57-
<version>1.1.1</version>
58-
</dependency>
59-
<dependency>
60-
<groupId>org.springframework.boot</groupId>
61-
<artifactId>spring-boot-starter-data-rest</artifactId>
62-
</dependency>
63-
<dependency>
64-
<groupId>org.springframework.boot</groupId>
65-
<artifactId>spring-boot-starter-oauth2-client</artifactId>
66-
</dependency>
67-
<dependency>
68-
<groupId>org.springframework.boot</groupId>
69-
<artifactId>spring-boot-starter-security</artifactId>
70-
</dependency>
71-
<dependency>
72-
<groupId>org.springframework.boot</groupId>
73-
<artifactId>spring-boot-starter-web</artifactId>
74-
</dependency>
75-
<dependency>
76-
<groupId>org.springframework.boot</groupId>
77-
<artifactId>spring-boot-starter-thymeleaf</artifactId>
78-
</dependency>
79-
<dependency>
80-
<groupId>org.springframework.boot</groupId>
81-
<artifactId>spring-boot-starter-test</artifactId>
82-
<scope>test</scope>
83-
</dependency>
84-
<dependency>
85-
<groupId>org.springframework.security</groupId>
86-
<artifactId>spring-security-test</artifactId>
87-
<scope>test</scope>
88-
</dependency>
89-
<!--
90-
<dependency>
91-
<groupId>org.springframework.boot</groupId>
92-
<artifactId>spring-boot-starter-jdbc</artifactId>
93-
</dependency>
94-
-->
95-
</dependencies>
23+
<dependencies>
24+
<dependency>
25+
<groupId>com.mashape.unirest</groupId>
26+
<artifactId>unirest-java</artifactId>
27+
<version>1.4.9</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.apache.httpcomponents</groupId>
31+
<artifactId>httpclient</artifactId>
32+
<version>4.5.8</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.apache.httpcomponents</groupId>
36+
<artifactId>httpasyncclient</artifactId>
37+
<version>4.1.4</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.apache.httpcomponents</groupId>
41+
<artifactId>httpmime</artifactId>
42+
<version>4.5.8</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.junit.jupiter</groupId>
46+
<artifactId>junit-jupiter-api</artifactId>
47+
<version>5.1.0</version>
48+
<scope>test</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.apache.logging.log4j</groupId>
52+
<artifactId>log4j-core</artifactId>
53+
</dependency>
54+
<dependency>
55+
<groupId>com.googlecode.json-simple</groupId>
56+
<artifactId>json-simple</artifactId>
57+
<version>1.1.1</version>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.springframework.boot</groupId>
61+
<artifactId>spring-boot-starter-data-rest</artifactId>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.springframework.boot</groupId>
65+
<artifactId>spring-boot-starter-oauth2-client</artifactId>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.springframework.boot</groupId>
69+
<artifactId>spring-boot-starter-security</artifactId>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.springframework.boot</groupId>
73+
<artifactId>spring-boot-starter-web</artifactId>
74+
</dependency>
75+
<dependency>
76+
<groupId>org.springframework.boot</groupId>
77+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.springframework.boot</groupId>
81+
<artifactId>spring-boot-starter-test</artifactId>
82+
<scope>test</scope>
83+
</dependency>
84+
<dependency>
85+
<groupId>org.springframework.security</groupId>
86+
<artifactId>spring-security-test</artifactId>
87+
<scope>test</scope>
88+
</dependency>
89+
<dependency>
90+
<groupId>org.springframework.boot</groupId>
91+
<artifactId>spring-boot-starter-data-jpa</artifactId>
92+
</dependency>
93+
<dependency>
94+
<groupId>mysql</groupId>
95+
<artifactId>mysql-connector-java</artifactId>
96+
<scope>runtime</scope>
97+
</dependency>
98+
</dependencies>
9699

97-
<build>
98-
<finalName>Codebin</finalName>
99-
<plugins>
100-
<plugin>
101-
<groupId>org.springframework.boot</groupId>
102-
<artifactId>spring-boot-maven-plugin</artifactId>
103-
<configuration>
104-
<mainClass>pl.simplemethod.codebin.CodebinApplication</mainClass>
105-
</configuration>
106-
</plugin>
107-
</plugins>
108-
</build>
100+
<build>
101+
<finalName>Codebin</finalName>
102+
<plugins>
103+
<plugin>
104+
<groupId>org.springframework.boot</groupId>
105+
<artifactId>spring-boot-maven-plugin</artifactId>
106+
<configuration>
107+
<mainClass>pl.simplemethod.codebin.CodebinApplication</mainClass>
108+
</configuration>
109+
</plugin>
110+
</plugins>
111+
</build>
109112

110-
</project>
113+
</project>

src/main/java/pl/simplemethod/codebin/CodebinApplication.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.boot.autoconfigure.domain.EntityScan;
6+
import org.springframework.context.ConfigurableApplicationContext;
67
import org.springframework.context.annotation.Bean;
78
import pl.simplemethod.codebin.githubOauth.GithubClient;
89
import pl.simplemethod.codebin.srv.SrvClient;
@@ -15,7 +16,8 @@
1516
public class CodebinApplication {
1617

1718
public static void main(String[] args) {
18-
SpringApplication.run(CodebinApplication.class, args);
19+
ConfigurableApplicationContext ctx = SpringApplication.run(CodebinApplication.class, args);
20+
ContextWrapper.initWrapper(ctx);
1921
}
2022

2123
@Bean
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package pl.simplemethod.codebin;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.context.ApplicationContext;
5+
import org.springframework.stereotype.Service;
6+
7+
@Service
8+
public class ContextWrapper {
9+
private static ApplicationContext context;
10+
11+
@Autowired
12+
public static void initWrapper(ApplicationContext ac) {
13+
context = ac;
14+
}
15+
16+
public static ApplicationContext getContext() {
17+
return context;
18+
}
19+
}

src/main/java/pl/simplemethod/codebin/SecurityConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected void configure(HttpSecurity http) throws Exception {
2828
// http://localhost/logowanie/github
2929
http.oauth2Login()
3030
.authorizationEndpoint()
31-
.baseUri("/logowanie")
31+
.baseUri("/oauth")
3232
.authorizationRequestRepository(authorizationRequestRepository()).and().permitAll();
3333
}
3434

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package pl.simplemethod.codebin.dao;
2+
3+
import org.springframework.stereotype.Repository;
4+
import org.springframework.transaction.annotation.Transactional;
5+
import pl.simplemethod.codebin.model.Images;
6+
7+
import javax.persistence.EntityManager;
8+
import javax.persistence.PersistenceContext;
9+
10+
@Repository
11+
public class ImagesDao {
12+
13+
@PersistenceContext
14+
private EntityManager entityManager;
15+
16+
@Transactional
17+
public void save(Images images) {
18+
entityManager.persist(images);
19+
}
20+
21+
@Transactional()
22+
public Images get(Integer id) {
23+
Images images = entityManager.find(Images.class, id);
24+
return images;
25+
}
26+
27+
@Transactional
28+
public void update(Integer id, Images images) {
29+
Images find = entityManager.find(Images.class, id);
30+
if (find != null) {
31+
find.setId(images.getId());
32+
find.setName(images.getName());
33+
find.setType(images.getType());
34+
find.setCreateTime(images.getCreateTime());
35+
find.setDocker_id(images.getDocker_id());
36+
}
37+
}
38+
39+
@Transactional
40+
public void remove(Integer id) {
41+
Images objToRemove = entityManager.find(Images.class, id);
42+
entityManager.remove(objToRemove);
43+
}
44+
}

0 commit comments

Comments
 (0)