mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-08 21:38:21 +00:00
WIP
This commit is contained in:
parent
710843bf0b
commit
c776a2ca57
@ -0,0 +1,14 @@
|
||||
package tech.ailef.dbadmin;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
//@ConditionalOnProperty(name = "crudadmin.enabled", matchIfMissing = true)
|
||||
@ComponentScan
|
||||
@EnableConfigurationProperties(DbAdminProperties.class)
|
||||
@Configuration
|
||||
public class DbAdminAutoConfiguration {
|
||||
|
||||
}
|
28
src/main/java/tech/ailef/dbadmin/DbAdminProperties.java
Normal file
28
src/main/java/tech/ailef/dbadmin/DbAdminProperties.java
Normal file
@ -0,0 +1,28 @@
|
||||
package tech.ailef.dbadmin;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("dbadmin")
|
||||
public class DbAdminProperties {
|
||||
public boolean enabled = true;
|
||||
|
||||
private String baseUrl;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
@ -28,6 +29,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import tech.ailef.dbadmin.DbAdmin;
|
||||
import tech.ailef.dbadmin.DbAdminProperties;
|
||||
import tech.ailef.dbadmin.dbmapping.DbAdminRepository;
|
||||
import tech.ailef.dbadmin.dbmapping.DbObject;
|
||||
import tech.ailef.dbadmin.dbmapping.DbObjectSchema;
|
||||
@ -41,8 +43,11 @@ import tech.ailef.dbadmin.misc.Utils;
|
||||
* The main DbAdmin controller that register most of the routes of the web interface.
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/dbadmin")
|
||||
@RequestMapping(value= {"/${dbadmin.baseUrl}", "/${dbadmin.baseUrl}/"}, method=RequestMethod.GET)
|
||||
public class DefaultDbAdminController {
|
||||
@Autowired
|
||||
private DbAdminProperties properties;
|
||||
|
||||
@Autowired
|
||||
private DbAdminRepository repository;
|
||||
|
||||
|
@ -2,10 +2,12 @@ package tech.ailef.dbadmin.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import tech.ailef.dbadmin.DbAdminProperties;
|
||||
|
||||
/**
|
||||
* This class registers some ModelAttribute objects that are
|
||||
@ -14,6 +16,9 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
@ControllerAdvice
|
||||
public class GlobalController {
|
||||
|
||||
@Autowired
|
||||
private DbAdminProperties props;
|
||||
|
||||
/**
|
||||
* A multi valued map containing the query parameters. It is used primarily
|
||||
* in building complex URL when performing faceted search with multiple filters.
|
||||
@ -24,4 +29,9 @@ public class GlobalController {
|
||||
public Map<String, String[]> getQueryParams(HttpServletRequest request) {
|
||||
return request.getParameterMap();
|
||||
}
|
||||
|
||||
@ModelAttribute("baseUrl")
|
||||
public String getBaseUrl(HttpServletRequest request) {
|
||||
return props.getBaseUrl();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user