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

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

    /**
     * 导出保养知识库列表
     */
    @RequiresPermissions("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, "保养知识库数据");
    }

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

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

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

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