Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
njgzx
dataease
Commits
2fbed9fd
提交
2fbed9fd
authored
8月 17, 2021
作者:
fit2cloud-chenyw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 定时查询未读消息条数错误
上级
d2b6fe43
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
75 行增加
和
18 行删除
+75
-18
ShiroServiceImpl.java
.../java/io/dataease/auth/service/impl/ShiroServiceImpl.java
+2
-0
MsgController.java
...c/main/java/io/dataease/controller/sys/MsgController.java
+12
-0
SysMsgService.java
.../main/java/io/dataease/service/message/SysMsgService.java
+7
-0
msg.js
frontend/src/api/system/msg.js
+9
-0
index.vue
frontend/src/components/Notification/index.vue
+42
-16
request.js
frontend/src/utils/request.js
+3
-2
没有找到文件。
backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java
浏览文件 @
2fbed9fd
...
...
@@ -45,6 +45,8 @@ public class ShiroServiceImpl implements ShiroService {
//验证链接
filterChainDefinitionMap
.
put
(
"/api/link/validate**"
,
ANON
);
filterChainDefinitionMap
.
put
(
"/api/map/areaEntitys/**"
,
ANON
);
//未读消息数量
filterChainDefinitionMap
.
put
(
"/api/sys_msg/unReadCount"
,
ANON
);
filterChainDefinitionMap
.
put
(
"/**/*.json"
,
ANON
);
filterChainDefinitionMap
.
put
(
"/system/ui/**"
,
ANON
);
...
...
backend/src/main/java/io/dataease/controller/sys/MsgController.java
浏览文件 @
2fbed9fd
...
...
@@ -6,6 +6,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import
io.dataease.base.domain.SysMsgChannel
;
import
io.dataease.base.domain.SysMsgSetting
;
import
io.dataease.base.domain.SysMsgType
;
import
io.dataease.commons.exception.DEException
;
import
io.dataease.commons.utils.AuthUtils
;
import
io.dataease.commons.utils.PageUtils
;
import
io.dataease.commons.utils.Pager
;
...
...
@@ -21,6 +22,7 @@ import org.apache.commons.lang3.ObjectUtils;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Api
(
tags
=
"系统:消息管理"
)
...
...
@@ -46,6 +48,16 @@ public class MsgController {
return
listPager
;
}
@ApiOperation
(
"查询未读数量"
)
@PostMapping
(
"/unReadCount"
)
public
Long
unReadCount
(
@RequestBody
Map
<
String
,
Long
>
request
)
{
if
(
null
==
request
||
null
==
request
.
get
(
"userId"
))
{
throw
new
RuntimeException
(
"缺少用户ID"
);
}
Long
userId
=
request
.
get
(
"userId"
);
return
sysMsgService
.
queryCount
(
userId
);
}
@ApiOperation
(
"设置已读"
)
@PostMapping
(
"/setReaded/{msgId}"
)
public
void
setReaded
(
@PathVariable
Long
msgId
)
{
...
...
backend/src/main/java/io/dataease/service/message/SysMsgService.java
浏览文件 @
2fbed9fd
...
...
@@ -105,6 +105,13 @@ public class SysMsgService {
return
msgGridDtos
;
}
public
Long
queryCount
(
Long
userId
)
{
SysMsgExample
example
=
new
SysMsgExample
();
SysMsgExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
).
andStatusEqualTo
(
false
);
return
sysMsgMapper
.
countByExample
(
example
);
}
public
void
setReaded
(
Long
msgId
)
{
SysMsg
sysMsg
=
new
SysMsg
();
sysMsg
.
setMsgId
(
msgId
);
...
...
frontend/src/api/system/msg.js
浏览文件 @
2fbed9fd
...
...
@@ -9,6 +9,15 @@ export function query(pageIndex, pageSize, data) {
})
}
export
function
unReadCount
(
data
)
{
return
request
({
url
:
'/api/sys_msg/unReadCount'
,
method
:
'post'
,
loading
:
false
,
data
})
}
export
function
updateStatus
(
msgId
)
{
return
request
({
url
:
'/api/sys_msg/setReaded/'
+
msgId
,
...
...
frontend/src/components/Notification/index.vue
浏览文件 @
2fbed9fd
...
...
@@ -53,14 +53,14 @@
class-name=
"notification"
icon-class=
"notification"
/>
<span
v-if=
"
paginationConfig.total"
class=
"msg-number"
>
{{
paginationConfig.total }}
</span>
<span
v-if=
"
count || paginationConfig.total"
class=
"msg-number"
>
{{ count ||
paginationConfig.total }}
</span>
</div>
</div>
</el-popover>
</template>
<
script
>
import
{
query
,
updateStatus
}
from
'@/api/system/msg'
import
{
query
,
updateStatus
,
unReadCount
}
from
'@/api/system/msg'
import
{
getTypeName
,
loadMsgTypes
}
from
'@/utils/webMsg'
import
{
mapGetters
}
from
'vuex'
import
bus
from
'@/utils/bus'
...
...
@@ -76,21 +76,30 @@ export default {
pageSize
:
5
,
total
:
0
},
timer
:
null
timer
:
null
,
count
:
0
}
},
computed
:
{
...
mapGetters
([
'permission_routes'
'permission_routes'
,
'user'
])
},
watch
:
{
'visible'
:
function
(
newV
,
oldV
)
{
if
(
newV
&&
!
oldV
)
{
this
.
search
()
}
}
},
created
()
{
// 先加载消息类型
loadMsgTypes
()
this
.
search
()
this
.
queryCount
()
// 每30s定时刷新拉取消息
this
.
timer
=
setInterval
(()
=>
{
this
.
search
()
this
.
queryCount
()
},
30000
)
},
mounted
()
{
...
...
@@ -105,19 +114,11 @@ export default {
this
.
timer
&&
clearInterval
(
this
.
timer
)
},
methods
:
{
// handClick(lang) {
// console.log(lang)
// },
showDetail
(
row
)
{
const
param
=
{
...{
msgNotification
:
true
,
msgType
:
row
.
typeId
,
sourceParam
:
row
.
param
}}
this
.
visible
=
false
// if (this.$route && this.$route.name && this.$route.name.includes('panel') && row.type === 0) {
// bus.$emit('to-msg-share', param)
// } else if (this.$route && this.$route.name && this.$route.name.includes('dataset') && row.type === 1) {
// bus.$emit('to-msg-dataset', param)
// } else {
// this.$router.push({ name: row.router, params: param })
// }
if
(
this
.
$route
&&
this
.
$route
.
name
&&
this
.
$route
.
name
===
row
.
router
)
{
// 如果当前路由就是目标路由 那么使用router.push页面不会刷新 这时候要使用事件方式
row
.
callback
&&
bus
.
$emit
(
row
.
callback
,
param
)
...
...
@@ -164,6 +165,31 @@ export default {
this
.
$store
.
commit
(
'permission/SET_CURRENT_ROUTES'
,
route
)
// this.setSidebarHide(route)
},
queryCount
()
{
const
token
=
getToken
()
if
(
!
token
||
token
===
'null'
||
token
===
'undefined'
||
!
this
.
user
||
!
this
.
user
.
userId
)
{
this
.
timer
&&
clearInterval
(
this
.
timer
)
const
message
=
this
.
$t
(
'login.tokenError'
)
this
.
$alert
(
message
,
{
confirmButtonText
:
this
.
$t
(
'login.re_login'
),
showClose
:
false
,
callback
:
function
(
action
,
instance
)
{
if
(
action
===
'confirm'
)
{
this
.
$store
.
dispatch
(
'user/logout'
).
then
(()
=>
{
location
.
reload
()
})
}
}.
bind
(
this
)
})
}
const
param
=
{
userId
:
this
.
user
.
userId
}
unReadCount
(
param
).
then
(
res
=>
{
this
.
count
=
res
.
data
})
},
search
()
{
const
param
=
{
status
:
false
,
...
...
frontend/src/utils/request.js
浏览文件 @
2fbed9fd
...
...
@@ -8,7 +8,7 @@ import i18n from '@/lang'
import
{
tryShowLoading
,
tryHideLoading
}
from
'./loading'
import
{
getLinkToken
,
setLinkToken
}
from
'@/utils/auth'
// import router from '@/router'
const
interruptTokenContineUrls
=
Config
.
interruptTokenContineUrls
//
const interruptTokenContineUrls = Config.interruptTokenContineUrls
const
TokenKey
=
Config
.
TokenKey
const
RefreshTokenKey
=
Config
.
RefreshTokenKey
const
LinkTokenKey
=
Config
.
LinkTokenKey
...
...
@@ -88,7 +88,8 @@ const checkAuth = response => {
})
}
// token到期后自动续命 刷新token
if
(
response
.
headers
[
RefreshTokenKey
]
&&
!
interruptTokenContineUrls
.
some
(
item
=>
response
.
config
.
url
.
indexOf
(
item
)
>=
0
))
{
// if (response.headers[RefreshTokenKey] && !interruptTokenContineUrls.some(item => response.config.url.indexOf(item) >= 0)) {
if
(
response
.
headers
[
RefreshTokenKey
])
{
const
refreshToken
=
response
.
headers
[
RefreshTokenKey
]
store
.
dispatch
(
'user/refreshToken'
,
refreshToken
)
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论