@@ -0,0 +1,48 @@
|
||||
package com.cloudhandson.vpdbackoffice.web;
|
||||
|
||||
import com.cloudhandson.vpdbackoffice.domain.protectedobject.ProtectedObjectCreateCommand;
|
||||
import com.cloudhandson.vpdbackoffice.service.ProtectedObjectService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
@Controller
|
||||
public class ProtectedObjectController {
|
||||
|
||||
private final ProtectedObjectService protectedObjectService;
|
||||
|
||||
public ProtectedObjectController(ProtectedObjectService protectedObjectService) {
|
||||
this.protectedObjectService = protectedObjectService;
|
||||
}
|
||||
|
||||
@GetMapping("/objects")
|
||||
public String objects(Model model) {
|
||||
model.addAttribute("objects", protectedObjectService.findEnabled());
|
||||
return "objects";
|
||||
}
|
||||
|
||||
@PostMapping("/objects")
|
||||
public String create(
|
||||
@RequestParam String owner,
|
||||
@RequestParam String objectName,
|
||||
@RequestParam String ordsPath,
|
||||
@RequestParam(required = false) String columns,
|
||||
@RequestParam(required = false) String sensitiveColumns,
|
||||
RedirectAttributes redirectAttributes
|
||||
) {
|
||||
protectedObjectService.createObject(
|
||||
new ProtectedObjectCreateCommand(owner, objectName, ordsPath, columns, sensitiveColumns));
|
||||
redirectAttributes.addFlashAttribute("message", "보호 객체를 추가했습니다.");
|
||||
return "redirect:/objects";
|
||||
}
|
||||
|
||||
@PostMapping("/objects/disable")
|
||||
public String disable(@RequestParam long objectId, RedirectAttributes redirectAttributes) {
|
||||
protectedObjectService.disableObject(objectId);
|
||||
redirectAttributes.addFlashAttribute("message", "보호 객체를 비활성화했습니다.");
|
||||
return "redirect:/objects";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user