Skip to content

Commit

Permalink
feat: upgrade spring boot version
Browse files Browse the repository at this point in the history
  • Loading branch information
nuromirzak committed Aug 17, 2024
1 parent 780e005 commit 377105d
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 52 deletions.
11 changes: 8 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
plugins {
id 'org.springframework.boot' version '2.6.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.springframework.boot' version '3.3.2'
id 'io.spring.dependency-management' version '1.1.6'
id 'java'
}

group = 'codes.sharing'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.springframework.stereotype.Controller;

import java.util.List;
import java.util.Optional;

@Controller
public class GetController {
Expand Down Expand Up @@ -41,7 +40,7 @@ public String getNthCode(@PathVariable String N, @RequestParam(value = "password
}

@GetMapping(value = {"/code/new", "/"})
public String createHtmlCode(Model model) {
public String createHtmlCode() {
return "index";
}

Expand All @@ -61,4 +60,4 @@ public String getAboutPage() {
public String getUsage() {
return "usage";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.Map;

@Controller
Expand Down Expand Up @@ -54,4 +53,4 @@ public ResponseEntity<Object> checkPassword(@RequestBody PasswordDTO passwordDTO
return ResponseEntity.badRequest().build();
}
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/codes/sharing/sharingcodes/model/Code.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import javax.persistence.*;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.UUID;

Expand Down Expand Up @@ -143,4 +143,4 @@ public String getPassword() {
public void setPassword(String password) {
this.password = password;
}
}
}
20 changes: 6 additions & 14 deletions src/main/java/codes/sharing/sharingcodes/service/CodeService.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
package codes.sharing.sharingcodes.service;

import codes.sharing.sharingcodes.dto.DateDTO;
import codes.sharing.sharingcodes.dto.PasswordDTO;
import codes.sharing.sharingcodes.model.Code;

import java.util.List;

public interface CodeService {
Code getById(String id);

public Code getById(String id);
void putCode(Code newCode);

public void putCode(Code newCode);
void refreshCode(Code code);

public void refreshCode(Code code);
List<Code> getLatestNCode(int n);

public List<Code> getLatestNCode(int n);

public boolean isExist(String id);

public void deleteById(String id);

public List<Code> superGetAll();

public DateDTO formatDate(String date);
}
DateDTO formatDate(String date);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package codes.sharing.sharingcodes.service;

import codes.sharing.sharingcodes.dto.DateDTO;
import codes.sharing.sharingcodes.dto.PasswordDTO;
import codes.sharing.sharingcodes.exceptions.NotFoundSnippet;
import codes.sharing.sharingcodes.model.Code;
import codes.sharing.sharingcodes.repository.CodeRepository;
Expand Down Expand Up @@ -65,21 +64,6 @@ public List<Code> getLatestNCode(int n) {
return newCodes;
}

@Override
public boolean isExist(String id) {
return repo.existsById(id);
}

@Override
public void deleteById(String id) {
repo.deleteById(id);
}

@Override
public List<Code> superGetAll() {
return (List<Code>) repo.findAll();
}

private void refresh(Code code) {
if (code.isViewsLimit() && code.getViews() >= 0) {
code.setViews(code.getViews() - 1);
Expand Down
14 changes: 6 additions & 8 deletions src/main/resources/static/js/myScript.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
let dangerMessage;
let errorCode;
let successMessage;
let obj;

window.onload = function() {
let form = document.querySelector("form");

Expand Down Expand Up @@ -41,7 +39,7 @@ function send() {
return;
}

if (xhr.status == 200) {
if (xhr.status === 200) {
successMessage.style.display = "block";
dangerMessage.style.display = "none";
document.querySelector("form").reset();
Expand All @@ -54,29 +52,29 @@ function send() {
dangerMessage.style.display = "block";
successMessage.style.display = "none";
errorCode.innerHTML = xhr.status + " " + xhr.statusText;
return;
}
}

function check() {
const codeId = location.pathname.substring(6);
var object = {
const object = {
"password": document.getElementById("password_field").value,
"id": codeId
};
let json = JSON.stringify(object);

let xhr;
try {
xhr = new XMLHttpRequest();
xhr.open("POST", '/api/code/password', false)
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
xhr.send(json);

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

if (xhr.status == 200) {
if (xhr.status === 200) {
window.location.href = url;
} else if (xhr.status == 400){
} else if (xhr.status === 400) {
dangerMessage.style.display = "block";
} else {
window.location.href = url;
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/getcode.ftlh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

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

</html>
</html>

0 comments on commit 377105d

Please sign in to comment.