upd: 编码规范
This commit is contained in:
+6
-13
@@ -12,17 +12,10 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface DeptMapper extends BaseMapper<Dept> {
|
public interface DeptMapper extends BaseMapper<Dept> {
|
||||||
|
List<Dept> findDeptListByPage(@Param("criteria") DeptQueryCriteria criteria);
|
||||||
List<Dept> selectByPage(@Param("criteria") DeptQueryCriteria criteria);
|
List<Dept> findDeptListByPid(@Param("pid") Long pid);
|
||||||
|
int countDeptByPid(@Param("pid") Long pid);
|
||||||
List<Dept> selectByPid(@Param("pid") Long pid);
|
List<Dept> findDeptListByPidIsNull();
|
||||||
@Select("select count(*) from sys_dept where pid = #{pid}")
|
Set<Dept> findDeptSetByRoleId(@Param("roleId") Long roleId);
|
||||||
int countByPid(@Param("pid") Long pid);
|
void updateDeptSubCountById(@Param("count") Integer count, @Param("id") Long id);
|
||||||
|
|
||||||
List<Dept> selectByPidIsNull();
|
|
||||||
|
|
||||||
Set<Dept> selectByRoleId(@Param("roleId") Long roleId);
|
|
||||||
|
|
||||||
@Select("update sys_dept set sub_count = #{count} where dept_id = #{id}")
|
|
||||||
void updateSubCntById(@Param("count") Integer count, @Param("id") Long id);
|
|
||||||
}
|
}
|
||||||
+9
-9
@@ -64,7 +64,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
|||||||
}
|
}
|
||||||
// 数据权限
|
// 数据权限
|
||||||
criteria.setIds(SecurityUtil.getCurrentUserDataScope());
|
criteria.setIds(SecurityUtil.getCurrentUserDataScope());
|
||||||
List<Dept> list = deptMapper.selectByPage(criteria);
|
List<Dept> list = deptMapper.findDeptListByPage(criteria);
|
||||||
// 如果为空,就代表为自定义权限或者本级权限,就需要去重,不理解可以注释掉,看查询结果
|
// 如果为空,就代表为自定义权限或者本级权限,就需要去重,不理解可以注释掉,看查询结果
|
||||||
if (StringUtil.isBlank(dataScopeType)) {
|
if (StringUtil.isBlank(dataScopeType)) {
|
||||||
return deduplication(list);
|
return deduplication(list);
|
||||||
@@ -85,12 +85,12 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Dept> findByPid(long pid) {
|
public List<Dept> findByPid(long pid) {
|
||||||
return deptMapper.selectByPid(pid);
|
return deptMapper.findDeptListByPid(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Dept> findByRoleId(Long id) {
|
public Set<Dept> findByRoleId(Long id) {
|
||||||
return deptMapper.selectByRoleId(id);
|
return deptMapper.findDeptSetByRoleId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -150,7 +150,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
|||||||
public Set<Dept> getDeleteDepts(List<Dept> menuList, Set<Dept> deptSet) {
|
public Set<Dept> getDeleteDepts(List<Dept> menuList, Set<Dept> deptSet) {
|
||||||
for (Dept dept : menuList) {
|
for (Dept dept : menuList) {
|
||||||
deptSet.add(dept);
|
deptSet.add(dept);
|
||||||
List<Dept> depts = deptMapper.selectByPid(dept.getId());
|
List<Dept> depts = deptMapper.findDeptListByPid(dept.getId());
|
||||||
if (CollUtil.isNotEmpty(depts)) {
|
if (CollUtil.isNotEmpty(depts)) {
|
||||||
getDeleteDepts(depts, deptSet);
|
getDeleteDepts(depts, deptSet);
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
|||||||
List<Long> list = new ArrayList<>();
|
List<Long> list = new ArrayList<>();
|
||||||
deptList.forEach(dept -> {
|
deptList.forEach(dept -> {
|
||||||
if (dept != null && dept.getEnabled()) {
|
if (dept != null && dept.getEnabled()) {
|
||||||
List<Dept> depts = deptMapper.selectByPid(dept.getId());
|
List<Dept> depts = deptMapper.findDeptListByPid(dept.getId());
|
||||||
if (CollUtil.isNotEmpty(depts)) {
|
if (CollUtil.isNotEmpty(depts)) {
|
||||||
list.addAll(getDeptChildren(depts));
|
list.addAll(getDeptChildren(depts));
|
||||||
}
|
}
|
||||||
@@ -177,10 +177,10 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
|||||||
@Override
|
@Override
|
||||||
public List<Dept> getSuperior(Dept dept, List<Dept> depts) {
|
public List<Dept> getSuperior(Dept dept, List<Dept> depts) {
|
||||||
if (dept.getPid() == null) {
|
if (dept.getPid() == null) {
|
||||||
depts.addAll(deptMapper.selectByPidIsNull());
|
depts.addAll(deptMapper.findDeptListByPidIsNull());
|
||||||
return depts;
|
return depts;
|
||||||
}
|
}
|
||||||
depts.addAll(deptMapper.selectByPid(dept.getPid()));
|
depts.addAll(deptMapper.findDeptListByPid(dept.getPid()));
|
||||||
return getSuperior(findById(dept.getPid()), depts);
|
return getSuperior(findById(dept.getPid()), depts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,8 +233,8 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
|||||||
|
|
||||||
private void updateSubCnt(Long deptId) {
|
private void updateSubCnt(Long deptId) {
|
||||||
if (deptId != null) {
|
if (deptId != null) {
|
||||||
int count = deptMapper.countByPid(deptId);
|
int count = deptMapper.countDeptByPid(deptId);
|
||||||
deptMapper.updateSubCntById(count, deptId);
|
deptMapper.updateDeptSubCountById(count, deptId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,11 @@
|
|||||||
<result column="create_time" property="createTime"/>
|
<result column="create_time" property="createTime"/>
|
||||||
<result column="update_time" property="updateTime"/>
|
<result column="update_time" property="updateTime"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<update id="updateDeptSubCountById">
|
||||||
|
update sys_dept set sub_count = #{count} where dept_id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
<select id="selectByPage" resultMap="BaseResultMap">
|
<select id="findDeptListByPage" resultMap="BaseResultMap">
|
||||||
SELECT
|
SELECT
|
||||||
dept_id,
|
dept_id,
|
||||||
`name`,
|
`name`,
|
||||||
@@ -54,21 +57,21 @@
|
|||||||
ORDER BY dept_sort
|
ORDER BY dept_sort
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectByPid" resultMap="BaseResultMap">
|
<select id="findDeptListByPid" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
dept_id, name, pid, sub_count, create_time, update_time, create_by, update_by, enabled, dept_sort
|
dept_id, name, pid, sub_count, create_time, update_time, create_by, update_by, enabled, dept_sort
|
||||||
from sys_dept
|
from sys_dept
|
||||||
where pid = #{pid}
|
where pid = #{pid}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectByPidIsNull" resultMap="BaseResultMap">
|
<select id="findDeptListByPidIsNull" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
dept_id, name, pid, sub_count, create_time, update_time, create_by, update_by, enabled, dept_sort
|
dept_id, name, pid, sub_count, create_time, update_time, create_by, update_by, enabled, dept_sort
|
||||||
from sys_dept
|
from sys_dept
|
||||||
where pid is null
|
where pid is null
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectByRoleId" resultType="cn.odboy.model.system.domain.Dept">
|
<select id="findDeptSetByRoleId" resultType="cn.odboy.model.system.domain.Dept">
|
||||||
SELECT
|
SELECT
|
||||||
d.dept_id AS id,
|
d.dept_id AS id,
|
||||||
d.NAME,
|
d.NAME,
|
||||||
@@ -87,4 +90,7 @@
|
|||||||
d.dept_id = rd.dept_id
|
d.dept_id = rd.dept_id
|
||||||
AND rd.role_id = #{roleId}
|
AND rd.role_id = #{roleId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="countDeptByPid" resultType="java.lang.Integer">
|
||||||
|
select count(*) from sys_dept where pid = #{pid}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user