upd: 编码规范
This commit is contained in:
+4
-6
@@ -5,17 +5,15 @@ import cn.odboy.model.system.dto.DeptQueryCriteria;
|
|||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
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> findDept(@Param("criteria") DeptQueryCriteria criteria);
|
||||||
List<Dept> findDeptListByPid(@Param("pid") Long pid);
|
List<Dept> findDeptByPid(@Param("pid") Long pid);
|
||||||
int countDeptByPid(@Param("pid") Long pid);
|
int countDeptByPid(@Param("pid") Long pid);
|
||||||
List<Dept> findDeptListByPidIsNull();
|
List<Dept> findDeptByPidIsNull();
|
||||||
Set<Dept> findDeptSetByRoleId(@Param("roleId") Long roleId);
|
Set<Dept> findDeptByRoleId(@Param("roleId") Long roleId);
|
||||||
void updateDeptSubCountById(@Param("count") Integer count, @Param("id") Long id);
|
void updateDeptSubCountById(@Param("count") Integer count, @Param("id") Long id);
|
||||||
}
|
}
|
||||||
+7
-7
@@ -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.findDeptListByPage(criteria);
|
List<Dept> list = deptMapper.findDept(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.findDeptListByPid(pid);
|
return deptMapper.findDeptByPid(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Dept> findByRoleId(Long id) {
|
public Set<Dept> findByRoleId(Long id) {
|
||||||
return deptMapper.findDeptSetByRoleId(id);
|
return deptMapper.findDeptByRoleId(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.findDeptListByPid(dept.getId());
|
List<Dept> depts = deptMapper.findDeptByPid(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.findDeptListByPid(dept.getId());
|
List<Dept> depts = deptMapper.findDeptByPid(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.findDeptListByPidIsNull());
|
depts.addAll(deptMapper.findDeptByPidIsNull());
|
||||||
return depts;
|
return depts;
|
||||||
}
|
}
|
||||||
depts.addAll(deptMapper.findDeptListByPid(dept.getPid()));
|
depts.addAll(deptMapper.findDeptByPid(dept.getPid()));
|
||||||
return getSuperior(findById(dept.getPid()), depts);
|
return getSuperior(findById(dept.getPid()), depts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
update sys_dept set sub_count = #{count} where dept_id = #{id}
|
update sys_dept set sub_count = #{count} where dept_id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="findDeptListByPage" resultMap="BaseResultMap">
|
<select id="findDept" resultMap="BaseResultMap">
|
||||||
SELECT
|
SELECT
|
||||||
dept_id,
|
dept_id,
|
||||||
`name`,
|
`name`,
|
||||||
@@ -57,21 +57,21 @@
|
|||||||
ORDER BY dept_sort
|
ORDER BY dept_sort
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findDeptListByPid" resultMap="BaseResultMap">
|
<select id="findDeptByPid" 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="findDeptListByPidIsNull" resultMap="BaseResultMap">
|
<select id="findDeptByPidIsNull" 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="findDeptSetByRoleId" resultType="cn.odboy.model.system.domain.Dept">
|
<select id="findDeptByRoleId" resultType="cn.odboy.model.system.domain.Dept">
|
||||||
SELECT
|
SELECT
|
||||||
d.dept_id AS id,
|
d.dept_id AS id,
|
||||||
d.NAME,
|
d.NAME,
|
||||||
|
|||||||
Reference in New Issue
Block a user