refactor: 缺陷添加platform_id

This commit is contained in:
chenjianxing 2021-10-26 19:02:26 +08:00 committed by jianxing
parent 99e6d2c6eb
commit c0daa6018d
11 changed files with 149 additions and 43 deletions

View File

@ -31,5 +31,7 @@ public class Issues implements Serializable {
private String platformStatus; private String platformStatus;
private String platformId;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -983,6 +983,76 @@ public class IssuesExample {
addCriterion("platform_status not between", value1, value2, "platformStatus"); addCriterion("platform_status not between", value1, value2, "platformStatus");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andPlatformIdIsNull() {
addCriterion("platform_id is null");
return (Criteria) this;
}
public Criteria andPlatformIdIsNotNull() {
addCriterion("platform_id is not null");
return (Criteria) this;
}
public Criteria andPlatformIdEqualTo(String value) {
addCriterion("platform_id =", value, "platformId");
return (Criteria) this;
}
public Criteria andPlatformIdNotEqualTo(String value) {
addCriterion("platform_id <>", value, "platformId");
return (Criteria) this;
}
public Criteria andPlatformIdGreaterThan(String value) {
addCriterion("platform_id >", value, "platformId");
return (Criteria) this;
}
public Criteria andPlatformIdGreaterThanOrEqualTo(String value) {
addCriterion("platform_id >=", value, "platformId");
return (Criteria) this;
}
public Criteria andPlatformIdLessThan(String value) {
addCriterion("platform_id <", value, "platformId");
return (Criteria) this;
}
public Criteria andPlatformIdLessThanOrEqualTo(String value) {
addCriterion("platform_id <=", value, "platformId");
return (Criteria) this;
}
public Criteria andPlatformIdLike(String value) {
addCriterion("platform_id like", value, "platformId");
return (Criteria) this;
}
public Criteria andPlatformIdNotLike(String value) {
addCriterion("platform_id not like", value, "platformId");
return (Criteria) this;
}
public Criteria andPlatformIdIn(List<String> values) {
addCriterion("platform_id in", values, "platformId");
return (Criteria) this;
}
public Criteria andPlatformIdNotIn(List<String> values) {
addCriterion("platform_id not in", values, "platformId");
return (Criteria) this;
}
public Criteria andPlatformIdBetween(String value1, String value2) {
addCriterion("platform_id between", value1, value2, "platformId");
return (Criteria) this;
}
public Criteria andPlatformIdNotBetween(String value1, String value2) {
addCriterion("platform_id not between", value1, value2, "platformId");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -15,6 +15,7 @@
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" /> <result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
<result column="num" jdbcType="INTEGER" property="num" /> <result column="num" jdbcType="INTEGER" property="num" />
<result column="platform_status" jdbcType="VARCHAR" property="platformStatus" /> <result column="platform_status" jdbcType="VARCHAR" property="platformStatus" />
<result column="platform_id" jdbcType="VARCHAR" property="platformId" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.IssuesWithBLOBs"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.IssuesWithBLOBs">
<result column="description" jdbcType="LONGVARCHAR" property="description" /> <result column="description" jdbcType="LONGVARCHAR" property="description" />
@ -80,7 +81,7 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, title, `status`, create_time, update_time, reporter, lastmodify, platform, project_id, id, title, `status`, create_time, update_time, reporter, lastmodify, platform, project_id,
creator, resource_id, num, platform_status creator, resource_id, num, platform_status, platform_id
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
description, custom_fields description, custom_fields
@ -138,14 +139,14 @@
create_time, update_time, reporter, create_time, update_time, reporter,
lastmodify, platform, project_id, lastmodify, platform, project_id,
creator, resource_id, num, creator, resource_id, num,
platform_status, description, custom_fields platform_status, platform_id, description,
) custom_fields)
values (#{id,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{reporter,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{reporter,jdbcType=VARCHAR},
#{lastmodify,jdbcType=VARCHAR}, #{platform,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{lastmodify,jdbcType=VARCHAR}, #{platform,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR},
#{creator,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, #{num,jdbcType=INTEGER}, #{creator,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, #{num,jdbcType=INTEGER},
#{platformStatus,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}, #{customFields,jdbcType=LONGVARCHAR} #{platformStatus,jdbcType=VARCHAR}, #{platformId,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR},
) #{customFields,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.IssuesWithBLOBs"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.IssuesWithBLOBs">
insert into issues insert into issues
@ -189,6 +190,9 @@
<if test="platformStatus != null"> <if test="platformStatus != null">
platform_status, platform_status,
</if> </if>
<if test="platformId != null">
platform_id,
</if>
<if test="description != null"> <if test="description != null">
description, description,
</if> </if>
@ -236,6 +240,9 @@
<if test="platformStatus != null"> <if test="platformStatus != null">
#{platformStatus,jdbcType=VARCHAR}, #{platformStatus,jdbcType=VARCHAR},
</if> </if>
<if test="platformId != null">
#{platformId,jdbcType=VARCHAR},
</if>
<if test="description != null"> <if test="description != null">
#{description,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR},
</if> </if>
@ -292,6 +299,9 @@
<if test="record.platformStatus != null"> <if test="record.platformStatus != null">
platform_status = #{record.platformStatus,jdbcType=VARCHAR}, platform_status = #{record.platformStatus,jdbcType=VARCHAR},
</if> </if>
<if test="record.platformId != null">
platform_id = #{record.platformId,jdbcType=VARCHAR},
</if>
<if test="record.description != null"> <if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR},
</if> </if>
@ -318,6 +328,7 @@
resource_id = #{record.resourceId,jdbcType=VARCHAR}, resource_id = #{record.resourceId,jdbcType=VARCHAR},
num = #{record.num,jdbcType=INTEGER}, num = #{record.num,jdbcType=INTEGER},
platform_status = #{record.platformStatus,jdbcType=VARCHAR}, platform_status = #{record.platformStatus,jdbcType=VARCHAR},
platform_id = #{record.platformId,jdbcType=VARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR},
custom_fields = #{record.customFields,jdbcType=LONGVARCHAR} custom_fields = #{record.customFields,jdbcType=LONGVARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
@ -338,7 +349,8 @@
creator = #{record.creator,jdbcType=VARCHAR}, creator = #{record.creator,jdbcType=VARCHAR},
resource_id = #{record.resourceId,jdbcType=VARCHAR}, resource_id = #{record.resourceId,jdbcType=VARCHAR},
num = #{record.num,jdbcType=INTEGER}, num = #{record.num,jdbcType=INTEGER},
platform_status = #{record.platformStatus,jdbcType=VARCHAR} platform_status = #{record.platformStatus,jdbcType=VARCHAR},
platform_id = #{record.platformId,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -382,6 +394,9 @@
<if test="platformStatus != null"> <if test="platformStatus != null">
platform_status = #{platformStatus,jdbcType=VARCHAR}, platform_status = #{platformStatus,jdbcType=VARCHAR},
</if> </if>
<if test="platformId != null">
platform_id = #{platformId,jdbcType=VARCHAR},
</if>
<if test="description != null"> <if test="description != null">
description = #{description,jdbcType=LONGVARCHAR}, description = #{description,jdbcType=LONGVARCHAR},
</if> </if>
@ -405,6 +420,7 @@
resource_id = #{resourceId,jdbcType=VARCHAR}, resource_id = #{resourceId,jdbcType=VARCHAR},
num = #{num,jdbcType=INTEGER}, num = #{num,jdbcType=INTEGER},
platform_status = #{platformStatus,jdbcType=VARCHAR}, platform_status = #{platformStatus,jdbcType=VARCHAR},
platform_id = #{platformId,jdbcType=VARCHAR},
description = #{description,jdbcType=LONGVARCHAR}, description = #{description,jdbcType=LONGVARCHAR},
custom_fields = #{customFields,jdbcType=LONGVARCHAR} custom_fields = #{customFields,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
@ -422,7 +438,8 @@
creator = #{creator,jdbcType=VARCHAR}, creator = #{creator,jdbcType=VARCHAR},
resource_id = #{resourceId,jdbcType=VARCHAR}, resource_id = #{resourceId,jdbcType=VARCHAR},
num = #{num,jdbcType=INTEGER}, num = #{num,jdbcType=INTEGER},
platform_status = #{platformStatus,jdbcType=VARCHAR} platform_status = #{platformStatus,jdbcType=VARCHAR},
platform_id = #{platformId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -13,7 +13,7 @@
</select> </select>
<select id="getIssues" resultType="io.metersphere.base.domain.IssuesDao"> <select id="getIssues" resultType="io.metersphere.base.domain.IssuesDao">
select issues.id, issues.num, ifnull(issues.title, '') as title, issues.project_id, issues.create_time, issues.update_time, select issues.id, issues.platform_id, issues.num, ifnull(issues.title, '') as title, issues.project_id, issues.create_time, issues.update_time,
ifnull(issues.description, '') as description, issues.status, issues.platform, issues.custom_fields, issues.reporter, ifnull(issues.description, '') as description, issues.status, issues.platform, issues.custom_fields, issues.reporter,
issues.creator,issues.resource_id,issues.platform_status, issues.creator,issues.resource_id,issues.platform_status,
issues.lastmodify issues.lastmodify
@ -43,7 +43,7 @@
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select> </select>
<select id="getIssueForSync" resultType="io.metersphere.base.domain.IssuesDao"> <select id="getIssueForSync" resultType="io.metersphere.base.domain.IssuesDao">
select id,platform select id,platform, platform_id
from issues from issues
where project_id = #{projectId} and platform != 'Local'; where project_id = #{projectId} and platform != 'Local';
</select> </select>

