package com.ruoyi.web.controller.wocom;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.CorpContextHolder;
import com.ruoyi.excel.wecom.service.ICorpDepartmentService;
import com.ruoyi.excel.wecom.vo.CorpDepartmentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/wecom/department")
public class CorpDepartmentController {

    @Autowired
    private ICorpDepartmentService corpDepartmentService;

    @GetMapping("/tree")
    public AjaxResult getDepartmentTree() {
        String corpId = CorpContextHolder.getCurrentCorpId();
        List<CorpDepartmentVO> tree = corpDepartmentService.selectCorpDepartmentTree(corpId);
        return AjaxResult.success(tree);
    }
}
