fix: ASW-161 pcap接口更新
This commit is contained in:
@@ -32,7 +32,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/pcap")
|
||||
@RequestMapping("/api/v1/workspace")
|
||||
public class PcapController {
|
||||
|
||||
private static final Log log = Log.get();
|
||||
@@ -43,26 +43,26 @@ public class PcapController {
|
||||
@Value("${webShark.url:127.0.0.1:8085}")
|
||||
private String websharkurl;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@GetMapping("/{workspaceId}/pcap/{id}")
|
||||
public R detail(@PathVariable("id") String id) {
|
||||
PcapEntity pcapEntity = pcapService.queryInfo(id);
|
||||
return R.ok().putData("record", pcapEntity);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public R list(@RequestParam Map<String, Object> params) {
|
||||
T.VerifyUtil.is(params).notNull()
|
||||
.and(T.MapUtil.getStr(params, "workspaceId")).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
||||
@GetMapping("/{workspaceId}/pcap")
|
||||
public R list(@PathVariable("workspaceId") String workspaceId, @RequestParam Map<String, Object> params) {
|
||||
T.VerifyUtil.is(params).notNull();
|
||||
|
||||
params.put("workspaceId", workspaceId);
|
||||
Page page = pcapService.queryList(params);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@PostMapping("/{workspaceId}/pcap")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R add(@RequestParam(value = "files", required = true) List<MultipartFile> fileList,
|
||||
@RequestParam(value = "descriptions", required = false) List<String> descriptionList,
|
||||
@RequestParam(required = false) String workspaceId) throws IOException {
|
||||
@PathVariable("workspaceId") String workspaceId) throws IOException {
|
||||
T.VerifyUtil.is(workspaceId).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
||||
|
||||
List<Object> recordList = T.ListUtil.list(true);
|
||||
@@ -79,9 +79,9 @@ public class PcapController {
|
||||
return R.ok().putData("records", recordList);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@PutMapping("/{workspaceId}/pcap")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R update(@RequestBody List<Map<String, String>> body) {
|
||||
public R update(@PathVariable("workspaceId") String workspaceId, @RequestBody List<Map<String, String>> body) {
|
||||
List<Object> recordList = T.ListUtil.list(true);
|
||||
for (Map<String, String> map : body) {
|
||||
String id = T.MapUtil.getStr(map, "id", "");
|
||||
@@ -102,7 +102,7 @@ public class PcapController {
|
||||
return R.ok().putData("records", recordList);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@DeleteMapping("/{workspaceId}/pcap")
|
||||
public R delete(String[] ids) {
|
||||
T.VerifyUtil.is(ids).notEmpty();
|
||||
|
||||
@@ -110,7 +110,7 @@ public class PcapController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PutMapping("/parse2session")
|
||||
@PutMapping("/{workspaceId}/pcap/parse2session")
|
||||
public R parse2session(String[] ids) {
|
||||
T.VerifyUtil.is(ids).notEmpty();
|
||||
|
||||
@@ -131,7 +131,7 @@ public class PcapController {
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/download")
|
||||
@GetMapping("/{workspaceId}/pcap/download")
|
||||
public void download(HttpServletResponse response, String ids) throws IOException {
|
||||
T.VerifyUtil.is(ids).notEmpty();
|
||||
List<String> pcapIdList = Arrays.asList(ids.split(","));
|
||||
@@ -150,8 +150,8 @@ public class PcapController {
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/webshark")
|
||||
public R webshark(@PathVariable String id) {
|
||||
@GetMapping("/{workspaceId}/pcap/{id}/webshark")
|
||||
public R webshark(@PathVariable("id") String id) {
|
||||
T.VerifyUtil.is(id).notEmpty();
|
||||
|
||||
HashMap<Object, Object> result = T.MapUtil.newHashMap();
|
||||
@@ -180,7 +180,7 @@ public class PcapController {
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/unparse2session")
|
||||
@PutMapping("/{workspaceId}/pcap/unparse2session")
|
||||
public R unparse2session(String[] ids) {
|
||||
T.VerifyUtil.is(ids).notEmpty();
|
||||
|
||||
@@ -188,14 +188,14 @@ public class PcapController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/explore")
|
||||
public R explore(@RequestParam String workspaceId, @RequestParam String pcapIds, @RequestParam(required = false) String protocol, @RequestParam(required = false) String streamId) {
|
||||
@GetMapping("/{workspaceId}/pcap/explore")
|
||||
public R explore(@PathVariable("workspaceId") String workspaceId, @RequestParam String pcapIds, @RequestParam(required = false) String protocol, @RequestParam(required = false) String streamId) {
|
||||
String discoverUrl = pcapService.generateKibanaDiscoverUrl(workspaceId, pcapIds, protocol, streamId);
|
||||
return R.ok().putData("url", discoverUrl);
|
||||
}
|
||||
|
||||
@GetMapping("/dashboard")
|
||||
public R dashboard(@RequestParam String workspaceId, @RequestParam String pcapIds) {
|
||||
@GetMapping("/{workspaceId}/pcap/dashboard")
|
||||
public R dashboard(@PathVariable("workspaceId") String workspaceId, @RequestParam String pcapIds) {
|
||||
String dashboardUrl = pcapService.generateKibanaDashboardUrl(workspaceId, pcapIds);
|
||||
return R.ok().putData("url", dashboardUrl);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.geedge.asw.common.util.T;
|
||||
import net.geedge.asw.module.app.entity.ApplicationEntity;
|
||||
import net.geedge.asw.module.app.entity.PackageEntity;
|
||||
import net.geedge.asw.module.environment.entity.EnvironmentEntity;
|
||||
import net.geedge.asw.module.sys.entity.SysUserEntity;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceEntity;
|
||||
|
||||
import java.nio.file.Path;
|
||||
@@ -50,6 +51,9 @@ public class PcapEntity {
|
||||
@TableField(exist = false)
|
||||
private PlaybookEntity playbook;
|
||||
|
||||
@TableField(exist = false)
|
||||
private SysUserEntity createUser;
|
||||
|
||||
@JsonIgnore
|
||||
public Path getCommonPcapFilePath() {
|
||||
return Path.of(T.WebPathUtil.getRootPath(), this.workspaceId, "pcap_comment", this.id + ".pcapng");
|
||||
|
||||
@@ -34,7 +34,9 @@ import net.geedge.asw.module.runner.service.IPcapService;
|
||||
import net.geedge.asw.module.runner.service.IPlaybookService;
|
||||
import net.geedge.asw.module.runner.util.PcapParserThread;
|
||||
import net.geedge.asw.module.runner.util.RunnerConstant;
|
||||
import net.geedge.asw.module.sys.entity.SysUserEntity;
|
||||
import net.geedge.asw.module.sys.service.ISysConfigService;
|
||||
import net.geedge.asw.module.sys.service.ISysUserService;
|
||||
import net.geedge.asw.module.workbook.service.IWorkbookResourceService;
|
||||
import net.geedge.asw.module.workbook.util.WorkbookConstant;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceEntity;
|
||||
@@ -79,18 +81,15 @@ public class PcapServiceImpl extends ServiceImpl<PcapDao, PcapEntity> implements
|
||||
@Autowired
|
||||
private IPackageService packageService;
|
||||
|
||||
@Autowired
|
||||
private IApplicationService applicationService;
|
||||
|
||||
@Autowired
|
||||
private IWorkbookResourceService workbookResourceService;
|
||||
|
||||
@Autowired
|
||||
private IWorkspaceService workspaceService;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Value("${kibana.url:127.0.0.1:5601}")
|
||||
private String kibanaUrl;
|
||||
|
||||
@@ -108,6 +107,9 @@ public class PcapServiceImpl extends ServiceImpl<PcapDao, PcapEntity> implements
|
||||
PcapEntity pcap = this.getById(id);
|
||||
T.VerifyUtil.is(pcap).notNull(RCode.SYS_RECORD_NOT_FOUND);
|
||||
|
||||
SysUserEntity user = userService.getById(pcap.getCreateUserId());
|
||||
pcap.setCreateUser(user);
|
||||
|
||||
JobEntity job = jobService.getOne(new LambdaQueryWrapper<JobEntity>().eq(JobEntity::getId, pcap.getJobId()));
|
||||
if (T.ObjectUtil.isNotNull(job)) {
|
||||
pcap.setJobId(job.getId());
|
||||
|
||||
@@ -34,6 +34,12 @@
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
<association property="createUser" columnPrefix="cu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="userName" column="user_name"/>
|
||||
</association>
|
||||
|
||||
</resultMap>
|
||||
|
||||
<select id="queryList" resultMap="pcapResultMap">
|
||||
@@ -49,13 +55,17 @@
|
||||
env.name AS em_name,
|
||||
|
||||
pb.id AS pb_id,
|
||||
pb.name AS pb_name
|
||||
pb.name AS pb_name,
|
||||
su.id AS cu_id,
|
||||
su.name AS cu_name,
|
||||
su.user_name AS cu_user_name
|
||||
FROM
|
||||
pcap pcap
|
||||
left join job job on pcap.job_id = job.id
|
||||
LEFT JOIN environment env ON job.env_id = env.id
|
||||
LEFT JOIN package pkg ON job.package_id = pkg.id
|
||||
LEFT JOIN playbook pb ON job.playbook_id = pb.id
|
||||
LEFT JOIN sys_user su ON su.id = pb.create_user_id
|
||||
<where>
|
||||
<if test="params.ids != null and params.ids != ''">
|
||||
pcap.id in
|
||||
|
||||
Reference in New Issue
Block a user