package com.openhis.web.nenu.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.core.common.core.domain.R;
import com.openhis.nenu.dto.GfTypeRatioDto;
import com.openhis.web.nenu.appservice.IGfRatioManageAppService;
import com.openhis.web.nenu.dto.GfIndividualRatioDto;
import com.openhis.web.nenu.dto.GfTypeRatioSaveDto;

/**
 * 公费医疗-自付比例管理 Controller
 *
 * @author Thanking
 * @date 2025-10-21
 */
@RestController
@RequestMapping("/nenu/gf-ratio-manage")
public class GfRatioManageController {

    @Autowired
    private IGfRatioManageAppService gfRatioManageAppService;

    /**
     * 查询大项比例列表
     *
     * @return 大项比例列表
     */
    @GetMapping("/type-ratio-list")
    public R<List<GfTypeRatioDto>> getTypeRatioList() {
        return gfRatioManageAppService.getTypeRatioList();
    }

    /**
     * 保存大项比例列表
     *
     * @param gfTypeRatioSaveDto 大项比例保存Dto
     * @return 结果
     */
    @PutMapping("/type-ratio-list")
    public R<?> saveTypeRatioList(@RequestBody GfTypeRatioSaveDto gfTypeRatioSaveDto) {
        return gfRatioManageAppService.saveTypeRatioList(gfTypeRatioSaveDto.getTypeRatioList());
    }

    /**
     * 查询单项比例分页
     *
     * @param searchParam 查询参数
     * @param searchKey 模糊查询关键字
     * @param pageNo 页码
     * @param pageSize 行数
     * @return 单项比例分页
     */
    @GetMapping("/individual-ratio-page")
    public R<IPage<GfIndividualRatioDto>> getIndividualRatioPage(GfIndividualRatioDto searchParam,
        @RequestParam(value = "searchKey", defaultValue = "") String searchKey,
        @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return gfRatioManageAppService.getIndividualRatioPage(searchParam, searchKey, pageNo, pageSize);
    }
}
