package com.gz.controller.system;

import cn.hutool.core.lang.tree.Tree;
import com.github.pagehelper.PageInfo;
import com.gz.dto.system.DeptDTO;
import com.gz.service.system.DeptService;
import com.gz.vo.PageVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author LiuchangLan
 * @date 2021/3/9 16:21
 */
@RequestMapping("system/dept")
@RestController
public class DeptController {

    @Resource
    private DeptService deptService;

    @PostMapping("insert")
    Integer insert(@RequestBody DeptDTO dto) {
        return deptService.insert(dto);
    }

    @DeleteMapping("delete")
    Integer delete(String id) {
        return deptService.delete(id);
    }

    @PostMapping("update")
    Integer update(@RequestBody DeptDTO dto) {
        return deptService.update(dto);
    }

    @GetMapping("selectAll")
    List<DeptDTO> selectAll() {
        return deptService.selectAll();
    }

    @GetMapping("selectTree")
    List<Tree<String>> selectTree(){
        return deptService.selectTree();
    }


    @GetMapping("selectByPage")
    PageInfo<DeptDTO> selectByPage(PageVO vo){
        return deptService.selectByPage(vo);
    }

    @GetMapping("selectByPrimaryKey")
    DeptDTO selectByPrimaryKey(String id){
        return deptService.selectByPrimaryKey(id);
    }
}
