package com.huigou.topsun.ep.controller;

import com.huigou.topsun.ep.epApplication.EpApplication;
import com.huigou.topsun.sap.sapApplication.application.SapDictionaryApplication;
import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.bmp.common.easysearch.EasySearch;
import com.huigou.util.SDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Auther: xin.lu
 * @Date: 2024/06/22/15:35
 * @Description: easySearch方式查询EP系统数据
 */
@Controller
@ControllerMapping("/epResourceSearch")
public class EpResourceSearchController {
    @Autowired
    private EpApplication epApplication;
    @Autowired
    private SapDictionaryApplication sapDictionaryApplication;

    @EasySearch(queryName = "queryBrand")
    public Map<String, Object> queryBrand(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = epApplication.queryEpBrand(param);
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }

    @EasySearch(queryName = "queryPd")
    public Map<String, Object> queryPd(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String filterValue = sdo.getString("filterValue");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = epApplication.queryEpPd(filterValue);
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }

    @EasySearch(queryName = "queryProductAndBom")
    public Map<String, Object> queryProductAndBom(SDO sdo) throws IOException {
        String param = sdo.getString("paramValue");
        String filterValue = sdo.getString("filterValue");
        List<Map<String, String>> mapList = new ArrayList<>();
        mapList = epApplication.queryProductAndBom(filterValue);
        return sapDictionaryApplication.initEasySearchModel( mapList, param, sdo);
    }
}
