fix: jira模板同步缺陷

This commit is contained in:
chenjianxing 2021-12-14 12:37:57 +08:00 committed by jianxing
parent fdee6c370f
commit a628ea36b4
8 changed files with 50 additions and 33 deletions

View File

@ -1,6 +1,7 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.CustomFieldTemplate; import io.metersphere.base.domain.CustomFieldTemplate;
import io.metersphere.dto.CustomFieldDao;
import io.metersphere.dto.CustomFieldTemplateDao; import io.metersphere.dto.CustomFieldTemplateDao;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -10,4 +11,6 @@ public interface ExtCustomFieldTemplateMapper {
List<String> getCustomFieldIds(@Param("templateId") String templateId); List<String> getCustomFieldIds(@Param("templateId") String templateId);
List<CustomFieldTemplateDao> list(@Param("request") CustomFieldTemplate request); List<CustomFieldTemplateDao> list(@Param("request") CustomFieldTemplate request);
List<CustomFieldDao> lisSimple(@Param("request") CustomFieldTemplate request);
} }

View File

@ -19,4 +19,16 @@
where cft.template_id = #{request.templateId} where cft.template_id = #{request.templateId}
</if> </if>
</select> </select>
<select id="lisSimple" resultType="io.metersphere.dto.CustomFieldDao">
select
template_id, required, default_value, custom_data,
cft.id as id,
cf.name as name, cf.type as type
from custom_field_template cft
inner join custom_field cf
on cft.field_id = cf.id
<if test="request.templateId != null">
where cft.template_id = #{request.templateId}
</if>
</select>
</mapper> </mapper>

View File

