Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
c9fe4a85
提交
c9fe4a85
authored
12月 03, 2021
作者:
zjm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(单位模块): 添加了单位名称重复的验证
添加了单位名称重复的验证
上级
c818c392
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
4 行删除
+17
-4
UnitsCache.java
.../main/java/com/tykj/dev/device/user/cache/UnitsCache.java
+1
-1
UnitsServiceImpl.java
...ev/device/user/subject/service/impl/UnitsServiceImpl.java
+16
-3
没有找到文件。
dev-user/src/main/java/com/tykj/dev/device/user/cache/UnitsCache.java
浏览文件 @
c9fe4a85
...
@@ -103,7 +103,7 @@ public class UnitsCache {
...
@@ -103,7 +103,7 @@ public class UnitsCache {
* 根据单位名称查询是否存在
* 根据单位名称查询是否存在
*/
*/
public
boolean
isNotName
(
String
name
){
public
boolean
isNotName
(
String
name
){
return
new
ArrayList
<>(
idMap
.
values
()).
stream
().
allMatch
(
units
->
!
units
.
getName
().
equals
(
name
));
return
new
ArrayList
<>(
idMap
.
values
()).
stream
().
noneMatch
(
units
->
units
.
getName
().
equals
(
name
));
}
}
}
}
dev-user/src/main/java/com/tykj/dev/device/user/subject/service/impl/UnitsServiceImpl.java
浏览文件 @
c9fe4a85
...
@@ -25,6 +25,7 @@ import org.springframework.data.domain.Pageable;
...
@@ -25,6 +25,7 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -495,6 +496,10 @@ public class UnitsServiceImpl implements UnitsService {
...
@@ -495,6 +496,10 @@ public class UnitsServiceImpl implements UnitsService {
@Override
@Override
public
List
<
Units
>
saveUnits
(
UnitsAddVo
unitsAddVo
)
{
public
List
<
Units
>
saveUnits
(
UnitsAddVo
unitsAddVo
)
{
if
(!
unitsCache
.
isNotName
(
unitsAddVo
.
getName
())){
throw
new
ApiException
(
ResponseEntity
.
status
(
20020
).
body
(
"单位名称重复"
));
}
Units
units
=
unitsAddVo
.
toUnits
();
Units
units
=
unitsAddVo
.
toUnits
();
//查询上级设备的单位
//查询上级设备的单位
Units
parentUnits
=
unitsCache
.
findById
(
unitsAddVo
.
getParentUnitId
());
Units
parentUnits
=
unitsCache
.
findById
(
unitsAddVo
.
getParentUnitId
());
...
@@ -537,6 +542,7 @@ public class UnitsServiceImpl implements UnitsService {
...
@@ -537,6 +542,7 @@ public class UnitsServiceImpl implements UnitsService {
}
}
}
}
@Override
@Override
@Transactional
public
Units
updateUnit
(
Units
units
)
{
public
Units
updateUnit
(
Units
units
)
{
Units
unitsOld
=
unitsCache
.
findById
(
units
.
getUnitId
());
Units
unitsOld
=
unitsCache
.
findById
(
units
.
getUnitId
());
if
(!
units
.
getLevel
().
equals
(
unitsOld
.
getLevel
())){
if
(!
units
.
getLevel
().
equals
(
unitsOld
.
getLevel
())){
...
@@ -573,6 +579,12 @@ public class UnitsServiceImpl implements UnitsService {
...
@@ -573,6 +579,12 @@ public class UnitsServiceImpl implements UnitsService {
sortingUnit
(
unitsOld
.
getShowOrder
(),
units
.
getShowOrder
());
sortingUnit
(
unitsOld
.
getShowOrder
(),
units
.
getShowOrder
());
}
}
}
}
if
(!
unitsOld
.
getName
().
equals
(
units
.
getName
())){
if
(!
unitsCache
.
isNotName
(
units
.
getName
())){
throw
new
ApiException
(
ResponseEntity
.
status
(
20020
).
body
(
"单位名称重复"
));
}
}
unitsDao
.
save
(
units
);
unitsDao
.
save
(
units
);
unitsCache
.
refresh
(
unitsDao
.
findAll
());
unitsCache
.
refresh
(
unitsDao
.
findAll
());
areaCache
.
refresh
(
areaDao
.
findAll
());
areaCache
.
refresh
(
areaDao
.
findAll
());
...
@@ -640,10 +652,11 @@ public class UnitsServiceImpl implements UnitsService {
...
@@ -640,10 +652,11 @@ public class UnitsServiceImpl implements UnitsService {
}
}
@Override
@Override
@Transactional
public
Units
save
(
Units
units
)
{
public
Units
save
(
Units
units
)
{
// if (!
unitsCache.isNotName(units.getName())){
if
(
unitsCache
.
isNotName
(
units
.
getName
())){
//
throw
new
ApiException
(
ResponseEntity
.
status
(
20020
).
body
(
"单位名称重复"
));
//
}
}
if
(
units
.
getAreaId
()
!=
null
&&
units
.
getAreaId
()
!=
0
)
{
if
(
units
.
getAreaId
()
!=
null
&&
units
.
getAreaId
()
!=
0
)
{
Optional
<
Area
>
optionalArea
=
areaDao
.
findById
(
units
.
getAreaId
());
Optional
<
Area
>
optionalArea
=
areaDao
.
findById
(
units
.
getAreaId
());
if
(
optionalArea
.
isPresent
())
{
if
(
optionalArea
.
isPresent
())
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论