package cn.ezhizao.project.business.controller;

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

import cn.ezhizao.common.utils.poi.ExcelUtil;
import cn.ezhizao.framework.aspectj.lang.annotation.Log;
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
import cn.ezhizao.framework.web.controller.BaseController;
import cn.ezhizao.framework.web.domain.AjaxResult;
import cn.ezhizao.framework.web.page.TableDataInfo;
import cn.ezhizao.project.business.domain.BizProcessInspectionRelationDetail;
import cn.ezhizao.project.business.service.IBizProcessInspectionRelationDetailService;
import org.springframework.security.access.prepost.PreAuthorize;
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;


/**
 * 外协检查关联明细Controller
 *
 * @author ezhizao
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/business/relationDetail")
public class BizProcessInspectionRelationDetailController extends BaseController
{
    @Resource
    private IBizProcessInspectionRelationDetailService bizProcessInspectionRelationDetailService;

    /**
     * 查询外协检查关联明细列表
     */
    @PreAuthorize("@ss.hasPermi('business:relationDetail:list')")
    @GetMapping("/list")
    @Log(title = "查询外协检查关联明细列表", businessType = BusinessType.SELECT)
    public TableDataInfo list(BizProcessInspectionRelationDetail bizProcessInspectionRelationDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizProcessInspectionRelationDetail);
        startPage();
        List<BizProcessInspectionRelationDetail> list = bizProcessInspectionRelationDetailService.getList(bizProcessInspectionRelationDetail);
        return getDataTable(list);
    }

    /**
     * 导出外协检查关联明细列表
     */
    @PreAuthorize("@ss.hasPermi('business:relationDetail:export')")
    @Log(title = "外协检查关联明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizProcessInspectionRelationDetail bizProcessInspectionRelationDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizProcessInspectionRelationDetail);
        List<BizProcessInspectionRelationDetail> list = bizProcessInspectionRelationDetailService.getList(bizProcessInspectionRelationDetail);
        ExcelUtil<BizProcessInspectionRelationDetail> util = new ExcelUtil<BizProcessInspectionRelationDetail>(BizProcessInspectionRelationDetail.class);
        util.exportExcel(response, list, "外协检查关联明细数据");
    }

    /**
     * 获取外协检查关联明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:relationDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizProcessInspectionRelationDetailService.getById(id));
    }

    /**
     * 新增外协检查关联明细
     */
    @PreAuthorize("@ss.hasPermi('business:relationDetail:add')")
    @Log(title = "新增外协检查关联明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizProcessInspectionRelationDetail bizProcessInspectionRelationDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizProcessInspectionRelationDetail);
        return toAjax(bizProcessInspectionRelationDetailService.save(bizProcessInspectionRelationDetail));
    }

    /**
     * 修改外协检查关联明细
     */
    @PreAuthorize("@ss.hasPermi('business:relationDetail:edit')")
    @Log(title = "编辑外协检查关联明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizProcessInspectionRelationDetail bizProcessInspectionRelationDetail) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizProcessInspectionRelationDetail);
        return toAjax(bizProcessInspectionRelationDetailService.updateById(bizProcessInspectionRelationDetail));
    }

    /**
     * 删除外协检查关联明细
     */
    @PreAuthorize("@ss.hasPermi('business:relationDetail:remove')")
    @Log(title = "删除外协检查关联明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(bizProcessInspectionRelationDetailService.removeBatchByIds(ids));
    }
}
