use of com.bc.pmpheep.back.po.WriterUser in project pmph by BCSquad.
the class AddTestUser method addTestUser.
public void addTestUser() {
String pmphUserData = "[" + "{'username':'yewutest01','realname':'业务测试账号A','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'主任'}]}," + "{'username':'yewutest02','realname':'业务测试账号B','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'系统管理员'},{'roleName':'项目编辑'}]}," + "{'username':'yewutest03','realname':'业务测试账号C','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'项目编辑'}]}," + "{'username':'yewutest04','realname':'业务测试账号D','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'项目编辑'}]}," + "{'username':'yewutest05','realname':'业务测试账号E','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'项目编辑'}]}," + "{'username':'yewutest06','realname':'业务测试账号F','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'项目编辑'}]}," + "{'username':'yewutest07','realname':'业务测试账号J','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'主任'}]}," + "{'username':'yewutest08','realname':'业务测试账号H','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[]}," + "{'username':'yewutest09','realname':'业务测试账号I','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'数字编辑'}]}," + "{'username':'yewutest10','realname':'业务测试账号J','password':'888888','department':'人民卫生出版社','avatar':'DEFAULT','roles':[{'roleName':'数字编辑'},{'roleName':'其他用户'}]}" + "]";
Gson gson = new Gson();
List<TestPmphUserBo> testPmphUsers = gson.fromJson(pmphUserData, new TypeToken<ArrayList<TestPmphUserBo>>() {
}.getType());
for (TestPmphUserBo user : testPmphUsers) {
PmphDepartment pmphDepartment = pmphDepartmentService.getPmphDepartmentByName(user.getDepartment());
PmphUser pmphUser = new PmphUser();
pmphUser.setUsername(user.getUsername());
pmphUser.setRealname(user.getRealname());
pmphUser.setPassword(user.getPassword());
pmphUser.setDepartmentId(pmphDepartment == null ? 0L : pmphDepartment.getId());
pmphUser.setAvatar(user.getAvatar());
pmphUser = pmphUserService.add(pmphUser);
for (PmphRole pmphRole : user.getRoles()) {
pmphRole = pmphRoleService.getByName(pmphRole.getRoleName());
PmphUserRole pmphUserRole = new PmphUserRole();
pmphUserRole.setUserId(pmphUser.getId());
pmphUserRole.setRoleId(pmphRole == null ? 0L : pmphRole.getId());
pmphUserRoleService.addPmphUserRole(pmphUserRole);
}
}
String orgData = "[" + "{'orgName':'北京测试学校','orgType':'本科','areaName':'北京市','username':'bjcsxxtest','password':'123456','realname':'北京学校管理员','avatar':'DEFAULT'," + "writerUsers:[" + "{'username':'bjzuojia01','password':'888888','nickname':'北京作家01','realname':'北京作家01'}," + "{'username':'bjzuojia02','password':'888888','nickname':'北京作家02','realname':'北京作家02'}," + "{'username':'bjzuojia03','password':'888888','nickname':'北京作家03','realname':'北京作家03'}," + "{'username':'bjzuojia04','password':'888888','nickname':'北京作家04','realname':'北京作家04'}," + "{'username':'bjzuojia05','password':'888888','nickname':'北京作家05','realname':'北京作家05'}," + "{'username':'bjzuojia06','password':'888888','nickname':'北京作家06','realname':'北京作家06'}," + "{'username':'bjzuojia07','password':'888888','nickname':'北京作家07','realname':'北京作家07'}," + "{'username':'bjzuojia08','password':'888888','nickname':'北京作家08','realname':'北京作家08'}," + "{'username':'bjzuojia09','password':'888888','nickname':'北京作家09','realname':'北京作家09'}," + "{'username':'bjzuojia10','password':'888888','nickname':'北京作家10','realname':'北京作家10'}," + "{'username':'bjzuojia11','password':'888888','nickname':'北京作家11','realname':'北京作家11'}" + "]" + "}," + "{'orgName':'天津测试学校','orgType':'本科','areaName':'天津市','username':'tjcsxxtest','password':'123456','realname':'天津学校管理员','avatar':'DEFAULT'," + "writerUsers:[" + "{'username':'tjzuojia01','password':'888888','nickname':'天津作家01','realname':'天津作家01'}," + "{'username':'tjzuojia02','password':'888888','nickname':'天津作家02','realname':'天津作家02'}," + "{'username':'tjzuojia03','password':'888888','nickname':'天津作家03','realname':'天津作家03'}," + "{'username':'tjzuojia04','password':'888888','nickname':'天津作家04','realname':'天津作家04'}," + "{'username':'tjzuojia05','password':'888888','nickname':'天津作家05','realname':'天津作家05'}," + "{'username':'tjzuojia06','password':'888888','nickname':'天津作家06','realname':'天津作家06'}," + "{'username':'tjzuojia07','password':'888888','nickname':'天津作家07','realname':'天津作家07'}," + "{'username':'tjzuojia08','password':'888888','nickname':'天津作家08','realname':'天津作家08'}," + "{'username':'tjzuojia09','password':'888888','nickname':'天津作家09','realname':'天津作家09'}," + "{'username':'tjzuojia10','password':'888888','nickname':'天津作家10','realname':'天津作家10'}," + "{'username':'tjzuojia11','password':'888888','nickname':'天津作家11','realname':'天津作家11'}" + "]" + "}" + "]";
List<TestOrgBo> orgBos = gson.fromJson(orgData, new TypeToken<ArrayList<TestOrgBo>>() {
}.getType());
for (TestOrgBo testOrgBo : orgBos) {
Org org = new Org();
org.setParentId(0L);
org.setOrgName(testOrgBo.getOrgName());
org.setOrgTypeId(orgTypeService.listOrgTypeByTypeName(testOrgBo.getOrgType()).get(0).getId());
org.setAreaId(areaService.getAreaIdByName(testOrgBo.getAreaName()));
org = orgService.addOrg(org);
OrgUser orgUser = new OrgUser();
orgUser.setUsername(testOrgBo.getUsername());
orgUser.setPassword(new DesRun("", testOrgBo.getPassword()).enpsw);
orgUser.setOrgId(org.getId());
orgUser.setRealname(testOrgBo.getRealname());
orgUser.setAvatar(testOrgBo.getAreaName());
orgUser = orgUserService.addOrgUser(orgUser);
for (WriterUser writerUser : testOrgBo.getWriterUsers()) {
writerUser.setOrgId(org.getId());
writerUserService.add(writerUser);
}
}
}
use of com.bc.pmpheep.back.po.WriterUser in project pmph by BCSquad.
the class WriterUserServiceTest method testUpdateWriterUserOfBack.
@Test
@Rollback(Const.ISROLLBACK)
public void testUpdateWriterUserOfBack() {
WriterUser writerUser = this.addWriterUser();
writerUser.setUsername(writerUser.getUsername());
writerUser.setPassword("789");
writerUser.setRealname("ZZZ");
writerUser.setNickname("QQQ");
writerUser.setAvatar("---");
writerUser.setRealname("UUU");
String result = writerUserService.updateWriterUserOfBack(writerUser);
Assert.assertTrue("更新失败", result.equals("SUCCESS"));
}
use of com.bc.pmpheep.back.po.WriterUser in project pmph by BCSquad.
the class WriterUserServiceTest method testGetListAllResource.
@Test
@Rollback(Const.ISROLLBACK)
public void testGetListAllResource() {
WriterUser writerUser = this.addWriterUser();
Integer writerPermission = writerPermissionService.addWriterPermission(new WriterPermission(2L, "PATH", "name", "menu_name", "url", false, null, null, null, null));
// 查询所有
Assert.assertNotNull("查询失败", writerUserService.getListAllResource(writerUser.getId()));
}
use of com.bc.pmpheep.back.po.WriterUser in project pmph by BCSquad.
the class WriterUserServiceTest method testGetId.
@Test
@Rollback(Const.ISROLLBACK)
public void testGetId() {
WriterUser writerUser = this.addWriterUser();
// 查询所有
Assert.assertNotNull("查询失败", writerUserService.get(writerUser.getId()));
}
use of com.bc.pmpheep.back.po.WriterUser in project pmph by BCSquad.
the class WriterUserServiceTest method testAddPmphUserTest.
/**
* PmphUser 添加Test
*/
@Test
@Rollback(Const.ISROLLBACK)
public void testAddPmphUserTest() {
List<Long> roleIdList = new ArrayList<Long>();
roleIdList.add(1L);
roleIdList.add(2L);
roleIdList.add(3L);
// 给单用户添加多个角色
WriterUser ps = writerUserService.add(new WriterUser("test1", "123"), roleIdList);
Assert.assertNotNull(ps);
}
Aggregations