|
@@ -64,8 +64,8 @@ public class SubjectServiceImpl implements SubjectService {
|
|
|
|
|
|
if (model.getIsReferences() == 0) {
|
|
|
model.setExecSql(model.getTabCode());
|
|
|
- }else{
|
|
|
- model.setExecSql(model.getExecSql().replaceAll("\\n",""));
|
|
|
+ } else {
|
|
|
+ model.setExecSql(model.getExecSql().replaceAll("\\n", ""));
|
|
|
}
|
|
|
List<SrTag> tagList = tagMapper.selectByExample(null);
|
|
|
|
|
@@ -88,7 +88,7 @@ public class SubjectServiceImpl implements SubjectService {
|
|
|
result = subjectMapper.updateByPrimaryKey(model);
|
|
|
}
|
|
|
//新加标签
|
|
|
- Arrays.stream(model.getTagList()).forEach(tag -> {
|
|
|
+ Arrays.stream(model.getTagList()).filter(tag->!StringUtils.IsNullEmpty(tag)).forEach(tag -> {
|
|
|
SrTag dbTag = tagList.stream().filter(f -> f.getTagName().equals(tag.trim())).findFirst().orElse(null);
|
|
|
if (dbTag == null) {
|
|
|
dbTag = new SrTag();
|
|
@@ -108,15 +108,18 @@ public class SubjectServiceImpl implements SubjectService {
|
|
|
SrSubjectfieldExample.Criteria criteria = example.or();
|
|
|
criteria.andSubIdEqualTo(model.getSubId());
|
|
|
List<SrSubjectfield> dbList = subjectfieldMapper.selectByExample(example);
|
|
|
- List<String> ids = fieldList.stream().map(x -> x.getFieldId()).collect(Collectors.toList());
|
|
|
|
|
|
- //删除字段前先删除关联标签
|
|
|
- SrSubjectfieldtagExample ftExp = new SrSubjectfieldtagExample();
|
|
|
- ftExp.or().andFieldIdIn(dbList.stream().map(x -> x.getFieldId()).collect(Collectors.toList()));
|
|
|
- subjectfieldtagMapper.deleteByExample(ftExp);
|
|
|
+ if (dbList.size() > 0) {
|
|
|
+ List<String> ids = fieldList.stream().map(x -> x.getFieldId()).collect(Collectors.toList());
|
|
|
|
|
|
- criteria.andFieldIdNotIn(ids);
|
|
|
- subjectfieldMapper.deleteByExample(example);
|
|
|
+ //删除字段前先删除关联标签
|
|
|
+ SrSubjectfieldtagExample ftExp = new SrSubjectfieldtagExample();
|
|
|
+ ftExp.or().andFieldIdIn(dbList.stream().map(x -> x.getFieldId()).collect(Collectors.toList()));
|
|
|
+ subjectfieldtagMapper.deleteByExample(ftExp);
|
|
|
+
|
|
|
+ criteria.andFieldIdNotIn(ids);
|
|
|
+ subjectfieldMapper.deleteByExample(example);
|
|
|
+ }
|
|
|
|
|
|
fieldList.stream().forEach(x -> {
|
|
|
long count = dbList.stream().filter(f -> f.getFieldId().equals(x.getFieldId())).count();
|
|
@@ -135,7 +138,7 @@ public class SubjectServiceImpl implements SubjectService {
|
|
|
subjectfieldMapper.insertSelective(x);
|
|
|
}
|
|
|
//新加标签
|
|
|
- Arrays.stream(x.getTagList()).forEach(tag -> {
|
|
|
+ Arrays.stream(x.getTagList()).filter(tag->!StringUtils.IsNullEmpty(tag)).forEach(tag -> {
|
|
|
SrTag dbTag = tagList.stream().filter(f -> f.getTagName().equals(tag.trim())).findFirst().orElse(null);
|
|
|
if (dbTag == null) {
|
|
|
dbTag = new SrTag();
|
|
@@ -166,7 +169,18 @@ public class SubjectServiceImpl implements SubjectService {
|
|
|
SrSubjectfieldExample example = new SrSubjectfieldExample();
|
|
|
SrSubjectfieldExample.Criteria criteria = example.or();
|
|
|
criteria.andSubIdIn(idList);
|
|
|
- subjectfieldMapper.selectByExample(example);
|
|
|
+ List<String> fieldList = subjectfieldMapper.selectByExample(example).stream().map(SrSubjectfield::getFieldId).collect(Collectors.toList());
|
|
|
+ if (fieldList.size() > 0) {
|
|
|
+ SrSubjectfieldtagExample tagExp = new SrSubjectfieldtagExample();
|
|
|
+ tagExp.or().andFieldIdIn(fieldList);
|
|
|
+ subjectfieldtagMapper.deleteByExample(tagExp);
|
|
|
+ }
|
|
|
+ subjectfieldMapper.deleteByExample(example);
|
|
|
+
|
|
|
+ //删除关联标签
|
|
|
+ SrSubjecttagExample stExp = new SrSubjecttagExample();
|
|
|
+ stExp.or().andSubIdIn(idList);
|
|
|
+ subjecttagMapper.deleteByExample(stExp);
|
|
|
|
|
|
SrSubjectExample subExp = new SrSubjectExample();
|
|
|
subExp.or().andSubIdIn(idList);
|