feat: add dedicated DDS permission backoffice instance
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.cloudhandson.ddsbackoffice.web;
|
||||
|
||||
import com.cloudhandson.ddsbackoffice.domain.DdsQueryResult;
|
||||
import com.cloudhandson.ddsbackoffice.service.DdsQueryService;
|
||||
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;
|
||||
|
||||
@Controller
|
||||
public class DdsController {
|
||||
|
||||
private final DdsQueryService service;
|
||||
|
||||
public DdsController(DdsQueryService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@GetMapping({"/", "/dds"})
|
||||
public String page(Model model) {
|
||||
addOptions(model, "both", "PG", null);
|
||||
return "dds";
|
||||
}
|
||||
|
||||
@PostMapping("/dds/query")
|
||||
public String query(
|
||||
@RequestParam String userKey,
|
||||
@RequestParam String sourceKey,
|
||||
@RequestParam(required = false) String searchText,
|
||||
@RequestParam(defaultValue = "20") int limit,
|
||||
Model model
|
||||
) {
|
||||
DdsQueryResult result;
|
||||
try {
|
||||
result = service.query(userKey, sourceKey, searchText, limit);
|
||||
} catch (IllegalArgumentException e) {
|
||||
result = new DdsQueryResult(
|
||||
userKey, sourceKey, userKey, sourceKey, "-", false,
|
||||
"입력값을 확인하세요.", e.getMessage(), null, null, null, java.util.List.of()
|
||||
);
|
||||
}
|
||||
addOptions(model, userKey, sourceKey, result);
|
||||
return "dds";
|
||||
}
|
||||
|
||||
private void addOptions(Model model, String userKey, String sourceKey, DdsQueryResult result) {
|
||||
var users = service.users();
|
||||
model.addAttribute("users", users);
|
||||
model.addAttribute("configuredUserCount", users.stream().filter(user -> user.configured()).count());
|
||||
model.addAttribute("sources", service.sources());
|
||||
model.addAttribute("selectedUser", userKey);
|
||||
model.addAttribute("selectedSource", sourceKey);
|
||||
model.addAttribute("queryResult", result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.cloudhandson.ddsbackoffice.web;
|
||||
|
||||
import java.util.Map;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class HealthController {
|
||||
|
||||
@GetMapping("/health")
|
||||
public Map<String, String> health() {
|
||||
return Map.of("status", "UP", "track", "DDS");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.cloudhandson.ddsbackoffice.web;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class LoginController {
|
||||
|
||||
@GetMapping("/login")
|
||||
public String login() {
|
||||
return "login";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user