package com.fs.store.controller;

import java.util.List;

import com.fs.store.vo.FsStoreCouponIssueVO;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.store.domain.FsStoreCouponIssue;
import com.fs.store.service.IFsStoreCouponIssueService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 优惠券领取Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/storeCouponIssue")
public class FsStoreCouponIssueController extends BaseController
{
    @Autowired
    private IFsStoreCouponIssueService fsStoreCouponIssueService;

    /**
     * 查询优惠券领取列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeCouponIssue:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsStoreCouponIssue fsStoreCouponIssue)
    {
        startPage();
        List<FsStoreCouponIssueVO> list = fsStoreCouponIssueService.selectFsStoreCouponIssueListVO(fsStoreCouponIssue);
        return getDataTable(list);
    }

    /**
     * 导出优惠券领取列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeCouponIssue:export')")
    @Log(title = "优惠券领取", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreCouponIssue fsStoreCouponIssue)
    {
        List<FsStoreCouponIssue> list = fsStoreCouponIssueService.selectFsStoreCouponIssueList(fsStoreCouponIssue);
        ExcelUtil<FsStoreCouponIssue> util = new ExcelUtil<FsStoreCouponIssue>(FsStoreCouponIssue.class);
        return util.exportExcel(list, "storeCouponIssue");
    }

    /**
     * 获取优惠券领取详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:storeCouponIssue:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsStoreCouponIssueService.selectFsStoreCouponIssueById(id));
    }

    /**
     * 新增优惠券领取
     */
    @PreAuthorize("@ss.hasPermi('store:storeCouponIssue:add')")
    @Log(title = "优惠券领取", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsStoreCouponIssue fsStoreCouponIssue)
    {
        return toAjax(fsStoreCouponIssueService.insertFsStoreCouponIssue(fsStoreCouponIssue));
    }

    /**
     * 修改优惠券领取
     */
    @PreAuthorize("@ss.hasPermi('store:storeCouponIssue:edit')")
    @Log(title = "优惠券领取", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreCouponIssue fsStoreCouponIssue)
    {
        return toAjax(fsStoreCouponIssueService.updateFsStoreCouponIssue(fsStoreCouponIssue));
    }

    /**
     * 删除优惠券领取
     */
    @PreAuthorize("@ss.hasPermi('store:storeCouponIssue:remove')")
    @Log(title = "优惠券领取", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsStoreCouponIssueService.deleteFsStoreCouponIssueByIds(ids));
    }
}
