新增检验项目设置中的检验类型页面并实现相关逻辑
This commit is contained in:
39
TestDeleteInspectionType.java
Normal file
39
TestDeleteInspectionType.java
Normal file
@@ -0,0 +1,39 @@
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class TestDeleteInspectionType {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
// 测试删除ID为1的检验类型
|
||||
long inspectionTypeId = 1;
|
||||
URL url = new URL("http://localhost:8080/system/inspection-type/" + inspectionTypeId);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("DELETE");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
|
||||
// 发送请求
|
||||
int responseCode = connection.getResponseCode();
|
||||
System.out.println("响应代码: " + responseCode);
|
||||
|
||||
// 读取响应
|
||||
Scanner scanner;
|
||||
if (responseCode >= 200 && responseCode < 300) {
|
||||
scanner = new Scanner(connection.getInputStream());
|
||||
} else {
|
||||
scanner = new Scanner(connection.getErrorStream());
|
||||
}
|
||||
|
||||
String response = scanner.useDelimiter("\\A").next();
|
||||
System.out.println("响应内容: " + response);
|
||||
|
||||
scanner.close();
|
||||
connection.disconnect();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user