package com.dayou.controller;

import com.dayou.dto.AssetsPerformanceDistributionAddDTO;
import com.dayou.dto.TaskRecordDTO;
import com.dayou.workflow.annotation.FinishTask;
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.IBusinessPerformanceDistributionService;
import com.dayou.entity.BusinessPerformanceDistribution;
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-05-09
 */
@RestController
@RequestMapping("businessPerformanceDistribution")
@Slf4j
public class BusinessPerformanceDistributionController extends BaseController {
    @Autowired
    private IBusinessPerformanceDistributionService businessPerformanceDistributionService;

    /**
    * 绩效分配比例信息列表
    */
    @GetMapping("/page")
    public RestResponse<Page<BusinessPerformanceDistribution>> page(BusinessPerformanceDistribution businessPerformanceDistribution, Page page){
        Page<BusinessPerformanceDistribution> pages=businessPerformanceDistributionService.selectPage(page,businessPerformanceDistribution);
        return RestResponse.data(pages);
    }

    /**
     * 绩效分配比例信息详情
     */
    @GetMapping("/detail/{id}")
    public RestResponse<BusinessPerformanceDistribution> detail(@PathVariable Long id){
        BusinessPerformanceDistribution xBusinessPerformanceDistribution =businessPerformanceDistributionService.detail(id);
        return RestResponse.data(xBusinessPerformanceDistribution);
     }

    /**
     * 绩效分配比例信息新增
     */
    @PostMapping("/save")
    public RestResponse<Boolean> save(@RequestBody BusinessPerformanceDistribution businessPerformanceDistribution) {
        Boolean ret = businessPerformanceDistributionService.add(businessPerformanceDistribution);
        return RestResponse.data(ret);
    }

    /**
     * 绩效分配比例信息更新
     */
    @PutMapping("/update")
    public RestResponse<Boolean> update(@RequestBody BusinessPerformanceDistribution businessPerformanceDistribution) {
        Boolean ret = businessPerformanceDistributionService.update(businessPerformanceDistribution);
        return RestResponse.data(ret);
    }

    /**
     * 绩效分配比例信息删除
     */
    @DeleteMapping("/delete/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = businessPerformanceDistributionService.delete(id);
        return RestResponse.data(ret);
    }

    /**
     * 新增资产绩效分配信息
     * @param dto 新增dto
     * @return Boolean
     */
    @FinishTask
    @PostMapping("/addAssetsPerformanceDistribution")
    public RestResponse<Boolean> addAssetsPerformanceDistribution(@RequestBody TaskRecordDTO<AssetsPerformanceDistributionAddDTO> dto) {
        return RestResponse.data(businessPerformanceDistributionService.addAssetsPerformanceDistribution(dto.getTaskData()));
    }

    /**
     * 获取资产绩效分配信息list
     * @param dto 查询dto
     * @return List<AssetsPerformanceDistributionAddDTO>
     */
    @GetMapping("/getPerformanceDistributionList")
    public RestResponse<List<BusinessPerformanceDistribution>> getPerformanceDistributionList(AssetsPerformanceDistributionAddDTO dto) {
        return RestResponse.data(businessPerformanceDistributionService.getPerformanceDistributionList(dto));
    }

    /**
     * 修改资产绩效分配信息
     * @param dto 修改dto
     * @return Boolean
     */
    @FinishTask
    @PutMapping("/updateAssetsPerformanceDistribution")
    public RestResponse<Boolean> updateAssetsPerformanceDistribution(@RequestBody TaskRecordDTO<AssetsPerformanceDistributionAddDTO> dto) {
        return RestResponse.data(businessPerformanceDistributionService.updateAssetsPerformanceDistribution(dto.getTaskData()));
    }

}

