| | |
| | | public IPage<MsgListVo> getMsgList(MsgListDto msgListDto) { |
| | | MemberEntity member = LoginUserUtils.getAppLoginUser(); |
| | | Long memberId = member.getId(); |
| | | // Long memberId = 445L; |
| | | // Long memberId = 443L; |
| | | Page<MsgListVo> page = new Page<>(msgListDto.getPageNum(), msgListDto.getPageSize()); |
| | | |
| | | OtcMsgUserListEntity otcMsgUserListEntity = new OtcMsgUserListEntity(); |
| | |
| | | if(CollUtil.isNotEmpty(records)){ |
| | | for(MsgListVo msgListVo : records){ |
| | | long targetId = msgListVo.getTargetId(); |
| | | if(memberId == targetId){ |
| | | MemberEntity memberEntity = memberDao.selectById(msgListVo.getMemberId()); |
| | | msgListVo.setNickname(memberEntity.getName()); |
| | | }else{ |
| | | MemberEntity memberEntity = memberDao.selectById(targetId); |
| | | msgListVo.setNickname(memberEntity.getName()); |
| | | } |
| | | } |
| | | } |
| | | return msgList; |
| | |
| | | otcMsgHistoryEntity.setMemberId(memberId); |
| | | otcMsgHistoryEntity.setTargetId(targetId); |
| | | IPage<ChatBoxVo> chatBoxVos= otcMsgHistoryDao.getChatBoxMsgList(page,otcMsgHistoryEntity); |
| | | List<ChatBoxVo> records = chatBoxVos.getRecords(); |
| | | if(CollUtil.isNotEmpty(records)){ |
| | | for(ChatBoxVo chatBoxVo : records){ |
| | | long memberIds = chatBoxVo.getMemberId(); |
| | | if(memberIds == member.getId()){ |
| | | chatBoxVo.setIsSelf(1); |
| | | }else{ |
| | | chatBoxVo.setIsSelf(2); |
| | | } |
| | | } |
| | | } |
| | | // List<ChatBoxVo> records = chatBoxVos.getRecords(); |
| | | // if(CollUtil.isNotEmpty(records)){ |
| | | // for(ChatBoxVo chatBoxVo : records){ |
| | | // long memberIds = chatBoxVo.getMemberId(); |
| | | // if(memberIds == member.getId()){ |
| | | // chatBoxVo.setIsSelf(1); |
| | | // }else{ |
| | | // chatBoxVo.setIsSelf(2); |
| | | // } |
| | | // } |
| | | // } |
| | | return Result.ok(chatBoxVos); |
| | | } |
| | | |
| | |
| | | public Result sendMsg(SendMsgDto sendMsgDto) { |
| | | MemberEntity member = LoginUserUtils.getAppLoginUser(); |
| | | Long memberId = member.getId(); |
| | | // Long memberId = 445L; |
| | | // Long memberId = 449L; |
| | | long targetId = sendMsgDto.getTargetId(); |
| | | if(ObjectUtil.isEmpty(targetId)){ |
| | | return Result.fail("对话用户不存在"); |
| | |
| | | // objectQueryWrapper.eq("member_id",memberId); |
| | | // objectQueryWrapper.eq("target_id",targetId); |
| | | // OtcMsgUserListEntity otcMsgUserListEntity = otcMsgUserListDao.selectById(objectQueryWrapper); |
| | | List<OtcMsgUserListEntity> otcMsgUserListEntitys = otcMsgUserListDao.selectListByMemberIdAndTargetId(memberId,targetId); |
| | | if(CollUtil.isEmpty(otcMsgUserListEntitys)){ |
| | | //发送方 |
| | | List<OtcMsgUserListEntity> otcMsgUserListEntityFrom = otcMsgUserListDao.selectListByMemberIdAndTargetId(memberId,targetId); |
| | | if(CollUtil.isEmpty(otcMsgUserListEntityFrom)){ |
| | | OtcMsgUserListEntity otcMsgUserListEntity = new OtcMsgUserListEntity(); |
| | | otcMsgUserListEntity.setMemberId(memberId); |
| | | otcMsgUserListEntity.setTargetId(targetId); |
| | | otcMsgUserListEntity.setIsRead(OtcMsgUserListEntity.ISREAD_TWO); |
| | | otcMsgUserListEntity.setLastMsgTime(DateUtil.date()); |
| | | otcMsgUserListDao.insert(otcMsgUserListEntity); |
| | | }else{ |
| | | OtcMsgUserListEntity otcMsgUserListEntity = otcMsgUserListEntityFrom.get(0); |
| | | otcMsgUserListEntity.setMemberId(memberId); |
| | | otcMsgUserListEntity.setTargetId(targetId); |
| | | otcMsgUserListEntity.setIsRead(OtcMsgUserListEntity.ISREAD_TWO); |
| | | otcMsgUserListEntity.setLastMsgTime(DateUtil.date()); |
| | | otcMsgUserListDao.updateById(otcMsgUserListEntity); |
| | | } |
| | | //历史消息中增加新纪录 |
| | | OtcMsgHistoryEntity otcMsgHistoryEntityFrom = new OtcMsgHistoryEntity(); |
| | | otcMsgHistoryEntityFrom.setMemberId(memberId); |
| | | otcMsgHistoryEntityFrom.setFromMemberId(memberId); |
| | | otcMsgHistoryEntityFrom.setTargetId(targetId); |
| | | otcMsgHistoryEntityFrom.setMsg(msg); |
| | | otcMsgHistoryEntityFrom.setMsgType(msgType); |
| | | otcMsgHistoryEntityFrom.setIsSelf(OtcMsgHistoryEntity.ISSELF_ONE); |
| | | otcMsgHistoryDao.insert(otcMsgHistoryEntityFrom); |
| | | //接受方 |
| | | List<OtcMsgUserListEntity> otcMsgUserListEntityTo = otcMsgUserListDao.selectListByMemberIdAndTargetId(targetId,memberId); |
| | | if(CollUtil.isEmpty(otcMsgUserListEntityTo)){ |
| | | OtcMsgUserListEntity otcMsgUserListEntity = new OtcMsgUserListEntity(); |
| | | otcMsgUserListEntity.setMemberId(targetId); |
| | | otcMsgUserListEntity.setTargetId(memberId); |
| | | otcMsgUserListEntity.setIsRead(OtcMsgUserListEntity.ISREAD_ONE); |
| | | otcMsgUserListEntity.setLastMsgTime(DateUtil.date()); |
| | | otcMsgUserListDao.insert(otcMsgUserListEntity); |
| | | }else{ |
| | | OtcMsgUserListEntity otcMsgUserListEntity = otcMsgUserListEntitys.get(0); |
| | | otcMsgUserListEntity.setMemberId(memberId); |
| | | otcMsgUserListEntity.setTargetId(targetId); |
| | | OtcMsgUserListEntity otcMsgUserListEntity = otcMsgUserListEntityTo.get(0); |
| | | otcMsgUserListEntity.setMemberId(targetId); |
| | | otcMsgUserListEntity.setTargetId(memberId); |
| | | otcMsgUserListEntity.setIsRead(OtcMsgUserListEntity.ISREAD_ONE); |
| | | otcMsgUserListEntity.setLastMsgTime(DateUtil.date()); |
| | | otcMsgUserListDao.updateById(otcMsgUserListEntity); |
| | | } |
| | | |
| | | //历史消息中增加新纪录 |
| | | OtcMsgHistoryEntity otcMsgHistoryEntity = new OtcMsgHistoryEntity(); |
| | | otcMsgHistoryEntity.setMemberId(memberId); |
| | | otcMsgHistoryEntity.setTargetId(targetId); |
| | | otcMsgHistoryEntity.setMsg(msg); |
| | | otcMsgHistoryEntity.setMsgType(msgType); |
| | | otcMsgHistoryDao.insert(otcMsgHistoryEntity); |
| | | OtcMsgHistoryEntity otcMsgHistoryEntityTo = new OtcMsgHistoryEntity(); |
| | | otcMsgHistoryEntityTo.setMemberId(targetId); |
| | | otcMsgHistoryEntityTo.setFromMemberId(memberId); |
| | | otcMsgHistoryEntityTo.setTargetId(targetId); |
| | | otcMsgHistoryEntityTo.setMsg(msg); |
| | | otcMsgHistoryEntityTo.setMsgType(msgType); |
| | | otcMsgHistoryEntityTo.setIsSelf(OtcMsgHistoryEntity.ISSELF_TWO); |
| | | otcMsgHistoryDao.insert(otcMsgHistoryEntityTo); |
| | | |
| | | //增加一个提醒的 |
| | | MemberSettingEntity memberSettingEntity = memberSettingDao.selectMemberSettingByMemberId(targetId); |
| | |
| | | otcMsgHistoryEntity.setMemberId(memberId); |
| | | otcMsgHistoryEntity.setTargetId(targetId); |
| | | chatBoxVos = otcMsgHistoryDao.getChatBoxMsgList(page,otcMsgHistoryEntity); |
| | | List<ChatBoxVo> records = chatBoxVos.getRecords(); |
| | | if(CollUtil.isNotEmpty(records)){ |
| | | for(ChatBoxVo chatBoxVo : records){ |
| | | long memberIds = chatBoxVo.getMemberId(); |
| | | if(memberIds == memberId){ |
| | | chatBoxVo.setIsSelf(1); |
| | | }else{ |
| | | chatBoxVo.setIsSelf(2); |
| | | } |
| | | } |
| | | } |
| | | // List<ChatBoxVo> records = chatBoxVos.getRecords(); |
| | | // if(CollUtil.isNotEmpty(records)){ |
| | | // for(ChatBoxVo chatBoxVo : records){ |
| | | // long memberIds = chatBoxVo.getMemberId(); |
| | | // if(memberIds == memberId){ |
| | | // chatBoxVo.setIsSelf(1); |
| | | // }else{ |
| | | // chatBoxVo.setIsSelf(2); |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | return Result.ok(chatBoxVos); |
| | | } |