Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
njgzx
dataease
Commits
daf441a0
提交
daf441a0
authored
2月 22, 2021
作者:
taojinlong
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'main' of github.com:dataease/dataease into main
上级
a0146d9c
fa6c20da
全部展开
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
209 行增加
和
98 行删除
+209
-98
SysDept.java
backend/src/main/java/io/dataease/base/domain/SysDept.java
+0
-2
SysDeptExample.java
...src/main/java/io/dataease/base/domain/SysDeptExample.java
+0
-60
SysDeptMapper.xml
...d/src/main/java/io/dataease/base/mapper/SysDeptMapper.xml
+8
-23
ExtDeptMapper.java
.../main/java/io/dataease/base/mapper/ext/ExtDeptMapper.java
+25
-0
SysDeptController.java
...in/java/io/dataease/controller/sys/SysDeptController.java
+38
-6
DeptCreateRequest.java
...io/dataease/controller/sys/request/DeptCreateRequest.java
+6
-1
DeptDeleteRequest.java
...io/dataease/controller/sys/request/DeptDeleteRequest.java
+11
-0
DeptStatusRequest.java
...io/dataease/controller/sys/request/DeptStatusRequest.java
+11
-0
DeptNodeResponse.java
...io/dataease/controller/sys/response/DeptNodeResponse.java
+12
-0
DeptService.java
...nd/src/main/java/io/dataease/service/sys/DeptService.java
+81
-6
V8__system.sql
backend/src/main/resources/db/migration/V8__system.sql
+17
-0
dept.vue
frontend/src/business/components/settings/sys/dept.vue
+0
-0
没有找到文件。
backend/src/main/java/io/dataease/base/domain/SysDept.java
浏览文件 @
daf441a0
...
@@ -14,8 +14,6 @@ public class SysDept implements Serializable {
...
@@ -14,8 +14,6 @@ public class SysDept implements Serializable {
private
String
name
;
private
String
name
;
private
Integer
level
;
private
Integer
deptSort
;
private
Integer
deptSort
;
private
Boolean
enabled
;
private
Boolean
enabled
;
...
...
backend/src/main/java/io/dataease/base/domain/SysDeptExample.java
浏览文件 @
daf441a0
...
@@ -355,66 +355,6 @@ public class SysDeptExample {
...
@@ -355,66 +355,6 @@ public class SysDeptExample {
return
(
Criteria
)
this
;
return
(
Criteria
)
this
;
}
}
public
Criteria
andLevelIsNull
()
{
addCriterion
(
"`level` is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andLevelIsNotNull
()
{
addCriterion
(
"`level` is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andLevelEqualTo
(
Integer
value
)
{
addCriterion
(
"`level` ="
,
value
,
"level"
);
return
(
Criteria
)
this
;
}
public
Criteria
andLevelNotEqualTo
(
Integer
value
)
{
addCriterion
(
"`level` <>"
,
value
,
"level"
);
return
(
Criteria
)
this
;
}
public
Criteria
andLevelGreaterThan
(
Integer
value
)
{
addCriterion
(
"`level` >"
,
value
,
"level"
);
return
(
Criteria
)
this
;
}
public
Criteria
andLevelGreaterThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"`level` >="
,
value
,
"level"
);
return
(
Criteria
)
this
;
}
public
Criteria
andLevelLessThan
(
Integer
value
)
{
addCriterion
(
"`level` <"
,
value
,
"level"
);
return
(
Criteria
)
this
;
}
public
Criteria
andLevelLessThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"`level` <="
,
value
,
"level"
);
return
(
Criteria
)
this
;
}
public
Criteria
andLevelIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"`level` in"
,
values
,
"level"
);
return
(
Criteria
)
this
;
}
public
Criteria
andLevelNotIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"`level` not in"
,
values
,
"level"
);
return
(
Criteria
)
this
;
}
public
Criteria
andLevelBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"`level` between"
,
value1
,
value2
,
"level"
);
return
(
Criteria
)
this
;
}
public
Criteria
andLevelNotBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"`level` not between"
,
value1
,
value2
,
"level"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeptSortIsNull
()
{
public
Criteria
andDeptSortIsNull
()
{
addCriterion
(
"dept_sort is null"
);
addCriterion
(
"dept_sort is null"
);
return
(
Criteria
)
this
;
return
(
Criteria
)
this
;
...
...
backend/src/main/java/io/dataease/base/mapper/SysDeptMapper.xml
浏览文件 @
daf441a0
...
@@ -6,7 +6,6 @@
...
@@ -6,7 +6,6 @@
<result
column=
"pid"
jdbcType=
"BIGINT"
property=
"pid"
/>
<result
column=
"pid"
jdbcType=
"BIGINT"
property=
"pid"
/>
<result
column=
"sub_count"
jdbcType=
"INTEGER"
property=
"subCount"
/>
<result
column=
"sub_count"
jdbcType=
"INTEGER"
property=
"subCount"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"level"
jdbcType=
"INTEGER"
property=
"level"
/>
<result
column=
"dept_sort"
jdbcType=
"INTEGER"
property=
"deptSort"
/>
<result
column=
"dept_sort"
jdbcType=
"INTEGER"
property=
"deptSort"
/>
<result
column=
"enabled"
jdbcType=
"BIT"
property=
"enabled"
/>
<result
column=
"enabled"
jdbcType=
"BIT"
property=
"enabled"
/>
<result
column=
"create_by"
jdbcType=
"VARCHAR"
property=
"createBy"
/>
<result
column=
"create_by"
jdbcType=
"VARCHAR"
property=
"createBy"
/>
...
@@ -73,8 +72,8 @@
...
@@ -73,8 +72,8 @@
</where>
</where>
</sql>
</sql>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
dept_id, pid, sub_count, `name`,
`level`, dept_sort, enabled, create_by, update_by
,
dept_id, pid, sub_count, `name`,
dept_sort, enabled, create_by, update_by, create_time
,
create_time,
update_time
update_time
</sql>
</sql>
<select
id=
"selectByExample"
parameterType=
"io.dataease.base.domain.SysDeptExample"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByExample"
parameterType=
"io.dataease.base.domain.SysDeptExample"
resultMap=
"BaseResultMap"
>
select
select
...
@@ -108,13 +107,13 @@
...
@@ -108,13 +107,13 @@
</delete>
</delete>
<insert
id=
"insert"
parameterType=
"io.dataease.base.domain.SysDept"
>
<insert
id=
"insert"
parameterType=
"io.dataease.base.domain.SysDept"
>
insert into sys_dept (dept_id, pid, sub_count,
insert into sys_dept (dept_id, pid, sub_count,
`name`,
`level`, dept_sort
,
`name`,
dept_sort, enabled
,
enabled, create_by, update_by
,
create_by, update_by, create_time
,
create_time,
update_time)
update_time)
values (#{deptId,jdbcType=BIGINT}, #{pid,jdbcType=BIGINT}, #{subCount,jdbcType=INTEGER},
values (#{deptId,jdbcType=BIGINT}, #{pid,jdbcType=BIGINT}, #{subCount,jdbcType=INTEGER},
#{name,jdbcType=VARCHAR}, #{
level,jdbcType=INTEGER}, #{deptSort,jdbcType=INTEGER
},
#{name,jdbcType=VARCHAR}, #{
deptSort,jdbcType=INTEGER}, #{enabled,jdbcType=BIT
},
#{
enabled,jdbcType=BIT}, #{createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR
},
#{
createBy,jdbcType=VARCHAR}, #{updateBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP
},
#{
createTime,jdbcType=TIMESTAMP}, #{
updateTime,jdbcType=TIMESTAMP})
#{updateTime,jdbcType=TIMESTAMP})
</insert>
</insert>
<insert
id=
"insertSelective"
parameterType=
"io.dataease.base.domain.SysDept"
>
<insert
id=
"insertSelective"
parameterType=
"io.dataease.base.domain.SysDept"
>
insert into sys_dept
insert into sys_dept
...
@@ -131,9 +130,6 @@
...
@@ -131,9 +130,6 @@
<if
test=
"name != null"
>
<if
test=
"name != null"
>
`name`,
`name`,
</if>
</if>
<if
test=
"level != null"
>
`level`,
</if>
<if
test=
"deptSort != null"
>
<if
test=
"deptSort != null"
>
dept_sort,
dept_sort,
</if>
</if>
...
@@ -166,9 +162,6 @@
...
@@ -166,9 +162,6 @@
<if
test=
"name != null"
>
<if
test=
"name != null"
>
#{name,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR},
</if>
</if>
<if
test=
"level != null"
>
#{level,jdbcType=INTEGER},
</if>
<if
test=
"deptSort != null"
>
<if
test=
"deptSort != null"
>
#{deptSort,jdbcType=INTEGER},
#{deptSort,jdbcType=INTEGER},
</if>
</if>
...
@@ -210,9 +203,6 @@
...
@@ -210,9 +203,6 @@
<if
test=
"record.name != null"
>
<if
test=
"record.name != null"
>
`name` = #{record.name,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
</if>
</if>
<if
test=
"record.level != null"
>
`level` = #{record.level,jdbcType=INTEGER},
</if>
<if
test=
"record.deptSort != null"
>
<if
test=
"record.deptSort != null"
>
dept_sort = #{record.deptSort,jdbcType=INTEGER},
dept_sort = #{record.deptSort,jdbcType=INTEGER},
</if>
</if>
...
@@ -242,7 +232,6 @@
...
@@ -242,7 +232,6 @@
pid = #{record.pid,jdbcType=BIGINT},
pid = #{record.pid,jdbcType=BIGINT},
sub_count = #{record.subCount,jdbcType=INTEGER},
sub_count = #{record.subCount,jdbcType=INTEGER},
`name` = #{record.name,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
`level` = #{record.level,jdbcType=INTEGER},
dept_sort = #{record.deptSort,jdbcType=INTEGER},
dept_sort = #{record.deptSort,jdbcType=INTEGER},
enabled = #{record.enabled,jdbcType=BIT},
enabled = #{record.enabled,jdbcType=BIT},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
...
@@ -265,9 +254,6 @@
...
@@ -265,9 +254,6 @@
<if
test=
"name != null"
>
<if
test=
"name != null"
>
`name` = #{name,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
</if>
</if>
<if
test=
"level != null"
>
`level` = #{level,jdbcType=INTEGER},
</if>
<if
test=
"deptSort != null"
>
<if
test=
"deptSort != null"
>
dept_sort = #{deptSort,jdbcType=INTEGER},
dept_sort = #{deptSort,jdbcType=INTEGER},
</if>
</if>
...
@@ -294,7 +280,6 @@
...
@@ -294,7 +280,6 @@
set pid = #{pid,jdbcType=BIGINT},
set pid = #{pid,jdbcType=BIGINT},
sub_count = #{subCount,jdbcType=INTEGER},
sub_count = #{subCount,jdbcType=INTEGER},
`name` = #{name,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
`level` = #{level,jdbcType=INTEGER},
dept_sort = #{deptSort,jdbcType=INTEGER},
dept_sort = #{deptSort,jdbcType=INTEGER},
enabled = #{enabled,jdbcType=BIT},
enabled = #{enabled,jdbcType=BIT},
create_by = #{createBy,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
...
...
backend/src/main/java/io/dataease/base/mapper/ext/ExtDeptMapper.java
0 → 100644
浏览文件 @
daf441a0
package
io
.
dataease
.
base
.
mapper
.
ext
;
import
org.apache.ibatis.annotations.Delete
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Update
;
import
java.util.List
;
@Mapper
public
interface
ExtDeptMapper
{
@Update
(
" update sys_dept set sub_count = sub_count+1 where dept_id = #{deptId} "
)
int
incrementalSubcount
(
@Param
(
"deptId"
)
Long
deptId
);
@Update
(
" update sys_dept set sub_count = sub_count-1 where dept_id = #{deptId} and sub_count > 0"
)
int
decreasingSubcount
(
@Param
(
"deptId"
)
Long
deptId
);
@Delete
(
"<script> "
+
" delete from sys_dept where dept_id in "
+
" <foreach collection='ids' item='id' open='(' separator=',' close=')'>#{id}</foreach> "
+
"</script>"
)
int
batchDelete
(
@Param
(
"ids"
)
List
<
Long
>
ids
);
}
backend/src/main/java/io/dataease/controller/sys/SysDeptController.java
浏览文件 @
daf441a0
package
io
.
dataease
.
controller
.
sys
;
package
io
.
dataease
.
controller
.
sys
;
import
io.dataease.base.domain.SysDept
;
import
io.dataease.base.domain.SysDept
;
import
io.dataease.commons.utils.BeanUtils
;
import
io.dataease.controller.ResultHolder
;
import
io.dataease.controller.ResultHolder
;
import
io.dataease.controller.sys.request.DeptCreateRequest
;
import
io.dataease.controller.sys.request.DeptDeleteRequest
;
import
io.dataease.controller.sys.request.DeptStatusRequest
;
import
io.dataease.controller.sys.response.DeptNodeResponse
;
import
io.dataease.service.sys.DeptService
;
import
io.dataease.service.sys.DeptService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@RestController
@RestController
@RequiredArgsConstructor
@RequiredArgsConstructor
...
@@ -23,17 +27,45 @@ public class SysDeptController extends ResultHolder {
...
@@ -23,17 +27,45 @@ public class SysDeptController extends ResultHolder {
@Resource
@Resource
private
DeptService
deptService
;
private
DeptService
deptService
;
@PostMapping
(
"/childNodes/{pid}"
)
public
List
<
DeptNodeResponse
>
childNodes
(
@PathVariable
(
"pid"
)
Long
pid
){
List
<
SysDept
>
nodes
=
deptService
.
nodesByPid
(
pid
);
List
<
DeptNodeResponse
>
nodeResponses
=
nodes
.
stream
().
map
(
node
->
{
DeptNodeResponse
deptNodeResponse
=
BeanUtils
.
copyBean
(
new
DeptNodeResponse
(),
node
);
deptNodeResponse
.
setHasChildren
(
node
.
getSubCount
()
>
0
);
deptNodeResponse
.
setTop
(
node
.
getPid
()
==
deptService
.
DEPT_ROOT_PID
);
return
deptNodeResponse
;
}).
collect
(
Collectors
.
toList
());
return
nodeResponses
;
}
@ApiOperation
(
"查询部门"
)
@ApiOperation
(
"查询部门"
)
@PostMapping
(
"/root"
)
@PostMapping
(
"/root"
)
public
ResultHolder
rootData
(){
public
ResultHolder
rootData
(){
List
<
SysDept
>
root
=
deptService
.
root
(
);
List
<
SysDept
>
root
=
deptService
.
nodesByPid
(
null
);
return
success
(
root
);
return
success
(
root
);
}
}
@ApiOperation
(
"新增部门"
)
@ApiOperation
(
"新增部门"
)
@PostMapping
(
"/create"
)
@PostMapping
(
"/create"
)
public
void
create
(
@RequestBody
SysDep
t
dept
){
public
void
create
(
@RequestBody
DeptCreateReques
t
dept
){
deptService
.
add
(
dept
);
deptService
.
add
(
dept
);
}
}
@ApiOperation
(
"删除部门"
)
@PostMapping
(
"/delete"
)
public
void
delete
(
@RequestBody
List
<
DeptDeleteRequest
>
requests
){
deptService
.
batchDelete
(
requests
);
}
@ApiOperation
(
"更新部门"
)
@PostMapping
(
"/update"
)
public
void
update
(
@RequestBody
DeptCreateRequest
dept
){
deptService
.
update
(
dept
);
}
@ApiOperation
(
"更新状态"
)
@PostMapping
(
"/updateStatus"
)
public
void
updateStatus
(
@RequestBody
DeptStatusRequest
request
){
deptService
.
updateStatus
(
request
);
}
}
}
backend/src/main/java/io/dataease/controller/sys/request/DeptCreateRequest.java
浏览文件 @
daf441a0
package
io
.
dataease
.
controller
.
sys
.
request
;
package
io
.
dataease
.
controller
.
sys
.
request
;
public
class
DeptCreateRequest
{
import
io.dataease.base.domain.SysDept
;
import
lombok.Data
;
@Data
public
class
DeptCreateRequest
extends
SysDept
{
private
boolean
top
;
}
}
backend/src/main/java/io/dataease/controller/sys/request/DeptDeleteRequest.java
0 → 100644
浏览文件 @
daf441a0
package
io
.
dataease
.
controller
.
sys
.
request
;
import
lombok.Data
;
@Data
public
class
DeptDeleteRequest
{
private
Long
deptId
;
private
Long
pid
;
}
backend/src/main/java/io/dataease/controller/sys/request/DeptStatusRequest.java
0 → 100644
浏览文件 @
daf441a0
package
io
.
dataease
.
controller
.
sys
.
request
;
import
lombok.Data
;
@Data
public
class
DeptStatusRequest
{
private
Long
deptId
;
private
boolean
status
;
}
backend/src/main/java/io/dataease/controller/sys/response/DeptNodeResponse.java
0 → 100644
浏览文件 @
daf441a0
package
io
.
dataease
.
controller
.
sys
.
response
;
import
io.dataease.base.domain.SysDept
;
import
lombok.Data
;
@Data
public
class
DeptNodeResponse
extends
SysDept
{
private
boolean
hasChildren
;
private
boolean
top
;
}
backend/src/main/java/io/dataease/service/sys/DeptService.java
浏览文件 @
daf441a0
...
@@ -3,46 +3,121 @@ package io.dataease.service.sys;
...
@@ -3,46 +3,121 @@ package io.dataease.service.sys;
import
io.dataease.base.domain.SysDept
;
import
io.dataease.base.domain.SysDept
;
import
io.dataease.base.domain.SysDeptExample
;
import
io.dataease.base.domain.SysDeptExample
;
import
io.dataease.base.mapper.SysDeptMapper
;
import
io.dataease.base.mapper.SysDeptMapper
;
import
io.dataease.base.mapper.ext.ExtDeptMapper
;
import
io.dataease.commons.utils.BeanUtils
;
import
io.dataease.controller.sys.request.DeptCreateRequest
;
import
io.dataease.controller.sys.request.DeptDeleteRequest
;
import
io.dataease.controller.sys.request.DeptStatusRequest
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
@Service
public
class
DeptService
{
public
class
DeptService
{
private
final
static
Integer
DEPT_ROOT_LEVEL
=
0
;
private
final
static
Integer
DEPT_ROOT_LEVEL
=
0
;
private
final
static
Integer
DEFAULT_SUBCOUNT
=
0
;
public
final
static
Long
DEPT_ROOT_PID
=
0L
;
@Resource
@Resource
private
SysDeptMapper
sysDeptMapper
;
private
SysDeptMapper
sysDeptMapper
;
public
List
<
SysDept
>
root
(){
@Resource
private
ExtDeptMapper
extDeptMapper
;
public
List
<
SysDept
>
nodesByPid
(
Long
pid
){
SysDeptExample
example
=
new
SysDeptExample
();
SysDeptExample
example
=
new
SysDeptExample
();
example
.
createCriteria
().
andLevelEqualTo
(
DEPT_ROOT_LEVEL
);
SysDeptExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(
ObjectUtils
.
isEmpty
(
pid
)){
criteria
.
andPidEqualTo
(
0L
);
}
else
{
criteria
.
andPidEqualTo
(
pid
);
}
example
.
setOrderByClause
(
"dept_sort"
);
example
.
setOrderByClause
(
"dept_sort"
);
List
<
SysDept
>
sysDepts
=
sysDeptMapper
.
selectByExample
(
example
);
List
<
SysDept
>
sysDepts
=
sysDeptMapper
.
selectByExample
(
example
);
return
sysDepts
;
return
sysDepts
;
}
}
public
boolean
add
(
SysDept
sysDept
){
@Transactional
if
(
ObjectUtils
.
isEmpty
(
sysDept
.
getLevel
())){
public
boolean
add
(
DeptCreateRequest
deptCreateRequest
){
sysDept
.
setLevel
(
DEPT_ROOT_LEVEL
);
SysDept
sysDept
=
BeanUtils
.
copyBean
(
new
SysDept
(),
deptCreateRequest
);
if
(
deptCreateRequest
.
isTop
()){
sysDept
.
setPid
(
DEPT_ROOT_PID
);
}
}
Date
now
=
new
Date
();
Date
now
=
new
Date
();
sysDept
.
setCreateTime
(
now
);
sysDept
.
setCreateTime
(
now
);
sysDept
.
setUpdateTime
(
now
);
sysDept
.
setUpdateTime
(
now
);
sysDept
.
setCreateBy
(
null
);
sysDept
.
setCreateBy
(
null
);
sysDept
.
setUpdateBy
(
null
);
sysDept
.
setUpdateBy
(
null
);
sysDept
.
setSubCount
(
DEFAULT_SUBCOUNT
);
try
{
try
{
int
insert
=
sysDeptMapper
.
insert
(
sysDept
);
int
insert
=
sysDeptMapper
.
insert
(
sysDept
);
Long
pid
=
null
;
if
((
pid
=
sysDept
.
getPid
())
!=
DEPT_ROOT_PID
){
//这里需要更新上级节点SubCount
extDeptMapper
.
incrementalSubcount
(
pid
);
}
if
(
insert
==
1
){
if
(
insert
==
1
){
return
true
;
return
true
;
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
return
false
;
e
.
printStackTrace
()
;
}
}
return
false
;
return
false
;
}
}
@Transactional
public
int
batchDelete
(
List
<
DeptDeleteRequest
>
requests
){
/* Integer index = ids.stream().map(sysDeptMapper::deleteByPrimaryKey).reduce(Integer::sum).orElse(-1);
return index;*/
List
<
Long
>
ids
=
requests
.
stream
().
map
(
request
->
{
Long
pid
=
request
.
getPid
();
if
(
pid
!=
DEPT_ROOT_PID
){
extDeptMapper
.
decreasingSubcount
(
pid
);
}
return
request
.
getDeptId
();
}).
collect
(
Collectors
.
toList
());
return
extDeptMapper
.
batchDelete
(
ids
);
}
@Transactional
public
int
update
(
DeptCreateRequest
deptCreateRequest
){
SysDept
sysDept
=
BeanUtils
.
copyBean
(
new
SysDept
(),
deptCreateRequest
);
if
(
deptCreateRequest
.
isTop
()){
sysDept
.
setPid
(
DEPT_ROOT_PID
);
}
sysDept
.
setUpdateTime
(
new
Date
());
sysDept
.
setUpdateBy
(
null
);
Long
deptId
=
sysDept
.
getDeptId
();
SysDept
dept_old
=
sysDeptMapper
.
selectByPrimaryKey
(
deptId
);
//如果PID发生了改变
//判断oldPid是否是跟节点PID ? nothing : parent.subcount-1
//判断newPid是否是跟节点PID ? nothing : parent.subcount+1
if
(
sysDept
.
getPid
()
!=
dept_old
.
getPid
()){
Long
oldPid
=
dept_old
.
getPid
();
if
(
oldPid
!=
DEPT_ROOT_PID
){
extDeptMapper
.
decreasingSubcount
(
oldPid
);
}
if
(
sysDept
.
getPid
()
!=
DEPT_ROOT_PID
){
extDeptMapper
.
incrementalSubcount
(
sysDept
.
getPid
());
}
}
return
sysDeptMapper
.
updateByPrimaryKeySelective
(
sysDept
);
}
public
int
updateStatus
(
DeptStatusRequest
request
){
Long
deptId
=
request
.
getDeptId
();
boolean
status
=
request
.
isStatus
();
SysDept
sysDept
=
new
SysDept
();
sysDept
.
setDeptId
(
deptId
);
sysDept
.
setEnabled
(
status
);
return
sysDeptMapper
.
updateByPrimaryKeySelective
(
sysDept
);
}
}
}
backend/src/main/resources/db/migration/V8__system.sql
0 → 100644
浏览文件 @
daf441a0
CREATE
TABLE
IF
NOT
EXISTS
`sys_dept`
(
`dept_id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'ID'
,
`pid`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'上级部门'
,
`sub_count`
int
(
5
)
DEFAULT
0
COMMENT
'子部门数目'
,
`name`
varchar
(
255
)
NOT
NULL
COMMENT
'名称'
,
`dept_sort`
int
(
5
)
DEFAULT
999
COMMENT
'排序'
,
`enabled`
bit
(
1
)
NOT
NULL
COMMENT
'状态'
,
`create_by`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'创建者'
,
`update_by`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'更新者'
,
`create_time`
datetime
DEFAULT
NULL
COMMENT
'创建日期'
,
`update_time`
datetime
DEFAULT
NULL
COMMENT
'更新时间'
,
PRIMARY
KEY
(
`dept_id`
)
USING
BTREE
,
KEY
`inx_pid`
(
`pid`
),
KEY
`inx_enabled`
(
`enabled`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
18
DEFAULT
CHARSET
=
utf8
ROW_FORMAT
=
COMPACT
COMMENT
=
'部门'
;
\ No newline at end of file
frontend/src/business/components/settings/sys/dept.vue
浏览文件 @
daf441a0
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论