mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-09 05:48:20 +00:00
Rename
This commit is contained in:
parent
f69363563d
commit
8455db747b
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package tech.ailef.snapadmin.external.controller;
|
package tech.ailef.snapadmin.external.controller;
|
||||||
|
|
||||||
|
import java.security.Principal;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -94,7 +95,7 @@ public class DefaultSnapAdminController {
|
|||||||
private SnapAdminRepository repository;
|
private SnapAdminRepository repository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SnapAdmin dbAdmin;
|
private SnapAdmin snapAdmin;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserActionService userActionService;
|
private UserActionService userActionService;
|
||||||
@ -116,8 +117,7 @@ public class DefaultSnapAdminController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String index(Model model, @RequestParam(required = false) String query) {
|
public String index(Model model, @RequestParam(required = false) String query) {
|
||||||
|
List<DbObjectSchema> schemas = snapAdmin.getSchemas();
|
||||||
List<DbObjectSchema> schemas = dbAdmin.getSchemas();
|
|
||||||
if (query != null && !query.isBlank()) {
|
if (query != null && !query.isBlank()) {
|
||||||
schemas = schemas.stream().filter(s -> {
|
schemas = schemas.stream().filter(s -> {
|
||||||
return s.getClassName().toLowerCase().contains(query.toLowerCase())
|
return s.getClassName().toLowerCase().contains(query.toLowerCase())
|
||||||
@ -169,7 +169,7 @@ public class DefaultSnapAdminController {
|
|||||||
if (page == null) page = 1;
|
if (page == null) page = 1;
|
||||||
if (pageSize == null) pageSize = 50;
|
if (pageSize == null) pageSize = 50;
|
||||||
|
|
||||||
DbObjectSchema schema = dbAdmin.findSchemaByClassName(className);
|
DbObjectSchema schema = snapAdmin.findSchemaByClassName(className);
|
||||||
|
|
||||||
Set<QueryFilter> queryFilters = Utils.computeFilters(schema, otherParams);
|
Set<QueryFilter> queryFilters = Utils.computeFilters(schema, otherParams);
|
||||||
if (otherParams.containsKey("remove_field")) {
|
if (otherParams.containsKey("remove_field")) {
|
||||||
@ -250,7 +250,7 @@ public class DefaultSnapAdminController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/model/{className}/schema")
|
@GetMapping("/model/{className}/schema")
|
||||||
public String schema(Model model, @PathVariable String className) {
|
public String schema(Model model, @PathVariable String className) {
|
||||||
DbObjectSchema schema = dbAdmin.findSchemaByClassName(className);
|
DbObjectSchema schema = snapAdmin.findSchemaByClassName(className);
|
||||||
|
|
||||||
model.addAttribute("activePage", "entities");
|
model.addAttribute("activePage", "entities");
|
||||||
model.addAttribute("schema", schema);
|
model.addAttribute("schema", schema);
|
||||||
@ -267,7 +267,7 @@ public class DefaultSnapAdminController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/model/{className}/show/{id}")
|
@GetMapping("/model/{className}/show/{id}")
|
||||||
public String show(Model model, @PathVariable String className, @PathVariable String id) {
|
public String show(Model model, @PathVariable String className, @PathVariable String id) {
|
||||||
DbObjectSchema schema = dbAdmin.findSchemaByClassName(className);
|
DbObjectSchema schema = snapAdmin.findSchemaByClassName(className);
|
||||||
|
|
||||||
Object pkValue = schema.getPrimaryKey().getType().parseValue(id);
|
Object pkValue = schema.getPrimaryKey().getType().parseValue(id);
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ public class DefaultSnapAdminController {
|
|||||||
|
|
||||||
@GetMapping("/model/{className}/create")
|
@GetMapping("/model/{className}/create")
|
||||||
public String create(Model model, @PathVariable String className, RedirectAttributes attr) {
|
public String create(Model model, @PathVariable String className, RedirectAttributes attr) {
|
||||||
DbObjectSchema schema = dbAdmin.findSchemaByClassName(className);
|
DbObjectSchema schema = snapAdmin.findSchemaByClassName(className);
|
||||||
|
|
||||||
if (!schema.isCreateEnabled()) {
|
if (!schema.isCreateEnabled()) {
|
||||||
attr.addFlashAttribute("errorTitle", "Unauthorized");
|
attr.addFlashAttribute("errorTitle", "Unauthorized");
|
||||||
@ -307,7 +307,7 @@ public class DefaultSnapAdminController {
|
|||||||
|
|
||||||
@GetMapping("/model/{className}/edit/{id}")
|
@GetMapping("/model/{className}/edit/{id}")
|
||||||
public String edit(Model model, @PathVariable String className, @PathVariable String id, RedirectAttributes attr) {
|
public String edit(Model model, @PathVariable String className, @PathVariable String id, RedirectAttributes attr) {
|
||||||
DbObjectSchema schema = dbAdmin.findSchemaByClassName(className);
|
DbObjectSchema schema = snapAdmin.findSchemaByClassName(className);
|
||||||
|
|
||||||
Object pkValue = schema.getPrimaryKey().getType().parseValue(id);
|
Object pkValue = schema.getPrimaryKey().getType().parseValue(id);
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ public class DefaultSnapAdminController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String delete(@PathVariable String className, @PathVariable String id, RedirectAttributes attr) {
|
public String delete(@PathVariable String className, @PathVariable String id, RedirectAttributes attr) {
|
||||||
DbObjectSchema schema = dbAdmin.findSchemaByClassName(className);
|
DbObjectSchema schema = snapAdmin.findSchemaByClassName(className);
|
||||||
|
|
||||||
if (!schema.isDeleteEnabled()) {
|
if (!schema.isDeleteEnabled()) {
|
||||||
attr.addFlashAttribute("errorTitle", "Unable to DELETE row");
|
attr.addFlashAttribute("errorTitle", "Unable to DELETE row");
|
||||||
@ -374,7 +374,7 @@ public class DefaultSnapAdminController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String delete(@PathVariable String className, @RequestParam String[] ids, RedirectAttributes attr) {
|
public String delete(@PathVariable String className, @RequestParam String[] ids, RedirectAttributes attr) {
|
||||||
DbObjectSchema schema = dbAdmin.findSchemaByClassName(className);
|
DbObjectSchema schema = snapAdmin.findSchemaByClassName(className);
|
||||||
|
|
||||||
if (!schema.isDeleteEnabled()) {
|
if (!schema.isDeleteEnabled()) {
|
||||||
attr.addFlashAttribute("errorTitle", "Unable to DELETE rows");
|
attr.addFlashAttribute("errorTitle", "Unable to DELETE rows");
|
||||||
@ -448,7 +448,7 @@ public class DefaultSnapAdminController {
|
|||||||
|
|
||||||
boolean create = Boolean.parseBoolean(c);
|
boolean create = Boolean.parseBoolean(c);
|
||||||
|
|
||||||
DbObjectSchema schema = dbAdmin.findSchemaByClassName(className);
|
DbObjectSchema schema = snapAdmin.findSchemaByClassName(className);
|
||||||
|
|
||||||
if (!schema.isCreateEnabled() && create) {
|
if (!schema.isCreateEnabled() && create) {
|
||||||
attr.addFlashAttribute("errorTitle", "Unauthorized");
|
attr.addFlashAttribute("errorTitle", "Unauthorized");
|
||||||
@ -536,7 +536,7 @@ public class DefaultSnapAdminController {
|
|||||||
"page",
|
"page",
|
||||||
userActionService.findActions(searchRequest)
|
userActionService.findActions(searchRequest)
|
||||||
);
|
);
|
||||||
model.addAttribute("schemas", dbAdmin.getSchemas());
|
model.addAttribute("schemas", snapAdmin.getSchemas());
|
||||||
model.addAttribute("searchRequest", searchRequest);
|
model.addAttribute("searchRequest", searchRequest);
|
||||||
return "logs";
|
return "logs";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user