package com.gz.controller.borrow;

import com.github.pagehelper.PageInfo;
import com.gz.dto.borrow.ArchiveBorrowDTO;
import com.gz.rvo.borrow.ArchiveBorrowHistoryRVO;
import com.gz.rvo.borrow.ArchiveBorrowListRVO;
import com.gz.rvo.borrow.AuditInfoRVO;
import com.gz.service.archive.ArchiveService;
import com.gz.service.borrow.ArchiveBorrowService;
import com.gz.vo.PageVO;
import com.gz.vo.borrow.BorrowVO;
import com.gz.vo.borrow.SearchBorrowVO;
import org.springframework.web.bind.annotation.*;

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

/**
 * @author LiuchangLan
 * @date 2021/2/27 15:11
 */
@RestController
@RequestMapping("borrow/archiveBorrow")
public class ArchiveBorrowController {

    @Resource
    private ArchiveBorrowService service;

    @Resource
    private ArchiveService archiveService;

    @PostMapping("borrow")
    Integer borrow(@RequestBody BorrowVO dto) throws Exception {
        return service.borrow(dto);
    }

    @GetMapping("selectBorrowList")
    PageInfo<ArchiveBorrowListRVO> selectBorrowList(PageVO vo){
        return archiveService.selectBorrowList(vo);
    }

    @GetMapping("selectCurrAdminArchiveBorrowHistory")
    PageInfo<ArchiveBorrowHistoryRVO> selectCurrAdminArchiveBorrowHistory(SearchBorrowVO vo){
        return service.selectCurrAdminArchiveBorrowHistory(vo);
    }

    @GetMapping("selectArchiveBorrowHistory")
    PageInfo<ArchiveBorrowHistoryRVO> selectArchiveBorrowHistory(SearchBorrowVO vo){
        return service.selectArchiveBorrowHistory(vo);
    }

    @PostMapping("audit")
    void audit(@RequestBody ArchiveBorrowDTO dto){
        service.audit(dto);
    }

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

    @GetMapping("selectBorrowInfo")
    AuditInfoRVO selectBorrowInfo(Integer id){
        return service.selectBorrowInfo(id);
    }

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

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