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

/**
 * 用户注册Controller
 *
 * @author ruoyi
 * @date 2022-06-28
 */
@RestController
@RequestMapping("/mall/mallMemberRegister")
public class MallMemberRegisterController extends BaseController
{
    @Autowired
    private IMallMemberRegisterService mallMemberRegisterService;

    /**
     * 查询用户注册列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberRegister:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallMemberRegister mallMemberRegister)
    {
        startPage();
        List<MallMemberRegister> list = mallMemberRegisterService.selectMallMemberRegisterList(mallMemberRegister);
        return getDataTable(list);
    }

    /**
     * 导出用户注册列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberRegister:export')")
    @Log(title = "用户注册", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallMemberRegister mallMemberRegister)
    {
        List<MallMemberRegister> list = mallMemberRegisterService.selectMallMemberRegisterList(mallMemberRegister);
        ExcelUtil<MallMemberRegister> util = new ExcelUtil<MallMemberRegister>(MallMemberRegister.class);
        return util.exportExcel(list, "用户注册数据");
    }

    /**
     * 获取用户注册详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberRegister:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(mallMemberRegisterService.selectMallMemberRegisterById(id));
    }

    /**
     * 新增用户注册
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberRegister:add')")
    @Log(title = "用户注册", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallMemberRegister mallMemberRegister)
    {
        return toAjax(mallMemberRegisterService.insertMallMemberRegister(mallMemberRegister));
    }

    /**
     * 修改用户注册
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberRegister:edit')")
    @Log(title = "用户注册", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallMemberRegister mallMemberRegister)
    {
        return toAjax(mallMemberRegisterService.updateMallMemberRegister(mallMemberRegister));
    }

    /**
     * 审核
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberRegister:edit')")
    @Log(title = "审核用户注册", businessType = BusinessType.UPDATE)
    @PostMapping("/examine")
    public AjaxResult examine(@RequestBody MallMemberRegister mallMemberRegister)
    {
        return mallMemberRegisterService.examine(mallMemberRegister);
    }

    /**
     * 删除用户注册
     */
    @PreAuthorize("@ss.hasPermi('mall:mallMemberRegister:remove')")
    @Log(title = "用户注册", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(mallMemberRegisterService.deleteMallMemberRegisterByIds(ids));
    }
}
