package com.fs.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.QwFriendWelcomeItem;
import com.fs.qw.service.IQwFriendWelcomeItemService;
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-07-20
 */
@RestController
@RequestMapping("/qw/friendWelcomeItem")
public class QwFriendWelcomeItemController extends BaseController
{
    @Autowired
    private IQwFriendWelcomeItemService qwFriendWelcomeItemService;

    /**
     * 查询好友欢迎语的附件列表
     */
    @PreAuthorize("@ss.hasPermi('qw:friendWelcomeItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwFriendWelcomeItem qwFriendWelcomeItem)
    {
        startPage();
        List<QwFriendWelcomeItem> list = qwFriendWelcomeItemService.selectQwFriendWelcomeItemList(qwFriendWelcomeItem);
        return getDataTable(list);
    }

    /**
     * 导出好友欢迎语的附件列表
     */
    @PreAuthorize("@ss.hasPermi('qw:friendWelcomeItem:export')")
    @Log(title = "好友欢迎语的附件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwFriendWelcomeItem qwFriendWelcomeItem)
    {
        List<QwFriendWelcomeItem> list = qwFriendWelcomeItemService.selectQwFriendWelcomeItemList(qwFriendWelcomeItem);
        ExcelUtil<QwFriendWelcomeItem> util = new ExcelUtil<QwFriendWelcomeItem>(QwFriendWelcomeItem.class);
        return util.exportExcel(list, "好友欢迎语的附件数据");
    }

    /**
     * 获取好友欢迎语的附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:friendWelcomeItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qwFriendWelcomeItemService.selectQwFriendWelcomeItemById(id));
    }

    /**
     * 新增好友欢迎语的附件
     */
    @PreAuthorize("@ss.hasPermi('qw:friendWelcomeItem:add')")
    @Log(title = "好友欢迎语的附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwFriendWelcomeItem qwFriendWelcomeItem)
    {
        return toAjax(qwFriendWelcomeItemService.insertQwFriendWelcomeItem(qwFriendWelcomeItem));
    }

    /**
     * 修改好友欢迎语的附件
     */
    @PreAuthorize("@ss.hasPermi('qw:friendWelcomeItem:edit')")
    @Log(title = "好友欢迎语的附件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwFriendWelcomeItem qwFriendWelcomeItem)
    {
        return toAjax(qwFriendWelcomeItemService.updateQwFriendWelcomeItem(qwFriendWelcomeItem));
    }

    /**
     * 删除好友欢迎语的附件
     */
    @PreAuthorize("@ss.hasPermi('qw:friendWelcomeItem:remove')")
    @Log(title = "好友欢迎语的附件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qwFriendWelcomeItemService.deleteQwFriendWelcomeItemByIds(ids));
    }
}
