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

/**
 * 用户等级记录Controller
 * 
 * @author fs
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/store/userLevel")
public class FsUserLevelController extends BaseController
{
    @Autowired
    private IFsUserLevelService fsUserLevelService;

    /**
     * 查询用户等级记录列表
     */
    @PreAuthorize("@ss.hasPermi('store:userLevel:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUserLevel fsUserLevel)
    {
        startPage();
        List<FsUserLevel> list = fsUserLevelService.selectFsUserLevelList(fsUserLevel);
        return getDataTable(list);
    }

    /**
     * 导出用户等级记录列表
     */
    @PreAuthorize("@ss.hasPermi('store:userLevel:export')")
    @Log(title = "用户等级记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserLevel fsUserLevel)
    {
        List<FsUserLevel> list = fsUserLevelService.selectFsUserLevelList(fsUserLevel);
        ExcelUtil<FsUserLevel> util = new ExcelUtil<FsUserLevel>(FsUserLevel.class);
        return util.exportExcel(list, "userLevel");
    }

    /**
     * 获取用户等级记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:userLevel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsUserLevelService.selectFsUserLevelById(id));
    }

    /**
     * 新增用户等级记录
     */
    @PreAuthorize("@ss.hasPermi('store:userLevel:add')")
    @Log(title = "用户等级记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserLevel fsUserLevel)
    {
        return toAjax(fsUserLevelService.insertFsUserLevel(fsUserLevel));
    }

    /**
     * 修改用户等级记录
     */
    @PreAuthorize("@ss.hasPermi('store:userLevel:edit')")
    @Log(title = "用户等级记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserLevel fsUserLevel)
    {
        return toAjax(fsUserLevelService.updateFsUserLevel(fsUserLevel));
    }

    /**
     * 删除用户等级记录
     */
    @PreAuthorize("@ss.hasPermi('store:userLevel:remove')")
    @Log(title = "用户等级记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsUserLevelService.deleteFsUserLevelByIds(ids));
    }
}
