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

/**
 * 高价值数据导入详情Controller
 *
 * @author ruoyi
 * @date 2023-03-19
 */
@RestController
@RequestMapping("/dimp/dHighValueInfoPreDetail")
public class DHighValueInfoPreDetailController extends BaseController {
    private final IDHighValueInfoPreDetailService dHighValueInfoPreDetailService;

    public DHighValueInfoPreDetailController(IDHighValueInfoPreDetailService dHighValueInfoPreDetailService) {
        this.dHighValueInfoPreDetailService = dHighValueInfoPreDetailService;
    }


    /**
     * 查询高价值数据导入详情列表
     *
     * @param dHighValueInfoPreDetail 高价值数据导入详情
     * @return 高价值数据导入详情集合
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dHighValueInfoPreDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(DHighValueInfoPreDetail dHighValueInfoPreDetail) {
        startPage();
        List<DHighValueInfoPreDetail> list = dHighValueInfoPreDetailService.queryList(dHighValueInfoPreDetail);
        return getDataTable(list);
    }


    /**
     * 导出高价值数据导入详情列表
     *
     * @param dHighValueInfoPreDetail 高价值数据导入详情
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dHighValueInfoPreDetail:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DHighValueInfoPreDetail dHighValueInfoPreDetail) {
        List<DHighValueInfoPreDetail> list = dHighValueInfoPreDetailService.list(new QueryWrapper<>());
        ExcelUtil<DHighValueInfoPreDetail> util = new ExcelUtil<>(DHighValueInfoPreDetail. class);
        util.exportExcel(response, list, "高价值数据导入详情数据");
    }

    /**
     * 获取高价值数据导入详情详细信息
     *
     * @param id 主键id
     * @return 结果
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dHighValueInfoPreDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(dHighValueInfoPreDetailService.getById(id));
    }


    /**
     * 新增高价值数据导入详情信息
     *
     * @param dHighValueInfoPreDetail 高价值数据导入详情
     * @return 结果
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dHighValueInfoPreDetail:add')")
    @Log(title = "高价值数据导入详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DHighValueInfoPreDetail dHighValueInfoPreDetail) {
        return toAjax(dHighValueInfoPreDetailService.save(dHighValueInfoPreDetail));
    }


    /**
     * 修改高价值数据导入详情信息
     *
     * @param dHighValueInfoPreDetail 高价值数据导入详情
     * @return 结果
     * @date 2023-03-19
     */
    @PreAuthorize("@ss.hasPermi('dimp:dHighValueInfoPreDetail:edit')")
    @Log(title = "高价值数据导入详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DHighValueInfoPreDetail dHighValueInfoPreDetail) {
        return toAjax(dHighValueInfoPreDetailService.updateById(dHighValueInfoPreDetail));
    }


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


}
