package com.gz.controller.archive;

import com.github.pagehelper.PageInfo;
import com.gz.dto.archive.ArchiveDTO;
import com.gz.dto.system.ArchivesTreeDTO;
import com.gz.rvo.archive.ArchiveRVO;
import com.gz.service.archive.ArchiveService;
import com.gz.vo.archive.GenerateDhVO;
import com.gz.vo.archive.InsertArchiveVO;
import com.gz.vo.archive.SearchArchiveVO;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

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

/**
 * 档案管理控制器
 * @author LiuchangLan
 * @date 2021/2/23 18:13
 */
@RestController
@RequestMapping("archive/archive")
public class ArchiveController {

    @Resource
    private ArchiveService service;

    @PostMapping("insert")
    Integer insert(@RequestBody InsertArchiveVO vo) throws Exception { return service.insert(vo); }

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

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

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

    @GetMapping("selectByPage")
    PageInfo<ArchiveRVO> selectByPage(SearchArchiveVO vo) {
        return service.selectByPage(vo);
    }

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

    @GetMapping("getJH")
    Integer getJH(String code){
        return service.getJH(code);
    }

    @PostMapping("generateDh")
    String generateDh(@RequestBody GenerateDhVO generateDhVO){
        return service.generateDh(generateDhVO);
    }

    @PostMapping("import")
    List<ArchiveDTO> importExcel(@RequestBody MultipartFile file) throws IOException {
        return service.importExcel(file);
    }
    @GetMapping("selectByPrimaryKeyText")
    ArchiveRVO selectByPrimaryKeyText(Integer id){
        return service.selectByPrimaryKeyText(id);
    }

    @GetMapping("confirmImport")
    Integer confirmImport(){
        return service.confirmImport();
    }
}
