Commit 2f8742a7 authored by 高滢's avatar 高滢

车型实验测试用例

parent f54d9f5f
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.List;
@ApiModel( description = "车型实验用例VO")
@Data
public class ItemsByUseCaseVO {
private String id;
private String serialNumber;
private String requirements;
private List<RecaordUseCasesVO> useCases;
}
package com.ruoyi.domain.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@ApiModel( description = "车型实验用例VO")
@Data
public class RecaordUseCasesVO {
private String id;
private String displayID;
private String customizedID;
private String name;
private String description;
private String remediation;
private String requirements;
private String riskLevel;
private String method;
private String scenario;
}
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.web.request.TestPlanRecordGetInfoRequest; import com.ruoyi.web.request.TestPlanRecordGetInfoRequest;
import com.ruoyi.web.request.TestPlanRecordPageRequest; import com.ruoyi.web.request.TestPlanRecordPageRequest;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
...@@ -22,4 +23,6 @@ public interface TTestPlanRecordService extends IService<TTestPlanRecord> { ...@@ -22,4 +23,6 @@ public interface TTestPlanRecordService extends IService<TTestPlanRecord> {
public int updateTestPlanRecord(TestPlanRecordGetInfoRequest testPlanRecordGetInfoRequest); public int updateTestPlanRecord(TestPlanRecordGetInfoRequest testPlanRecordGetInfoRequest);
public List getCarTestDetail (String request) throws IOException;
} }
package com.ruoyi.service.impl; package com.ruoyi.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.domain.TTestPlanRecord; import com.ruoyi.domain.TTestPlanRecord;
import com.ruoyi.domain.vo.ItemsByUseCaseVO;
import com.ruoyi.domain.vo.UseCaseUrlVO;
import com.ruoyi.service.TTestPlanRecordService; import com.ruoyi.service.TTestPlanRecordService;
import com.ruoyi.mapper.TTestPlanRecordMapper; import com.ruoyi.mapper.TTestPlanRecordMapper;
import com.ruoyi.web.request.TestPlanRecordGetInfoRequest; import com.ruoyi.web.request.TestPlanRecordGetInfoRequest;
import com.ruoyi.web.request.TestPlanRecordPageRequest; import com.ruoyi.web.request.TestPlanRecordPageRequest;
import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -46,6 +52,29 @@ public class TTestPlanRecordServiceImpl extends ServiceImpl<TTestPlanRecordMappe ...@@ -46,6 +52,29 @@ public class TTestPlanRecordServiceImpl extends ServiceImpl<TTestPlanRecordMappe
public int updateTestPlanRecord(TestPlanRecordGetInfoRequest testPlanRecordGetInfoRequest){ public int updateTestPlanRecord(TestPlanRecordGetInfoRequest testPlanRecordGetInfoRequest){
return tTestPlanRecordMapper.updateTestPlanRecord(testPlanRecordGetInfoRequest); return tTestPlanRecordMapper.updateTestPlanRecord(testPlanRecordGetInfoRequest);
} }
@Override
public List getCarTestDetail(String request) throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"query\":\"query regulationItemsByUseCase($regulationName:String!$matchUseCases:[String!]!){regulationByName(name:$regulationName){itemsByUseCase(match:$matchUseCases){id serialNumber requirements useCases{id displayID customizedID class name description remediation requirements riskLevel method{name}scenario{name}}}}}\",\"variables\":"+request+"}");
Request requestKs = new Request.Builder()
.url("http://10.12.48.80:8089/api/query")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjAsInRva2VuaWQiOjYxLCJ0eXBlIjoiYXBpIiwidXNlcm5hbWUiOiJhZG1pbiJ9.48Ggjx-FtOcecf73vAHn0XglwgLXZlfXxhXiLDHWWQE")
.build();
Response response = client.newCall(requestKs).execute();
String string = response.body().string();
JSONObject jsonObject = JSONObject.parseObject(string);
// List listUseCase = new ArrayList();
List listUseCase = jsonObject.getJSONObject("data").getJSONObject("regulationByName").getList("itemsByUseCase", ItemsByUseCaseVO.class);
return listUseCase;
}
} }
......
package com.ruoyi.web; package com.ruoyi.web;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
...@@ -14,17 +15,17 @@ import com.ruoyi.web.request.TestPlanRecordGetInfoRequest; ...@@ -14,17 +15,17 @@ import com.ruoyi.web.request.TestPlanRecordGetInfoRequest;
import com.ruoyi.web.request.TestPlanRecordPageRequest; import com.ruoyi.web.request.TestPlanRecordPageRequest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import okhttp3.*;
import org.apache.skywalking.apm.toolkit.trace.Tag; import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags; import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace; import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
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.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import java.io.IOException;
import java.util.List; import java.util.List;
...@@ -83,4 +84,13 @@ public class TestPlanRecordController extends BaseController{ ...@@ -83,4 +84,13 @@ public class TestPlanRecordController extends BaseController{
public R<Integer> updateTestPlanRecord(TestPlanRecordGetInfoRequest testPlanRecordGetInfoRequest){ public R<Integer> updateTestPlanRecord(TestPlanRecordGetInfoRequest testPlanRecordGetInfoRequest){
return R.ok(tTestPlanRecordService.updateTestPlanRecord(testPlanRecordGetInfoRequest)); return R.ok(tTestPlanRecordService.updateTestPlanRecord(testPlanRecordGetInfoRequest));
} }
@ApiOperation("车型实验详情")
@Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@RequestMapping(method = RequestMethod.POST, value = "/useCase")
public R<List> getUseCases(@Validated @RequestBody String request ) throws IOException {
return R.ok(tTestPlanRecordService.getCarTestDetail(request));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment