package com.ruoyi.web.controller.dragForm;

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

import com.ruoyi.system.entity.CommonEntity;
import com.ruoyi.system.entity.DragTableCondition;
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.system.service.IDragTableConditionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 动态格条件Controller
 * 
 * @author ruoyi
 * @date 2023-07-31
 */
@RestController
@RequestMapping("/system/condition")
public class DragTableConditionController extends BaseController
{
    @Autowired
    private IDragTableConditionService dragTableConditionService;

    /**
     * 查询动态格条件列表
     */
    @PreAuthorize("@ss.hasPermi('system:condition:list')")
    @GetMapping("/list")
    public TableDataInfo list(CommonEntity commonEntity)
    {
        startPage();
        return getDataTable(dragTableConditionService.selectDragTableConditionList(commonEntity));
    }

    /**
     * 新增动态格条件
     */
    @PreAuthorize("@ss.hasPermi('system:condition:add')")
    @Log(title = "动态格条件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CommonEntity commonEntity)
    {
        return toAjax(dragTableConditionService.insertDragTableCondition(commonEntity));
    }

    /**
     * 修改动态格条件
     */
    @PreAuthorize("@ss.hasPermi('system:condition:edit')")
    @Log(title = "动态格条件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CommonEntity commonEntity)
    {
        return toAjax(dragTableConditionService.updateDragTableCondition(commonEntity));
    }

    /**
     * 删除动态格条件
     */
    @PreAuthorize("@ss.hasPermi('system:condition:remove')")
    @Log(title = "动态格条件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tcIds}")
    public AjaxResult remove(@RequestBody CommonEntity commonEntity)
    {
        return toAjax(dragTableConditionService.deleteDragTableConditionByTcIds(commonEntity));
    }
}
