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

/**
 * mallController
 * 
 * @author ruoyi
 * @date 2021-12-23
 */
@RestController
@RequestMapping("/mall/history")
public class MallMemberSearchHistoryController extends BaseController
{
    @Autowired
    private IMallMemberSearchHistoryService mallMemberSearchHistoryService;

    /**
     * 查询mall列表
     */
    @PreAuthorize("@ss.hasPermi('mall:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallMemberSearchHistory mallMemberSearchHistory)
    {
        startPage();
        List<MallMemberSearchHistory> list = mallMemberSearchHistoryService.selectMallMemberSearchHistoryList(mallMemberSearchHistory);
        return getDataTable(list);
    }

    /**
     * 导出mall列表
     */
    @PreAuthorize("@ss.hasPermi('mall:history:export')")
    @Log(title = "mall", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallMemberSearchHistory mallMemberSearchHistory)
    {
        List<MallMemberSearchHistory> list = mallMemberSearchHistoryService.selectMallMemberSearchHistoryList(mallMemberSearchHistory);
        ExcelUtil<MallMemberSearchHistory> util = new ExcelUtil<MallMemberSearchHistory>(MallMemberSearchHistory.class);
        return util.exportExcel(list, "mall数据");
    }

    /**
     * 获取mall详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:history:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallMemberSearchHistoryService.selectMallMemberSearchHistoryById(id));
    }

    /**
     * 新增mall
     */
    @PreAuthorize("@ss.hasPermi('mall:history:add')")
    @Log(title = "mall", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallMemberSearchHistory mallMemberSearchHistory)
    {
        return toAjax(mallMemberSearchHistoryService.insertMallMemberSearchHistory(mallMemberSearchHistory));
    }

    /**
     * 修改mall
     */
    @PreAuthorize("@ss.hasPermi('mall:history:edit')")
    @Log(title = "mall", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallMemberSearchHistory mallMemberSearchHistory)
    {
        return toAjax(mallMemberSearchHistoryService.updateMallMemberSearchHistory(mallMemberSearchHistory));
    }

    /**
     * 删除mall
     */
    @PreAuthorize("@ss.hasPermi('mall:history:remove')")
    @Log(title = "mall", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallMemberSearchHistoryService.deleteMallMemberSearchHistoryByIds(ids));
    }
}
