diff --git a/src/main/java/net/geedge/asw/common/util/RCode.java b/src/main/java/net/geedge/asw/common/util/RCode.java index afbc88a..60c4a3a 100644 --- a/src/main/java/net/geedge/asw/common/util/RCode.java +++ b/src/main/java/net/geedge/asw/common/util/RCode.java @@ -38,6 +38,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 diff --git a/src/main/java/net/geedge/asw/common/util/VerifyUtil.java b/src/main/java/net/geedge/asw/common/util/VerifyUtil.java index 1963051..3c94fe2 100644 --- a/src/main/java/net/geedge/asw/common/util/VerifyUtil.java +++ b/src/main/java/net/geedge/asw/common/util/VerifyUtil.java @@ -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; + } + /** * 多参数校验,不能同时为空 * diff --git a/src/main/java/net/geedge/asw/module/app/controller/ApplicationController.java b/src/main/java/net/geedge/asw/module/app/controller/ApplicationController.java index ef7fd13..f868943 100644 --- a/src/main/java/net/geedge/asw/module/app/controller/ApplicationController.java +++ b/src/main/java/net/geedge/asw/module/app/controller/ApplicationController.java @@ -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,26 +118,57 @@ public class ApplicationController { return R.ok(); } - @GetMapping("/{id}/log") - public R queryLogList(@PathVariable("id") String id) { - List 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 list = attachmentService.list(new LambdaQueryWrapper().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 list = applicationService.compare(id, oldVersion, newVersion); - return R.ok().putData("record", list); + @PostMapping("/{applicationId}/attachment") + public R uploadAttachment(@PathVariable String applicationId, @RequestParam("files") List fileList) { + + List 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) { + + attachmentService.removedAttachment(applicationId, ids); + return R.ok(); } - @PostMapping("/{id}/{version}/restore") - public R restore(@PathVariable("id") String id, + @GetMapping("/{applicationId}/signature") + public R querySignature(@PathVariable String applicationId) { + T.VerifyUtil.is(applicationId).notNull(); + List signatureList = signatureService.queryList(applicationId); + return R.ok().putData("records", signatureList); + } + + + @GetMapping("/{applicationId}/signature/{oldVersion}/{newVersion}") + public R signatureCompare(@PathVariable("applicationId") String applicationId, + @PathVariable("oldVersion") String oldVersion, + @PathVariable("newVersion") String newVersion) { + List 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) { - applicationService.restore(id, version); + signatureService.restore(applicationId, version); return R.ok(); } diff --git a/src/main/java/net/geedge/asw/module/app/dao/ApplicationAttachmentDao.java b/src/main/java/net/geedge/asw/module/app/dao/ApplicationAttachmentDao.java new file mode 100644 index 0000000..4c07bd6 --- /dev/null +++ b/src/main/java/net/geedge/asw/module/app/dao/ApplicationAttachmentDao.java @@ -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{ + +} diff --git a/src/main/java/net/geedge/asw/module/app/dao/SignatureDao.java b/src/main/java/net/geedge/asw/module/app/dao/ApplicationNoteDao.java similarity index 51% rename from src/main/java/net/geedge/asw/module/app/dao/SignatureDao.java rename to src/main/java/net/geedge/asw/module/app/dao/ApplicationNoteDao.java index f23dd15..88dca7f 100644 --- a/src/main/java/net/geedge/asw/module/app/dao/SignatureDao.java +++ b/src/main/java/net/geedge/asw/module/app/dao/ApplicationNoteDao.java @@ -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{ +public interface ApplicationNoteDao extends BaseMapper{ } diff --git a/src/main/java/net/geedge/asw/module/app/dao/ApplicationSignatureDao.java b/src/main/java/net/geedge/asw/module/app/dao/ApplicationSignatureDao.java new file mode 100644 index 0000000..4da0801 --- /dev/null +++ b/src/main/java/net/geedge/asw/module/app/dao/ApplicationSignatureDao.java @@ -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{ + + List queryList(@Param("params") Map params); +} diff --git a/src/main/java/net/geedge/asw/module/app/entity/ApplicationAttachmentEntity.java b/src/main/java/net/geedge/asw/module/app/entity/ApplicationAttachmentEntity.java new file mode 100644 index 0000000..8f15e2a --- /dev/null +++ b/src/main/java/net/geedge/asw/module/app/entity/ApplicationAttachmentEntity.java @@ -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; + +} \ No newline at end of file diff --git a/src/main/java/net/geedge/asw/module/app/entity/ApplicationEntity.java b/src/main/java/net/geedge/asw/module/app/entity/ApplicationEntity.java index 217dda5..5e8d69e 100644 --- a/src/main/java/net/geedge/asw/module/app/entity/ApplicationEntity.java +++ b/src/main/java/net/geedge/asw/module/app/entity/ApplicationEntity.java @@ -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 attatchments; } \ No newline at end of file diff --git a/src/main/java/net/geedge/asw/module/app/entity/ApplicationLogEntity.java b/src/main/java/net/geedge/asw/module/app/entity/ApplicationLogEntity.java index 6718169..98ba63a 100644 --- a/src/main/java/net/geedge/asw/module/app/entity/ApplicationLogEntity.java +++ b/src/main/java/net/geedge/asw/module/app/entity/ApplicationLogEntity.java @@ -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 attatchments; + } diff --git a/src/main/java/net/geedge/asw/module/app/entity/SignatureEntity.java b/src/main/java/net/geedge/asw/module/app/entity/ApplicationNoteEntity.java similarity index 55% rename from src/main/java/net/geedge/asw/module/app/entity/SignatureEntity.java rename to src/main/java/net/geedge/asw/module/app/entity/ApplicationNoteEntity.java index 1ef28db..1cbcbe7 100644 --- a/src/main/java/net/geedge/asw/module/app/entity/SignatureEntity.java +++ b/src/main/java/net/geedge/asw/module/app/entity/ApplicationNoteEntity.java @@ -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; } \ No newline at end of file diff --git a/src/main/java/net/geedge/asw/module/app/entity/ApplicationSignatureEntity.java b/src/main/java/net/geedge/asw/module/app/entity/ApplicationSignatureEntity.java new file mode 100644 index 0000000..4ab1a42 --- /dev/null +++ b/src/main/java/net/geedge/asw/module/app/entity/ApplicationSignatureEntity.java @@ -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; + +} \ No newline at end of file diff --git a/src/main/java/net/geedge/asw/module/app/service/ApplicationAttachmentService.java b/src/main/java/net/geedge/asw/module/app/service/ApplicationAttachmentService.java new file mode 100644 index 0000000..f4d4028 --- /dev/null +++ b/src/main/java/net/geedge/asw/module/app/service/ApplicationAttachmentService.java @@ -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 saveAttachment(Resource fileResource, String applicationId); + + void removedAttachment(String applicationId, String ids); +} diff --git a/src/main/java/net/geedge/asw/module/app/service/ApplicationNoteService.java b/src/main/java/net/geedge/asw/module/app/service/ApplicationNoteService.java new file mode 100644 index 0000000..cf75795 --- /dev/null +++ b/src/main/java/net/geedge/asw/module/app/service/ApplicationNoteService.java @@ -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{ + + void saveNote(ApplicationNoteEntity note, String applicationId); +} diff --git a/src/main/java/net/geedge/asw/module/app/service/ApplicationSignatureService.java b/src/main/java/net/geedge/asw/module/app/service/ApplicationSignatureService.java new file mode 100644 index 0000000..d8b3528 --- /dev/null +++ b/src/main/java/net/geedge/asw/module/app/service/ApplicationSignatureService.java @@ -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{ + + void saveSignature(ApplicationSignatureEntity signature, String applicationId); + + List queryList(String applicationId); + + List compare(String applicationId, String oldVersion, String newVersion); + + void restore(String id, String version); +} diff --git a/src/main/java/net/geedge/asw/module/app/service/IApplicationService.java b/src/main/java/net/geedge/asw/module/app/service/IApplicationService.java index 4de8fab..b455401 100644 --- a/src/main/java/net/geedge/asw/module/app/service/IApplicationService.java +++ b/src/main/java/net/geedge/asw/module/app/service/IApplicationService.java @@ -9,20 +9,15 @@ import java.util.Map; public interface IApplicationService extends IService{ + ApplicationEntity detail(String id, String workspaceId); + Page queryList(Map params); ApplicationEntity saveApplication(ApplicationEntity entity); ApplicationEntity updateApplication(ApplicationEntity entity); + ApplicationEntity updateBasic(ApplicationEntity entity); + void removeApplication(List ids); - - ApplicationEntity queryByApplicationAndLog(String id, String version); - - List compare(String id, String oldVersion, String newVersion); - - List queryLogList(String id); - - void restore(String id, String version); - } diff --git a/src/main/java/net/geedge/asw/module/app/service/ISignatureService.java b/src/main/java/net/geedge/asw/module/app/service/ISignatureService.java deleted file mode 100644 index 6860d1d..0000000 --- a/src/main/java/net/geedge/asw/module/app/service/ISignatureService.java +++ /dev/null @@ -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{ - -} diff --git a/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationAttachmentServiceImpl.java b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationAttachmentServiceImpl.java new file mode 100644 index 0000000..4bd8e74 --- /dev/null +++ b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationAttachmentServiceImpl.java @@ -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 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() + .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 idList = Arrays.asList(ids.split(",")); + + for (String id : idList) { + ApplicationAttachmentEntity attachment = this.getOne(new LambdaQueryWrapper() + .eq(ApplicationAttachmentEntity::getApplicationId, applicationId) + .eq(ApplicationAttachmentEntity::getId, id)); + + T.FileUtil.del(FileUtil.file(attachment.getPath())); + this.removeById(id); + } + } +} diff --git a/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationNoteServiceImpl.java b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationNoteServiceImpl.java new file mode 100644 index 0000000..690915c --- /dev/null +++ b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationNoteServiceImpl.java @@ -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 implements ApplicationNoteService { + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveNote(ApplicationNoteEntity note, String applicationId) { + // query last note + ApplicationNoteEntity noteLast = this.getOne(new LambdaQueryWrapper() + .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); + } +} diff --git a/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java index f3c7d8a..53be083 100644 --- a/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java +++ b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java @@ -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() + .eq(ApplicationEntity::getId, id) + .eq(ApplicationEntity::getWorkspaceId, workspaceId)); + + ApplicationSignatureEntity signature = signatureService.getOne(new LambdaQueryWrapper() + .eq(ApplicationSignatureEntity::getApplicationId, app.getId()) + .orderByDesc(ApplicationSignatureEntity::getOpVersion) + .last("limit 1")); + app.setSignature(signature); + + ApplicationNoteEntity note = noteService.getOne(new LambdaQueryWrapper() + .eq(ApplicationNoteEntity::getApplicationId, app.getId()) + .orderByDesc(ApplicationNoteEntity::getOpVersion) + .last("limit 1")); + app.setNote(note); + + List attachmentEntityList = attachmentService.list(new LambdaQueryWrapper() + .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() .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() - .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().in(ApplicationSignatureEntity::getApplicationId, ids)); + noteService.remove(new LambdaQueryWrapper().in(ApplicationNoteEntity::getApplicationId, ids)); + attachmentService.remove(new LambdaQueryWrapper().in(ApplicationAttachmentEntity::getApplicationId, ids)); } @Override - public List queryLogList(String id) { - List packageList = this.getBaseMapper().queryLogList(id); - return packageList; - } + public ApplicationEntity updateBasic(ApplicationEntity entity) { - @Override - public List compare(String id, String oldVersion, String newVersion) { - Map params = Map.of("id", id, "versions", Arrays.asList(oldVersion, newVersion)); - List packageList = this.getBaseMapper().compare(params); - return packageList; - } + 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("{}"); + } - @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() - .eq(ApplicationLogEntity::getId, id) - .eq(ApplicationLogEntity::getOpVersion, version)); + entity.setUpdateTimestamp(System.currentTimeMillis()); + entity.setUpdateUserId(StpUtil.getLoginIdAsString()); + entity.setOpVersion(one.getOpVersion() + 1); - oldApplication.setUpdateTimestamp(System.currentTimeMillis()); - oldApplication.setUpdateUserId(StpUtil.getLoginIdAsString()); - oldApplication.setOpVersion(curApplication.getOpVersion() + 1); - - ApplicationEntity application = T.BeanUtil.toBean(oldApplication, ApplicationEntity.class); - this.updateById(application); + this.saveApplicationToLog(one); + this.updateById(entity); + return entity; } } diff --git a/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationSignatureServiceImpl.java b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationSignatureServiceImpl.java new file mode 100644 index 0000000..e1c6e12 --- /dev/null +++ b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationSignatureServiceImpl.java @@ -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 implements ApplicationSignatureService { + + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveSignature(ApplicationSignatureEntity signature, String applicationId) { + // query last note + ApplicationSignatureEntity signatureLast = this.getOne(new LambdaQueryWrapper() + .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 queryList(String applicationId) { + Map params = T.MapUtil.builder().put("applicationId", applicationId).build(); + List list = this.getBaseMapper().queryList(params); + return list; + } + + @Override + public List compare(String applicationId, String oldVersion, String newVersion) { + + List versionList = Arrays.asList(oldVersion, newVersion); + Map params = T.MapUtil.builder() + .put("applicationId", applicationId) + .put("versions", versionList) + .build(); + List list = this.getBaseMapper().queryList(params); + return list; + } + + @Override + public void restore(String applicationId, String version) { + ApplicationSignatureEntity signature = this.getOne(new LambdaQueryWrapper() + .eq(ApplicationSignatureEntity::getApplicationId, applicationId) + .eq(ApplicationSignatureEntity::getOpVersion, version)); + ApplicationSignatureEntity lastSignature = this.getOne(new LambdaQueryWrapper() + .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); + } +} diff --git a/src/main/java/net/geedge/asw/module/app/service/impl/SignatureServiceImpl.java b/src/main/java/net/geedge/asw/module/app/service/impl/SignatureServiceImpl.java deleted file mode 100644 index 10ed915..0000000 --- a/src/main/java/net/geedge/asw/module/app/service/impl/SignatureServiceImpl.java +++ /dev/null @@ -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 implements ISignatureService { - - -} diff --git a/src/main/resources/db/mapper/app/ApplicationMapper.xml b/src/main/resources/db/mapper/app/ApplicationMapper.xml index ad9ad2a..9cc1b6a 100644 --- a/src/main/resources/db/mapper/app/ApplicationMapper.xml +++ b/src/main/resources/db/mapper/app/ApplicationMapper.xml @@ -5,13 +5,12 @@ - - - + - + + @@ -48,13 +47,9 @@ #{id} - AND ( locate(#{params.q}, app.name) OR locate(#{params.q}, app.description) ) - - AND app.id = #{params.id} - AND app.workspace_id = #{params.workspaceId} diff --git a/src/main/resources/db/mapper/app/ApplicationSignatureMapper.xml b/src/main/resources/db/mapper/app/ApplicationSignatureMapper.xml new file mode 100644 index 0000000..441ba8c --- /dev/null +++ b/src/main/resources/db/mapper/app/ApplicationSignatureMapper.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/db/migration/R__AZ_sys_i18n.sql b/src/main/resources/db/migration/R__AZ_sys_i18n.sql index 2b7eab0..7b5ba13 100644 --- a/src/main/resources/db/migration/R__AZ_sys_i18n.sql +++ b/src/main/resources/db/migration/R__AZ_sys_i18n.sql @@ -103,6 +103,16 @@ 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 (163, '100016', 'SYS_USER_BUILT_IN', '内置用户不允许删除或更新', 'zh', '', 'admin', 1724030366000); INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (165, '401010', 'WORKSPACE_NOT_EXIST', 'Workspace does not exist', 'en', '', 'admin', 1724030366000); INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (167, '401010', 'WORKSPACE_NOT_EXIST', '工作空间不存在', 'zh', '', 'admin', 1724030366000); +INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (169, '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 (171, '201010', 'APP_TAGS_FORMAT_ERROR', '应用标签格式错误', 'zh', '', 'admin', 1724030366000); +INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (173, '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 (175, '201011', 'APP_SIGNATURE_FORMAT_ERROR', '应用特征格式错误', 'zh', '', 'admin', 1724030366000); +INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (177, '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 (179, '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 (181, '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 (183, '201013', 'APP_SIGNATURE_NOT_EXIST', '应用特征不存在', 'zh', '', 'admin', 1724030366000); +INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (185, '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 (187, '201014', 'APP_NOTE_CONTENT_CANNOT_EMPTY', '应用说明内容不能为空', 'zh', '', 'admin', 1724030366000); SET FOREIGN_KEY_CHECKS = 1; diff --git a/src/main/resources/db/migration/V1.0.01__INIT_TABLES.sql b/src/main/resources/db/migration/V1.0.01__INIT_TABLES.sql index 2aef0aa..e5ba4f8 100644 --- a/src/main/resources/db/migration/V1.0.01__INIT_TABLES.sql +++ b/src/main/resources/db/migration/V1.0.01__INIT_TABLES.sql @@ -251,13 +251,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 '创建人', @@ -266,7 +265,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; @@ -278,13 +276,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 '创建人', @@ -294,6 +291,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 表 */