package com.tmerclub.cloud.search.controller.supplier;

import com.tmerclub.cloud.api.dto.EsPageDTO;
import com.tmerclub.cloud.api.vo.EsPageVO;
import com.tmerclub.cloud.common.constant.SysTypeEnum;
import com.tmerclub.cloud.common.order.dto.AllotOrderSearchDTO;
import com.tmerclub.cloud.common.order.vo.EsAllotOrderVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.security.AuthUserContext;
import com.tmerclub.cloud.search.manager.AllotOrderSearchManager;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author gaozijie
 * @since 2023-11-27
 */
@Tag(name = "调拨订单搜索接口(供应商端)")
@RestController("supplierAllotOrderSearchController")
@RequestMapping("/s/allotOrderSearch")
public class AllotOrderSearchController {

    @Autowired
    private AllotOrderSearchManager allotOrderSearchManager;

    @Operation(summary = "分页查询")
    @GetMapping("/page")
    public ServerResponseEntity<EsPageVO<EsAllotOrderVO>> page(EsPageDTO pageDTO,
                                                               AllotOrderSearchDTO allotOrderSearchDTO) {
        allotOrderSearchDTO.setShopId(AuthUserContext.get().getTenantId());
        allotOrderSearchDTO.setSysType(SysTypeEnum.SUPPLIER.value());
        EsPageVO<EsAllotOrderVO> page = allotOrderSearchManager.page(pageDTO, allotOrderSearchDTO);
        return ServerResponseEntity.success(page);
    }
}
