package cn.gistack.sm.sjztmd.service.impl;
|
|
import cn.gistack.sm.sjztmd.entity.RelResLabel;
|
import cn.gistack.sm.sjztmd.mapper.RelResLabelMapper;
|
import cn.gistack.sm.sjztmd.service.IRelResLabelService;
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import org.springblade.core.tool.utils.StringUtil;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.List;
|
|
@Service
|
@DS("zt")
|
public class RelResLabelServiceImpl extends ServiceImpl<RelResLabelMapper, RelResLabel> implements IRelResLabelService {
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public Boolean updateEntity(String guid, String label) {
|
|
//删除表中原来的标签
|
QueryWrapper queryWrapper = new QueryWrapper();
|
queryWrapper.eq("\"guid\"",guid);
|
|
boolean remove = remove(queryWrapper);
|
//添加新标签数据
|
if (StringUtil.isNotBlank(label)){
|
List<RelResLabel> list = new ArrayList<>();
|
|
List<String> labelList = Arrays.asList(label.split(","));
|
|
labelList.forEach(e->{
|
RelResLabel relResLabel = new RelResLabel();
|
|
relResLabel.setGuid(guid);
|
relResLabel.setLabel(e);
|
|
list.add(relResLabel);
|
});
|
|
boolean saveBatch = saveBatch(list);
|
return saveBatch;
|
}
|
return remove;
|
}
|
}
|