package com.hw.dms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.dms.domain.DmsBaseLubeStandard;
import com.hw.dms.service.IDmsBaseLubeStandardService;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.page.TableDataInfo;

/**
 * 润滑标准信息Controller
 * 
 * @author Open Platform
 * @date 2024-01-12
 */
@RestController
@RequestMapping("/lubeStandard")
public class DmsBaseLubeStandardController extends BaseController
{
    @Autowired
    private IDmsBaseLubeStandardService dmsBaseLubeStandardService;

    /**
     * 查询润滑标准信息列表
     */
    @RequiresPermissions("dms:lubeStandard:list")
    @GetMapping("/list")
    public TableDataInfo list(DmsBaseLubeStandard dmsBaseLubeStandard)
    {
        startPage();
        List<DmsBaseLubeStandard> list = dmsBaseLubeStandardService.selectDmsBaseLubeStandardList(dmsBaseLubeStandard);
        return getDataTable(list);
    }

    /**
     * 导出润滑标准信息列表
     */
    @RequiresPermissions("dms:lubeStandard:export")
    @Log(title = "润滑标准信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsBaseLubeStandard dmsBaseLubeStandard)
    {
        List<DmsBaseLubeStandard> list = dmsBaseLubeStandardService.selectDmsBaseLubeStandardList(dmsBaseLubeStandard);
        ExcelUtil<DmsBaseLubeStandard> util = new ExcelUtil<DmsBaseLubeStandard>(DmsBaseLubeStandard.class);
        util.exportExcel(response, list, "润滑标准信息数据");
    }

    /**
     * 获取润滑标准信息详细信息
     */
    @RequiresPermissions("dms:lubeStandard:query")
    @GetMapping(value = "/{lubeStandardId}")
    public AjaxResult getInfo(@PathVariable("lubeStandardId") Long lubeStandardId)
    {
        return success(dmsBaseLubeStandardService.selectDmsBaseLubeStandardByLubeStandardId(lubeStandardId));
    }

    /**
     * 新增润滑标准信息
     */
    @RequiresPermissions("dms:lubeStandard:add")
    @Log(title = "润滑标准信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsBaseLubeStandard dmsBaseLubeStandard)
    {
        return toAjax(dmsBaseLubeStandardService.insertDmsBaseLubeStandard(dmsBaseLubeStandard));
    }

    /**
     * 修改润滑标准信息
     */
    @RequiresPermissions("dms:lubeStandard:edit")
    @Log(title = "润滑标准信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsBaseLubeStandard dmsBaseLubeStandard)
    {
        return toAjax(dmsBaseLubeStandardService.updateDmsBaseLubeStandard(dmsBaseLubeStandard));
    }

    /**
     * 删除润滑标准信息
     */
    @RequiresPermissions("dms:lubeStandard:remove")
    @Log(title = "润滑标准信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{lubeStandardIds}")
    public AjaxResult remove(@PathVariable Long[] lubeStandardIds)
    {
        return toAjax(dmsBaseLubeStandardService.deleteDmsBaseLubeStandardByLubeStandardIds(lubeStandardIds));
    }
}
