use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphUserServiceTest method updatePmphUserTest.
/**
* PmphUser 更新方法
*/
@Test
public void updatePmphUserTest() {
PmphUser pmphUser = new PmphUser();
pmphUser.setId(18L);
pmphUser.setUsername("test1");
List<Long> userIdList = new ArrayList<Long>();
userIdList.add(1L);
userIdList.add(2L);
PmphUser pu = userService.update(pmphUser, userIdList);
Assert.assertNotNull("修改成功", pu);
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphUserServiceTest method testUpdate.
/**
* PmphUser 更新方法
*/
@Test
public void testUpdate() {
PmphUser pmphUser = new PmphUser();
pmphUser.setId(18L);
pmphUser.setUsername("test1");
List<Long> userIdList = new ArrayList<Long>();
userIdList.add(1L);
userIdList.add(2L);
PmphUser pu = userService.update(pmphUser);
// 查看对象是否不为空。
Assert.assertNotNull("修改成功", pu);
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphGroupFileServiceImpl method deletePmphGroupFileById.
/**
* @param id
* 主键id
* @return 影响行数
* @throws CheckedServiceException
*/
@Override
public String deletePmphGroupFileById(Long groupId, Long[] ids, String sessionId) throws CheckedServiceException {
String result = "FAIL";
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser) || ObjectUtil.isNull(pmphUser.getId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
Long userId = pmphUser.getId();
PmphGroupMemberVO currentUser = new PmphGroupMemberVO();
if (ObjectUtil.isNull(ids) || ids.length == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "主键为空");
} else {
if (!pmphUser.getIsAdmin()) {
currentUser = pmphGroupMemberService.getPmphGroupMemberByMemberId(groupId, userId, false);
}
for (Long id : ids) {
Long uploaderId = pmphGroupFileDao.getPmphGroupFileById(id).getMemberId();
if (pmphUser.getIsAdmin() || uploaderId.equals(currentUser.getId()) || currentUser.getIsFounder() || currentUser.getIsAdmin()) {
// 超级管理员、小组创建者、小组管理者、文件上传人才可以删除文件
PmphGroupFile pmphGroupFile = pmphGroupFileDao.getPmphGroupFileById(id);
Integer num = pmphGroupFileDao.getPmphGroupFileTotalByFileId(pmphGroupFile.getFileId());
if (1 == num) {
fileService.remove(pmphGroupFile.getFileId());
}
pmphGroupFileDao.deletePmphGroupFileById(id);
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有此操作权限");
}
}
result = "SUCCESS";
}
return result;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphGroupMemberServiceImpl method updateGroupMemberByIds.
@Override
public String updateGroupMemberByIds(Long groupId, Long[] ids, String sessionId) throws CheckedServiceException {
String result = "FAIL";
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "该用户为空");
}
if (!pmphUser.getIsAdmin()) {
if (!isFounderOrisAdmin(groupId, sessionId)) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有操作权限");
}
}
Long userid = pmphUser.getId();
PmphGroupMemberVO currentUser = pmphGroupMemberDao.getPmphGroupMemberByMemberId(groupId, userid, false);
if (null == ids || ids.length == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "主键不能为空");
} else {
for (Long id : ids) {
PmphGroupMember pmphGroupMember = pmphGroupMemberDao.getPmphGroupMemberById(id);
// }
if (pmphUser.getIsAdmin() || currentUser.getIsFounder()) {
// 只有小组创建者和超级管理员可以删除小组成员
if (pmphGroupMemberDao.getPmphGroupMemberById(id).getIsFounder()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "小组创建者不能删除,请重新选择");
}
pmphGroupMemberDao.updateGroupMemberById(id);
} else {
// 管理员进入的方法
if (currentUser.getIsAdmin() && (pmphGroupMember.getIsFounder() || pmphGroupMember.getIsAdmin())) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "您无权限删除管理员,请重新选择");
} else {
pmphGroupMemberDao.updateGroupMemberById(id);
}
}
}
result = "SUCCESS";
}
return result;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphGroupMemberServiceImpl method isFounderOrisAdmin.
@Override
public Boolean isFounderOrisAdmin(Long groupId, String sessionId) throws CheckedServiceException {
boolean flag = false;
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
Long memberId = pmphUser.getId();
PmphGroupMemberVO currentUser = pmphGroupMemberDao.getPmphGroupMemberByMemberId(groupId, memberId, false);
if (null != currentUser) {
if (currentUser.getIsFounder() || currentUser.getIsAdmin()) {
flag = true;
}
}
return flag;
}
Aggregations