feat: ASW-7 新增 Package 相关接口
This commit is contained in:
@@ -26,6 +26,7 @@ public enum RCode {
|
||||
|
||||
// Package
|
||||
PACKAGE_ID_CANNOT_EMPTY(202001, "package id cannot be empty"),
|
||||
PACKAGE_DESCRIPTION_CANNOT_EMPTY(202002, "package description cannot be empty"),
|
||||
|
||||
|
||||
// Runner
|
||||
@@ -35,6 +36,10 @@ public enum RCode {
|
||||
// Playbook
|
||||
PLAYBOOK_ID_CANNOT_EMPTY(302001, "playbook id cannot be empty"),
|
||||
|
||||
|
||||
// Workspace
|
||||
WORKSPACE_ID_CANNOT_EMPTY(401001, "workspace id cannot be empty"),
|
||||
|
||||
SUCCESS(200, "success"); // 成功
|
||||
|
||||
private RCode(Integer code, String msg) {
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package net.geedge.asw.common.util;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Robot;
|
||||
import java.lang.ref.PhantomReference;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
import java.awt.*;
|
||||
import java.lang.ref.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.Socket;
|
||||
@@ -16,24 +21,10 @@ import java.security.SecureRandom;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.Temporal;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Spliterator;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
|
||||
public class T {
|
||||
|
||||
public static final Pattern REGEX_SPECIAL_DATE = Pattern
|
||||
@@ -315,6 +306,27 @@ public class T {
|
||||
* @author xiaoleilu
|
||||
*/
|
||||
public static class PageUtil extends cn.hutool.core.util.PageUtil {
|
||||
public static final Integer DEFAULT_PAGENO = 1;
|
||||
public static final Integer DEFAULT_PAGESIZE = 20;
|
||||
|
||||
public static Page getPage(Map<String, Object> params) {
|
||||
// 分页参数
|
||||
Integer pageNo = T.MapUtil.getInt(params, "current", DEFAULT_PAGENO);
|
||||
Integer pageSize = T.MapUtil.getInt(params, "size", DEFAULT_PAGESIZE);
|
||||
if (pageSize == -1) {
|
||||
pageNo = 0;
|
||||
pageSize = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
Page page = Page.of(pageNo, pageSize);
|
||||
|
||||
String orderBy = T.MapUtil.getStr(params, "orderBy");
|
||||
if (T.StrUtil.isNotEmpty(orderBy)) {
|
||||
page.addOrder(T.PageUtil.decodeOrderByStr(orderBy));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
public static OrderItem decodeOrderByStr(String orderBy) {
|
||||
if (cn.hutool.core.util.StrUtil.isBlank(orderBy)) {
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package net.geedge.asw.module.app.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.geedge.asw.common.util.R;
|
||||
import net.geedge.asw.common.util.RCode;
|
||||
import net.geedge.asw.common.util.T;
|
||||
import net.geedge.asw.module.app.entity.PackageEntity;
|
||||
import net.geedge.asw.module.app.service.IPackageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/package")
|
||||
public class PackageController {
|
||||
|
||||
@Autowired
|
||||
private IPackageService packageService;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public R detail(@PathVariable("id") String id) {
|
||||
PackageEntity entity = packageService.getById(id);
|
||||
return R.ok().putData("record", entity);
|
||||
}
|
||||
|
||||
@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);
|
||||
Page page = packageService.queryList(params);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public R add(@RequestBody PackageEntity entity) {
|
||||
T.VerifyUtil.is(entity).notNull()
|
||||
.and(entity.getName()).notEmpty(RCode.NAME_CANNOT_EMPTY)
|
||||
.and(entity.getDescription()).notEmpty(RCode.PACKAGE_DESCRIPTION_CANNOT_EMPTY)
|
||||
.and(entity.getWorkspaceId()).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
||||
|
||||
PackageEntity pkgEntity = packageService.savePackage(entity);
|
||||
return R.ok().putData("id", pkgEntity.getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public R update(@RequestBody PackageEntity entity) {
|
||||
T.VerifyUtil.is(entity).notNull()
|
||||
.and(entity.getId()).notEmpty(RCode.ID_CANNOT_EMPTY)
|
||||
.and(entity.getName()).notEmpty(RCode.NAME_CANNOT_EMPTY)
|
||||
.and(entity.getDescription()).notEmpty(RCode.PACKAGE_DESCRIPTION_CANNOT_EMPTY)
|
||||
.and(entity.getWorkspaceId()).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
||||
|
||||
PackageEntity pkgEntity = packageService.updatePackage(entity);
|
||||
return R.ok().putData("id", pkgEntity.getId());
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public R delete(String[] ids) {
|
||||
T.VerifyUtil.is(ids).notEmpty();
|
||||
packageService.removePackage(T.ListUtil.of(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,16 @@
|
||||
package net.geedge.asw.module.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.geedge.asw.module.app.entity.PackageEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface PackageDao extends BaseMapper<PackageEntity>{
|
||||
|
||||
List<PackageEntity> queryList(Page page, Map<String, Object> params);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.geedge.asw.module.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.geedge.asw.module.app.entity.SignatureEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SignatureDao extends BaseMapper<SignatureEntity>{
|
||||
|
||||
}
|
||||
@@ -22,4 +22,6 @@ public class ApplicationEntity {
|
||||
private String createUserId;
|
||||
private String updateUserId;
|
||||
|
||||
private String workspaceId;
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.geedge.asw.module.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@@ -11,6 +12,7 @@ public class PackageEntity {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
private String name;
|
||||
private String logo;
|
||||
private String description;
|
||||
private String platform;
|
||||
@@ -22,4 +24,9 @@ public class PackageEntity {
|
||||
private String createUserId;
|
||||
private String updateUserId;
|
||||
|
||||
private String workspaceId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String workbookId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.geedge.asw.module.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("signature")
|
||||
public class SignatureEntity {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
private String appId;
|
||||
private String name;
|
||||
private String tags;
|
||||
private String description;
|
||||
private Integer displayFlag;
|
||||
private String conditions;
|
||||
private Long opVersion;
|
||||
|
||||
private Long createTimestamp;
|
||||
private Long updateTimestamp;
|
||||
private String createUserId;
|
||||
private String updateUserId;
|
||||
|
||||
private String workspaceId;
|
||||
|
||||
}
|
||||
@@ -1,8 +1,19 @@
|
||||
package net.geedge.asw.module.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import net.geedge.asw.module.app.entity.PackageEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IPackageService extends IService<PackageEntity>{
|
||||
|
||||
Page queryList(Map<String, Object> params);
|
||||
|
||||
PackageEntity savePackage(PackageEntity entity);
|
||||
|
||||
PackageEntity updatePackage(PackageEntity entity);
|
||||
|
||||
void removePackage(List<String> ids);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.geedge.asw.module.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import net.geedge.asw.module.app.entity.SignatureEntity;
|
||||
|
||||
public interface ISignatureService extends IService<SignatureEntity>{
|
||||
|
||||
}
|
||||
@@ -1,13 +1,90 @@
|
||||
package net.geedge.asw.module.app.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.geedge.asw.common.util.ASWException;
|
||||
import net.geedge.asw.common.util.RCode;
|
||||
import net.geedge.asw.common.util.T;
|
||||
import net.geedge.asw.module.app.dao.PackageDao;
|
||||
import net.geedge.asw.module.app.entity.PackageEntity;
|
||||
import net.geedge.asw.module.app.service.IPackageService;
|
||||
import net.geedge.asw.module.workbook.service.IWorkbookResourceService;
|
||||
import net.geedge.asw.module.workbook.util.WorkbookConstant;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class PackageServiceImpl extends ServiceImpl<PackageDao, PackageEntity> implements IPackageService {
|
||||
|
||||
@Autowired
|
||||
private IWorkbookResourceService workbookResourceService;
|
||||
|
||||
@Override
|
||||
public Page queryList(Map<String, Object> params) {
|
||||
Page page = T.PageUtil.getPage(params);
|
||||
List<PackageEntity> packageList = this.getBaseMapper().queryList(page, params);
|
||||
page.setRecords(packageList);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PackageEntity savePackage(PackageEntity entity) {
|
||||
PackageEntity one = this.getOne(new LambdaQueryWrapper<PackageEntity>()
|
||||
.eq(PackageEntity::getWorkspaceId, entity.getWorkspaceId())
|
||||
.eq(PackageEntity::getName, entity.getName()));
|
||||
if (T.ObjectUtil.isNotNull(one)) {
|
||||
throw ASWException.builder().rcode(RCode.SYS_DUPLICATE_RECORD).build();
|
||||
}
|
||||
|
||||
entity.setCreateTimestamp(System.currentTimeMillis());
|
||||
entity.setUpdateTimestamp(System.currentTimeMillis());
|
||||
entity.setCreateUserId(StpUtil.getLoginIdAsString());
|
||||
entity.setUpdateUserId(StpUtil.getLoginIdAsString());
|
||||
|
||||
// save
|
||||
this.save(entity);
|
||||
|
||||
// workbook resource
|
||||
workbookResourceService.saveResource(entity.getWorkbookId(), entity.getId(), WorkbookConstant.ResourceType.PACKAGE.getValue());
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PackageEntity updatePackage(PackageEntity entity) {
|
||||
PackageEntity one = this.getOne(new LambdaQueryWrapper<PackageEntity>()
|
||||
.eq(PackageEntity::getWorkspaceId, entity.getWorkspaceId())
|
||||
.eq(PackageEntity::getName, entity.getName())
|
||||
.ne(PackageEntity::getId, entity.getId()));
|
||||
if (T.ObjectUtil.isNotNull(one)) {
|
||||
throw ASWException.builder().rcode(RCode.SYS_DUPLICATE_RECORD).build();
|
||||
}
|
||||
|
||||
entity.setUpdateTimestamp(System.currentTimeMillis());
|
||||
entity.setUpdateUserId(StpUtil.getLoginIdAsString());
|
||||
|
||||
// update
|
||||
this.updateById(entity);
|
||||
|
||||
// workbook resource
|
||||
workbookResourceService.saveResource(entity.getWorkbookId(), entity.getId(), WorkbookConstant.ResourceType.PACKAGE.getValue());
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removePackage(List<String> ids) {
|
||||
// remove
|
||||
this.removeBatchByIds(ids);
|
||||
// workbook resource
|
||||
workbookResourceService.removeResource(ids, WorkbookConstant.ResourceType.PACKAGE.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.geedge.asw.module.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.geedge.asw.module.app.dao.SignatureDao;
|
||||
import net.geedge.asw.module.app.entity.SignatureEntity;
|
||||
import net.geedge.asw.module.app.service.ISignatureService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SignatureServiceImpl extends ServiceImpl<SignatureDao, SignatureEntity> implements ISignatureService {
|
||||
|
||||
|
||||
}
|
||||
@@ -27,6 +27,8 @@ public class JobController {
|
||||
|
||||
@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);
|
||||
Page page = jobService.queryList(params);
|
||||
return R.ok(page);
|
||||
}
|
||||
@@ -34,9 +36,9 @@ public class JobController {
|
||||
@PostMapping
|
||||
public R add(@RequestBody JobEntity entity) {
|
||||
T.VerifyUtil.is(entity).notNull()
|
||||
.and(entity.getRunnerId()).notNull(RCode.RUNNER_ID_CANNOT_EMPTY)
|
||||
.and(entity.getPackageId()).notNull(RCode.PACKAGE_ID_CANNOT_EMPTY)
|
||||
.and(entity.getPlaybookId()).notNull(RCode.PLAYBOOK_ID_CANNOT_EMPTY);
|
||||
.and(entity.getRunnerId()).notEmpty(RCode.RUNNER_ID_CANNOT_EMPTY)
|
||||
.and(entity.getPackageId()).notEmpty(RCode.PACKAGE_ID_CANNOT_EMPTY)
|
||||
.and(entity.getWorkspaceId()).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
|
||||
|
||||
JobEntity jobEntity = jobService.saveJob(entity);
|
||||
return R.ok().putData("id", jobEntity.getId());
|
||||
@@ -51,6 +53,7 @@ public class JobController {
|
||||
|
||||
@PutMapping("/cancel")
|
||||
public R cancel(String[] ids) {
|
||||
T.VerifyUtil.is(ids).notEmpty();
|
||||
// TODO 其他处理
|
||||
|
||||
// update state
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.geedge.asw.module.runner.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.geedge.asw.module.runner.entity.DecodeRecordEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface DecodeRecordDao extends BaseMapper<DecodeRecordEntity>{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.geedge.asw.module.runner.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("decode_record")
|
||||
public class DecodeRecordEntity {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
private String pcapId;
|
||||
private Long streamId;
|
||||
private String streamAttributes;
|
||||
private String workspaceId;
|
||||
|
||||
}
|
||||
@@ -32,6 +32,8 @@ public class JobEntity {
|
||||
private String createUserId;
|
||||
private String updateUserId;
|
||||
|
||||
private String workspaceId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String workbookId;
|
||||
|
||||
|
||||
@@ -11,11 +11,20 @@ public class PcapEntity {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
private String name;
|
||||
private String tags;
|
||||
private String description;
|
||||
private String path;
|
||||
|
||||
private Long size;
|
||||
private Long connections;
|
||||
private Long hosts;
|
||||
private String md5;
|
||||
private Long connectionTimeFirst;
|
||||
private Long connectionTimeLast;
|
||||
private String protocols;
|
||||
private String status;
|
||||
private Long createTimestamp;
|
||||
private String createUserId;
|
||||
private String workspaceId;
|
||||
|
||||
}
|
||||
@@ -15,11 +15,13 @@ public class PlaybookEntity {
|
||||
private String appId;
|
||||
private String tags;
|
||||
private String script;
|
||||
private String opVersion;
|
||||
private Long opVersion;
|
||||
|
||||
private Long createTimestamp;
|
||||
private Long updateTimestamp;
|
||||
private String createUserId;
|
||||
private String updateUserId;
|
||||
|
||||
private String workspaceId;
|
||||
|
||||
}
|
||||
@@ -24,4 +24,6 @@ public class RunnerEntity {
|
||||
private String createUserId;
|
||||
private String updateUserId;
|
||||
|
||||
private String workspaceId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.geedge.asw.module.runner.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import net.geedge.asw.module.runner.entity.DecodeRecordEntity;
|
||||
|
||||
public interface IDecodeRecordService extends IService<DecodeRecordEntity>{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.geedge.asw.module.runner.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.geedge.asw.module.runner.dao.DecodeRecordDao;
|
||||
import net.geedge.asw.module.runner.entity.DecodeRecordEntity;
|
||||
import net.geedge.asw.module.runner.service.IDecodeRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class DecodeRecordServiceImpl extends ServiceImpl<DecodeRecordDao, DecodeRecordEntity> implements IDecodeRecordService {
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.geedge.asw.module.runner.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.geedge.asw.common.util.RCode;
|
||||
@@ -17,7 +16,6 @@ import net.geedge.asw.module.runner.entity.RunnerEntity;
|
||||
import net.geedge.asw.module.runner.service.IJobService;
|
||||
import net.geedge.asw.module.runner.service.IPlaybookService;
|
||||
import net.geedge.asw.module.runner.service.IRunnerService;
|
||||
import net.geedge.asw.module.workbook.entity.WorkbookResourceEntity;
|
||||
import net.geedge.asw.module.workbook.service.IWorkbookResourceService;
|
||||
import net.geedge.asw.module.workbook.util.WorkbookConstant;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -68,12 +66,7 @@ public class JobServiceImpl extends ServiceImpl<JobDao, JobEntity> implements IJ
|
||||
|
||||
@Override
|
||||
public Page queryList(Map<String, Object> params) {
|
||||
Integer current = T.MapUtil.getInt(params, "current", 1);
|
||||
Integer size = T.MapUtil.getInt(params, "size", 20);
|
||||
String orderBy = T.MapUtil.getStr(params, "orderBy", "id");
|
||||
Page<JobEntity> page = Page.of(current, size);
|
||||
page.addOrder(T.PageUtil.decodeOrderByStr(orderBy));
|
||||
|
||||
Page page = T.PageUtil.getPage(params);
|
||||
List<JobEntity> jobList = this.getBaseMapper().queryList(page, params);
|
||||
page.setRecords(jobList);
|
||||
return page;
|
||||
@@ -91,13 +84,7 @@ public class JobServiceImpl extends ServiceImpl<JobDao, JobEntity> implements IJ
|
||||
this.save(entity);
|
||||
|
||||
// workbook resource
|
||||
if (T.ObjectUtil.isNotEmpty(entity.getWorkbookId())) {
|
||||
WorkbookResourceEntity res = new WorkbookResourceEntity();
|
||||
res.setWorkbookId(entity.getWorkbookId());
|
||||
res.setResourceType(WorkbookConstant.ResourceType.JOB.getValue());
|
||||
res.setResourceId(entity.getId());
|
||||
workbookResourceService.save(res);
|
||||
}
|
||||
workbookResourceService.saveResource(entity.getWorkbookId(), entity.getId(), WorkbookConstant.ResourceType.JOB.getValue());
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -107,9 +94,7 @@ public class JobServiceImpl extends ServiceImpl<JobDao, JobEntity> implements IJ
|
||||
// remove
|
||||
this.removeBatchByIds(ids);
|
||||
// workbook resource
|
||||
workbookResourceService.remove(new LambdaQueryWrapper<WorkbookResourceEntity>()
|
||||
.eq(WorkbookResourceEntity::getResourceType, WorkbookConstant.ResourceType.JOB.getValue())
|
||||
.in(WorkbookResourceEntity::getResourceId, ids));
|
||||
workbookResourceService.removeResource(ids, WorkbookConstant.ResourceType.JOB.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,12 @@ package net.geedge.asw.module.workbook.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import net.geedge.asw.module.workbook.entity.WorkbookResourceEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IWorkbookResourceService extends IService<WorkbookResourceEntity>{
|
||||
|
||||
void saveResource(String workbookId, String resourceId, String type);
|
||||
|
||||
void removeResource(List<String> resourceIdList, String type);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,50 @@
|
||||
package net.geedge.asw.module.workbook.service.impl;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.geedge.asw.common.util.T;
|
||||
import net.geedge.asw.module.workbook.dao.WorkbookResourceDao;
|
||||
import net.geedge.asw.module.workbook.entity.WorkbookResourceEntity;
|
||||
import net.geedge.asw.module.workbook.service.IWorkbookResourceService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class WorkbookResourceServiceImpl extends ServiceImpl<WorkbookResourceDao, WorkbookResourceEntity> implements IWorkbookResourceService {
|
||||
|
||||
private static final Log log = Log.get();
|
||||
|
||||
@Override
|
||||
public void saveResource(String wbId, String resId, String type) {
|
||||
if (T.StrUtil.hasEmpty(wbId, resId, type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove
|
||||
this.remove(new LambdaQueryWrapper<WorkbookResourceEntity>()
|
||||
.eq(WorkbookResourceEntity::getResourceId, resId)
|
||||
.eq(WorkbookResourceEntity::getResourceType, type));
|
||||
|
||||
// insert
|
||||
WorkbookResourceEntity res = new WorkbookResourceEntity();
|
||||
res.setWorkbookId(wbId);
|
||||
res.setResourceId(resId);
|
||||
res.setResourceType(type);
|
||||
this.save(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeResource(List<String> resIdList, String type) {
|
||||
if (T.CollUtil.isEmpty(resIdList) || T.StrUtil.isEmpty(type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove
|
||||
this.remove(new LambdaQueryWrapper<WorkbookResourceEntity>()
|
||||
.eq(WorkbookResourceEntity::getResourceType, type)
|
||||
.in(WorkbookResourceEntity::getResourceId, resIdList));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.geedge.asw.module.workspace.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface WorkspaceDao extends BaseMapper<WorkspaceEntity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.geedge.asw.module.workspace.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceMemberEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface WorkspaceMemberDao extends BaseMapper<WorkspaceMemberEntity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.geedge.asw.module.workspace.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("workspace")
|
||||
public class WorkspaceEntity {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
private String name;
|
||||
private String tags;
|
||||
private String visibility;
|
||||
private String description;
|
||||
|
||||
private Long createTimestamp;
|
||||
private Long updateTimestamp;
|
||||
private String createUserId;
|
||||
private String updateUserId;
|
||||
|
||||
private String workspaceId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.geedge.asw.module.workspace.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("workspace_member")
|
||||
public class WorkspaceMemberEntity {
|
||||
|
||||
private String workspaceId;
|
||||
private String userId;
|
||||
private String roleId;
|
||||
|
||||
private Long createTimestamp;
|
||||
private String createUserId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.geedge.asw.module.workspace.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceMemberEntity;
|
||||
|
||||
public interface IWorkspaceMemberService extends IService<WorkspaceMemberEntity>{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.geedge.asw.module.workspace.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceEntity;
|
||||
|
||||
public interface IWorkspaceService extends IService<WorkspaceEntity>{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.geedge.asw.module.workspace.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.geedge.asw.module.workspace.dao.WorkspaceMemberDao;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceMemberEntity;
|
||||
import net.geedge.asw.module.workspace.service.IWorkspaceMemberService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class WorkspaceMemberServiceImpl extends ServiceImpl<WorkspaceMemberDao, WorkspaceMemberEntity> implements IWorkspaceMemberService {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.geedge.asw.module.workspace.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.geedge.asw.module.workspace.dao.WorkspaceDao;
|
||||
import net.geedge.asw.module.workspace.entity.WorkspaceEntity;
|
||||
import net.geedge.asw.module.workspace.service.IWorkspaceService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceDao, WorkspaceEntity> implements IWorkspaceService {
|
||||
|
||||
|
||||
}
|
||||
41
src/main/resources/db/mapper/app/PackageMapper.xml
Normal file
41
src/main/resources/db/mapper/app/PackageMapper.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="net.geedge.asw.module.app.dao.PackageDao">
|
||||
|
||||
|
||||
<select id="queryList" resultType="net.geedge.asw.module.app.entity.PackageEntity">
|
||||
SELECT
|
||||
pkg.*
|
||||
FROM
|
||||
package pkg
|
||||
LEFT JOIN workbook_resource wr ON pkg.id = wr.resource_id AND wr.resource_type = 'package'
|
||||
<where>
|
||||
<if test="params.ids != null and params.ids != ''">
|
||||
pkg.id in
|
||||
<foreach item="id" collection="params.ids.split(',')" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="params.q != null and params.q != ''">
|
||||
AND ( locate(#{params.q}, pkg.name) OR locate(#{params.q}, pkg.description) )
|
||||
</if>
|
||||
|
||||
<if test="params.workbookId != null and params.workbookId != ''">
|
||||
AND wr.workbook_id = #{params.workbookId}
|
||||
</if>
|
||||
|
||||
<if test="params.workspaceId != null and params.workspaceId != ''">
|
||||
AND pkg.workspace_id = #{params.workspaceId}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
GROUP BY
|
||||
pkg.id
|
||||
<if test="params.orderBy == null or params.orderBy == ''">
|
||||
ORDER BY pkg.id
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -21,6 +21,7 @@
|
||||
<result property="updateTimestamp" column="update_timestamp"/>
|
||||
<result property="createUserId" column="create_user_id"/>
|
||||
<result property="updateUserId" column="update_user_id"/>
|
||||
<result property="workspaceId" column="workspace_id"/>
|
||||
|
||||
<association property="pkg" columnPrefix="pkg_" javaType="net.geedge.asw.module.app.entity.PackageEntity">
|
||||
<id property="id" column="id"/>
|
||||
@@ -70,6 +71,7 @@
|
||||
LEFT JOIN package pkg ON job.package_id = pkg.id
|
||||
LEFT JOIN playbook pb ON job.playbook_id = pb.id
|
||||
LEFT JOIN application app ON pb.app_id = app.id
|
||||
LEFT JOIN workbook_resource wr ON job.id = wr.resource_id AND wr.resource_type = 'job'
|
||||
<where>
|
||||
<if test="params.ids != null and params.ids != ''">
|
||||
job.id in
|
||||
@@ -101,10 +103,22 @@
|
||||
locate(#{item}, job.signature_ids)
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="params.workbookId != null and params.workbookId != ''">
|
||||
AND wr.workbook_id = #{params.workbookId}
|
||||
</if>
|
||||
|
||||
<if test="params.workspaceId != null and params.workspaceId != ''">
|
||||
AND job.workspace_id = #{params.workspaceId}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
GROUP BY
|
||||
job.id
|
||||
|
||||
<if test="params.orderBy == null or params.orderBy == ''">
|
||||
ORDER BY job.id
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -47,6 +47,10 @@ INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (51, '301001', 'RUNNER_ID_CANNOT_EMPTY', 'Runner ID不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (53, '302001', 'PLAYBOOK_ID_CANNOT_EMPTY', 'playbook id cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (55, '302001', 'PLAYBOOK_ID_CANNOT_EMPTY', '任务信息ID不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (57, '202002', 'PACKAGE_DESCRIPTION_CANNOT_EMPTY', 'package description cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (59, '202002', 'PACKAGE_DESCRIPTION_CANNOT_EMPTY', '安装包描述信息不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (61, '401001', 'WORKSPACE_ID_CANNOT_EMPTY', 'workspace id cannot be empty', 'en', '', 'admin', 1719280800000);
|
||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (63, '401001', 'WORKSPACE_ID_CANNOT_EMPTY', '工作空间ID不能为空', 'zh', '', 'admin', 1719280800000);
|
||||
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -135,30 +135,26 @@ CREATE TABLE `sys_file_content` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
/**
|
||||
* 新增 job 表
|
||||
* 新增 runner 表
|
||||
*/
|
||||
DROP TABLE IF EXISTS `job`;
|
||||
CREATE TABLE `job` (
|
||||
DROP TABLE IF EXISTS `runner`;
|
||||
CREATE TABLE `runner` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`playbook_id` varchar(64) NOT NULL COMMENT 'Playbook ID',
|
||||
`package_id` varchar(64) NOT NULL COMMENT 'Package ID',
|
||||
`runner_id` varchar(64) NOT NULL COMMENT 'Runner ID',
|
||||
`schedule_id` varchar(64) NOT NULL COMMENT '定时器ID',
|
||||
`signature_ids` text NOT NULL COMMENT '特征ID,多个逗号分隔',
|
||||
`tags` varchar(256) NOT NULL DEFAULT '' COMMENT '标签; 默认:"";多个用逗号分隔;例:kz,vpn,android',
|
||||
`start_timestamp` bigint(20) NOT NULL COMMENT '开始时间戳',
|
||||
`end_timestamp` bigint(20) NOT NULL COMMENT '结束时间戳',
|
||||
`status` varchar(64) NOT NULL COMMENT '状态; 可选值: created,pending,running,passed,failed,cancel',
|
||||
`pcap_id` varchar(64) NOT NULL COMMENT 'PCAP ID',
|
||||
`log_path` varchar(256) NOT NULL COMMENT '日志文件路径',
|
||||
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '名称',
|
||||
`tags` varchar(256) NOT NULL DEFAULT '' COMMENT '标签,多个逗号分隔',
|
||||
`support_platforms` varchar(256) NOT NULL DEFAULT '' COMMENT '支持的平台; 可选值:android,ios,windows; 多个逗号分隔; 例:android,ios',
|
||||
`share_flag` int(1) NOT NULL DEFAULT 1 COMMENT '共享标识; 1:共享 0:不共享,仅创建人可用',
|
||||
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
||||
`status` varchar(64) NOT NULL DEFAULT 'online' COMMENT '状态;可选值:online,offline',
|
||||
`last_heartbeat_timestamp` bigint(20) NOT NULL DEFAULT (UNIX_TIMESTAMP(NOW()) * 1000) COMMENT '最后心跳时间戳',
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
`update_user_id` varchar(64) NOT NULL COMMENT '更新人',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '工作空间ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_playbook_id` (`playbook_id`) USING BTREE,
|
||||
KEY `idx_package_id` (`package_id`) USING BTREE,
|
||||
KEY `idx_runner_id` (`runner_id`) USING BTREE
|
||||
KEY `idx_name` (`name`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
/**
|
||||
@@ -167,19 +163,50 @@ CREATE TABLE `job` (
|
||||
DROP TABLE IF EXISTS `playbook`;
|
||||
CREATE TABLE `playbook` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`name` varchar(256) NOT NULL COMMENT '名称',
|
||||
`app_id` varchar(64) NOT NULL COMMENT '应用程序 ID',
|
||||
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '名称',
|
||||
`app_id` varchar(64) NOT NULL DEFAULT '' COMMENT '应用程序 ID',
|
||||
`tags` varchar(256) NOT NULL DEFAULT '' COMMENT '标签',
|
||||
`script` text NOT NULL COMMENT '脚本内容',
|
||||
`op_version` bigint(20) NOT NULL COMMENT '更新版本号, 默认:1;每次更新递增',
|
||||
`script` text NOT NULL DEFAULT '' COMMENT '脚本内容',
|
||||
`op_version` bigint(20) NOT NULL DEFAULT 1 COMMENT '更新版本号, 默认:1;每次更新递增',
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
`update_user_id` varchar(64) NOT NULL COMMENT '更新人',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '工作空间ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_name` (`name`) USING BTREE,
|
||||
KEY `idx_app_id` (`app_id`) USING BTREE,
|
||||
KEY `idx_op_version` (`op_version`) USING BTREE
|
||||
KEY `idx_op_version` (`op_version`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
/**
|
||||
* 新增 job 表
|
||||
*/
|
||||
DROP TABLE IF EXISTS `job`;
|
||||
CREATE TABLE `job` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`playbook_id` varchar(64) NOT NULL DEFAULT '' COMMENT 'Playbook ID',
|
||||
`package_id` varchar(64) NOT NULL DEFAULT '' COMMENT 'Package ID',
|
||||
`runner_id` varchar(64) NOT NULL DEFAULT '' COMMENT 'Runner ID',
|
||||
`schedule_id` varchar(64) NOT NULL DEFAULT '' COMMENT '定时器ID',
|
||||
`signature_ids` text NOT NULL DEFAULT '' COMMENT '特征ID,多个逗号分隔',
|
||||
`tags` varchar(256) NOT NULL DEFAULT '' COMMENT '标签; 默认:"";多个用逗号分隔;例:kz,vpn,android',
|
||||
`start_timestamp` bigint(20) NOT NULL DEFAULT (UNIX_TIMESTAMP(NOW()) * 1000) COMMENT '开始时间戳',
|
||||
`end_timestamp` bigint(20) NOT NULL DEFAULT (UNIX_TIMESTAMP(NOW()) * 1000) COMMENT '结束时间戳',
|
||||
`status` varchar(64) NOT NULL DEFAULT '' COMMENT '状态; 可选值: created,pending,running,passed,failed,cancel',
|
||||
`pcap_id` varchar(64) NOT NULL DEFAULT '' COMMENT 'PCAP ID',
|
||||
`log_path` varchar(256) NOT NULL DEFAULT '' COMMENT '日志文件路径',
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
`update_user_id` varchar(64) NOT NULL COMMENT '更新人',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '工作空间ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_playbook_id` (`playbook_id`) USING BTREE,
|
||||
KEY `idx_package_id` (`package_id`) USING BTREE,
|
||||
KEY `idx_runner_id` (`runner_id`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
/**
|
||||
@@ -188,13 +215,42 @@ CREATE TABLE `playbook` (
|
||||
DROP TABLE IF EXISTS `pcap`;
|
||||
CREATE TABLE `pcap` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '文件名称',
|
||||
`tags` varchar(256) NOT NULL DEFAULT '' COMMENT '标签',
|
||||
`description` text NOT NULL COMMENT '描述信息',
|
||||
`path` varchar(64) NOT NULL COMMENT 'PCAP文件路径',
|
||||
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
||||
`path` varchar(64) NOT NULL DEFAULT '' COMMENT 'PCAP文件路径',
|
||||
`size` bigint(20) NOT NULL DEFAULT 0 COMMENT '文件大小',
|
||||
`connections` bigint(20) NOT NULL DEFAULT 0 COMMENT '连接数量',
|
||||
`hosts` bigint(20) NOT NULL DEFAULT 0 COMMENT 'IP数量',
|
||||
`md5` varchar(64) NOT NULL DEFAULT '' COMMENT '摘要值,根据文件md5值判断是否已上存在,存在则响应当前id',
|
||||
`connection_time_first` bigint(20) NOT NULL DEFAULT (UNIX_TIMESTAMP(NOW()) * 1000) COMMENT '连接开始时间',
|
||||
`connection_time_last` bigint(20) NOT NULL DEFAULT (UNIX_TIMESTAMP(NOW()) * 1000) COMMENT '连接结束时间',
|
||||
`protocols` varchar(64) NOT NULL DEFAULT '' COMMENT '包含的协议,多个逗号分隔',
|
||||
`status` varchar(64) NOT NULL DEFAULT '' COMMENT '状态,可选值 Uploaded,Analyzing,Completed',
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '工作空间ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_tags` (`tags`) USING BTREE
|
||||
KEY `idx_name` (`name`) USING BTREE,
|
||||
KEY `idx_md5` (`md5`) USING BTREE,
|
||||
KEY `idx_tags` (`tags`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
/**
|
||||
* 新增 decode_record 表
|
||||
*/
|
||||
DROP TABLE IF EXISTS `decode_record`;
|
||||
CREATE TABLE `decode_record` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`pcap_id` varchar(64) NOT NULL DEFAULT '' COMMENT 'PCAP文件ID',
|
||||
`stream_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '流ID',
|
||||
`stream_attributes` text NOT NULL DEFAULT '' COMMENT '流属性',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '工作空间ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_pcap_id` (`pcap_id`) USING BTREE,
|
||||
KEY `idx_stream_id` (`stream_id`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
@@ -204,18 +260,20 @@ CREATE TABLE `pcap` (
|
||||
DROP TABLE IF EXISTS `application`;
|
||||
CREATE TABLE `application` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`name` varchar(256) NOT NULL COMMENT '应用名称',
|
||||
`long_name` varchar(256) NOT NULL COMMENT '应用全称',
|
||||
`properties` text NOT NULL COMMENT '应用数据',
|
||||
`description` text NOT NULL COMMENT '描述信息',
|
||||
`surrogates` text NOT NULL COMMENT '',
|
||||
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '应用名称',
|
||||
`long_name` varchar(256) NOT NULL DEFAULT '' COMMENT '应用全称',
|
||||
`properties` text NOT NULL DEFAULT '' COMMENT '应用数据',
|
||||
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
||||
`surrogates` text NOT NULL DEFAULT '' COMMENT '',
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
`update_user_id` varchar(64) NOT NULL COMMENT '更新人',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '工作空间ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_name` (`name`) USING BTREE,
|
||||
KEY `idx_long_name` (`long_name`) USING BTREE
|
||||
KEY `idx_long_name` (`long_name`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
/**
|
||||
@@ -224,57 +282,67 @@ CREATE TABLE `application` (
|
||||
DROP TABLE IF EXISTS `package`;
|
||||
CREATE TABLE `package` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`logo` varchar(512) NOT NULL COMMENT '图标,图标文件 url 地址',
|
||||
`description` text NOT NULL COMMENT '描述信息',
|
||||
`platform` varchar(256) NOT NULL COMMENT '操作系统; 可选值:android,ios,windows,linux',
|
||||
`version` varchar(256) NOT NULL COMMENT '安装包版本',
|
||||
`identifier` varchar(256) NOT NULL COMMENT '唯一标识;android:package name,ios:bundle id',
|
||||
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '名称',
|
||||
`logo` varchar(512) NOT NULL DEFAULT '' COMMENT '图标,图标文件 url 地址',
|
||||
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
||||
`platform` varchar(256) NOT NULL DEFAULT '' COMMENT '操作系统; 可选值:android,ios,windows,linux',
|
||||
`version` varchar(256) NOT NULL DEFAULT '' COMMENT '安装包版本',
|
||||
`identifier` varchar(256) NOT NULL DEFAULT '' COMMENT '唯一标识;android:package name,ios:bundle id',
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
`update_user_id` varchar(64) NOT NULL COMMENT '更新人',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '工作空间ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_version` (`version`) USING BTREE
|
||||
KEY `idx_name` (`name`) USING BTREE,
|
||||
KEY `idx_version` (`version`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
/**
|
||||
* 新增 runner 表
|
||||
* 新增 signature 表
|
||||
*/
|
||||
DROP TABLE IF EXISTS `runner`;
|
||||
CREATE TABLE `runner` (
|
||||
DROP TABLE IF EXISTS `signature`;
|
||||
CREATE TABLE `signature` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`name` varchar(256) NOT NULL COMMENT '名称',
|
||||
`app_id` varchar(64) NOT NULL DEFAULT '' COMMENT '应用ID',
|
||||
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '名称',
|
||||
`tags` varchar(256) NOT NULL DEFAULT '' COMMENT '标签,多个逗号分隔',
|
||||
`support_platforms` varchar(256) NOT NULL COMMENT '支持的平台; 可选值:android,ios,windows; 多个逗号分隔; 例:android,ios',
|
||||
`share_flag` int(1) NOT NULL COMMENT '共享标识; 1:共享 0:不共享,仅创建人可用',
|
||||
`description` text NOT NULL COMMENT '描述信息',
|
||||
`status` varchar(64) NOT NULL COMMENT '状态;可选值:online,offline',
|
||||
`last_heartbeat_timestamp` bigint(20) NOT NULL COMMENT '最后心跳时间戳',
|
||||
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
||||
`display_flag` int(1) NOT NULL DEFAULT 1 COMMENT '是否显示; 1:显示 0:不显示',
|
||||
`conditions` text NOT NULL DEFAULT '' COMMENT '条件',
|
||||
`op_version` bigint(20) NOT NULL DEFAULT 1 COMMENT '更新版本号, 默认:1;每次更新递增',
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
`update_user_id` varchar(64) NOT NULL COMMENT '更新人',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '工作空间ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_name` (`name`) USING BTREE
|
||||
KEY `idx_app_id` (`app_id`) USING BTREE,
|
||||
KEY `idx_name` (`name`) USING BTREE,
|
||||
KEY `idx_op_version` (`op_version`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
/**
|
||||
* 新增 workbook,workbook_member,workbook_resource 表
|
||||
*/
|
||||
DROP TABLE IF EXISTS `workbook`;
|
||||
CREATE TABLE `workbook` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`name` varchar(256) NOT NULL COMMENT '名称',
|
||||
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '名称',
|
||||
`tags` varchar(256) NOT NULL DEFAULT '' COMMENT '标签,多个逗号分隔',
|
||||
`visibility` varchar(16) NOT NULL DEFAULT 'private' COMMENT '可见程度,可选值:private,public 默认:private',
|
||||
`description` text NOT NULL COMMENT '描述信息',
|
||||
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
`update_user_id` varchar(64) NOT NULL COMMENT '更新人',
|
||||
`workspace_id` varchar(64) NOT NULL DEFAULT '' COMMENT '工作空间ID',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_name` (`name`) USING BTREE
|
||||
KEY `idx_name` (`name`) USING BTREE,
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `workbook_member`;
|
||||
@@ -294,3 +362,34 @@ CREATE TABLE `workbook_resource` (
|
||||
`resource_id` varchar(64) NOT NULL COMMENT '资源id',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
/**
|
||||
* 新增 workspace, workspace_member 表
|
||||
*/
|
||||
DROP TABLE IF EXISTS `workspace`;
|
||||
CREATE TABLE `workspace` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键',
|
||||
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '名称',
|
||||
`tags` varchar(256) NOT NULL DEFAULT '' COMMENT '标签,多个逗号分隔',
|
||||
`visibility` varchar(16) NOT NULL DEFAULT 'private' COMMENT '可见程度,可选值:private,public 默认:private',
|
||||
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
`update_user_id` varchar(64) NOT NULL COMMENT '更新人',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_name` (`name`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
DROP TABLE IF EXISTS `workspace_member`;
|
||||
CREATE TABLE `workspace_member` (
|
||||
`workspace_id` varchar(64) NOT NULL,
|
||||
`user_id` varchar(64) NOT NULL,
|
||||
`role_id` varchar(64) NOT NULL,
|
||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||
`create_user_id` varchar(64) NOT NULL COMMENT '创建人',
|
||||
KEY `idx_workspace_id` (`workspace_id`) USING BTREE,
|
||||
KEY `idx_user_id` (`user_id`) USING BTREE,
|
||||
KEY `idx_role_id` (`role_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
Reference in New Issue
Block a user