package com.cool.store.controller.webb;

import com.cool.store.common.InsertGroup;
import com.cool.store.common.UpdateGroup;
import com.cool.store.request.fees.WalletCompanyQueryRequest;
import com.cool.store.request.fees.WalletAllocationConfigAddRequest;
import com.cool.store.request.fees.WalletAllocationConfigPageRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.fees.WalletAllocationConfigService;
import com.cool.store.vo.fees.InvestDivisionRegionVO;
import com.cool.store.vo.fees.WalletAllocationCompanyVO;
import com.cool.store.vo.fees.WalletAllocationConfigVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 分账配置Controller
 *
 * @author system
 */
@Api(tags = "分账配置")
@RestController
@RequestMapping("/pc/fees/allocationConfig")
@RequiredArgsConstructor
@Validated
public class WalletAllocationConfigController {

    private final WalletAllocationConfigService walletAllocationConfigService;

    @ApiOperation("新增分账配置")
    @PostMapping("/add")
    public ResponseResult<Boolean> add(@RequestBody @Validated({InsertGroup.class}) WalletAllocationConfigAddRequest request) {
        return ResponseResult.success(walletAllocationConfigService.add(request));
    }

    @ApiOperation("编辑分账配置")
    @PostMapping("/update")
    public ResponseResult<Boolean> update(@RequestBody @Validated({UpdateGroup.class}) WalletAllocationConfigAddRequest request) {
        return ResponseResult.success(walletAllocationConfigService.update(request));
    }

    @ApiOperation("分页查询分账配置")
    @PostMapping("/page")
    public ResponseResult<PageInfo<WalletAllocationConfigVO>> page(@RequestBody WalletAllocationConfigPageRequest request) {
        return ResponseResult.success(walletAllocationConfigService.page(request));
    }

    @ApiOperation("招商分部列表")
    @GetMapping("/getInvestDivisionRegion")
    public ResponseResult<List<InvestDivisionRegionVO>> getInvestDivisionRegion() {
        return ResponseResult.success(walletAllocationConfigService.getInvestDivisionRegionList());
    }

    @ApiOperation("收款公司列表")
    @PostMapping("/companyPage")
    public ResponseResult<PageInfo<WalletAllocationCompanyVO>> companyPage(@RequestBody WalletCompanyQueryRequest request) {
        return ResponseResult.success(walletAllocationConfigService.companyPage(request));
    }
}

