package com.zkqy.web.controller.dragForm;

import com.zkqy.system.entity.CommonEntity;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zkqy.common.annotation.Log;
import com.zkqy.common.core.controller.BaseController;
import com.zkqy.common.core.domain.AjaxResult;
import com.zkqy.common.enums.BusinessType;
import com.zkqy.system.service.IDragTableConditionService;
import com.zkqy.common.core.page.TableDataInfo;

/**
 * 动态表格条件Controller
 * 
 * @author zkqy
 * @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));
    }
}
