Search in sources :

Example 1 with PmphUser

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

the class PmphDepartmentSeviceTest method department.

// 部门对比
@Test
@Rollback(Const.ISROLLBACK)
public void department() {
    // 查询现在所有父级部门,
    PmphUserDepartmentVO departmentVO = pmphDepartmentService.listPmphDepartment(null);
    // 部门总数为28,超过则是多余部门
    if (ObjectUtil.notNull(departmentVO) && departmentVO.getSonDepartment().size() > 28) {
        for (PmphUserDepartmentVO pmphDepartment : departmentVO.getSonDepartment()) {
            // 查询该部门下的所有成员
            List<PmphUser> pmphUsers = pmphUserService.listPmphUserByDepartmentId(pmphDepartment.getId());
            switch(pmphDepartment.getDpName()) {
                case "出版社科室1":
                    if (ObjectUtil.notNull(pmphUsers)) {
                        for (PmphUser pmphUser : pmphUsers) {
                            // 把该部门人员移到人民卫生出版社部门下
                            pmphUser.setDepartmentId(0L);
                            pmphUserService.updateUser(pmphUser);
                        }
                    }
                    // 删除多余的部门
                    pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
                    break;
                case "公司领导":
                    // 查询该部门下的所有成员
                    if (ObjectUtil.notNull(pmphUsers)) {
                        for (PmphUser pmphUser : pmphUsers) {
                            // 把该部门人员移到人民卫生出版社部门下
                            pmphUser.setDepartmentId(0L);
                            pmphUserService.updateUser(pmphUser);
                        }
                    }
                    // 删除多余的部门
                    pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
                    break;
                case "其他":
                    // 查询该部门下的所有成员
                    if (ObjectUtil.notNull(pmphUsers)) {
                        for (PmphUser pmphUser : pmphUsers) {
                            // 把该部门人员移到人民卫生出版社部门下
                            pmphUser.setDepartmentId(0L);
                            pmphUserService.updateUser(pmphUser);
                        }
                    }
                    // 删除多余的部门
                    pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
                    break;
                case "农协":
                    // 查询该部门下的所有成员
                    if (ObjectUtil.notNull(pmphUsers)) {
                        for (PmphUser pmphUser : pmphUsers) {
                            // 把该部门人员移到人民卫生出版社部门下
                            pmphUser.setDepartmentId(0L);
                            pmphUserService.updateUser(pmphUser);
                        }
                    }
                    // 删除多余的部门
                    pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
                    break;
                default:
                    break;
            }
        }
    }
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) PmphUserDepartmentVO(com.bc.pmpheep.back.vo.PmphUserDepartmentVO) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 2 with PmphUser

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

the class PmphUserServiceTest method testAdd.

/**
 * PmphUser 添加Test
 */
@Test
public void testAdd() {
    List<Long> roleIdList = new ArrayList<Long>();
    roleIdList.add(1L);
    roleIdList.add(2L);
    roleIdList.add(3L);
    PmphUser user = new PmphUser();
    user.setUsername("admin3");
    user.setAvatar("110");
    user.setPassword("1");
    user.setRealname("admin3");
    user.setIsDisabled(false);
    // 给单用户添加多个角色
    PmphUser ps = userService.add(user, roleIdList);
    // 查看对象是否不为空。
    Assert.assertNotNull("是否保存成功", ps);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 3 with PmphUser

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

the class PmphUserServiceTest method testAddPmphUser.

/**
 * PmphUser 添加Test
 */
@Test
public void testAddPmphUser() {
    List<Long> roleIdList = new ArrayList<Long>();
    roleIdList.add(1L);
    roleIdList.add(2L);
    roleIdList.add(3L);
    PmphUser user = new PmphUser();
    user.setUsername("admin3");
    user.setAvatar("110");
    user.setPassword("1");
    user.setRealname("admin3");
    user.setIsDisabled(false);
    // 添加用户
    PmphUser u = userService.add(user);
    // 查看两个对象的引用是否相等。类似于使用“==”比较两个对象
    Assert.assertNotSame("是否有返回值", null, u.getId());
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 4 with PmphUser

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

the class PmphUserServiceTest method testDelete.

@Test
public void testDelete() {
    PmphUser pmphUser = new PmphUser();
    pmphUser.setUsername("admin001");
    pmphUser.setPassword("123");
    pmphUser.setRealname("ABC");
    pmphUser.setAvatar("110");
    userService.add(pmphUser);
    Assert.assertTrue("删除失败", userService.delete(pmphUser.getId()) > 0);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 5 with PmphUser

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

the class PmphUserServiceTest method testDeleteUserAndRole.

@Test
public void testDeleteUserAndRole() {
    List<Long> ids = new ArrayList<Long>();
    ids.add(1L);
    ids.add(2L);
    ids.add(3L);
    PmphUser pmphUser = new PmphUser();
    pmphUser.setUsername("ABC");
    pmphUser.setPassword("123");
    pmphUser.setAvatar("110");
    pmphUser.setRealname("ABC");
    userService.add(pmphUser, ids);
    Assert.assertTrue("影响行数不为3就为错误", userService.deleteUserAndRole(ids) == 3);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

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