即时通信嵌入开发完成,期待下次开发将ui嵌入navbar中,以及完成拉起群聊以及群聊系统开发
This commit is contained in:
@@ -42,7 +42,6 @@ public class SocketContactController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询通信目录列表
|
* 查询通信目录列表
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:contact:list")
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<SocketContactVo> list(SocketContactBo bo, PageQuery pageQuery) {
|
public TableDataInfo<SocketContactVo> list(SocketContactBo bo, PageQuery pageQuery) {
|
||||||
return iSocketContactService.queryPageList(bo, pageQuery);
|
return iSocketContactService.queryPageList(bo, pageQuery);
|
||||||
@@ -51,7 +50,6 @@ public class SocketContactController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 导出通信目录列表
|
* 导出通信目录列表
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:contact:export")
|
|
||||||
@Log(title = "通信目录", businessType = BusinessType.EXPORT)
|
@Log(title = "通信目录", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(SocketContactBo bo, HttpServletResponse response) {
|
public void export(SocketContactBo bo, HttpServletResponse response) {
|
||||||
@@ -64,17 +62,16 @@ public class SocketContactController extends BaseController {
|
|||||||
*
|
*
|
||||||
* @param id 主键
|
* @param id 主键
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:contact:query")
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public R<SocketContactVo> getInfo(@NotNull(message = "主键不能为空")
|
public R<SocketContactVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
@PathVariable Long id) {
|
@PathVariable Long id) {
|
||||||
return R.ok(iSocketContactService.queryById(id));
|
return R.ok(iSocketContactService.queryById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增通信目录
|
* 新增通信目录
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:contact:add")
|
|
||||||
@Log(title = "通信目录", businessType = BusinessType.INSERT)
|
@Log(title = "通信目录", businessType = BusinessType.INSERT)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
@@ -85,7 +82,6 @@ public class SocketContactController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改通信目录
|
* 修改通信目录
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:contact:edit")
|
|
||||||
@Log(title = "通信目录", businessType = BusinessType.UPDATE)
|
@Log(title = "通信目录", businessType = BusinessType.UPDATE)
|
||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PutMapping()
|
@PutMapping()
|
||||||
@@ -98,7 +94,6 @@ public class SocketContactController extends BaseController {
|
|||||||
*
|
*
|
||||||
* @param ids 主键串
|
* @param ids 主键串
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("system:contact:remove")
|
|
||||||
@Log(title = "通信目录", businessType = BusinessType.DELETE)
|
@Log(title = "通信目录", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.core.validate.AddGroup;
|
||||||
|
import com.ruoyi.common.core.validate.EditGroup;
|
||||||
|
import com.ruoyi.common.core.validate.QueryGroup;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.system.domain.vo.SocketMessageVo;
|
||||||
|
import com.ruoyi.system.domain.bo.SocketMessageBo;
|
||||||
|
import com.ruoyi.system.service.ISocketMessageService;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话信息
|
||||||
|
*
|
||||||
|
* @author hdka
|
||||||
|
* @date 2024-10-27
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/message")
|
||||||
|
public class SocketMessageController extends BaseController {
|
||||||
|
|
||||||
|
private final ISocketMessageService iSocketMessageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询对话信息列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<SocketMessageVo> list(SocketMessageBo bo, PageQuery pageQuery) {
|
||||||
|
return iSocketMessageService.queryPageList(bo, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出对话信息列表
|
||||||
|
*/
|
||||||
|
@Log(title = "对话信息", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(SocketMessageBo bo, HttpServletResponse response) {
|
||||||
|
List<SocketMessageVo> list = iSocketMessageService.queryList(bo);
|
||||||
|
ExcelUtil.exportExcel(list, "对话信息", SocketMessageVo.class, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对话信息详细信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public R<SocketMessageVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable Long id) {
|
||||||
|
return R.ok(iSocketMessageService.queryById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增对话信息
|
||||||
|
*/
|
||||||
|
@Log(title = "对话信息", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody SocketMessageBo bo) {
|
||||||
|
return toAjax(iSocketMessageService.insertByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改对话信息
|
||||||
|
*/
|
||||||
|
@Log(title = "对话信息", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SocketMessageBo bo) {
|
||||||
|
return toAjax(iSocketMessageService.updateByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除对话信息
|
||||||
|
*
|
||||||
|
* @param ids 主键串
|
||||||
|
*/
|
||||||
|
@Log(title = "对话信息", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable Long[] ids) {
|
||||||
|
return toAjax(iSocketMessageService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ public class SocketContact extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 通信id
|
* 通信id
|
||||||
*/
|
*/
|
||||||
@TableId(value = "id")
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 用户id
|
* 用户id
|
||||||
@@ -44,5 +44,9 @@ public class SocketContact extends BaseEntity {
|
|||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
/**
|
||||||
|
* 房间号
|
||||||
|
*/
|
||||||
|
private Long roomId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话信息对象 socket_message
|
||||||
|
*
|
||||||
|
* @author hdka
|
||||||
|
* @date 2024-10-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("socket_message")
|
||||||
|
public class SocketMessage extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 接收者id
|
||||||
|
*/
|
||||||
|
private Long contactId;
|
||||||
|
/**
|
||||||
|
* 发送者id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 发送信息内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
/**
|
||||||
|
* 房间号(针对群聊开发)
|
||||||
|
*/
|
||||||
|
private Long roomId;
|
||||||
|
/**
|
||||||
|
* 删除标志
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Long delFlag;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.system.domain.bo;
|
package com.ruoyi.system.domain.bo;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.validate.AddGroup;
|
import com.ruoyi.common.core.validate.AddGroup;
|
||||||
import com.ruoyi.common.core.validate.EditGroup;
|
import com.ruoyi.common.core.validate.EditGroup;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -7,6 +8,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
@@ -42,11 +44,18 @@ public class SocketContactBo extends BaseEntity {
|
|||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class })
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/** 用户名 */
|
/** 用户名 */
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 房间号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "房间号不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private Long roomId;
|
||||||
|
|
||||||
|
private List<SysUser> userList;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.ruoyi.system.domain.bo;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.validate.AddGroup;
|
||||||
|
import com.ruoyi.common.core.validate.EditGroup;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话信息业务对象 socket_message
|
||||||
|
*
|
||||||
|
* @author hdka
|
||||||
|
* @date 2024-10-27
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SocketMessageBo extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "主键id不能为空", groups = { EditGroup.class })
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收者id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "接收者id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private Long contactId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送者id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "发送者id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送信息内容
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "发送信息内容不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 房间号(针对群聊开发)
|
||||||
|
*/
|
||||||
|
@NotNull(message = "房间号(针对群聊开发)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private Long roomId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import com.ruoyi.common.convert.ExcelDictConvert;
|
|||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,4 +52,15 @@ public class SocketContactVo {
|
|||||||
private SysUser user;
|
private SysUser user;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话信息表
|
||||||
|
*/
|
||||||
|
private List<SocketMessageVo> messages;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 房间号
|
||||||
|
*/
|
||||||
|
private Long roomId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.ruoyi.system.domain.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||||
|
import com.ruoyi.common.convert.ExcelDictConvert;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话信息视图对象 socket_message
|
||||||
|
*
|
||||||
|
* @author hdka
|
||||||
|
* @date 2024-10-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class SocketMessageVo {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "主键id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收者id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "接收者id")
|
||||||
|
private Long contactId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送者id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "发送者id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送信息内容
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "发送信息内容")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 房间号(针对群聊开发)
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "房间号", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(readConverterExp = "针=对群聊开发")
|
||||||
|
private Long roomId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.system.domain.SocketMessage;
|
||||||
|
import com.ruoyi.system.domain.vo.SocketMessageVo;
|
||||||
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话信息Mapper接口
|
||||||
|
*
|
||||||
|
* @author hdka
|
||||||
|
* @date 2024-10-27
|
||||||
|
*/
|
||||||
|
public interface SocketMessageMapper extends BaseMapperPlus<SocketMessageMapper, SocketMessage, SocketMessageVo> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -37,6 +37,11 @@ public interface ISocketContactService {
|
|||||||
*/
|
*/
|
||||||
Boolean insertByBo(SocketContactBo bo);
|
Boolean insertByBo(SocketContactBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增通信群聊目录
|
||||||
|
*/
|
||||||
|
Boolean insertByBoAndRoom(SocketContactBo bo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改通信目录
|
* 修改通信目录
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
|
import com.ruoyi.system.domain.SocketMessage;
|
||||||
|
import com.ruoyi.system.domain.vo.SocketMessageVo;
|
||||||
|
import com.ruoyi.system.domain.bo.SocketMessageBo;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话信息Service接口
|
||||||
|
*
|
||||||
|
* @author hdka
|
||||||
|
* @date 2024-10-27
|
||||||
|
*/
|
||||||
|
public interface ISocketMessageService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询对话信息
|
||||||
|
*/
|
||||||
|
SocketMessageVo queryById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询对话信息列表
|
||||||
|
*/
|
||||||
|
TableDataInfo<SocketMessageVo> queryPageList(SocketMessageBo bo, PageQuery pageQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询对话信息列表
|
||||||
|
*/
|
||||||
|
List<SocketMessageVo> queryList(SocketMessageBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增对话信息
|
||||||
|
*/
|
||||||
|
Boolean insertByBo(SocketMessageBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改对话信息
|
||||||
|
*/
|
||||||
|
Boolean updateByBo(SocketMessageBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除对话信息信息
|
||||||
|
*/
|
||||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据contactId查询对应的List
|
||||||
|
*/
|
||||||
|
List<SocketMessageVo> queryByContactId(@NotNull(message = "主键不能为空") Long contactId);
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@ import com.ruoyi.common.core.domain.PageQuery;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.ruoyi.system.domain.SocketMessage;
|
||||||
|
import com.ruoyi.system.mapper.SocketMessageMapper;
|
||||||
import com.ruoyi.system.mapper.SysUserMapper;
|
import com.ruoyi.system.mapper.SysUserMapper;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
import liquibase.pro.packaged.S;
|
import liquibase.pro.packaged.S;
|
||||||
@@ -38,12 +40,24 @@ public class SocketContactServiceImpl implements ISocketContactService {
|
|||||||
|
|
||||||
private final SysUserMapper sysUserMapper;
|
private final SysUserMapper sysUserMapper;
|
||||||
|
|
||||||
|
private final SocketMessageMapper socketMessageMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询通信目录
|
* 查询通信目录
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SocketContactVo queryById(Long id){
|
public SocketContactVo queryById(Long id) {
|
||||||
return baseMapper.selectVoById(id);
|
SocketContactVo socketContactVo = baseMapper.selectVoById(id);
|
||||||
|
LambdaQueryWrapper<SocketMessage> socketMessageLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
socketMessageLambdaQueryWrapper.eq(SocketMessage::getRoomId, socketContactVo.getRoomId())
|
||||||
|
.and(item ->
|
||||||
|
item.eq(SocketMessage::getUserId, socketContactVo.getContactUserId())
|
||||||
|
.or()
|
||||||
|
.eq(SocketMessage::getUserId, socketContactVo.getUserId())
|
||||||
|
);
|
||||||
|
|
||||||
|
socketContactVo.setMessages(socketMessageMapper.selectVoList(socketMessageLambdaQueryWrapper));
|
||||||
|
return socketContactVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,12 +96,54 @@ public class SocketContactServiceImpl implements ISocketContactService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean insertByBo(SocketContactBo bo) {
|
public Boolean insertByBo(SocketContactBo bo) {
|
||||||
|
|
||||||
|
|
||||||
|
// 正向存
|
||||||
SocketContact add = BeanUtil.toBean(bo, SocketContact.class);
|
SocketContact add = BeanUtil.toBean(bo, SocketContact.class);
|
||||||
|
add.setRoomId(0L);
|
||||||
validEntityBeforeSave(add);
|
validEntityBeforeSave(add);
|
||||||
boolean flag = baseMapper.insert(add) > 0;
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
bo.setId(add.getId());
|
bo.setId(add.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 反向存
|
||||||
|
add.setContactUserId(bo.getUserId());
|
||||||
|
add.setUserId(bo.getContactUserId());
|
||||||
|
validEntityBeforeSave(add);
|
||||||
|
flag = baseMapper.insert(add) > 0;
|
||||||
|
if (flag) {
|
||||||
|
bo.setId(add.getId());
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增通信群聊目录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean insertByBoAndRoom(SocketContactBo bo) {
|
||||||
|
Long roomId = System.currentTimeMillis();
|
||||||
|
boolean flag = false;
|
||||||
|
List<SysUser> userList = bo.getUserList();
|
||||||
|
for (SysUser sysUser : userList) {
|
||||||
|
SocketContact add = BeanUtil.toBean(bo, SocketContact.class);
|
||||||
|
add.setUserId(sysUser.getUserId());
|
||||||
|
for (SysUser user : userList) {
|
||||||
|
// 当当前用户不等于接收者用户时候再进行set
|
||||||
|
if (!user.getUserId().equals(sysUser.getUserId())) {
|
||||||
|
add.setContactUserId(user.getUserId());
|
||||||
|
add.setRoomId(roomId);
|
||||||
|
flag = baseMapper.insert(add) > 0;
|
||||||
|
if (flag) {
|
||||||
|
bo.setId(add.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +160,7 @@ public class SocketContactServiceImpl implements ISocketContactService {
|
|||||||
/**
|
/**
|
||||||
* 保存前的数据校验
|
* 保存前的数据校验
|
||||||
*/
|
*/
|
||||||
private void validEntityBeforeSave(SocketContact entity){
|
private void validEntityBeforeSave(SocketContact entity) {
|
||||||
//TODO 做一些数据校验,如唯一约束
|
//TODO 做一些数据校验,如唯一约束
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +169,7 @@ public class SocketContactServiceImpl implements ISocketContactService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
if(isValid){
|
if (isValid) {
|
||||||
//TODO 做一些业务上的校验,判断是否需要校验
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
}
|
}
|
||||||
return baseMapper.deleteBatchIds(ids) > 0;
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.ruoyi.system.domain.bo.SocketMessageBo;
|
||||||
|
import com.ruoyi.system.domain.vo.SocketMessageVo;
|
||||||
|
import com.ruoyi.system.domain.SocketMessage;
|
||||||
|
import com.ruoyi.system.mapper.SocketMessageMapper;
|
||||||
|
import com.ruoyi.system.service.ISocketMessageService;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话信息Service业务层处理
|
||||||
|
*
|
||||||
|
* @author hdka
|
||||||
|
* @date 2024-10-27
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class SocketMessageServiceImpl implements ISocketMessageService {
|
||||||
|
|
||||||
|
private final SocketMessageMapper baseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询对话信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SocketMessageVo queryById(Long id){
|
||||||
|
return baseMapper.selectVoById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询对话信息列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<SocketMessageVo> queryPageList(SocketMessageBo bo, PageQuery pageQuery) {
|
||||||
|
LambdaQueryWrapper<SocketMessage> lqw = buildQueryWrapper(bo);
|
||||||
|
Page<SocketMessageVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
return TableDataInfo.build(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询对话信息列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SocketMessageVo> queryList(SocketMessageBo bo) {
|
||||||
|
LambdaQueryWrapper<SocketMessage> lqw = buildQueryWrapper(bo);
|
||||||
|
return baseMapper.selectVoList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<SocketMessage> buildQueryWrapper(SocketMessageBo bo) {
|
||||||
|
Map<String, Object> params = bo.getParams();
|
||||||
|
LambdaQueryWrapper<SocketMessage> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.eq(bo.getContactId() != null, SocketMessage::getContactId, bo.getContactId());
|
||||||
|
lqw.eq(bo.getUserId() != null, SocketMessage::getUserId, bo.getUserId());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getContent()), SocketMessage::getContent, bo.getContent());
|
||||||
|
lqw.eq(bo.getRoomId() != null, SocketMessage::getRoomId, bo.getRoomId());
|
||||||
|
return lqw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增对话信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean insertByBo(SocketMessageBo bo) {
|
||||||
|
SocketMessage add = BeanUtil.toBean(bo, SocketMessage.class);
|
||||||
|
validEntityBeforeSave(add);
|
||||||
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
|
if (flag) {
|
||||||
|
bo.setId(add.getId());
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改对话信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean updateByBo(SocketMessageBo bo) {
|
||||||
|
SocketMessage update = BeanUtil.toBean(bo, SocketMessage.class);
|
||||||
|
validEntityBeforeSave(update);
|
||||||
|
return baseMapper.updateById(update) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存前的数据校验
|
||||||
|
*/
|
||||||
|
private void validEntityBeforeSave(SocketMessage entity){
|
||||||
|
//TODO 做一些数据校验,如唯一约束
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除对话信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
|
if(isValid){
|
||||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
|
}
|
||||||
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据对话的id查询列表
|
||||||
|
* @param contactId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SocketMessageVo> queryByContactId(Long contactId) {
|
||||||
|
LambdaQueryWrapper<SocketMessage> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.eq(SocketMessage::getContactId, contactId);
|
||||||
|
return baseMapper.selectVoList(lqw);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.system.mapper.SocketMessageMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.ruoyi.system.domain.SocketMessage" id="SocketMessageResult">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="contactId" column="contact_id"/>
|
||||||
|
<result property="userId" column="user_id"/>
|
||||||
|
<result property="content" column="content"/>
|
||||||
|
<result property="roomId" column="room_id"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="delFlag" column="del_flag"/>
|
||||||
|
<result property="remark" column="remark"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询对话信息列表
|
||||||
|
export function listMessage(query) {
|
||||||
|
return request({
|
||||||
|
url: '/system/message/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询对话信息详细
|
||||||
|
export function getMessage(id) {
|
||||||
|
return request({
|
||||||
|
url: '/system/message/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增对话信息
|
||||||
|
export function addMessage(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/message',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改对话信息
|
||||||
|
export function updateMessage(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/message',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除对话信息
|
||||||
|
export function delMessage(id) {
|
||||||
|
return request({
|
||||||
|
url: '/system/message/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
40
ruoyi-ui/src/components/Message/index.vue
Normal file
40
ruoyi-ui/src/components/Message/index.vue
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<template>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
<script >
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Message',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.init()
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.destroy()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
click() {
|
||||||
|
this.$router
|
||||||
|
},
|
||||||
|
change() {
|
||||||
|
|
||||||
|
},
|
||||||
|
init() {
|
||||||
|
|
||||||
|
},
|
||||||
|
destroy() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped lang="scss">
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -11,23 +11,15 @@
|
|||||||
|
|
||||||
<search id="header-search" class="right-menu-item" />
|
<search id="header-search" class="right-menu-item" />
|
||||||
|
|
||||||
<!-- <el-tooltip content="源码地址" effect="dark" placement="bottom">
|
<div style="position: absolute;top: 0;right: 280px;font-weight: 200">
|
||||||
<ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
|
<i style="position: relative;top: -7px;font-size: small;right: -20px;background-color: red;border-radius: 50%;color: white;width: 50px">99</i>
|
||||||
</el-tooltip>
|
<i class="el-icon-s-comment" @click="chat = true" style=""></i>
|
||||||
|
|
||||||
<el-tooltip content="文档地址" effect="dark" placement="bottom">
|
|
||||||
<ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
|
|
||||||
</el-tooltip>-->
|
|
||||||
|
|
||||||
|
</div>
|
||||||
<screenfull id="screenfull" class="right-menu-item hover-effect" />
|
<screenfull id="screenfull" class="right-menu-item hover-effect" />
|
||||||
<el-tooltip content="用户" effect="dark" placement="bottom">
|
<el-tooltip content="用户" effect="dark" placement="bottom">
|
||||||
<div class="right-menu-item hover-effect" >{{roleGroup}} / {{user.nickName}}</div>
|
<div class="right-menu-item hover-effect" >{{roleGroup}} / {{user.nickName}}</div>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|
||||||
<!-- <el-tooltip content="布局大小" effect="dark" placement="bottom">
|
|
||||||
<size-select id="size-select" class="right-menu-item hover-effect" />
|
|
||||||
</el-tooltip>-->
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
|
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
|
||||||
@@ -48,6 +40,80 @@
|
|||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<el-drawer
|
||||||
|
|
||||||
|
:visible.sync="chat"
|
||||||
|
:with-header="false">
|
||||||
|
<!-- 好友列表-->
|
||||||
|
<el-aside width="" style="background-color: white">
|
||||||
|
<el-container>
|
||||||
|
<el-header>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-input suffix-icon="el-icon-search" placeholder="Enter 回车搜索联系人" v-model="contactQueryParams.userName" @keyup.enter.native="getContactList"/>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row style="margin-top: 5px">
|
||||||
|
<!-- TODO 这里搞一个弹窗去搜索用户表 从而进行添加好友操作 -->
|
||||||
|
<el-button size="mini">添加联系人</el-button>
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
<el-row style="margin-top: 5px">
|
||||||
|
<el-button size="mini">全部</el-button>
|
||||||
|
<el-button size="mini">个人</el-button>
|
||||||
|
<el-button size="mini">群聊</el-button>
|
||||||
|
</el-row>
|
||||||
|
</el-header>
|
||||||
|
<div v-loading="contactListLoading" style="margin-top: 30px">
|
||||||
|
<el-main v-if="contactList.length > 0" v-infinite-scroll="contactLoadMore" :infinite-scroll-distance="750" :infinite-scroll-disabled="contactListTotal < 10" class="msgListMain">
|
||||||
|
<el-row class="msgUserList" v-for="(item, index) in contactList" :key="item.contactUserId" :style="index > 0 && 'margin-top: 10px'" @click.native="loadMessage(item.id)">
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-image :src="(item.user.avatar === '' || item.user.avatar == null) ? require('@/assets/images/profile.jpg') : item.user.avatar" fit="fill" style="width: 70%;border-radius: 50%;"/>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="18">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="15"><span style="font-weight: 500; font-size: 16px">{{item.user.nickName}}</span></el-col>
|
||||||
|
<el-col :span="5">
|
||||||
|
<el-divider direction="vertical"/>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="5" style="font-size: 13px; text-overflow: ellipsis; white-space: nowrap">
|
||||||
|
<span><i class="el-icon-circle-check"></i> {{item.endMsg}}</span>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="5" style="float: right">
|
||||||
|
<el-dropdown class="hover_down_menu">
|
||||||
|
<span class="el-dropdown-link">
|
||||||
|
<i class="el-icon-arrow-down el-icon-more"></i>
|
||||||
|
</span>
|
||||||
|
<el-dropdown-menu slot="dropdown">
|
||||||
|
<el-dropdown-item>置顶</el-dropdown-item>
|
||||||
|
<el-dropdown-item>删除</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</el-dropdown>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-main>
|
||||||
|
<el-main v-else class="msgListMain_empty">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<img src="@/assets/images/contact.png" style="width: 80%; height: 80%"/>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<span style="color: gray">暂无联系人</span>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-main>
|
||||||
|
</div>
|
||||||
|
</el-container>
|
||||||
|
</el-aside>
|
||||||
|
</el-drawer>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -62,7 +128,9 @@ import Search from '@/components/HeaderSearch'
|
|||||||
import RuoYiGit from '@/components/RuoYi/Git'
|
import RuoYiGit from '@/components/RuoYi/Git'
|
||||||
import RuoYiDoc from '@/components/RuoYi/Doc'
|
import RuoYiDoc from '@/components/RuoYi/Doc'
|
||||||
import {getUserProfile} from "@/api/system/user";
|
import {getUserProfile} from "@/api/system/user";
|
||||||
|
import {getContact, listContact} from "../../api/system/contact";
|
||||||
|
import {addMessage} from "../../api/system/message";
|
||||||
|
import {parseTime} from "../../utils/ruoyi";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Breadcrumb,
|
Breadcrumb,
|
||||||
@@ -82,6 +150,7 @@ export default {
|
|||||||
]),
|
]),
|
||||||
setting: {
|
setting: {
|
||||||
get() {
|
get() {
|
||||||
|
|
||||||
return this.$store.state.settings.showSettings
|
return this.$store.state.settings.showSettings
|
||||||
},
|
},
|
||||||
set(val) {
|
set(val) {
|
||||||
@@ -100,12 +169,38 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
user: {},
|
user: {},
|
||||||
|
chat:false,
|
||||||
roleGroup: {},
|
roleGroup: {},
|
||||||
// postGroup: {},
|
// postGroup: {},
|
||||||
|
|
||||||
|
//联系人列表
|
||||||
|
contactList: [],
|
||||||
|
contactListTotal: 0,
|
||||||
|
contactListLoading: false,
|
||||||
|
//消息记录
|
||||||
|
msgList: [],
|
||||||
|
msgListTotal: 0,
|
||||||
|
msgListLoading: false,
|
||||||
|
inputVal: '',
|
||||||
|
search: '',
|
||||||
|
contactUserId: null,
|
||||||
|
userId: null,
|
||||||
|
contactQueryParams: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageNum: 1
|
||||||
|
},
|
||||||
|
currentContact: {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
window.addEventListener("onmessageWS", this.subscribeMessage);
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
||||||
this.getUser();
|
this.getUser();
|
||||||
|
this.userId = this.$store.state.user.id;
|
||||||
|
this.subscribeMessage();
|
||||||
|
this.getContactList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggleSideBar() {
|
toggleSideBar() {
|
||||||
@@ -129,6 +224,99 @@ export default {
|
|||||||
location.href = process.env.VUE_APP_CONTEXT_PATH + "index";
|
location.href = process.env.VUE_APP_CONTEXT_PATH + "index";
|
||||||
})
|
})
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
|
},
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
|
||||||
|
getContactList() {
|
||||||
|
this.contactListLoading = true;
|
||||||
|
this.contactQueryParams.userId = this.userId;
|
||||||
|
listContact(this.contactQueryParams).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.contactList = response.rows;
|
||||||
|
this.contactListTotal = response.total;
|
||||||
|
const contactUserId = this.$route.query.userId;
|
||||||
|
if (contactUserId) {
|
||||||
|
this.contactUserId = contactUserId;
|
||||||
|
let contact = response.rows.find(row => row.contactUserId == contactUserId);
|
||||||
|
this.loadMessage(contact.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.contactListLoading = false;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
contactLoadMore() {
|
||||||
|
// this.contactQueryParams.pageSize = 5;
|
||||||
|
// this.contactQueryParams.pageNum++;
|
||||||
|
this.getContactList();
|
||||||
|
},
|
||||||
|
loadMessage(concatId) {
|
||||||
|
this.msgListLoading = true;
|
||||||
|
getContact(concatId).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
console.log(response.data)
|
||||||
|
this.currentContact = response.data;
|
||||||
|
|
||||||
|
this.msgList = response.data.messages;
|
||||||
|
}
|
||||||
|
this.msgListLoading = false;
|
||||||
|
this.fleshScroll();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
insertEmoji(emoji) {
|
||||||
|
this.inputVal += emoji.data;
|
||||||
|
},
|
||||||
|
send() {
|
||||||
|
console.log("发送数据")
|
||||||
|
const message = {
|
||||||
|
contactId: this.currentContact.id,
|
||||||
|
userId: this.userId,
|
||||||
|
content: this.inputVal,
|
||||||
|
roomId: this.currentContact.roomId
|
||||||
|
}
|
||||||
|
this.msgList.push({
|
||||||
|
...message,
|
||||||
|
id: this.msgList.length + 1,
|
||||||
|
createTime: parseTime(new Date())
|
||||||
|
})
|
||||||
|
this.fleshLastMsg();
|
||||||
|
addMessage(message)
|
||||||
|
const msg = {
|
||||||
|
sendUserId: this.userId,
|
||||||
|
sendUserName: this.$store.state.user.name,
|
||||||
|
userId: this.currentContact.contactUserId,
|
||||||
|
type: "chat",
|
||||||
|
detail: this.inputVal
|
||||||
|
}
|
||||||
|
this.$webSocket.sendWebsocket(JSON.stringify(msg));
|
||||||
|
this.inputVal = '';
|
||||||
|
this.fleshScroll();
|
||||||
|
},
|
||||||
|
subscribeMessage(res) {
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
const { sendUserId, sendUserName, userId, type, detail } = res.detail.data;
|
||||||
|
const message = {
|
||||||
|
id: 1,
|
||||||
|
contactId: userId,
|
||||||
|
userId: sendUserId,
|
||||||
|
content: detail,
|
||||||
|
roomId: this.currentContact.roomId,
|
||||||
|
createTime: parseTime(new Date())
|
||||||
|
}
|
||||||
|
this.msgList.push(message);
|
||||||
|
this.fleshLastMsg();
|
||||||
|
this.fleshScroll();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fleshLastMsg() {
|
||||||
|
const index = this.contactList.findIndex(e => e.id === this.currentContact.id);
|
||||||
|
this.contactList[index].endMsg = this.msgList[this.msgList.length - 1].content;
|
||||||
|
},
|
||||||
|
fleshScroll() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
document.getElementById("message_content_end").scrollIntoView();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,4 +410,84 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.app-container {
|
||||||
|
background: linear-gradient(180deg, rgba(0, 190, 189, .1), rgba(136, 255, 254, .2) 50%, rgba(242, 244, 247, .1));
|
||||||
|
}
|
||||||
|
.app {
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 12px 12px 0 0;
|
||||||
|
}
|
||||||
|
.msgListMain {
|
||||||
|
height: 500px;
|
||||||
|
overflow-y:auto;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
.msgUserList {
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
.msgListMain_empty {
|
||||||
|
display: flex;
|
||||||
|
height: 500px;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.hover_down_menu {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.msgUserList:hover {
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.msgUserList:hover .hover_down_menu{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.el-dropdown-link {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.el-icon-arrow-down {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.main {
|
||||||
|
background-color: white;
|
||||||
|
height: 600px;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
.main_empty {
|
||||||
|
display: flex;
|
||||||
|
background-color: white;
|
||||||
|
height: 600px;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.main_empty .el-row {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.main_empty img {
|
||||||
|
width: 25%;
|
||||||
|
}
|
||||||
|
.msg_content {
|
||||||
|
margin-top: 30px;
|
||||||
|
height: 390px;
|
||||||
|
overflow: auto;
|
||||||
|
//background-color: gray;
|
||||||
|
}
|
||||||
|
.chat_bubble {
|
||||||
|
float: right;
|
||||||
|
margin-right: 35px;
|
||||||
|
color: #333;
|
||||||
|
background-color: rgba(0, 190, 189, .2);
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
padding: 0 12px 0 12px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
.input_top_menu_img{
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export default {
|
|||||||
RightPanel,
|
RightPanel,
|
||||||
Settings,
|
Settings,
|
||||||
Sidebar,
|
Sidebar,
|
||||||
TagsView
|
TagsView,
|
||||||
},
|
},
|
||||||
mixins: [ResizeMixin],
|
mixins: [ResizeMixin],
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ let newVue = new Vue({
|
|||||||
},
|
},
|
||||||
closeSocket() {
|
closeSocket() {
|
||||||
//关闭websocket连接
|
//关闭websocket连接
|
||||||
this.$websocket.close();
|
this.$webSocket.close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
router,
|
router,
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ const webSocketOnError = (e) => {
|
|||||||
//服务器返回的数据
|
//服务器返回的数据
|
||||||
const webSocketOnMessage = (e)=> {
|
const webSocketOnMessage = (e)=> {
|
||||||
//判断是否登录
|
//判断是否登录
|
||||||
console.log("111111111111"+e)
|
|
||||||
if (getToken()) {
|
if (getToken()) {
|
||||||
//window自定义事件
|
//window自定义事件
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
|
|||||||
@@ -212,7 +212,9 @@ export default {
|
|||||||
this.msgListLoading = true;
|
this.msgListLoading = true;
|
||||||
getContact(concatId).then(response => {
|
getContact(concatId).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
|
console.log(response.data)
|
||||||
this.currentContact = response.data;
|
this.currentContact = response.data;
|
||||||
|
|
||||||
this.msgList = response.data.messages;
|
this.msgList = response.data.messages;
|
||||||
}
|
}
|
||||||
this.msgListLoading = false;
|
this.msgListLoading = false;
|
||||||
@@ -223,6 +225,7 @@ export default {
|
|||||||
this.inputVal += emoji.data;
|
this.inputVal += emoji.data;
|
||||||
},
|
},
|
||||||
send() {
|
send() {
|
||||||
|
console.log("发送数据")
|
||||||
const message = {
|
const message = {
|
||||||
contactId: this.currentContact.id,
|
contactId: this.currentContact.id,
|
||||||
userId: this.userId,
|
userId: this.userId,
|
||||||
@@ -235,7 +238,7 @@ export default {
|
|||||||
createTime: parseTime(new Date())
|
createTime: parseTime(new Date())
|
||||||
})
|
})
|
||||||
this.fleshLastMsg();
|
this.fleshLastMsg();
|
||||||
addMessage(message);
|
addMessage(message)
|
||||||
const msg = {
|
const msg = {
|
||||||
sendUserId: this.userId,
|
sendUserId: this.userId,
|
||||||
sendUserName: this.$store.state.user.name,
|
sendUserName: this.$store.state.user.name,
|
||||||
@@ -243,12 +246,12 @@ export default {
|
|||||||
type: "chat",
|
type: "chat",
|
||||||
detail: this.inputVal
|
detail: this.inputVal
|
||||||
}
|
}
|
||||||
this.$websocket.sendWebsocket(JSON.stringify(msg));
|
this.$webSocket.sendWebsocket(JSON.stringify(msg));
|
||||||
this.inputVal = '';
|
this.inputVal = '';
|
||||||
this.fleshScroll();
|
this.fleshScroll();
|
||||||
},
|
},
|
||||||
subscribeMessage(res) {
|
subscribeMessage(res) {
|
||||||
console.log(res);
|
|
||||||
if (res) {
|
if (res) {
|
||||||
const { sendUserId, sendUserName, userId, type, detail } = res.detail.data;
|
const { sendUserId, sendUserName, userId, type, detail } = res.detail.data;
|
||||||
const message = {
|
const message = {
|
||||||
|
|||||||
Reference in New Issue
Block a user