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.DPctApplyInfo;
import com.ruoyi.dimp.service.IDPctApplyInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * PCT申请导入Controller
 *
 * @author ruoyi
 * @date 2023-03-19
 */
@RestController
@RequestMapping("/dimp/dPctApplyInfo")
public class DPctApplyInfoController extends BaseController {
    private final IDPctApplyInfoService dPctApplyInfoService;

    public DPctApplyInfoController(IDPctApplyInfoService dPctApplyInfoService) {
        this.dPctApplyInfoService = dPctApplyInfoService;
    }


    /**
     * 查询PCT申请导入列表
     *
     * @param dPctApplyInfo PCT申请导入
     * @return PCT申请导入集合
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dPctApplyInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DPctApplyInfo dPctApplyInfo) {
        startPage();
        List<DPctApplyInfo> list = dPctApplyInfoService.queryList(dPctApplyInfo);
        return getDataTable(list);
    }


    /**
     * 导出PCT申请导入列表
     *
     * @param dPctApplyInfo PCT申请导入
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dPctApplyInfo:export')")
    @Log(title = "PCT申请导入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DPctApplyInfo dPctApplyInfo) {
        List<DPctApplyInfo> list = dPctApplyInfoService.list(new QueryWrapper<>());
        ExcelUtil<DPctApplyInfo> util = new ExcelUtil<>(DPctApplyInfo. class);
        util.exportExcel(response, list, "PCT申请导入数据");
    }

    /**
     * 获取PCT申请导入详细信息
     *
     * @param id 主键id
     * @return 结果
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dPctApplyInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(dPctApplyInfoService.getById(id));
    }


    /**
     * 新增PCT申请导入信息
     *
     * @param dPctApplyInfo PCT申请导入
     * @return 结果
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dPctApplyInfo:add')")
    @Log(title = "PCT申请导入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DPctApplyInfo dPctApplyInfo) {
        return toAjax(dPctApplyInfoService.save(dPctApplyInfo));
    }


    /**
     * 修改PCT申请导入信息
     *
     * @param dPctApplyInfo PCT申请导入
     * @return 结果
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dPctApplyInfo:edit')")
    @Log(title = "PCT申请导入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DPctApplyInfo dPctApplyInfo) {
        return toAjax(dPctApplyInfoService.updateById(dPctApplyInfo));
    }


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


}
