Search in sources :

Example 1 with WriterRolePermission

use of com.bc.pmpheep.back.po.WriterRolePermission in project pmph by BCSquad.

the class WriterRolePermissionServiceTest method testAddWriterRolePermission.

@Test
@Rollback(Const.ISROLLBACK)
public void testAddWriterRolePermission() throws Exception {
    WriterRolePermission writerRolePermission = this.addWriterRolePermission();
    Assert.assertNotNull("addWriterRolePermission是否添加成功", writerRolePermissionService.addWriterRolePermission(writerRolePermission));
}
Also used : WriterRolePermission(com.bc.pmpheep.back.po.WriterRolePermission) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 2 with WriterRolePermission

use of com.bc.pmpheep.back.po.WriterRolePermission in project pmph by BCSquad.

the class WriterRolePermissionServiceTest method testGetWriterRolePermissionById.

@Test
@Rollback(Const.ISROLLBACK)
public void testGetWriterRolePermissionById() {
    WriterRolePermission writerRolePermission = this.addWriterRolePermission();
    WriterRolePermission wrp = writerRolePermissionService.getWriterRolePermissionById(writerRolePermission.getId());
    Assert.assertNotNull("获取失败", wrp);
}
Also used : WriterRolePermission(com.bc.pmpheep.back.po.WriterRolePermission) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 3 with WriterRolePermission

use of com.bc.pmpheep.back.po.WriterRolePermission in project pmph by BCSquad.

the class WriterRolePermissionServiceTest method testDeleteWriterRolePermissionById.

@Test
@Rollback(Const.ISROLLBACK)
public void testDeleteWriterRolePermissionById() {
    WriterRolePermission writerRolePermission = this.addWriterRolePermission();
    Integer bInteger = writerRolePermissionService.deleteWriterRolePermissionById(writerRolePermission.getId());
    Assert.assertTrue("删除成功失败", bInteger > 0 ? true : false);
}
Also used : WriterRolePermission(com.bc.pmpheep.back.po.WriterRolePermission) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 4 with WriterRolePermission

use of com.bc.pmpheep.back.po.WriterRolePermission in project pmph by BCSquad.

the class WriterRoleServiceTest method testGetListRoleResource.

@Test
@Rollback(Const.ISROLLBACK)
public void testGetListRoleResource() {
    WriterRole writerRole = this.addWriterRole();
    List<WriterPermission> list = writerRoleService.getListRoleResource(writerRole.getId());
    Assert.assertNotNull("是否查询成功", list);
    List<WriterRolePermission> list1 = writerRoleService.getListWriterRolePermission(writerRole.getId());
    Assert.assertNotNull("是否查询成功", list1);
    List<Long> ids = writerRoleService.getListPmphWriterPermissionIdByRoleId(writerRole.getId());
    Assert.assertNotNull("是否查询成功", ids);
}
Also used : WriterPermission(com.bc.pmpheep.back.po.WriterPermission) WriterRolePermission(com.bc.pmpheep.back.po.WriterRolePermission) WriterRole(com.bc.pmpheep.back.po.WriterRole) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 5 with WriterRolePermission

use of com.bc.pmpheep.back.po.WriterRolePermission in project pmph by BCSquad.

the class WriterRoleServiceImpl method addRoleResource.

@Override
public Integer addRoleResource(Long roleId, List<Long> permissionIds) throws CheckedServiceException {
    // 添加时先删除当前权限
    deleteRoleResourceByRoleId(roleId);
    if (ObjectUtil.isNull(roleId) || permissionIds.size() < 0) {
        throw new CheckedServiceException(CheckedExceptionBusiness.ROLE_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "角色ID或资源ID为空时禁止新增");
    }
    List<WriterRolePermission> lists = new ArrayList<WriterRolePermission>();
    WriterRolePermission writerRolePermission;
    for (Long permissionId : permissionIds) {
        writerRolePermission = new WriterRolePermission();
        writerRolePermission.setRoleId(roleId);
        writerRolePermission.setPermissionId(permissionId);
        lists.add(writerRolePermission);
    }
    return roleDao.addRoleResource(lists);
}
Also used : WriterRolePermission(com.bc.pmpheep.back.po.WriterRolePermission) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Aggregations

WriterRolePermission (com.bc.pmpheep.back.po.WriterRolePermission)7 BaseTest (com.bc.pmpheep.test.BaseTest)6 Test (org.junit.Test)6 Rollback (org.springframework.test.annotation.Rollback)6 ArrayList (java.util.ArrayList)2 WriterPermission (com.bc.pmpheep.back.po.WriterPermission)1 WriterRole (com.bc.pmpheep.back.po.WriterRole)1 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)1