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