|
@@ -44,6 +44,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -103,39 +105,60 @@ public class BandingTaskClassController {
|
|
|
@PostMapping
|
|
|
@ApiOperation(value = "新增新生分班")
|
|
|
@SaCheckPermission("bandingTaskClass:add")
|
|
|
- public RT<Boolean> add(@Valid @RequestBody AddBandingTaskClassDto dto){
|
|
|
- if(dto.getSortCode() != null){
|
|
|
- List<BandingTaskClass> list = bandingTaskClassService.list(
|
|
|
- new QueryWrapper<BandingTaskClass>().lambda()
|
|
|
- .eq(BandingTaskClass::getSortCode, dto.getSortCode())
|
|
|
- .eq(BandingTaskClass::getBandingTaskId, dto.getBandingTaskId())
|
|
|
- );
|
|
|
- if(!list.isEmpty()){
|
|
|
- return RT.error("班级编号重复");
|
|
|
+ public RT<Boolean> add(@Valid @RequestBody List<AddBandingTaskClassDto> dtoList){
|
|
|
+ List<BandingTaskClass> dataList = new ArrayList<>();
|
|
|
+ List<String> errorList = new ArrayList<>();
|
|
|
+ for (AddBandingTaskClassDto dto : dtoList) {
|
|
|
+ if(dto.getSortCode() != null){
|
|
|
+ List<BandingTaskClass> list = bandingTaskClassService.list(
|
|
|
+ new QueryWrapper<BandingTaskClass>().lambda()
|
|
|
+ .eq(BandingTaskClass::getSortCode, dto.getSortCode())
|
|
|
+ .eq(BandingTaskClass::getBandingTaskId, dto.getBandingTaskId())
|
|
|
+ );
|
|
|
+ if(!list.isEmpty()){
|
|
|
+ errorList.add(dto.getName());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ BandingTaskClass bandingTask = BeanUtil.toBean(dto, BandingTaskClass.class);
|
|
|
+ bandingTask.setCreateDate(new Date());
|
|
|
+ }
|
|
|
+ if(!errorList.isEmpty()){
|
|
|
+ return RT.error(errorList.toString().replace("[", "").replace("]", "") + ",分班排序重复");
|
|
|
}
|
|
|
|
|
|
- BandingTaskClass bandingTask = BeanUtil.toBean(dto, BandingTaskClass.class);
|
|
|
- boolean isSuccess = bandingTaskClassService.add(bandingTask);
|
|
|
+ boolean isSuccess = bandingTaskClassService.saveBatch(dataList);
|
|
|
return RT.ok(isSuccess);
|
|
|
}
|
|
|
|
|
|
@PutMapping
|
|
|
@ApiOperation(value = "修改新生分班")
|
|
|
@SaCheckPermission("bandingTaskClass:edit")
|
|
|
- public RT<Boolean> update(@Valid @RequestBody UpdateBandingClassDto dto){
|
|
|
- if(dto.getSortCode() != null){
|
|
|
- List<BandingTaskClass> list = bandingTaskClassService.list(
|
|
|
- new QueryWrapper<BandingTaskClass>().lambda()
|
|
|
- .eq(BandingTaskClass::getSortCode, dto.getSortCode())
|
|
|
- .eq(BandingTaskClass::getBandingTaskId, dto.getBandingTaskId())
|
|
|
- );
|
|
|
- if(!list.isEmpty()){
|
|
|
- return RT.error("班级编号重复");
|
|
|
+ public RT<Boolean> update(@Valid @RequestBody List<UpdateBandingClassDto> dtoList){
|
|
|
+ List<BandingTaskClass> dataList = new ArrayList<>();
|
|
|
+ List<String> errorList = new ArrayList<>();
|
|
|
+ for (UpdateBandingClassDto dto : dtoList) {
|
|
|
+ if(dto.getSortCode() != null){
|
|
|
+ List<BandingTaskClass> list = bandingTaskClassService.list(
|
|
|
+ new QueryWrapper<BandingTaskClass>().lambda()
|
|
|
+ .eq(BandingTaskClass::getSortCode, dto.getSortCode())
|
|
|
+ .eq(BandingTaskClass::getBandingTaskId, dto.getBandingTaskId())
|
|
|
+ .ne(BandingTaskClass::getId, dto.getId())
|
|
|
+ );
|
|
|
+ if(!list.isEmpty()){
|
|
|
+ errorList.add(dto.getName());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ BandingTaskClass bandingTask = BeanUtil.toBean(dto, BandingTaskClass.class);
|
|
|
+ bandingTask.setModifyDate(new Date());
|
|
|
+ }
|
|
|
+ if(!errorList.isEmpty()){
|
|
|
+ return RT.error(errorList.toString().replace("[", "").replace("]", "") + ",分班排序重复");
|
|
|
}
|
|
|
- BandingTaskClass bandingTask = BeanUtil.toBean(dto, BandingTaskClass.class);
|
|
|
- return RT.ok(bandingTaskClassService.update(bandingTask));
|
|
|
+
|
|
|
+ boolean isSuccess = bandingTaskClassService.updateBatchById(dataList);
|
|
|
+ return RT.ok(isSuccess);
|
|
|
}
|
|
|
|
|
|
@DeleteMapping
|