|
@@ -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());
|
|
|
|
+ }
|
|
|
|
+}
|