package com.gz.controller.archive;

import com.github.pagehelper.PageInfo;
import com.gz.dto.archive.ArchiveDTO;
import com.gz.dto.archive.SecondaryArchiveDTO;
import com.gz.service.archive.SecondaryArchiveService;
import com.gz.vo.PageVO;
import com.gz.vo.archive.SecondaryArchiveInsertVO;
import com.gz.vo.archive.SecondaryArchiveVO;
import org.springframework.web.bind.annotation.*;

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

/**
 * @author LiuchangLan
 * @date 2021/3/2 18:34
 */
@RestController
@RequestMapping("secondary/archive")
public class SecondaryArchiveController {

    @Resource
    private SecondaryArchiveService service;

    /**
     * @description 增
     * @author LiuChangLan
     * @since 2020/9/4 14:46
     */
    @PostMapping("insert")
    Integer insert(SecondaryArchiveInsertVO dto) throws Exception{
        return service.insert(dto);
    }

    /**
     * @description 删
     * @author LiuChangLan
     * @since 2020/9/4 14:46
     */
    @DeleteMapping("delete")
    Integer delete(Integer id){
        return service.delete(id);
    }

    /**
     * @description 改
     * @author LiuChangLan
     * @since 2020/9/4 14:46
     */
    @PostMapping("update")
    Integer update(@RequestBody SecondaryArchiveDTO dto){
        return service.update(dto);
    }

    /**
     * @description 分页查询
     * @author LiuChangLan
     * @since 2020/9/4 14:46
     */
    @GetMapping("selectByPage")
    PageInfo<SecondaryArchiveDTO> selectByPage(SecondaryArchiveVO vo){
        return service.selectByPage(vo);
    }


    /**
     * @description 根据主键查询
     * @author LiuChangLan
     * @since 2021/3/2 19:24
     */
    @GetMapping("selectByPrimaryKey")
    SecondaryArchiveDTO selectByPrimaryKey(Integer id) {
        return service.selectByPrimaryKey(id);
    }


    /**
     * @description 根据文档id查询卷内目录
     * @author LiuChangLan
     * @since 2021/3/9 15:35
     */
    @GetMapping("selectByArchiveId")
    List<SecondaryArchiveDTO> selectByArchiveId(Integer archiveId){
        return service.selectByArchiveId(archiveId);
    }
}