@ -7,6 +7,7 @@ import io.metersphere.base.domain.CustomFieldTemplateExample;
import io.metersphere.base.mapper.CustomFieldMapper; import io.metersphere.base.mapper.CustomFieldMapper;
import io.metersphere.base.mapper.CustomFieldTemplateMapper; import io.metersphere.base.mapper.CustomFieldTemplateMapper;
import io.metersphere.base.mapper.ext.ExtCustomFieldTemplateMapper; import io.metersphere.base.mapper.ext.ExtCustomFieldTemplateMapper;
import io.metersphere.dto.CustomFieldDao;
import io.metersphere.dto.CustomFieldTemplateDao; import io.metersphere.dto.CustomFieldTemplateDao;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -51,6 +52,10 @@ public class CustomFieldTemplateService {
return extCustomFieldTemplateMapper.list(request); return extCustomFieldTemplateMapper.list(request);
} }
public List<CustomFieldDao> lisSimple(CustomFieldTemplate request) {
return extCustomFieldTemplateMapper.lisSimple(request);
}
public void deleteByTemplateId(String templateId) { public void deleteByTemplateId(String templateId) {
if (StringUtils.isNotBlank(templateId)) { if (StringUtils.isNotBlank(templateId)) {
CustomFieldTemplateExample example = new CustomFieldTemplateExample(); CustomFieldTemplateExample example = new CustomFieldTemplateExample();

View File

@ -13,7 +13,7 @@ import io.metersphere.commons.constants.IssuesStatus;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*; import io.metersphere.commons.utils.*;
import io.metersphere.controller.request.IntegrationRequest; import io.metersphere.controller.request.IntegrationRequest;
import io.metersphere.dto.CustomFieldTemplateDao; import io.metersphere.dto.CustomFieldDao;
import io.metersphere.dto.IssueTemplateDao; import io.metersphere.dto.IssueTemplateDao;
import io.metersphere.log.utils.ReflexObjectUtil; import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn; import io.metersphere.log.vo.DetailColumn;
@ -476,8 +476,11 @@ public class IssuesService {
IssueTemplateDao template = issueTemplateService.getTemplate(projectId); IssueTemplateDao template = issueTemplateService.getTemplate(projectId);
CustomFieldTemplate request = new CustomFieldTemplate(); CustomFieldTemplate request = new CustomFieldTemplate();
request.setTemplateId(template.getId()); request.setTemplateId(template.getId());
List<CustomFieldTemplateDao> customFields = customFieldTemplateService.list(request); List<CustomFieldDao> customFields = customFieldTemplateService.lisSimple(request);
return getCustomFieldsValuesString(customFields);
}
public String getCustomFieldsValuesString(List<CustomFieldDao> customFields) {
JSONArray fields = new JSONArray(); JSONArray fields = new JSONArray();
customFields.forEach(item -> { customFields.forEach(item -> {
JSONObject field = new JSONObject(true); JSONObject field = new JSONObject(true);

@ -1 +1 @@
Subproject commit cf8337c9a6341d8c9eb7f5c9bef897083b0d2951 Subproject commit a41ba52f5495bc68f84a07643442d2b0e9524786

View File

@ -18,6 +18,7 @@
v-else-if="data.type === 'cascadingSelect'" v-else-if="data.type === 'cascadingSelect'"
expand-trigger="hover" expand-trigger="hover"
@change="handleChange" @change="handleChange"
:props="{label: 'text'}"
:options="data.options" :options="data.options"
v-model="data[prop]"> v-model="data[prop]">
</el-cascader> </el-cascader>
@ -128,9 +129,6 @@ export default {
memberOptions: [], memberOptions: [],
}; };
}, },
created() {
this.initOption(this.data.options);
},
mounted() { mounted() {
this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => { this.$post('/user/project/member/tester/list', {projectId: getCurrentProjectID()}, response => {
this.memberOptions = response.data; this.memberOptions = response.data;
@ -145,15 +143,6 @@ export default {
this.$set(this.form, this.data.name, this.data[this.prop]); this.$set(this.form, this.data.name, this.data[this.prop]);
} }
}, },
initOption(options) {
if (options) {
options.forEach(i => {
i.label = i.text;
this.$set(i, 'label', i.text);
this.initOption(i.children);
});
}
}
} }
}; };
</script> </script>

View File

@ -179,25 +179,23 @@ export default {
}, },
methods: { methods: {
open(data) { open(data) {
let initAddFuc = this.initEdit; this.result.loading = true;
this.$nextTick(() => {
getCurrentProject((responseData) => { getCurrentProject((responseData) => {
this.currentProject = responseData; this.currentProject = responseData;
if (hasLicense() && this.currentProject && this.currentProject.thirdPartTemplate && this.currentProject.platform === JIRA) { if (hasLicense() && this.currentProject && this.currentProject.thirdPartTemplate && this.currentProject.platform === JIRA) {
getIssueThirdPartTemplate() getIssueThirdPartTemplate()
.then((template) => { .then((template) => {
this.issueTemplate = template; this.init(template, data);
this.getThirdPartyInfo();
initAddFuc(data);
}); });
} else { } else {
getIssueTemplate() getIssueTemplate()
.then((template) => { .then((template) => {
this.issueTemplate = template; this.init(template, data);
this.getThirdPartyInfo();
initAddFuc(data);
}); });
} }
}); });
});
if(data&&data.id){ if(data&&data.id){
this.$get('/issues/follow/' + data.id, response => { this.$get('/issues/follow/' + data.id, response => {
@ -216,6 +214,12 @@ export default {
currentUser: () => { currentUser: () => {
return getCurrentUser(); return getCurrentUser();
}, },
init(template, data) {
this.issueTemplate = template;
this.getThirdPartyInfo();
this.initEdit(data);
this.result.loading = false;
},
getThirdPartyInfo() { getThirdPartyInfo() {
let platform = this.issueTemplate.platform; let platform = this.issueTemplate.platform;
if (platform === 'Zentao') { if (platform === 'Zentao') {

View File

@ -117,6 +117,7 @@ export function buildCustomFields(data, param, template) {
hasField = true; hasField = true;
customFields[index].name = item.name; customFields[index].name = item.name;
customFields[index].value = item.defaultValue; customFields[index].value = item.defaultValue;
customFields[index].type = item.type;
break; break;
} }
} }