package com.siwei.rsmonitoring.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.siwei.common.log.annotation.Log;
import com.siwei.common.log.enums.BusinessType;
import com.siwei.common.security.annotation.RequiresPermissions;
import com.siwei.rsmonitoring.domain.TDkAuditflowRecordFj;
import com.siwei.rsmonitoring.service.ITDkAuditflowRecordFjService;
import com.siwei.common.core.web.controller.BaseController;
import com.siwei.common.core.web.domain.AjaxResult;
import com.siwei.common.core.utils.poi.ExcelUtil;
import com.siwei.common.core.web.page.TableDataInfo;

/**
 * 地块核查流程与附件关联Controller
 *
 * @author siwei
 * @date 2025-01-22
 */
@RestController
@RequestMapping("/auditflow/round_fj")
public class TDkAuditflowRecordFjController extends BaseController {
    @Autowired
    private ITDkAuditflowRecordFjService tDkAuditflowRecordFjService;

    /**
     * 查询地块核查流程与附件关联列表
     */
    @RequiresPermissions("rsmonitoring:auditflow:fj:list")
    @GetMapping("/list")
    public TableDataInfo list(TDkAuditflowRecordFj tDkAuditflowRecordFj) {
        startPage();
        List<TDkAuditflowRecordFj> list = tDkAuditflowRecordFjService.selectTDkAuditflowRecordFjList(tDkAuditflowRecordFj);
        return getDataTable(list);
    }

    /**
     * 导出地块核查流程与附件关联列表
     */
    @RequiresPermissions("rsmonitoring:auditflow:fj:export")
    @Log(title = "地块核查流程与附件关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TDkAuditflowRecordFj tDkAuditflowRecordFj) {
        List<TDkAuditflowRecordFj> list = tDkAuditflowRecordFjService.selectTDkAuditflowRecordFjList(tDkAuditflowRecordFj);
        ExcelUtil<TDkAuditflowRecordFj> util = new ExcelUtil<TDkAuditflowRecordFj>(TDkAuditflowRecordFj.class);
        util.exportExcel(response, list, "地块核查流程与附件关联数据");
    }

    /**
     * 获取地块核查流程与附件关联详细信息
     */
    @RequiresPermissions("rsmonitoring:auditflow:fj:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(tDkAuditflowRecordFjService.selectTDkAuditflowRecordFjById(id));
    }

    /**
     * 新增地块核查流程与附件关联
     */
    @RequiresPermissions("rsmonitoring:auditflow:fj:add")
    @Log(title = "地块核查流程与附件关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDkAuditflowRecordFj tDkAuditflowRecordFj) {
        return toAjax(tDkAuditflowRecordFjService.insertTDkAuditflowRecordFj(tDkAuditflowRecordFj));
    }

    /**
     * 修改地块核查流程与附件关联
     */
    @RequiresPermissions("rsmonitoring:auditflow:fj:edit")
    @Log(title = "地块核查流程与附件关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDkAuditflowRecordFj tDkAuditflowRecordFj) {
        return toAjax(tDkAuditflowRecordFjService.updateTDkAuditflowRecordFj(tDkAuditflowRecordFj));
    }

    /**
     * 删除地块核查流程与附件关联
     */
    @RequiresPermissions("rsmonitoring:auditflow:fj:remove")
    @Log(title = "地块核查流程与附件关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tDkAuditflowRecordFjService.deleteTDkAuditflowRecordFjByIds(ids));
    }
}
