package com.fs.store.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.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.FsStoreCouponIssueUser;
import com.fs.store.service.IFsStoreCouponIssueUserService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 优惠券用户领取记录Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/storeCouponIssueUser")
public class FsStoreCouponIssueUserController extends BaseController
{
    @Autowired
    private IFsStoreCouponIssueUserService fsStoreCouponIssueUserService;

    /**
     * 查询优惠券用户领取记录列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeCouponIssueUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsStoreCouponIssueUser fsStoreCouponIssueUser)
    {
        startPage();
        List<FsStoreCouponIssueUser> list = fsStoreCouponIssueUserService.selectFsStoreCouponIssueUserList(fsStoreCouponIssueUser);
        return getDataTable(list);
    }

    /**
     * 导出优惠券用户领取记录列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeCouponIssueUser:export')")
    @Log(title = "优惠券用户领取记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreCouponIssueUser fsStoreCouponIssueUser)
    {
        List<FsStoreCouponIssueUser> list = fsStoreCouponIssueUserService.selectFsStoreCouponIssueUserList(fsStoreCouponIssueUser);
        ExcelUtil<FsStoreCouponIssueUser> util = new ExcelUtil<FsStoreCouponIssueUser>(FsStoreCouponIssueUser.class);
        return util.exportExcel(list, "storeCouponIssueUser");
    }

    /**
     * 获取优惠券用户领取记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:storeCouponIssueUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsStoreCouponIssueUserService.selectFsStoreCouponIssueUserById(id));
    }

    /**
     * 新增优惠券用户领取记录
     */
    @PreAuthorize("@ss.hasPermi('store:storeCouponIssueUser:add')")
    @Log(title = "优惠券用户领取记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsStoreCouponIssueUser fsStoreCouponIssueUser)
    {
        return toAjax(fsStoreCouponIssueUserService.insertFsStoreCouponIssueUser(fsStoreCouponIssueUser));
    }

    /**
     * 修改优惠券用户领取记录
     */
    @PreAuthorize("@ss.hasPermi('store:storeCouponIssueUser:edit')")
    @Log(title = "优惠券用户领取记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreCouponIssueUser fsStoreCouponIssueUser)
    {
        return toAjax(fsStoreCouponIssueUserService.updateFsStoreCouponIssueUser(fsStoreCouponIssueUser));
    }

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