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.MallMemberCms;
import com.ruoyi.mall.service.IMallMemberCmsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 手机验证码Controller
 * 
 * @author ruoyi
 * @date 2022-06-28
 */
@RestController
@RequestMapping("/mall/mallMemberCms")
public class MallMemberCmsController extends BaseController
{
    @Autowired
    private IMallMemberCmsService mallMemberCmsService;

    /**
     * 查询手机验证码列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberCms:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallMemberCms mallMemberCms)
    {
        startPage();
        List<MallMemberCms> list = mallMemberCmsService.selectMallMemberCmsList(mallMemberCms);
        return getDataTable(list);
    }

    /**
     * 导出手机验证码列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberCms:export')")
    @Log(title = "手机验证码", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallMemberCms mallMemberCms)
    {
        List<MallMemberCms> list = mallMemberCmsService.selectMallMemberCmsList(mallMemberCms);
        ExcelUtil<MallMemberCms> util = new ExcelUtil<MallMemberCms>(MallMemberCms.class);
        return util.exportExcel(list, "手机验证码数据");
    }

    /**
     * 获取手机验证码详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberCms:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallMemberCmsService.selectMallMemberCmsById(id));
    }

    /**
     * 新增手机验证码
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberCms:add')")
    @Log(title = "手机验证码", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallMemberCms mallMemberCms)
    {
        return toAjax(mallMemberCmsService.insertMallMemberCms(mallMemberCms));
    }

    /**
     * 修改手机验证码
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberCms:edit')")
    @Log(title = "手机验证码", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallMemberCms mallMemberCms)
    {
        return toAjax(mallMemberCmsService.updateMallMemberCms(mallMemberCms));
    }

    /**
     * 删除手机验证码
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberCms:remove')")
    @Log(title = "手机验证码", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallMemberCmsService.deleteMallMemberCmsByIds(ids));
    }
}
