Search in sources :

Example 51 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class UserMessageServiceImpl method listMyMessageOfIcon.

@Override
public PageResult<MyMessageVO> listMyMessageOfIcon(PageParameter<MyMessageVO> pageParameter) throws CheckedServiceException {
    if (ObjectUtil.isNull(pageParameter.getParameter().getUserId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户id为空!");
    }
    if (ObjectUtil.isNull(pageParameter.getParameter().getUserType())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户类型为空!");
    }
    PageResult<MyMessageVO> pageResult = new PageResult<MyMessageVO>();
    Integer total = userMessageDao.listMyMessageTotal(pageParameter);
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    if (total > 0) {
        List<MyMessageVO> list = userMessageDao.listMyMessage(pageParameter);
        for (MyMessageVO myMessageVO : list) {
            switch(myMessageVO.getSenderType()) {
                case 0:
                    myMessageVO.setSenderName("系统");
                    break;
                case 1:
                    PmphUser pmphUser = pmphUserService.get(myMessageVO.getSenderId());
                    myMessageVO.setSenderAvatar(pmphUser.getAvatar());
                    myMessageVO.setSenderName(pmphUser.getRealname());
                    break;
                case 2:
                    WriterUser writerUser = writerUserService.get(myMessageVO.getSenderId());
                    myMessageVO.setSenderAvatar(writerUser.getAvatar());
                    myMessageVO.setSenderName(writerUser.getRealname());
                    break;
                case 3:
                    // 现在没有机构用户
                    break;
                default:
                    throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "发送者类型不正确!");
            }
            Message message = messageService.get(myMessageVO.getMsgId());
            if (ObjectUtil.isNull(message)) {
                throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "没有获取到内容!");
            }
            myMessageVO.setContent(message.getContent());
        }
        pageResult.setRows(list);
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) PmphUser(com.bc.pmpheep.back.po.PmphUser) MyMessageVO(com.bc.pmpheep.back.vo.MyMessageVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) WriterUser(com.bc.pmpheep.back.po.WriterUser) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 52 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class UserMessageServiceImpl method listMyMessage.

@Override
public PageResult<MyMessageVO> listMyMessage(PageParameter<MyMessageVO> pageParameter) throws CheckedServiceException {
    if (ObjectUtil.isNull(pageParameter.getParameter().getUserId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户id为空!");
    }
    if (ObjectUtil.isNull(pageParameter.getParameter().getUserType())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户类型为空!");
    }
    PageResult<MyMessageVO> pageResult = new PageResult<MyMessageVO>();
    Integer total = userMessageDao.listMyMessageTotal(pageParameter);
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    if (total > 0) {
        List<MyMessageVO> list = userMessageDao.listMyMessage(pageParameter);
        for (MyMessageVO myMessageVO : list) {
            switch(myMessageVO.getSenderType()) {
                case 0:
                    myMessageVO.setSenderName("系统");
                    break;
                case 1:
                    PmphUser pmphUser = pmphUserService.get(myMessageVO.getSenderId());
                    myMessageVO.setSenderAvatar(pmphUser.getAvatar());
                    myMessageVO.setSenderName(pmphUser.getRealname());
                    break;
                case 2:
                    WriterUser writerUser = writerUserService.get(myMessageVO.getSenderId());
                    myMessageVO.setSenderAvatar(writerUser.getAvatar());
                    myMessageVO.setSenderName(writerUser.getRealname());
                    break;
                case 3:
                    // 现在没有机构用户
                    break;
                default:
                    throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "发送者类型不正确!");
            }
        }
        pageResult.setRows(list);
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) MyMessageVO(com.bc.pmpheep.back.vo.MyMessageVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) WriterUser(com.bc.pmpheep.back.po.WriterUser) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 53 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class UserMessageServiceImpl method addOneUserMessage.

@Override
public Integer addOneUserMessage(Message message, Long receiverId, String sessionId) throws CheckedServiceException, IOException {
    // 发送者id
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.OBJECT_NOT_FOUND, "发送人为空!");
    }
    // MongoDB 消息插入
    message = messageService.add(message);
    if (StringUtil.isEmpty(message.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.OBJECT_NOT_FOUND, "储存失败!");
    }
    // 新发消息,发送者Id为登陆用户ID
    Long senderUserId = pmphUser.getId();
    // 装储存数据
    UserMessage userMessage = new UserMessage();
    // 私信发送
    if (null == receiverId) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "接收人为空!");
    } else {
        userMessage = new UserMessage(message.getId(), "系统消息", Const.MSG_TYPE_0, senderUserId, Const.SENDER_TYPE_1, receiverId, Const.RECEIVER_TYPE_2);
    }
    // 插入消息发送对象数据
    Integer res = userMessageDao.addUserMessage(userMessage);
    // websocket发送的id
    List<String> websocketUserId = new ArrayList<String>();
    websocketUserId.add(userMessage.getReceiverType() + "_" + userMessage.getReceiverId());
    // webscokt发送消息
    if (CollectionUtil.isNotEmpty(websocketUserId)) {
        WebScocketMessage webScocketMessage = new WebScocketMessage(message.getId(), Const.MSG_TYPE_0, senderUserId, pmphUser.getRealname(), Const.SENDER_TYPE_1, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, message.getContent(), DateUtil.getCurrentTime());
        myWebSocketHandler.sendWebSocketMessageToUser(websocketUserId, webScocketMessage);
    }
    return res;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage)

Example 54 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class WriterPointLogServiceImpl method getListWriterPointLog.

