package com.simuwang.manage.api.distribution;

import com.simuwang.base.common.support.MybatisPage;
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.manage.service.DistributionService;
import com.smppw.common.pojo.ResultVo;
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
     */
    @PostMapping("delete-distribution")
    public boolean deleteDistribution(@RequestBody IdListVO idListVO) {
        distributionService.deleteDistribution(idListVO);
        return true;
    }

    /**
     * 上传分红信息
     *
     * @param file
     * @return
     */
    @PostMapping("upload-distribution")
    public ResultVo uploadDistribution(@RequestPart(value = "file") MultipartFile file) {
        ResultVo vo = distributionService.uploadDistribution(file);
        return vo;
    }
}
