|
@@ -1,15 +1,20 @@
|
|
package com.xjrsoft.module.student.service.impl;
|
|
package com.xjrsoft.module.student.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
|
+import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
|
+import com.xjrsoft.module.base.service.IBaseClassService;
|
|
|
|
+import com.xjrsoft.module.student.dto.AddBasePunishmentStudentRelationDto;
|
|
|
|
+import com.xjrsoft.module.student.dto.AddBaseStudentPunishmentInfoDto;
|
|
import com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoMobilePageDto;
|
|
import com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoMobilePageDto;
|
|
import com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoPageDto;
|
|
import com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoPageDto;
|
|
-import com.xjrsoft.module.student.entity.BasePunishmentStudentRelation;
|
|
|
|
|
|
+import com.xjrsoft.module.student.entity.BasePunishmentStudentHandle;
|
|
import com.xjrsoft.module.student.entity.BaseStudentPunishmentInfo;
|
|
import com.xjrsoft.module.student.entity.BaseStudentPunishmentInfo;
|
|
import com.xjrsoft.module.student.mapper.BasePunishmentStudentRelationMapper;
|
|
import com.xjrsoft.module.student.mapper.BasePunishmentStudentRelationMapper;
|
|
import com.xjrsoft.module.student.mapper.BaseStudentPunishmentInfoMapper;
|
|
import com.xjrsoft.module.student.mapper.BaseStudentPunishmentInfoMapper;
|
|
@@ -25,8 +30,9 @@ import lombok.AllArgsConstructor;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Objects;
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -40,11 +46,12 @@ import java.util.stream.Collectors;
|
|
public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<BaseStudentPunishmentInfoMapper, BaseStudentPunishmentInfo> implements IBaseStudentPunishmentInfoService {
|
|
public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<BaseStudentPunishmentInfoMapper, BaseStudentPunishmentInfo> implements IBaseStudentPunishmentInfoService {
|
|
private final BaseStudentPunishmentInfoMapper baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper;
|
|
private final BaseStudentPunishmentInfoMapper baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper;
|
|
|
|
|
|
- private final BasePunishmentStudentRelationMapper baseStudentPunishmentInfoBasePunishmentStudentRelationMapper;
|
|
|
|
|
|
+ private final BasePunishmentStudentRelationMapper relationMapper;
|
|
|
|
|
|
IBasePunishStudentRelationService basePunishStudentRelationService;
|
|
IBasePunishStudentRelationService basePunishStudentRelationService;
|
|
|
|
|
|
private final IFileService fileService;
|
|
private final IFileService fileService;
|
|
|
|
+ private final IBaseClassService classService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -85,9 +92,9 @@ public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<Bas
|
|
BaseStudentPunishmentInfoDetailVo baseStudentPunishmentInfoDetailVo = baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.getInfo(id);
|
|
BaseStudentPunishmentInfoDetailVo baseStudentPunishmentInfoDetailVo = baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.getInfo(id);
|
|
|
|
|
|
//添加学生列表集合
|
|
//添加学生列表集合
|
|
- QueryWrapper<BasePunishmentStudentRelation> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
+ QueryWrapper<BasePunishmentStudentHandle> queryWrapper = new QueryWrapper<>();
|
|
queryWrapper.eq("punishment_info_id", id);
|
|
queryWrapper.eq("punishment_info_id", id);
|
|
- List<BasePunishmentStudentRelation> studentList = basePunishStudentRelationService.list(queryWrapper);
|
|
|
|
|
|
+ List<BasePunishmentStudentHandle> studentList = basePunishStudentRelationService.list(queryWrapper);
|
|
|
|
|
|
baseStudentPunishmentInfoDetailVo.setStudentList(studentList);
|
|
baseStudentPunishmentInfoDetailVo.setStudentList(studentList);
|
|
|
|
|
|
@@ -112,11 +119,6 @@ public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<Bas
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public Boolean add(BaseStudentPunishmentInfo baseStudentPunishmentInfo) {
|
|
public Boolean add(BaseStudentPunishmentInfo baseStudentPunishmentInfo) {
|
|
baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.insert(baseStudentPunishmentInfo);
|
|
baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.insert(baseStudentPunishmentInfo);
|
|
- for (BasePunishmentStudentRelation basePunishmentStudentRelation : baseStudentPunishmentInfo.getBasePunishmentStudentRelationList()) {
|
|
|
|
- basePunishmentStudentRelation.setPunishmentInfoId(baseStudentPunishmentInfo.getId());
|
|
|
|
- baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.insert(basePunishmentStudentRelation);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -127,29 +129,8 @@ public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<Bas
|
|
//********************************* BasePunishmentStudentRelation 增删改 开始 *******************************************/
|
|
//********************************* BasePunishmentStudentRelation 增删改 开始 *******************************************/
|
|
{
|
|
{
|
|
// 查出所有子级的id
|
|
// 查出所有子级的id
|
|
- List<BasePunishmentStudentRelation> basePunishmentStudentRelationList = baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.selectList(Wrappers.lambdaQuery(BasePunishmentStudentRelation.class).eq(BasePunishmentStudentRelation::getPunishmentInfoId, baseStudentPunishmentInfo.getId()).select(BasePunishmentStudentRelation::getId));
|
|
|
|
- List<Long> basePunishmentStudentRelationIds = basePunishmentStudentRelationList.stream().map(BasePunishmentStudentRelation::getId).collect(Collectors.toList());
|
|
|
|
- //原有子表单 没有被删除的主键
|
|
|
|
- List<Long> basePunishmentStudentRelationOldIds = baseStudentPunishmentInfo.getBasePunishmentStudentRelationList().stream().map(BasePunishmentStudentRelation::getId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
- //找到需要删除的id
|
|
|
|
- List<Long> basePunishmentStudentRelationRemoveIds = basePunishmentStudentRelationIds.stream().filter(item -> !basePunishmentStudentRelationOldIds.contains(item)).collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- for (BasePunishmentStudentRelation basePunishmentStudentRelation : baseStudentPunishmentInfo.getBasePunishmentStudentRelationList()) {
|
|
|
|
- //如果不等于空则修改
|
|
|
|
- if (basePunishmentStudentRelation.getId() != null) {
|
|
|
|
- baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.updateById(basePunishmentStudentRelation);
|
|
|
|
- }
|
|
|
|
- //如果等于空 则新增
|
|
|
|
- else {
|
|
|
|
- //已经不存在的id 删除
|
|
|
|
- basePunishmentStudentRelation.setPunishmentInfoId(baseStudentPunishmentInfo.getId());
|
|
|
|
- baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.insert(basePunishmentStudentRelation);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //已经不存在的id 删除
|
|
|
|
- if(basePunishmentStudentRelationRemoveIds.size() > 0){
|
|
|
|
- baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.deleteBatchIds(basePunishmentStudentRelationRemoveIds);
|
|
|
|
- }
|
|
|
|
|
|
+ List<BasePunishmentStudentHandle> basePunishmentStudentHandleList = relationMapper.selectList(Wrappers.lambdaQuery(BasePunishmentStudentHandle.class).eq(BasePunishmentStudentHandle::getPunishmentInfoId, baseStudentPunishmentInfo.getId()).select(BasePunishmentStudentHandle::getId));
|
|
|
|
+ List<Long> basePunishmentStudentRelationIds = basePunishmentStudentHandleList.stream().map(BasePunishmentStudentHandle::getId).collect(Collectors.toList());
|
|
}
|
|
}
|
|
//********************************* BasePunishmentStudentRelation 增删改 结束 *******************************************/
|
|
//********************************* BasePunishmentStudentRelation 增删改 结束 *******************************************/
|
|
|
|
|
|
@@ -160,7 +141,7 @@ public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<Bas
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public Boolean delete(List<Long> ids) {
|
|
public Boolean delete(List<Long> ids) {
|
|
baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.deleteBatchIds(ids);
|
|
baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.deleteBatchIds(ids);
|
|
- baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.delete(Wrappers.lambdaQuery(BasePunishmentStudentRelation.class).in(BasePunishmentStudentRelation::getPunishmentInfoId, ids));
|
|
|
|
|
|
+ relationMapper.delete(Wrappers.lambdaQuery(BasePunishmentStudentHandle.class).in(BasePunishmentStudentHandle::getPunishmentInfoId, ids));
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -171,4 +152,22 @@ public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<Bas
|
|
Page<BaseStudentPunishmentInfoMobilePageVo> result = baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.getMobilePage(page, dto);
|
|
Page<BaseStudentPunishmentInfoMobilePageVo> result = baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.getMobilePage(page, dto);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean add(AddBaseStudentPunishmentInfoDto dto) {
|
|
|
|
+ List<BaseStudentPunishmentInfo> dataList = new ArrayList<>();
|
|
|
|
+ List<AddBasePunishmentStudentRelationDto> relationList = dto.getBasePunishmentStudentRelationList();
|
|
|
|
+ for (AddBasePunishmentStudentRelationDto el : relationList) {
|
|
|
|
+ BaseStudentPunishmentInfo punishmentInfo = BeanUtil.toBean(dto, BaseStudentPunishmentInfo.class);
|
|
|
|
+ punishmentInfo.setCreateDate(new Date());
|
|
|
|
+ BeanUtil.copyProperties(el, punishmentInfo);
|
|
|
|
+ if(el.getClassId() != null){
|
|
|
|
+ BaseClass aClass = classService.getById(el.getClassId());
|
|
|
|
+ punishmentInfo.setTeacherId(aClass.getTeacherId());
|
|
|
|
+ }
|
|
|
|
+ dataList.add(punishmentInfo);
|
|
|
|
+ }
|
|
|
|
+ this.saveBatch(dataList);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|