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;
}
}
}
}
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);
}
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());
}
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);
}
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);
}
Aggregations