package com.ruoyi.frequency.mallspecifications.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.frequency.mallspecifications.entity.MallSpecifications;
import com.ruoyi.frequency.mallspecifications.service.MallSpecificationsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 单规格规格Controller
 *
 * @author liwenlong
 * @date 2024-01-25
 */
@RestController
@RequestMapping("/frequency/mallspecifications")
public class MallSpecificationsController extends BaseController
{
    @Autowired
    private MallSpecificationsService mallSpecificationsService;

    /**
     * 查询单规格规格列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:list')")
    @PostMapping("/list")
    public TableDataInfo<MallSpecifications> list(@RequestBody MallSpecifications mallSpecifications)
    {
        startPage();
        List<MallSpecifications> list = mallSpecificationsService.selectMallSpecificationsList(mallSpecifications);
        return getDataTable(list);
    }

    /**
     * 导出单规格规格列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:export')")
    @Log(title = "单规格规格", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallSpecifications mallSpecifications)
    {
        List<MallSpecifications> list = mallSpecificationsService.selectMallSpecificationsList(mallSpecifications);
        ExcelUtil<MallSpecifications> util = new ExcelUtil<MallSpecifications>(MallSpecifications.class);
        return util.exportExcel(list, "单规格规格数据");
    }

    /**
     * 获取单规格规格详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<MallSpecifications> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallSpecificationsService.selectMallSpecificationsById(id));
    }

    /**
     * 新增单规格规格
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:add')")
    @Log(title = "单规格规格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallSpecifications mallSpecifications)
    {
        return toAjax(mallSpecificationsService.insertMallSpecifications(mallSpecifications));
    }

    /**
     * 修改单规格规格
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:edit')")
    @Log(title = "单规格规格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallSpecifications mallSpecifications)
    {
        return toAjax(mallSpecificationsService.updateMallSpecifications(mallSpecifications));
    }

    /**
     * 删除单规格规格
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallspecifications:remove')")
    @Log(title = "单规格规格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
    {
        return toAjax(mallSpecificationsService.deleteMallSpecificationsByIds(ids,delFlag));
    }
}
