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.logging.SystemLog;
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;

/**
 * 分红管理
 * Author:   chenjianhua
 * Date:     2024/9/15 13:36
 * Description: ${DESCRIPTION}
 */
@SystemLog(value = "分红管理")
@RestController
@RequestMapping("/v1/distribution")
public class DistributionController {

    @Autowired
    private DistributionService distributionService;

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

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

    /**
     * 删除分红信息
     *
     * @param idListVO
     * @return
     */
    @SystemLog(value = "删除分红", type = SystemLog.Type.DELETE)
    @PostMapping("delete-distribution")
    public boolean deleteDistribution(@RequestBody IdListVO idListVO) {
        distributionService.deleteDistribution(idListVO);
        return true;
    }

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