SysOrgController.java 1.27 KB
package com.youjia.system.controller;

import com.youjia.common.core.Result;
import com.youjia.system.service.SysOrgService;
import com.youjia.system.vo.TreeNodeVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 组织(后台维护,本期不提供管理界面)。
 */
@Tag(name = "系统设置 · 组织")
@RestController
@RequestMapping("/system/org")
@RequiredArgsConstructor
public class SysOrgController {

    private final SysOrgService sysOrgService;

    @Operation(summary = "组织树")
    @GetMapping("/tree")
    public Result<List<TreeNodeVO>> tree() {
        return Result.success(sysOrgService.listOrgTree());
    }

    @Operation(summary = "组织及全部下级组织 ID(数据域「本部门及下级」使用)")
    @GetMapping("/{orgId}/children")
    public Result<List<Long>> children(@PathVariable Long orgId) {
        return Result.success(sysOrgService.listSelfAndChildOrgIds(orgId));
    }
}