feat: ASW-40 application 接口开发

This commit is contained in:
zhangshuai
2024-08-21 10:19:01 +08:00
parent c57ade402f
commit e675144a6c
25 changed files with 745 additions and 179 deletions

View File

@@ -34,6 +34,12 @@ public enum RCode {
APP_DUPLICATE_RECORD(201007, "application duplicate record"),
APP_NOT_EXIST(201008, "application does not exist"),
APP_PACKAGE_NAME_FORMAT_ERROR(201009, "application package name format error"),
APP_TAGS_FORMAT_ERROR(201010, "application tags format error"),
APP_SIGNATURE_FORMAT_ERROR(201011, "application signature format error"),
APP_SIGNATURE_CONTENT_CANNOT_EMPTY(201012, "application signature content cannot be empty"),
APP_SIGNATURE_NOT_EXIST(201013, "application signature does not exist"),
APP_NOTE_CONTENT_CANNOT_EMPTY(201014, "application note content cannot be empty"),
// Package

View File

@@ -387,6 +387,13 @@ public class VerifyUtil {
return this;
}
public VerifyUtil json(RCode code) {
if (!T.JSONUtil.isTypeJSON(T.StrUtil.toStringOrNull(value))) {
throw ASWException.builder().rcode(code).build();
}
return this;
}
/**
* 多参数校验,不能同时为空
*

View File

@@ -1,16 +1,22 @@
package net.geedge.asw.module.app.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.geedge.asw.common.util.ASWException;
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.ApplicationAttachmentEntity;
import net.geedge.asw.module.app.entity.ApplicationEntity;
import net.geedge.asw.module.app.entity.ApplicationNoteEntity;
import net.geedge.asw.module.app.entity.ApplicationSignatureEntity;
import net.geedge.asw.module.app.service.ApplicationAttachmentService;
import net.geedge.asw.module.app.service.ApplicationNoteService;
import net.geedge.asw.module.app.service.ApplicationSignatureService;
import net.geedge.asw.module.app.service.IApplicationService;
import net.geedge.asw.module.sys.entity.SysUserEntity;
import net.geedge.asw.module.sys.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
@@ -23,35 +29,21 @@ public class ApplicationController {
private IApplicationService applicationService;
@Autowired
private ISysUserService userService;
private ApplicationSignatureService signatureService;
@Autowired
private ApplicationNoteService noteService;
@Autowired
private ApplicationAttachmentService attachmentService;
@GetMapping("/{id}")
public R detail(@PathVariable String id) {
ApplicationEntity entity = applicationService.getById(id);
if (T.ObjectUtil.isNull(entity)){
public R detail(@PathVariable("id") String id, String workspaceId) {
T.VerifyUtil.is(workspaceId).notNull();
ApplicationEntity entity = applicationService.detail(id, workspaceId);
if (T.ObjectUtil.isNull(entity)) {
throw new ASWException(RCode.APP_NOT_EXIST);
}
SysUserEntity createUser = userService.getById(entity.getCreateUserId());
SysUserEntity updateUser = userService.getById(entity.getUpdateUserId());
entity.setCreateUser(createUser);
entity.setUpdateUser(updateUser);
return R.ok().putData("record", entity);
}
@GetMapping("/{id}/{version}")
public R detail(@PathVariable String id,
@PathVariable(required = false) String version) {
ApplicationEntity entity = applicationService.getById(id);
if (T.StrUtil.isNotEmpty(version)){
entity = applicationService.queryByApplicationAndLog(id, version);
}
if (T.ObjectUtil.isNull(entity)){
throw new ASWException(RCode.APP_NOT_EXIST);
}
SysUserEntity createUser = userService.getById(entity.getCreateUserId());
SysUserEntity updateUser = userService.getById(entity.getUpdateUserId());
entity.setCreateUser(createUser);
entity.setUpdateUser(updateUser);
return R.ok().putData("record", entity);
}
@@ -68,10 +60,8 @@ public class ApplicationController {
public R add(@RequestBody ApplicationEntity entity) {
T.VerifyUtil.is(entity).notNull()
.and(entity.getName()).notEmpty(RCode.APP_NAME_CANNOT_EMPTY)
//.and(entity.getLongName()).notEmpty(RCode.APP_LONGNAME_CANNOT_EMPTY)
//.and(entity.getProperties()).notEmpty(RCode.APP_PROPERTIES_CANNOT_EMPTY)
//.and(entity.getSurrogates()).notEmpty(RCode.APP_SURROGATES_CANNOT_EMPTY)
//.and(entity.getDescription()).notEmpty(RCode.APP_DESCRIPTION_CANNOT_EMPTY)
//.and(entity.getSignature()).notEmpty(RCode.APP_SURROGATES_CANNOT_EMPTY)
//.and(entity.getNote()).notEmpty(RCode.APP_PROPERTIES_CANNOT_EMPTY)
.and(entity.getWorkspaceId()).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
ApplicationEntity applicationEntity = applicationService.saveApplication(entity);
@@ -83,16 +73,44 @@ public class ApplicationController {
T.VerifyUtil.is(entity).notNull()
.and(entity.getId()).notEmpty(RCode.ID_CANNOT_EMPTY)
.and(entity.getName()).notEmpty(RCode.NAME_CANNOT_EMPTY)
//.and(entity.getLongName()).notEmpty(RCode.APP_LONGNAME_CANNOT_EMPTY)
//.and(entity.getProperties()).notEmpty(RCode.APP_PROPERTIES_CANNOT_EMPTY)
//.and(entity.getSurrogates()).notEmpty(RCode.APP_SURROGATES_CANNOT_EMPTY)
//.and(entity.getDescription()).notEmpty(RCode.APP_DESCRIPTION_CANNOT_EMPTY)
//.and(entity.getSignature()).notEmpty(RCode.APP_SURROGATES_CANNOT_EMPTY)
//.and(entity.getNote()).notEmpty(RCode.APP_PROPERTIES_CANNOT_EMPTY)
.and(entity.getWorkspaceId()).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
ApplicationEntity applicationEntity = applicationService.updateApplication(entity);
return R.ok().putData("id", applicationEntity.getId());
}
@PutMapping("/{id}/basic")
public R basic(@PathVariable String id, @RequestBody ApplicationEntity entity) {
T.VerifyUtil.is(entity).notNull()
.and(entity.getName()).notEmpty(RCode.NAME_CANNOT_EMPTY)
.and(entity.getWorkspaceId()).notEmpty(RCode.WORKSPACE_ID_CANNOT_EMPTY);
entity.setId(id);
ApplicationEntity app = applicationService.updateBasic(entity);
return R.ok().putData("id", app.getId());
}
@PutMapping("/{applicationId}/signature")
public R updateSignature(@PathVariable("applicationId") String applicationId, @RequestBody ApplicationSignatureEntity signature) {
T.VerifyUtil.is(signature).notNull()
.and(signature.getContent()).notEmpty(RCode.APP_SURROGATES_CANNOT_EMPTY)
.and(signature.getContent()).json(RCode.APP_SURROGATES_CANNOT_EMPTY);
signatureService.saveSignature(signature, applicationId);
return R.ok().putData("id", signature.getId());
}
@PutMapping("/{applicationId}/note")
public R updateNote(@PathVariable("applicationId") String applicationId, @RequestBody ApplicationNoteEntity note) {
T.VerifyUtil.is(note).notNull()
.and(note.getContent()).notEmpty(RCode.APP_NOTE_CONTENT_CANNOT_EMPTY);
noteService.saveNote(note, applicationId);
return R.ok().putData("id", note.getId());
}
@DeleteMapping
public R delete(String[] ids) {
T.VerifyUtil.is(ids).notEmpty();
@@ -100,33 +118,64 @@ public class ApplicationController {
return R.ok();
}
@GetMapping("/{id}/log")
public R queryLogList(@PathVariable("id") String id) {
List<ApplicationEntity> applicationEntityList = applicationService.queryLogList(id);
return R.ok().putData("record", applicationEntityList);
@GetMapping("/{applicationId}/attachment")
public R queryAttachment(@PathVariable String applicationId) {
T.VerifyUtil.is(applicationId).notNull();
List<ApplicationAttachmentEntity> list = attachmentService.list(new LambdaQueryWrapper<ApplicationAttachmentEntity>().eq(ApplicationAttachmentEntity::getApplicationId, applicationId));
return R.ok().putData("records", list);
}
@GetMapping("/{id}/{oldVersion}/{newVersion}")
public R applicationCompare(@PathVariable("id") String id,
@PathVariable("oldVersion") String oldVersion,
@PathVariable("newVersion") String newVersion) {
List<ApplicationEntity> list = applicationService.compare(id, oldVersion, newVersion);
return R.ok().putData("record", list);
@PostMapping("/{applicationId}/attachment")
public R uploadAttachment(@PathVariable String applicationId, @RequestParam("files") List<MultipartFile> fileList) {
List<ApplicationAttachmentEntity> recordList = T.ListUtil.list(true);
for (int i = 0; i < fileList.size(); i++) {
MultipartFile file = fileList.get(i);
ApplicationAttachmentEntity attachmentEntity = attachmentService.saveAttachment(file.getResource(), applicationId);
recordList.add(attachmentEntity);
}
return R.ok().putData("records", recordList);
}
@DeleteMapping("/{applicationId}/attachment")
public R removedAttachment(@PathVariable String applicationId, @RequestParam String ids) {
@PostMapping("/{id}/{version}/restore")
public R restore(@PathVariable("id") String id,
@PathVariable("version") String version) {
applicationService.restore(id, version);
attachmentService.removedAttachment(applicationId, ids);
return R.ok();
}
@GetMapping("/{applicationId}/signature")
public R querySignature(@PathVariable String applicationId) {
T.VerifyUtil.is(applicationId).notNull();
List<ApplicationSignatureEntity> signatureList = signatureService.queryList(applicationId);
return R.ok().putData("records", signatureList);
}
@GetMapping("/explore")
public R explore(@RequestParam String workspaceId, @RequestParam String pcapIds) {
String discoverUrl = applicationService.generateKibanaDiscoverUrl(workspaceId, pcapIds);
return R.ok().putData("url", discoverUrl);
}
@GetMapping("/{applicationId}/signature/{oldVersion}/{newVersion}")
public R signatureCompare(@PathVariable("applicationId") String applicationId,
@PathVariable("oldVersion") String oldVersion,
@PathVariable("newVersion") String newVersion) {
List<ApplicationSignatureEntity> list = signatureService.compare(applicationId, oldVersion, newVersion);
return R.ok().putData("records", list);
}
@PutMapping("/{applicationId}/signature/{version}/restore")
public R restore(@PathVariable("applicationId") String applicationId,
@PathVariable("version") String version) {
signatureService.restore(applicationId, version);
return R.ok();
}
}

View File

@@ -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.ApplicationAttachmentEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ApplicationAttachmentDao extends BaseMapper<ApplicationAttachmentEntity>{
}

View File

@@ -1,10 +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 net.geedge.asw.module.app.entity.ApplicationNoteEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SignatureDao extends BaseMapper<SignatureEntity>{
public interface ApplicationNoteDao extends BaseMapper<ApplicationNoteEntity>{
}

View File

@@ -0,0 +1,15 @@
package net.geedge.asw.module.app.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.geedge.asw.module.app.entity.ApplicationSignatureEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface ApplicationSignatureDao extends BaseMapper<ApplicationSignatureEntity>{
List<ApplicationSignatureEntity> queryList(@Param("params") Map<Object, Object> params);
}

View File

@@ -0,0 +1,25 @@
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("application_attachment")
public class ApplicationAttachmentEntity {
@TableId(type = IdType.ASSIGN_UUID)
private String id;
private String applicationId;
private String name;
private String path;
private Long createTimestamp;
private String createUserId;
}

View File

@@ -7,27 +7,39 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import net.geedge.asw.module.sys.entity.SysUserEntity;
import java.util.List;
@Data
@TableName("application")
public class ApplicationEntity {
@TableId(type = IdType.ASSIGN_UUID)
private String id;
private String name;
private String longName;
private String properties;
private String description;
private String surrogates;
private String tags;
private String packageName;
private String website;
private String provider;
private String status;
private String description;
private Long createTimestamp;
private Long updateTimestamp;
private String createUserId;
private String updateUserId;
private String workspaceId;
private Integer opVersion;
@TableField(exist = false)
@@ -36,4 +48,12 @@ public class ApplicationEntity {
@TableField(exist = false)
private SysUserEntity updateUser;
@TableField(exist = false)
private ApplicationSignatureEntity signature;
@TableField(exist = false)
private ApplicationNoteEntity note;
@TableField(exist = false)
private List<ApplicationAttachmentEntity> attatchments;
}

View File

@@ -1,27 +1,60 @@
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;
import net.geedge.asw.module.sys.entity.SysUserEntity;
import java.util.List;
@Data
@TableName("application_log")
public class ApplicationLogEntity {
@TableId(type = IdType.ASSIGN_UUID)
private String id;
private String name;
private String longName;
private String properties;
private String description;
private String surrogates;
private String tags;
private String packageName;
private String website;
private String provider;
private String status;
private String description;
private Long createTimestamp;
private Long updateTimestamp;
private String createUserId;
private String updateUserId;
private String workspaceId;
private Integer opVersion;
@TableField(exist = false)
private SysUserEntity createUser;
@TableField(exist = false)
private SysUserEntity updateUser;
@TableField(exist = false)
private ApplicationSignatureEntity signature;
@TableField(exist = false)
private ApplicationNoteEntity note;
@TableField(exist = false)
private List<ApplicationAttachmentEntity> attatchments;
}

View File

@@ -6,24 +6,20 @@ import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("signature")
public class SignatureEntity {
@TableName("application_note")
public class ApplicationNoteEntity {
@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 String applicationId;
private String content;
private Long createTimestamp;
private Long updateTimestamp;
private String createUserId;
private String updateUserId;
private String workspaceId;
private String createUserId;
private Long opVersion;
}

View File

@@ -0,0 +1,30 @@
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;
import net.geedge.asw.module.sys.entity.SysUserEntity;
@Data
@TableName("application_signature")
public class ApplicationSignatureEntity {
@TableId(type = IdType.ASSIGN_UUID)
private String id;
private String applicationId;
private String content;
private Long createTimestamp;
private String createUserId;
private Long opVersion;
@TableField(exist = false)
private SysUserEntity createUser;
}

View File

@@ -0,0 +1,12 @@
package net.geedge.asw.module.app.service;
import com.baomidou.mybatisplus.extension.service.IService;
import net.geedge.asw.module.app.entity.ApplicationAttachmentEntity;
import org.springframework.core.io.Resource;
public interface ApplicationAttachmentService extends IService<ApplicationAttachmentEntity>{
ApplicationAttachmentEntity saveAttachment(Resource fileResource, String applicationId);
void removedAttachment(String applicationId, String ids);
}

View File

@@ -0,0 +1,9 @@
package net.geedge.asw.module.app.service;
import com.baomidou.mybatisplus.extension.service.IService;
import net.geedge.asw.module.app.entity.ApplicationNoteEntity;
public interface ApplicationNoteService extends IService<ApplicationNoteEntity>{
void saveNote(ApplicationNoteEntity note, String applicationId);
}

View File

@@ -0,0 +1,17 @@
package net.geedge.asw.module.app.service;
import com.baomidou.mybatisplus.extension.service.IService;
import net.geedge.asw.module.app.entity.ApplicationSignatureEntity;
import java.util.List;
public interface ApplicationSignatureService extends IService<ApplicationSignatureEntity>{
void saveSignature(ApplicationSignatureEntity signature, String applicationId);
List<ApplicationSignatureEntity> queryList(String applicationId);
List<ApplicationSignatureEntity> compare(String applicationId, String oldVersion, String newVersion);
void restore(String id, String version);
}

View File

@@ -9,22 +9,17 @@ import java.util.Map;
public interface IApplicationService extends IService<ApplicationEntity>{
ApplicationEntity detail(String id, String workspaceId);
Page queryList(Map<String, Object> params);
ApplicationEntity saveApplication(ApplicationEntity entity);
ApplicationEntity updateApplication(ApplicationEntity entity);
ApplicationEntity updateBasic(ApplicationEntity entity);
void removeApplication(List<String> ids);
ApplicationEntity queryByApplicationAndLog(String id, String version);
List<ApplicationEntity> compare(String id, String oldVersion, String newVersion);
List<ApplicationEntity> queryLogList(String id);
void restore(String id, String version);
String generateKibanaDiscoverUrl(String workspaceId, String pcapIds);
}

View File

@@ -1,8 +0,0 @@
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>{
}

View File

@@ -0,0 +1,82 @@
package net.geedge.asw.module.app.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.io.FileUtil;
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.ASWException;
import net.geedge.asw.common.util.RCode;
import net.geedge.asw.common.util.T;
import net.geedge.asw.module.app.dao.ApplicationAttachmentDao;
import net.geedge.asw.module.app.entity.ApplicationAttachmentEntity;
import net.geedge.asw.module.app.entity.ApplicationEntity;
import net.geedge.asw.module.app.service.ApplicationAttachmentService;
import net.geedge.asw.module.app.service.IApplicationService;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
@Service
public class ApplicationAttachmentServiceImpl extends ServiceImpl<ApplicationAttachmentDao, ApplicationAttachmentEntity> implements ApplicationAttachmentService {
private static final Log log = Log.get();
@Autowired
private IApplicationService applicationService;
@Override
public ApplicationAttachmentEntity saveAttachment(Resource fileResource, String applicationId) {
ApplicationEntity app = applicationService.getById(applicationId);
ApplicationAttachmentEntity entity = new ApplicationAttachmentEntity();
try {
entity.setName(fileResource.getFilename());
entity.setCreateTimestamp(System.currentTimeMillis());
entity.setCreateUserId(StpUtil.getLoginIdAsString());
entity.setApplicationId(applicationId);
// path
File destination = T.FileUtil.file(T.WebPathUtil.getRootPath(), app.getId(), fileResource.getFilename());
FileUtils.copyInputStreamToFile(fileResource.getInputStream(), destination);
entity.setPath(destination.getPath());
// 根据文件 applicationId path 判断是否已上存在,存在则响应当前实体
ApplicationAttachmentEntity attachment = this.getOne(new LambdaQueryWrapper<ApplicationAttachmentEntity>()
.eq(ApplicationAttachmentEntity::getApplicationId, applicationId)
.eq(ApplicationAttachmentEntity::getPath, destination.getPath()));
if (T.ObjectUtil.isNotNull(attachment)) {
return attachment;
}
// save
this.save(entity);
} catch (IOException e) {
log.error(e, "[saveAttachment] [error] [applicationId: {}]", applicationId);
throw new ASWException(RCode.ERROR);
}
return entity;
}
@Override
public void removedAttachment(String applicationId, String ids) {
List<String> idList = Arrays.asList(ids.split(","));
for (String id : idList) {
ApplicationAttachmentEntity attachment = this.getOne(new LambdaQueryWrapper<ApplicationAttachmentEntity>()
.eq(ApplicationAttachmentEntity::getApplicationId, applicationId)
.eq(ApplicationAttachmentEntity::getId, id));
T.FileUtil.del(FileUtil.file(attachment.getPath()));
this.removeById(id);
}
}
}

View File

@@ -0,0 +1,36 @@
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.service.impl.ServiceImpl;
import net.geedge.asw.common.util.T;
import net.geedge.asw.module.app.dao.ApplicationNoteDao;
import net.geedge.asw.module.app.entity.ApplicationNoteEntity;
import net.geedge.asw.module.app.service.ApplicationNoteService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class ApplicationNoteServiceImpl extends ServiceImpl<ApplicationNoteDao, ApplicationNoteEntity> implements ApplicationNoteService {
@Override
@Transactional(rollbackFor = Exception.class)
public void saveNote(ApplicationNoteEntity note, String applicationId) {
// query last note
ApplicationNoteEntity noteLast = this.getOne(new LambdaQueryWrapper<ApplicationNoteEntity>()
.eq(ApplicationNoteEntity::getApplicationId, applicationId)
.orderByDesc(ApplicationNoteEntity::getOpVersion)
.last("limit 1"));
if (T.ObjectUtil.isNotEmpty(noteLast)){
note.setOpVersion(noteLast.getOpVersion() + 1);
}
//save note
note.setApplicationId(applicationId);
note.setCreateTimestamp(System.currentTimeMillis());
note.setCreateUserId(StpUtil.getLoginIdAsString());
this.save(note);
}
}

View File

@@ -14,13 +14,13 @@ 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.ApplicationDao;
import net.geedge.asw.module.app.entity.ApplicationEntity;
import net.geedge.asw.module.app.entity.ApplicationLogEntity;
import net.geedge.asw.module.app.service.IApplicationLogService;
import net.geedge.asw.module.app.service.IApplicationService;
import net.geedge.asw.module.app.entity.*;
import net.geedge.asw.module.app.service.*;
import net.geedge.asw.module.feign.client.KibanaClient;
import net.geedge.asw.module.runner.entity.PcapEntity;
import net.geedge.asw.module.runner.service.IPcapService;
import net.geedge.asw.module.sys.entity.SysUserEntity;
import net.geedge.asw.module.sys.service.ISysUserService;
import net.geedge.asw.module.workspace.entity.WorkspaceEntity;
import net.geedge.asw.module.workspace.service.IWorkspaceService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -28,7 +28,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -50,13 +49,49 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, Applicat
@Autowired
private IPcapService pcapService;
@Autowired
private ISysUserService userService;
@Autowired
private ApplicationSignatureService signatureService;
@Autowired
private ApplicationNoteService noteService;
@Autowired
private ApplicationAttachmentService attachmentService;
@Resource
private KibanaClient kibanaClient;
@Override
public ApplicationEntity queryByApplicationAndLog(String id, String version) {
ApplicationEntity entity = this.baseMapper.queryByApplicationAndLog(id, version);
return entity;
public ApplicationEntity detail(String id, String workspaceId) {
ApplicationEntity app = this.getOne(new LambdaQueryWrapper<ApplicationEntity>()
.eq(ApplicationEntity::getId, id)
.eq(ApplicationEntity::getWorkspaceId, workspaceId));
ApplicationSignatureEntity signature = signatureService.getOne(new LambdaQueryWrapper<ApplicationSignatureEntity>()
.eq(ApplicationSignatureEntity::getApplicationId, app.getId())
.orderByDesc(ApplicationSignatureEntity::getOpVersion)
.last("limit 1"));
app.setSignature(signature);
ApplicationNoteEntity note = noteService.getOne(new LambdaQueryWrapper<ApplicationNoteEntity>()
.eq(ApplicationNoteEntity::getApplicationId, app.getId())
.orderByDesc(ApplicationNoteEntity::getOpVersion)
.last("limit 1"));
app.setNote(note);
List<ApplicationAttachmentEntity> attachmentEntityList = attachmentService.list(new LambdaQueryWrapper<ApplicationAttachmentEntity>()
.eq(ApplicationAttachmentEntity::getApplicationId, app.getId()));
app.setAttatchments(attachmentEntityList);
SysUserEntity createUser = userService.getById(app.getCreateUserId());
SysUserEntity updateUser = userService.getById(app.getUpdateUserId());
app.setCreateUser(createUser);
app.setUpdateUser(updateUser);
return app;
}
@Override
@@ -67,44 +102,79 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, Applicat
return page;
}
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationEntity saveApplication(ApplicationEntity entity) {
private void validateParam(ApplicationEntity entity, boolean isUpdate) {
ApplicationEntity one = this.getOne(new LambdaQueryWrapper<ApplicationEntity>()
.eq(ApplicationEntity::getWorkspaceId, entity.getWorkspaceId())
.eq(ApplicationEntity::getName, entity.getName()));
if (T.ObjectUtil.isNotNull(one)) {
if (T.ObjectUtil.isNotNull(one) && !isUpdate || T.ObjectUtil.isNotNull(one) && isUpdate && !T.StrUtil.equals(entity.getId(), one.getId())) {
throw ASWException.builder().rcode(RCode.APP_DUPLICATE_RECORD).build();
}
if (T.ObjectUtil.isNotEmpty(entity.getPackageName()) && !T.JSONUtil.isTypeJSON(entity.getPackageName())){
// package name format
if (T.ObjectUtil.isNotEmpty(entity.getPackageName()) && !T.JSONUtil.isTypeJSON(entity.getPackageName())) {
throw ASWException.builder().rcode(RCode.APP_PACKAGE_NAME_FORMAT_ERROR).build();
}else if (T.ObjectUtil.isEmpty(entity.getPackageName())){
} else if (T.ObjectUtil.isEmpty(entity.getPackageName())) {
entity.setPackageName("{}");
}
// tags name format
if (T.StrUtil.isNotEmpty(entity.getTags()) && !T.JSONUtil.isTypeJSON(entity.getTags())) {
throw ASWException.builder().rcode(RCode.APP_TAGS_FORMAT_ERROR).build();
}
// signature
if (T.ObjectUtil.isNotEmpty(entity.getSignature())) {
if (!T.StrUtil.isNotEmpty(entity.getSignature().getContent())){
throw ASWException.builder().rcode(RCode.APP_SIGNATURE_CONTENT_CANNOT_EMPTY).build();
}
if (!T.JSONUtil.isTypeJSON(entity.getSignature().getContent())){
throw ASWException.builder().rcode(RCode.APP_SIGNATURE_CONTENT_CANNOT_EMPTY).build();
}
}
// note
if (T.ObjectUtil.isNotEmpty(entity.getNote()) && !T.StrUtil.isNotEmpty(entity.getNote().getContent())) {
throw ASWException.builder().rcode(RCode.APP_NOTE_CONTENT_CANNOT_EMPTY).build();
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationEntity saveApplication(ApplicationEntity entity) {
this.validateParam(entity, false);
// save
entity.setCreateTimestamp(System.currentTimeMillis());
entity.setUpdateTimestamp(System.currentTimeMillis());
entity.setCreateUserId(StpUtil.getLoginIdAsString());
entity.setUpdateUserId(StpUtil.getLoginIdAsString());
// save
this.save(entity);
if (T.ObjectUtil.isNotEmpty(entity.getSignature())){
// save signature
signatureService.saveSignature(entity.getSignature(), entity.getId());
}
if (T.ObjectUtil.isNotEmpty(entity.getNote())){
//save note
noteService.saveNote(entity.getNote(), entity.getId());
}
return entity;
}
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationEntity updateApplication(ApplicationEntity entity) {
ApplicationEntity one = this.getOne(new LambdaQueryWrapper<ApplicationEntity>()
.eq(ApplicationEntity::getWorkspaceId, entity.getWorkspaceId())
.eq(ApplicationEntity::getId, entity.getId()));
if (T.ObjectUtil.isNull(one)) {
throw ASWException.builder().rcode(RCode.APP_NOT_EXIST).build();
}
if (T.ObjectUtil.isNotEmpty(entity.getPackageName()) && !T.JSONUtil.isTypeJSON(entity.getPackageName())){
throw ASWException.builder().rcode(RCode.APP_PACKAGE_NAME_FORMAT_ERROR).build();
}else if (T.ObjectUtil.isEmpty(entity.getPackageName())){
entity.setPackageName("{}");
}
this.validateParam(entity, true);
ApplicationEntity one = this.getById(entity.getId());
entity.setUpdateTimestamp(System.currentTimeMillis());
entity.setUpdateUserId(StpUtil.getLoginIdAsString());
entity.setOpVersion(one.getOpVersion() + 1);
@@ -113,11 +183,22 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, Applicat
this.updateById(entity);
// save log
this.saveApplcationToLog(one);
this.saveApplicationToLog(one);
if (T.ObjectUtil.isNotEmpty(entity.getSignature())){
// save signature
signatureService.saveSignature(entity.getSignature(), entity.getId());
}
if (T.ObjectUtil.isNotEmpty(entity.getNote())){
//save note
noteService.saveNote(entity.getNote(), entity.getId());
}
return entity;
}
private void saveApplcationToLog(ApplicationEntity one) {
private void saveApplicationToLog(ApplicationEntity one) {
ApplicationLogEntity applicationLogEntity = T.BeanUtil.toBean(one, ApplicationLogEntity.class);
applicationLogEntity.setUpdateTimestamp(System.currentTimeMillis());
applicationLogEntity.setUpdateUserId(StpUtil.getLoginIdAsString());
@@ -132,39 +213,9 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, Applicat
// remove
this.removeBatchByIds(ids);
applicationLogService.removeBatchByIds(ids);
}
@Override
public List<ApplicationEntity> queryLogList(String id) {
List<ApplicationEntity> packageList = this.getBaseMapper().queryLogList(id);
return packageList;
}
@Override
public List<ApplicationEntity> compare(String id, String oldVersion, String newVersion) {
Map<String, Object> params = Map.of("id", id, "versions", Arrays.asList(oldVersion, newVersion));
List<ApplicationEntity> packageList = this.getBaseMapper().compare(params);
return packageList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void restore(String id, String version) {
// save current to log
ApplicationEntity curApplication = this.getById(id);
this.saveApplcationToLog(curApplication);
// restore
ApplicationLogEntity oldApplication = applicationLogService.getOne(new LambdaQueryWrapper<ApplicationLogEntity>()
.eq(ApplicationLogEntity::getId, id)
.eq(ApplicationLogEntity::getOpVersion, version));
oldApplication.setUpdateTimestamp(System.currentTimeMillis());
oldApplication.setUpdateUserId(StpUtil.getLoginIdAsString());
oldApplication.setOpVersion(curApplication.getOpVersion() + 1);
ApplicationEntity application = T.BeanUtil.toBean(oldApplication, ApplicationEntity.class);
this.updateById(application);
signatureService.remove(new LambdaQueryWrapper<ApplicationSignatureEntity>().in(ApplicationSignatureEntity::getApplicationId, ids));
noteService.remove(new LambdaQueryWrapper<ApplicationNoteEntity>().in(ApplicationNoteEntity::getApplicationId, ids));
attachmentService.remove(new LambdaQueryWrapper<ApplicationAttachmentEntity>().in(ApplicationAttachmentEntity::getApplicationId, ids));
}
/**
@@ -250,4 +301,28 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, Applicat
}
return kibanaDiscoverUrl;
}
@Override
public ApplicationEntity updateBasic(ApplicationEntity entity) {
ApplicationEntity one = this.getById(entity.getId());
if (T.ObjectUtil.isNotNull(one) && !T.StrUtil.equals(entity.getId(), one.getId())) {
throw ASWException.builder().rcode(RCode.APP_DUPLICATE_RECORD).build();
}
// package name format
if (T.ObjectUtil.isNotEmpty(entity.getPackageName()) && !T.JSONUtil.isTypeJSON(entity.getPackageName())) {
throw ASWException.builder().rcode(RCode.APP_PACKAGE_NAME_FORMAT_ERROR).build();
} else if (T.ObjectUtil.isEmpty(entity.getPackageName())) {
entity.setPackageName("{}");
}
entity.setUpdateTimestamp(System.currentTimeMillis());
entity.setUpdateUserId(StpUtil.getLoginIdAsString());
entity.setOpVersion(one.getOpVersion() + 1);
this.saveApplicationToLog(one);
this.updateById(entity);
return entity;
}
}

View File

@@ -0,0 +1,81 @@
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.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.ApplicationSignatureDao;
import net.geedge.asw.module.app.entity.ApplicationSignatureEntity;
import net.geedge.asw.module.app.service.ApplicationSignatureService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Service
public class ApplicationSignatureServiceImpl extends ServiceImpl<ApplicationSignatureDao, ApplicationSignatureEntity> implements ApplicationSignatureService {
@Override
@Transactional(rollbackFor = Exception.class)
public void saveSignature(ApplicationSignatureEntity signature, String applicationId) {
// query last note
ApplicationSignatureEntity signatureLast = this.getOne(new LambdaQueryWrapper<ApplicationSignatureEntity>()
.eq(ApplicationSignatureEntity::getApplicationId, applicationId)
.orderByDesc(ApplicationSignatureEntity::getOpVersion)
.last("limit 1"));
if (T.ObjectUtil.isNotEmpty(signatureLast)){
signature.setOpVersion(signatureLast.getOpVersion() + 1);
}
// save signature
signature.setApplicationId(applicationId);
signature.setCreateTimestamp(System.currentTimeMillis());
signature.setCreateUserId(StpUtil.getLoginIdAsString());
this.save(signature);
}
@Override
public List<ApplicationSignatureEntity> queryList(String applicationId) {
Map<Object, Object> params = T.MapUtil.builder().put("applicationId", applicationId).build();
List<ApplicationSignatureEntity> list = this.getBaseMapper().queryList(params);
return list;
}
@Override
public List<ApplicationSignatureEntity> compare(String applicationId, String oldVersion, String newVersion) {
List<String> versionList = Arrays.asList(oldVersion, newVersion);
Map<Object, Object> params = T.MapUtil.builder()
.put("applicationId", applicationId)
.put("versions", versionList)
.build();
List<ApplicationSignatureEntity> list = this.getBaseMapper().queryList(params);
return list;
}
@Override
public void restore(String applicationId, String version) {
ApplicationSignatureEntity signature = this.getOne(new LambdaQueryWrapper<ApplicationSignatureEntity>()
.eq(ApplicationSignatureEntity::getApplicationId, applicationId)
.eq(ApplicationSignatureEntity::getOpVersion, version));
ApplicationSignatureEntity lastSignature = this.getOne(new LambdaQueryWrapper<ApplicationSignatureEntity>()
.eq(ApplicationSignatureEntity::getApplicationId, applicationId)
.orderByDesc(ApplicationSignatureEntity::getOpVersion)
.last("limit 1"));
if (T.ObjectUtil.isEmpty(signature)) {
throw ASWException.builder().rcode(RCode.APP_SIGNATURE_NOT_EXIST).build();
}
// restore
signature.setId(null);
signature.setOpVersion(lastSignature.getOpVersion() + 1);
this.save(signature);
}
}

View File

@@ -1,13 +0,0 @@
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 {
}

View File

@@ -5,13 +5,12 @@
<resultMap id="appResult" type="net.geedge.asw.module.app.entity.ApplicationEntity">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="longName" column="long_name"/>
<result property="properties" column="properties"/>
<result property="description" column="description"/>
<result property="tags" column="tags"/>
<result property="packageName" column="package_name"/>
<result property="website" column="website"/>
<result property="provider" column="provider"/>
<result property="surrogates" column="surrogates"/>
<result property="status" column="status"/>
<result property="description" column="description"/>
<result property="createTimestamp" column="create_timestamp"/>
<result property="updateTimestamp" column="update_timestamp"/>
<result property="createUserId" column="create_user_id"/>
@@ -48,13 +47,9 @@
#{id}
</foreach>
</if>
<if test="params.q != null and params.q != ''">
AND ( locate(#{params.q}, app.name) OR locate(#{params.q}, app.description) )
</if>
<if test="params.id != null and params.id != ''">
AND app.id = #{params.id}
</if>
<if test="params.workspaceId != null and params.workspaceId != ''">
AND app.workspace_id = #{params.workspaceId}
</if>

View 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.ApplicationSignatureDao">
<resultMap id="signatureResult" type="net.geedge.asw.module.app.entity.ApplicationSignatureEntity">
<result property="id" column="id"/>
<result property="applicationId" column="application_id"/>
<result property="content" column="content"/>
<result property="createTimestamp" column="create_timestamp"/>
<result property="createUserId" column="create_user_id"/>
<result property="opVersion" column="op_version"/>
<association property="createUser" columnPrefix="c_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
<id property="id" column="id"/>
<result property="name" column="name"/>
</association>
</resultMap>
<select id="queryList" resultMap="signatureResult">
SELECT
asg.*,
cu.id as c_id,
cu.name as c_name
FROM
application_signature asg
left join sys_user cu on asg.create_user_id = cu.id
<where>
<if test="params.applicationId != null and params.applicationId != ''">
AND asg.application_id = #{params.applicationId}
</if>
<if test="params.versions != null and params.versions != ''">
AND asg.op_version in
<foreach item="version" collection="params.versions" separator="," open="(" close=")">
#{version}
</foreach>
</if>
</where>
ORDER BY asg.op_version DESC
</select>
</mapper>

View File

@@ -89,6 +89,20 @@ 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 (135, '100011', 'USER_NOT_EXIST', '用户不存在', 'zh', '', 'admin', 1719280800000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (137, '100012', 'ROLE_NOT_EXIST', 'role does not exist', 'en', '', 'admin', 1719280800000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (139, '100012', 'ROLE_NOT_EXIST', '权限不存在', 'zh', '', 'admin', 1719280800000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (141, '501001', 'PCAP_UPLOAD_WEB_SHARK_ERROR', 'web shark upload pcap error', 'en', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (143, '501001', 'PCAP_UPLOAD_WEB_SHARK_ERROR', 'pcap 上传失败', 'zh', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (145, '201009', 'APP_PACKAGE_NAME_FORMAT_ERROR', 'application package name format error', 'en', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (147, '201009', 'APP_PACKAGE_NAME_FORMAT_ERROR', '应用安装包名称格式错误', 'zh', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (149, '201010', 'APP_TAGS_FORMAT_ERROR', 'application tags format error', 'en', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (151, '201010', 'APP_TAGS_FORMAT_ERROR', '应用标签格式错误', 'zh', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (153, '201011', 'APP_SIGNATURE_FORMAT_ERROR', 'application signature format error', 'en', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (155, '201011', 'APP_SIGNATURE_FORMAT_ERROR', '应用特征格式错误', 'zh', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (157, '201012', 'APP_SIGNATURE_CONTENT_CANNOT_EMPTY', 'application signature content cannot be empty', 'en', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (159, '201012', 'APP_SIGNATURE_CONTENT_CANNOT_EMPTY', '应用特征内容不能为空', 'zh', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (161, '201013', 'APP_SIGNATURE_NOT_EXIST', 'application signature does not exist', 'en', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (163, '201013', 'APP_SIGNATURE_NOT_EXIST', '应用特征不存在', 'zh', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (165, '201014', 'APP_NOTE_CONTENT_CANNOT_EMPTY', 'application note content cannot be empty', 'en', '', 'admin', 1724030366000);
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (167, '201014', 'APP_NOTE_CONTENT_CANNOT_EMPTY', '应用说明内容不能为空', 'zh', '', 'admin', 1724030366000);
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -245,13 +245,12 @@ DROP TABLE IF EXISTS `application`;
CREATE TABLE `application` (
`id` varchar(64) NOT NULL COMMENT '主键',
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '应用名称',
`long_name` varchar(256) NOT NULL DEFAULT '' COMMENT '应用全称',
`properties` text NOT NULL DEFAULT '' COMMENT '应用数据',
`tags` TEXT NOT NULL DEFAULT '' COMMENT '标签',
`package_name` VARCHAR(512) NOT NULL DEFAULT '' COMMENT '包名',
`website` VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '网站',
`provider` VARCHAR(256) NOT NULL DEFAULT '' COMMENT '开发者',
`status` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '状态:open,inprogress,done',
`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 '创建人',
@@ -260,7 +259,6 @@ CREATE TABLE `application` (
`op_version` int(10) NOT NULL DEFAULT 1 COMMENT '版本号',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_name` (`name`) USING BTREE,
KEY `idx_long_name` (`long_name`) USING BTREE,
KEY `idx_workspace_id` (`workspace_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
@@ -272,13 +270,12 @@ DROP TABLE IF EXISTS `application_log`;
CREATE TABLE `application_log` (
`id` varchar(64) NOT NULL COMMENT '主键',
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '应用名称',
`long_name` varchar(256) NOT NULL DEFAULT '' COMMENT '应用全称',
`properties` text NOT NULL DEFAULT '' COMMENT '应用数据',
`tags` TEXT NOT NULL DEFAULT '' COMMENT '标签',
`package_name` VARCHAR(512) NOT NULL DEFAULT '' COMMENT '包名',
`website` VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '网站',
`provider` VARCHAR(256) NOT NULL DEFAULT '' COMMENT '开发者',
`status` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '状态:open,inprogress,done',
`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 '创建人',
@@ -288,6 +285,48 @@ CREATE TABLE `application_log` (
UNIQUE INDEX `index_id_version` (`id`, `op_version`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/**
* 新增 application_signature 表
*/
DROP TABLE IF EXISTS `application_signature`;
CREATE TABLE `application_signature` (
`id` VARCHAR(64) NOT NULL COMMENT '主键',
`application_id` VARCHAR(64) NOT NULL COMMENT '应用id',
`content` TEXT NOT NULL COMMENT '特征 json',
`create_timestamp` BIGINT(20) NOT NULL COMMENT '创建时间戳',
`create_user_id` VARCHAR(64) NOT NULL COMMENT '创建人',
`op_version` INT(10) NOT NULL DEFAULT 1 COMMENT '版本号',
UNIQUE INDEX `index_id_version` (`id`, `op_version`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/**
* 新增 application_note 表
*/
DROP TABLE IF EXISTS `application_note`;
CREATE TABLE `application_note` (
`id` VARCHAR(64) NOT NULL COMMENT '主键',
`application_id` VARCHAR(64) NOT NULL COMMENT '应用id',
`content` TEXT NOT NULL ,
`create_timestamp` BIGINT(20) NOT NULL COMMENT '创建时间戳',
`create_user_id` VARCHAR(64) NOT NULL COMMENT '创建人id',
`op_version` INT(10) NOT NULL DEFAULT 1 COMMENT '版本号',
UNIQUE INDEX `index_id_version` (`id`, `op_version`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/**
* 新增 application_attachment 表
*/
DROP TABLE IF EXISTS `application_attachment`;
CREATE TABLE `application_attachment` (
`id` VARCHAR(64) NOT NULL COMMENT '主键',
`application_id` VARCHAR(64) NOT NULL COMMENT '应用id',
`name` VARCHAR(256) NOT NULL COMMENT '文件名',
`path` VARCHAR(512) NOT NULL COMMENT '文件路径',
`create_timestamp` BIGINT(20) NOT NULL COMMENT '创建时间戳',
`create_user_id` VARCHAR(64) NOT NULL COMMENT '创建人id',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/**
* 新增 package 表
*/