package com.ruoyi.mall.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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallSeckillTime;
import com.ruoyi.mall.service.IMallSeckillTimeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 秒杀时间Controller
 *
 * @author ruoyi
 * @date 2022-07-01
 */
@RestController
@RequestMapping("/mall/mallSeckillTime")
public class MallSeckillTimeController extends BaseController
{
    @Autowired
    private IMallSeckillTimeService mallSeckillTimeService;

    /**
     * 查询秒杀时间列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSeckillTime:list')")
    @GetMapping("/seckillTimeSelectList")
    public AjaxResult seckillTimeSelectList()
    {
        return AjaxResult.success(mallSeckillTimeService.seckillTimeSelectList());
    }

    /**
     * 查询秒杀时间列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSeckillTime:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallSeckillTime mallSeckillTime)
    {
        startPage();
        List<MallSeckillTime> list = mallSeckillTimeService.selectMallSeckillTimeList(mallSeckillTime);
        return getDataTable(list);
    }

    /**
     * 导出秒杀时间列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSeckillTime:export')")
    @Log(title = "秒杀时间", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallSeckillTime mallSeckillTime)
    {
        List<MallSeckillTime> list = mallSeckillTimeService.selectMallSeckillTimeList(mallSeckillTime);
        ExcelUtil<MallSeckillTime> util = new ExcelUtil<MallSeckillTime>(MallSeckillTime.class);
        return util.exportExcel(list, "秒杀时间数据");
    }

    /**
     * 获取秒杀时间详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSeckillTime:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(mallSeckillTimeService.selectMallSeckillTimeById(id));
    }

    /**
     * 新增秒杀时间
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSeckillTime:add')")
    @Log(title = "秒杀时间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallSeckillTime mallSeckillTime)
    {
        return toAjax(mallSeckillTimeService.insertMallSeckillTime(mallSeckillTime));
    }

    /**
     * 修改秒杀时间
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSeckillTime:edit')")
    @Log(title = "秒杀时间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallSeckillTime mallSeckillTime)
    {
        return toAjax(mallSeckillTimeService.updateMallSeckillTime(mallSeckillTime));
    }

    /**
     * 删除秒杀时间
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSeckillTime:remove')")
    @Log(title = "秒杀时间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(mallSeckillTimeService.deleteMallSeckillTimeByIds(ids));
    }
}
