package cn.ey.biz.module.system.api.delegation;


import cn.ey.biz.common.pojo.R;
import cn.ey.biz.module.system.api.delegation.dto.UserDelegationDTO;
import cn.ey.biz.module.system.api.delegation.dto.UserDelegationReqDTO;
import cn.ey.biz.module.system.api.delegation.dto.UserDelegationUnitDTO;
import cn.ey.biz.module.system.enums.ApiConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
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.List;

@FeignClient(name = ApiConstants.NAME)
@Api(tags = "RPC 服务 - 代理人关系信息")
public interface DelegationApi {

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

    @GetMapping(PREFIX + "/list")
    @ApiOperation("获取代理人与被代理人关系")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "app", value = "应用", example = "timesheet", required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "agentGpn", value = "代理人GPN", example = "XE0312345", required = true, dataTypeClass = String.class)
    })
    List<UserDelegationDTO> getDelegation(@RequestParam("app") String app, @RequestParam("agentGpn") String gpn);

    @PostMapping(PREFIX + "/listDelegation")
    @ApiOperation("获取代理人与被代理人关系")
    R<List<UserDelegationDTO>> listDelegation(@RequestBody UserDelegationReqDTO userDelegationReq);

    @GetMapping(PREFIX + "/ListUnit")
    @ApiOperation("获取代理人与被代理单元关系")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "app", value = "应用", example = "timesheet", required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "agentGpn", value = "代理人GPN", example = "XE0312345", required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "type", value = "代理关系类型", example = "01-rank/02-mu/03-subMu", dataTypeClass = String.class)
    })
    List<UserDelegationUnitDTO> getDelegationUnit(@RequestParam("app") String app, @RequestParam("agentGpn") String gpn,
                                                  @RequestParam(value = "type", required = false) String type);

}
