package cn.superdesk.uniorder.controller._common;

import cn.superdesk.uniorder.common.enums.common.CommonServiceNoEnum;
import cn.superdesk.uniorder.common.enums.common.CommonSourceFromEnum;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.rest.response.ResponseResultOuterUtils;
import cn.superdesk.uniorder.controller.base.BaseController;
import cn.superdesk.uniorder.dto.vo._common.EnumSelectStringStringVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2022/5/13 3:47 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/5/13 3:47 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Api(value = "公共接口-下拉列表-公共", tags = {"公共接口-下拉列表-公共"})
@Slf4j
@RestController
@RequestMapping("/common/select/common")
public class CommonSelectCommonController extends BaseController {

    @ApiOperation(value = "业务来源", notes = "v2.3")
    @RequestMapping(value = "/v2_3/sourceFrom", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectStringStringVo>> selectCommonSourceFromEnum() {

        List<EnumSelectStringStringVo> selectVos = new ArrayList<>();

        for (CommonSourceFromEnum value : CommonSourceFromEnum.values()) {
            selectVos.add(EnumSelectStringStringVo
                    .builder()
                    .key(value.getSourceFromCode())
                    .desc(value.getSourceFromName())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }

    @ApiOperation(value = "订单来源", notes = "v2.3")
    @RequestMapping(value = "/v2_3/serviceNo", method = RequestMethod.POST)
    @ResponseBody
    public R<List<EnumSelectStringStringVo>> selectCommonServiceNoEnum() {

        List<EnumSelectStringStringVo> selectVos = new ArrayList<>();

        for (CommonServiceNoEnum value : CommonServiceNoEnum.values()) {
            selectVos.add(EnumSelectStringStringVo
                    .builder()
                    .key(value.getServiceNo())
                    .desc(value.getServiceName())
                    .build()
            );
        }

        return ResponseResultOuterUtils.createSuccesResult("SUCCESS", selectVos);
    }


    // 作用上有点不同 @link UnifiedServiceController
//    @ApiOperation(value = "订单类型-下拉")
//    @RequestMapping(value = "/getAsOrderType", method = RequestMethod.POST)
//    @ResponseBody
//    public R<List<UnifiedService>> getAsOrderType() {
//
//        R<List<UnifiedService>> result = new R<>();
//
//        result.setData(unifiedServiceDubboConsumerService.getAsOrderType(getToken()));
//
//        return result;
//    }
}
