package com.openhis.web.pharmacyWarehousemanage.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.openhis.common.enums.LocationForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.core.common.core.domain.R;
import com.openhis.common.enums.SupplyType;
import com.openhis.web.pharmacyWarehousemanage.appservice.IPharmacyWarehouseCommonService;
import com.openhis.web.pharmacyWarehousemanage.appservice.IPharmacyWarehouseReceiptApprovalService;
import com.openhis.web.pharmacyWarehousemanage.appservice.IPharmacyWarehouseDocumentManagementService;
import com.openhis.web.pharmacyWarehousemanage.dto.PharmacyWarehouseDetailDto;
import com.openhis.web.pharmacyWarehousemanage.dto.PharmacyWarehouseSearchParam;

import lombok.extern.slf4j.Slf4j;

/**
 * 药库单据管理
 *
 * @author  yuxj
 * @date 2025-07-22
 */
@RestController
@RequestMapping("/pharmacy-warehouse/documentManagement")
@Slf4j
public class PharmacyWarehouseDocumentManagementController {

    @Autowired
    private IPharmacyWarehouseDocumentManagementService pharmacyWarehouseDocumentManagementService;

    @Autowired
    private IPharmacyWarehouseCommonService pharmacyWarehouseCommonService;

    /**
     * 单据管理初始化
     *
     * @return 初始化信息
     */
    @GetMapping(value = "/init")
    public R<?> init() {
        return pharmacyWarehouseDocumentManagementService.init();
    }

    /**
     * 单据管理单据列表
     *
     * @param documentManagementSearchParam 查询条件
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 单据管理据分页列表
     */
    @GetMapping(value = "/documentManagement-page")
    public R<?> getPage(PharmacyWarehouseSearchParam documentManagementSearchParam,
                        @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return pharmacyWarehouseCommonService.getPage(documentManagementSearchParam, pageNo, pageSize, searchKey, request,
           null, null);
    }

}
