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

/**
 * 平台有问必答类型Controller
 *
 * @author liwenlong
 * @date 2024-02-21
 */
@RestController
@RequestMapping("/frequency/platformanswertype")
public class PlatformAnswerTypeController extends BaseController
{
    @Autowired
    private PlatformAnswerTypeService platformAnswerTypeService;

    /**
     * 查询平台有问必答类型列表
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:list')")
    @PostMapping("/list")
    public TableDataInfo<PlatformAnswerType> list(@RequestBody PlatformAnswerType platformAnswerType)
    {
        startPage();
        List<PlatformAnswerType> list = platformAnswerTypeService.selectPlatformAnswerTypeList(platformAnswerType);
        return getDataTable(list);
    }

    /**
     * 导出平台有问必答类型列表
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:export')")
    @Log(title = "平台有问必答类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PlatformAnswerType platformAnswerType)
    {
        List<PlatformAnswerType> list = platformAnswerTypeService.selectPlatformAnswerTypeList(platformAnswerType);
        ExcelUtil<PlatformAnswerType> util = new ExcelUtil<PlatformAnswerType>(PlatformAnswerType.class);
        return util.exportExcel(list, "平台有问必答类型数据");
    }

    /**
     * 获取平台有问必答类型详细信息
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<PlatformAnswerType> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(platformAnswerTypeService.selectPlatformAnswerTypeById(id));
    }

    /**
     * 新增平台有问必答类型
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:add')")
    @Log(title = "平台有问必答类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlatformAnswerType platformAnswerType)
    {
        return toAjax(platformAnswerTypeService.insertPlatformAnswerType(platformAnswerType));
    }

    /**
     * 修改平台有问必答类型
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:edit')")
    @Log(title = "平台有问必答类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlatformAnswerType platformAnswerType)
    {
        return toAjax(platformAnswerTypeService.updatePlatformAnswerType(platformAnswerType));
    }

    /**
     * 删除平台有问必答类型
     */
    //@PreAuthorize("@ss.hasPermi('frequency:platformanswertype:remove')")
    @Log(title = "平台有问必答类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
    {
        return toAjax(platformAnswerTypeService.deletePlatformAnswerTypeByIds(ids,delFlag));
    }
}
