package com.dayou.controller;

import com.dayou.vo.ResourceTransferVO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RestController;
import com.dayou.controller.BaseController;
import com.dayou.service.IResourceTransferService;
import com.dayou.entity.ResourceTransfer;
import com.dayou.common.RestResponse;
import org.springframework.web.bind.annotation.*;
import com.dayou.utils.ConvertUtil;
import com.dayou.utils.HttpKit;
import com.dayou.exception.ErrorCode;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.http.MediaType;
import org.springframework.web.multipart.MultipartFile;
/**
 * 业务资源转移表
 *
 * @author wucl
 * @since 2023-05-31
 */
@RestController
@RequestMapping("resourceTransfer")
@Slf4j
public class ResourceTransferController extends BaseController {
    @Autowired
    private IResourceTransferService resourceTransferService;

    /**
    * 业务资源转移表列表
    */
    @GetMapping("")
    public RestResponse<Page<ResourceTransfer>> page(ResourceTransfer resourceTransfer, Page page){
        Page<ResourceTransfer> pages=resourceTransferService.selectPage(page,resourceTransfer);
        return RestResponse.data(pages);
    }

    /**
     * 业务资源转移表详情
     */
    @GetMapping("/{id}")
    public RestResponse<ResourceTransferVO> detail(@PathVariable Long id){
        ResourceTransferVO xResourceTransfer =resourceTransferService.detail(id);
        return RestResponse.data(xResourceTransfer);
    }

    /**
     * 业务资源转移表新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody ResourceTransfer resourceTransfer) {
        Boolean ret = resourceTransferService.add(resourceTransfer);
        return RestResponse.data(ret);
    }

    /**
     * 业务资源转移表更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody ResourceTransfer resourceTransfer) {
        Boolean ret = resourceTransferService.update(resourceTransfer);
        return RestResponse.data(ret);
    }

    /**
     * 业务资源转移表删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = resourceTransferService.delete(id);
        return RestResponse.data(ret);
    }

    /**
     * 业务资源转移历史
     * @param resourceType
     * @param resourceId
     * @return
     */
    @GetMapping("/history")
    public RestResponse<List<ResourceTransferVO>> transferHistory(String resourceType,Long resourceId){
        List<ResourceTransferVO> list = resourceTransferService.transferHistory(resourceType,resourceId);
        return RestResponse.data(list);
    }

}

