package com.njcn.product.system.dept.controller;


import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;

import com.njcn.product.system.dept.pojo.dto.DeptDTO;
import com.njcn.product.system.dept.pojo.po.Dept;
import com.njcn.product.system.dept.pojo.vo.DeptTreeVO;
import com.njcn.product.system.dept.service.IDeptService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 前端控制器(部门信息)
 * </p>
 *
 * @author hongawen
 * @since 2021-12-13
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/dept")
@Api(tags = "部门管理")
@AllArgsConstructor
public class DeptController extends BaseController {

    private final IDeptService deptService;



    /**
     * 获取部门树
     */
    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @PostMapping("/deptTree")
    @ApiOperation("部门信息树")
    public HttpResult<Object> deptTree() {
        String methodDescribe = getMethodDescribe("deptTree");
        List<DeptTreeVO> result = deptService.deptTree();
         //删除返回失败，查不到数据返回空数组，兼容治理项目没有部门直接报错的bug
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);

    }



}

