package com.boman.web.core.controller;

import java.io.IOException;
import java.util.List;


import com.boman.common.core.utils.poi.ExcelUtil;
import com.boman.common.core.web.controller.BaseController;
import com.boman.domain.TableDataInfo;
import com.boman.common.log.annotation.Log;
import com.boman.common.log.enums.BusinessType;
import com.boman.domain.dto.AjaxResult;
import com.boman.web.core.service.vaccineInfo.IVaccineInfoOperationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.boman.domain.VaccineInfoOperation;

import javax.servlet.http.HttpServletResponse;


/**
 * 疫苗信息操作Controller
 * 
 * @author ruoyi
 * @date 2021-09-05
 */
@RestController
@RequestMapping("/core/operation")
public class VaccineInfoOperationController extends BaseController
{
    @Autowired
    private IVaccineInfoOperationService vaccineInfoOperationService;

    /**
     * 查询疫苗信息操作列表
     */
//    @PreAuthorize(hasPermi = "@ss.hasPermi('core:operation:list')")
    @GetMapping("/list")
    public TableDataInfo list(VaccineInfoOperation vaccineInfoOperation)
    {
        startPage();
        List<VaccineInfoOperation> list = vaccineInfoOperationService.selectVaccineInfoOperationList(vaccineInfoOperation);
        return getDataTable(list);
    }

    /**
     * 导出疫苗信息操作列表
     */
//    @PreAuthorize(hasPermi = "@ss.hasPermi('core:operation:export')")
    @Log(title = "疫苗信息操作", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public void export(HttpServletResponse response, VaccineInfoOperation vaccineInfoOperation)   throws IOException
    {
        List<VaccineInfoOperation> list = vaccineInfoOperationService.selectVaccineInfoOperationList(vaccineInfoOperation);
        ExcelUtil<VaccineInfoOperation> util = new ExcelUtil<VaccineInfoOperation>(VaccineInfoOperation.class);
         util.exportExcel(response,list, "operation");
    }

    /**
     * 获取疫苗信息操作详细信息
     */
//    @PreAuthorize(hasPermi = "@ss.hasPermi('core:operation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(vaccineInfoOperationService.selectVaccineInfoOperationById(id));
    }

    /**
     * 新增疫苗信息操作
     */
//    @PreAuthorize(hasPermi = "@ss.hasPermi('core:operation:add')")
    @Log(title = "疫苗信息操作", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VaccineInfoOperation vaccineInfoOperation)
    {
        return toAjax(vaccineInfoOperationService.insertVaccineInfoOperation(vaccineInfoOperation));
    }

    /**
     * 修改疫苗信息操作
     */
//    @PreAuthorize(hasPermi = "@ss.hasPermi('core:operation:edit')")
    @Log(title = "疫苗信息操作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VaccineInfoOperation vaccineInfoOperation)
    {
        return toAjax(vaccineInfoOperationService.updateVaccineInfoOperation(vaccineInfoOperation));
    }

    /**
     * 删除疫苗信息操作
     */
//    @PreAuthorize(hasPermi = "@ss.hasPermi('core:operation:remove')")
    @Log(title = "疫苗信息操作", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vaccineInfoOperationService.deleteVaccineInfoOperationByIds(ids));
    }
}
