package com.ruoyi.cms.controller.cms;

import java.sql.Array;
import java.util.ArrayList;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.cms.domain.CompanyCard;
import com.ruoyi.cms.service.ICompanyCardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司卡片Controller
 * 
 * @author ${author}
 * @date 2025-02-18
 */
@RestController
@RequestMapping("/cms/card")
@Api(tags = "公司卡片")
public class CompanyCardController extends BaseController
{
    @Autowired
    private ICompanyCardService companyCardService;

    /**
     * 查询公司卡片列表
     */
    @ApiOperation("查询公司卡片列表")
    @PreAuthorize("@ss.hasPermi('system:card:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyCard companyCard)
    {
        startPage();
        List<CompanyCard> list = companyCardService.selectCompanyCardList(companyCard);
        return getDataTable(list);
    }

    /**
     * 导出公司卡片列表
     */
    @ApiOperation("导出公司卡片列表")
    @PreAuthorize("@ss.hasPermi('system:card:export')")
    @Log(title = "公司卡片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompanyCard companyCard)
    {
        List<CompanyCard> list = companyCardService.selectCompanyCardList(companyCard);
        ExcelUtil<CompanyCard> util = new ExcelUtil<CompanyCard>(CompanyCard.class);
        util.exportExcel(response, list, "公司卡片数据");
    }

    /**
     * 获取公司卡片详细信息
     */
    @ApiOperation("获取公司卡片详细信息")
    @PreAuthorize("@ss.hasPermi('system:card:query')")
    @GetMapping(value = "/{companyCardId}")
    public AjaxResult getInfo(@PathVariable("companyCardId") Long companyCardId)
    {
        return success(companyCardService.selectCompanyCardByCompanyCardId(companyCardId));
    }

    /**
     * 新增公司卡片
     */
    @ApiOperation("新增公司卡片")
    @PreAuthorize("@ss.hasPermi('system:card:add')")
    @Log(title = "公司卡片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyCard companyCard)
    {
        return toAjax(companyCardService.insertCompanyCard(companyCard));
    }

    /**
     * 修改公司卡片
     */
    @ApiOperation("修改公司卡片")
    @PreAuthorize("@ss.hasPermi('system:card:edit')")
    @Log(title = "公司卡片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyCard companyCard)
    {
        return toAjax(companyCardService.updateCompanyCard(companyCard));
    }

    /**
     * 删除公司卡片
     */
    @ApiOperation("删除公司卡片")
    @PreAuthorize("@ss.hasPermi('system:card:remove')")
    @Log(title = "公司卡片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{companyCardIds}")
    public AjaxResult remove(@PathVariable Long[] companyCardIds)
    {
        return toAjax(companyCardService.deleteCompanyCardByCompanyCardIds(companyCardIds));
    }

}