package com.ruoyi.controller;

import java.util.List;
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.cs.domain.CsBusinessMapping;
import com.ruoyi.cs.service.ICsBusinessMappingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务映射Controller
 * 
 * @author ruoyi
 * @date 2024-04-26
 */
@RestController
@RequestMapping("/cs/CsBusinessMapping")
public class CsBusinessMappingController extends BaseController
{
    @Autowired
    private ICsBusinessMappingService csBusinessMappingService;

    /**
     * 查询业务映射列表
     */
    @PreAuthorize("@ss.hasPermi('cs:CsBusinessMapping:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsBusinessMapping csBusinessMapping)
    {
        startPage();
        List<CsBusinessMapping> list = csBusinessMappingService.selectCsBusinessMappingList(csBusinessMapping);
        return getDataTable(list);
    }

    /**
     * 导出业务映射列表
     */
    @PreAuthorize("@ss.hasPermi('cs:CsBusinessMapping:export')")
    @Log(title = "业务映射", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsBusinessMapping csBusinessMapping)
    {
        List<CsBusinessMapping> list = csBusinessMappingService.selectCsBusinessMappingList(csBusinessMapping);
        ExcelUtil<CsBusinessMapping> util = new ExcelUtil<CsBusinessMapping>(CsBusinessMapping.class);
        util.exportExcel(response, list, "业务映射数据");
    }

    /**
     * 获取业务映射详细信息
     */
    @PreAuthorize("@ss.hasPermi('cs:CsBusinessMapping:query')")
    @GetMapping(value = "/{mappingId}")
    public AjaxResult getInfo(@PathVariable("mappingId") String mappingId)
    {
        return AjaxResult.success(csBusinessMappingService.selectCsBusinessMappingByMappingId(mappingId));
    }

    /**
     * 新增业务映射
     */
    @PreAuthorize("@ss.hasPermi('cs:CsBusinessMapping:add')")
    @Log(title = "业务映射", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsBusinessMapping csBusinessMapping)
    {
        return toAjax(csBusinessMappingService.insertCsBusinessMapping(csBusinessMapping));
    }

    /**
     * 修改业务映射
     */
    @PreAuthorize("@ss.hasPermi('cs:CsBusinessMapping:edit')")
    @Log(title = "业务映射", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsBusinessMapping csBusinessMapping)
    {
        return toAjax(csBusinessMappingService.updateCsBusinessMapping(csBusinessMapping));
    }

    /**
     * 删除业务映射
     */
    @PreAuthorize("@ss.hasPermi('cs:CsBusinessMapping:remove')")
    @Log(title = "业务映射", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mappingIds}")
    public AjaxResult remove(@PathVariable String[] mappingIds)
    {
        return toAjax(csBusinessMappingService.deleteCsBusinessMappingByMappingIds(mappingIds));
    }
}
