Search in sources :

Example 41 with PmphUser

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

the class PmphGroupServiceImpl method addEditorSelcetionGroup.

@Override
public PmphGroup addEditorSelcetionGroup(String sessionId, List<PmphGroupMember> list, Long textbookId) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (list.size() == 0) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "成员名单为空,更新失败");
    }
    Textbook textbook = textbookService.getTextbookById(textbookId);
    list.get(0).setTextbookId(textbookId);
    list.get(0).setMaterialId(textbook.getMaterialId());
    // 未上传小组头像时,获取默认小组头像路径
    String groupImage = RouteUtil.DEFAULT_GROUP_IMAGE;
    PmphGroup pmphGroup = new PmphGroup();
    // 查询小组名称是否已存在 不存在直接用书名
    if (ObjectUtil.isNull(pmphGroupDao.getPmphGroupByGroupName(textbook.getTextbookName()))) {
        pmphGroup.setGroupName(textbook.getTextbookName());
    } else {
        // 存在则用书名加当前小组总数进行区分
        Long count = pmphGroupDao.getPmphGroupCount();
        pmphGroup.setGroupName(textbook.getTextbookName() + count);
    }
    pmphGroup.setGroupImage(groupImage);
    pmphGroup.setBookId(textbookId);
    pmphGroup.setFounderId(pmphUser.getId());
    pmphGroupDao.addPmphGroup(pmphGroup);
    if (null != pmphGroup.getId()) {
        // 判断是否新增小组成功,如果成功则调用PmphGroupMemberService添加小组成员的方法将创建者添加到小组中
        PmphGroupMember pmphGroupMember = new PmphGroupMember();
        pmphGroupMember.setGroupId(pmphGroup.getId());
        pmphGroupMember.setIsFounder(true);
        pmphGroupMember.setUserId(pmphUser.getId());
        pmphGroupMember.setDisplayName(pmphUser.getRealname());
        pmphGroupMemberService.addPmphGroupMember(pmphGroupMember);
        // 批量把前台传入的作家用户添加到该小组
        pmphGroupMemberService.addPmphGroupMemberOnGroup(pmphGroup.getId(), list, sessionId);
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.OBJECT_NOT_FOUND, "添加小组和成员失败");
    }
    return pmphGroup;
}
Also used : PmphGroupMember(com.bc.pmpheep.back.po.PmphGroupMember) PmphUser(com.bc.pmpheep.back.po.PmphUser) Textbook(com.bc.pmpheep.back.po.Textbook) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 42 with PmphUser

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

the class PmphGroupServiceImpl method listPmphGroupFile.

@Override
public List<PmphGroupListVO> listPmphGroupFile(PmphGroup pmphGroup, String sessionId) throws CheckedServiceException {
    if (null == pmphGroup) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "参数对象为空");
    }
    // session PmphUser用户验证
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    List<PmphGroupListVO> list = new ArrayList<>();
    list = pmphGroupDao.getList(pmphGroup, pmphUser.getId());
    for (PmphGroupListVO pmphGroupListVO : list) {
        pmphGroupListVO.setGroupImage(RouteUtil.groupImage(pmphGroupListVO.getGroupImage()));
    }
    return list;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PmphGroupListVO(com.bc.pmpheep.back.vo.PmphGroupListVO)

Example 43 with PmphUser

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

the class PmphUserServiceImpl method getListByUsernameAndRealname.

@Override
public PageResult<PmphUserManagerVO> getListByUsernameAndRealname(String name, int number, int size) throws CheckedServiceException {
    if (null == name || "".equals(name)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "模糊查询条件为空");
    }
    List<PmphUser> pmphUsers = pmphUserDao.getListByUsernameAndRealname(name, (number - 1) * size, size);
    PageResult<PmphUserManagerVO> page = new PageResult<>();
    page.setFirst(true);
    page.setLast(true);
    page.setPageNumber(number);
    page.setPageSize(size);
    if (!pmphUsers.isEmpty()) {
        List<PmphUserManagerVO> list = new ArrayList<>();
        for (PmphUser user : pmphUsers) {
            PmphUserManagerVO userVO = new PmphUserManagerVO();
            PmphDepartment department = pmphDepartmentDao.getPmphDepartmentById(user.getDepartmentId());
            if (null != department) {
                userVO.setDepartmentName(department.getDpName());
            }
            try {
                BeanUtils.copyProperties(userVO, user);
            } catch (BeansException ex) {
                throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.VO_CONVERSION_FAILED, ex.getMessage());
            }
            list.add(userVO);
        }
        page.setRows(list);
    }
    return page;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PmphUserManagerVO(com.bc.pmpheep.back.vo.PmphUserManagerVO) PageResult(com.bc.pmpheep.back.plugin.PageResult) PmphDepartment(com.bc.pmpheep.back.po.PmphDepartment) BeansException(org.springframework.beans.BeansException)

Example 44 with PmphUser

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

the class PmphUserServiceImpl method updatePassword.

@Override
public Integer updatePassword(HttpServletRequest request, String oldPassword, String newPassword) {
    // 获取当前用户
    String sessionId = CookiesUtil.getSessionId(request);
    PmphUser sessionPmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == sessionPmphUser) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
    }
    Long id = sessionPmphUser.getId();
    if (null == id) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "用户ID为空时禁止查询");
    }
    if (StringUtil.isEmpty(oldPassword)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "原密码为空");
    }
    if (StringUtil.isEmpty(newPassword)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "新密码为空");
    }
    oldPassword = oldPassword.trim();
    newPassword = newPassword.trim();
    if (newPassword.length() > 50) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.ILLEGAL_PARAM, "新密码长度不能超过50");
    }
    if (oldPassword.equals(newPassword)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.ILLEGAL_PARAM, "新旧密码不能一致");
    }
    // 先修改SSO
    // ---------------------------------
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", id);
    // 加密密码
    map.put("oldPassword", new DesRun("", oldPassword).enpsw);
    map.put("newPassword", new DesRun("", newPassword).enpsw);
    Integer res = pmphUserDao.updatePassword(map);
    if (null == res || res == 0) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "原密码错误");
    }
    return 1;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) HashMap(java.util.HashMap) DesRun(com.bc.pmpheep.back.util.DesRun) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 45 with PmphUser

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

the class PmphUserServiceImpl method getInfo.

/**
 * 根据主键 id 加载用户对象
 *
 * @param id
 * @return
 */
@Override
public PmphUser getInfo(HttpServletRequest request) throws CheckedServiceException {
    // 获取当前用户
    String sessionId = CookiesUtil.getSessionId(request);
    PmphUser sessionPmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == sessionPmphUser) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
    }
    Long id = sessionPmphUser.getId();
    if (ObjectUtil.isNull(id)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "用户ID为空时禁止查询");
    }
    PmphUser pmphUser = pmphUserDao.getInfo(id);
    if (null == pmphUser) {
        pmphUser = new PmphUser();
    }
    String avatar = pmphUser.getAvatar();
    pmphUser.setAvatar(RouteUtil.userAvatar(avatar));
    return pmphUser;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

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