Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cxt104926
Stusystem
提交
5438dda4
S
Stusystem
项目概览
cxt104926
/
Stusystem
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Stusystem
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5438dda4
编写于
6月 23, 2021
作者:
cxt104926
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bug fix
上级
85125cc5
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
96 addition
and
27 deletion
+96
-27
README.md
README.md
+12
-3
pom.xml
pom.xml
+0
-7
src/main/java/com/stu/stusystem/controller/chat/ChatController.java
...ava/com/stu/stusystem/controller/chat/ChatController.java
+16
-2
src/main/java/com/stu/stusystem/mapper/chat/ChatMapper.java
src/main/java/com/stu/stusystem/mapper/chat/ChatMapper.java
+15
-0
src/main/java/com/stu/stusystem/model/chat/ChatMsg.java
src/main/java/com/stu/stusystem/model/chat/ChatMsg.java
+5
-1
src/main/java/com/stu/stusystem/service/chat/ChatService.java
...main/java/com/stu/stusystem/service/chat/ChatService.java
+32
-0
src/main/resources/config/liquibase/20210616_creat_table_ChatMsg.xml
...sources/config/liquibase/20210616_creat_table_ChatMsg.xml
+6
-13
src/main/resources/config/master.xml
src/main/resources/config/master.xml
+1
-1
src/main/resources/mapper/chat/ChatMapper.xml
src/main/resources/mapper/chat/ChatMapper.xml
+9
-0
未找到文件。
README.md
浏览文件 @
5438dda4
...
...
@@ -60,9 +60,18 @@
管理员账号:admin
密码:1
#### 5.说在最后
1.
系统正在开发,想到的后面再更新
2.
正在学习使用这些技术,若有错误 不对之处欢迎大佬指正
#### 5.报错
① 启动项目时候卡死,控制台报
`Waiting for changelog lock....`
出现的问题:liquibase导致表锁死报错
解决办法,在数据库中执行更新语句,将DATABASECHANGELOGLOCK表中锁状态改成0
UPDATE DATABASECHANGELOGLOCK
SET locked=0, lockgranted=null, lockedby=null
WHERE id=1
#### 6.说在最后
1.
系统正在开发,想到的后面再更新
2.
正在学习使用这些技术,若有错误 不对之处欢迎大佬指正
...
...
pom.xml
浏览文件 @
5438dda4
...
...
@@ -28,13 +28,6 @@
<artifactId>
spring-boot-starter-websocket
</artifactId>
</dependency>
<!-- 集成json -->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.74
</version>
</dependency>
<!-- 获取系统信息 -->
<dependency>
<groupId>
com.github.oshi
</groupId>
...
...
src/main/java/com/stu/stusystem/controller/chat/ChatController.java
浏览文件 @
5438dda4
...
...
@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONArray;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.stu.stusystem.model.chat.ChatMsg
;
import
com.stu.stusystem.service.chat.ChatService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.websocket.*
;
...
...
@@ -24,6 +26,13 @@ import java.util.concurrent.ConcurrentHashMap;
@ServerEndpoint
(
"/stu/chat/{name}"
)
public
class
ChatController
{
private
static
ChatService
chatMsgService
;
@Autowired
public
void
setChatService
(
ChatService
chatService
)
{
ChatController
.
chatMsgService
=
chatService
;
}
private
static
final
Map
<
String
,
Session
>
clients
=
new
ConcurrentHashMap
<>();
@OnOpen
...
...
@@ -33,7 +42,6 @@ public class ChatController {
log
.
info
(
"当前在线用户数:{}"
,
clients
.
size
());
}
/**
* 发送消息,前端将消息转成json字符串,后端转成对象
*/
...
...
@@ -51,7 +59,14 @@ public class ChatController {
}
else
if
(
"3"
.
equals
(
msg
.
getSendType
()))
{
Session
se
=
clients
.
get
(
msg
.
getAcceptUser
());
if
(
se
!=
null
)
{
new
Thread
(()
->
{
if
(
chatMsgService
==
null
)
return
;
chatMsgService
.
addMsg
(
msg
);
}).
start
();
sendMessage
(
se
,
msg
);
}
else
{
}
}
}
catch
(
JsonProcessingException
e
)
{
...
...
@@ -140,7 +155,6 @@ public class ChatController {
});
}
/**
* 单聊
*
...
...
src/main/java/com/stu/stusystem/mapper/chat/ChatMapper.java
0 → 100644
浏览文件 @
5438dda4
package
com.stu.stusystem.mapper.chat
;
import
com.stu.stusystem.common.CommonMapper
;
import
com.stu.stusystem.model.chat.ChatMsg
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
/**
* @author: cxt
* @time: 2021/6/23
*/
@Mapper
public
interface
ChatMapper
extends
CommonMapper
<
ChatMsg
>
{
int
addMsg
(
@Param
(
"chatMsg"
)
ChatMsg
chatMsg
);
}
src/main/java/com/stu/stusystem/model/chat/ChatMsg.java
浏览文件 @
5438dda4
...
...
@@ -16,7 +16,7 @@ import java.util.Date;
@NoArgsConstructor
public
class
ChatMsg
extends
BaseModel
{
private
String
id
;
private
Integer
id
;
// 消息内容
private
String
msg
;
...
...
@@ -33,5 +33,9 @@ public class ChatMsg extends BaseModel {
// 内容类型:0文本;1图片;
private
String
msgType
;
// 是否已读
private
String
isRead
;
// 发送时间
private
Date
sendTime
;
}
src/main/java/com/stu/stusystem/service/chat/ChatService.java
0 → 100644
浏览文件 @
5438dda4
package
com.stu.stusystem.service.chat
;
import
com.stu.stusystem.common.ApiException
;
import
com.stu.stusystem.mapper.chat.ChatMapper
;
import
com.stu.stusystem.model.chat.ChatMsg
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* @author: cxt
* @time: 2021/6/23
*/
@Service
public
class
ChatService
{
private
ChatMapper
chatMapper
;
public
void
addMsg
(
ChatMsg
chatMsg
){
if
(
chatMapper
==
null
){
return
;
}
int
insert
=
this
.
chatMapper
.
addMsg
(
chatMsg
);
if
(
insert
==
0
){
throw
new
ApiException
(
ApiException
.
SAVE_FAIL
);
}
}
@Autowired
public
void
setChatMapper
(
ChatMapper
chatMapper
)
{
this
.
chatMapper
=
chatMapper
;
}
}
src/main/resources/config/liquibase/2021061
5
_creat_table_ChatMsg.xml
→
src/main/resources/config/liquibase/2021061
6
_creat_table_ChatMsg.xml
浏览文件 @
5438dda4
...
...
@@ -9,13 +9,13 @@
<!--
Added the entity ChatMsg.
-->
<changeSet
id=
"2021061
5
-01"
author=
"cxt"
>
<changeSet
id=
"2021061
6
-01"
author=
"cxt"
>
<createTable
tableName=
"chat_msg"
remarks=
"聊天消息"
>
<column
name=
"id"
type=
"
varchar(22)
"
>
<column
name=
"id"
type=
"
int(11)"
autoIncrement=
"true
"
>
<constraints
primaryKey=
"true"
nullable=
"false"
/>
</column>
<column
name=
"msg"
type=
"varchar(
3
00)"
remarks=
"消息内容"
>
<column
name=
"msg"
type=
"varchar(
1
00)"
remarks=
"消息内容"
>
<constraints
nullable=
"false"
/>
</column>
...
...
@@ -27,7 +27,7 @@
<constraints
nullable=
"false"
/>
</column>
<column
name=
"send_type"
type=
"varchar(2)"
remarks=
"
发送消息id
"
>
<column
name=
"send_type"
type=
"varchar(2)"
remarks=
"
聊天类型
"
>
<constraints
nullable=
"false"
/>
</column>
...
...
@@ -35,21 +35,14 @@
<constraints
nullable=
"false"
/>
</column>
<column
name=
"
create_time"
type=
"datetime"
remarks=
"创建时间
"
>
<column
name=
"
is_read"
type=
"varchar(2)"
remarks=
"是否已读
"
>
<constraints
nullable=
"false"
/>
</column>
<column
name=
"
create_by"
type=
"varchar(18)"
remarks=
"创建人
"
>
<column
name=
"
send_time"
type=
"datetime"
remarks=
"发送时间
"
>
<constraints
nullable=
"false"
/>
</column>
<column
name=
"update_time"
type=
"datetime"
remarks=
"更新时间"
>
<constraints
nullable=
"true"
/>
</column>
<column
name=
"update_by"
type=
"varchar(18)"
remarks=
"更新人"
>
<constraints
nullable=
"true"
/>
</column>
</createTable>
</changeSet>
...
...
src/main/resources/config/master.xml
浏览文件 @
5438dda4
...
...
@@ -11,6 +11,6 @@
<include
file=
"classpath:config/liquibase/20210331_creat_table_role.xml"
relativeToChangelogFile=
"false"
/>
<include
file=
"classpath:config/liquibase/20210331_creat_table_role_jurisdiction.xml"
relativeToChangelogFile=
"false"
/>
<include
file=
"classpath:config/liquibase/20210615_creat_table_ChatFriends.xml"
relativeToChangelogFile=
"false"
/>
<include
file=
"classpath:config/liquibase/2021061
5
_creat_table_ChatMsg.xml"
relativeToChangelogFile=
"false"
/>
<include
file=
"classpath:config/liquibase/2021061
6
_creat_table_ChatMsg.xml"
relativeToChangelogFile=
"false"
/>
</databaseChangeLog>
\ No newline at end of file
src/main/resources/mapper/chat/ChatMapper.xml
0 → 100644
浏览文件 @
5438dda4
<?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.stu.stusystem.mapper.chat.ChatMapper"
>
<insert
id=
"addMsg"
>
insert into chat_msg(msg, accept_user, send_user, send_type, msg_type, is_read, send_time)
VALUES (#{chatMsg.msg}, #{chatMsg.acceptUser}, #{chatMsg.sendUser}, #{chatMsg.sendType}, #{chatMsg.msgType}, #{chatMsg.isRead}, #{chatMsg.sendTime})
</insert>
</mapper>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录