diff --git a/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/CommunicationServer.java b/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/CommunicationServer.java index fb9d1f6a8523b69884248c33611cdbc2341bc6bd..ba7fee0ffd53164e8ec813c576af2ec5c9b73c18 100644 --- a/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/CommunicationServer.java +++ b/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/CommunicationServer.java @@ -25,6 +25,7 @@ public class CommunicationServer { private ChatChannelInitializer chatChannelInitializer; public void run(int port) throws Exception { + System.out.println("聊天服务启动成功端口为:"+port); EventLoopGroup bossGroup = new NioEventLoopGroup(2); EventLoopGroup workerGroup = new NioEventLoopGroup(15); try { diff --git a/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/HasChannelChatService.java b/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/HasChannelChatService.java index 948a146579af7b593bfd47c22487d4511ef87105..afdd8fc8ed741b5bd004ed73fcaa66f691e6a8f8 100644 --- a/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/HasChannelChatService.java +++ b/mobile-app/src/main/java/com/ruoyi/chat/LongConnection/handler/nettyService/HasChannelChatService.java @@ -62,21 +62,14 @@ public class HasChannelChatService { TextMsg textMsg = mapper.convertValue(chatDTO.getMessage(), new TypeReference() { }); ChatRecord chatrecord = ChatRecord.ChatRecordReaded(senderId, chatDTO.getReceiverId(), textMsg.getText(), chatDTO.getMsgType()); - CountDownLatch countDownLatch = new CountDownLatch(1); - AsyncManager.me().execute(new TimerTask() { - @SneakyThrows - @Override - public void run() { - TextMsgVo msgVo = dozerMapper.map(chatrecord, TextMsgVo.class); - SocketChannel channel = LongConnectionUtil.getChannelById(chatDTO.getReceiverId()); - channel.writeAndFlush(LongConnectionMsgUtil.ObjectToWSTextResult(new ReturnMsgVo(ReturnMsgVo.RECEIVE_MSG, new ReceiveMsgVo(chatDTO.getMsgType(), msgVo)))); - ctx.writeAndFlush(LongConnectionMsgUtil.ObjectToWSTextResult(new ReturnMsgVo(ReturnMsgVo.SEND_SUCCESS, - new SendMsgVo(chatDTO.getChatId(), msgVo)))); - countDownLatch.countDown(); - } - }); - countDownLatch.await(); mclass.chatrecordService.save(chatrecord); + TextMsgVo msgVo = dozerMapper.map(chatrecord, TextMsgVo.class); + SocketChannel channel = LongConnectionUtil.getChannelById(chatDTO.getReceiverId()); + channel.writeAndFlush(LongConnectionMsgUtil.ObjectToWSTextResult(new ReturnMsgVo(ReturnMsgVo.RECEIVE_MSG, new ReceiveMsgVo(chatDTO.getMsgType(), msgVo)))); + ctx.writeAndFlush(LongConnectionMsgUtil.ObjectToWSTextResult(new ReturnMsgVo(ReturnMsgVo.SEND_SUCCESS, + new SendMsgVo(chatDTO.getChatId(), msgVo)))); + + })); map.put(LongConnectionChatDTO.FILE, ((ctx, chatDTO, senderId) -> { @@ -84,23 +77,19 @@ public class HasChannelChatService { FileMsg fileMsg = mapper.convertValue(chatDTO.getMessage(), FileMsg.class); String url = mclass.minioService.setFile(fileMsg); CountDownLatch countDownLatch = new CountDownLatch(1); - AsyncManager.me().execute(new TimerTask() { - @SneakyThrows - @Override - public void run() { - SocketChannel channel = LongConnectionUtil.getChannelById(chatDTO.getReceiverId()); - FileMsgVo fileMsgVo = dozerMapper.map(chatrecord, FileMsgVo.class); - fileMsgVo.setFileName(fileMsg.getFileName()).setUrl(url); - channel.writeAndFlush(LongConnectionMsgUtil.ObjectToWSTextResult(new ReturnMsgVo(ReturnMsgVo.RECEIVE_MSG, new ReceiveMsgVo(chatDTO.getMsgType(), fileMsgVo)))); - ctx.writeAndFlush(LongConnectionMsgUtil.ObjectToWSTextResult(new ReturnMsgVo(ReturnMsgVo.SEND_SUCCESS, new SendMsgVo(chatDTO.getChatId(), fileMsgVo)))); - countDownLatch.countDown(); - } - }); + countDownLatch.await(); mclass.chatrecordService.save(chatrecord); ChatFileData ChatFileData = new ChatFileData(chatrecord.getMsgId(), url, fileMsg.getFileName()); mclass.ChatFileDataService.save(ChatFileData); + SocketChannel channel = LongConnectionUtil.getChannelById(chatDTO.getReceiverId()); + FileMsgVo fileMsgVo = dozerMapper.map(chatrecord, FileMsgVo.class); + fileMsgVo.setFileName(fileMsg.getFileName()).setUrl(url); + channel.writeAndFlush(LongConnectionMsgUtil.ObjectToWSTextResult(new ReturnMsgVo(ReturnMsgVo.RECEIVE_MSG, new ReceiveMsgVo(chatDTO.getMsgType(), fileMsgVo)))); + ctx.writeAndFlush(LongConnectionMsgUtil.ObjectToWSTextResult(new ReturnMsgVo(ReturnMsgVo.SEND_SUCCESS, new SendMsgVo(chatDTO.getChatId(), fileMsgVo)))); + countDownLatch.countDown(); + })); } diff --git a/mobile-app/src/main/java/com/ruoyi/chat/ab/entity/ChatFileData.java b/mobile-app/src/main/java/com/ruoyi/chat/ab/entity/ChatFileData.java index f75e50d6c7551803a5b390c3e00c9b339795729a..f8148d38d17f259fe1188ffdf4616f7d2792a08d 100644 --- a/mobile-app/src/main/java/com/ruoyi/chat/ab/entity/ChatFileData.java +++ b/mobile-app/src/main/java/com/ruoyi/chat/ab/entity/ChatFileData.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; + import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -70,7 +71,7 @@ public class ChatFileData implements Serializable { private LocalDateTime updatedTime; @TableField(value = "deleted",fill = FieldFill.INSERT) - @TableLogic + @TableLogic(value = "F",delval = "T") private String deleted; diff --git a/mobile-app/src/main/java/com/ruoyi/chat/ab/entity/ChatRecord.java b/mobile-app/src/main/java/com/ruoyi/chat/ab/entity/ChatRecord.java index cdcdc249df08423f1bf349ab56f1c8f3b4cd883c..ca487ce1251393105f57e7193a1973b902462618 100644 --- a/mobile-app/src/main/java/com/ruoyi/chat/ab/entity/ChatRecord.java +++ b/mobile-app/src/main/java/com/ruoyi/chat/ab/entity/ChatRecord.java @@ -101,7 +101,7 @@ public class ChatRecord implements Serializable { * 逻辑删除 */ @TableField(value = "deleted",fill = FieldFill.INSERT) - @TableLogic + @TableLogic(value = "F",delval = "T") private String deleted; @TableId(value = "msg_id", type = IdType.ASSIGN_UUID) diff --git a/mobile-app/src/main/java/com/ruoyi/chat/service/impl/ChatServiceImpl.java b/mobile-app/src/main/java/com/ruoyi/chat/service/impl/ChatServiceImpl.java index 69e2dbef4f1d5e2205191c78f87a1d4adaccd412..610b51f066f58a054781109fd408121c14b967d7 100644 --- a/mobile-app/src/main/java/com/ruoyi/chat/service/impl/ChatServiceImpl.java +++ b/mobile-app/src/main/java/com/ruoyi/chat/service/impl/ChatServiceImpl.java @@ -1,12 +1,18 @@ package com.ruoyi.chat.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.chat.LongConnection.model.ReceiveMsgVo; +import com.ruoyi.chat.LongConnection.model.ReturnMsgVo; +import com.ruoyi.chat.LongConnection.model.SendMsgVo; +import com.ruoyi.chat.LongConnection.model.msg.TextMsgVo; import com.ruoyi.chat.LongConnection.util.LongConnectionMsgUtil; import com.ruoyi.chat.LongConnection.util.LongConnectionUtil; import com.ruoyi.chat.ab.entity.ChatRecord; import com.ruoyi.chat.ab.service.IChatRecordService; import com.ruoyi.chat.service.IChatService; +import com.ruoyi.framework.manager.AsyncManager; import io.netty.channel.socket.SocketChannel; +import lombok.SneakyThrows; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -14,6 +20,7 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.TimerTask; import java.util.concurrent.CountDownLatch; import java.util.stream.Collectors; @@ -59,17 +66,21 @@ public class ChatServiceImpl implements IChatService { //System.out.println(set); final CountDownLatch latch = new CountDownLatch(set.size()); List rs = new ArrayList<>(); + for (String item : set) { - Runnable runnable = () -> { - QueryWrapper wrapper1 = new QueryWrapper<>(); - wrapper1.eq("receiver_id", item).and(i -> i.eq("sender_id", id)).or().eq("sender_id", item).and(i -> i.eq("receiver_id", id)). - select("receiver_id", "sender_id", "message", "msg_type", "rb", "CREATED_TIME", "msg_id").orderByDesc("CREATED_TIME").last("limit 3"); - List list = chatrecordService.list(wrapper1); - rs.addAll(list); - latch.countDown(); - }; - runnable.run(); + AsyncManager.me().execute(new TimerTask() { + @SneakyThrows + @Override + public void run() { + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq("receiver_id", item).and(i -> i.eq("sender_id", id)).or().eq("sender_id", item).and(i -> i.eq("receiver_id", id)). + select("receiver_id", "sender_id", "message", "msg_type", "rb", "CREATED_TIME", "msg_id").orderByDesc("CREATED_TIME").last("limit 3"); + List list = chatrecordService.list(wrapper1); + rs.addAll(list); + latch.countDown(); + } + }); } try { latch.await(); @@ -82,6 +93,8 @@ public class ChatServiceImpl implements IChatService { @Override public List getFiveHisChats(String msgId, String user1, String user2) { //System.out.println(user1 + "" + user2); + chatrecordService.save(new ChatRecord().setMessage("text")); + chatrecordService.list(); LocalDateTime lastTime = chatrecordService.getById(msgId).getCreatedTime(); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("receiver_id", user1).and(i -> i.eq("sender_id", user2)). diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index b29a30027fb5727220e3452459fd207934769ae1..aad72e529e702d00bec0ba8bb83e62ecebef3dac 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -105,7 +105,7 @@ accessToken: accessExcludes: /login,/register,/captchaImage # 匹配连接 # accessUrlPatterns: - accessUrlPatterns: /chat/*,/app/user/api/*,/file/api/*,/classes/api/* + accessUrlPatterns: /app/user/api/*,/file/api/*,/classes/api/*,/chat/* # MyBatis配置 diff --git a/ruoyi-framework/src/main/java/com/ruoyi/data/filter/second/AccessFilter.java b/ruoyi-framework/src/main/java/com/ruoyi/data/filter/second/AccessFilter.java index a177f8c796ed797ed433368541c437593210e624..30499883d76f2879cbc9f2b3b2552eb402cd6dbb 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/data/filter/second/AccessFilter.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/data/filter/second/AccessFilter.java @@ -24,11 +24,8 @@ public class AccessFilter implements Filter { String appId = request.getParameter("appId"); String token = request.getParameter("token"); String currentTime = request.getParameter("timeStamp"); - ApiAuthencator apiAuthencator = GetBeanUtil.getBean(ApiAuthencator.class); - int code = apiAuthencator.auth(new ApiRequest(token,Long.valueOf(appId),Long.valueOf(currentTime)),request,response); - if(code != 1){ return; } diff --git a/ruoyi-ui/2021.12.7dist.zip b/ruoyi-ui/2021.12.7dist.zip new file mode 100644 index 0000000000000000000000000000000000000000..e2a2593bf5eb1aee5e0eff0e9f0395d85d581f48 Binary files /dev/null and b/ruoyi-ui/2021.12.7dist.zip differ diff --git a/ruoyi-ui/src/api/app/user.js b/ruoyi-ui/src/api/app/user.js new file mode 100644 index 0000000000000000000000000000000000000000..c48696cf06238371b619f7f6227093e7d909b300 --- /dev/null +++ b/ruoyi-ui/src/api/app/user.js @@ -0,0 +1,121 @@ +import request from '@/utils/request' +import { praseStrEmpty } from "@/utils/ruoyi"; + +// 查询用户列表 +export function listUser(query) { + return request({ + url: '/app/user/list', + method: 'get', + params: query + }) +} + +// 查询用户详细 +export function getUser(userId) { + return request({ + url: '/app/user/' + praseStrEmpty(userId), + method: 'get' + }) +} + +// 新增用户 +export function addUser(data) { + return request({ + url: '/app/user', + method: 'post', + data: data + }) +} + +// 修改用户 +export function updateUser(data) { + return request({ + url: '/app/user', + method: 'put', + data: data + }) +} + +// 删除用户 +export function delUser(userId) { + return request({ + url: '/app/user/' + userId, + method: 'delete' + }) +} + +// 导出用户 +export function exportUser(query) { + return request({ + url: '/app/user/export', + method: 'get', + params: query + }) +} + +// 用户密码重置 +export function resetUserPwd(userId, password) { + const data = { + userId, + password + } + return request({ + url: '/app/user/resetPwd', + method: 'put', + data: data + }) +} + +// 用户状态修改 +export function changeUserStatus(userId, status) { + const data = { + userId, + status + } + return request({ + url: '/app/user/changeStatus', + method: 'put', + data: data + }) +} + +// 查询用户个人信息 +export function getUserProfile() { + return request({ + url: '/app/user/profile', + method: 'get' + }) +} + +// 修改用户个人信息 +export function updateUserProfile(data) { + return request({ + url: '/app/user/profile', + method: 'put', + data: data + }) +} + +// 用户密码重置 +export function updateUserPwd(oldPassword, newPassword) { + const data = { + oldPassword, + newPassword + } + return request({ + url: '/app/user/profile/updatePwd', + method: 'put', + params: data + }) +} + + + +// 下载用户导入模板 +export function importTemplate() { + return request({ + url: '/app/user/importTemplate', + method: 'get' + }) +} + diff --git a/ruoyi-ui/src/views/app/user/authRole.vue b/ruoyi-ui/src/views/app/user/authRole.vue new file mode 100644 index 0000000000000000000000000000000000000000..2a569e5d56bd1cb84ef273879e0a8ad48425810e --- /dev/null +++ b/ruoyi-ui/src/views/app/user/authRole.vue @@ -0,0 +1,117 @@ + + + \ No newline at end of file diff --git a/ruoyi-ui/src/views/app/user/index.vue b/ruoyi-ui/src/views/app/user/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..b266383840faed8e634b8f1f3adcd75a7b231a8a --- /dev/null +++ b/ruoyi-ui/src/views/app/user/index.vue @@ -0,0 +1,648 @@ + + + diff --git a/ruoyi-ui/src/views/app/user/profile/index.vue b/ruoyi-ui/src/views/app/user/profile/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..dcfb82dab1d7f12dbc3182226ef671205281d5a9 --- /dev/null +++ b/ruoyi-ui/src/views/app/user/profile/index.vue @@ -0,0 +1,88 @@ + + + diff --git a/ruoyi-ui/src/views/app/user/profile/resetPwd.vue b/ruoyi-ui/src/views/app/user/profile/resetPwd.vue new file mode 100644 index 0000000000000000000000000000000000000000..8b94228fa797706e2974da60e1faa68146ec396c --- /dev/null +++ b/ruoyi-ui/src/views/app/user/profile/resetPwd.vue @@ -0,0 +1,72 @@ + + + diff --git a/ruoyi-ui/src/views/app/user/profile/userInfo.vue b/ruoyi-ui/src/views/app/user/profile/userInfo.vue new file mode 100644 index 0000000000000000000000000000000000000000..329a675c13acc3f3100e2521168db87a110092f3 --- /dev/null +++ b/ruoyi-ui/src/views/app/user/profile/userInfo.vue @@ -0,0 +1,76 @@ + + +