package com.aucma.dms.controller;

import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.core.page.TableDataInfo;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.dms.domain.DmsBaseLubeStandard;
import com.aucma.dms.service.IDmsBaseLubeStandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


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

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

    /**
     * 导出润滑标准信息列表
     */
    //@PreAuthorize("@ss.hasPermi('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, "润滑标准信息数据");
    }

    /**
     * 查询润滑标准列表
     */
    @GetMapping("/getLueStandardList")
    public AjaxResult getLueStandardList(DmsBaseLubeStandard dmsBaseLubeStandard)
    {
        List<DmsBaseLubeStandard> list = dmsBaseLubeStandardService
                .selectDmsBaseLubeStandardList(dmsBaseLubeStandard);
        return success(list);
    }

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

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

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

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