|
@@ -6,7 +6,11 @@ import cn.iselab.mooctest.site.dao.Task2CaseDao;
|
|
|
import cn.iselab.mooctest.site.dao.Task2GroupDao;
|
|
import cn.iselab.mooctest.site.dao.Task2GroupDao;
|
|
|
import cn.iselab.mooctest.site.data.AssignedCase;
|
|
import cn.iselab.mooctest.site.data.AssignedCase;
|
|
|
import cn.iselab.mooctest.site.models.*;
|
|
import cn.iselab.mooctest.site.models.*;
|
|
|
|
|
+import cn.iselab.mooctest.site.models.instancePermission.GroupPermission;
|
|
|
import cn.iselab.mooctest.site.service.*;
|
|
import cn.iselab.mooctest.site.service.*;
|
|
|
|
|
+import cn.iselab.mooctest.site.service.instancePermission.GroupPermissionService;
|
|
|
|
|
+import cn.iselab.mooctest.site.web.exception.IllegalOperationException;
|
|
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Pageable;
|
|
@@ -52,6 +56,9 @@ public class GroupServiceImpl implements GroupService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private Task2CaseDao paper2CaseDao;
|
|
private Task2CaseDao paper2CaseDao;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private GroupPermissionService groupPermissionService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<Group> getGroupsByWorkerId(long workerId) {
|
|
public List<Group> getGroupsByWorkerId(long workerId) {
|
|
|
return groupDao.findGroupListByWorker(workerId);
|
|
return groupDao.findGroupListByWorker(workerId);
|
|
@@ -123,6 +130,10 @@ public class GroupServiceImpl implements GroupService {
|
|
|
@Override
|
|
@Override
|
|
|
public Group joinGroup(long userId, Group group) {
|
|
public Group joinGroup(long userId, Group group) {
|
|
|
|
|
|
|
|
|
|
+ String permission = userId + ":group:*:" + group.getId();
|
|
|
|
|
+ if(SecurityUtils.getSubject().isPermitted(new GroupPermission(permission))){
|
|
|
|
|
+ throw new IllegalOperationException("Cannot join Group YOU OWN!");
|
|
|
|
|
+ }
|
|
|
if (group2WorkerDao.findByParticipantIdAndGroupId(userId, group.getId()) != null) {
|
|
if (group2WorkerDao.findByParticipantIdAndGroupId(userId, group.getId()) != null) {
|
|
|
return group;
|
|
return group;
|
|
|
}
|
|
}
|
|
@@ -135,6 +146,11 @@ public class GroupServiceImpl implements GroupService {
|
|
|
group2Worker.setRecordCreateTime(new Timestamp(System.currentTimeMillis()));
|
|
group2Worker.setRecordCreateTime(new Timestamp(System.currentTimeMillis()));
|
|
|
group2WorkerDao.save(group2Worker);
|
|
group2WorkerDao.save(group2Worker);
|
|
|
|
|
|
|
|
|
|
+ GroupPermission groupPermission=groupPermissionService.joinGroup(userId,group.getId());
|
|
|
|
|
+ if(groupPermission == null){
|
|
|
|
|
+ throw new IllegalOperationException("Can not create Group Permission!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return group;
|
|
return group;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -170,11 +186,19 @@ public class GroupServiceImpl implements GroupService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public User addUserIntoGroup(long userId, long groupId) {
|
|
public User addUserIntoGroup(long userId, long groupId) {
|
|
|
|
|
+ String permission = userId + ":group:*:" + groupId;
|
|
|
|
|
+ if(SecurityUtils.getSubject().isPermitted(new GroupPermission(permission))){
|
|
|
|
|
+ throw new IllegalOperationException("Cannot join Group YOU OWN!");
|
|
|
|
|
+ }
|
|
|
Group2Worker group2Worker = new Group2Worker();
|
|
Group2Worker group2Worker = new Group2Worker();
|
|
|
group2Worker.setGroupId(groupId);
|
|
group2Worker.setGroupId(groupId);
|
|
|
group2Worker.setParticipantId(userId);
|
|
group2Worker.setParticipantId(userId);
|
|
|
group2Worker.setWorkerId(userId);
|
|
group2Worker.setWorkerId(userId);
|
|
|
group2WorkerDao.save(group2Worker);
|
|
group2WorkerDao.save(group2Worker);
|
|
|
|
|
+ GroupPermission groupPermission=groupPermissionService.joinGroup(userId,groupId);
|
|
|
|
|
+ if(groupPermission == null){
|
|
|
|
|
+ throw new IllegalOperationException("Can not create Group Permission!");
|
|
|
|
|
+ }
|
|
|
return userService.findByUserId(userId);
|
|
return userService.findByUserId(userId);
|
|
|
}
|
|
}
|
|
|
|
|
|