View File

@ -194,10 +194,11 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
issuesMapper.insert(issues); issuesMapper.insert(issues);
} }
protected void insertIssues(String id, IssuesUpdateRequest issuesRequest) { protected void insertIssues(IssuesUpdateRequest issuesRequest) {
IssuesWithBLOBs issues = new IssuesWithBLOBs(); IssuesWithBLOBs issues = new IssuesWithBLOBs();
BeanUtils.copyBean(issues, issuesRequest); BeanUtils.copyBean(issues, issuesRequest);
issues.setId(id); issues.setId(issuesRequest.getId());
issues.setPlatformId(issuesRequest.getPlatformId());
issues.setCreateTime(System.currentTimeMillis()); issues.setCreateTime(System.currentTimeMillis());
issues.setUpdateTime(System.currentTimeMillis()); issues.setUpdateTime(System.currentTimeMillis());
issues.setNum(getNextNum(issuesRequest.getProjectId())); issues.setNum(getNextNum(issuesRequest.getProjectId()));

View File

@ -34,6 +34,7 @@ import org.springframework.web.client.RestTemplate;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
public class JiraPlatform extends AbstractIssuePlatform { public class JiraPlatform extends AbstractIssuePlatform {
@ -99,7 +100,6 @@ public class JiraPlatform extends AbstractIssuePlatform {
if (assignee != null) { if (assignee != null) {
lastmodify = assignee.getString("displayName"); lastmodify = assignee.getString("displayName");
} }
item.setId(jiraIssue.getKey());
item.setTitle(fields.getString("summary")); item.setTitle(fields.getString("summary"));
item.setCreateTime(fields.getLong("created")); item.setCreateTime(fields.getLong("created"));
item.setLastmodify(lastmodify); item.setLastmodify(lastmodify);
@ -247,15 +247,18 @@ public class JiraPlatform extends AbstractIssuePlatform {
imageFiles.forEach(img -> { imageFiles.forEach(img -> {
jiraClientV2.uploadAttachment(result.getKey(), img); jiraClientV2.uploadAttachment(result.getKey(), img);
}); });
String status = getStatus(issues.getFields()); String status = getStatus(issues.getFields());
issuesRequest.setPlatformStatus(status); issuesRequest.setPlatformStatus(status);
issuesRequest.setId(result.getKey()); issuesRequest.setPlatformId(result.getKey());
// 用例与第三方缺陷平台中的缺陷关联 issuesRequest.setId(UUID.randomUUID().toString());
handleTestCaseIssues(issuesRequest);
// 插入缺陷表 // 插入缺陷表
insertIssues(result.getKey(), issuesRequest); insertIssues(issuesRequest);
// 用例与第三方缺陷平台中的缺陷关联
handleTestCaseIssues(issuesRequest);
} }
private JSONObject buildUpdateParam(IssuesUpdateRequest issuesRequest) { private JSONObject buildUpdateParam(IssuesUpdateRequest issuesRequest) {
@ -329,14 +332,15 @@ public class JiraPlatform extends AbstractIssuePlatform {
public void updateIssue(IssuesUpdateRequest request) { public void updateIssue(IssuesUpdateRequest request) {
JSONObject param = buildUpdateParam(request); JSONObject param = buildUpdateParam(request);
handleIssueUpdate(request); handleIssueUpdate(request);
jiraClientV2.updateIssue(request.getId(), JSONObject.toJSONString(param)); jiraClientV2.updateIssue(request.getPlatformId(), JSONObject.toJSONString(param));
} }
@Override @Override
public void deleteIssue(String id) { public void deleteIssue(String id) {
IssuesWithBLOBs issuesWithBLOBs = issuesMapper.selectByPrimaryKey(id);
super.deleteIssue(id); super.deleteIssue(id);
setConfig(); setConfig();
jiraClientV2.deleteIssue(id); jiraClientV2.deleteIssue(issuesWithBLOBs.getPlatformId());
} }
@Override @Override
@ -367,7 +371,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
setConfig(); setConfig();
try { try {
IssuesWithBLOBs issuesWithBLOBs = issuesMapper.selectByPrimaryKey(item.getId()); IssuesWithBLOBs issuesWithBLOBs = issuesMapper.selectByPrimaryKey(item.getId());
parseIssue(item, jiraClientV2.getIssues(item.getId()), issuesWithBLOBs.getCustomFields()); parseIssue(item, jiraClientV2.getIssues(item.getPlatformId()), issuesWithBLOBs.getCustomFields());
String desc = htmlDesc2MsDesc(item.getDescription()); String desc = htmlDesc2MsDesc(item.getDescription());
// 保留之前上传的图片 // 保留之前上传的图片
String images = getImages(issuesWithBLOBs.getDescription()); String images = getImages(issuesWithBLOBs.getDescription());

View File

@ -44,6 +44,7 @@ public class LocalPlatform extends LocalAbstractPlatform {
IssuesWithBLOBs issues = new IssuesWithBLOBs(); IssuesWithBLOBs issues = new IssuesWithBLOBs();
BeanUtils.copyBean(issues, issuesRequest); BeanUtils.copyBean(issues, issuesRequest);
issues.setId(id); issues.setId(id);
issues.setPlatformId(id);
issues.setStatus("new"); issues.setStatus("new");
issues.setReporter(user.getId()); issues.setReporter(user.getId());
issues.setCreateTime(System.currentTimeMillis()); issues.setCreateTime(System.currentTimeMillis());

View File

@ -3,10 +3,7 @@ package io.metersphere.track.issue;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import io.metersphere.base.domain.Issues; import io.metersphere.base.domain.*;
import io.metersphere.base.domain.IssuesDao;
import io.metersphere.base.domain.Project;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import io.metersphere.commons.constants.IssuesManagePlatform; import io.metersphere.commons.constants.IssuesManagePlatform;
import io.metersphere.commons.constants.IssuesStatus; import io.metersphere.commons.constants.IssuesStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
@ -37,6 +34,7 @@ import org.springframework.web.client.RestTemplate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class TapdPlatform extends AbstractIssuePlatform { public class TapdPlatform extends AbstractIssuePlatform {
@ -91,18 +89,20 @@ public class TapdPlatform extends AbstractIssuePlatform {
Map<String, String> statusMap = tapdClient.getStatusMap(getProjectId(this.projectId)); Map<String, String> statusMap = tapdClient.getStatusMap(getProjectId(this.projectId));
issuesRequest.setPlatformStatus(statusMap.get(bug.getStatus())); issuesRequest.setPlatformStatus(statusMap.get(bug.getStatus()));
issuesRequest.setId(bug.getId()); issuesRequest.setPlatformId(bug.getId());
// 用例与第三方缺陷平台中的缺陷关联 issuesRequest.setId(UUID.randomUUID().toString());
handleTestCaseIssues(issuesRequest);
// 插入缺陷表 // 插入缺陷表
insertIssues(bug.getId(), issuesRequest); insertIssues(issuesRequest);
// 用例与第三方缺陷平台中的缺陷关联
handleTestCaseIssues(issuesRequest);
} }
@Override @Override
public void updateIssue(IssuesUpdateRequest request) { public void updateIssue(IssuesUpdateRequest request) {
MultiValueMap<String, Object> param = buildUpdateParam(request); MultiValueMap<String, Object> param = buildUpdateParam(request);
param.add("id", request.getId()); param.add("id", request.getPlatformId());
handleIssueUpdate(request); handleIssueUpdate(request);
tapdClient.updateIssue(param); tapdClient.updateIssue(param);
} }
@ -199,8 +199,11 @@ public class TapdPlatform extends AbstractIssuePlatform {
int limit = 50; int limit = 50;
int count = 50; int count = 50;
Map<String, String> idMap = tapdIssues.stream()
.collect(Collectors.toMap(IssuesDao::getPlatformId, IssuesDao::getId));
List<String> ids = tapdIssues.stream() List<String> ids = tapdIssues.stream()
.map(Issues::getId) .map(IssuesDao::getPlatformId)
.collect(Collectors.toList()); .collect(Collectors.toList());
LogUtil.info("ids: " + ids); LogUtil.info("ids: " + ids);
@ -214,7 +217,6 @@ public class TapdPlatform extends AbstractIssuePlatform {
Map<String, String> statusMap = tapdClient.getStatusMap(project.getTapdId()); Map<String, String> statusMap = tapdClient.getStatusMap(project.getTapdId());
while (count == limit) { while (count == limit) {
count = 0;
TapdGetIssueResponse result = tapdClient.getIssueForPageByIds(project.getTapdId(), pageNum, limit, ids); TapdGetIssueResponse result = tapdClient.getIssueForPageByIds(project.getTapdId(), pageNum, limit, ids);
List<TapdGetIssueResponse.Data> data = result.getData(); List<TapdGetIssueResponse.Data> data = result.getData();
count = data.size(); count = data.size();
@ -223,6 +225,7 @@ public class TapdPlatform extends AbstractIssuePlatform {
TapdBug bug = issue.getBug(); TapdBug bug = issue.getBug();
IssuesDao issuesDao = new IssuesDao(); IssuesDao issuesDao = new IssuesDao();
BeanUtils.copyBean(issuesDao, bug); BeanUtils.copyBean(issuesDao, bug);
issuesDao.setId(idMap.get(issuesDao.getId()));
issuesDao.setPlatformStatus(statusMap.get(bug.getStatus())); issuesDao.setPlatformStatus(statusMap.get(bug.getStatus()));
issuesDao.setDescription(htmlDesc2MsDesc(issuesDao.getDescription())); issuesDao.setDescription(htmlDesc2MsDesc(issuesDao.getDescription()));
issuesMapper.updateByPrimaryKeySelective(issuesDao); issuesMapper.updateByPrimaryKeySelective(issuesDao);
@ -231,10 +234,12 @@ public class TapdPlatform extends AbstractIssuePlatform {
} }
// 查不到的就置为删除 // 查不到的就置为删除
ids.forEach((id) -> { ids.forEach((id) -> {
IssuesDao issuesDao = new IssuesDao(); if (StringUtils.isNotBlank(idMap.get(id))) {
issuesDao.setId(id); IssuesDao issuesDao = new IssuesDao();
issuesDao.setPlatformStatus(IssuesStatus.DELETE.toString()); issuesDao.setId(idMap.get(id));
issuesMapper.updateByPrimaryKeySelective(issuesDao); issuesDao.setPlatformStatus(IssuesStatus.DELETE.toString());
issuesMapper.updateByPrimaryKeySelective(issuesDao);
}
}); });
} }

View File

@ -158,7 +158,6 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
} }
IssuesDao issues = new IssuesDao(); IssuesDao issues = new IssuesDao();
issues.setId(bug.getId());
issues.setPlatformStatus(bug.getStatus()); issues.setPlatformStatus(bug.getStatus());
if (StringUtils.equals(bug.getDeleted(),"1")) { if (StringUtils.equals(bug.getDeleted(),"1")) {
issues.setPlatformStatus(IssuesStatus.DELETE.toString()); issues.setPlatformStatus(IssuesStatus.DELETE.toString());
@ -179,17 +178,19 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
String id = issue.getId(); String id = issue.getId();
if (StringUtils.isNotBlank(id)) { if (StringUtils.isNotBlank(id)) {
issuesRequest.setId(id); issuesRequest.setPlatformId(id);
// 用例与第三方缺陷平台中的缺陷关联 issuesRequest.setId(UUID.randomUUID().toString());
handleTestCaseIssues(issuesRequest);
IssuesExample issuesExample = new IssuesExample(); IssuesExample issuesExample = new IssuesExample();
issuesExample.createCriteria().andIdEqualTo(id) issuesExample.createCriteria().andIdEqualTo(id)
.andPlatformEqualTo(IssuesManagePlatform.Zentao.toString()); .andPlatformEqualTo(IssuesManagePlatform.Zentao.toString());
if (issuesMapper.selectByExample(issuesExample).size() <= 0) { if (issuesMapper.selectByExample(issuesExample).size() <= 0) {
// 插入缺陷表 // 插入缺陷表
insertIssues(id, issuesRequest); insertIssues(issuesRequest);
} }
// 用例与第三方缺陷平台中的缺陷关联
handleTestCaseIssues(issuesRequest);
} }
} }
@ -198,7 +199,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
MultiValueMap<String, Object> param = buildUpdateParam(request); MultiValueMap<String, Object> param = buildUpdateParam(request);
handleIssueUpdate(request); handleIssueUpdate(request);
zentaoClient.setConfig(getUserConfig()); zentaoClient.setConfig(getUserConfig());
zentaoClient.updateIssue(request.getId(), param); zentaoClient.updateIssue(request.getPlatformId(), param);
} }
private MultiValueMap<String, Object> buildUpdateParam(IssuesUpdateRequest issuesRequest) { private MultiValueMap<String, Object> buildUpdateParam(IssuesUpdateRequest issuesRequest) {
@ -242,9 +243,10 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
@Override @Override
public void deleteIssue(String id) { public void deleteIssue(String id) {
IssuesWithBLOBs issuesWithBLOBs = issuesMapper.selectByPrimaryKey(id);
super.deleteIssue(id); super.deleteIssue(id);
zentaoClient.setConfig(getUserConfig()); zentaoClient.setConfig(getUserConfig());
zentaoClient.deleteIssue(id); zentaoClient.deleteIssue(issuesWithBLOBs.getPlatformId());
} }
@Override @Override
@ -327,7 +329,8 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
public void syncIssues(Project project, List<IssuesDao> issues) { public void syncIssues(Project project, List<IssuesDao> issues) {
issues.forEach(item -> { issues.forEach(item -> {
setConfig(); setConfig();
IssuesDao issuesDao = getZentaoIssues(item.getId()); IssuesDao issuesDao = getZentaoIssues(item.getPlatformId());
issuesDao.setId(item.getId());
issuesMapper.updateByPrimaryKeySelective(issuesDao); issuesMapper.updateByPrimaryKeySelective(issuesDao);
}); });
} }

@ -1 +1 @@
Subproject commit d9804d8c3d0496423403794f0997b3b596871a27 Subproject commit ec08189a4f2c3aebf0688f4b9798af2993002d25

View File

@ -453,3 +453,6 @@ WHERE follow_people IS NOT NULL AND follow_people != '';
ALTER TABLE test_case DROP COLUMN follow_people; ALTER TABLE test_case DROP COLUMN follow_people;
-- 操作日志类型增加普通索引 -- 操作日志类型增加普通索引
ALTER TABLE `operating_log` ADD INDEX oper_module_index ( `oper_module` ); ALTER TABLE `operating_log` ADD INDEX oper_module_index ( `oper_module` );
ALTER TABLE issues ADD platform_id varchar(50) NOT NULL;
UPDATE issues SET platform_id = id WHERE 1;