package com.xinda.data.controller;

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

import com.xinda.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
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.xinda.common.annotation.Log;
import com.xinda.common.core.controller.BaseController;
import com.xinda.common.core.domain.AjaxResult;
import com.xinda.common.enums.BusinessType;
import com.xinda.iot.domain.Doc;
import com.xinda.iot.service.IDocService;
import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 档案管理Controller
 *
 * @author leo
 * @date 2025-04-04
 */
@RestController
@RequestMapping("/iot/doc")
@Api(tags = "档案管理")
public class DocController extends BaseController
{
    @Autowired
    private IDocService docService;

/**
 * 查询档案管理列表
 */
@PreAuthorize("@ss.hasPermi('iot:doc:list')")
@GetMapping("/list")
@ApiOperation("查询档案管理列表")
    public TableDataInfo list(Doc doc)
    {
        startPage();
        List<Doc> list = docService.selectDocList(doc);
        return getDataTable(list);
    }

    /**
     * 导出档案管理列表
     */
    @ApiOperation("导出档案管理列表")
    @PreAuthorize("@ss.hasPermi('iot:doc:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, Doc doc)
    {
        List<Doc> list = docService.selectDocList(doc);
        ExcelUtil<Doc> util = new ExcelUtil<Doc>(Doc.class);
        util.exportExcel(response, list, "档案管理数据");
    }

    /**
     * 获取档案管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('iot:doc:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取档案管理详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(docService.selectDocById(id));
    }

    /**
     * 新增档案管理
     */
    @PreAuthorize("@ss.hasPermi('iot:doc:add')")
    @PostMapping
    @ApiOperation("新增档案管理")
    public AjaxResult add(@RequestBody Doc doc)
    {
        return toAjax(docService.insertDoc(doc));
    }

    /**
     * 修改档案管理
     */
    @PreAuthorize("@ss.hasPermi('iot:doc:edit')")
    @PutMapping
    @ApiOperation("修改档案管理")
    public AjaxResult edit(@RequestBody Doc doc)
    {
        return toAjax(docService.updateDoc(doc));
    }

    /**
     * 删除档案管理
     */
    @PreAuthorize("@ss.hasPermi('iot:doc:remove')")
    @DeleteMapping("/{ids}")
    @ApiOperation("删除档案管理")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(docService.deleteDocByIds(ids));
    }

}
