package com.ruoyi.mall.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.MallMemberBanner;
import com.ruoyi.mall.service.IMallMemberBannerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户轮播图Controller
 *
 * @author ruoyi
 * @date 2024-11-15
 */
@RestController
@RequestMapping("/mall/mallMemberBanner")
public class MallMemberBannerController extends BaseController
{
    @Autowired
    private IMallMemberBannerService mallMemberBannerService;

    /**
     * 查询用户轮播图列表
     */
    // @PreAuthorize("@ss.hasPermi('mall:mallMemberBanner:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallMemberBanner mallMemberBanner)
    {
        startPage();
        List<MallMemberBanner> list = mallMemberBannerService.selectMallMemberBannerList(mallMemberBanner);
        return getDataTable(list);
    }

    /**
     * 导出用户轮播图列表
     */
    // @PreAuthorize("@ss.hasPermi('mall:mallMemberBanner:export')")
    @Log(title = "用户轮播图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallMemberBanner mallMemberBanner)
    {
        List<MallMemberBanner> list = mallMemberBannerService.selectMallMemberBannerList(mallMemberBanner);
        ExcelUtil<MallMemberBanner> util = new ExcelUtil<MallMemberBanner>(MallMemberBanner.class);
        util.exportExcel(response, list, "用户轮播图数据");
    }

    /**
     * 获取用户轮播图详细信息
     */
    // @PreAuthorize("@ss.hasPermi('mall:mallMemberBanner:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallMemberBannerService.selectMallMemberBannerById(id));
    }

    /**
     * 新增用户轮播图
     */
    // @PreAuthorize("@ss.hasPermi('mall:mallMemberBanner:add')")
    @Log(title = "用户轮播图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallMemberBanner mallMemberBanner)
    {
        return toAjax(mallMemberBannerService.insertMallMemberBanner(mallMemberBanner));
    }

    /**
     * 修改用户轮播图
     */
    // @PreAuthorize("@ss.hasPermi('mall:mallMemberBanner:edit')")
    @Log(title = "用户轮播图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallMemberBanner mallMemberBanner)
    {
        return toAjax(mallMemberBannerService.updateMallMemberBanner(mallMemberBanner));
    }

    /**
     * 删除用户轮播图
     */
    // @PreAuthorize("@ss.hasPermi('mall:mallMemberBanner:remove')")
    @Log(title = "用户轮播图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallMemberBannerService.deleteMallMemberBannerByIds(ids));
    }
}
