Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
govdna
Project
Project
Details
Activity
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
开发共享交流平台
govdna
Commits
218df9be
Commit
218df9be
authored
6 years ago
by
刘弈臻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
行政区划递归数据-刘弈臻
parent
d6ab3746
master
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
276 additions
and
0 deletions
+276
-0
AreaController.java
...com/govmade/modules/system/controller/AreaController.java
+71
-0
AreaDao.java
src/main/java/com/govmade/modules/system/dao/AreaDao.java
+18
-0
AreaEntity.java
...in/java/com/govmade/modules/system/entity/AreaEntity.java
+84
-0
AreaService.java
.../java/com/govmade/modules/system/service/AreaService.java
+38
-0
AreaServiceImpl.java
.../govmade/modules/system/service/impl/AreaServiceImpl.java
+65
-0
No files found.
src/main/java/com/govmade/modules/system/controller/AreaController.java
0 → 100644
View file @
218df9be
package
com
.
govmade
.
modules
.
system
.
controller
;
import
java.util.List
;
import
java.util.Set
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.govmade.common.utils.R
;
import
com.govmade.modules.basic.controller.AbstractController
;
import
com.govmade.modules.system.entity.AreaEntity
;
import
com.govmade.modules.system.service.AreaService
;
/**
* 系统管理 - 行政区划设置
*
* @author 刘弈臻
* @date 2018年8月9日
*/
@RestController
@RequestMapping
(
"/system/area"
)
public
class
AreaController
extends
AbstractController
{
@Autowired
private
AreaService
areaService
;
/**
* 所有区划数据树结构
*/
@GetMapping
(
"/allList"
)
public
R
allList
()
{
List
<
AreaEntity
>
data
=
areaService
.
queryAll
();
return
R
.
ok
().
put
(
"data"
,
data
);
}
/**
* 保存或更新区划
*/
@PostMapping
(
"/save"
)
public
R
save
(
AreaEntity
area
)
{
if
(
null
==
area
.
getId
())
{
if
(
this
.
areaService
.
checkArea
(
area
.
getName
())
>
0
)
{
return
R
.
error
(
area
.
getName
()
+
" 已存在!"
);
}
}
areaService
.
save
(
area
);
return
R
.
ok
();
}
/**
* 删除、批量删除区划
*
* @param ids
* @return
*/
@DeleteMapping
(
"/delete"
)
public
R
deleteArea
(
@RequestParam
Set
<
Long
>
ids
)
{
areaService
.
deleteBatchIds
(
ids
);
return
R
.
ok
();
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/modules/system/dao/AreaDao.java
0 → 100644
View file @
218df9be
package
com
.
govmade
.
modules
.
system
.
dao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.govmade.modules.system.entity.AreaEntity
;
/**
* 系统管理 - 行政区划设置
*
* @author 刘弈臻
* @date 2018年8月9日
*/
@Mapper
public
interface
AreaDao
extends
BaseMapper
<
AreaEntity
>
{
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/modules/system/entity/AreaEntity.java
0 → 100644
View file @
218df9be
package
com
.
govmade
.
modules
.
system
.
entity
;
import
java.util.List
;
import
com.baomidou.mybatisplus.annotations.TableField
;
import
com.baomidou.mybatisplus.annotations.TableName
;
import
com.govmade.modules.basic.entity.BaseEntity
;
/**
* 系统管理 - 行政区划设置
*
* @author 刘弈臻
* @date 2018年8月9日
*/
@TableName
(
"system_areas"
)
public
class
AreaEntity
extends
BaseEntity
<
Long
>{
private
static
final
long
serialVersionUID
=
1L
;
private
Long
pid
;
//上级区划ID
private
String
name
;
//区划名称
private
String
code
;
//区划代码
private
Integer
level
;
//区划级别
private
Long
weight
;
//权重
@TableField
(
exist
=
false
)
private
List
<
AreaEntity
>
children
;
public
Long
getPid
()
{
return
pid
;
}
public
void
setPid
(
Long
pid
)
{
this
.
pid
=
pid
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
Integer
getLevel
()
{
return
level
;
}
public
void
setLevel
(
Integer
level
)
{
this
.
level
=
level
;
}
public
Long
getWeight
()
{
return
weight
;
}
public
void
setWeight
(
Long
weight
)
{
this
.
weight
=
weight
;
}
public
List
<
AreaEntity
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
AreaEntity
>
children
)
{
this
.
children
=
children
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/modules/system/service/AreaService.java
0 → 100644
View file @
218df9be
package
com
.
govmade
.
modules
.
system
.
service
;
import
java.util.List
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.govmade.modules.system.entity.AreaEntity
;
/**
* 系统管理 - 行政区划设置
*
* @author 刘弈臻
* @date 2018年8月9日
*/
public
interface
AreaService
extends
IService
<
AreaEntity
>{
/**
* 查询所有数据树结构
*/
List
<
AreaEntity
>
queryAll
();
/**
* 保存或修改行政区划
*/
void
save
(
AreaEntity
area
);
/**
* 删除行政区划
*/
void
deleteBatch
(
Long
[]
areaIds
);
/**
* 行政区划查重
*/
Integer
checkArea
(
String
name
);
}
This diff is collapsed.
Click to expand it.
src/main/java/com/govmade/modules/system/service/impl/AreaServiceImpl.java
0 → 100644
View file @
218df9be
package
com
.
govmade
.
modules
.
system
.
service
.
impl
;
import
java.util.List
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.google.common.collect.Lists
;
import
com.govmade.modules.system.dao.AreaDao
;
import
com.govmade.modules.system.entity.AreaEntity
;
import
com.govmade.modules.system.service.AreaService
;
/**
* 系统管理 - 行政区划设置
*
* @author 刘弈臻
* @date 2018年8月9日
*/
@Service
(
"AreaService"
)
public
class
AreaServiceImpl
extends
ServiceImpl
<
AreaDao
,
AreaEntity
>
implements
AreaService
{
@Override
public
List
<
AreaEntity
>
queryAll
()
{
List
<
AreaEntity
>
areaList
=
this
.
selectList
(
new
EntityWrapper
<
AreaEntity
>().
eq
(
"state"
,
1
));
List
<
AreaEntity
>
aTreeList
=
buildAreaTree
(
areaList
,
0L
);
return
aTreeList
;
}
/**
*递归方法
*/
private
List
<
AreaEntity
>
buildAreaTree
(
List
<
AreaEntity
>
list
,
long
id
)
{
List
<
AreaEntity
>
aList
=
Lists
.
newArrayList
();
for
(
AreaEntity
a
:
list
)
{
if
(
id
==
a
.
getPid
())
{
a
.
setChildren
(
buildAreaTree
(
list
,
a
.
getId
()));
aList
.
add
(
a
);
}
}
return
aList
;
}
@Override
public
void
save
(
AreaEntity
area
)
{
super
.
insertOrUpdate
(
area
);
}
@Override
public
void
deleteBatch
(
Long
[]
areaIds
)
{
// TODO Auto-generated method stub
}
@Override
public
Integer
checkArea
(
String
name
)
{
return
super
.
selectCount
(
new
EntityWrapper
<
AreaEntity
>().
eq
(
"name"
,
name
));
}
}
This diff is collapsed.
Click to expand it.
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