add SpringBoot 2.7.x application
This commit is contained in:
@ -0,0 +1,13 @@
|
||||
package net.hostsharing.hsadminng;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class HsadminNgApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(HsadminNgApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
37
src/main/java/net/hostsharing/hsadminng/TestController.java
Normal file
37
src/main/java/net/hostsharing/hsadminng/TestController.java
Normal file
@ -0,0 +1,37 @@
|
||||
package net.hostsharing.hsadminng;
|
||||
|
||||
import org.hibernate.type.PostgresUUIDType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class TestController {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
@RequestMapping(value = "/api/test", method = RequestMethod.GET)
|
||||
public List<Object> test() {
|
||||
final var query = em.createNativeQuery("select * from public.rbacuser")
|
||||
.unwrap(org.hibernate.query.NativeQuery.class)
|
||||
.addScalar("uuidColumn", PostgresUUIDType.INSTANCE);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/api/currentUser", method = RequestMethod.GET)
|
||||
public String currentUser() {
|
||||
em.createNativeQuery("SET LOCAL hsadminng.currentUser = 'mike@hostsharing.net';").executeUpdate();
|
||||
em.createNativeQuery("SET LOCAL hsadminng.assumedRoles = '';").executeUpdate();
|
||||
final var query = em.createNativeQuery("select currentUser()");
|
||||
return query.getSingleResult().toString();
|
||||
}
|
||||
}
|
11
src/main/resources/application.yml
Normal file
11
src/main/resources/application.yml
Normal file
@ -0,0 +1,11 @@
|
||||
spring:
|
||||
|
||||
datasource:
|
||||
driver-class-name: org.postgresql.Driver
|
||||
password: password
|
||||
url: jdbc:postgresql://localhost:5432/postgres
|
||||
username: postgres
|
||||
|
||||
sql:
|
||||
init:
|
||||
mode: never
|
Reference in New Issue
Block a user