upd: 编码规范

This commit is contained in:
2025-04-09 20:06:14 +08:00
parent f3719b3f1c
commit 1414e17444
7 changed files with 43 additions and 43 deletions
@@ -37,7 +37,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
// 获取用户的权限
List<RoleCodeModel> authorities = roleService.buildPermissions(user);
// 初始化JwtUserDto
userJwtModel = new UserJwtModel(user, dataService.selectDeptIdByUserIdWithDeptId(user), authorities);
userJwtModel = new UserJwtModel(user, dataService.describeDeptIdListByUserIdWithDeptId(user), authorities);
// 添加缓存数据
userCacheService.cacheUserJwtModelByUserName(username, userJwtModel);
}
@@ -38,14 +38,14 @@ public class DeptController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('dept:list')")
public void exportDept(HttpServletResponse response, QueryDeptRequest criteria) throws Exception {
deptService.downloadExcel(deptService.selectDeptByCriteria(criteria, false), response);
deptService.downloadDeptExcel(deptService.describeDeptList(criteria, false), response);
}
@ApiOperation("查询部门")
@GetMapping
@PreAuthorize("@el.check('user:list','dept:list')")
public ResponseEntity<PageResult<Dept>> queryDept(QueryDeptRequest criteria) throws Exception {
List<Dept> depts = deptService.selectDeptByCriteria(criteria, true);
List<Dept> depts = deptService.describeDeptList(criteria, true);
return new ResponseEntity<>(PageUtil.toPage(depts), HttpStatus.OK);
}
@@ -55,8 +55,8 @@ public class DeptController {
public ResponseEntity<Object> getDeptSuperior(@RequestBody List<Long> ids, @RequestParam(defaultValue = "false") Boolean exclude) {
Set<Dept> deptSet = new LinkedHashSet<>();
for (Long id : ids) {
Dept dept = deptService.getDeptById(id);
List<Dept> depts = deptService.selectSuperiorDeptByPid(dept, new ArrayList<>());
Dept dept = deptService.describeDeptById(id);
List<Dept> depts = deptService.describeSuperiorDeptListByPid(dept, new ArrayList<>());
if (exclude) {
for (Dept data : depts) {
if (data.getId().equals(dept.getPid())) {
@@ -68,7 +68,7 @@ public class DeptController {
}
deptSet.addAll(depts);
}
return new ResponseEntity<>(deptService.buildTree(new ArrayList<>(deptSet)), HttpStatus.OK);
return new ResponseEntity<>(deptService.buildDeptTree(new ArrayList<>(deptSet)), HttpStatus.OK);
}
@ApiOperation("新增部门")
@@ -83,7 +83,7 @@ public class DeptController {
@PostMapping(value = "/updateDept")
@PreAuthorize("@el.check('dept:edit')")
public ResponseEntity<Object> updateDept(@Validated(Dept.Update.class) @RequestBody Dept resources) {
deptService.updateDept(resources);
deptService.modifyDept(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@@ -75,12 +75,12 @@ public class UserController {
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
criteria.getDeptIds().add(criteria.getDeptId());
// 先查找是否存在子节点
List<Dept> data = deptService.selectDeptByPid(criteria.getDeptId());
List<Dept> data = deptService.describeDeptListByPid(criteria.getDeptId());
// 然后把子节点的ID都加入到集合中
criteria.getDeptIds().addAll(deptService.selectChildDeptIdByDeptIds(data));
criteria.getDeptIds().addAll(deptService.describeChildDeptIdListByDeptIds(data));
}
// 数据权限
List<Long> dataScopes = dataService.selectDeptIdByUserIdWithDeptId(userService.getUserByUsername(SecurityHelper.getCurrentUsername()));
List<Long> dataScopes = dataService.describeDeptIdListByUserIdWithDeptId(userService.getUserByUsername(SecurityHelper.getCurrentUsername()));
// criteria.getDeptIds() 不为空并且数据权限不为空则取交集
if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
// 取交集
@@ -15,5 +15,5 @@ public interface DataService {
* @param user /
* @return /
*/
List<Long> selectDeptIdByUserIdWithDeptId(User user);
List<Long> describeDeptIdListByUserIdWithDeptId(User user);
}
@@ -20,7 +20,7 @@ public interface DeptService extends IService<Dept> {
* @return /
* @throws Exception /
*/
List<Dept> selectDeptByCriteria(QueryDeptRequest criteria, Boolean isQuery) throws Exception;
List<Dept> describeDeptList(QueryDeptRequest criteria, Boolean isQuery) throws Exception;
/**
* 根据ID查询
@@ -28,7 +28,7 @@ public interface DeptService extends IService<Dept> {
* @param id /
* @return /
*/
Dept getDeptById(Long id);
Dept describeDeptById(Long id);
/**
* 创建
@@ -42,7 +42,7 @@ public interface DeptService extends IService<Dept> {
*
* @param resources /
*/
void updateDept(Dept resources);
void modifyDept(Dept resources);
/**
* 删除
@@ -57,7 +57,7 @@ public interface DeptService extends IService<Dept> {
* @param pid /
* @return /
*/
List<Dept> selectDeptByPid(long pid);
List<Dept> describeDeptListByPid(long pid);
/**
* 根据角色ID查询
@@ -65,7 +65,7 @@ public interface DeptService extends IService<Dept> {
* @param id /
* @return /
*/
Set<Dept> selectDeptByRoleId(Long id);
Set<Dept> describeDeptByRoleId(Long id);
/**
* 导出数据
@@ -74,7 +74,7 @@ public interface DeptService extends IService<Dept> {
* @param response /
* @throws IOException /
*/
void downloadExcel(List<Dept> depts, HttpServletResponse response) throws IOException;
void downloadDeptExcel(List<Dept> depts, HttpServletResponse response) throws IOException;
/**
* 获取部门下所有关联的部门
@@ -83,7 +83,7 @@ public interface DeptService extends IService<Dept> {
* @param depts /
* @return /
*/
Set<Dept> selectRelationDept(List<Dept> deptList, Set<Dept> depts);
Set<Dept> describeRelationDeptSet(List<Dept> deptList, Set<Dept> depts);
/**
* 根据ID获取同级与上级数据
@@ -92,7 +92,7 @@ public interface DeptService extends IService<Dept> {
* @param depts /
* @return /
*/
List<Dept> selectSuperiorDeptByPid(Dept dept, List<Dept> depts);
List<Dept> describeSuperiorDeptListByPid(Dept dept, List<Dept> depts);
/**
* 构建树形数据
@@ -100,7 +100,7 @@ public interface DeptService extends IService<Dept> {
* @param depts /
* @return /
*/
BaseResult<Object> buildTree(List<Dept> depts);
BaseResult<Object> buildDeptTree(List<Dept> depts);
/**
* 获取
@@ -108,7 +108,7 @@ public interface DeptService extends IService<Dept> {
* @param deptList 、
* @return 、
*/
List<Long> selectChildDeptIdByDeptIds(List<Dept> deptList);
List<Long> describeChildDeptIdListByDeptIds(List<Dept> deptList);
/**
* 验证是否被角色或用户关联
@@ -36,7 +36,7 @@ public class DataServiceImpl implements DataService {
* @return /
*/
@Override
public List<Long> selectDeptIdByUserIdWithDeptId(User user) {
public List<Long> describeDeptIdListByUserIdWithDeptId(User user) {
String key = SystemRedisKey.DATA_USER + user.getId();
List<Long> ids = redisHelper.getList(key, Long.class);
if (CollUtil.isEmpty(ids)) {
@@ -71,12 +71,12 @@ public class DataServiceImpl implements DataService {
* @return 数据权限ID
*/
public Set<Long> getCustomize(Set<Long> deptIds, Role role) {
Set<Dept> deptList = deptService.selectDeptByRoleId(role.getId());
Set<Dept> deptList = deptService.describeDeptByRoleId(role.getId());
for (Dept dept : deptList) {
deptIds.add(dept.getId());
List<Dept> deptChildren = deptService.selectDeptByPid(dept.getId());
List<Dept> deptChildren = deptService.describeDeptListByPid(dept.getId());
if (CollUtil.isNotEmpty(deptChildren)) {
deptIds.addAll(deptService.selectChildDeptIdByDeptIds(deptChildren));
deptIds.addAll(deptService.describeChildDeptIdListByDeptIds(deptChildren));
}
}
return deptIds;
@@ -46,7 +46,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
private final RedisHelper redisHelper;
@Override
public List<Dept> selectDeptByCriteria(QueryDeptRequest criteria, Boolean isQuery) throws Exception {
public List<Dept> describeDeptList(QueryDeptRequest criteria, Boolean isQuery) throws Exception {
String dataScopeType = SecurityHelper.getDataScopeType();
if (isQuery) {
if (dataScopeType.equals(DataScopeEnum.ALL.getValue())) {
@@ -81,7 +81,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
}
@Override
public Dept getDeptById(Long id) {
public Dept describeDeptById(Long id) {
String key = SystemRedisKey.DEPT_ID + id;
Dept dept = redisHelper.get(key, Dept.class);
if (dept == null) {
@@ -92,12 +92,12 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
}
@Override
public List<Dept> selectDeptByPid(long pid) {
public List<Dept> describeDeptListByPid(long pid) {
return deptMapper.queryDeptListByPid(pid);
}
@Override
public Set<Dept> selectDeptByRoleId(Long id) {
public Set<Dept> describeDeptByRoleId(Long id) {
return deptMapper.queryDeptSetByRoleId(id);
}
@@ -113,9 +113,9 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
@Override
@Transactional(rollbackFor = Exception.class)
public void updateDept(Dept resources) {
public void modifyDept(Dept resources) {
// 旧的部门
Long oldPid = getDeptById(resources.getId()).getPid();
Long oldPid = describeDeptById(resources.getId()).getPid();
Long newPid = resources.getPid();
if (resources.getPid() != null && resources.getId().equals(resources.getPid())) {
throw new BadRequestException("上级不能为自己");
@@ -142,7 +142,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
}
@Override
public void downloadExcel(List<Dept> deptList, HttpServletResponse response) throws IOException {
public void downloadDeptExcel(List<Dept> deptList, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (Dept dept : deptList) {
Map<String, Object> map = new LinkedHashMap<>();
@@ -155,25 +155,25 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
}
@Override
public Set<Dept> selectRelationDept(List<Dept> menuList, Set<Dept> deptSet) {
public Set<Dept> describeRelationDeptSet(List<Dept> menuList, Set<Dept> deptSet) {
for (Dept dept : menuList) {
deptSet.add(dept);
List<Dept> deptList = deptMapper.queryDeptListByPid(dept.getId());
if (CollUtil.isNotEmpty(deptList)) {
selectRelationDept(deptList, deptSet);
describeRelationDeptSet(deptList, deptSet);
}
}
return deptSet;
}
@Override
public List<Long> selectChildDeptIdByDeptIds(List<Dept> deptList) {
public List<Long> describeChildDeptIdListByDeptIds(List<Dept> deptList) {
List<Long> list = new ArrayList<>();
deptList.forEach(dept -> {
if (dept != null && dept.getEnabled()) {
List<Dept> deptList1 = deptMapper.queryDeptListByPid(dept.getId());
if (CollUtil.isNotEmpty(deptList1)) {
list.addAll(selectChildDeptIdByDeptIds(deptList1));
list.addAll(describeChildDeptIdListByDeptIds(deptList1));
}
list.add(dept.getId());
}
@@ -183,17 +183,17 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
}
@Override
public List<Dept> selectSuperiorDeptByPid(Dept dept, List<Dept> deptList) {
public List<Dept> describeSuperiorDeptListByPid(Dept dept, List<Dept> deptList) {
if (dept.getPid() == null) {
deptList.addAll(deptMapper.queryDeptListByPidIsNull());
return deptList;
}
deptList.addAll(deptMapper.queryDeptListByPid(dept.getPid()));
return selectSuperiorDeptByPid(getDeptById(dept.getPid()), deptList);
return describeSuperiorDeptListByPid(describeDeptById(dept.getPid()), deptList);
}
@Override
public BaseResult<Object> buildTree(List<Dept> deptList) {
public BaseResult<Object> buildDeptTree(List<Dept> deptList) {
Set<Dept> trees = new LinkedHashSet<>();
Set<Dept> deptSet = new LinkedHashSet<>();
List<String> deptNames = deptList.stream().map(Dept::getName).collect(Collectors.toList());
@@ -214,7 +214,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
}
if (isChild) {
deptSet.add(dept);
} else if (dept.getPid() != null && !deptNames.contains(getDeptById(dept.getPid()).getName())) {
} else if (dept.getPid() != null && !deptNames.contains(describeDeptById(dept.getPid()).getName())) {
deptSet.add(dept);
}
}
@@ -242,11 +242,11 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
public void traverseDeptByIdWithPids(Set<Long> ids, Set<Dept> depts) {
for (Long id : ids) {
// 根部门
depts.add(getDeptById(id));
depts.add(describeDeptById(id));
// 子部门
List<Dept> deptList = selectDeptByPid(id);
List<Dept> deptList = describeDeptListByPid(id);
if (CollectionUtil.isNotEmpty(deptList)) {
depts = selectRelationDept(deptList, depts);
depts = describeRelationDeptSet(deptList, depts);
}
}
}