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.DmsKnowledgeRepair;
import com.hw.dms.service.IDmsKnowledgeRepairService;
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("/knowledgeRepair")
public class DmsKnowledgeRepairController extends BaseController
{
    @Autowired
    private IDmsKnowledgeRepairService dmsKnowledgeRepairService;

    /**
     * 查询维修知识库列表
     */
    @RequiresPermissions("dms:knowledgeRepair:list")
    @GetMapping("/list")
    public TableDataInfo list(DmsKnowledgeRepair dmsKnowledgeRepair)
    {
        startPage();
        List<DmsKnowledgeRepair> list = dmsKnowledgeRepairService.selectDmsKnowledgeRepairList(dmsKnowledgeRepair);
        return getDataTable(list);
    }

    /**
     * 导出维修知识库列表
     */
    @RequiresPermissions("dms:knowledgeRepair:export")
    @Log(title = "维修知识库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsKnowledgeRepair dmsKnowledgeRepair)
    {
        List<DmsKnowledgeRepair> list = dmsKnowledgeRepairService.selectDmsKnowledgeRepairList(dmsKnowledgeRepair);
        ExcelUtil<DmsKnowledgeRepair> util = new ExcelUtil<DmsKnowledgeRepair>(DmsKnowledgeRepair.class);
        util.exportExcel(response, list, "维修知识库数据");
    }

    /**
     * 获取维修知识库详细信息
     */
    @RequiresPermissions("dms:knowledgeRepair:query")
    @GetMapping(value = "/{knowledgeRepairId}")
    public AjaxResult getInfo(@PathVariable("knowledgeRepairId") Long knowledgeRepairId)
    {
        return success(dmsKnowledgeRepairService.selectDmsKnowledgeRepairByKnowledgeRepairId(knowledgeRepairId));
    }

    /**
     * 新增维修知识库
     */
    @RequiresPermissions("dms:knowledgeRepair:add")
    @Log(title = "维修知识库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsKnowledgeRepair dmsKnowledgeRepair)
    {
        return toAjax(dmsKnowledgeRepairService.insertDmsKnowledgeRepair(dmsKnowledgeRepair));
    }

    /**
     * 修改维修知识库
     */
    @RequiresPermissions("dms:knowledgeRepair:edit")
    @Log(title = "维修知识库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsKnowledgeRepair dmsKnowledgeRepair)
    {
        return toAjax(dmsKnowledgeRepairService.updateDmsKnowledgeRepair(dmsKnowledgeRepair));
    }

    /**
     * 删除维修知识库
     */
    @RequiresPermissions("dms:knowledgeRepair:remove")
    @Log(title = "维修知识库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{knowledgeRepairIds}")
    public AjaxResult remove(@PathVariable Long[] knowledgeRepairIds)
    {
        return toAjax(dmsKnowledgeRepairService.deleteDmsKnowledgeRepairByKnowledgeRepairIds(knowledgeRepairIds));
    }
}
