|
|
@@ -1,6 +1,7 @@
|
|
|
package cn.tr.module.smart.common.service.impl;
|
|
|
|
|
|
import cn.tr.core.exception.TRExcCode;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
@@ -72,6 +73,7 @@ public class BizQuestionServiceImpl implements IBizQuestionService {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean insertBizQuestion(BizQuestionDTO source){
|
|
|
+ validate(source);
|
|
|
return baseRepository.insert(BizQuestionMapper.INSTANCE.convertPO(source))!=0;
|
|
|
};
|
|
|
|
|
|
@@ -89,4 +91,16 @@ public class BizQuestionServiceImpl implements IBizQuestionService {
|
|
|
}
|
|
|
return baseRepository.deleteBatchIds(ids);
|
|
|
};
|
|
|
+
|
|
|
+ private void validate(BizQuestionDTO source){
|
|
|
+ BizQuestionPO one = baseRepository.selectOne(new LambdaQueryWrapper<BizQuestionPO>()
|
|
|
+ .ne(StringUtils.isNotBlank(source.getId()),BizQuestionPO::getId, source.getId())
|
|
|
+ .eq(BizQuestionPO::getGroupId, source.getGroupId())
|
|
|
+ .nested(i->i.eq(BizQuestionPO::getFieldName, source.getFieldName())
|
|
|
+ ).last("limit 1"));
|
|
|
+ if(one!=null){
|
|
|
+ throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"该字段名称已存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|