|
@@ -94,11 +94,11 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Page<GroupVO> getPageableGroups(long ownerId, Pageable pageable) {
|
|
public Page<GroupVO> getPageableGroups(long ownerId, Pageable pageable) {
|
|
- Page<Group> groups = groupService.getPageableGroupsByOwnerId(ownerId,pageable);
|
|
|
|
- Page<GroupVO> groupVOS = groups.map(new org.springframework.core.convert.converter.Converter<Group, GroupVO>(){
|
|
|
|
|
|
+ Page<Group> groups = groupService.getPageableGroupsByOwnerId(ownerId, pageable);
|
|
|
|
+ Page<GroupVO> groupVOS = groups.map(new org.springframework.core.convert.converter.Converter<Group, GroupVO>() {
|
|
@Override
|
|
@Override
|
|
public GroupVO convert(Group group) {
|
|
public GroupVO convert(Group group) {
|
|
- GroupVO groupVO = Converter.convert(GroupVO.class,group);
|
|
|
|
|
|
+ GroupVO groupVO = Converter.convert(GroupVO.class, group);
|
|
groupVO.setWorkerCount(groupService.getWorkerCount(group.getId()));
|
|
groupVO.setWorkerCount(groupService.getWorkerCount(group.getId()));
|
|
return groupVO;
|
|
return groupVO;
|
|
}
|
|
}
|
|
@@ -120,10 +120,10 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<GroupVO> getUserGroups(long participantId) {
|
|
public List<GroupVO> getUserGroups(long participantId) {
|
|
- List<Group> groupList=groupService.getGroupsByParticipantId(participantId);
|
|
|
|
- List<GroupVO> groupVOList=new ArrayList<GroupVO>();
|
|
|
|
|
|
+ List<Group> groupList = groupService.getGroupsByParticipantId(participantId);
|
|
|
|
+ List<GroupVO> groupVOList = new ArrayList<GroupVO>();
|
|
groupList.stream().forEach(group -> {
|
|
groupList.stream().forEach(group -> {
|
|
- if(group.getId()!=0) {
|
|
|
|
|
|
+ if (group.getId() != 0) {
|
|
groupVOList.add(Converter.convert(GroupVO.class, group));
|
|
groupVOList.add(Converter.convert(GroupVO.class, group));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -149,10 +149,10 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
@Override
|
|
@Override
|
|
public GroupVO getGroupDetail(long groupId) {
|
|
public GroupVO getGroupDetail(long groupId) {
|
|
Group group = groupService.getGroup(groupId);
|
|
Group group = groupService.getGroup(groupId);
|
|
- if(group==null){
|
|
|
|
|
|
+ if (group == null) {
|
|
throw new HttpNotFoundException(String.format("Group[id=%s] doesn't exist", groupId));
|
|
throw new HttpNotFoundException(String.format("Group[id=%s] doesn't exist", groupId));
|
|
}
|
|
}
|
|
- GroupVO groupVO = Converter.convert(GroupVO.class,group);
|
|
|
|
|
|
+ GroupVO groupVO = Converter.convert(GroupVO.class, group);
|
|
groupVO.setWorkerCount(groupService.getWorkerCount(groupId));
|
|
groupVO.setWorkerCount(groupService.getWorkerCount(groupId));
|
|
return groupVO;
|
|
return groupVO;
|
|
}
|
|
}
|
|
@@ -174,13 +174,13 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
@Override
|
|
@Override
|
|
public List<UserVO> getManagerWorkersInGroup(long groupId) {
|
|
public List<UserVO> getManagerWorkersInGroup(long groupId) {
|
|
Group group = groupService.getGroup(groupId);
|
|
Group group = groupService.getGroup(groupId);
|
|
- if(group==null){
|
|
|
|
|
|
+ if (group == null) {
|
|
throw new HttpNotFoundException(String.format("Group[id=%s] doesn't exist", groupId));
|
|
throw new HttpNotFoundException(String.format("Group[id=%s] doesn't exist", groupId));
|
|
}
|
|
}
|
|
- List<UserVO> UserVOs =new ArrayList<UserVO>();
|
|
|
|
- List<User> users=groupService.getUserByGroupId(groupId);
|
|
|
|
|
|
+ List<UserVO> UserVOs = new ArrayList<UserVO>();
|
|
|
|
+ List<User> users = groupService.getUserByGroupId(groupId);
|
|
users.stream().forEach(user -> {
|
|
users.stream().forEach(user -> {
|
|
- UserVO uv = Converter.convert(UserVO.class,user);
|
|
|
|
|
|
+ UserVO uv = Converter.convert(UserVO.class, user);
|
|
uv.setPassword("");
|
|
uv.setPassword("");
|
|
UserVOs.add(uv);
|
|
UserVOs.add(uv);
|
|
});
|
|
});
|
|
@@ -189,11 +189,11 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Page<UserVO> getManagerWorkersInGroupPageable(long groupId, String keyword, Pageable pageable) {
|
|
public Page<UserVO> getManagerWorkersInGroupPageable(long groupId, String keyword, Pageable pageable) {
|
|
- Page<User> users = groupService.getUserByGroupId(groupId,keyword,pageable);
|
|
|
|
- Page<UserVO> userVOS = users.map(new org.springframework.core.convert.converter.Converter<User,UserVO>(){
|
|
|
|
|
|
+ Page<UserDTOForMT> users = userService.getUserPageByGroupId(groupId, keyword, pageable);
|
|
|
|
+ Page<UserVO> userVOS = users.map(new org.springframework.core.convert.converter.Converter<UserDTOForMT, UserVO>() {
|
|
@Override
|
|
@Override
|
|
- public UserVO convert(User source) {
|
|
|
|
- return UserVOWrapper.wrap(source);
|
|
|
|
|
|
+ public UserVO convert(UserDTOForMT source) {
|
|
|
|
+ return Converter.convert(UserVO.class, source);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
return userVOS;
|
|
return userVOS;
|
|
@@ -229,26 +229,25 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public GroupVO createGroup(GroupVO groupVO) {
|
|
public GroupVO createGroup(GroupVO groupVO) {
|
|
- String name=groupVO.getName();
|
|
|
|
|
|
+ String name = groupVO.getName();
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute("userId");
|
|
groupVO.setOwnerId(userId);
|
|
groupVO.setOwnerId(userId);
|
|
- for(Group group:groupService.getGroupsByOwnerId(groupVO.getOwnerId())){
|
|
|
|
- if(name.equals(group.getName())) {
|
|
|
|
|
|
+ for (Group group : groupService.getGroupsByOwnerId(groupVO.getOwnerId())) {
|
|
|
|
+ if (name.equals(group.getName())) {
|
|
throw new HttpBadRequestException("Group name already created by this manager");
|
|
throw new HttpBadRequestException("Group name already created by this manager");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(name.length() > 25){
|
|
|
|
|
|
+ if (name.length() > 25) {
|
|
throw new HttpBadRequestException("Group name exceed 25 chars");
|
|
throw new HttpBadRequestException("Group name exceed 25 chars");
|
|
- }else if(name.length() < 1){
|
|
|
|
|
|
+ } else if (name.length() < 1) {
|
|
throw new HttpBadRequestException("Group name cannot be empty.");
|
|
throw new HttpBadRequestException("Group name cannot be empty.");
|
|
- }
|
|
|
|
- else{
|
|
|
|
- Group g=Converter.convert(Group.class,groupVO);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ Group g = Converter.convert(Group.class, groupVO);
|
|
g.setManagerId(-1L);
|
|
g.setManagerId(-1L);
|
|
g.setIsActive(true);
|
|
g.setIsActive(true);
|
|
Group group = groupService.save(g);
|
|
Group group = groupService.save(g);
|
|
- groupPermissionService.createGroup(userId,group.getId());
|
|
|
|
- return Converter.convert(GroupVO.class,group);
|
|
|
|
|
|
+ groupPermissionService.createGroup(userId, group.getId());
|
|
|
|
+ return Converter.convert(GroupVO.class, group);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -256,17 +255,17 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
@Override
|
|
@Override
|
|
public GroupVO joinGroup(HttpServletRequest request, long userId, GroupVO groupVO) {
|
|
public GroupVO joinGroup(HttpServletRequest request, long userId, GroupVO groupVO) {
|
|
Group group = groupService.getGroup(groupVO.getId());
|
|
Group group = groupService.getGroup(groupVO.getId());
|
|
- if(group.getIsActive() == false) {
|
|
|
|
|
|
+ if (group.getIsActive() == false) {
|
|
throw new HttpBadRequestException("班级已关闭");
|
|
throw new HttpBadRequestException("班级已关闭");
|
|
}
|
|
}
|
|
long managerId = group.getOwnerId();
|
|
long managerId = group.getOwnerId();
|
|
- if(!groupService.checkManagerGroupSize(managerId)) {
|
|
|
|
|
|
+ if (!groupService.checkManagerGroupSize(managerId)) {
|
|
throw new HttpBadRequestException("老师份额已使用完");
|
|
throw new HttpBadRequestException("老师份额已使用完");
|
|
}
|
|
}
|
|
- if ( groupVO.getCaptcha()!=null && ( groupVO.getCaptcha().equals("summer") || CaptchaUtils.verifyPictureCaptcha(request, groupVO.getCaptcha()))) {
|
|
|
|
|
|
+ if (groupVO.getCaptcha() != null && (groupVO.getCaptcha().equals("summer") || CaptchaUtils.verifyPictureCaptcha(request, groupVO.getCaptcha()))) {
|
|
String managerName = groupVO.getManagerName();
|
|
String managerName = groupVO.getManagerName();
|
|
- UserDTOForMT user= userService.findByUserId(group.getOwnerId());
|
|
|
|
- if(!group.getAllowJoin()){
|
|
|
|
|
|
+ UserDTOForMT user = userService.findByUserId(group.getOwnerId());
|
|
|
|
+ if (!group.getAllowJoin()) {
|
|
throw new HttpForbiddenException("Group not allowed to join");
|
|
throw new HttpForbiddenException("Group not allowed to join");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -276,7 +275,7 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
"] is not manager of Group[id=" + groupVO.getId() + "]");
|
|
"] is not manager of Group[id=" + groupVO.getId() + "]");
|
|
}
|
|
}
|
|
return groupVOWrapper.wrap(groupService.joinGroup(userId, group));
|
|
return groupVOWrapper.wrap(groupService.joinGroup(userId, group));
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
throw new HttpBadRequestException("Captcha error");
|
|
throw new HttpBadRequestException("Captcha error");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -323,14 +322,14 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
if (group == null) {
|
|
if (group == null) {
|
|
throw new HttpNotFoundException("班级[id=" + groupId + "]不存在!");
|
|
throw new HttpNotFoundException("班级[id=" + groupId + "]不存在!");
|
|
}
|
|
}
|
|
- if(group.getIsActive() == false) {
|
|
|
|
|
|
+ if (group.getIsActive() == false) {
|
|
throw new HttpBadRequestException("班级已关闭");
|
|
throw new HttpBadRequestException("班级已关闭");
|
|
}
|
|
}
|
|
- if(!groupService.checkManagerGroupSize(group.getOwnerId())) {
|
|
|
|
|
|
+ if (!groupService.checkManagerGroupSize(group.getOwnerId())) {
|
|
throw new HttpBadRequestException("老师份额已使用完");
|
|
throw new HttpBadRequestException("老师份额已使用完");
|
|
}
|
|
}
|
|
- UserDTOForMT user= userService.findByUsername(userName);
|
|
|
|
- if(user==null){
|
|
|
|
|
|
+ UserDTOForMT user = userService.findByUsername(userName);
|
|
|
|
+ if (user == null) {
|
|
throw new HttpNotFoundException("用户[" + userName + "]不存在!");
|
|
throw new HttpNotFoundException("用户[" + userName + "]不存在!");
|
|
}
|
|
}
|
|
if (groupService.checkUserExist(user.getId(), groupId)) {
|
|
if (groupService.checkUserExist(user.getId(), groupId)) {
|
|
@@ -339,7 +338,7 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
if (group.getOwnerId() == user.getId()) {
|
|
if (group.getOwnerId() == user.getId()) {
|
|
throw new IllegalOperationException("Cannot join Group YOU OWN!");
|
|
throw new IllegalOperationException("Cannot join Group YOU OWN!");
|
|
}
|
|
}
|
|
- UserVO uv=Converter.convert(UserVO.class,groupService.addUserIntoGroup(user.getId(),groupId));
|
|
|
|
|
|
+ UserVO uv = Converter.convert(UserVO.class, groupService.addUserIntoGroup(user.getId(), groupId));
|
|
uv.setPassword("");
|
|
uv.setPassword("");
|
|
return uv;
|
|
return uv;
|
|
}
|
|
}
|
|
@@ -376,17 +375,17 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
if (group == null) {
|
|
if (group == null) {
|
|
throw new HttpNotFoundException(String.format("Group[id=%s] not exist", groupId));
|
|
throw new HttpNotFoundException(String.format("Group[id=%s] not exist", groupId));
|
|
}
|
|
}
|
|
- UserDTOForMT user= userService.findByUserId(userId);
|
|
|
|
- if(user==null){
|
|
|
|
- throw new HttpNotFoundException(String.format("User[id=%s] not exist",userId));
|
|
|
|
|
|
+ UserDTOForMT user = userService.findByUserId(userId);
|
|
|
|
+ if (user == null) {
|
|
|
|
+ throw new HttpNotFoundException(String.format("User[id=%s] not exist", userId));
|
|
}
|
|
}
|
|
- if(!groupService.checkUserExist(userId,groupId)){
|
|
|
|
- throw new HttpBadRequestException(String.format("User[id=%s] not exists in Group[id=%s]",user.getId(), groupId));
|
|
|
|
|
|
+ if (!groupService.checkUserExist(userId, groupId)) {
|
|
|
|
+ throw new HttpBadRequestException(String.format("User[id=%s] not exists in Group[id=%s]", user.getId(), groupId));
|
|
}
|
|
}
|
|
- UserVO UserVO =new UserVO();
|
|
|
|
- UserVO =Converter.copy(UserVO,groupService.deleteUserFromGroup(userId,groupId));
|
|
|
|
|
|
+ UserVO UserVO = new UserVO();
|
|
|
|
+ UserVO = Converter.copy(UserVO, groupService.deleteUserFromGroup(userId, groupId));
|
|
UserVO.setPassword("");
|
|
UserVO.setPassword("");
|
|
- List<GroupPermission> groupPermissions = groupPermissionService.deleteWorkerPermission(userId,groupId);
|
|
|
|
|
|
+ List<GroupPermission> groupPermissions = groupPermissionService.deleteWorkerPermission(userId, groupId);
|
|
return UserVO;
|
|
return UserVO;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -407,7 +406,7 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
@Override
|
|
@Override
|
|
public GroupVO updateAllowJoin(long managerId, GroupVO groupVO) {
|
|
public GroupVO updateAllowJoin(long managerId, GroupVO groupVO) {
|
|
Group group = groupService.getGroup(groupVO.getId());
|
|
Group group = groupService.getGroup(groupVO.getId());
|
|
- if(managerId != group.getManagerId()){
|
|
|
|
|
|
+ if (managerId != group.getManagerId()) {
|
|
throw new HttpForbiddenException("unauthorized for the task");
|
|
throw new HttpForbiddenException("unauthorized for the task");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -416,17 +415,17 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public GroupVO updateAllowJoin(long groupId){
|
|
|
|
- Group group=groupService.getGroup(groupId);
|
|
|
|
|
|
+ public GroupVO updateAllowJoin(long groupId) {
|
|
|
|
+ Group group = groupService.getGroup(groupId);
|
|
group.setAllowJoin(!group.getAllowJoin());
|
|
group.setAllowJoin(!group.getAllowJoin());
|
|
- return Converter.convert(GroupVO.class,groupService.save(group));
|
|
|
|
|
|
+ return Converter.convert(GroupVO.class, groupService.save(group));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public GroupVO updateGroupActive(Long groupId) {
|
|
public GroupVO updateGroupActive(Long groupId) {
|
|
Group group = groupService.getGroup(groupId);
|
|
Group group = groupService.getGroup(groupId);
|
|
group.setIsActive(false);
|
|
group.setIsActive(false);
|
|
- return Converter.convert(GroupVO.class,groupService.save(group));
|
|
|
|
|
|
+ return Converter.convert(GroupVO.class, groupService.save(group));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -437,21 +436,21 @@ public class GroupLogicImpl extends BaseLogic implements GroupLogic {
|
|
@Override
|
|
@Override
|
|
public int getManagerGroupSize(long managerId) {
|
|
public int getManagerGroupSize(long managerId) {
|
|
ManagerProperty managerProperty = managerPropertyService.getManagerPropertyByUserId(managerId);
|
|
ManagerProperty managerProperty = managerPropertyService.getManagerPropertyByUserId(managerId);
|
|
- if(managerProperty == null) {
|
|
|
|
|
|
+ if (managerProperty == null) {
|
|
throw new HttpBadRequestException("manager don't exist");
|
|
throw new HttpBadRequestException("manager don't exist");
|
|
}
|
|
}
|
|
return managerProperty.getGroupSize();
|
|
return managerProperty.getGroupSize();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public GroupVO joinGroupByQrCode(long userId,long groupId){
|
|
|
|
|
|
+ public GroupVO joinGroupByQrCode(long userId, long groupId) {
|
|
Group group = groupService.getGroup(groupId);
|
|
Group group = groupService.getGroup(groupId);
|
|
|
|
|
|
if (group == null) {
|
|
if (group == null) {
|
|
throw new HttpNotFoundException("Group[id=" + groupId + "] doesn't exist");
|
|
throw new HttpNotFoundException("Group[id=" + groupId + "] doesn't exist");
|
|
}
|
|
}
|
|
|
|
|
|
- if(!group.getAllowJoin()){
|
|
|
|
|
|
+ if (!group.getAllowJoin()) {
|
|
throw new HttpForbiddenException("Group not allowed to join");
|
|
throw new HttpForbiddenException("Group not allowed to join");
|
|
}
|
|
}
|
|
|
|
|