Search in sources :

Example 6 with OrgUser

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

the class SsoHelperTest method createSSOAccount.

@Test
public void createSSOAccount() {
    // SSO已存在该账号,理应报错
    OrgUser orgUser = new OrgUser("gugia", "123");
    String msg = ssoHelper.createSSOAccount(orgUser);
    logger.info(msg);
    Assert.assertFalse(msg.equals("success"));
}
Also used : OrgUser(com.bc.pmpheep.back.po.OrgUser) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 7 with OrgUser

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

the class OrgUserServiceImpl method resetPassword.

@Override
public String resetPassword(Long id) throws CheckedServiceException {
    if (ObjectUtil.isNull(id)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.ORG, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    String password = "123456";
    OrgUser orgUser = orgUserDao.getOrgUserById(id);
    DesRun desRun = new DesRun(orgUser.getUsername(), password);
    orgUser.setPassword(desRun.enpsw);
    orgUserDao.updateOrgUser(orgUser);
    return password;
}
Also used : OrgUser(com.bc.pmpheep.back.po.OrgUser) DesRun(com.bc.pmpheep.back.util.DesRun) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 8 with OrgUser

use of com.bc.pmpheep.back.po.OrgUser 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 9 with OrgUser

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

the class OrgUserServiceImpl method updateOrgUserProgressById.

@Override
public Integer updateOrgUserProgressById(Integer progress, List<Long> orgUserIds) throws CheckedServiceException, IOException {
    if (CollectionUtil.isEmpty(orgUserIds) || ObjectUtil.isNull(progress)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.SCHOOL_ADMIN_CHECK, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    List<OrgUser> orgUserList = orgUserDao.getOrgUserByIds(orgUserIds);
    Integer count = 0;
    if (CollectionUtil.isNotEmpty(orgUserList)) {
        List<OrgUser> orgUsers = new ArrayList<OrgUser>(orgUserList.size());
        for (OrgUser orgUser : orgUserList) {
            if (Const.ORG_USER_PROGRESS_1 == orgUser.getProgress() || Const.ORG_USER_PROGRESS_2 == orgUser.getProgress()) {
                throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "已审核的用户不能再次审核");
            }
            orgUsers.add(new OrgUser(orgUser.getId(), progress));
        }
        if (CollectionUtil.isNotEmpty(orgUsers)) {
            count = orgUserDao.updateOrgUserProgressById(orgUsers);
        }
    }
    Boolean isPass = null;
    if (1 == progress) {
        isPass = true;
    }
    if (2 == progress) {
        isPass = false;
    }
    if (null != isPass) {
        // 推送机构认证审核信息
        systemMessageService.sendWhenManagerCertificationAudit(orgUserIds, isPass);
    }
    return count;
}
Also used : OrgUser(com.bc.pmpheep.back.po.OrgUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 10 with OrgUser

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

the class UserMessageServiceImpl method getUserMessageById.

@Override
public Map<String, Object> getUserMessageById(Long userMsgId) {
    Map<String, Object> resultMap = new HashMap<String, Object>();
    if (ObjectUtil.isNull(userMsgId)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "消息ID为空!");
    }
    UserMessage userMessage = userMessageDao.getUserMessageById(userMsgId);
    if (ObjectUtil.isNull(userMessage)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户消息对象为空!");
    }
    String realName = null;
    if (Const.SENDER_TYPE_0 == userMessage.getSenderType() || Const.SENDER_TYPE_1 == userMessage.getSenderType()) {
        PmphUser pmphUser = pmphUserService.get(userMessage.getSenderId());
        realName = pmphUser.getRealname();
    }
    if (Const.SENDER_TYPE_2 == userMessage.getSenderType()) {
        WriterUser writerUser = writerUserService.get(userMessage.getSenderId());
        realName = writerUser.getRealname();
    }
    if (Const.SENDER_TYPE_3 == userMessage.getSenderType()) {
        OrgUser orgUser = orgUserService.getOrgUserById(userMessage.getSenderId());
        realName = orgUser.getRealname();
    }
    // 主键ID
    resultMap.put("msgId", userMessage.getId());
    // 标题
    resultMap.put("title", userMessage.getTitle());
    // 发送者
    resultMap.put("senderName", realName);
    // 发送时间
    resultMap.put("senderDate", userMessage.getGmtCreate());
    // 获取消息内容
    Message message = messageService.get(userMessage.getMsgId());
    if (ObjectUtil.notNull(message)) {
        // throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE,
        // CheckedExceptionResult.NULL_PARAM, "消息对象为空!");
        // 内容
        resultMap.put("content", message.getContent());
        List<MessageAttachment> messageAttachments = messageAttachmentService.getMessageAttachmentByMsgId(message.getId());
        if (CollectionUtil.isNotEmpty(messageAttachments)) {
            for (MessageAttachment mAttachment : messageAttachments) {
                String attachmentId = mAttachment.getAttachment();
                mAttachment.setAttachment(Const.FILE_DOWNLOAD + attachmentId);
            }
        }
        // 内容附件
        resultMap.put("MessageAttachment", messageAttachments);
    }
    return resultMap;
}
Also used : MessageAttachment(com.bc.pmpheep.back.po.MessageAttachment) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) HashMap(java.util.HashMap) PmphUser(com.bc.pmpheep.back.po.PmphUser) OrgUser(com.bc.pmpheep.back.po.OrgUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UserMessage(com.bc.pmpheep.back.po.UserMessage) WriterUser(com.bc.pmpheep.back.po.WriterUser)

Aggregations

OrgUser (com.bc.pmpheep.back.po.OrgUser)18 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)11 ArrayList (java.util.ArrayList)10 UserMessage (com.bc.pmpheep.back.po.UserMessage)8 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)8 Message (com.bc.pmpheep.general.po.Message)7 Org (com.bc.pmpheep.back.po.Org)6 WriterUser (com.bc.pmpheep.back.po.WriterUser)6 PmphUser (com.bc.pmpheep.back.po.PmphUser)5 Declaration (com.bc.pmpheep.back.po.Declaration)4 Material (com.bc.pmpheep.back.po.Material)4 BaseTest (com.bc.pmpheep.test.BaseTest)4 Test (org.junit.Test)4 DecPosition (com.bc.pmpheep.back.po.DecPosition)2 Textbook (com.bc.pmpheep.back.po.Textbook)2 DesRun (com.bc.pmpheep.back.util.DesRun)2 Timestamp (java.sql.Timestamp)2 HashMap (java.util.HashMap)2 DecPositionPublished (com.bc.pmpheep.back.po.DecPositionPublished)1 MessageAttachment (com.bc.pmpheep.back.po.MessageAttachment)1