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
0fabd1b1
Commit
0fabd1b1
authored
Aug 21, 2018
by
Fred
Browse files
Options
Browse Files
Download
Plain Diff
地区树,数据变更
parents
31ad8778
72ac9948
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
492 additions
and
73 deletions
+492
-73
PageTreeUtils.java
src/main/java/com/govmade/common/utils/PageTreeUtils.java
+87
-0
AreaController.java
...com/govmade/modules/system/controller/AreaController.java
+2
-2
DepartController.java
...m/govmade/modules/system/controller/DepartController.java
+1
-1
DictController.java
...com/govmade/modules/system/controller/DictController.java
+46
-0
MenuController.java
...com/govmade/modules/system/controller/MenuController.java
+31
-7
AreaDao.java
src/main/java/com/govmade/modules/system/dao/AreaDao.java
+2
-1
DictDao.java
src/main/java/com/govmade/modules/system/dao/DictDao.java
+13
-0
MenuDao.java
src/main/java/com/govmade/modules/system/dao/MenuDao.java
+16
-0
DictEntity.java
...in/java/com/govmade/modules/system/entity/DictEntity.java
+24
-0
MenuEntity.java
...in/java/com/govmade/modules/system/entity/MenuEntity.java
+15
-0
AreaService.java
.../java/com/govmade/modules/system/service/AreaService.java
+2
-3
DepartService.java
...ava/com/govmade/modules/system/service/DepartService.java
+1
-1
DictService.java
.../java/com/govmade/modules/system/service/DictService.java
+24
-3
MenuService.java
.../java/com/govmade/modules/system/service/MenuService.java
+8
-1
AreaServiceImpl.java
.../govmade/modules/system/service/impl/AreaServiceImpl.java
+37
-32
DepartServiceImpl.java
...ovmade/modules/system/service/impl/DepartServiceImpl.java
+1
-1
DictServiceImpl.java
.../govmade/modules/system/service/impl/DictServiceImpl.java
+54
-5
MenuServiceImpl.java
.../govmade/modules/system/service/impl/MenuServiceImpl.java
+40
-5
AreaDao.xml
src/main/resources/mapper/system/AreaDao.xml
+12
-10
DictDao.xml
src/main/resources/mapper/system/DictDao.xml
+35
-1
MenuDao.xml
src/main/resources/mapper/system/MenuDao.xml
+41
-0
No files found.
src/main/java/com/govmade/common/utils/PageTreeUtils.java
0 → 100644
View file @
0fabd1b1
package
com
.
govmade
.
common
.
utils
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 树形数据分页工具类
*
* @author 刘弈臻
* @date 2018年8月14日
*/
public
class
PageTreeUtils
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
int
totalCount
;
// 总记录数
private
int
pageSize
;
// 每页记录数
private
int
totalPage
;
// 总页数
private
int
currPage
;
// 当前页数
private
List
<?>
list
;
// 列表数据
/**
* 分页
*
* @param list
* 列表数据
* @param totalCount
* 总记录数
* @param pageSize
* 每页记录数
* @param currPage
* 当前页数
*/
public
PageTreeUtils
(
List
<?>
list
,
int
totalCount
,
int
pageSize
,
int
currPage
)
{
this
.
list
=
list
;
this
.
totalCount
=
totalCount
;
this
.
pageSize
=
pageSize
;
this
.
currPage
=
currPage
;
this
.
totalPage
=
(
int
)
Math
.
ceil
((
double
)
totalCount
/
pageSize
);
}
public
int
getTotalCount
()
{
return
totalCount
;
}
public
void
setTotalCount
(
int
totalCount
)
{
this
.
totalCount
=
totalCount
;
}
public
int
getPageSize
()
{
return
pageSize
;
}
public
void
setPageSize
(
int
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
public
int
getTotalPage
()
{
return
totalPage
;
}
public
void
setTotalPage
(
int
totalPage
)
{
this
.
totalPage
=
totalPage
;
}
public
int
getCurrPage
()
{
return
currPage
;
}
public
void
setCurrPage
(
int
currPage
)
{
this
.
currPage
=
currPage
;
}
public
List
<?>
getList
()
{
return
list
;
}
public
void
setList
(
List
<?>
list
)
{
this
.
list
=
list
;
}
}
src/main/java/com/govmade/modules/system/controller/AreaController.java
View file @
0fabd1b1
...
...
@@ -12,7 +12,7 @@ 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.PageUtils
;
import
com.govmade.common.utils.Page
Tree
Utils
;
import
com.govmade.common.utils.R
;
import
com.govmade.common.validator.Assert
;
import
com.govmade.modules.basic.controller.AbstractController
;
...
...
@@ -38,7 +38,7 @@ public class AreaController extends AbstractController{
*/
@GetMapping
(
"/listTree"
)
public
R
listTree
(
@RequestParam
Map
<
String
,
Object
>
params
)
{
PageUtils
page
=
areaService
.
queryPage
(
params
);
Page
Tree
Utils
page
=
areaService
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
page
);
}
...
...
src/main/java/com/govmade/modules/system/controller/DepartController.java
View file @
0fabd1b1
...
...
@@ -75,7 +75,7 @@ public class DepartController extends AbstractController{
if
(
this
.
userService
.
userCount
(
depart
.
getId
())>
0
)
{
return
R
.
error
(
"选中部门下有用户!!"
);
}
departService
.
delete
Batch
(
depart
);
departService
.
delete
Depart
(
depart
);
return
R
.
ok
();
}
...
...
src/main/java/com/govmade/modules/system/controller/DictController.java
View file @
0fabd1b1
...
...
@@ -2,12 +2,20 @@ package com.govmade.modules.system.controller;
import
java.util.List
;
import
java.util.Map
;
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.RequestBody
;
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.PageTreeUtils
;
import
com.govmade.common.utils.R
;
import
com.govmade.common.validator.Assert
;
import
com.govmade.modules.basic.controller.AbstractController
;
import
com.govmade.modules.system.entity.DictEntity
;
import
com.govmade.modules.system.service.DictService
;
...
...
@@ -37,5 +45,43 @@ public class DictController extends AbstractController {
return
R
.
ok
().
put
(
"childs"
,
dictList
);
}
/**
* 所有字典数据树结构
*/
@GetMapping
(
"/listTree"
)
public
R
listTree
(
@RequestParam
Map
<
String
,
Object
>
params
)
{
PageTreeUtils
page
=
dictService
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
page
);
}
/**
* 保存或更新字典
*/
@PostMapping
(
"/save"
)
public
R
save
(
DictEntity
dict
)
{
if
(
null
==
dict
.
getId
())
{
if
(
this
.
dictService
.
checkDict
(
dict
.
getName
())
>
0
)
{
return
R
.
error
(
dict
.
getName
()
+
" 已存在!"
);
}
}
dictService
.
save
(
dict
);
return
R
.
ok
();
}
/**
* 批量删除字典
*
* @param ids
* @return
*/
@DeleteMapping
(
"/delete"
)
public
R
deleteDict
(
@RequestBody
Set
<
Long
>
ids
)
{
Assert
.
isNull
(
ids
,
"删除项不能为空"
);
dictService
.
deleteBatch
(
ids
);
return
R
.
ok
();
}
}
src/main/java/com/govmade/modules/system/controller/MenuController.java
View file @
0fabd1b1
package
com
.
govmade
.
modules
.
system
.
controller
;
import
java.util.Map
;
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.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
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.PageTreeUtils
;
import
com.govmade.common.utils.R
;
import
com.govmade.common.validator.Assert
;
import
com.govmade.modules.basic.controller.AbstractController
;
import
com.govmade.modules.system.entity.MenuEntity
;
import
com.govmade.modules.system.service.MenuService
;
...
...
@@ -28,17 +35,17 @@ public class MenuController extends AbstractController {
private
MenuService
menuService
;
/**
*
菜单列表
*
所有菜单数据树结构
*/
@GetMapping
(
"/list"
)
public
R
list
(
Map
<
String
,
Object
>
params
)
{
menuService
.
queryPage
(
params
);
return
null
;
@GetMapping
(
"/listTree"
)
public
R
listTree
(
@RequestParam
Map
<
String
,
Object
>
params
)
{
PageTreeUtils
page
=
menuService
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
page
);
}
/**
* 保存或更新
用户
* 保存或更新
菜单
*/
@PostMapping
(
"/save"
)
public
R
save
(
MenuEntity
menu
)
{
...
...
@@ -48,6 +55,7 @@ public class MenuController extends AbstractController {
return
R
.
error
(
menu
.
getName
()
+
" 已存在!"
);
}
}
menuService
.
save
(
menu
);
return
R
.
ok
();
}
...
...
@@ -61,4 +69,20 @@ public class MenuController extends AbstractController {
public
R
info
(
@PathVariable
(
"id"
)
Long
id
)
{
return
R
.
ok
().
put
(
"menu"
,
menuService
.
queryById
(
id
));
}
/**
* 批量删除菜单
*
* @param ids
* @return
*/
@DeleteMapping
(
"/delete"
)
public
R
deleteMenu
(
@RequestBody
Set
<
Long
>
ids
)
{
Assert
.
isNull
(
ids
,
"删除项不能为空"
);
menuService
.
deleteBatch
(
ids
);
return
R
.
ok
();
}
}
src/main/java/com/govmade/modules/system/dao/AreaDao.java
View file @
0fabd1b1
package
com
.
govmade
.
modules
.
system
.
dao
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.apache.ibatis.annotations.Mapper
;
...
...
@@ -26,5 +27,5 @@ public interface AreaDao extends BaseMapper<AreaEntity> {
/**
* 查询树形数据
*/
List
<
AreaEntity
>
listTree
(
@Param
(
"
name"
)
String
name
);
List
<
AreaEntity
>
listTree
(
@Param
(
"
params"
)
Map
<
String
,
Object
>
params
);
}
src/main/java/com/govmade/modules/system/dao/DictDao.java
View file @
0fabd1b1
package
com
.
govmade
.
modules
.
system
.
dao
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
...
...
@@ -19,4 +21,15 @@ import com.govmade.modules.system.entity.DictEntity;
public
interface
DictDao
extends
BaseMapper
<
DictEntity
>
{
List
<
DictEntity
>
selectChilds
(
@Param
(
"pValue"
)
String
pValue
);
/**
* 批量删除或删除
*/
void
deleteBatch
(
@Param
(
"ids"
)
Set
<
Long
>
ids
);
/**
* 查询树形数据
*/
List
<
DictEntity
>
listTree
(
@Param
(
"params"
)
Map
<
String
,
Object
>
params
);
}
src/main/java/com/govmade/modules/system/dao/MenuDao.java
View file @
0fabd1b1
package
com
.
govmade
.
modules
.
system
.
dao
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
com.baomidou.mybatisplus.mapper.BaseMapper
;
import
com.govmade.modules.system.entity.MenuEntity
;
...
...
@@ -15,4 +21,14 @@ import com.govmade.modules.system.entity.MenuEntity;
@Mapper
public
interface
MenuDao
extends
BaseMapper
<
MenuEntity
>
{
/**
* 批量删除或删除
*/
void
deleteBatch
(
@Param
(
"ids"
)
Set
<
Long
>
ids
);
/**
* 查询树形数据
*/
List
<
MenuEntity
>
listTree
(
@Param
(
"params"
)
Map
<
String
,
Object
>
params
);
}
src/main/java/com/govmade/modules/system/entity/DictEntity.java
View file @
0fabd1b1
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
;
...
...
@@ -20,12 +23,17 @@ public class DictEntity extends BaseEntity<Long> {
private
String
name
;
// 字典名
private
String
value
;
// 字典值
private
Long
rootId
;
//根Id
private
Integer
type
;
// 类型
private
Integer
weight
;
// 权重
private
String
remark
;
// 备注
@TableField
(
exist
=
false
)
private
List
<
DictEntity
>
children
;
public
Long
getPid
()
{
return
pid
;
...
...
@@ -49,6 +57,14 @@ public class DictEntity extends BaseEntity<Long> {
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
Long
getRootId
()
{
return
rootId
;
}
public
void
setRootId
(
Long
rootId
)
{
this
.
rootId
=
rootId
;
}
public
Integer
getType
()
{
...
...
@@ -74,4 +90,12 @@ public class DictEntity extends BaseEntity<Long> {
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
public
List
<
DictEntity
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
DictEntity
>
children
)
{
this
.
children
=
children
;
}
}
src/main/java/com/govmade/modules/system/entity/MenuEntity.java
View file @
0fabd1b1
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
;
...
...
@@ -32,6 +35,9 @@ public class MenuEntity extends BaseEntity<Long> {
private
Long
moduleId
;
private
Long
weight
;
@TableField
(
exist
=
false
)
private
List
<
MenuEntity
>
children
;
public
Long
getPid
()
{
return
pid
;
...
...
@@ -104,4 +110,13 @@ public class MenuEntity extends BaseEntity<Long> {
public
void
setWeight
(
Long
weight
)
{
this
.
weight
=
weight
;
}
public
List
<
MenuEntity
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
MenuEntity
>
children
)
{
this
.
children
=
children
;
}
}
src/main/java/com/govmade/modules/system/service/AreaService.java
View file @
0fabd1b1
package
com
.
govmade
.
modules
.
system
.
service
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.Page
Tree
Utils
;
import
com.govmade.modules.system.entity.AreaEntity
;
/**
...
...
@@ -24,7 +23,7 @@ public interface AreaService extends IService<AreaEntity>{
/**
* 查看列表
*/
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
Page
Tree
Utils
queryPage
(
Map
<
String
,
Object
>
params
);
/**
* 保存或修改行政区划
...
...
src/main/java/com/govmade/modules/system/service/DepartService.java
View file @
0fabd1b1
...
...
@@ -28,7 +28,7 @@ public interface DepartService extends IService<DepartEntity>{
/**
* 删除部门
*/
void
delete
Batch
(
DepartEntity
depart
);
void
delete
Depart
(
DepartEntity
depart
);
/**
...
...
src/main/java/com/govmade/modules/system/service/DictService.java
View file @
0fabd1b1
...
...
@@ -2,8 +2,10 @@ package com.govmade.modules.system.service;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.govmade.common.utils.PageTreeUtils
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.modules.system.entity.DictEntity
;
import
com.govmade.modules.system.entity.UserEntity
;
...
...
@@ -17,10 +19,29 @@ import com.govmade.modules.system.entity.UserEntity;
*/
public
interface
DictService
extends
IService
<
DictEntity
>
{
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
DictEntity
queryOne
(
Map
<
String
,
Object
>
params
);
List
<
DictEntity
>
queryChilds
(
String
value
);
/**
* 树机构列表
*/
PageTreeUtils
queryPage
(
Map
<
String
,
Object
>
params
);
/**
* 保存或修改字典
*/
void
save
(
DictEntity
dict
);
/**
* 检测是否重名
*/
Integer
checkDict
(
String
name
);
DictEntity
queryById
(
Long
id
);
/**
* 删除字典
*/
void
deleteBatch
(
Set
<
Long
>
ids
);
}
src/main/java/com/govmade/modules/system/service/MenuService.java
View file @
0fabd1b1
...
...
@@ -2,8 +2,10 @@ package com.govmade.modules.system.service;
import
java.util.Map
;
import
java.util.Set
;
import
com.baomidou.mybatisplus.service.IService
;
import
com.govmade.common.utils.PageTreeUtils
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.modules.system.entity.MenuEntity
;
...
...
@@ -17,7 +19,7 @@ import com.govmade.modules.system.entity.MenuEntity;
public
interface
MenuService
extends
IService
<
MenuEntity
>
{
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
Page
Tree
Utils
queryPage
(
Map
<
String
,
Object
>
params
);
/**
* 保存或修改菜单
...
...
@@ -30,4 +32,9 @@ public interface MenuService extends IService<MenuEntity> {
Integer
checkMenu
(
String
name
);
MenuEntity
queryById
(
Long
id
);
/**
* 删除菜单
*/
void
deleteBatch
(
Set
<
Long
>
ids
);
}
src/main/java/com/govmade/modules/system/service/impl/AreaServiceImpl.java
View file @
0fabd1b1
...
...
@@ -7,14 +7,15 @@ import java.util.Set;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.google.common.collect.Lists
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.Page
Tree
Utils
;
import
com.govmade.modules.system.dao.AreaDao
;
import
com.govmade.modules.system.entity.AreaEntity
;
import
com.govmade.modules.system.service.AreaService
;
import
cn.hutool.core.util.StrUtil
;
/**
* 系统管理 - 行政区划设置
*
...
...
@@ -22,49 +23,53 @@ import com.govmade.modules.system.service.AreaService;
* @date 2018年8月9日
*/
@Service
(
"AreaService"
)
public
class
AreaServiceImpl
extends
ServiceImpl
<
AreaDao
,
AreaEntity
>
implements
AreaService
{
public
class
AreaServiceImpl
extends
ServiceImpl
<
AreaDao
,
AreaEntity
>
implements
AreaService
{
@Override
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
public
PageTreeUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
String
name
=
(
String
)
params
.
get
(
"name"
);
List
<
AreaEntity
>
list
=
buildAreaTree
(
this
.
baseMapper
.
listTree
(
name
),
0
);
Page
<
AreaEntity
>
page
=
new
Page
<
AreaEntity
>();
page
.
setRecords
(
list
);
return
new
PageUtils
(
page
);
}
/**
*递归方法
*/
private
List
<
AreaEntity
>
buildAreaTree
(
List
<
AreaEntity
>
list
,
long
id
)
{
List
<
AreaEntity
>
aList
=
Lists
.
newArrayList
();
int
currPage
=
Integer
.
parseInt
((
String
)
params
.
get
(
"currPage"
));
int
pageSize
=
Integer
.
parseInt
((
String
)
params
.
get
(
"pageSize"
));
int
start
=
(
currPage
-
1
)
*
pageSize
;
params
.
put
(
"name2"
,
name
);
params
.
put
(
"pageSize2"
,
pageSize
);
params
.
put
(
"start"
,
start
);
List
<
AreaEntity
>
allList
=
this
.
baseMapper
.
listTree
(
params
);
List
<
AreaEntity
>
list
=
buildAreaTree
(
allList
,
0L
);
int
totalCount
=
super
.
selectCount
(
new
EntityWrapper
<
AreaEntity
>().
like
(
StrUtil
.
isNotBlank
(
name
),
"name"
,
name
)
.
eq
(
"pid"
,
0
).
eq
(
"state"
,
1
));
return
new
PageTreeUtils
(
list
,
totalCount
,
pageSize
,
currPage
);
}
/**
* 递归方法
*/
private
List
<
AreaEntity
>
buildAreaTree
(
List
<
AreaEntity
>
areaList
,
Long
id
)
{
List
<
AreaEntity
>
aList
=
Lists
.
newArrayList
();
for
(
AreaEntity
area
:
areaList
)
{
if
(
id
==
area
.
getPid
())
{
area
.
setChildren
(
buildAreaTree
(
areaList
,
area
.
getId
()));
aList
.
add
(
area
);
}
}
return
aList
;
}
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
(
Set
<
Long
>
ids
)
{
this
.
baseMapper
.
deleteBatch
(
ids
);
}
@Override
public
Integer
checkArea
(
String
name
)
{
return
super
.
selectCount
(
new
EntityWrapper
<
AreaEntity
>().
eq
(
"name"
,
name
));
return
super
.
selectCount
(
new
EntityWrapper
<
AreaEntity
>().
eq
(
"name"
,
name
));
}
}
src/main/java/com/govmade/modules/system/service/impl/DepartServiceImpl.java
View file @
0fabd1b1
...
...
@@ -44,7 +44,7 @@ public class DepartServiceImpl extends ServiceImpl<DepartDao,DepartEntity> imple
}
@Override
public
void
delete
Batch
(
DepartEntity
depart
)
{
public
void
delete
Depart
(
DepartEntity
depart
)
{
depart
.
setState
(
Constant
.
STATE_DELETE
);
super
.
updateById
(
depart
);
}
...
...
src/main/java/com/govmade/modules/system/service/impl/DictServiceImpl.java
View file @
0fabd1b1
...
...
@@ -2,12 +2,15 @@ package com.govmade.modules.system.service.impl;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.service.impl.ServiceImpl
;
import
com.google.common.collect.Lists
;
import
com.govmade.common.utils.PageTreeUtils
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.common.utils.Query
;
import
com.govmade.modules.system.dao.DictDao
;
...
...
@@ -26,12 +29,38 @@ import cn.hutool.core.util.StrUtil;
@Service
(
"DictService"
)
public
class
DictServiceImpl
extends
ServiceImpl
<
DictDao
,
DictEntity
>
implements
DictService
{
@Override
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
Page
<
DictEntity
>
page
=
this
.
selectPage
(
new
Query
<
DictEntity
>(
params
).
getPage
());
return
new
PageUtils
(
page
);
}
@Override
public
PageTreeUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
String
name
=
(
String
)
params
.
get
(
"name"
);
int
currPage
=
Integer
.
parseInt
((
String
)
params
.
get
(
"currPage"
));
int
pageSize
=
Integer
.
parseInt
((
String
)
params
.
get
(
"pageSize"
));
int
start
=
(
currPage
-
1
)*
pageSize
;
params
.
put
(
"name2"
,
name
);
params
.
put
(
"pageSize2"
,
pageSize
);
params
.
put
(
"start"
,
start
);
List
<
DictEntity
>
allList
=
this
.
baseMapper
.
listTree
(
params
);
List
<
DictEntity
>
list
=
buildAreaTree
(
allList
,
0L
);
int
totalCount
=
super
.
selectCount
(
new
EntityWrapper
<
DictEntity
>().
like
(
StrUtil
.
isNotBlank
(
name
),
"name"
,
name
)
.
eq
(
"pid"
,
0
).
eq
(
"state"
,
1
));
return
new
PageTreeUtils
(
list
,
totalCount
,
pageSize
,
currPage
);
}
/**
*递归方法
*/
private
List
<
DictEntity
>
buildAreaTree
(
List
<
DictEntity
>
dictList
,
Long
id
)
{
List
<
DictEntity
>
dList
=
Lists
.
newArrayList
();
for
(
DictEntity
dict
:
dictList
)
{
if
(
id
==
dict
.
getPid
())
{
dict
.
setChildren
(
buildAreaTree
(
dictList
,
dict
.
getId
()));
dList
.
add
(
dict
);
}
}
return
dList
;
}
@Override
public
DictEntity
queryOne
(
Map
<
String
,
Object
>
params
)
{
...
...
@@ -47,4 +76,24 @@ public class DictServiceImpl extends ServiceImpl<DictDao, DictEntity> implements
return
childs
;
}
@Override
public
void
save
(
DictEntity
dict
)
{
super
.
insertOrUpdate
(
dict
);
}
@Override
public
void
deleteBatch
(
Set
<
Long
>
ids
)
{
this
.
baseMapper
.
deleteBatch
(
ids
);
}
@Override
public
Integer
checkDict
(
String
name
)
{
return
super
.
selectCount
(
new
EntityWrapper
<
DictEntity
>().
eq
(
"name"
,
name
));
}
@Override
public
DictEntity
queryById
(
Long
id
)
{
return
super
.
selectById
(
id
);
}
}
src/main/java/com/govmade/modules/system/service/impl/MenuServiceImpl.java
View file @
0fabd1b1
...
...
@@ -2,16 +2,21 @@ package com.govmade.modules.system.service.impl;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
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.common.utils.PageTreeUtils
;
import
com.govmade.common.utils.PageUtils
;
import
com.govmade.modules.system.dao.MenuDao
;
import
com.govmade.modules.system.entity.MenuEntity
;
import
com.govmade.modules.system.service.MenuService
;
import
cn.hutool.core.util.StrUtil
;
/**
* 系统管理 - 菜单设置
*
...
...
@@ -24,11 +29,36 @@ public class MenuServiceImpl extends ServiceImpl<MenuDao, MenuEntity> implements
@Override
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
// TODO Auto-generated method stub
//this.baseMapper.selectPage();
return
null
;
}
public
PageTreeUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
String
name
=
(
String
)
params
.
get
(
"name"
);
int
currPage
=
Integer
.
parseInt
((
String
)
params
.
get
(
"currPage"
));
int
pageSize
=
Integer
.
parseInt
((
String
)
params
.
get
(
"pageSize"
));
int
start
=
(
currPage
-
1
)*
pageSize
;
params
.
put
(
"name2"
,
name
);
params
.
put
(
"pageSize2"
,
pageSize
);
params
.
put
(
"start"
,
start
);
List
<
MenuEntity
>
allList
=
this
.
baseMapper
.
listTree
(
params
);
List
<
MenuEntity
>
list
=
buildAreaTree
(
allList
,
0L
);
int
totalCount
=
super
.
selectCount
(
new
EntityWrapper
<
MenuEntity
>().
like
(
StrUtil
.
isNotBlank
(
name
),
"name"
,
name
)
.
eq
(
"pid"
,
0
).
eq
(
"state"
,
1
));
return
new
PageTreeUtils
(
list
,
totalCount
,
pageSize
,
currPage
);
}
/**
*递归方法
*/
private
List
<
MenuEntity
>
buildAreaTree
(
List
<
MenuEntity
>
menuList
,
Long
id
)
{
List
<
MenuEntity
>
mList
=
Lists
.
newArrayList
();
for
(
MenuEntity
menu
:
menuList
)
{
if
(
id
==
menu
.
getPid
())
{
menu
.
setChildren
(
buildAreaTree
(
menuList
,
menu
.
getId
()));
mList
.
add
(
menu
);
}
}
return
mList
;
}
/**
* 获取所有菜单列表
...
...
@@ -56,5 +86,10 @@ public class MenuServiceImpl extends ServiceImpl<MenuDao, MenuEntity> implements
public
MenuEntity
queryById
(
Long
id
)
{
return
super
.
selectById
(
id
);
}
@Override
public
void
deleteBatch
(
Set
<
Long
>
ids
)
{
this
.
baseMapper
.
deleteBatch
(
ids
);
}
}
src/main/resources/mapper/system/AreaDao.xml
View file @
0fabd1b1
...
...
@@ -19,21 +19,22 @@
SELECT id AS id2 FROM system_areas
WHERE
pid = 0
<if
test=
"name != null and name !=''"
>
AND NAME LIKE CONCAT('%',#{name},'%')
AND state =1
<if
test=
"params.name2 != null and params.name2 !=''"
>
AND NAME LIKE CONCAT('%',#{params.name2},'%')
</if>
LIMIT 10
) AS t2 ON t.root_id = t2.id2
LIMIT #{params.start},#{params.pageSize2}
) AS t2 ON t.root_id = t2.id2 AND t.state=1
UNION ALL(SELECT *, 0 AS id2 FROM system_areas
WHERE
pid = 0
<if
test=
"name != null and name !=''"
>
AND NAME LIKE CONCAT('%',#{name},'%')
AND state =1
<if
test=
"params.name2 != null and params.name2 !=''"
>
AND NAME LIKE CONCAT('%',#{params.name2},'%')
</if>
LIMIT
10
LIMIT
#{params.start},#{params.pageSize2}
)
ORDER BY id
ORDER BY id
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper/system/DictDao.xml
View file @
0fabd1b1
...
...
@@ -7,5 +7,38 @@
select value,name from
system_dicts where pid = (select id from system_dicts where value = #{pValue})
</select>
<!-- 批量删除 -->
<update
id=
"deleteBatch"
>
UPDATE system_dicts SET state =${@com.govmade.common.utils.Constant@STATE_DELETE} WHERE id IN
<foreach
collection=
"ids"
item=
"id"
open=
"("
close=
")"
separator=
","
>
#{id}
</foreach>
</update>
<!-- 查询树形数据-->
<select
id=
"listTree"
resultType=
"DictEntity"
>
SELECT * FROM system_dicts AS t
INNER JOIN (
SELECT id AS id2 FROM system_dicts
WHERE
pid = 0
AND state =1
<if
test=
"params.name2 != null and params.name2 !=''"
>
AND NAME LIKE CONCAT('%',#{params.name2},'%')
</if>
LIMIT #{params.start},#{params.pageSize2}
) AS t2 ON t.root_id = t2.id2 AND t.state=1
UNION ALL(SELECT *, 0 AS id2 FROM system_dicts
WHERE
pid = 0
AND state =1
<if
test=
"params.name2 != null and params.name2 !=''"
>
AND NAME LIKE CONCAT('%',#{params.name2},'%')
</if>
LIMIT #{params.start},#{params.pageSize2}
)
ORDER BY id
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper/system/MenuDao.xml
0 → 100644
View file @
0fabd1b1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.govmade.modules.system.dao.MenuDao"
>
<!-- 批量删除 -->
<update
id=
"deleteBatch"
>
UPDATE system_menus SET state =${@com.govmade.common.utils.Constant@STATE_DELETE} WHERE id IN
<foreach
collection=
"ids"
item=
"id"
open=
"("
close=
")"
separator=
","
>
#{id}
</foreach>
</update>
<!-- 查询树形数据-->
<select
id=
"listTree"
resultType=
"MenuEntity"
>
SELECT * FROM system_menus AS t
INNER JOIN (
SELECT id AS id2 FROM system_menus
WHERE
pid = 0
AND state =1
<if
test=
"params.name2 != null and params.name2 !=''"
>
AND NAME LIKE CONCAT('%',#{params.name2},'%')
</if>
LIMIT #{params.start},#{params.pageSize2}
) AS t2 ON t.root_id = t2.id2 AND t.state=1
UNION ALL(SELECT *, 0 AS id2 FROM system_menus
WHERE
pid = 0
AND state =1
<if
test=
"params.name2 != null and params.name2 !=''"
>
AND NAME LIKE CONCAT('%',#{params.name2},'%')
</if>
LIMIT #{params.start},#{params.pageSize2}
)
ORDER BY id
</select>
</mapper>
\ No newline at end of file
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