package com.ruoyi.mall.controller;

import java.util.List;
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.mall.domain.MallCombineOrderLink;
import com.ruoyi.mall.service.IMallCombineOrderLinkService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 拼团订单关联Controller
 *
 * @author ruoyi
 * @date 2024-03-21
 */
@RestController
@RequestMapping("/mall/mallCombineOrderLink")
public class MallCombineOrderLinkController extends BaseController
{
    @Resource
    private IMallCombineOrderLinkService mallCombineOrderLinkService;

    /**
     * 查询拼团订单关联列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCombineOrderLink:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallCombineOrderLink mallCombineOrderLink)
    {
        startPage();
        List<MallCombineOrderLink> list = mallCombineOrderLinkService.selectMallCombineOrderLinkList(mallCombineOrderLink);
        return getDataTable(list);
    }

    /**
     * 导出拼团订单关联列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCombineOrderLink:export')")
    @Log(title = "拼团订单关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallCombineOrderLink mallCombineOrderLink)
    {
        List<MallCombineOrderLink> list = mallCombineOrderLinkService.selectMallCombineOrderLinkList(mallCombineOrderLink);
        ExcelUtil<MallCombineOrderLink> util = new ExcelUtil<MallCombineOrderLink>(MallCombineOrderLink.class);
        return util.exportExcel(list, "拼团订单关联数据");
    }

    /**
     * 获取拼团订单关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCombineOrderLink:query')")
    @GetMapping(value = "/{linkId}")
    public AjaxResult getInfo(@PathVariable("linkId") Long linkId)
    {
        return AjaxResult.success(mallCombineOrderLinkService.selectMallCombineOrderLinkByLinkId(linkId));
    }

    /**
     * 新增拼团订单关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCombineOrderLink:add')")
    @Log(title = "拼团订单关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallCombineOrderLink mallCombineOrderLink)
    {
        return toAjax(mallCombineOrderLinkService.insertMallCombineOrderLink(mallCombineOrderLink));
    }

    /**
     * 修改拼团订单关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCombineOrderLink:edit')")
    @Log(title = "拼团订单关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallCombineOrderLink mallCombineOrderLink)
    {
        return toAjax(mallCombineOrderLinkService.updateMallCombineOrderLink(mallCombineOrderLink));
    }

    /**
     * 删除拼团订单关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallCombineOrderLink:remove')")
    @Log(title = "拼团订单关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{linkIds}")
    public AjaxResult remove(@PathVariable Long[] linkIds)
    {
        return toAjax(mallCombineOrderLinkService.deleteMallCombineOrderLinkByLinkIds(linkIds));
    }
}
