141 lines
5.6 KiB
Java
141 lines
5.6 KiB
Java
package com.unisinsight.project.controller;
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.unisinsight.project.entity.req.DeleteIdReq;
|
|
import com.unisinsight.project.entity.req.ImageVirtualMachinesReq;
|
|
import com.unisinsight.project.entity.res.ImageVirtualMachinesRes;
|
|
import com.unisinsight.project.entity.res.PageResult;
|
|
import com.unisinsight.project.exception.BaseErrorCode;
|
|
import com.unisinsight.project.exception.Result;
|
|
import com.unisinsight.project.service.ImageVirtualMachinesService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* 镜像虚拟机(ImageVirtualMachines)表控制层
|
|
*
|
|
* @author ch
|
|
* @since 2025-08-22 09:42:41
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/api/nex/v1/image/virtual/machines")
|
|
@Slf4j
|
|
@Api(tags = "镜像虚拟机类")
|
|
public class ImageVirtualMachinesController {
|
|
/**
|
|
* 服务对象
|
|
*/
|
|
@Resource
|
|
private ImageVirtualMachinesService service;
|
|
|
|
/**
|
|
* 分页查询所有数据
|
|
*
|
|
*
|
|
* @param imageVirtualMachinesReq 查询实体
|
|
* @return 所有数据
|
|
*/
|
|
@ApiOperation(value = "分页查询镜像")
|
|
@PostMapping("/select/page")
|
|
public Result<PageResult<ImageVirtualMachinesRes>> selectPage(@RequestBody ImageVirtualMachinesReq imageVirtualMachinesReq) {
|
|
if (Objects.isNull(imageVirtualMachinesReq)) {
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
|
}
|
|
log.info("分页查询镜像请求参数为:{}", JSONUtil.toJsonStr(imageVirtualMachinesReq));
|
|
return service.selectPage(imageVirtualMachinesReq);
|
|
}
|
|
@ApiOperation(value = "新增")
|
|
@PostMapping("/add")
|
|
public Result<?> insertImageVirtualMachines(@RequestBody ImageVirtualMachinesReq imageVirtualMachinesReq) {
|
|
if (Objects.isNull(imageVirtualMachinesReq)) {
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
|
}
|
|
log.info("镜像虚拟机新增请求参数为:{}", JSONUtil.toJsonStr(imageVirtualMachinesReq));
|
|
return service.insert(imageVirtualMachinesReq);
|
|
}
|
|
@ApiOperation(value = "镜像虚拟机修改")
|
|
@PostMapping("/update")
|
|
public Result<?> updateUser(@RequestBody ImageVirtualMachinesReq imageVirtualMachinesReq) {
|
|
if (Objects.isNull(imageVirtualMachinesReq)) {
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
|
}
|
|
log.info("镜像虚拟机修改请求参数为:{}", JSONUtil.toJsonStr(imageVirtualMachinesReq));
|
|
return service.update(imageVirtualMachinesReq);
|
|
}
|
|
@ApiOperation(value = "镜像虚拟机查询")
|
|
@PostMapping("/query")
|
|
public Result<?> queryUser(@RequestBody ImageVirtualMachinesReq imageVirtualMachinesReq) {
|
|
if (Objects.isNull(imageVirtualMachinesReq)) {
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
|
}
|
|
log.info("镜像虚拟机查询请求参数为:{}", JSONUtil.toJsonStr(imageVirtualMachinesReq));
|
|
return service.query(imageVirtualMachinesReq);
|
|
}
|
|
|
|
@ApiOperation(value = "终端删除")
|
|
@PostMapping("/delete")
|
|
public Result<?> delete(@RequestBody DeleteIdReq deleteIdReq) {
|
|
if (Objects.isNull(deleteIdReq)) {
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
|
}
|
|
log.info("镜像虚拟机删除请求参数为:{}", JSONUtil.toJsonStr(deleteIdReq));
|
|
return service.delete(deleteIdReq);
|
|
}
|
|
@ApiOperation(value = "终端克隆")
|
|
@PostMapping("/clone/template")
|
|
public Result<?> cloneTemplate(@RequestBody ImageVirtualMachinesReq req) {
|
|
if (Objects.isNull(req)) {
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
|
}
|
|
log.info("镜像虚拟机克隆为模板请求参数为:{}", JSONUtil.toJsonStr(req));
|
|
return service.cloneTemplate(req);
|
|
}
|
|
@ApiOperation(value = "终端启动")
|
|
@PostMapping("/start")
|
|
public Result<?> start(@RequestBody ImageVirtualMachinesReq req) {
|
|
if (Objects.isNull(req)) {
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
|
}
|
|
log.info("终端启动请求参数为:{}", JSONUtil.toJsonStr(req));
|
|
return service.start(req);
|
|
}
|
|
@ApiOperation(value = "终端关闭")
|
|
@PostMapping("/shutdown")
|
|
public Result<?> shutdown(@RequestBody ImageVirtualMachinesReq req) {
|
|
if (Objects.isNull(req)) {
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
|
}
|
|
log.info("终端关闭请求参数为:{}", JSONUtil.toJsonStr(req));
|
|
return service.shutdown(req);
|
|
}
|
|
// @ApiOperation(value = "终端强制关闭")
|
|
// @PostMapping("/destroy")
|
|
// public Result<?> destroy(@RequestBody ImageVirtualMachinesReq req) {
|
|
// if (Objects.isNull(req)) {
|
|
// return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
|
// }
|
|
// log.info("终端强制关闭请求参数为:{}", JSONUtil.toJsonStr(req));
|
|
// return service.destroy(req);
|
|
// }
|
|
@ApiOperation(value = "终端重启")
|
|
@PostMapping("/reboot")
|
|
public Result<?> reboot(@RequestBody ImageVirtualMachinesReq req) {
|
|
if (Objects.isNull(req)) {
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
|
}
|
|
log.info("终端重启请求参数为:{}", JSONUtil.toJsonStr(req));
|
|
return service.reboot(req);
|
|
}
|
|
|
|
}
|
|
|