xiaoyong931011
2021-05-26 4ac2bde488291508f3535fdee690c3189aa5a8ba
20210526  聊天
1 files added
4 files modified
78 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/otc/controller/OtcMsgController.java 18 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/otc/dto/ChatBoxDto.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/otc/dto/ConnectDto.java 20 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/otc/service/OtcMsgService.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMsgServiceImpl.java 34 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/otc/controller/OtcMsgController.java
@@ -2,14 +2,10 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.modules.otc.dto.ChatBoxDto;
import com.xcong.excoin.modules.otc.dto.MsgListDto;
import com.xcong.excoin.modules.otc.dto.OrderListDto;
import com.xcong.excoin.modules.otc.dto.SendMsgDto;
import com.xcong.excoin.modules.otc.dto.*;
import com.xcong.excoin.modules.otc.service.OtcMsgService;
import com.xcong.excoin.modules.otc.vo.ChatBoxVo;
import com.xcong.excoin.modules.otc.vo.MsgListVo;
import com.xcong.excoin.modules.otc.vo.OrderListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
@@ -46,6 +42,18 @@
    }
    /**
     * 联系卖家或者联系买家
     */
    @ApiOperation(value = "联系卖家或者联系买家")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = ChatBoxVo.class)
    })
    @PostMapping(value = "/getChatBoxConnect")
    public Result getChatBoxConnect(@RequestBody ConnectDto connectDto) {
        return otcMsgService.getChatBoxConnect(connectDto);
    }
    /**
     * 进入聊天框,获取聊天记录
     */
    @ApiOperation(value = "进入聊天框,获取聊天记录")
src/main/java/com/xcong/excoin/modules/otc/dto/ChatBoxDto.java
@@ -16,4 +16,7 @@
    @ApiModelProperty(value = "ID", example = "1")
    private long id;
    @ApiModelProperty(value = "目标ID", example = "1")
    private long targetId;
}
src/main/java/com/xcong/excoin/modules/otc/dto/ConnectDto.java
New file
@@ -0,0 +1,20 @@
package com.xcong.excoin.modules.otc.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "ConnectDto", description = "参数接收类")
public class ConnectDto {
    @ApiModelProperty(value = "条数", example = "10")
    private Integer pageSize;
    @ApiModelProperty(value = "页码", example = "1")
    private Integer pageNum;
    @ApiModelProperty(value = "目标ID", example = "1")
    private long targetId;
}
src/main/java/com/xcong/excoin/modules/otc/service/OtcMsgService.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.modules.otc.dto.ChatBoxDto;
import com.xcong.excoin.modules.otc.dto.ConnectDto;
import com.xcong.excoin.modules.otc.dto.MsgListDto;
import com.xcong.excoin.modules.otc.dto.SendMsgDto;
import com.xcong.excoin.modules.otc.entity.OtcMsgUserListEntity;
@@ -17,4 +18,6 @@
    Result getChatBox(ChatBoxDto chatBoxDto);
    Result sendMsg(SendMsgDto sendMsgDto);
    Result getChatBoxConnect(ConnectDto connectDto);
}
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMsgServiceImpl.java
@@ -16,6 +16,7 @@
import com.xcong.excoin.modules.otc.dao.OtcMsgHistoryDao;
import com.xcong.excoin.modules.otc.dao.OtcMsgUserListDao;
import com.xcong.excoin.modules.otc.dto.ChatBoxDto;
import com.xcong.excoin.modules.otc.dto.ConnectDto;
import com.xcong.excoin.modules.otc.dto.MsgListDto;
import com.xcong.excoin.modules.otc.dto.SendMsgDto;
import com.xcong.excoin.modules.otc.entity.OtcMsgHistoryEntity;
@@ -171,5 +172,38 @@
        return Result.ok("发送成功");
    }
    @Override
    public Result getChatBoxConnect(ConnectDto connectDto) {
        MemberEntity member = LoginUserUtils.getAppLoginUser();
        Long memberId = member.getId();
//        Long memberId = 443L;
        long targetId = connectDto.getTargetId();
        if(ObjectUtil.isEmpty(targetId)){
            return Result.fail("请返回重试");
        }
        IPage<ChatBoxVo> chatBoxVos= new Page<>();
        List<OtcMsgUserListEntity> otcMsgUserListEntitys = otcMsgUserListDao.selectListByMemberIdAndTargetId(memberId,targetId);
        if(CollUtil.isNotEmpty(otcMsgUserListEntitys)){
            Page<ChatBoxVo> page = new Page<>(connectDto.getPageNum(), connectDto.getPageSize());
            OtcMsgHistoryEntity otcMsgHistoryEntity = new OtcMsgHistoryEntity();
            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);
                    }
                }
            }
        }
        return Result.ok(chatBoxVos);
    }
}