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

/**
 * 签到记录Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/userSign")
public class FsUserSignController extends BaseController
{
    @Autowired
    private IFsUserSignService fsUserSignService;

    /**
     * 查询签到记录列表
     */
    @PreAuthorize("@ss.hasPermi('store:userSign:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUserSign fsUserSign)
    {
        startPage();
        List<FsUserSign> list = fsUserSignService.selectFsUserSignList(fsUserSign);
        return getDataTable(list);
    }

    /**
     * 导出签到记录列表
     */
    @PreAuthorize("@ss.hasPermi('store:userSign:export')")
    @Log(title = "签到记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserSign fsUserSign)
    {
        List<FsUserSign> list = fsUserSignService.selectFsUserSignList(fsUserSign);
        ExcelUtil<FsUserSign> util = new ExcelUtil<FsUserSign>(FsUserSign.class);
        return util.exportExcel(list, "userSign");
    }

    /**
     * 获取签到记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:userSign:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsUserSignService.selectFsUserSignById(id));
    }

    /**
     * 新增签到记录
     */
    @PreAuthorize("@ss.hasPermi('store:userSign:add')")
    @Log(title = "签到记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserSign fsUserSign)
    {
        return toAjax(fsUserSignService.insertFsUserSign(fsUserSign));
    }

    /**
     * 修改签到记录
     */
    @PreAuthorize("@ss.hasPermi('store:userSign:edit')")
    @Log(title = "签到记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserSign fsUserSign)
    {
        return toAjax(fsUserSignService.updateFsUserSign(fsUserSign));
    }

    /**
     * 删除签到记录
     */
    @PreAuthorize("@ss.hasPermi('store:userSign:remove')")
    @Log(title = "签到记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsUserSignService.deleteFsUserSignByIds(ids));
    }
}
