主服务增加fegin接口调用

This commit is contained in:
刘雅馨
2026-07-06 11:32:26 +08:00
committed by kongxz
parent 045214ae80
commit 7475f9d75d
5 changed files with 78 additions and 1 deletions
@@ -26,8 +26,10 @@
package org.springblade.system.feign;
import lombok.AllArgsConstructor;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.pojo.entity.*;
import org.springblade.system.service.*;
import org.springframework.web.bind.annotation.GetMapping;
@@ -103,6 +105,52 @@ public class SysClient implements ISysClient {
return R.data(deptService.getDeptChild(deptId));
}
@Override
@GetMapping(CURRENT_USER_COMPANY)
public R<Dept> getCurrentUserCompany() {
Long deptId = Func.firstLong(AuthUtil.getDeptId());
if (Func.isEmpty(deptId)) {
return R.data(null);
}
Dept company = findCompanyByDeptId(deptId);
return R.data(company);
}
@Override
@GetMapping(CURRENT_USER_DEPT)
public R<Dept> getCurrentUserDept() {
Long deptId = Func.firstLong(AuthUtil.getDeptId());
if (Func.isEmpty(deptId)) {
return R.data(null);
}
Dept dept = deptService.getById(deptId);
if (dept != null && Integer.valueOf(2).equals(dept.getDeptCategory())) {
return R.data(dept);
}
return R.data(null);
}
/**
* 根据部门ID向上查找所属公司(dept_category = 1)
*
* @param deptId 部门ID
* @return 公司信息
*/
private Dept findCompanyByDeptId(Long deptId) {
Dept current = deptService.getById(deptId);
while (current != null) {
if (Integer.valueOf(1).equals(current.getDeptCategory())) {
return current;
}
Long parentId = current.getParentId();
if (Func.isEmpty(parentId) || parentId <= 0L) {
break;
}
current = deptService.getById(parentId);
}
return null;
}
@Override
public R<Post> getPost(Long id) {
return R.data(postService.getById(id));