1、绑定知识点

beetlsql3-dev
wgf 2 years ago
parent 363218d681
commit e5a77f19b8

@ -137,29 +137,51 @@ public class TeacherOpenCourseKnowledgePointRelationService extends CoreBaseServ
String teacherOpenCourseKnowledgePointIdPlural = Objects.isNull(pointRelationQuery.getTeacherOpenCourseKnowledgePointIdPlural()) ? "" : pointRelationQuery.getTeacherOpenCourseKnowledgePointIdPlural();
String[] knowledgePointIdPlural = teacherOpenCourseKnowledgePointIdPlural.split(",");
//先解绑
List<TeacherOpenCourseKnowledgePointRelation> pointRelationList = sqlManager.lambdaQuery(TeacherOpenCourseKnowledgePointRelation.class)
.andEq(TeacherOpenCourseKnowledgePointRelation::getBussinessId, pointRelationQuery.getBussinessId())
.andEq(TeacherOpenCourseKnowledgePointRelation::getDelFlag, 0)
.andEq(TeacherOpenCourseKnowledgePointRelation::getOrgId, pointRelationQuery.getOrgId())
.andEq(TeacherOpenCourseKnowledgePointRelation::getUserId, pointRelationQuery.getUserId())
.select();
pointRelationList.stream().filter(item -> {
boolean b = true;
for (String s : knowledgePointIdPlural) {
if (Objects.equals(s, item.getTeacherOpenCourseKnowledgePointId().toString())) {
b = false;
break;
}
}
return b;
}).collect(Collectors.toList()).forEach(item ->{
sqlManager.lambdaQuery(TeacherOpenCourseKnowledgePointRelation.class)
.andEq(TeacherOpenCourseKnowledgePointRelation::getTeacherOpenCourseKnowledgeRelationId,item.getTeacherOpenCourseKnowledgeRelationId())
.delete();
});
//绑定、修改
for (String s : knowledgePointIdPlural) {
TeacherOpenCourseKnowledgePointRelation single = sqlManager.lambdaQuery(TeacherOpenCourseKnowledgePointRelation.class)
.andEq(TeacherOpenCourseKnowledgePointRelation::getTeacherOpenCourseKnowledgePointId, Long.valueOf(s))
.andEq(TeacherOpenCourseKnowledgePointRelation::getBussinessId, pointRelationQuery.getBussinessId())
.andEq(TeacherOpenCourseKnowledgePointRelation::getDelFlag, 0)
.andEq(TeacherOpenCourseKnowledgePointRelation::getOrgId, pointRelationQuery.getOrgId())
.andEq(TeacherOpenCourseKnowledgePointRelation::getUserId, pointRelationQuery.getUserId())
.single();
TeacherOpenCourseKnowledgePointRelation relation = new TeacherOpenCourseKnowledgePointRelation();
relation.setBussinessId(pointRelationQuery.getBussinessId());
relation.setBussinessType(pointRelationQuery.getBussinessType());
relation.setCreateTime(new Date());
if (Objects.isNull(single)) {
relation.setTeacherOpenCourseKnowledgePointId(Long.parseLong(s));
relation.setBussinessId(pointRelationQuery.getBussinessId());
relation.setBussinessType(pointRelationQuery.getBussinessType());
relation.setCreateTime(new Date());
relation.setOrgId(pointRelationQuery.getOrgId());
relation.setUserId(pointRelationQuery.getUserId());
relation.setDelFlag(0);
sqlManager.lambdaQuery(TeacherOpenCourseKnowledgePointRelation.class).insert(relation);
} else {
relation.setDelFlag(1);
sqlManager.lambdaQuery(TeacherOpenCourseKnowledgePointRelation.class)
.andEq(TeacherOpenCourseKnowledgePointRelation::getTeacherOpenCourseKnowledgeRelationId, single.getTeacherOpenCourseKnowledgeRelationId())
.updateSelective(relation);

Loading…
Cancel
Save