Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengtianlai3
ioc_sixiang_license
Commits
771b029c
Commit
771b029c
authored
Feb 08, 2023
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
c0c2d9f3
6d71c671
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
7 deletions
+38
-7
AlarmReadMapper.java
...main/java/iot/sixiang/license/mapper/AlarmReadMapper.java
+5
-2
AlarmReadServiceImpl.java
...ot/sixiang/license/service/impl/AlarmReadServiceImpl.java
+28
-3
AlarmReadMapper.xml
license/src/main/resources/mapper/AlarmReadMapper.xml
+5
-2
No files found.
license/src/main/java/iot/sixiang/license/mapper/AlarmReadMapper.java
View file @
771b029c
...
...
@@ -2,10 +2,13 @@ package iot.sixiang.license.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.entity.AlarmRead
;
import
iot.sixiang.license.model.vo.AlarmVo
;
import
java.util.List
;
/**
* <p>
*
Mapper 接口
* Mapper 接口
* </p>
*
* @author m33
...
...
@@ -13,5 +16,5 @@ import iot.sixiang.license.entity.AlarmRead;
*/
public
interface
AlarmReadMapper
extends
BaseMapper
<
AlarmRead
>
{
boolean
readAlarm
(
int
alarmId
,
int
typeId
,
String
title
,
String
content
,
int
userId
);
boolean
readAlarm
(
List
<
AlarmVo
>
alarmVos
,
int
userId
);
}
license/src/main/java/iot/sixiang/license/service/impl/AlarmReadServiceImpl.java
View file @
771b029c
...
...
@@ -33,6 +33,7 @@ public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead
AlarmMapper
alarmMapper
;
@Resource
AlarmReadMapper
alarmReadMapper
;
private
static
final
int
INSERT_BATCH_SIZE
=
1000
;
@Override
...
...
@@ -42,6 +43,7 @@ public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead
}
userId
=
Integer
.
valueOf
(
XssUtil
.
checkXSS
(
String
.
valueOf
(
userId
)));
List
<
AlarmVo
>
alarmList
=
alarmMapper
.
getAlarmList
(
userId
);
List
<
AlarmVo
>
newAlarmList
=
new
ArrayList
<>();
for
(
AlarmVo
alarm:
alarmList
)
{
if
(
alarm
.
getReadFlag
()
==
0
)
{
int
alarmId
=
alarm
.
getId
();
...
...
@@ -54,9 +56,32 @@ public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead
title
=
XssUtil
.
checkXSS
(
title
);
content
=
XssUtil
.
checkXSS
(
content
);
boolean
res
=
alarmReadMapper
.
readAlarm
(
alarmId
,
typeId
,
title
,
content
,
userId
);
if
(!
res
)
{
return
false
;
alarm
.
setTitle
(
title
);
alarm
.
setContent
(
content
);
alarm
.
setId
(
alarmId
);
alarm
.
setTypeId
(
typeId
);
newAlarmList
.
add
(
alarm
);
}
}
int
size
=
newAlarmList
.
size
();
if
(
size
<
INSERT_BATCH_SIZE
)
{
boolean
res
=
alarmReadMapper
.
readAlarm
(
newAlarmList
,
userId
);
if
(!
res
)
{
return
false
;
}
}
else
{
for
(
int
i
=
0
;
i
<=
size
/
INSERT_BATCH_SIZE
;
i
++)
{
List
<
AlarmVo
>
list
;
if
(
i
!=
size
/
INSERT_BATCH_SIZE
)
{
list
=
newAlarmList
.
subList
(
i
*
INSERT_BATCH_SIZE
,
i
*
INSERT_BATCH_SIZE
+
INSERT_BATCH_SIZE
);
}
else
{
list
=
newAlarmList
.
subList
(
i
*
INSERT_BATCH_SIZE
,
size
);
}
if
(
list
.
size
()
!=
0
)
{
boolean
res
=
alarmReadMapper
.
readAlarm
(
list
,
userId
);
if
(!
res
)
{
return
false
;
}
}
}
}
...
...
license/src/main/resources/mapper/AlarmReadMapper.xml
View file @
771b029c
...
...
@@ -2,7 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"iot.sixiang.license.mapper.AlarmReadMapper"
>
<insert
id=
"readAlarm"
parameterType=
"iot.sixiang.license.entity.AlarmRead"
>
insert into alarm_read (alarm_id, type_id, title, content, create_time, user_id) values (#{alarmId},#{typeId},#{title},#{content},now(),#{userId});
<insert
id=
"readAlarm"
>
insert into alarm_read (alarm_id, type_id, title, content, create_time, user_id) values
<foreach
collection=
"alarmVos"
separator=
","
item=
"item"
>
(#{item.id},#{item.typeId},#{item.title},#{item.content},now(),#{userId})
</foreach>
</insert>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment