optimize code
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Bea 2024-08-07 10:21:35 +02:00
parent f142912471
commit b88a9f75bf
4 changed files with 16 additions and 9 deletions

View File

@ -9,6 +9,7 @@
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- Logging Dependencies -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
@ -19,6 +20,8 @@
<artifactId>log4j-core</artifactId>
<version>2.23.1</version>
</dependency>
<!-- Web Dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
@ -30,12 +33,12 @@
<version>3.3.2</version>
</dependency>
<!-- Database Dependencies -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.6.0.CR1</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>

View File

@ -18,22 +18,25 @@ public class Main {
public static void main(String[] args) {
LOGGER.info("Hello world!");
LOGGER.info("Registering shutdown hooks");
Runtime.getRuntime().addShutdownHook(shutdownHook);
LOGGER.info("Initializing database backend");
HibernateManager.initialize();
LOGGER.info("Initializing Spring Boot");
SpringApplication.run(Main.class, args);
LOGGER.info("Spring Boot initialized!");
HibernateManager.initialize();
LOGGER.info("Spring Boot & DB initialized!");
Session session = HibernateManager.getSession();
Transaction transaction = session.beginTransaction();
List<User> users = session.createQuery("FROM User", User.class).getResultList();
for (User user : users) {
LOGGER.info("ID: {}, Name: {}", user.getUuid(), user.getUsername());
}
transaction.commit();
users.forEach(user -> LOGGER.info("ID: {}, Name: {}", user.getUuid(), user.getUsername()));
}
private static final Thread shutdownHook = new Thread(() -> {

View File

@ -1,8 +1,10 @@
package wtf.beatrice.releasehive.resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import wtf.beatrice.releasehive.util.JsonUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import wtf.beatrice.releasehive.model.User;
import wtf.beatrice.releasehive.service.AccountService;

View File

@ -17,7 +17,6 @@ public class AccountServiceImpl implements AccountService {
return JsonUtil.spawnJsonError("Cannot register user without username");
}
if(null == user.getPassword() || user.getPassword().isEmpty()) {
return JsonUtil.spawnJsonError("Cannot register user without password");
}