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

/**
 * mallController
 * 
 * @author ruoyi
 * @date 2021-12-31
 */
@RestController
@RequestMapping("/mall/tips")
public class MallGoodsTipsController extends BaseController
{
    @Autowired
    private IMallGoodsTipsService mallGoodsTipsService;

    /**
     * 查询mall列表
     */
    @PreAuthorize("@ss.hasPermi('mall:tips:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallGoodsTips mallGoodsTips)
    {
        startPage();
        List<MallGoodsTips> list = mallGoodsTipsService.selectMallGoodsTipsList(mallGoodsTips);
        return getDataTable(list);
    }

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

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

    /**
     * 新增mall
     */
    @PreAuthorize("@ss.hasPermi('mall:tips:add')")
    @Log(title = "mall", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallGoodsTips mallGoodsTips)
    {
        return toAjax(mallGoodsTipsService.insertMallGoodsTips(mallGoodsTips));
    }

    /**
     * 修改mall
     */
    @PreAuthorize("@ss.hasPermi('mall:tips:edit')")
    @Log(title = "mall", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallGoodsTips mallGoodsTips)
    {
        return toAjax(mallGoodsTipsService.updateMallGoodsTips(mallGoodsTips));
    }

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