package com.fzm.mall.server.admin.finance_center.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fzm.mall.server.admin.finance_center.entity.vo.PlatformAssetsFlowVO;
import com.fzm.mall.server.admin.finance_center.service.IMerchantAssetsFlowService;
import com.fzm.mall.server.admin.finance_center.service.IPlatformAssetsFlowService;
import com.fzm.mall.server.admin.home_page.enums.type.AdminTypeEnum;
import com.fzm.mall.server.admin.home_page.service.IAdminService;
import com.fzm.mall.server.admin.repo.ResponseFactory;
import com.fzm.mall.server.admin.repo.ResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wangp
 * @date 2021/4/27 10:44
 * @description 平台流水
 * @since JDK 1.8
 */
@Api(tags = "财务中心-平台流水")
@RestController
@RequestMapping("/platformAssetsFlow")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlatformAssetsFlowController {
    private final IPlatformAssetsFlowService platformAssetsFlowService;
    private final ResponseFactory resFac;
    private final IAdminService adminService;

    @ApiOperation(value = "分页查询-平台流水")
    @GetMapping("/page")
    public ResponseVO page(
            @ApiParam(name = "flowId", value = "流水号")
            @RequestParam(required = false) String flowId,
            @ApiParam(name = "coin", value = "资产类型")
            @RequestParam(required = false) String coin,
            @ApiParam(name = "type", value = "记录状态")
            @RequestParam(required = false) Integer type,
            @RequestParam Integer pageNum,
            @RequestParam Integer pageSize,
            @RequestHeader String adminId) {
        adminService.adminAuthChecks(adminId, AdminTypeEnum.getPlatFormTypeArr());
        IPage<PlatformAssetsFlowVO> page = platformAssetsFlowService.page(flowId, coin, type, pageNum, pageSize);
        return resFac.getSuccessResponseWithData(page);
    }

    @ApiOperation(value = "资产类型")
    @GetMapping("/assetsType")
    public ResponseVO assetsType(@RequestHeader String adminId) {
        adminService.adminAuthChecks(adminId, AdminTypeEnum.getPlatFormTypeArr());
        List<String> assetsTypes = platformAssetsFlowService.assetsType();
        return resFac.getSuccessResponseWithData(assetsTypes);
    }
}
