upd: 编码规范

This commit is contained in:
2025-03-25 19:27:14 +08:00
parent 1c6ee31486
commit 005fd0cae2
3 changed files with 49 additions and 25 deletions
@@ -15,11 +15,11 @@ public interface DeptMapper extends BaseMapper<Dept> {
List<Dept> findAll(@Param("criteria") DeptQueryCriteria criteria); List<Dept> findAll(@Param("criteria") DeptQueryCriteria criteria);
List<Dept> findByPid(@Param("pid") Long pid); List<Dept> selectByPid(@Param("pid") Long pid);
List<Dept> findByPidIsNull(); List<Dept> selectByPidIsNull();
Set<Dept> findByRoleId(@Param("roleId") Long roleId); Set<Dept> selectByRoleId(@Param("roleId") Long roleId);
@Select("select count(*) from sys_dept where pid = #{pid}") @Select("select count(*) from sys_dept where pid = #{pid}")
int countByPid(@Param("pid") Long pid); int countByPid(@Param("pid") Long pid);
@@ -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.findByPid(pid); return deptMapper.selectByPid(pid);
} }
@Override @Override
public Set<Dept> findByRoleId(Long id) { public Set<Dept> findByRoleId(Long id) {
return deptMapper.findByRoleId(id); return deptMapper.selectByRoleId(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.findByPid(dept.getId()); List<Dept> depts = deptMapper.selectByPid(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.findByPid(dept.getId()); List<Dept> depts = deptMapper.selectByPid(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.findByPidIsNull()); depts.addAll(deptMapper.selectByPidIsNull());
return depts; return depts;
} }
depts.addAll(deptMapper.findByPid(dept.getPid())); depts.addAll(deptMapper.selectByPid(dept.getPid()));
return getSuperior(findById(dept.getPid()), depts); return getSuperior(findById(dept.getPid()), depts);
} }
@@ -15,52 +15,76 @@
</resultMap> </resultMap>
<select id="findAll" resultMap="BaseResultMap"> <select id="findAll" resultMap="BaseResultMap">
select SELECT
dept_id, name, pid, sub_count, create_time, update_time, create_by, update_by, enabled, dept_sort dept_id,
from sys_dept `name`,
pid,
sub_count,
create_time,
update_time,
create_by,
update_by,
enabled,
dept_sort
FROM
sys_dept
<where> <where>
<if test="criteria.ids != null and criteria.ids.size() > 0"> <if test="criteria.ids != null and criteria.ids.size() > 0">
and dept_id in AND dept_id in
<foreach collection="criteria.ids" item="id" open="(" separator="," close=")"> <foreach collection="criteria.ids" item="id" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</if> </if>
<if test="criteria.name != null and criteria.name != ''"> <if test="criteria.name != null and criteria.name != ''">
and name like concat('%', #{criteria.name}, '%') AND `name` LIKE concat('%', #{criteria.name}, '%')
</if> </if>
<if test="criteria.enabled != null"> <if test="criteria.enabled != null">
and enabled = #{criteria.enabled} AND enabled = #{criteria.enabled}
</if> </if>
<if test="criteria.pid != null"> <if test="criteria.pid != null">
and pid = #{criteria.pid} AND pid = #{criteria.pid}
</if> </if>
<if test="criteria.pidIsNull != null"> <if test="criteria.pidIsNull != null">
and pid is null AND pid IS NULL
</if> </if>
<if test="criteria.createTime != null and criteria.createTime.size() != 0"> <if test="criteria.createTime != null and criteria.createTime.size() != 0">
and create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]} AND create_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]}
</if> </if>
</where> </where>
order by dept_sort ORDER BY dept_sort
</select> </select>
<select id="findByPid" resultMap="BaseResultMap"> <select id="selectByPid" 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="findByPidIsNull" resultMap="BaseResultMap"> <select id="selectByPidIsNull" 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="findByRoleId" resultType="cn.odboy.model.system.domain.Dept"> <select id="selectByRoleId" resultType="cn.odboy.model.system.domain.Dept">
select d.dept_id as id, d.name, d.pid, d.sub_count, d.create_time, d.update_time, d.create_by, d.update_by, d.enabled, d.dept_sort SELECT
from sys_dept d, sys_roles_depts r d.dept_id AS id,
where d.dept_id = r.dept_id and r.role_id = #{roleId} d.NAME,
d.pid,
d.sub_count,
d.create_time,
d.update_time,
d.create_by,
d.update_by,
d.enabled,
d.dept_sort
FROM
sys_dept d,
sys_roles_depts rd
WHERE
d.dept_id = rd.dept_id
AND rd.role_id = #{roleId}
</select> </select>
</mapper> </mapper>