feat: (REQ-3457) 创建与获取历史聊天用户接口添加
This commit is contained in:
parent
0d05adbeab
commit
7beffefba7
@ -29,7 +29,7 @@ public interface ChatUserApi {
|
||||
/**
|
||||
* 获取聊天用户记录
|
||||
*/
|
||||
@PostMapping("api/im/chat/user/queryChatUserHistory")
|
||||
ApiResult<List<QueryChatUserHistoryResp>> chatUserHistory(@RequestBody @Validated QueryChatUserHistoryReq req);
|
||||
@PostMapping("api/im/chat/user/searchChatUserHistory")
|
||||
ApiResult<List<QueryChatUserHistoryResp>> searchChatUserHistory(@RequestBody @Validated QueryChatUserHistoryReq req);
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package cn.axzo.im.center.api.vo.req.chatuser;
|
||||
|
||||
import cn.axzo.im.center.api.vo.req.ComplaintCreateReq;
|
||||
import cn.axzo.im.center.common.enums.WorkspaceOrOuEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -16,9 +18,54 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class CreateChatUserHistoryReq {
|
||||
|
||||
/**
|
||||
* 发送人IM账号
|
||||
*/
|
||||
private String senderImAccount;
|
||||
|
||||
/**
|
||||
* 发送人PersonId
|
||||
*/
|
||||
private Long sendPersonId;
|
||||
private Long senderPersonId;
|
||||
|
||||
/**
|
||||
* 发送人单位Id
|
||||
*/
|
||||
private Long senderOuId;
|
||||
|
||||
/**
|
||||
* 接收人IM账号
|
||||
*/
|
||||
private String receiverImAccount;
|
||||
|
||||
/**
|
||||
* 接收人personId
|
||||
*/
|
||||
private Long receiverPersonId;
|
||||
|
||||
/**
|
||||
* 接收人单位Id
|
||||
*/
|
||||
private Long receiverOuId;
|
||||
|
||||
/**
|
||||
* 接收人项目Id
|
||||
*/
|
||||
private Long receiverWorkspaceId;
|
||||
|
||||
/**
|
||||
* 接收人类型,WORKSPACE:项目;OU:单位
|
||||
*/
|
||||
private WorkspaceOrOuEnum receiverType;
|
||||
|
||||
/**
|
||||
* 类型,PRIVATE:私聊,GROUP:群聊
|
||||
*/
|
||||
private ComplaintCreateReq.ChatTypeEnum chatType;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long creator;
|
||||
|
||||
}
|
||||
|
||||
@ -20,4 +20,9 @@ public class QueryChatUserHistoryReq {
|
||||
* 发送人PersonId
|
||||
*/
|
||||
private Long sendPersonId;
|
||||
|
||||
/**
|
||||
* 发送人IM账号
|
||||
*/
|
||||
private String senderImAccount;
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package cn.axzo.im.center.api.vo.resp.chatuser;
|
||||
|
||||
import cn.axzo.im.center.api.vo.req.ComplaintCreateReq;
|
||||
import cn.axzo.im.center.common.enums.WorkspaceOrOuEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -16,9 +18,49 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class QueryChatUserHistoryResp {
|
||||
|
||||
/**
|
||||
* 发送人IM账号
|
||||
*/
|
||||
private String senderImAccount;
|
||||
|
||||
/**
|
||||
* 发送人PersonId
|
||||
*/
|
||||
private Long sendPersonId;
|
||||
private Long senderPersonId;
|
||||
|
||||
/**
|
||||
* 发送人单位Id
|
||||
*/
|
||||
private Long senderOuId;
|
||||
|
||||
/**
|
||||
* 接收人IM账号
|
||||
*/
|
||||
private String receiverImAccount;
|
||||
|
||||
/**
|
||||
* 接收人personId
|
||||
*/
|
||||
private Long receiverPersonId;
|
||||
|
||||
/**
|
||||
* 接收人单位Id
|
||||
*/
|
||||
private Long receiverOuId;
|
||||
|
||||
/**
|
||||
* 接收人项目Id
|
||||
*/
|
||||
private Long receiverWorkspaceId;
|
||||
|
||||
/**
|
||||
* 接收人类型,WORKSPACE:项目;OU:单位
|
||||
*/
|
||||
private WorkspaceOrOuEnum receiverType;
|
||||
|
||||
/**
|
||||
* 类型,PRIVATE:私聊,GROUP:群聊
|
||||
*/
|
||||
private ComplaintCreateReq.ChatTypeEnum chatType;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.axzo.im.center.common.enums;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
/**
|
||||
* 项目或者单位
|
||||
* @author xudawei@axzo.cn
|
||||
* @date 2024/12/30
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public enum WorkspaceOrOuEnum {
|
||||
|
||||
/**
|
||||
* 项目
|
||||
*/
|
||||
WORKSPACE("workspace", "项目"),
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
OU("ou", "单位")
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String message;
|
||||
|
||||
}
|
||||
@ -5,6 +5,7 @@ import cn.axzo.im.center.api.feign.ChatUserApi;
|
||||
import cn.axzo.im.center.api.vo.req.chatuser.CreateChatUserHistoryReq;
|
||||
import cn.axzo.im.center.api.vo.req.chatuser.QueryChatUserHistoryReq;
|
||||
import cn.axzo.im.center.api.vo.resp.chatuser.QueryChatUserHistoryResp;
|
||||
import cn.axzo.im.service.ChatUserHistoryService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
@ -23,14 +24,23 @@ import java.util.List;
|
||||
@RefreshScope
|
||||
public class ChatUserController implements ChatUserApi {
|
||||
|
||||
private final ChatUserHistoryService chatUserHistoryService;
|
||||
|
||||
/**
|
||||
* 创建历史聊天用户
|
||||
*/
|
||||
@Override
|
||||
public ApiResult<Void> createChatUserHistory(CreateChatUserHistoryReq req) {
|
||||
return null;
|
||||
chatUserHistoryService.create(req);
|
||||
return ApiResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询历史聊天用户
|
||||
*/
|
||||
@Override
|
||||
public ApiResult<List<QueryChatUserHistoryResp>> chatUserHistory(QueryChatUserHistoryReq req) {
|
||||
return null;
|
||||
public ApiResult<List<QueryChatUserHistoryResp>> searchChatUserHistory(QueryChatUserHistoryReq req) {
|
||||
List<QueryChatUserHistoryResp> list = chatUserHistoryService.searchChatUserHistory(req);
|
||||
return ApiResult.ok(list);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package cn.axzo.im.dao.mapper;
|
||||
|
||||
import cn.axzo.im.entity.ChatUserHistory;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author xudawei@axzo.cn
|
||||
* @date 2024/11/05
|
||||
* @desc 历史聊天用户
|
||||
*/
|
||||
public interface ChatUserHistoryMapper extends BaseMapper<ChatUserHistory> {
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
package cn.axzo.im.entity;
|
||||
|
||||
import cn.axzo.im.center.api.vo.req.ComplaintCreateReq;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 历史聊天用户
|
||||
* @author xudawei@axzo.cn
|
||||
* @date 2024/12/27
|
||||
*/
|
||||
@TableName("im_chat_user_history")
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ChatUserHistory implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 发送人IM账号
|
||||
*/
|
||||
@TableField("sender_im_account")
|
||||
private String senderImAccount;
|
||||
|
||||
/**
|
||||
* 发送人PersonId
|
||||
*/
|
||||
@TableField("sender_person_id")
|
||||
private Long senderPersonId;
|
||||
|
||||
/**
|
||||
* 发送人单位Id
|
||||
*/
|
||||
@TableField("sender_ou_id")
|
||||
private Long senderOuId;
|
||||
|
||||
/**
|
||||
* 接收人IM账号
|
||||
*/
|
||||
@TableField("receiver_im_account")
|
||||
private String receiverImAccount;
|
||||
|
||||
/**
|
||||
* 接收人personId
|
||||
*/
|
||||
@TableField("receiver_person_id")
|
||||
private Long receiverPersonId;
|
||||
|
||||
/**
|
||||
* 接收人单位Id
|
||||
*/
|
||||
@TableField("receiver_ou_id")
|
||||
private Long receiverOuId;
|
||||
|
||||
/**
|
||||
* 接收人项目Id
|
||||
*/
|
||||
@TableField("receiver_workspace_id")
|
||||
private Long receiverWorkspaceId;
|
||||
|
||||
/**
|
||||
* 接收人类型,WORKSPACE:项目;OU:单位
|
||||
*/
|
||||
@TableField("receiver_type")
|
||||
private ComplaintCreateReq.ChatTypeEnum receiverType;
|
||||
|
||||
/**
|
||||
* 类型,PRIVATE:私聊,GROUP:群聊
|
||||
*/
|
||||
@TableField("chat_type")
|
||||
private ComplaintCreateReq.ChatTypeEnum chatType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField("creator")
|
||||
private Long creator;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@TableField("is_delete")
|
||||
private Long isDelete;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_at")
|
||||
private Date createAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_at")
|
||||
private Date updateAt;
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.axzo.im.service;
|
||||
|
||||
import cn.axzo.im.center.api.vo.req.chatuser.CreateChatUserHistoryReq;
|
||||
import cn.axzo.im.center.api.vo.req.chatuser.QueryChatUserHistoryReq;
|
||||
import cn.axzo.im.center.api.vo.resp.chatuser.QueryChatUserHistoryResp;
|
||||
import cn.axzo.im.entity.ChatUserHistory;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xudawei@axzo.cn
|
||||
* @date 2024/12/27
|
||||
* @desc 历史聊天用户
|
||||
*/
|
||||
public interface ChatUserHistoryService extends IService<ChatUserHistory> {
|
||||
|
||||
/**
|
||||
* 创建历史聊天用户
|
||||
*/
|
||||
Boolean create(CreateChatUserHistoryReq req);
|
||||
|
||||
/**
|
||||
* 查询历史聊天用户
|
||||
*/
|
||||
List<QueryChatUserHistoryResp> searchChatUserHistory(QueryChatUserHistoryReq req);
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package cn.axzo.im.service.impl;
|
||||
|
||||
import cn.axzo.im.center.api.vo.req.chatuser.CreateChatUserHistoryReq;
|
||||
import cn.axzo.im.center.api.vo.req.chatuser.QueryChatUserHistoryReq;
|
||||
import cn.axzo.im.center.api.vo.resp.chatuser.QueryChatUserHistoryResp;
|
||||
import cn.axzo.im.dao.mapper.ChatUserHistoryMapper;
|
||||
import cn.axzo.im.entity.ChatUserHistory;
|
||||
import cn.axzo.im.service.ChatUserHistoryService;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xudawei@axzo.cn
|
||||
* @date 2024/11/05
|
||||
* @desc 历史聊天用户
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RefreshScope
|
||||
public class ChatUserHistoryServiceImpl extends ServiceImpl<ChatUserHistoryMapper, ChatUserHistory>
|
||||
implements ChatUserHistoryService {
|
||||
|
||||
/**
|
||||
* 创建历史聊天用户
|
||||
*/
|
||||
@Override
|
||||
public Boolean create(CreateChatUserHistoryReq req) {
|
||||
return this.saveOrUpdate(ChatUserHistory.builder()
|
||||
.senderImAccount(req.getSenderImAccount())
|
||||
.senderPersonId(req.getSenderPersonId())
|
||||
.senderOuId(req.getSenderOuId())
|
||||
.receiverImAccount(req.getReceiverImAccount())
|
||||
.receiverPersonId(req.getReceiverPersonId())
|
||||
.receiverOuId(req.getReceiverOuId())
|
||||
.receiverWorkspaceId(req.getReceiverWorkspaceId())
|
||||
.chatType(req.getChatType())
|
||||
.createAt(new Date())
|
||||
.updateAt(new Date())
|
||||
.creator(req.getCreator())
|
||||
.isDelete(0L)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询历史聊天用户
|
||||
*/
|
||||
@Override
|
||||
public List<QueryChatUserHistoryResp> searchChatUserHistory(QueryChatUserHistoryReq req) {
|
||||
List<ChatUserHistory> list = this.lambdaQuery()
|
||||
.eq(ChatUserHistory::getSenderImAccount, req.getSendPersonId())
|
||||
.list();
|
||||
return BeanUtil.copyToList(list, QueryChatUserHistoryResp.class);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user