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

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

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");
}