package com.ruoyi.web.controller.doumu;

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

import com.ruoyi.system.domain.vo.DoumuProductInfoVo;
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.DoumuProductInfo;
import com.ruoyi.system.service.IDoumuProductInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 痘姆古陶信息Controller
 *
 * @author boman
 * @date 2024-01-16
 */
@RestController
@RequestMapping("/system/info")
public class DoumuProductInfoController extends BaseController
{
    @Autowired
    private IDoumuProductInfoService doumuProductInfoService;

    /**
     * 查询痘姆古陶信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoumuProductInfo doumuProductInfo)
    {
        startPage();
        List<DoumuProductInfo> list = doumuProductInfoService.selectDoumuProductInfoList(doumuProductInfo);
        return getDataTable(list);
    }

    /**
     * 导出痘姆古陶信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "痘姆古陶信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DoumuProductInfo doumuProductInfo)
    {
        List<DoumuProductInfo> list = doumuProductInfoService.selectDoumuProductInfoList(doumuProductInfo);
        ExcelUtil<DoumuProductInfo> util = new ExcelUtil<DoumuProductInfo>(DoumuProductInfo.class);
        util.exportExcel(response, list, "痘姆古陶信息数据");
    }

    /**
     * 获取痘姆古陶信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{productId}")
    public AjaxResult getInfo(@PathVariable("productId") Long productId)
    {
        return success(doumuProductInfoService.selectDoumuProductInfoByProductId(productId));
    }

    /**
     * 新增痘姆古陶信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "痘姆古陶信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoumuProductInfo doumuProductInfo)
    {
        return toAjax(doumuProductInfoService.insertDoumuProductInfo(doumuProductInfo));
    }

    /**
     * 修改痘姆古陶信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "痘姆古陶信息", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody DoumuProductInfo doumuProductInfo)
    {
        return toAjax(doumuProductInfoService.updateDoumuProductInfo(doumuProductInfo));
    }

    /**
     * 修改痘姆古陶流程
     */
    @PreAuthorize("@ss.hasPermi('system:info:flow')")
    @Log(title = "痘姆古陶流程", businessType = BusinessType.UPDATE)
    @PostMapping("/put/flow")
    public AjaxResult editFlow(@RequestBody DoumuProductInfoVo doumuProductInfoVo)
    {
        return toAjax(doumuProductInfoService.editFlow(doumuProductInfoVo));
    }

    /**
     * 删除痘姆古陶信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "痘姆古陶信息", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{productIds}")
    public AjaxResult remove(@PathVariable Long[] productIds)
    {
        return toAjax(doumuProductInfoService.deleteDoumuProductInfoByProductIds(productIds));
    }
}
