Search in sources :

Example 1 with Org

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

the class OrgUserSeviceTest method testUpdateOrgUserOfBack.

@Test
public void testUpdateOrgUserOfBack() {
    OrgAndOrgUserVO orgAndOrgUserVO = new OrgAndOrgUserVO();
    Org org = new Org();
    OrgUser orgUser = new OrgUser();
    // 所属区域
    org.setAreaId(12345L);
    // 机构id
    org.setOrgTypeId(4L);
    orgUser.setRealname("s");
    orgUser.setOrgId(org.getId());
    // 管理员姓名
    org.setOrgName("asdasdasdasda");
    // 机构代码
    orgUser.setUsername("m1001021");
    orgUserService.addOrgUserAndOrgOfBack(orgUser, org);
    orgAndOrgUserVO.setId(orgUser.getId());
    orgAndOrgUserVO.setRealname("机构");
    orgAndOrgUserVO.setUsername(orgUser.getUsername());
    orgAndOrgUserVO.setOrgId(org.getId());
    orgAndOrgUserVO.setOrgName("name");
    Object result = orgUserService.updateOrgUserOfBack(orgAndOrgUserVO);
    Assert.assertTrue("更新失败", result.equals("SUCCESS"));
}
Also used : OrgAndOrgUserVO(com.bc.pmpheep.back.vo.OrgAndOrgUserVO) Org(com.bc.pmpheep.back.po.Org) OrgUser(com.bc.pmpheep.back.po.OrgUser) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 2 with Org

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

the class OrgUserSeviceTest method addOrgUserAndOrgOfBack.

@Test
public void addOrgUserAndOrgOfBack() {
    Org org = new Org();
    OrgUser orgUser = new OrgUser();
    // 所属区域
    org.setAreaId(12345L);
    // 机构id
    org.setOrgTypeId(4L);
    orgUser.setRealname("s");
    // 排序码
    org.setSort(null);
    // 备注
    org.setNote(null);
    orgUser.setOrgId(org.getId());
    // 管理员姓名
    org.setOrgName("asdasdasdasda");
    // 机构代码
    orgUser.setUsername("m1001021");
    orgUser.setEmail(null);
    orgUser.setHandphone(null);
    Assert.assertNotNull("添加失败", orgUserService.addOrgUserAndOrgOfBack(orgUser, org));
}
Also used : Org(com.bc.pmpheep.back.po.Org) OrgUser(com.bc.pmpheep.back.po.OrgUser) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 3 with Org

use of com.bc.pmpheep.back.po.Org 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);
        }
    }
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) Org(com.bc.pmpheep.back.po.Org) OrgUser(com.bc.pmpheep.back.po.OrgUser) Gson(com.google.gson.Gson) PmphRole(com.bc.pmpheep.back.po.PmphRole) TypeToken(com.google.gson.reflect.TypeToken) DesRun(com.bc.pmpheep.back.util.DesRun) WriterUser(com.bc.pmpheep.back.po.WriterUser) PmphDepartment(com.bc.pmpheep.back.po.PmphDepartment) PmphUserRole(com.bc.pmpheep.back.po.PmphUserRole)

Example 4 with Org

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

the class OrgUserServiceImpl method updateOrgUserOfBack.

