package com.aucma.dms.controller;

//import com.hw.common.core.utils.poi.ExcelUtil;
//import com.hw.common.core.web.controller.BaseController;
//import com.hw.common.core.web.domain.AjaxResult;
//import com.hw.common.core.web.page.TableDataInfo;
//import com.hw.common.log.annotation.Log;
//import com.hw.common.log.enums.BusinessType;
//import com.hw.common.security.annotation.RequiresPermissions;
//import com.aucma.dms.domain.DmsKnowledgeMaint;
//import com.aucma.dms.service.IDmsKnowledgeMaintService;

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.DmsKnowledgeMaint;
import com.aucma.dms.service.IDmsKnowledgeMaintService;
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-02-26
 */
@RestController
@RequestMapping("/dms/konwledgeMaint")
public class DmsKnowledgeMaintController extends BaseController
{
    @Autowired
    private IDmsKnowledgeMaintService dmsKnowledgeMaintService;

    /**
     * 查询保养知识库列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:konwledgeMaint:list')" )
    @GetMapping("/list")
    public TableDataInfo list(DmsKnowledgeMaint dmsKnowledgeMaint)
    {
        startPage();
        List<DmsKnowledgeMaint> list = dmsKnowledgeMaintService.selectDmsKnowledgeMaintList(dmsKnowledgeMaint);
        return getDataTable(list);
    }

    /**
     * 导出保养知识库列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:konwledgeMaint:export')" )
    //@Log(title = "保养知识库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsKnowledgeMaint dmsKnowledgeMaint)
    {
        List<DmsKnowledgeMaint> list = dmsKnowledgeMaintService.selectDmsKnowledgeMaintList(dmsKnowledgeMaint);
        ExcelUtil<DmsKnowledgeMaint> util = new ExcelUtil<DmsKnowledgeMaint>(DmsKnowledgeMaint.class);
        util.exportExcel(response, list, "保养知识库数据");
    }

    /**
     * 获取保养知识库详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:konwledgeMaint:query')" )
    @GetMapping(value = "/{knowledgeMaintId}")
    public AjaxResult getInfo(@PathVariable("knowledgeMaintId") Long knowledgeMaintId)
    {
        return success(dmsKnowledgeMaintService.selectDmsKnowledgeMaintByKnowledgeMaintId(knowledgeMaintId));
    }

    /**
     * 新增保养知识库
     */
    //@PreAuthorize("@ss.hasPermi('dms:konwledgeMaint:add')" )
    //@Log(title = "保养知识库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsKnowledgeMaint dmsKnowledgeMaint)
    {
        return toAjax(dmsKnowledgeMaintService.insertDmsKnowledgeMaint(dmsKnowledgeMaint));
    }

    /**
     * 修改保养知识库
     */
    //@PreAuthorize("@ss.hasPermi('dms:konwledgeMaint:edit')" )
    //@Log(title = "保养知识库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsKnowledgeMaint dmsKnowledgeMaint)
    {
        return toAjax(dmsKnowledgeMaintService.updateDmsKnowledgeMaint(dmsKnowledgeMaint));
    }

    /**
     * 删除保养知识库
     */
    //@PreAuthorize("@ss.hasPermi('dms:konwledgeMaint:remove')" )
    //@Log(title = "保养知识库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{knowledgeMaintIds}")
    public AjaxResult remove(@PathVariable Long[] knowledgeMaintIds)
    {
        return toAjax(dmsKnowledgeMaintService.deleteDmsKnowledgeMaintByKnowledgeMaintIds(knowledgeMaintIds));
    }
}
