Search in sources :

Example 96 with PmphUser

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);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 97 with PmphUser

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);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 98 with PmphUser

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;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) PmphGroupMemberVO(com.bc.pmpheep.back.vo.PmphGroupMemberVO) PmphGroupFile(com.bc.pmpheep.back.po.PmphGroupFile) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 99 with PmphUser

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;
}
Also used : PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) PmphUser(com.bc.pmpheep.back.po.PmphUser) PmphGroupMemberVO(com.bc.pmpheep.back.vo.PmphGroupMemberVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 100 with PmphUser

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;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) PmphGroupMemberVO(com.bc.pmpheep.back.vo.PmphGroupMemberVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Aggregations

PmphUser (com.bc.pmpheep.back.po.PmphUser)102 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)81 ArrayList (java.util.ArrayList)33 PageResult (com.bc.pmpheep.back.plugin.PageResult)17 HashMap (java.util.HashMap)13 Material (com.bc.pmpheep.back.po.Material)11 WriterUser (com.bc.pmpheep.back.po.WriterUser)11 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)10 PmphRole (com.bc.pmpheep.back.po.PmphRole)9 UserMessage (com.bc.pmpheep.back.po.UserMessage)9 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)9 BaseTest (com.bc.pmpheep.test.BaseTest)9 Test (org.junit.Test)9 CmsContent (com.bc.pmpheep.back.po.CmsContent)8 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)8 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)7 Textbook (com.bc.pmpheep.back.po.Textbook)7 WriterUserTrendst (com.bc.pmpheep.back.po.WriterUserTrendst)6 Gson (com.google.gson.Gson)6 OrgUser (com.bc.pmpheep.back.po.OrgUser)5