package cn.superdesk.uniorder.controller.operationCenter.operators;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dto.param.operationCenter.base.OperationCenterParam;
import cn.superdesk.uniorder.dto.param.operationCenter.operators.OperationCenterOperatorsParam;
import cn.superdesk.uniorder.dto.param.operationCenter.order.OperationCenterOrderParam;
import cn.superdesk.uniorder.dto.vo.operationCenter.base.OperationCenterVo;
import cn.superdesk.uniorder.dto.vo.operationCenter.operators.OperationCenterOperatorsVo;
import cn.superdesk.uniorder.dto.vo.operationCenter.order.OperationCenterOrderFormVo;
import cn.superdesk.uniorder.dubbo.consumer.operationCenter.operators.OperationCenterOperatorsDubboService;
import com.alibaba.fastjson2.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author : zx
 * @Create : 2023/3/28 11:04
 * Description : 数据管理-运营商数据
 */
@Api(value = " 数据管理-运营商数据", tags = {" 运营商数据-列表"})
@Slf4j
@RestController
@RequestMapping("/operationCenter/operators")
@RequiredArgsConstructor
public class OperationCenterOperatorsController {
    private final OperationCenterOperatorsDubboService operationCenterOperatorsDubboService;


    @ApiOperation(value = "数据管理-运营商数据-列表", notes = "")
    @PostMapping("/list")
    @ResponseBody
    public R<List<OperationCenterOperatorsVo>> list(@RequestBody @Validated OperationCenterOperatorsParam param) {
        log.info("运营中心-订单管理-列表,param:{}", JSON.toJSONString(param));

        R<List<OperationCenterOperatorsVo>> result = new R<>();

        result = operationCenterOperatorsDubboService.getOpCenterOperatorList(param);

        return result;
    }

    @ApiOperation(value = "查询运营商下拉列表", notes = "")
    @PostMapping("/selectOperators")
    @ResponseBody
    public R<List<OperationCenterVo>> selectOperators(@RequestBody OperationCenterParam param) {
        if (StringUtils.isBlank(param.getCustomerId())) {
            return new R<>("500", "客户id必传！", false);
        }

        log.info("运营中心-订单管理-查询运营商下拉列表,param:{}", JSON.toJSONString(param));

        return  operationCenterOperatorsDubboService.selectOperationCenterOperators(param);
    }

}
