mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-23 11:09:29 +08:00
部门管理
This commit is contained in:
22
src/main/java/xyz/playedu/api/bus/AppBus.java
Normal file
22
src/main/java/xyz/playedu/api/bus/AppBus.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package xyz.playedu.api.bus;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import xyz.playedu.api.config.PlayEduConfig;
|
||||
import xyz.playedu.api.constant.SystemConstant;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
* @create 2023/2/19 12:06
|
||||
*/
|
||||
@Component
|
||||
public class AppBus {
|
||||
|
||||
@Autowired
|
||||
private PlayEduConfig playEduConfig;
|
||||
|
||||
public boolean isDev() {
|
||||
return !playEduConfig.getEnv().equals(SystemConstant.ENV_PROD);
|
||||
}
|
||||
|
||||
}
|
||||
32
src/main/java/xyz/playedu/api/bus/DepartmentBus.java
Normal file
32
src/main/java/xyz/playedu/api/bus/DepartmentBus.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package xyz.playedu.api.bus;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import xyz.playedu.api.domain.Department;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
import xyz.playedu.api.service.DepartmentService;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
* @create 2023/2/19 11:02
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class DepartmentBus {
|
||||
|
||||
@Autowired
|
||||
private DepartmentService departmentService;
|
||||
|
||||
public String compParentChain(Integer parentId) throws NotFoundException {
|
||||
String parentChain = "";
|
||||
if (parentId != 0) {
|
||||
Department parentDepartment = departmentService.getById(parentId);
|
||||
if (parentDepartment == null) {
|
||||
throw new NotFoundException("父级部门不存在");
|
||||
}
|
||||
parentChain = parentDepartment.getParentChain() + "," + parentId;
|
||||
}
|
||||
return parentChain;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user