package cn.iocoder.yudao.module.system.api.loan;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.api.loan.dto.LoanDTO;
import cn.iocoder.yudao.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
@Tag(name = "RPC 服务 - 假期")
public interface LoanApi {

    String PREFIX = ApiConstants.PREFIX + "/loan";

    @PostMapping(PREFIX + "/create")
    @Operation(summary = "创建借支记录")
    CommonResult<Boolean> createLoan(@RequestBody LoanDTO dto);

    @GetMapping(PREFIX + "/getByUserId")
    @Operation(summary = "获取借支记录")
    @Parameter(name = "userId", description = "用户编号", required = true)
    @Parameter(name = "loanType", description = "借支类型", required = true)
    CommonResult<LoanDTO> getByUserId(@RequestParam("userId") Long userId,
                                      @RequestParam("loanType") Integer loanType);

    @GetMapping(PREFIX + "/getListByUserId")
    @Operation(summary = "获取借支记录")
    @Parameter(name = "userIds", description = "用户编号", required = true)
    @Parameter(name = "loanType", description = "借支类型", required = true)
    CommonResult<List<LoanDTO>> getListByUserId(@RequestParam("userIds") Collection<Long> userId,
                                                @RequestParam("loanType") Integer loanType);


    @GetMapping(PREFIX + "/getListByMonth")
    @Operation(summary = "获取员工截止当前月份的工资借支余额")
    @Parameter(name = "userIds", description = "用户编号", required = true)
    @Parameter(name = "month", description = "月份", required = true)
    CommonResult<List<LoanDTO>> getListByMonth(@RequestParam("userIds") Collection<Long> userId,
                                               @RequestParam("month") String month);


}
