package com.gz.controller.system;

import cn.hutool.core.lang.tree.Tree;
import com.gz.core.annotation.TraceLog;
import com.gz.dto.system.ArchivesTreeDTO;
import com.gz.service.system.ArchivesTreeService;
import org.springframework.web.bind.annotation.*;

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

/**
 * 档案树控制器
 *
 * @author LiuchangLan
 * @date 2021/2/23 16:10
 */
@RestController
@RequestMapping("system/archivesTree")
public class ArchivesTreeController {
    @Resource
    private ArchivesTreeService service;

    @PostMapping("insert")
    Integer insert(@RequestBody ArchivesTreeDTO dto) {
        return service.insert(dto);
    }

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

    @PostMapping("update")
    Integer update(@RequestBody ArchivesTreeDTO dto) {
        return service.update(dto);
    }

    @GetMapping("selectAll")
    List<ArchivesTreeDTO> selectAll() {
        return service.selectAll();
    }

    @GetMapping("selectByPrimaryKey")
    ArchivesTreeDTO selectByPrimaryKey(Integer id) {
        return service.selectByPrimaryKey(id);
    }

    @GetMapping("selectByOrder")
    List<ArchivesTreeDTO> selectByOrder(){
        return service.selectByOrder();
    }

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

    @GetMapping("upMove")
    void upMove(Integer id){
        service.upMove(id);
    }

    @GetMapping("downMove")
    void upDown(Integer id){
        service.downMove(id);
    }

    @GetMapping("selectChildById")
    List<ArchivesTreeDTO> selectChildById(Integer id){
        return service.selectChildById(id);
    }

    @GetMapping("selectParentByCode")
    ArchivesTreeDTO selectParentByCode(String code){
        return service.selectParentByCode(code);
    }

    @GetMapping("selectArchiveRole")
    List<Tree<String>> selectArchiveRole(Integer roleId){
        return service.selectArchiveRole(roleId);
    }
}
