Переглянути джерело

增加机构查询开放接口

luoshi 2 роки тому
батько
коміт
c22f9363f4

+ 8 - 3
src/main/java/com/qmth/ops/api/controller/open/OpenAppDeployController.java

@@ -5,7 +5,9 @@ import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.core.solar.model.AppInfo;
 import com.qmth.boot.tools.signature.SignatureType;
 import com.qmth.ops.api.constants.OpsApiConstants;
+import com.qmth.ops.api.security.AccessDeploy;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -16,10 +18,13 @@ public class OpenAppDeployController {
 
     @PostMapping("/app/info")
     @Aac(auth = BOOL.FALSE)
-    public AppInfo getAppInfo() {
+    public AppInfo getAppDeployInfo(@RequestAttribute AccessDeploy accessDeploy) {
         AppInfo info = new AppInfo();
-        info.setId(123L);
-        info.setName("测试应用");
+        info.setId(accessDeploy.getDeploy().getId());
+        info.setName(accessDeploy.getDeploy().getName());
+        if (accessDeploy.getDeploy().getControl() != null) {
+            info.setControl(accessDeploy.getDeploy().getControl());
+        }
         return info;
     }
 }

+ 52 - 0
src/main/java/com/qmth/ops/api/controller/open/OpenOrgController.java

@@ -0,0 +1,52 @@
+package com.qmth.ops.api.controller.open;
+
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
+import com.qmth.boot.core.solar.enums.OrgType;
+import com.qmth.boot.core.solar.model.OrgInfo;
+import com.qmth.boot.tools.signature.SignatureType;
+import com.qmth.ops.api.constants.OpsApiConstants;
+import com.qmth.ops.api.security.AccessDeploy;
+import com.qmth.ops.api.vo.CodeNameVO;
+import com.qmth.ops.biz.query.OrgQuery;
+import com.qmth.ops.biz.service.FileService;
+import com.qmth.ops.biz.service.OrgService;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@RestController
+@RequestMapping(OpsApiConstants.OPEN_URI_PREFIX + "/org")
+@Aac(auth = BOOL.TRUE, signType = SignatureType.SECRET)
+public class OpenOrgController {
+
+    @Resource
+    private OrgService orgService;
+
+    @Resource
+    private FileService fileService;
+
+    private Object[] orgTypes = Arrays.stream(OrgType.values())
+            .map(type -> new CodeNameVO(type.toString(), type.getName())).toArray();
+
+    @RequestMapping("/types")
+    @Aac(auth = BOOL.FALSE)
+    public Object[] types() {
+        return orgTypes;
+    }
+
+    @PostMapping("/query")
+    public List<OrgInfo> query(@Validated OrgQuery query, @RequestAttribute AccessDeploy accessDeploy) {
+        query.setEnable(true);
+        query.setDeployId(accessDeploy.getDeploy().getId());
+        return orgService.listByQuery(query).stream().map(org -> org.buildOrgInfo(fileService.getServer()))
+                .collect(Collectors.toList());
+    }
+}

+ 8 - 0
src/main/java/com/qmth/ops/api/security/AccessDeploy.java

@@ -20,4 +20,12 @@ public class AccessDeploy implements AccessEntity {
     public String getSecret() {
         return deploy.getAccessSecret();
     }
+
+    public Deploy getDeploy() {
+        return deploy;
+    }
+
+    public void setDeploy(Deploy deploy) {
+        this.deploy = deploy;
+    }
 }

+ 14 - 0
src/main/java/com/qmth/ops/biz/query/OrgQuery.java

@@ -5,6 +5,9 @@ import com.qmth.boot.core.solar.enums.OrgType;
 import com.qmth.boot.mybatis.query.BaseQuery;
 import com.qmth.ops.biz.domain.Org;
 
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+
 public class OrgQuery extends BaseQuery<Org> {
 
     private static final long serialVersionUID = 1865451038975724572L;
@@ -88,4 +91,15 @@ public class OrgQuery extends BaseQuery<Org> {
     public void setDeployId(Long deployId) {
         this.deployId = deployId;
     }
+
+    @Min(1)
+    public long getPageNumber() {
+        return super.getPageNumber();
+    }
+
+    @Min(1)
+    @Max(100)
+    public long getPageSize() {
+        return super.getPageSize();
+    }
 }