package com.ruoyi.os.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.os.domain.DrugArchive;
import com.ruoyi.os.service.IDrugArchiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 *
 *  @author 知无涯
 */
@RestController
@RequestMapping("/healthcare/archive/editHealthcareDrug")
public class DrugArchiveController extends BaseController {

    @Autowired
    private IDrugArchiveService drugArchiveService;

    @GetMapping("/list")
    public TableDataInfo list(DrugArchive drugArchive) {
        startPage();
        List<DrugArchive> list = drugArchiveService.selectDrugArchiveList(drugArchive);
        return getDataTable(list);
    }

    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return success(drugArchiveService.selectDrugArchiveById(id));
    }

    @PostMapping
    public AjaxResult add(@RequestBody DrugArchive drugArchive) {
        return toAjax(drugArchiveService.insertDrugArchive(drugArchive));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody DrugArchive drugArchive) {
        return toAjax(drugArchiveService.updateDrugArchive(drugArchive));
    }

    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(drugArchiveService.deleteDrugArchiveByIds(ids));
    }
}