Search in sources :

Example 6 with WriterRole

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

the class WriterRoleServiceTest method testAddUserRole.

@Test
@Rollback(Const.ISROLLBACK)
public void testAddUserRole() {
    WriterRole writerRole = this.addWriterRole();
    int num = -1;
    num = writerRoleService.addUserRole(writerRole.getId(), writerRole.getId());
    Assert.assertNotNull("是否添加成功", num >= 0);
}
Also used : WriterRole(com.bc.pmpheep.back.po.WriterRole) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 7 with WriterRole

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

the class MigrationStageTwo method writerRole.

protected void writerRole() {
    String tableName = "sys_role";
    // 增加new_pk字段
    JdbcHelper.addColumn(tableName);
    List<Map<String, Object>> maps = JdbcHelper.queryForList(tableName);
    List<Map<String, Object>> excel = new LinkedList<>();
    int count = 0;
    for (Map<String, Object> map : maps) {
        Double roleId = (Double) map.get("roleid");
        String rolename = (String) map.get("rolename");
        Integer isDisabled = (Integer) map.get("isvalid");
        Integer sort = (Integer) map.get("sortno");
        if (ObjectUtil.notNull(sort) && sort < 0) {
            sort = 999;
        }
        String note = (String) map.get("memo");
        WriterRole writerRole = new WriterRole();
        writerRole.setRoleName(rolename);
        writerRole.setIsDisabled(isDisabled != 1);
        writerRole.setSort(sort);
        writerRole.setNote(note);
        writerRole = writerRoleService.add(writerRole);
        count++;
        Long pk = writerRole.getId();
        JdbcHelper.updateNewPrimaryKey(tableName, pk, "roleid", roleId);
    }
    if (excel.size() > 0) {
        try {
            excelHelper.exportFromMaps(excel, "作家角色表", "writer_role");
        } catch (IOException ex) {
            logger.error("异常数据导出到Excel失败", ex);
        }
    }
    logger.info("writer_role表迁移完成");
    logger.info("原数据库表共有{}条数据,迁移了{}条数据", maps.size(), count);
    // 记录信息
    Map<String, Object> msg = new HashMap<String, Object>();
    msg.put("result", "writer_role表迁移完成" + count + "/" + maps.size());
    SQLParameters.STATISTICS.add(msg);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IOException(java.io.IOException) WriterRole(com.bc.pmpheep.back.po.WriterRole) LinkedList(java.util.LinkedList) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 8 with WriterRole

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

the class WriterRoleServiceTest method testAdd.

@Test
@Rollback(Const.ISROLLBACK)
public void testAdd() {
    WriterRole writerRole = this.addWriterRole();
    Assert.assertNotNull("是否添加成功", writerRole.getId());
}
Also used : WriterRole(com.bc.pmpheep.back.po.WriterRole) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 9 with WriterRole

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

the class WriterRoleServiceTest method testDeleteRoleAndResource.

@Test
@Rollback(Const.ISROLLBACK)
public void testDeleteRoleAndResource() {
    WriterRole writerRole = this.addWriterRole();
    List<Long> ids = new ArrayList<>();
    int num = 0;
    ids.add(writerRole.getId());
    writerRoleService.addRoleResource(writerRole.getId(), ids);
    num = writerRoleService.deleteRoleAndResource(ids);
    Assert.assertTrue("删除失败", num > 0 ? true : false);
}
Also used : ArrayList(java.util.ArrayList) WriterRole(com.bc.pmpheep.back.po.WriterRole) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 10 with WriterRole

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

the class WriterUserServiceTest method testGetListsTest.

/**
 * 查询
 */
@Test
@Rollback(Const.ISROLLBACK)
public void testGetListsTest() {
    WriterUser writerUser = this.addWriterUser();
    // WriterUser wtUser;
    // List<WriterUser> pmUsers;
    // List<WriterPermission> listPermissions;
    // wtUser = writerUserService.login("test1", "123");
    List<WriterRole> pr = writerUserService.getListUserRole(writerUser.getId());
    Assert.assertNotNull("获取失败", pr);
}
Also used : WriterUser(com.bc.pmpheep.back.po.WriterUser) WriterRole(com.bc.pmpheep.back.po.WriterRole) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Aggregations

WriterRole (com.bc.pmpheep.back.po.WriterRole)11 BaseTest (com.bc.pmpheep.test.BaseTest)10 Test (org.junit.Test)10 Rollback (org.springframework.test.annotation.Rollback)10 WriterUser (com.bc.pmpheep.back.po.WriterUser)2 ArrayList (java.util.ArrayList)2 WriterPermission (com.bc.pmpheep.back.po.WriterPermission)1 WriterRolePermission (com.bc.pmpheep.back.po.WriterRolePermission)1 WriterUserRole (com.bc.pmpheep.back.po.WriterUserRole)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1