
package com.tmerclub.cloud.search.feign;


import com.tmerclub.cloud.api.dto.PurchaseOrderUpdateDTO;
import com.tmerclub.cloud.api.feign.SearchPurchaseOrderFeignClient;
import com.tmerclub.cloud.api.order.bo.EsPurchaseOrderBO;
import com.tmerclub.cloud.api.vo.EsPageVO;
import com.tmerclub.cloud.common.order.dto.PurchaseOrderSearchDTO;
import com.tmerclub.cloud.common.order.vo.EsPurchaseOrderVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.search.constant.EsIndexEnum;
import com.tmerclub.cloud.search.manager.PurchaseOrderSearchManager;
import com.tmerclub.cloud.search.util.EsSearchUtil;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * 订单搜索feign连接
 * @author YXF
 * @date 2020/12/07
 */
@DubboService
public class SearchPurchaseOrderFeignController implements SearchPurchaseOrderFeignClient {

    @Autowired
    private PurchaseOrderSearchManager purchaseOrderSearchManager;

    @Override
    public ServerResponseEntity<EsPageVO<EsPurchaseOrderVO>> pagePurchaseOrder(PurchaseOrderSearchDTO purchaseOrderSearchDTO) {
        return ServerResponseEntity.success(purchaseOrderSearchManager.pageSearchResult(purchaseOrderSearchDTO));
    }

    @Override
    public void updatePurchaseOrderStatus(PurchaseOrderUpdateDTO purchaseOrder) {
        EsPurchaseOrderBO esOrder = new EsPurchaseOrderBO();
        esOrder.setStatus(purchaseOrder.getStatus());
        EsSearchUtil.esUpdate(purchaseOrder.getPurchaseOrderId(), EsIndexEnum.PURCHASE_ORDER, esOrder);
    }
}
