refactor code structure
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
36c9f4f188
commit
c7003c1d02
2
pom.xml
2
pom.xml
@ -33,7 +33,7 @@
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>5.6.15.Final</version>
|
||||
<version>6.6.0.CR1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -6,6 +6,8 @@ import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import wtf.beatrice.releasehive.db.HibernateManager;
|
||||
import wtf.beatrice.releasehive.model.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package wtf.beatrice.releasehive;
|
||||
package wtf.beatrice.releasehive.db;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
@ -1,10 +1,8 @@
|
||||
package wtf.beatrice.releasehive;
|
||||
package wtf.beatrice.releasehive.model;
|
||||
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@ -13,7 +11,7 @@ public class User
|
||||
{
|
||||
|
||||
@Id
|
||||
@Column
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
private UUID uuid;
|
||||
|
||||
@Column
|
@ -1,8 +1,9 @@
|
||||
package wtf.beatrice.releasehive;
|
||||
package wtf.beatrice.releasehive.resource;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import wtf.beatrice.releasehive.util.JsonUtil;
|
||||
import wtf.beatrice.releasehive.model.User;
|
||||
import wtf.beatrice.releasehive.service.AccountService;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -18,10 +19,7 @@ public class AccountResource {
|
||||
produces="application/json")
|
||||
public String register(@RequestBody User user)
|
||||
{
|
||||
UUID id = UUID.randomUUID();
|
||||
user.setUuid(id);
|
||||
accountService.registerUser(user);
|
||||
|
||||
return JsonUtil.convertToJson(user);
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package wtf.beatrice.releasehive;
|
||||
package wtf.beatrice.releasehive.service;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import wtf.beatrice.releasehive.db.HibernateManager;
|
||||
import wtf.beatrice.releasehive.model.User;
|
||||
|
||||
public class AccountService
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package wtf.beatrice.releasehive;
|
||||
package wtf.beatrice.releasehive.util;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@ -7,6 +7,11 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class JsonUtil
|
||||
{
|
||||
|
||||
private JsonUtil() {
|
||||
throw new AssertionError("Utility class");
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(JsonUtil.class);
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
|
@ -22,7 +22,7 @@
|
||||
<property name="hibernate.hbm2ddl.auto">update</property>
|
||||
|
||||
<!-- Annotated entity classes -->
|
||||
<mapping class="wtf.beatrice.releasehive.User"/>
|
||||
<mapping class="wtf.beatrice.releasehive.model.User"/>
|
||||
|
||||
</session-factory>
|
||||
</hibernate-configuration>
|
||||
|
Loading…
Reference in New Issue
Block a user