Skip to content

Commit 377105d

Browse files
committed
feat: upgrade spring boot version
1 parent 780e005 commit 377105d

File tree

9 files changed

+29
-52
lines changed

9 files changed

+29
-52
lines changed

build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
plugins {
2-
id 'org.springframework.boot' version '2.6.4'
3-
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
2+
id 'org.springframework.boot' version '3.3.2'
3+
id 'io.spring.dependency-management' version '1.1.6'
44
id 'java'
55
}
66

77
group = 'codes.sharing'
88
version = '0.0.1-SNAPSHOT'
9-
sourceCompatibility = '11'
9+
10+
java {
11+
toolchain {
12+
languageVersion = JavaLanguageVersion.of(17)
13+
}
14+
}
1015

1116
repositories {
1217
mavenCentral()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/codes/sharing/sharingcodes/controller/GetController.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.springframework.stereotype.Controller;
1010

1111
import java.util.List;
12-
import java.util.Optional;
1312

1413
@Controller
1514
public class GetController {
@@ -41,7 +40,7 @@ public String getNthCode(@PathVariable String N, @RequestParam(value = "password
4140
}
4241

4342
@GetMapping(value = {"/code/new", "/"})
44-
public String createHtmlCode(Model model) {
43+
public String createHtmlCode() {
4544
return "index";
4645
}
4746

@@ -61,4 +60,4 @@ public String getAboutPage() {
6160
public String getUsage() {
6261
return "usage";
6362
}
64-
}
63+
}

src/main/java/codes/sharing/sharingcodes/controller/PostController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.springframework.web.bind.annotation.*;
1010
import org.springframework.stereotype.Controller;
1111

12-
import java.util.HashMap;
1312
import java.util.Map;
1413

1514
@Controller
@@ -54,4 +53,4 @@ public ResponseEntity<Object> checkPassword(@RequestBody PasswordDTO passwordDTO
5453
return ResponseEntity.badRequest().build();
5554
}
5655
}
57-
}
56+
}

src/main/java/codes/sharing/sharingcodes/model/Code.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
44

5-
import javax.persistence.*;
5+
import jakarta.persistence.*;
66
import java.time.LocalDateTime;
77
import java.util.UUID;
88

@@ -143,4 +143,4 @@ public String getPassword() {
143143
public void setPassword(String password) {
144144
this.password = password;
145145
}
146-
}
146+
}
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
package codes.sharing.sharingcodes.service;
22

33
import codes.sharing.sharingcodes.dto.DateDTO;
4-
import codes.sharing.sharingcodes.dto.PasswordDTO;
54
import codes.sharing.sharingcodes.model.Code;
65

76
import java.util.List;
87

98
public interface CodeService {
9+
Code getById(String id);
1010

11-
public Code getById(String id);
11+
void putCode(Code newCode);
1212

13-
public void putCode(Code newCode);
13+
void refreshCode(Code code);
1414

15-
public void refreshCode(Code code);
15+
List<Code> getLatestNCode(int n);
1616

17-
public List<Code> getLatestNCode(int n);
18-
19-
public boolean isExist(String id);
20-
21-
public void deleteById(String id);
22-
23-
public List<Code> superGetAll();
24-
25-
public DateDTO formatDate(String date);
26-
}
17+
DateDTO formatDate(String date);
18+
}

src/main/java/codes/sharing/sharingcodes/service/CodeServiceImpl.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package codes.sharing.sharingcodes.service;
22

33
import codes.sharing.sharingcodes.dto.DateDTO;
4-
import codes.sharing.sharingcodes.dto.PasswordDTO;
54
import codes.sharing.sharingcodes.exceptions.NotFoundSnippet;
65
import codes.sharing.sharingcodes.model.Code;
76
import codes.sharing.sharingcodes.repository.CodeRepository;
@@ -65,21 +64,6 @@ public List<Code> getLatestNCode(int n) {
6564
return newCodes;
6665
}
6766

68-
@Override
69-
public boolean isExist(String id) {
70-
return repo.existsById(id);
71-
}
72-
73-
@Override
74-
public void deleteById(String id) {
75-
repo.deleteById(id);
76-
}
77-
78-
@Override
79-
public List<Code> superGetAll() {
80-
return (List<Code>) repo.findAll();
81-
}
82-
8367
private void refresh(Code code) {
8468
if (code.isViewsLimit() && code.getViews() >= 0) {
8569
code.setViews(code.getViews() - 1);

src/main/resources/static/js/myScript.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
let dangerMessage;
22
let errorCode;
33
let successMessage;
4-
let obj;
5-
64
window.onload = function() {
75
let form = document.querySelector("form");
86

@@ -41,7 +39,7 @@ function send() {
4139
return;
4240
}
4341

44-
if (xhr.status == 200) {
42+
if (xhr.status === 200) {
4543
successMessage.style.display = "block";
4644
dangerMessage.style.display = "none";
4745
document.querySelector("form").reset();
@@ -54,29 +52,29 @@ function send() {
5452
dangerMessage.style.display = "block";
5553
successMessage.style.display = "none";
5654
errorCode.innerHTML = xhr.status + " " + xhr.statusText;
57-
return;
5855
}
5956
}
6057

6158
function check() {
6259
const codeId = location.pathname.substring(6);
63-
var object = {
60+
const object = {
6461
"password": document.getElementById("password_field").value,
6562
"id": codeId
6663
};
6764
let json = JSON.stringify(object);
6865

66+
let xhr;
6967
try {
7068
xhr = new XMLHttpRequest();
7169
xhr.open("POST", '/api/code/password', false)
7270
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
7371
xhr.send(json);
7472

75-
var url = location.protocol + '//' + location.host + location.pathname + '?password=' + object.password;
73+
const url = location.protocol + '//' + location.host + location.pathname + '?password=' + object.password;
7674

77-
if (xhr.status == 200) {
75+
if (xhr.status === 200) {
7876
window.location.href = url;
79-
} else if (xhr.status == 400){
77+
} else if (xhr.status === 400) {
8078
dangerMessage.style.display = "block";
8179
} else {
8280
window.location.href = url;

src/main/resources/templates/getcode.ftlh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<body>
2525
<nav class="navbar navbar-expand-lg navbar-light bg-light">
26-
<a class="navbar-brand" href="/">Sharing <img src=" /imgs/code-pngrepo-com.png" alt="" style="height: 1em;"> Codes</a>
26+
<a class="navbar-brand" href="/">Sharing <img src="/imgs/code-pngrepo-com.png" alt="" style="height: 1em;"> Codes</a>
2727
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
2828
<span class="navbar-toggler-icon"></span>
2929
</button>
@@ -51,7 +51,7 @@
5151
<#if pieceOfCode.isViewsLimit()>
5252
<br>
5353
<#if pieceOfCode.getViews() == 0>
54-
<small><u><span id="views_restriction">No more views allowed</small>
54+
<small><u><span id="views_restriction">No more views allowed</span></u></small>
5555
<#else>
5656
<small><u><span id="views_restriction">${pieceOfCode.getViews()}</span></u> more views allowed</small>
5757
</#if>
@@ -64,4 +64,4 @@
6464
<script src="/js/bootstrap.bundle.min.js"></script>
6565
</body>
6666

67-
</html>
67+
</html>

0 commit comments

Comments
 (0)