|
|
@@ -0,0 +1,94 @@
|
|
|
+package cn.gov.customs.demo.controller;
|
|
|
+
|
|
|
+import cn.gov.customs.cacp.sdks.auth.*;
|
|
|
+import cn.gov.customs.cacp.sdks.core.config.CacpAppProperties;
|
|
|
+import cn.gov.customs.cacp.sdks.core.result.Result;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+/**
|
|
|
+ * todo
|
|
|
+ *
|
|
|
+ * @author sunxuewen
|
|
|
+ * @date 2024/7/31 13:40
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/auth")
|
|
|
+public class AuthController {
|
|
|
+ private final AuthAdapter adapter;
|
|
|
+ private final CacpAppProperties properties;
|
|
|
+
|
|
|
+ public AuthController(AuthAdapter adapter, CacpAppProperties properties) {
|
|
|
+ this.adapter = adapter;
|
|
|
+ this.properties = properties;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("get-root-organization")
|
|
|
+ public Result<CacpOrganization> getRootOrganization() {
|
|
|
+ Map<String, Object> configuration = this.adapter.getConfiguration();
|
|
|
+ String viewCode = (String) configuration.get("defaultBaseView");
|
|
|
+ CacpOrganization result = this.adapter.getRootOrganization(viewCode);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("get-organization")
|
|
|
+ public Result<CacpOrganization> getOrganization(@RequestParam String orgId) {
|
|
|
+ Map<String, Object> configuration = this.adapter.getConfiguration();
|
|
|
+ String viewCode = (String) configuration.get("defaultBaseView");
|
|
|
+ CacpOrganization result = this.adapter.getOrganization(viewCode, orgId);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("get-organization-by-path")
|
|
|
+ public Result<CacpOrganization> getOrganizationByPath(@RequestParam String orgPath) {
|
|
|
+ Map<String, Object> configuration = this.adapter.getConfiguration();
|
|
|
+ String viewCode = (String) configuration.get("defaultBaseView");
|
|
|
+ CacpOrganization result = this.adapter.getOrganizationByPath(viewCode, orgPath);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("get-organization-list-by-parent")
|
|
|
+ public Result<List<? extends CacpOrganization>> getOrganizationListByParent(@RequestParam String parentPath, @RequestParam boolean oneLevel) {
|
|
|
+ Map<String, Object> configuration = this.adapter.getConfiguration();
|
|
|
+ String viewCode = (String) configuration.get("defaultBaseView");
|
|
|
+ List<? extends CacpOrganization> result = this.adapter.getOrganizationListByParent(viewCode, parentPath, oneLevel);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("get-user")
|
|
|
+ public Result<CacpUser> getUser(@RequestParam String parentId, @RequestParam String userId) {
|
|
|
+ Map<String, Object> configuration = this.adapter.getConfiguration();
|
|
|
+ String viewCode = (String) configuration.get("defaultBaseView");
|
|
|
+ CacpUser result = this.adapter.getUser(viewCode, parentId, userId);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("get-user-list-by-id")
|
|
|
+ public Result<List<? extends CacpUser>> getUserListById(@RequestParam String userId) {
|
|
|
+ Map<String, Object> configuration = this.adapter.getConfiguration();
|
|
|
+ String viewCode = (String) configuration.get("defaultBaseView");
|
|
|
+ List<? extends CacpUser> result = this.adapter.getUserListById(viewCode, userId);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("get-user-list-by-parent")
|
|
|
+ public Result<List<? extends CacpUser>> getUserListByParent(@RequestParam String parentPath, @RequestParam boolean oneLevel) {
|
|
|
+ Map<String, Object> configuration = this.adapter.getConfiguration();
|
|
|
+ String viewCode = (String) configuration.get("defaultBaseView");
|
|
|
+ List<? extends CacpUser> result = this.adapter.getUserListByParent(viewCode, parentPath, oneLevel);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("query-user-list-by-condition")
|
|
|
+ public Result<List<? extends CacpUser>> queryUserListByCondition(@RequestParam String parentPath, @RequestParam String keyword) {
|
|
|
+ Map<String, Object> configuration = this.adapter.getConfiguration();
|
|
|
+ String viewCode = (String) configuration.get("defaultBaseView");
|
|
|
+ List<? extends CacpUser> result = this.adapter.queryUserListByCondition(viewCode, parentPath, keyword);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+}
|