fix: application 接口 添加 properties 属性
This commit is contained in:
@@ -44,6 +44,7 @@ public enum RCode {
|
|||||||
APP_SIGNATURE_NOT_EXIST(201013, "application signature does not exist"),
|
APP_SIGNATURE_NOT_EXIST(201013, "application signature does not exist"),
|
||||||
APP_NOTE_CONTENT_CANNOT_EMPTY(201014, "application note content cannot be empty"),
|
APP_NOTE_CONTENT_CANNOT_EMPTY(201014, "application note content cannot be empty"),
|
||||||
APP_ATTACHMENT_NOT_EXIST(201015, "application attachment does not exist"),
|
APP_ATTACHMENT_NOT_EXIST(201015, "application attachment does not exist"),
|
||||||
|
APP_PROPERTIES_FORMAT_ERROR(201016, "application properties format error"),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import net.geedge.asw.module.app.entity.ApplicationEntity;
|
import net.geedge.asw.module.app.entity.ApplicationEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -14,13 +12,4 @@ import java.util.Map;
|
|||||||
public interface ApplicationDao extends BaseMapper<ApplicationEntity>{
|
public interface ApplicationDao extends BaseMapper<ApplicationEntity>{
|
||||||
|
|
||||||
List<ApplicationEntity> queryList(Page page, Map<String, Object> params);
|
List<ApplicationEntity> queryList(Page page, Map<String, Object> params);
|
||||||
|
|
||||||
@Select("select * from ( select * from application union select * from application_log ) app where app.id = #{id} and app.op_version = #{version}")
|
|
||||||
ApplicationEntity queryByApplicationAndLog(String id, String version);
|
|
||||||
|
|
||||||
List<ApplicationEntity> queryLogList(String id);
|
|
||||||
|
|
||||||
List<ApplicationEntity> compare(@Param("params") Map<String, Object> params);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.geedge.asw.module.sys.entity.SysUserEntity;
|
import net.geedge.asw.module.sys.entity.SysUserEntity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName("application")
|
@TableName(value = "application", autoResultMap = true)
|
||||||
public class ApplicationEntity {
|
public class ApplicationEntity {
|
||||||
|
|
||||||
@TableId(type = IdType.ASSIGN_UUID)
|
@TableId(type = IdType.ASSIGN_UUID)
|
||||||
@@ -26,6 +27,9 @@ public class ApplicationEntity {
|
|||||||
|
|
||||||
private String provider;
|
private String provider;
|
||||||
|
|
||||||
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
|
private Object properties;
|
||||||
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.geedge.asw.module.sys.entity.SysUserEntity;
|
import net.geedge.asw.module.sys.entity.SysUserEntity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName("application_log")
|
@TableName(value = "application_log", autoResultMap = true)
|
||||||
public class ApplicationLogEntity {
|
public class ApplicationLogEntity {
|
||||||
|
|
||||||
@TableId(type = IdType.ASSIGN_UUID)
|
@TableId(type = IdType.ASSIGN_UUID)
|
||||||
@@ -26,7 +26,8 @@ public class ApplicationLogEntity {
|
|||||||
|
|
||||||
private String provider;
|
private String provider;
|
||||||
|
|
||||||
private String status;
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
|
private String properties;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
|||||||
@@ -1,53 +1,33 @@
|
|||||||
package net.geedge.asw.module.app.service.impl;
|
package net.geedge.asw.module.app.service.impl;
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.net.url.UrlBuilder;
|
|
||||||
import cn.hutool.log.Log;
|
import cn.hutool.log.Log;
|
||||||
import com.alibaba.fastjson2.JSONArray;
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import net.geedge.asw.common.util.ASWException;
|
import net.geedge.asw.common.util.ASWException;
|
||||||
import net.geedge.asw.common.util.RCode;
|
import net.geedge.asw.common.util.RCode;
|
||||||
import net.geedge.asw.common.util.T;
|
import net.geedge.asw.common.util.T;
|
||||||
import net.geedge.asw.module.app.dao.ApplicationDao;
|
import net.geedge.asw.module.app.dao.ApplicationDao;
|
||||||
import net.geedge.asw.module.app.entity.*;
|
import net.geedge.asw.module.app.entity.*;
|
||||||
import net.geedge.asw.module.app.service.*;
|
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.entity.SysUserEntity;
|
||||||
import net.geedge.asw.module.sys.service.ISysUserService;
|
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;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, ApplicationEntity> implements IApplicationService {
|
public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, ApplicationEntity> implements IApplicationService {
|
||||||
|
|
||||||
private static final Log log = Log.get();
|
private static final Log log = Log.get();
|
||||||
|
|
||||||
@Value("${kibana.url:127.0.0.1:5601}")
|
|
||||||
private String kibanaUrl;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IApplicationLogService applicationLogService;
|
private IApplicationLogService applicationLogService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IWorkspaceService workspaceService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IPcapService pcapService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
@@ -61,8 +41,6 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, Applicat
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationAttachmentService attachmentService;
|
private ApplicationAttachmentService attachmentService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private KibanaClient kibanaClient;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationEntity detail(String id, String workspaceId) {
|
public ApplicationEntity detail(String id, String workspaceId) {
|
||||||
@@ -139,6 +117,11 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, Applicat
|
|||||||
throw ASWException.builder().rcode(RCode.APP_NOTE_CONTENT_CANNOT_EMPTY).build();
|
throw ASWException.builder().rcode(RCode.APP_NOTE_CONTENT_CANNOT_EMPTY).build();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
// properties
|
||||||
|
if (T.ObjectUtil.isNotEmpty(entity.getProperties()) && !T.JSONUtil.isTypeJSON(entity.getProperties().toString())) {
|
||||||
|
throw ASWException.builder().rcode(RCode.APP_PROPERTIES_FORMAT_ERROR).build();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -233,6 +216,11 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, Applicat
|
|||||||
entity.setPackageName("{}");
|
entity.setPackageName("{}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// properties
|
||||||
|
if (T.ObjectUtil.isNotEmpty(entity.getProperties()) && !T.JSONUtil.isTypeJSON(entity.getProperties().toString())) {
|
||||||
|
throw ASWException.builder().rcode(RCode.APP_PROPERTIES_FORMAT_ERROR).build();
|
||||||
|
}
|
||||||
|
|
||||||
entity.setUpdateTimestamp(System.currentTimeMillis());
|
entity.setUpdateTimestamp(System.currentTimeMillis());
|
||||||
entity.setUpdateUserId(StpUtil.getLoginIdAsString());
|
entity.setUpdateUserId(StpUtil.getLoginIdAsString());
|
||||||
entity.setOpVersion(one.getOpVersion() + 1);
|
entity.setOpVersion(one.getOpVersion() + 1);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<result property="website" column="website"/>
|
<result property="website" column="website"/>
|
||||||
<result property="provider" column="provider"/>
|
<result property="provider" column="provider"/>
|
||||||
<result property="status" column="status"/>
|
<result property="status" column="status"/>
|
||||||
|
<result property="properties" column="properties" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
|
||||||
<result property="description" column="description"/>
|
<result property="description" column="description"/>
|
||||||
<result property="createTimestamp" column="create_timestamp"/>
|
<result property="createTimestamp" column="create_timestamp"/>
|
||||||
<result property="updateTimestamp" column="update_timestamp"/>
|
<result property="updateTimestamp" column="update_timestamp"/>
|
||||||
@@ -59,48 +60,4 @@
|
|||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryLogList" resultMap="appResult">
|
|
||||||
SELECT
|
|
||||||
app.*,
|
|
||||||
cu.id as cu_id,
|
|
||||||
cu.name as cu_name,
|
|
||||||
uu.id as uu_id,
|
|
||||||
uu.id as uu_name
|
|
||||||
FROM
|
|
||||||
(select * from application union select * from application_log) app
|
|
||||||
left join sys_user cu on app.create_user_id = cu.id
|
|
||||||
left join sys_user uu on app.update_user_id = uu.id
|
|
||||||
<where>
|
|
||||||
<if test="id != null and id != ''">
|
|
||||||
AND app.id = #{id}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
ORDER BY app.op_version DESC
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="compare" resultMap="appResult">
|
|
||||||
SELECT
|
|
||||||
app.*,
|
|
||||||
cu.id as cu_id,
|
|
||||||
cu.name as cu_name,
|
|
||||||
uu.id as uu_id,
|
|
||||||
uu.id as uu_name
|
|
||||||
FROM
|
|
||||||
(select * from application union select * from application_log ) app
|
|
||||||
left join sys_user cu on app.create_user_id = cu.id
|
|
||||||
left join sys_user uu on app.update_user_id = uu.id
|
|
||||||
<where>
|
|
||||||
<if test="params.versions != null and params.versions != ''">
|
|
||||||
AND app.op_version in
|
|
||||||
<foreach item="version" collection="params.versions" separator="," open="(" close=")">
|
|
||||||
#{version}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="params.id != null and params.id != ''">
|
|
||||||
AND app.id = #{params.id}
|
|
||||||
</if>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -115,5 +115,7 @@ 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 (187, '201014', 'APP_NOTE_CONTENT_CANNOT_EMPTY', '应用说明内容不能为空', 'zh', '', '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);
|
||||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (189, '201015', 'APP_ATTACHMENT_NOT_EXIST', 'application attachment does not exist', 'en', '', 'admin', 1724030366000);
|
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (189, '201015', 'APP_ATTACHMENT_NOT_EXIST', 'application attachment does not exist', 'en', '', 'admin', 1724030366000);
|
||||||
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (191, '201015', 'APP_ATTACHMENT_NOT_EXIST', '应用附件不存在', 'zh', '', 'admin', 1724030366000);
|
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (191, '201015', 'APP_ATTACHMENT_NOT_EXIST', '应用附件不存在', 'zh', '', 'admin', 1724030366000);
|
||||||
|
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (193, '201016', 'APP_PROPERTIES_FORMAT_ERROR', 'application properties format error', 'en', '', 'admin', 1724030366000);
|
||||||
|
INSERT INTO `sys_i18n`(`id`, `name`, `code`, `value`, `lang`, `remark`, `update_user_id`, `update_timestamp`) VALUES (195, '201016', 'APP_PROPERTIES_FORMAT_ERROR', '应用属性格式错误', 'zh', '', 'admin', 1724030366000);
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|||||||
@@ -256,6 +256,7 @@ CREATE TABLE `application` (
|
|||||||
`website` VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '网站',
|
`website` VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '网站',
|
||||||
`provider` VARCHAR(256) NOT NULL DEFAULT '' COMMENT '开发者',
|
`provider` VARCHAR(256) NOT NULL DEFAULT '' COMMENT '开发者',
|
||||||
`status` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '状态:open,inprogress,done',
|
`status` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '状态:open,inprogress,done',
|
||||||
|
`properties` VARCHAR(4096) NOT NULL DEFAULT '' COMMENT '属性',
|
||||||
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
||||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||||
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
||||||
@@ -281,6 +282,7 @@ CREATE TABLE `application_log` (
|
|||||||
`website` VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '网站',
|
`website` VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '网站',
|
||||||
`provider` VARCHAR(256) NOT NULL DEFAULT '' COMMENT '开发者',
|
`provider` VARCHAR(256) NOT NULL DEFAULT '' COMMENT '开发者',
|
||||||
`status` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '状态:open,inprogress,done',
|
`status` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '状态:open,inprogress,done',
|
||||||
|
`properties` VARCHAR(4096) NOT NULL DEFAULT '' COMMENT '属性',
|
||||||
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
`description` text NOT NULL DEFAULT '' COMMENT '描述信息',
|
||||||
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
`create_timestamp` bigint(20) NOT NULL COMMENT '创建时间戳',
|
||||||
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
`update_timestamp` bigint(20) NOT NULL COMMENT '更新时间戳',
|
||||||
|
|||||||
Reference in New Issue
Block a user