package com.ruoyi.web.modules.architecture.controller;

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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.modules.architecture.service.IAppMedicationDrugService;

/**
 * 移动端用药工具 — 查询药物。
 */
@RestController
@RequestMapping("/app/medication/drug")
public class BizAppMedicationDrugController extends BaseController
{
    @Autowired
    private IAppMedicationDrugService appMedicationDrugService;

    /**
     * 药物名称下拉选项（distinct drug_name，支持 keyword 模糊）。
     */
    @GetMapping("/names")
    public AjaxResult drugNames(@RequestParam(value = "keyword", required = false) String keyword)
    {
        return success(appMedicationDrugService.selectDrugNameOptions(keyword));
    }

    /**
     * 按药物名称查询休药期标准及配伍禁忌（配伍药物逗号分隔）。
     */
    @GetMapping("/query")
    public AjaxResult query(@RequestParam("drugName") String drugName)
    {
        return success(appMedicationDrugService.queryByDrugName(drugName));
    }
}
