|
@@ -4,7 +4,9 @@ import cn.hutool.core.util.IdUtil;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import space.anyi.openAPI.model.PageVO;
|
|
import space.anyi.openAPI.model.PageVO;
|
|
|
import space.anyi.openAPI.model.ResponseResult;
|
|
import space.anyi.openAPI.model.ResponseResult;
|
|
|
|
|
+import space.anyi.openAPI.model.commom.RequestID;
|
|
|
import space.anyi.openAPI.model.interfaceInfo.InterfaceInfo;
|
|
import space.anyi.openAPI.model.interfaceInfo.InterfaceInfo;
|
|
|
|
|
+import space.anyi.openAPI.model.interfaceInfo.InterfaceStatus;
|
|
|
import space.anyi.openAPI.model.interfaceInfo.dto.RequestAddInterfaceInfo;
|
|
import space.anyi.openAPI.model.interfaceInfo.dto.RequestAddInterfaceInfo;
|
|
|
import space.anyi.openAPI.model.interfaceInfo.dto.RequestPageInterfaceInfo;
|
|
import space.anyi.openAPI.model.interfaceInfo.dto.RequestPageInterfaceInfo;
|
|
|
import space.anyi.openAPI.model.interfaceInfo.dto.RequestUpdateInterfaceInfo;
|
|
import space.anyi.openAPI.model.interfaceInfo.dto.RequestUpdateInterfaceInfo;
|
|
@@ -14,6 +16,7 @@ import space.anyi.openAPI.util.SecurityUtils;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @ProjectName: yangyi-open-api-platform
|
|
* @ProjectName: yangyi-open-api-platform
|
|
@@ -55,4 +58,41 @@ public class InterfaceInfoController {
|
|
|
PageVO pageVO = interfaceInfoService.listPage(requestPageInterfaceInfo);
|
|
PageVO pageVO = interfaceInfoService.listPage(requestPageInterfaceInfo);
|
|
|
return ResponseResult.okResult(pageVO);
|
|
return ResponseResult.okResult(pageVO);
|
|
|
}
|
|
}
|
|
|
|
|
+ @PutMapping("/online")
|
|
|
|
|
+ public ResponseResult onlineInterface(@RequestBody RequestID requestID){
|
|
|
|
|
+ //校验
|
|
|
|
|
+ //接口是否存在
|
|
|
|
|
+ InterfaceInfo interfaceInfo = interfaceInfoService.getById(requestID.getId());
|
|
|
|
|
+ if (Objects.isNull(interfaceInfo)) {
|
|
|
|
|
+ return ResponseResult.errorResult(ResponseResult.AppHttpCodeEnum.INTERFACE_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+ //是否为当前用户创建
|
|
|
|
|
+ if (!SecurityUtils.getUserId().equals(interfaceInfo.getUserId())) {
|
|
|
|
|
+ return ResponseResult.errorResult(ResponseResult.AppHttpCodeEnum.NO_OPERATOR_AUTH);
|
|
|
|
|
+ }
|
|
|
|
|
+ //todo:是否可以调用
|
|
|
|
|
+ //更新状态
|
|
|
|
|
+ interfaceInfo.setStatus(InterfaceStatus.online.getStatus());
|
|
|
|
|
+ interfaceInfoService.updateById(interfaceInfo);
|
|
|
|
|
+ return ResponseResult.okResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PutMapping("/offline")
|
|
|
|
|
+ public ResponseResult offlineInterface(@RequestBody RequestID requestID){
|
|
|
|
|
+ //校验
|
|
|
|
|
+ //接口是否存在
|
|
|
|
|
+ InterfaceInfo interfaceInfo = interfaceInfoService.getById(requestID.getId());
|
|
|
|
|
+ if (Objects.isNull(interfaceInfo)) {
|
|
|
|
|
+ return ResponseResult.errorResult(ResponseResult.AppHttpCodeEnum.INTERFACE_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+ //是否为当前用户创建
|
|
|
|
|
+ if (!SecurityUtils.getUserId().equals(interfaceInfo.getUserId())) {
|
|
|
|
|
+ return ResponseResult.errorResult(ResponseResult.AppHttpCodeEnum.NO_OPERATOR_AUTH);
|
|
|
|
|
+ }
|
|
|
|
|
+ //更新状态
|
|
|
|
|
+ interfaceInfo.setStatus(InterfaceStatus.offline.getStatus());
|
|
|
|
|
+ interfaceInfoService.updateById(interfaceInfo);
|
|
|
|
|
+ return ResponseResult.okResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|