package com.ruoyi.zongzhi.controller;

import java.util.List;
import io.swagger.annotations.Api;
import javax.servlet.http.HttpServletResponse;
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.zongzhi.domain.TcQinglangZhuanxiang;
import com.ruoyi.zongzhi.service.ITcQinglangZhuanxiangService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 清朗专项Controller
 * 
 * @author ruoyi
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/zongzhi/zhuanxiang")
@Api(tags = " 清朗专项")
public class TcQinglangZhuanxiangController extends BaseController
{
    @Autowired
    private ITcQinglangZhuanxiangService tcQinglangZhuanxiangService;

    /**
     * 查询清朗专项列表
     */

    @GetMapping("/list")
    public TableDataInfo list(TcQinglangZhuanxiang tcQinglangZhuanxiang)
    {
        startPage();
        List<TcQinglangZhuanxiang> list = tcQinglangZhuanxiangService.selectTcQinglangZhuanxiangList(tcQinglangZhuanxiang);
        return getDataTable(list);
    }

    /**
     * 导出清朗专项列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, TcQinglangZhuanxiang tcQinglangZhuanxiang)
    {
        List<TcQinglangZhuanxiang> list = tcQinglangZhuanxiangService.selectTcQinglangZhuanxiangList(tcQinglangZhuanxiang);
        ExcelUtil<TcQinglangZhuanxiang> util = new ExcelUtil<TcQinglangZhuanxiang>(TcQinglangZhuanxiang.class);
        util.exportExcel(response, list, "清朗专项数据");
    }

    /**
     * 获取清朗专项详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tcQinglangZhuanxiangService.selectTcQinglangZhuanxiangById(id));
    }

    /**
     * 新增清朗专项
     */

    @PostMapping
    public AjaxResult add(@RequestBody TcQinglangZhuanxiang tcQinglangZhuanxiang)
    {
        tcQinglangZhuanxiang.setIsStatus(true);
        return toAjax(tcQinglangZhuanxiangService.insertTcQinglangZhuanxiang(tcQinglangZhuanxiang));
    }

    /**
     * 修改清朗专项
     */

    @PutMapping
    public AjaxResult edit(@RequestBody TcQinglangZhuanxiang tcQinglangZhuanxiang)
    {
        return toAjax(tcQinglangZhuanxiangService.updateTcQinglangZhuanxiang(tcQinglangZhuanxiang));
    }

    /**
     * 删除清朗专项
     */

	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tcQinglangZhuanxiangService.deleteTcQinglangZhuanxiangByIds(ids));
    }
}
