package com.ruoyi.web.controller.doumu;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
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 com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DoumuProductHistory;
import com.ruoyi.system.service.IDoumuProductHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 痘姆古陶主历史信息Controller
 * 
 * @author boman
 * @date 2024-01-16
 */
@RestController
@RequestMapping("/system/history")
public class DoumuProductHistoryController extends BaseController
{
    @Autowired
    private IDoumuProductHistoryService doumuProductHistoryService;

    /**
     * 查询痘姆古陶主历史信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoumuProductHistory doumuProductHistory)
    {
        startPage();
        List<DoumuProductHistory> list = doumuProductHistoryService.selectDoumuProductHistoryList(doumuProductHistory);
        return getDataTable(list);
    }

    /**
     * 导出痘姆古陶主历史信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:export')")
    @Log(title = "痘姆古陶主历史信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DoumuProductHistory doumuProductHistory)
    {
        List<DoumuProductHistory> list = doumuProductHistoryService.selectDoumuProductHistoryList(doumuProductHistory);
        ExcelUtil<DoumuProductHistory> util = new ExcelUtil<DoumuProductHistory>(DoumuProductHistory.class);
        util.exportExcel(response, list, "痘姆古陶主历史信息数据");
    }

    /**
     * 获取痘姆古陶主历史信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:query')")
    @GetMapping(value = "/{historyId}")
    public AjaxResult getInfo(@PathVariable("historyId") Long historyId)
    {
        return success(doumuProductHistoryService.selectDoumuProductHistoryByHistoryId(historyId));
    }

    /**
     * 新增痘姆古陶主历史信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:add')")
    @Log(title = "痘姆古陶主历史信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoumuProductHistory doumuProductHistory)
    {
        return toAjax(doumuProductHistoryService.insertDoumuProductHistory(doumuProductHistory));
    }

    /**
     * 修改痘姆古陶主历史信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:edit')")
    @Log(title = "痘姆古陶主历史信息", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody DoumuProductHistory doumuProductHistory)
    {
        return toAjax(doumuProductHistoryService.updateDoumuProductHistory(doumuProductHistory));
    }

    /**
     * 删除痘姆古陶主历史信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:remove')")
    @Log(title = "痘姆古陶主历史信息", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{historyIds}")
    public AjaxResult remove(@PathVariable Long[] historyIds)
    {
        return toAjax(doumuProductHistoryService.deleteDoumuProductHistoryByHistoryIds(historyIds));
    }
}
