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 teacherOpenCourseKnowledgePointIdPlural = Objects.isNull(pointRelationQuery.getTeacherOpenCourseKnowledgePointIdPlural()) ? "" : pointRelationQuery.getTeacherOpenCourseKnowledgePointIdPlural();
String[] knowledgePointIdPlural = teacherOpenCourseKnowledgePointIdPlural.split(","); 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) { for (String s : knowledgePointIdPlural) {
TeacherOpenCourseKnowledgePointRelation single = sqlManager.lambdaQuery(TeacherOpenCourseKnowledgePointRelation.class) TeacherOpenCourseKnowledgePointRelation single = sqlManager.lambdaQuery(TeacherOpenCourseKnowledgePointRelation.class)
.andEq(TeacherOpenCourseKnowledgePointRelation::getTeacherOpenCourseKnowledgePointId, Long.valueOf(s)) .andEq(TeacherOpenCourseKnowledgePointRelation::getTeacherOpenCourseKnowledgePointId, Long.valueOf(s))
.andEq(TeacherOpenCourseKnowledgePointRelation::getBussinessId, pointRelationQuery.getBussinessId())
.andEq(TeacherOpenCourseKnowledgePointRelation::getDelFlag, 0) .andEq(TeacherOpenCourseKnowledgePointRelation::getDelFlag, 0)
.andEq(TeacherOpenCourseKnowledgePointRelation::getOrgId, pointRelationQuery.getOrgId()) .andEq(TeacherOpenCourseKnowledgePointRelation::getOrgId, pointRelationQuery.getOrgId())
.andEq(TeacherOpenCourseKnowledgePointRelation::getUserId, pointRelationQuery.getUserId()) .andEq(TeacherOpenCourseKnowledgePointRelation::getUserId, pointRelationQuery.getUserId())
.single(); .single();
TeacherOpenCourseKnowledgePointRelation relation = new TeacherOpenCourseKnowledgePointRelation(); TeacherOpenCourseKnowledgePointRelation relation = new TeacherOpenCourseKnowledgePointRelation();
relation.setBussinessId(pointRelationQuery.getBussinessId());
relation.setBussinessType(pointRelationQuery.getBussinessType());
relation.setCreateTime(new Date());
if (Objects.isNull(single)) { if (Objects.isNull(single)) {
relation.setTeacherOpenCourseKnowledgePointId(Long.parseLong(s)); relation.setTeacherOpenCourseKnowledgePointId(Long.parseLong(s));
relation.setBussinessId(pointRelationQuery.getBussinessId());
relation.setBussinessType(pointRelationQuery.getBussinessType());
relation.setCreateTime(new Date());
relation.setOrgId(pointRelationQuery.getOrgId()); relation.setOrgId(pointRelationQuery.getOrgId());
relation.setUserId(pointRelationQuery.getUserId()); relation.setUserId(pointRelationQuery.getUserId());
relation.setDelFlag(0);
sqlManager.lambdaQuery(TeacherOpenCourseKnowledgePointRelation.class).insert(relation); sqlManager.lambdaQuery(TeacherOpenCourseKnowledgePointRelation.class).insert(relation);
} else { } else {
relation.setDelFlag(1);
sqlManager.lambdaQuery(TeacherOpenCourseKnowledgePointRelation.class) sqlManager.lambdaQuery(TeacherOpenCourseKnowledgePointRelation.class)
.andEq(TeacherOpenCourseKnowledgePointRelation::getTeacherOpenCourseKnowledgeRelationId, single.getTeacherOpenCourseKnowledgeRelationId()) .andEq(TeacherOpenCourseKnowledgePointRelation::getTeacherOpenCourseKnowledgeRelationId, single.getTeacherOpenCourseKnowledgeRelationId())
.updateSelective(relation); .updateSelective(relation);

Loading…
Cancel
Save