Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
10629dd5
authored
Sep 05, 2023
by
lzy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
空间管理
parent
25e385c5
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
283 additions
and
5 deletions
db/space.sql
server-module/src/main/java/com/makeit/module/controller/space/PlatSpaceController.java
server-service/src/main/java/com/makeit/dto/platform/space/PlatSpaceAddDTO.java
server-service/src/main/java/com/makeit/dto/platform/space/PlatSpaceQueryDTO.java
server-service/src/main/java/com/makeit/dto/platform/space/PlatSpaceVO.java
server-service/src/main/java/com/makeit/entity/platform/space/PlatSpace.java
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatUserServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/space/PlatSpaceService.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
db/space.sql
0 → 100644
View file @
10629dd5
CREATE
TABLE
`plat_space`
(
`id`
VARCHAR
(
64
)
NOT
NULL
COMMENT
'id'
,
`name`
VARCHAR
(
128
)
NOT
NULL
COMMENT
'名称'
,
`parent_id`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'上级空间'
,
`type`
VARCHAR
(
4
)
NOT
NULL
COMMENT
'空间类型 1:小区/社区/街道 2:楼栋 3:单元 4 楼层'
,
`address`
VARCHAR
(
256
)
DEFAULT
NULL
COMMENT
'地址'
,
`longitude`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'经度'
,
`latitude`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'纬度'
,
`province`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'省(预留字段)'
,
`city`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'市(预留字段)'
,
`district`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'区(预留字段)'
,
`parent_path`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'父级全路径'
,
`create_by`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'创建者'
,
`create_date`
datetime
DEFAULT
NULL
COMMENT
'创建时间'
,
`update_by`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'更新者'
,
`update_date`
datetime
DEFAULT
NULL
COMMENT
'更新时间'
,
`del_flag`
INT
(
1
)
DEFAULT
'0'
COMMENT
'删除标记'
,
`tenant_id`
varchar
(
64
)
COLLATE
utf8mb4_general_ci
DEFAULT
NULL
COMMENT
' 租户id '
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
INNODB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'空间管理'
;
CREATE
TABLE
`plat_room`
(
`id`
VARCHAR
(
64
)
NOT
NULL
COMMENT
'id'
,
`name`
VARCHAR
(
128
)
NOT
NULL
COMMENT
'名称'
,
`space_id`
VARCHAR
(
64
)
NOT
NULL
COMMENT
'空间id'
,
`space_path`
VARCHAR
(
512
)
NOT
NULL
COMMENT
'空间全路径'
,
`space_path_name`
VARCHAR
(
512
)
NOT
NULL
COMMENT
'空间全路径名称'
,
`bed_number`
INT
(
4
)
NOT
NULL
COMMENT
'床位数量'
,
`description`
VARCHAR
(
1024
)
DEFAULT
NULL
COMMENT
'床位描述'
,
`create_by`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'创建者'
,
`create_date`
datetime
DEFAULT
NULL
COMMENT
'创建时间'
,
`update_by`
VARCHAR
(
64
)
DEFAULT
NULL
COMMENT
'更新者'
,
`update_date`
datetime
DEFAULT
NULL
COMMENT
'更新时间'
,
`del_flag`
INT
(
1
)
DEFAULT
'0'
COMMENT
'删除标记'
,
`tenant_id`
varchar
(
64
)
COLLATE
utf8mb4_general_ci
DEFAULT
NULL
COMMENT
' 租户id '
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
INNODB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'房间管理'
;
CREATE
TABLE
`plat_bed`
(
`id`
varchar
(
64
)
NOT
NULL
COMMENT
'id'
,
`name`
varchar
(
128
)
NOT
NULL
COMMENT
'床位名称 床位1,床位2'
,
`room_id`
varchar
(
64
)
NOT
NULL
COMMENT
'房间id'
,
`space_id`
varchar
(
64
)
NOT
NULL
COMMENT
'空间id'
,
`equipment_id`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'设备id'
,
`status`
char
(
1
)
DEFAULT
1
COMMENT
'是否空闲 1 是 0 否 '
,
`create_by`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'创建者'
,
`create_date`
datetime
DEFAULT
NULL
COMMENT
'创建时间'
,
`update_by`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'更新者'
,
`update_date`
datetime
DEFAULT
NULL
COMMENT
'更新时间'
,
`del_flag`
int
(
1
)
DEFAULT
'0'
COMMENT
'删除标记'
,
`tenant_id`
varchar
(
64
)
COLLATE
utf8mb4_general_ci
DEFAULT
NULL
COMMENT
' 租户id '
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'床位管理'
;
-- 待完善 区域设置表
CREATE
TABLE
`plat_region_setting`
(
`id`
varchar
(
64
)
NOT
NULL
COMMENT
'id'
,
`name`
varchar
(
128
)
NOT
NULL
COMMENT
'区域名称'
,
`room_id`
varchar
(
64
)
NOT
NULL
COMMENT
'房间id'
,
`range_map`
varchar
(
1024
)
NOT
NULL
COMMENT
'区域地图 json'
,
`create_by`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'创建者'
,
`create_date`
datetime
DEFAULT
NULL
COMMENT
'创建时间'
,
`update_by`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'更新者'
,
`update_date`
datetime
DEFAULT
NULL
COMMENT
'更新时间'
,
`del_flag`
int
(
1
)
DEFAULT
'0'
COMMENT
'删除标记'
,
`tenant_id`
varchar
(
64
)
COLLATE
utf8mb4_general_ci
DEFAULT
NULL
COMMENT
' 租户id '
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'区域设置'
;
CREATE
TABLE
`plat_region_setting_location`
(
`id`
varchar
(
64
)
NOT
NULL
COMMENT
'id'
,
`region_setting_id`
varchar
(
64
)
NOT
NULL
COMMENT
'区域设置Id'
,
`install_type`
char
(
1
)
NOT
NULL
COMMENT
'安装方式 0-顶装 1-侧装'
,
`toward`
char
(
1
)
NOT
NULL
COMMENT
'设备朝向 0-上 1-下 2-左 3-右'
,
`region_name`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'区域名称'
,
`region_range`
varchar
(
128
)
DEFAULT
NULL
COMMENT
'区域定位'
,
`room_range`
varchar
(
128
)
DEFAULT
NULL
COMMENT
'房间门定位'
,
`equipment_range`
varchar
(
128
)
DEFAULT
NULL
COMMENT
'设备定位'
,
`equipment_id`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'设备Id'
,
`create_by`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'创建者'
,
`create_date`
datetime
DEFAULT
NULL
COMMENT
'创建时间'
,
`update_by`
varchar
(
64
)
DEFAULT
NULL
COMMENT
'更新者'
,
`update_date`
datetime
DEFAULT
NULL
COMMENT
'更新时间'
,
`del_flag`
int
(
1
)
DEFAULT
'0'
COMMENT
'删除标记'
,
`tenant_id`
varchar
(
64
)
COLLATE
utf8mb4_general_ci
DEFAULT
NULL
COMMENT
' 租户id '
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'区域设置定位'
;
server-module/src/main/java/com/makeit/module/controller/space/PlatSpaceController.java
View file @
10629dd5
package
com
.
makeit
.
module
.
controller
.
space
;
package
com
.
makeit
.
module
.
controller
.
space
;
import
com.makeit.common.dto.BaseIdDTO
;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseUtils
;
import
com.makeit.common.response.ApiResponseUtils
;
import
com.makeit.dto.platform.space.PlatSpaceAddDTO
;
import
com.makeit.dto.platform.space.PlatSpaceAddDTO
;
import
com.makeit.dto.platform.space.PlatSpaceQueryDTO
;
import
com.makeit.dto.platform.space.PlatSpaceVO
;
import
com.makeit.service.platform.space.PlatSpaceService
;
import
com.makeit.service.platform.space.PlatSpaceService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -13,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestBody;
...
@@ -13,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
/**
* @Author:lzy
* @Author:lzy
* @Date:2023/9/4 16:52
* @Date:2023/9/4 16:52
...
@@ -33,5 +38,39 @@ public class PlatSpaceController {
...
@@ -33,5 +38,39 @@ public class PlatSpaceController {
return
ApiResponseUtils
.
success
();
return
ApiResponseUtils
.
success
();
}
}
@ApiOperation
(
"编辑"
)
@PostMapping
(
"edit"
)
public
ApiResponseEntity
<?>
edit
(
@Validated
@RequestBody
PlatSpaceAddDTO
dto
)
{
spaceService
.
edit
(
dto
);
return
ApiResponseUtils
.
success
();
}
@ApiOperation
(
"详情"
)
@PostMapping
(
"view"
)
public
ApiResponseEntity
<
PlatSpaceAddDTO
>
view
(
@RequestBody
BaseIdDTO
baseIdDTO
)
{
PlatSpaceAddDTO
data
=
spaceService
.
view
(
baseIdDTO
.
getId
());
return
ApiResponseUtils
.
success
(
data
);
}
@ApiOperation
(
"删除"
)
@PostMapping
(
"del"
)
public
ApiResponseEntity
<?>
del
(
@RequestBody
BaseIdDTO
baseIdDTO
)
{
spaceService
.
del
(
baseIdDTO
.
getId
());
return
ApiResponseUtils
.
success
();
}
@ApiOperation
(
"树"
)
@PostMapping
(
"tree"
)
public
ApiResponseEntity
<
List
<
PlatSpaceVO
>>
tree
(
@RequestBody
PlatSpaceQueryDTO
dto
)
{
List
<
PlatSpaceVO
>
data
=
spaceService
.
tree
(
dto
);
return
ApiResponseUtils
.
success
(
data
);
}
@ApiOperation
(
"树-无权限"
)
@PostMapping
(
"listTreeAuthIgnore"
)
public
ApiResponseEntity
<
List
<
PlatSpaceVO
>>
listTreeAuthIgnore
(
@RequestBody
PlatSpaceQueryDTO
dto
)
{
List
<
PlatSpaceVO
>
data
=
spaceService
.
tree
(
dto
);
return
ApiResponseUtils
.
success
(
data
);
}
}
}
server-service/src/main/java/com/makeit/dto/platform/space/PlatSpaceAddDTO.java
View file @
10629dd5
package
com
.
makeit
.
dto
.
platform
.
space
;
package
com
.
makeit
.
dto
.
platform
.
space
;
import
com.makeit.common.dto.BaseIdDTO
;
import
com.makeit.common.dto.BaseTenantDTO
;
import
com.makeit.common.dto.BaseTenantDTO
;
import
com.makeit.enums.platform.space.PlatSpaceEnum
;
import
com.makeit.enums.platform.space.PlatSpaceEnum
;
import
com.makeit.global.validator.DictEnum
;
import
com.makeit.global.validator.DictEnum
;
...
@@ -19,15 +20,15 @@ import javax.validation.constraints.Size;
...
@@ -19,15 +20,15 @@ import javax.validation.constraints.Size;
@Data
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"PlatSpaceAddDTO对象"
,
description
=
"空间添加"
)
@ApiModel
(
value
=
"PlatSpaceAddDTO对象"
,
description
=
"空间添加"
)
public
class
PlatSpaceAddDTO
extends
Base
Tenant
DTO
{
public
class
PlatSpaceAddDTO
extends
Base
Id
DTO
{
@NotBlank
(
message
=
"空间名称不能为空"
)
@NotBlank
(
message
=
"空间名称不能为空"
)
@Size
(
max
=
50
,
message
=
"空间名称最长为50个字符"
)
@Size
(
max
=
50
,
message
=
"空间名称最长为50个字符"
)
@ApiModelProperty
(
value
=
"空间名称"
)
@ApiModelProperty
(
value
=
"空间名称"
,
required
=
true
)
private
String
name
;
private
String
name
;
@DictEnum
(
em
=
PlatSpaceEnum
.
TypeEnum
.
class
,
message
=
"空间类型可选值为{m}"
)
@DictEnum
(
em
=
PlatSpaceEnum
.
TypeEnum
.
class
,
message
=
"空间类型可选值为{m}"
)
@ApiModelProperty
(
value
=
"空间类型 数据字典 1:小区/社区/街道 2:楼栋 3:单元 4 楼层"
)
@ApiModelProperty
(
value
=
"空间类型 数据字典 1:小区/社区/街道 2:楼栋 3:单元 4 楼层"
,
required
=
true
)
private
String
type
;
private
String
type
;
@ApiModelProperty
(
value
=
"上级空间"
)
@ApiModelProperty
(
value
=
"上级空间"
)
...
@@ -42,4 +43,7 @@ public class PlatSpaceAddDTO extends BaseTenantDTO {
...
@@ -42,4 +43,7 @@ public class PlatSpaceAddDTO extends BaseTenantDTO {
@ApiModelProperty
(
value
=
"纬度"
)
@ApiModelProperty
(
value
=
"纬度"
)
private
String
latitude
;
private
String
latitude
;
@ApiModelProperty
(
value
=
"上级全路径"
,
required
=
true
)
private
String
parentPath
;
}
}
server-service/src/main/java/com/makeit/dto/platform/space/PlatSpaceQueryDTO.java
0 → 100644
View file @
10629dd5
package
com
.
makeit
.
dto
.
platform
.
space
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* @Author:lzy
* @Date:2023/9/5 11:45
* @Describe:
*/
@Data
@ApiModel
(
"PlatSpaceQueryDTO参数"
)
public
class
PlatSpaceQueryDTO
{
@ApiModelProperty
(
"空间名称"
)
private
String
name
;
}
server-service/src/main/java/com/makeit/dto/platform/space/PlatSpaceVO.java
0 → 100644
View file @
10629dd5
package
com
.
makeit
.
dto
.
platform
.
space
;
import
com.makeit.common.dto.BaseIdDTO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
/**
* @Author:lzy
* @Date:2023/9/5 11:41
* @Describe:
*/
@Data
@ApiModel
(
"PlatSpaceVO参数"
)
public
class
PlatSpaceVO
extends
BaseIdDTO
{
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"父级Id"
)
private
String
parentId
;
@ApiModelProperty
(
"子集"
)
private
List
<
PlatSpaceVO
>
child
;
}
server-service/src/main/java/com/makeit/entity/platform/space/PlatSpace.java
View file @
10629dd5
...
@@ -43,5 +43,8 @@ public class PlatSpace extends BaseBusEntity {
...
@@ -43,5 +43,8 @@ public class PlatSpace extends BaseBusEntity {
@ApiModelProperty
(
value
=
"区"
)
@ApiModelProperty
(
value
=
"区"
)
private
String
district
;
private
String
district
;
@ApiModelProperty
(
value
=
"上级全路径"
)
private
String
parentPath
;
}
}
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatUserServiceImpl.java
View file @
10629dd5
...
@@ -364,7 +364,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
...
@@ -364,7 +364,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
/**
/**
* 校验机场
* 校验机场
*/
*/
checkUserOrg
(
platUser
);
//
checkUserOrg(platUser);
PlatUserLoginVO
userLoginVO
=
BeanDtoVoUtils
.
convert
(
platUser
,
PlatUserLoginVO
.
class
);
PlatUserLoginVO
userLoginVO
=
BeanDtoVoUtils
.
convert
(
platUser
,
PlatUserLoginVO
.
class
);
...
...
server-service/src/main/java/com/makeit/service/platform/space/PlatSpaceService.java
View file @
10629dd5
...
@@ -2,8 +2,12 @@ package com.makeit.service.platform.space;
...
@@ -2,8 +2,12 @@ package com.makeit.service.platform.space;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.makeit.dto.platform.space.PlatSpaceAddDTO
;
import
com.makeit.dto.platform.space.PlatSpaceAddDTO
;
import
com.makeit.dto.platform.space.PlatSpaceQueryDTO
;
import
com.makeit.dto.platform.space.PlatSpaceVO
;
import
com.makeit.entity.platform.space.PlatSpace
;
import
com.makeit.entity.platform.space.PlatSpace
;
import
java.util.List
;
/**
/**
* @Author:lzy
* @Author:lzy
* @Date:2023/8/31 16:17
* @Date:2023/8/31 16:17
...
@@ -28,4 +32,18 @@ public interface PlatSpaceService extends IService<PlatSpace> {
...
@@ -28,4 +32,18 @@ public interface PlatSpaceService extends IService<PlatSpace> {
* @param id
* @param id
*/
*/
void
del
(
String
id
);
void
del
(
String
id
);
/**
* 树结构
* @param dto
* @return
*/
List
<
PlatSpaceVO
>
tree
(
PlatSpaceQueryDTO
dto
);
/**
* 详情
* @param id
* @return
*/
PlatSpaceAddDTO
view
(
String
id
);
}
}
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
View file @
10629dd5
...
@@ -3,6 +3,8 @@ package com.makeit.service.platform.space.impl;
...
@@ -3,6 +3,8 @@ package com.makeit.service.platform.space.impl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.makeit.dto.platform.space.PlatSpaceAddDTO
;
import
com.makeit.dto.platform.space.PlatSpaceAddDTO
;
import
com.makeit.dto.platform.space.PlatSpaceQueryDTO
;
import
com.makeit.dto.platform.space.PlatSpaceVO
;
import
com.makeit.entity.platform.space.PlatSpace
;
import
com.makeit.entity.platform.space.PlatSpace
;
import
com.makeit.enums.CodeMessageEnum
;
import
com.makeit.enums.CodeMessageEnum
;
import
com.makeit.exception.BusinessException
;
import
com.makeit.exception.BusinessException
;
...
@@ -13,6 +15,11 @@ import jodd.util.StringUtil;
...
@@ -13,6 +15,11 @@ import jodd.util.StringUtil;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* @Author:lzy
* @Author:lzy
* @Date:2023/8/31 16:17
* @Date:2023/8/31 16:17
...
@@ -24,9 +31,15 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -24,9 +31,15 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
private
void
check
(
PlatSpaceAddDTO
dto
){
private
void
check
(
PlatSpaceAddDTO
dto
){
LambdaQueryWrapper
<
PlatSpace
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
PlatSpace
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
PlatSpace:
:
getParentId
,
dto
.
getParentId
());
queryWrapper
.
eq
(
PlatSpace:
:
getName
,
dto
.
getName
());
queryWrapper
.
eq
(
PlatSpace:
:
getName
,
dto
.
getName
());
queryWrapper
.
ne
(
StringUtil
.
isNotEmpty
(
dto
.
getId
()),
PlatSpace:
:
getId
,
dto
.
getId
());
queryWrapper
.
ne
(
StringUtil
.
isNotEmpty
(
dto
.
getId
()),
PlatSpace:
:
getId
,
dto
.
getId
());
if
(
StringUtil
.
isEmpty
(
dto
.
getParentId
())){
queryWrapper
.
isNull
(
PlatSpace:
:
getParentId
);
}
else
{
queryWrapper
.
eq
(
PlatSpace:
:
getParentId
,
dto
.
getParentId
());
}
if
(
this
.
count
(
queryWrapper
)
>
0
){
if
(
this
.
count
(
queryWrapper
)
>
0
){
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_NAME_DUPLICATE
);
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_NAME_DUPLICATE
);
}
}
...
@@ -53,6 +66,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -53,6 +66,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
space
.
setLatitude
(
dto
.
getLatitude
());
space
.
setLatitude
(
dto
.
getLatitude
());
space
.
setLongitude
(
dto
.
getLongitude
());
space
.
setLongitude
(
dto
.
getLongitude
());
space
.
setParentId
(
dto
.
getParentId
());
space
.
setParentId
(
dto
.
getParentId
());
space
.
setParentPath
(
dto
.
getParentPath
());
this
.
updateById
(
space
);
this
.
updateById
(
space
);
}
}
...
@@ -62,4 +76,61 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -62,4 +76,61 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
this
.
removeById
(
id
);
this
.
removeById
(
id
);
}
}
@Override
public
List
<
PlatSpaceVO
>
tree
(
PlatSpaceQueryDTO
dto
)
{
LambdaQueryWrapper
<
PlatSpace
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
like
(
StringUtil
.
isNotEmpty
(
dto
.
getName
()),
PlatSpace:
:
getName
,
dto
.
getName
());
List
<
PlatSpace
>
list
=
this
.
list
(
queryWrapper
);
//父级
List
<
PlatSpace
>
listParent
=
list
.
stream
().
filter
(
item
->
StringUtil
.
isEmpty
(
item
.
getParentId
())).
collect
(
Collectors
.
toList
());
//子集
List
<
PlatSpace
>
listChild
=
list
.
stream
().
filter
(
item
->
item
.
getParentId
()
!=
null
).
collect
(
Collectors
.
toList
());
Map
<
String
,
List
<
PlatSpace
>>
map
=
listChild
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatSpace:
:
getParentId
));
List
<
PlatSpaceVO
>
data
=
new
ArrayList
<>();
for
(
PlatSpace
space:
listParent
){
PlatSpaceVO
vo
=
convertToVO
(
space
);
vo
=
child
(
vo
,
map
);
data
.
add
(
vo
);
}
return
data
;
}
@Override
public
PlatSpaceAddDTO
view
(
String
id
)
{
PlatSpace
space
=
getById
(
id
);
PlatSpaceAddDTO
data
=
BeanDtoVoUtils
.
convert
(
space
,
PlatSpaceAddDTO
.
class
);
return
data
;
}
private
PlatSpaceVO
child
(
PlatSpaceVO
vo
,
Map
<
String
,
List
<
PlatSpace
>>
map
){
if
(!
map
.
containsKey
(
vo
.
getId
())){
return
vo
;
}
List
<
PlatSpace
>
list
=
map
.
get
(
vo
.
getId
());
List
<
PlatSpaceVO
>
listChild
=
new
ArrayList
<>();
for
(
PlatSpace
item:
list
){
PlatSpaceVO
dto
=
convertToVO
(
item
);
this
.
child
(
dto
,
map
);
listChild
.
add
(
dto
);
}
vo
.
setChild
(
listChild
);
return
vo
;
}
private
PlatSpaceVO
convertToVO
(
PlatSpace
space
){
PlatSpaceVO
vo
=
new
PlatSpaceVO
();
vo
.
setName
(
space
.
getName
());
vo
.
setParentId
(
space
.
getId
());
vo
.
setId
(
space
.
getId
());
return
vo
;
}
}
}
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