package com.fs.company.controller.qw;


import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.qw.domain.QwGroupMsgItem;
import com.fs.qw.service.IQwGroupMsgItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 客户群发消息的附件记录Controller
 *
 * @author fs
 * @date 2024-06-28
 */
@RestController
@RequestMapping("/shop/item")
public class QwGroupMsgItemController extends BaseController
{
    @Autowired
    private IQwGroupMsgItemService qwGroupMsgItemService;

    /**
     * 查询客户群发消息的附件记录列表
     */
    @PreAuthorize("@ss.hasPermi('shop:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwGroupMsgItem qwGroupMsgItem)
    {
        startPage();
        List<QwGroupMsgItem> list = qwGroupMsgItemService.selectQwGroupMsgItemList(qwGroupMsgItem);
        return getDataTable(list);
    }

    /**
     * 导出客户群发消息的附件记录列表
     */
    @PreAuthorize("@ss.hasPermi('shop:item:export')")
    @Log(title = "客户群发消息的附件记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwGroupMsgItem qwGroupMsgItem)
    {
        List<QwGroupMsgItem> list = qwGroupMsgItemService.selectQwGroupMsgItemList(qwGroupMsgItem);
        ExcelUtil<QwGroupMsgItem> util = new ExcelUtil<QwGroupMsgItem>(QwGroupMsgItem.class);
        return util.exportExcel(list, "客户群发消息的附件记录数据");
    }

    /**
     * 获取客户群发消息的附件记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:item:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qwGroupMsgItemService.selectQwGroupMsgItemById(id));
    }

    /**
     * 新增客户群发消息的附件记录
     */
    @PreAuthorize("@ss.hasPermi('shop:item:add')")
    @Log(title = "客户群发消息的附件记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwGroupMsgItem qwGroupMsgItem)
    {
        return toAjax(qwGroupMsgItemService.insertQwGroupMsgItem(qwGroupMsgItem));
    }

    /**
     * 修改客户群发消息的附件记录
     */
    @PreAuthorize("@ss.hasPermi('shop:item:edit')")
    @Log(title = "客户群发消息的附件记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwGroupMsgItem qwGroupMsgItem)
    {
        return toAjax(qwGroupMsgItemService.updateQwGroupMsgItem(qwGroupMsgItem));
    }

    /**
     * 删除客户群发消息的附件记录
     */
    @PreAuthorize("@ss.hasPermi('shop:item:remove')")
    @Log(title = "客户群发消息的附件记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qwGroupMsgItemService.deleteQwGroupMsgItemByIds(ids));
    }
}
