package com.ruoyi.adjust.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.adjust.domain.DHighValuePub;
import com.ruoyi.adjust.service.IDHighValuePubService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 高价值对照关联Controller
 *
 * @author ruoyi
 * @date 2023-04-20
 */
@RestController
@RequestMapping("/adjust/dHighValuePub")
public class DHighValuePubController extends BaseController {
    private final IDHighValuePubService dHighValuePubService;

    public DHighValuePubController(IDHighValuePubService dHighValuePubService) {
        this.dHighValuePubService = dHighValuePubService;
    }


    /**
     * 查询高价值对照关联列表
     *
     * @param dHighValuePub 高价值对照关联
     * @return 高价值对照关联集合
     * @date 2023-04-20
     */
    @PreAuthorize("@ss.hasPermi('adjust:dHighValuePub:list')")
    @GetMapping("/list")
    public TableDataInfo list(DHighValuePub dHighValuePub) {
        startPage();
        List<DHighValuePub> list = dHighValuePubService.queryList(dHighValuePub);
        return getDataTable(list);
    }


    /**
     * 导出高价值对照关联列表
     *
     * @param dHighValuePub 高价值对照关联
     * @date 2023-04-20
     */
    @PreAuthorize("@ss.hasPermi('adjust:dHighValuePub:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DHighValuePub dHighValuePub) {
        List<DHighValuePub> list = dHighValuePubService.list(new QueryWrapper<>());
        ExcelUtil<DHighValuePub> util = new ExcelUtil<>(DHighValuePub. class);
        util.exportExcel(response, list, "高价值对照关联数据");
    }

    /**
     * 获取高价值对照关联详细信息
     *
     * @param id 主键id
     * @return 结果
     * @date 2023-04-20
     */
    @PreAuthorize("@ss.hasPermi('adjust:dHighValuePub:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(dHighValuePubService.getById(id));
    }


    /**
     * 新增高价值对照关联信息
     *
     * @param dHighValuePub 高价值对照关联
     * @return 结果
     * @date 2023-04-20
     */
    @PreAuthorize("@ss.hasPermi('adjust:dHighValuePub:add')")
    @Log(title = "高价值对照关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DHighValuePub dHighValuePub) {
        return toAjax(dHighValuePubService.save(dHighValuePub));
    }


    /**
     * 修改高价值对照关联信息
     *
     * @param dHighValuePub 高价值对照关联
     * @return 结果
     * @date 2023-04-20
     */
    @PreAuthorize("@ss.hasPermi('adjust:dHighValuePub:edit')")
    @Log(title = "高价值对照关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DHighValuePub dHighValuePub) {
        return toAjax(dHighValuePubService.updateById(dHighValuePub));
    }


    /**
     * 删除高价值对照关联信息
     *
     * @param ids 主键ids
     * @return 结果
     * @date 2023-04-20
     */
    @PreAuthorize("@ss.hasPermi('adjust:dHighValuePub:remove')")
    @Log(title = "高价值对照关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(dHighValuePubService.removeByIds(Arrays.asList(ids)));
    }


}
