|
@@ -44,9 +44,6 @@ import java.util.stream.Collectors;
|
|
@Service
|
|
@Service
|
|
public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
|
|
|
|
- /* @Autowired
|
|
|
|
- private GroupLogicImpl groupLogic;*/
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private GroupService groupService;
|
|
private GroupService groupService;
|
|
|
|
|
|
@@ -215,7 +212,7 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
if (group.getOwnerId() == userDto.getId()) {
|
|
if (group.getOwnerId() == userDto.getId()) {
|
|
throw new IllegalOperationException("Cannot join Group YOU OWN!");
|
|
throw new IllegalOperationException("Cannot join Group YOU OWN!");
|
|
}
|
|
}
|
|
- if(groupService.getWorkerCount(groupId) == group.getClassSize()){
|
|
|
|
|
|
+ if(groupService.getWorkerCount(groupId) >=group.getClassSize()){
|
|
throw new HttpBadRequestException("班级人数已达上限,请联系管理员");
|
|
throw new HttpBadRequestException("班级人数已达上限,请联系管理员");
|
|
}
|
|
}
|
|
UserVO uv = Converter.convert(UserVO.class, groupService.addUserIntoGroup(userDto.getId(), groupId));
|
|
UserVO uv = Converter.convert(UserVO.class, groupService.addUserIntoGroup(userDto.getId(), groupId));
|
|
@@ -352,11 +349,15 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
params.setHeadRows(1);
|
|
params.setHeadRows(1);
|
|
List<User> result = ExcelImportUtil.importExcel(file.getInputStream(),
|
|
List<User> result = ExcelImportUtil.importExcel(file.getInputStream(),
|
|
User.class, params);
|
|
User.class, params);
|
|
- List<UserVO> addlist=new ArrayList<>();
|
|
|
|
|
|
+ Group group = groupService.getGroup(groupId);
|
|
|
|
+ if(result.size()>(group.getClassSize()-groupService.getWorkerCount(groupId))){
|
|
|
|
+ throw new HttpBadRequestException("批量导入人数超出班级上限");
|
|
|
|
+ }
|
|
|
|
+ List<UserVO> batchAddList=new ArrayList<>();
|
|
for(User user:result){
|
|
for(User user:result){
|
|
UserVO userVO = this.addUserIntoGroup(user.getEmail(), groupId);
|
|
UserVO userVO = this.addUserIntoGroup(user.getEmail(), groupId);
|
|
- addlist.add(userVO);
|
|
|
|
|
|
+ batchAddList.add(userVO);
|
|
}
|
|
}
|
|
- return addlist;
|
|
|
|
|
|
+ return batchAddList;
|
|
}
|
|
}
|
|
}
|
|
}
|