提交 2c06af33 作者: 925993793@qq.com

【定制专题】增加批量绑定信息源接口

上级 862b7cc1
......@@ -35,6 +35,7 @@ import com.zzsn.event.xxljob.entity.XxlJobInfo;
import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.Jsoup;
import org.springframework.beans.BeanUtils;
......@@ -375,6 +376,48 @@ public class ExternalController {
}
/**
* 批量绑定信息源
*
* @param params 参数
* @author lkg
* @date 2025/9/10
*/
@PostMapping("/batchBindSource")
public Result<?> batchBindSource(@RequestBody Map<String, Object> params) {
Object subjectId = params.get("subjectId");
if (ObjectUtils.isEmpty(subjectId)) {
return Result.FAIL("专题id不能为空");
}
Object bindList = params.get("bindList");
if (ObjectUtils.isEmpty(bindList)) {
return Result.FAIL("请添加信息源");
}
List<ExternalSubjectInfoSourceMap> saveList = new ArrayList<>();
List<ExternalSubjectInfoSourceMap> mapList = JSON.parseArray(JSON.toJSONString(bindList), ExternalSubjectInfoSourceMap.class);
LambdaQueryWrapper<ExternalSubjectInfoSourceMap> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(ExternalSubjectInfoSourceMap::getSubjectId, subjectId.toString());
List<ExternalSubjectInfoSourceMap> existedList = externalSubjectInfoSourceMapService.list(queryWrapper);
if (CollectionUtils.isEmpty(existedList)) {
saveList.addAll(mapList);
} else {
for (ExternalSubjectInfoSourceMap externalSubjectInfoSourceMap : mapList) {
Optional<ExternalSubjectInfoSourceMap> any = existedList.stream()
.filter(map -> map.getInfoSourceUrl().equals(externalSubjectInfoSourceMap.getInfoSourceUrl()))
.findAny();
if (!any.isPresent()) {
saveList.add(externalSubjectInfoSourceMap);
}
}
}
for (ExternalSubjectInfoSourceMap externalSubjectInfoSourceMap : saveList) {
externalSubjectInfoSourceMap.setSubjectId(subjectId.toString());
externalSubjectInfoSourceMap.setType(1);
}
externalSubjectInfoSourceMapService.saveBatch(saveList);
return Result.OK();
}
/**
* 解绑信息源
*
* @param ids id集合
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论