package com.dayou.controller;

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.IBusinessFileService;
import com.dayou.entity.BusinessFile;
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 2024-03-01
 */
@RestController
@RequestMapping("businessFile")
@Slf4j
public class BusinessFileController extends BaseController {
    @Autowired
    private IBusinessFileService businessFileService;

    /**
    * 业务文档列表
    */
    @GetMapping("")
    public RestResponse<Page<BusinessFile>> page(BusinessFile businessFile, Page page){
        Page<BusinessFile> pages=businessFileService.selectPage(page,businessFile);
        return RestResponse.data(pages);
    }

    /**
     * 业务文档详情
     */
    @GetMapping("/{id}")
    public RestResponse<BusinessFile> detail(@PathVariable Long id){
        BusinessFile xBusinessFile =businessFileService.detail(id);
        return RestResponse.data(xBusinessFile);
     }

    /**
     * 业务文档新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody BusinessFile businessFile) {
        Boolean ret = businessFileService.add(businessFile);
        return RestResponse.data(ret);
    }

    /**
     * 业务文档更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody BusinessFile businessFile) {
        Boolean ret = businessFileService.update(businessFile);
        return RestResponse.data(ret);
    }

    /**
     * 业务文档删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = businessFileService.delete(id);
        return RestResponse.data(ret);
    }


}

