package com.simuwang.manage.api.distribution;

import com.simuwang.base.common.support.MybatisPage;
import com.simuwang.base.pojo.dto.query.CompanyEmailPageQuery;
import com.simuwang.base.pojo.dto.query.DistributionPageQuery;
import com.simuwang.base.pojo.vo.DistributionTablePageVO;
import com.simuwang.base.pojo.vo.DistributionVO;
import com.simuwang.base.pojo.vo.IdListVO;
import com.simuwang.base.pojo.vo.IdVO;
import com.simuwang.manage.service.DistributionService;
import com.smppw.common.pojo.ResultVo;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * FileName: DistributionController
 * Author:   chenjianhua
 * Date:     2024/9/15 13:36
 * Description: ${DESCRIPTION}
 */
@RestController
@RequestMapping("/v1/distribution")
public class DistributionController {

    @Autowired
    private DistributionService distributionService;
    /**
     * 分红页面展示查询
     * @param distributionPageQuery
     * @return
     */
    @RequestMapping("search-distribution-list")
    public MybatisPage<DistributionTablePageVO> searchDistributionList(DistributionPageQuery distributionPageQuery){
        MybatisPage<DistributionTablePageVO> result = distributionService.searchDistributionList(distributionPageQuery);
        return result;
    }

    /**
     * 保存分红信息
     * @param distributionVO
     * @return
     */
    @RequestMapping("save-distribution")
    public ResultVo saveDistribution(@RequestBody DistributionVO distributionVO){
        ResultVo vo = distributionService.saveDistribution(distributionVO);
        return vo;
    }

    /**
     * 删除分红信息
     * @param idListVO
     * @return
     */
    @RequestMapping("delete-distribution")
    public boolean deleteDistribution(IdListVO idListVO){
        distributionService.deleteDistribution(idListVO);
        return true;
    }

    /**
     * 上传分红信息
     * @param file
     * @param response
     * @param request
     * @return
     */
    @RequestMapping("upload-distribution")
    public ResultVo uploadDistribution(@RequestParam(value = "file",required = false) MultipartFile file, HttpServletResponse response, HttpServletRequest request){
        ResultVo vo = distributionService.uploadDistribution(file);
        return vo;
    }
}
