package com.ruixuan.isc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruixuan.common.annotation.Log;
import com.ruixuan.common.core.controller.BaseController;
import com.ruixuan.common.core.domain.AjaxResult;
import com.ruixuan.common.core.page.TableDataInfo;
import com.ruixuan.common.enums.BusinessType;
import com.ruixuan.common.utils.poi.ExcelUtil;
import com.ruixuan.isc.entity.KuaishouRuleDetail;
import com.ruixuan.isc.service.IKuaishouRuleDetailService;
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;


/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2023-05-15
 */
@RestController
@RequestMapping("/detail")
public class KuaishouRuleDetailController extends BaseController {
    @Autowired
    private IKuaishouRuleDetailService kuaishouRuleDetailService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(KuaishouRuleDetail kuaishouRuleDetail) {
        startPage();
        List<KuaishouRuleDetail> list = kuaishouRuleDetailService.selectKuaishouRuleDetailList(kuaishouRuleDetail);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:detail:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KuaishouRuleDetail kuaishouRuleDetail) {
        List<KuaishouRuleDetail> list = kuaishouRuleDetailService.selectKuaishouRuleDetailList(kuaishouRuleDetail);
        ExcelUtil<KuaishouRuleDetail> util = new ExcelUtil<KuaishouRuleDetail>(KuaishouRuleDetail.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(kuaishouRuleDetailService.selectKuaishouRuleDetailById(id));
    }

    /**
     * 新增【请填写功能名称】
     */

    @PostMapping("/add")
    public AjaxResult add(@RequestBody KuaishouRuleDetail kuaishouRuleDetail) {
        return toAjax(kuaishouRuleDetailService.insertKuaishouRuleDetail(kuaishouRuleDetail));
    }

    /**
     * 修改【请填写功能名称】
     */

    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody KuaishouRuleDetail kuaishouRuleDetail) {
        return toAjax(kuaishouRuleDetailService.updateKuaishouRuleDetail(kuaishouRuleDetail));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:detail:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(kuaishouRuleDetailService.deleteKuaishouRuleDetailByIds(ids));
    }
}

