package com.zkqy.web.controller.dragForm;

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

import com.zkqy.system.entity.DragTableStyle;
import com.zkqy.system.entity.vo.DragTableVo;
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.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.IDragTableStyleService;
import com.zkqy.common.utils.poi.ExcelUtil;
import com.zkqy.common.core.page.TableDataInfo;

/**
 * 动态格样式Controller
 * 
 * @author zkqy
 * @date 2023-11-03
 */
@RestController
@RequestMapping("/system/style")
public class DragTableStyleController extends BaseController
{
    @Autowired
    private IDragTableStyleService dragTableStyleService;

    /**
     * 查询动态格样式列表
     */
    @PreAuthorize("@ss.hasPermi('system:style:list')")
    @GetMapping("/list")
    public TableDataInfo list(DragTableStyle dragTableStyle)
    {
        startPage();
        List<DragTableStyle> list = dragTableStyleService.selectDragTableStyleList(dragTableStyle);
        return getDataTable(list);
    }

    /**
     * 导出动态格样式列表
     */
    @PreAuthorize("@ss.hasPermi('system:style:export')")
    @Log(title = "动态格样式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DragTableStyle dragTableStyle)
    {
        List<DragTableStyle> list = dragTableStyleService.selectDragTableStyleList(dragTableStyle);
        ExcelUtil<DragTableStyle> util = new ExcelUtil<DragTableStyle>(DragTableStyle.class);
        util.exportExcel(response, list, "动态格样式数据");
    }

    /**
     * 获取动态格样式详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:style:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dragTableStyleService.selectDragTableStyleById(id));
    }

    /**
     * 新增动态格样式
     */
    @PreAuthorize("@ss.hasPermi('system:style:add')")
    @Log(title = "动态格样式", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DragTableVo vo)
    {
        return toAjax(dragTableStyleService.batchInsertDragTableStyle(vo));
    }

    /**
     * 修改动态格样式
     */
    @PreAuthorize("@ss.hasPermi('system:style:edit')")
    @Log(title = "动态格样式", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DragTableVo vo)
    {
        dragTableStyleService.updateDragTableStyle(vo);
        return AjaxResult.success();
    }

    /**
     * 删除动态格样式
     */
    @PreAuthorize("@ss.hasPermi('system:style:remove')")
    @Log(title = "动态格样式", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(dragTableStyleService.deleteDragTableStyleByIds(ids));
    }
}
