|
|
@@ -0,0 +1,73 @@
|
|
|
+package com.xjrsoft.module.banding.service.impl;
|
|
|
+
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.xjrsoft.module.banding.dto.ChangeClassDto;
|
|
|
+import com.xjrsoft.module.banding.entity.BandingTaskClassStudent;
|
|
|
+import com.xjrsoft.module.banding.mapper.BandingTaskClassStudentMapper;
|
|
|
+import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+* @title: 新生分班任务
|
|
|
+* @Author dzx
|
|
|
+* @Date: 2024-07-01
|
|
|
+* @Version 1.0
|
|
|
+*/
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<BandingTaskClassStudentMapper, BandingTaskClassStudent> implements IBandingTaskClassStudentService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean add(BandingTaskClassStudent bandingTaskClass) {
|
|
|
+ bandingTaskClass.setCreateDate(new Date());
|
|
|
+ this.baseMapper.insert(bandingTaskClass);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean update(BandingTaskClassStudent bandingTaskClass) {
|
|
|
+ bandingTaskClass.setModifyDate(new Date());
|
|
|
+ this.baseMapper.updateById(bandingTaskClass);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean delete(List<Long> ids) {
|
|
|
+ this.baseMapper.deleteBatchIds(ids);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean changeClass(ChangeClassDto dto) {
|
|
|
+ this.baseMapper.delete(
|
|
|
+ new QueryWrapper<BandingTaskClassStudent>().lambda()
|
|
|
+ .in(BandingTaskClassStudent::getNewStudentId, dto.getNewStudentIds())
|
|
|
+ );
|
|
|
+ List<BandingTaskClassStudent> dataList = new ArrayList<>();
|
|
|
+ long createUserId = StpUtil.getLoginIdAsLong();
|
|
|
+ for (Long newStudentId : dto.getNewStudentIds()) {
|
|
|
+ dataList.add(
|
|
|
+ new BandingTaskClassStudent(){{
|
|
|
+ setCreateDate(new Date());
|
|
|
+ setNewStudentId(newStudentId);
|
|
|
+ setBandingTaskClassId(dto.getBandingTaskClassId());
|
|
|
+ setCreateUserId(createUserId);
|
|
|
+ }}
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if(!dataList.isEmpty()){
|
|
|
+ this.saveBatch(dataList);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|