|
@@ -6,29 +6,23 @@ import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.boot.tools.device.DeviceInfo;
|
|
import com.qmth.boot.tools.device.DeviceInfo;
|
|
import com.qmth.ops.api.constants.OpsApiConstants;
|
|
import com.qmth.ops.api.constants.OpsApiConstants;
|
|
import com.qmth.ops.api.dto.DeployForm;
|
|
import com.qmth.ops.api.dto.DeployForm;
|
|
-import com.qmth.ops.api.vo.CodeNameVO;
|
|
|
|
-import com.qmth.ops.api.vo.DeployPageVO;
|
|
|
|
-import com.qmth.ops.api.vo.DeployVO;
|
|
|
|
-import com.qmth.ops.api.vo.SuccessVO;
|
|
|
|
|
|
+import com.qmth.ops.api.vo.*;
|
|
import com.qmth.ops.biz.domain.Deploy;
|
|
import com.qmth.ops.biz.domain.Deploy;
|
|
import com.qmth.ops.biz.domain.DeployMode;
|
|
import com.qmth.ops.biz.domain.DeployMode;
|
|
import com.qmth.ops.biz.query.DeployQuery;
|
|
import com.qmth.ops.biz.query.DeployQuery;
|
|
-import com.qmth.ops.biz.service.AppService;
|
|
|
|
-import com.qmth.ops.biz.service.DeployService;
|
|
|
|
-import com.qmth.ops.biz.service.FileService;
|
|
|
|
-import com.qmth.ops.biz.service.LicenseService;
|
|
|
|
|
|
+import com.qmth.ops.biz.query.OrgQuery;
|
|
|
|
+import com.qmth.ops.biz.service.*;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping(OpsApiConstants.ADMIN_URI_PREFIX + "/deploy")
|
|
@RequestMapping(OpsApiConstants.ADMIN_URI_PREFIX + "/deploy")
|
|
@@ -46,28 +40,31 @@ public class DeployController {
|
|
@Resource
|
|
@Resource
|
|
private LicenseService licenseService;
|
|
private LicenseService licenseService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private OrgService orgService;
|
|
|
|
+
|
|
@RequestMapping("/modes")
|
|
@RequestMapping("/modes")
|
|
@Aac(auth = BOOL.FALSE)
|
|
@Aac(auth = BOOL.FALSE)
|
|
public Object getModes() {
|
|
public Object getModes() {
|
|
return Arrays.stream(DeployMode.values()).map(item -> new CodeNameVO(item.getCode(), item.getName())).toArray();
|
|
return Arrays.stream(DeployMode.values()).map(item -> new CodeNameVO(item.getCode(), item.getName())).toArray();
|
|
}
|
|
}
|
|
|
|
|
|
- @RequestMapping("/query")
|
|
|
|
|
|
+ @PostMapping("/query")
|
|
public DeployPageVO query(DeployQuery query) {
|
|
public DeployPageVO query(DeployQuery query) {
|
|
return new DeployPageVO(deployService.query(query), appService);
|
|
return new DeployPageVO(deployService.query(query), appService);
|
|
}
|
|
}
|
|
|
|
|
|
- @RequestMapping("/insert")
|
|
|
|
|
|
+ @PostMapping("/insert")
|
|
public DeployVO insert(@Validated(DeployForm.InsertGroup.class) @RequestBody DeployForm form) {
|
|
public DeployVO insert(@Validated(DeployForm.InsertGroup.class) @RequestBody DeployForm form) {
|
|
return new DeployVO(deployService.insert(form.build()), appService);
|
|
return new DeployVO(deployService.insert(form.build()), appService);
|
|
}
|
|
}
|
|
|
|
|
|
- @RequestMapping("/update")
|
|
|
|
|
|
+ @PostMapping("/update")
|
|
public DeployVO update(@Validated(DeployForm.UpdateGroup.class) @RequestBody DeployForm form) {
|
|
public DeployVO update(@Validated(DeployForm.UpdateGroup.class) @RequestBody DeployForm form) {
|
|
return new DeployVO(deployService.update(form.build()), appService);
|
|
return new DeployVO(deployService.update(form.build()), appService);
|
|
}
|
|
}
|
|
|
|
|
|
- @RequestMapping("/device/save")
|
|
|
|
|
|
+ @PostMapping("/device/save")
|
|
public Object saveDevice(@RequestParam Long id, @RequestParam MultipartFile deviceInfo,
|
|
public Object saveDevice(@RequestParam Long id, @RequestParam MultipartFile deviceInfo,
|
|
@RequestParam(required = false) String remark) throws Exception {
|
|
@RequestParam(required = false) String remark) throws Exception {
|
|
Deploy deploy = deployService.findById(id);
|
|
Deploy deploy = deployService.findById(id);
|
|
@@ -78,35 +75,35 @@ public class DeployController {
|
|
}
|
|
}
|
|
String deviceId = info.uuid();
|
|
String deviceId = info.uuid();
|
|
fileService.uploadDeviceInfo(deviceId, info);
|
|
fileService.uploadDeviceInfo(deviceId, info);
|
|
- deployService.bindDevice(id, deviceId, StringUtils.trimToEmpty(remark));
|
|
|
|
|
|
+ deployService.saveDevice(deploy, deviceId, StringUtils.trimToEmpty(remark));
|
|
return new SuccessVO(true);
|
|
return new SuccessVO(true);
|
|
} else {
|
|
} else {
|
|
throw new ApiException(HttpStatus.BAD_REQUEST, 400100, "deploy unexists", null);
|
|
throw new ApiException(HttpStatus.BAD_REQUEST, 400100, "deploy unexists", null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @RequestMapping("/device/delete")
|
|
|
|
|
|
+ @PostMapping("/device/delete")
|
|
public Object deleteDevice(@RequestParam Long id, @RequestParam String deviceId) throws Exception {
|
|
public Object deleteDevice(@RequestParam Long id, @RequestParam String deviceId) throws Exception {
|
|
Deploy deploy = deployService.findById(id);
|
|
Deploy deploy = deployService.findById(id);
|
|
if (deploy != null) {
|
|
if (deploy != null) {
|
|
- deployService.unbindDevice(appId, deviceId);
|
|
|
|
|
|
+ deployService.deleteDevice(deploy, deviceId);
|
|
return new SuccessVO(true);
|
|
return new SuccessVO(true);
|
|
} else {
|
|
} else {
|
|
throw new ApiException(HttpStatus.BAD_REQUEST, 400100, "deploy unexists", null);
|
|
throw new ApiException(HttpStatus.BAD_REQUEST, 400100, "deploy unexists", null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @RequestMapping("/device/list")
|
|
|
|
- public Object listDevice(@RequestParam Long id) throws Exception {
|
|
|
|
- return deployService.listDevice(query);
|
|
|
|
|
|
+ @PostMapping("/device/list")
|
|
|
|
+ public Object listDevice(@RequestParam Long id) {
|
|
|
|
+ return deployService.listDevice(id);
|
|
}
|
|
}
|
|
|
|
|
|
- @RequestMapping("/device/info")
|
|
|
|
|
|
+ @PostMapping("/device/info")
|
|
public Object getDeviceInfo(@RequestParam String deviceId) throws Exception {
|
|
public Object getDeviceInfo(@RequestParam String deviceId) throws Exception {
|
|
return fileService.getDeviceInfo(deviceId).toString();
|
|
return fileService.getDeviceInfo(deviceId).toString();
|
|
}
|
|
}
|
|
|
|
|
|
- @RequestMapping("/license/download")
|
|
|
|
|
|
+ @PostMapping("/license/download")
|
|
public void licenseDownload(HttpServletResponse response, @RequestParam Long id,
|
|
public void licenseDownload(HttpServletResponse response, @RequestParam Long id,
|
|
@RequestParam(required = false) String deviceId, @RequestParam(required = false) String version)
|
|
@RequestParam(required = false) String deviceId, @RequestParam(required = false) String version)
|
|
throws Exception {
|
|
throws Exception {
|
|
@@ -115,4 +112,25 @@ public class DeployController {
|
|
licenseService.buildLicense(deployService.findById(id), deviceId, version, response.getOutputStream());
|
|
licenseService.buildLicense(deployService.findById(id), deviceId, version, response.getOutputStream());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @PostMapping("/org/list")
|
|
|
|
+ public List<OrgVO> listOrg(@RequestParam Long id) {
|
|
|
|
+ OrgQuery query = new OrgQuery();
|
|
|
|
+ query.setDeployId(id);
|
|
|
|
+ query.setEnable(true);
|
|
|
|
+ query.setPageNumber(1);
|
|
|
|
+ query.setPageSize(Long.MAX_VALUE);
|
|
|
|
+ return orgService.listByQuery(query).stream().map(OrgVO::new).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping("/org/update")
|
|
|
|
+ public Object updateOrg(@RequestParam Long id, @RequestParam Long[] orgId) {
|
|
|
|
+ Deploy deploy = deployService.findById(id);
|
|
|
|
+ if (deploy != null) {
|
|
|
|
+ deployService.updateOrg(deploy, orgId);
|
|
|
|
+ return orgId;
|
|
|
|
+ } else {
|
|
|
|
+ throw new ApiException(HttpStatus.BAD_REQUEST, 400100, "deploy unexists", null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|