@Override
public String updateOrgUserOfBack(OrgAndOrgUserVO orgAndOrgUserVO) throws CheckedServiceException {
    OrgUser username = orgUserDao.getOrgUserById(orgAndOrgUserVO.getId());
    if (!username.getUsername().equals(orgAndOrgUserVO.getUsername())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.ILLEGAL_PARAM, "机构代码不相同");
    }
    if (ObjectUtil.isNull(orgAndOrgUserVO.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "主键为空");
    }
    if (StringUtil.strLength(orgAndOrgUserVO.getUsername()) > 20) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.ILLEGAL_PARAM, "用户名不能超过20个字符");
    }
    if (StringUtil.isEmpty(orgAndOrgUserVO.getUsername())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "机构代码不能为空");
    }
    if (StringUtil.strLength(orgAndOrgUserVO.getRealname()) > 20) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.ILLEGAL_PARAM, "管理员姓名不能超过20个字符");
    }
    if (StringUtil.strLength(orgAndOrgUserVO.getNote()) > 100) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.ILLEGAL_PARAM, "备注不能超过100个字符");
    }
    if (!StringUtil.isEmpty(orgAndOrgUserVO.getEmail())) {
        if (!ValidatUtil.checkEmail(orgAndOrgUserVO.getEmail())) {
            throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.ILLEGAL_PARAM, "邮箱不符合规范");
        }
    }
    if (!StringUtil.isEmpty(orgAndOrgUserVO.getHandphone())) {
        if (!ValidatUtil.checkMobileNumber(orgAndOrgUserVO.getHandphone())) {
            throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.ILLEGAL_PARAM, "手机号码不符合规范");
        }
    }
    if (StringUtil.isEmpty(orgAndOrgUserVO.getOrgName())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.ORG, CheckedExceptionResult.ILLEGAL_PARAM, "机构名称为空");
    }
    if (StringUtil.strLength(orgAndOrgUserVO.getOrgName()) > 20) {
        throw new CheckedServiceException(CheckedExceptionBusiness.ORG, CheckedExceptionResult.ILLEGAL_PARAM, "机构名称过长");
    }
    // 通过id查询机构用户来判断该机构名称是否被使用或者用户名等于数据库的机构
    Org orgname = orgDao.getOrgById(orgAndOrgUserVO.getOrgId());
    if (!orgname.getOrgName().equals(orgAndOrgUserVO.getOrgName())) {
        if (orgDao.getOrgByOrgName(orgAndOrgUserVO.getOrgName()).size() > 0) {
            throw new CheckedServiceException(CheckedExceptionBusiness.ORG, CheckedExceptionResult.ILLEGAL_PARAM, "该机构名称已被使用,请重新输入");
        }
    }
    Org org = new Org();
    org.setId(orgAndOrgUserVO.getOrgId());
    org.setOrgName(orgAndOrgUserVO.getOrgName());
    org.setOrgTypeId(orgAndOrgUserVO.getOrgTypeId());
    org.setAreaId(orgAndOrgUserVO.getAreaId());
    if (ObjectUtil.notNull(org)) {
        orgDao.updateOrg(org);
    }
    OrgUser orgUser = new OrgUser();
    orgUser.setId(orgAndOrgUserVO.getId());
    if (StringUtil.isEmpty(orgAndOrgUserVO.getRealname())) {
        orgUser.setRealname(orgAndOrgUserVO.getUsername());
    } else {
        orgUser.setRealname(orgAndOrgUserVO.getRealname());
    }
    orgUser.setIsDisabled(orgAndOrgUserVO.getIsDisabled());
    orgUser.setHandphone(orgAndOrgUserVO.getHandphone());
    orgUser.setEmail(orgAndOrgUserVO.getEmail());
    orgUser.setAddress(orgAndOrgUserVO.getNote());
    String result = "FAIL";
    if (ObjectUtil.notNull(orgUser)) {
        // 返回的影响行数,如果不是影响0行就是添加成功
        int count = orgUserDao.updateOrgUser(orgUser);
        if (count > 0) {
            result = "SUCCESS";
        }
    }
    return result;
}
Also used : Org(com.bc.pmpheep.back.po.Org) OrgUser(com.bc.pmpheep.back.po.OrgUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 5 with Org

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

the class WriterUserCertificationServiceImpl method updateWriterUserCertificationProgressByUserId.

@Override
public Integer updateWriterUserCertificationProgressByUserId(Short progress, Long[] userIds, HttpServletRequest request) throws CheckedServiceException, Exception {
    String sessionId = CookiesUtil.getSessionId(request);
    PmphUser pmphuser = SessionUtil.getPmphUserBySessionId(sessionId);
    List<WriterUserCertification> writerUserCertifications = this.getWriterUserCertificationByUserIds(userIds);
    if (ObjectUtil.isNull(progress)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TEACHER_CHECK, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    Integer count = 0;
    List<WriterUserCertification> wUserCertifications = new ArrayList<WriterUserCertification>(writerUserCertifications.size());
    List<WriterUser> writerUsers = new ArrayList<>();
    for (WriterUserCertification writerUserCertification : writerUserCertifications) {
        if (Const.WRITER_PROGRESS_0 == writerUserCertification.getProgress()) {
            throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "用户信息未提交,不能审核");
        }
        if (Const.WRITER_PROGRESS_2 == writerUserCertification.getProgress() || Const.WRITER_PROGRESS_3 == writerUserCertification.getProgress()) {
            throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "已审核的用户不能再次审核");
        }
        wUserCertifications.add(new WriterUserCertification(writerUserCertification.getUserId(), progress));
        writerUsers.add(new WriterUser(writerUserCertification.getUserId()));
    }
    if (CollectionUtil.isNotEmpty(wUserCertifications)) {
        // 教师审核通过的同时修改普通用户级别为教师
        count = writerUserCertificationDao.updateWriterUserCertificationProgressByUserId(wUserCertifications);
        List<WriterUser> list = writerUserService.getWriterUserRankList(writerUsers);
        for (WriterUser writerUser : list) {
            // 当级别为0并且是通过的时候修改
            if (0 == writerUser.getRank() && 3 == progress.intValue()) {
                for (WriterUser wrs : writerUsers) {
                    wrs.setRank(1);
                    wrs.setAuthUserType(1);
                    wrs.setAuthUserId(pmphuser.getId());
                    wrs.setIsTeacher(true);
                    writerUserService.updateWriterUserRank(wrs);
                }
            // 当级别为0并且是退回的时候修改
            } else if (0 == writerUser.getRank() && 2 == progress.intValue()) {
                for (WriterUser wrs : writerUsers) {
                    wrs.setAuthUserType(1);
                    wrs.setAuthUserId(pmphuser.getId());
                    wrs.setIsTeacher(false);
                    writerUserService.updateWriterUser(wrs);
                }
            // 当级别为1并且是通过的时候修改
            } else if (1 == writerUser.getRank() && 3 == progress.intValue()) {
                for (WriterUser wrs : writerUsers) {
                    wrs.setAuthUserType(1);
                    wrs.setAuthUserId(pmphuser.getId());
                    wrs.setIsTeacher(true);
                    writerUserService.updateWriterUserRank(wrs);
                }
            // 当级别为1并且是退回的时候修改
            } else if (1 == writerUser.getRank() && 2 == progress.intValue()) {
                for (WriterUser wrs : writerUsers) {
                    wrs.setAuthUserType(1);
                    wrs.setAuthUserId(pmphuser.getId());
                    wrs.setIsTeacher(false);
                    writerUserService.updateWriterUser(wrs);
                }
            // 当级别为2并且是通过的时候修改
            } else if (2 == writerUser.getRank() && 3 == progress.intValue()) {
                for (WriterUser wrs : writerUsers) {
                    wrs.setAuthUserType(1);
                    wrs.setAuthUserId(pmphuser.getId());
                    wrs.setIsTeacher(true);
                    writerUserService.updateWriterUserRank(wrs);
                }
            // 当级别为2并且是退回的时候修改
            } else if (2 == writerUser.getRank() && 2 == progress.intValue()) {
                for (WriterUser wrs : writerUsers) {
                    wrs.setAuthUserType(1);
                    wrs.setAuthUserId(pmphuser.getId());
                    wrs.setIsTeacher(false);
                    writerUserService.updateWriterUser(wrs);
                }
            // 当级别为3并且是通过的时候修改
            } else if (3 == writerUser.getRank() && 3 == progress.intValue()) {
                for (WriterUser wrs : writerUsers) {
                    wrs.setAuthUserType(1);
                    wrs.setAuthUserId(pmphuser.getId());
                    wrs.setIsTeacher(true);
                    writerUserService.updateWriterUserRank(wrs);
                }
            // 当级别为2并且是退回的时候修改
            } else if (3 == writerUser.getRank() && 2 == progress.intValue()) {
                for (WriterUser wrs : writerUsers) {
                    wrs.setAuthUserType(1);
                    wrs.setAuthUserId(pmphuser.getId());
                    wrs.setIsTeacher(false);
                    writerUserService.updateWriterUser(wrs);
                }
            }
        }
    }
    // 认证通过或退回的推送消息
    Boolean isPass = null;
    if (2 == progress) {
        isPass = false;
    }
    if (3 == progress) {
        isPass = true;
    }
    if (null != isPass) {
        List<Long> teacherIds = new ArrayList<>();
        for (int i = 0; i < userIds.length; i++) {
            teacherIds.add(userIds[0]);
        }
        // 获取用户认证类型和认证人
        List<WriterUser> users = writerUserService.getWriterUserList(userIds);
        for (WriterUser writerUser : users) {
            if (1 == writerUser.getAuthUserType()) {
                // 社内用户
                PmphUser pmphUser = pmphUserService.get(writerUser.getAuthUserId());
                systemMessageService.sendWhenTeacherCertificationAudit(pmphUser.getRealname(), teacherIds, isPass);
            }
            if (2 == writerUser.getAuthUserType()) {
                // 学校机构用户
                OrgUser orgUsers = orgUserService.getOrgUserById(writerUser.getAuthUserId());
                Org org = orgService.getOrgById(orgUsers.getOrgId());
                systemMessageService.sendWhenTeacherCertificationAudit(org.getOrgName(), teacherIds, isPass);
            }
        }
    }
    return count;
}
Also used : WriterUserCertification(com.bc.pmpheep.back.po.WriterUserCertification) PmphUser(com.bc.pmpheep.back.po.PmphUser) Org(com.bc.pmpheep.back.po.Org) OrgUser(com.bc.pmpheep.back.po.OrgUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) WriterUser(com.bc.pmpheep.back.po.WriterUser)

Aggregations

Org (com.bc.pmpheep.back.po.Org)9 OrgUser (com.bc.pmpheep.back.po.OrgUser)6 ArrayList (java.util.ArrayList)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 PmphUser (com.bc.pmpheep.back.po.PmphUser)2 WriterUser (com.bc.pmpheep.back.po.WriterUser)2 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)2 BaseTest (com.bc.pmpheep.test.BaseTest)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 Test (org.junit.Test)2 LogDetail (com.bc.pmpheep.annotation.LogDetail)1 DecPosition (com.bc.pmpheep.back.po.DecPosition)1 DecPositionPublished (com.bc.pmpheep.back.po.DecPositionPublished)1 Declaration (com.bc.pmpheep.back.po.Declaration)1 Material (com.bc.pmpheep.back.po.Material)1 MaterialOrg (com.bc.pmpheep.back.po.MaterialOrg)1 PmphDepartment (com.bc.pmpheep.back.po.PmphDepartment)1