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

/**
 * 平台规则类型Controller
 *
 * @author liwenlong
 * @date 2024-02-23
 */
@RestController
@RequestMapping("/frequency/platformrulestype")
public class PlatformRulesTypeController extends BaseController
{
    @Autowired
    private PlatformRulesTypeService platformRulesTypeService;

    /**
     * 查询平台规则类型列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:list')")
    @PostMapping("/list")
    public TableDataInfo<PlatformRulesType> list(@RequestBody PlatformRulesType platformRulesType)
    {
        startPage();
        List<PlatformRulesType> list = platformRulesTypeService.selectPlatformRulesTypeList(platformRulesType);
        return getDataTable(list);
    }

    /**
     * 导出平台规则类型列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:export')")
    @Log(title = "平台规则类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PlatformRulesType platformRulesType)
    {
        List<PlatformRulesType> list = platformRulesTypeService.selectPlatformRulesTypeList(platformRulesType);
        ExcelUtil<PlatformRulesType> util = new ExcelUtil<PlatformRulesType>(PlatformRulesType.class);
        return util.exportExcel(list, "平台规则类型数据");
    }

    /**
     * 获取平台规则类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<PlatformRulesType> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(platformRulesTypeService.selectPlatformRulesTypeById(id));
    }

    /**
     * 新增平台规则类型
     */
    @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:add')")
    @Log(title = "平台规则类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlatformRulesType platformRulesType)
    {
        return toAjax(platformRulesTypeService.insertPlatformRulesType(platformRulesType));
    }

    /**
     * 修改平台规则类型
     */
    @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:edit')")
    @Log(title = "平台规则类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlatformRulesType platformRulesType)
    {
        return toAjax(platformRulesTypeService.updatePlatformRulesType(platformRulesType));
    }

    /**
     * 删除平台规则类型
     */
    @PreAuthorize("@ss.hasPermi('frequency:platformrulestype:remove')")
    @Log(title = "平台规则类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
    {
        return toAjax(platformRulesTypeService.deletePlatformRulesTypeByIds(ids,delFlag));
    }
}
