fix(测试跟踪): 模板保存后关联的自定义字段展示顺序会变
--bug=1016758 --user=陈建星 【项目设置】模版管理-缺陷模版,编辑模版,不做任何操作,点击保存,字段顺序会变+【github #17895】 https://www.tapd.cn/55049933/s/1243736
This commit is contained in:
parent
5b37d04efa
commit
dfd43d9dd9
|
@ -17,4 +17,6 @@ public interface ExtCustomFieldTemplateMapper {
|
|||
List<String> getSystemCustomField(@Param("templateId") String templateId, @Param("fieldName") String fieldName);
|
||||
|
||||
void batchInsert(@Param("customFieldTemplates") List<CustomFieldTemplate> customFieldTemplates);
|
||||
|
||||
Long getLastOrder(@Param("templateId") String templateId, @Param("baseOrder") Long baseOrder);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<if test="request.templateId != null">
|
||||
where cft.template_id = #{request.templateId}
|
||||
</if>
|
||||
order by `order` asc
|
||||
</select>
|
||||
<select id="lisSimple" resultType="io.metersphere.dto.CustomFieldDao">
|
||||
select
|
||||
|
@ -38,6 +39,13 @@
|
|||
where cft.template_id = #{templateId}
|
||||
and cf.name = #{fieldName}
|
||||
</select>
|
||||
<select id="getLastOrder" resultType="java.lang.Long">
|
||||
select `order` from custom_field_template where template_id = #{templateId}
|
||||
<if test="baseOrder != null">
|
||||
and `order` > #{baseOrder}
|
||||
</if>
|
||||
order by `order` desc limit 1;
|
||||
</select>
|
||||
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package io.metersphere.service;
|
||||
|
||||
|
||||
import io.metersphere.base.domain.CustomField;
|
||||
import io.metersphere.base.domain.CustomFieldTemplate;
|
||||
import io.metersphere.base.domain.CustomFieldTemplateExample;
|
||||
import io.metersphere.base.mapper.CustomFieldMapper;
|
||||
import io.metersphere.base.mapper.CustomFieldTemplateMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtCustomFieldTemplateMapper;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.dto.CustomFieldDao;
|
||||
import io.metersphere.dto.CustomFieldTemplateDao;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -44,6 +44,7 @@ public class CustomFieldTemplateService {
|
|||
public List<CustomFieldTemplate> getCustomFields(String templateId) {
|
||||
CustomFieldTemplateExample example = new CustomFieldTemplateExample();
|
||||
example.createCriteria().andTemplateIdEqualTo(templateId);
|
||||
example.setOrderByClause("`order` asc");
|
||||
return customFieldTemplateMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
|
@ -110,15 +111,18 @@ public class CustomFieldTemplateService {
|
|||
CustomFieldTemplateMapper customFieldTemplateMapper =
|
||||
sqlSession.getMapper(CustomFieldTemplateMapper.class);
|
||||
if (CollectionUtils.isNotEmpty(customFields)) {
|
||||
customFields.forEach(item -> {
|
||||
Long nextOrder = ServiceUtils.getNextOrder(templateId, extCustomFieldTemplateMapper::getLastOrder);
|
||||
for (CustomFieldTemplate item : customFields) {
|
||||
item.setId(UUID.randomUUID().toString());
|
||||
item.setTemplateId(templateId);
|
||||
item.setScene(scene);
|
||||
if (item.getRequired() == null) {
|
||||
item.setRequired(false);
|
||||
}
|
||||
nextOrder += ServiceUtils.ORDER_STEP;
|
||||
item.setOrder((int) nextOrder.longValue());
|
||||
customFieldTemplateMapper.insert(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
if (sqlSession != null && sqlSessionFactory != null) {
|
||||
|
|
Loading…
Reference in New Issue