package com.ruoyi.dimp.controller;

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

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;
import com.ruoyi.common.annotation.Log;

import java.util.Arrays;

import com.ruoyi.common.core.controller.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dimp.domain.DPatentEffectiveInfoPreDetail;
import com.ruoyi.dimp.service.IDPatentEffectiveInfoPreDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专利有效导入详情Controller
 *
 * @author ruoyi
 * @date 2023-03-19
 */
@RestController
@RequestMapping("/dimp/dPatentEffectiveInfoPreDetail")
public class DPatentEffectiveInfoPreDetailController extends BaseController {
    private final IDPatentEffectiveInfoPreDetailService dPatentEffectiveInfoPreDetailService;

    public DPatentEffectiveInfoPreDetailController(IDPatentEffectiveInfoPreDetailService dPatentEffectiveInfoPreDetailService) {
        this.dPatentEffectiveInfoPreDetailService = dPatentEffectiveInfoPreDetailService;
    }


    /**
     * 查询专利有效导入详情列表
     *
     * @param dPatentEffectiveInfoPreDetail 专利有效导入详情
     * @return 专利有效导入详情集合
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dPatentEffectiveInfoPreDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(DPatentEffectiveInfoPreDetail dPatentEffectiveInfoPreDetail) {
        startPage();
        List<DPatentEffectiveInfoPreDetail> list = dPatentEffectiveInfoPreDetailService.queryList(dPatentEffectiveInfoPreDetail);
        return getDataTable(list);
    }


    /**
     * 导出专利有效导入详情列表
     *
     * @param dPatentEffectiveInfoPreDetail 专利有效导入详情
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dPatentEffectiveInfoPreDetail:export')")
    @Log(title = "专利有效导入详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DPatentEffectiveInfoPreDetail dPatentEffectiveInfoPreDetail) {
        List<DPatentEffectiveInfoPreDetail> list = dPatentEffectiveInfoPreDetailService.list(new QueryWrapper<>());
        ExcelUtil<DPatentEffectiveInfoPreDetail> util = new ExcelUtil<>(DPatentEffectiveInfoPreDetail. class);
        util.exportExcel(response, list, "专利有效导入详情数据");
    }

    /**
     * 获取专利有效导入详情详细信息
     *
     * @param id 主键id
     * @return 结果
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dPatentEffectiveInfoPreDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(dPatentEffectiveInfoPreDetailService.getById(id));
    }


    /**
     * 新增专利有效导入详情信息
     *
     * @param dPatentEffectiveInfoPreDetail 专利有效导入详情
     * @return 结果
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dPatentEffectiveInfoPreDetail:add')")
    @Log(title = "专利有效导入详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DPatentEffectiveInfoPreDetail dPatentEffectiveInfoPreDetail) {
        return toAjax(dPatentEffectiveInfoPreDetailService.save(dPatentEffectiveInfoPreDetail));
    }


    /**
     * 修改专利有效导入详情信息
     *
     * @param dPatentEffectiveInfoPreDetail 专利有效导入详情
     * @return 结果
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dPatentEffectiveInfoPreDetail:edit')")
    @Log(title = "专利有效导入详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DPatentEffectiveInfoPreDetail dPatentEffectiveInfoPreDetail) {
        return toAjax(dPatentEffectiveInfoPreDetailService.updateById(dPatentEffectiveInfoPreDetail));
    }


    /**
     * 删除专利有效导入详情信息
     *
     * @param ids 主键ids
     * @return 结果
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dPatentEffectiveInfoPreDetail:remove')")
    @Log(title = "专利有效导入详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(dPatentEffectiveInfoPreDetailService.removeByIds(Arrays.asList(ids)));
    }


}