@Override
public PageResult<WriterPointLogVO> getListWriterPointLog(PageParameter<WriterPointLogVO> pageParameter) throws CheckedServiceException {
    PageResult<WriterPointLogVO> pageResult = new PageResult<WriterPointLogVO>();
    // 开始时间
    String startTime = pageParameter.getParameter().getStartTime();
    // 结束时间
    String endTime = pageParameter.getParameter().getEndTime();
    Long userId = pageParameter.getParameter().getUserId();
    WriterPointLogVO writerPointLogVO = new WriterPointLogVO();
    if (StringUtil.isEmpty(startTime) && StringUtil.isEmpty(endTime)) {
        writerPointLogVO.setStartTime(null);
        writerPointLogVO.setEndTime(null);
    } else {
        writerPointLogVO.setStartTime(startTime + " 00:00:00");
        writerPointLogVO.setEndTime(endTime + " 23:59:59");
    }
    if (StringUtil.isEmpty(startTime) && StringUtil.notEmpty(endTime)) {
        writerPointLogVO.setStartTime(endTime + " 00:00:00");
        writerPointLogVO.setEndTime(endTime + " 23:59:59");
    } else if (StringUtil.isEmpty(endTime) && StringUtil.notEmpty(startTime)) {
        writerPointLogVO.setStartTime(startTime + " 00:00:00");
        writerPointLogVO.setEndTime(startTime + " 23:59:59");
    }
    if (ObjectUtil.notNull(userId)) {
        writerPointLogVO.setUserId(userId);
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_POINT_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    pageParameter.setParameter(writerPointLogVO);
    // 将页面大小和页面页码拷贝
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    // 包含数据总条数的数据集
    List<WriterPointLogVO> writerPointLogVOs = writerPointLogDao.listWriterPointLogVO(pageParameter);
    if (CollectionUtil.isNotEmpty(writerPointLogVOs)) {
        Integer count = writerPointLogVOs.get(0).getCount();
        pageResult.setTotal(count);
        pageResult.setRows(writerPointLogVOs);
    }
    return pageResult;
}
Also used : WriterPointLogVO(com.bc.pmpheep.back.vo.WriterPointLogVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 55 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class WriterPointLogServiceImpl method addWriterPointLogByRuleName.

@Override
public void addWriterPointLogByRuleName(String ruleName, Long userId) throws CheckedServiceException {
    if (StringUtil.isEmpty(ruleName)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_POINT_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "规则名称为空");
    }
    if (ObjectUtil.isNull(userId)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_POINT_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "作者Id为空");
    }
    // 获取积分规则
    WriterPointRule writerPointRuleVOs = writerPointRuleService.getWriterPointRuleByName(ruleName);
    if (null != writerPointRuleVOs) {
        if (writerPointRuleVOs.getIsDisabled() == false) {
            // 查询用户之前的积分值
            List<WriterPointLog> writerPointLog2 = this.getWriterPointLogByUserId(userId);
            WriterPointLog writerPointLog = new WriterPointLog();
            // 现在的规则的积分值+以前的积分
            // 获取的总积分
            Integer temp = 0;
            if (!writerPointLog2.isEmpty()) {
                // 以前的总积分
                Integer newTemp = 0;
                // 遍历以前获取的积分
                for (WriterPointLog writerPointLogNew : writerPointLog2) {
                    newTemp += writerPointLogNew.getPoint();
                }
                temp = writerPointRuleVOs.getPoint() + newTemp;
            } else {
                temp = writerPointRuleVOs.getPoint();
            }
            writerPointLog.setPoint(writerPointRuleVOs.getPoint());
            // 积分规则id
            writerPointLog.setRuleId(writerPointRuleVOs.getId());
            writerPointLog.setUserId(userId);
            // 增加积分记录
            this.add(writerPointLog);
            // 查询用户积分
            WriterPoint point = writerPointService.getWriterPointByUserId(userId);
            if (ObjectUtil.notNull(point)) {
                writerPointService.updateWriterPoint(new WriterPoint(point.getId(), userId, temp + point.getLoss(), temp, point.getLoss()));
            } else {
                writerPointService.addWriterPoint(new WriterPoint(userId, temp, temp, 0));
            }
        }
    }
}
Also used : CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) WriterPointRule(com.bc.pmpheep.back.po.WriterPointRule) WriterPointLog(com.bc.pmpheep.back.po.WriterPointLog) WriterPoint(com.bc.pmpheep.back.po.WriterPoint)

Aggregations

CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)208 PmphUser (com.bc.pmpheep.back.po.PmphUser)81 ArrayList (java.util.ArrayList)73 PageResult (com.bc.pmpheep.back.plugin.PageResult)33 Material (com.bc.pmpheep.back.po.Material)30 IOException (java.io.IOException)30 HashMap (java.util.HashMap)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)25 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)24 Workbook (org.apache.poi.ss.usermodel.Workbook)23 UserMessage (com.bc.pmpheep.back.po.UserMessage)22 LogDetail (com.bc.pmpheep.annotation.LogDetail)20 Message (com.bc.pmpheep.general.po.Message)20 Textbook (com.bc.pmpheep.back.po.Textbook)18 WriterUser (com.bc.pmpheep.back.po.WriterUser)17 OutputStream (java.io.OutputStream)17 CmsContent (com.bc.pmpheep.back.po.CmsContent)16 BufferedOutputStream (java.io.BufferedOutputStream)16 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)14 UnsupportedEncodingException (java.io.UnsupportedEncodingException)14