package com.ruoyi.web.controller.back;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.voluntary.domain.BusiCardsOpenDetail;
import com.ruoyi.voluntary.service.IBusiCardsOpenDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 卡分配记录详情Controller
 * 
 * @author mingxue
 * @date 2021-11-18
 */
@RestController
@RequestMapping("/back/bBusiCardsOpenDetail")
public class BackBusiCardsOpenDetailController extends BaseController
{
    @Autowired
    private IBusiCardsOpenDetailService cardsOpenDetailService;

    /**
     * 查询卡分配记录详情列表
     */
    @PreAuthorize("@ss.hasPermi('back:bBusiCardsOpenDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusiCardsOpenDetail bBusiCardsOpenDetail)
    {
        startPage();
        List<BusiCardsOpenDetail> list = cardsOpenDetailService.selectBusiCardsOpenDetailList(bBusiCardsOpenDetail);
        return getDataTable(list);
    }

    /**
     * 导出卡分配记录详情列表
     */
    @PreAuthorize("@ss.hasPermi('back:bBusiCardsOpenDetail:export')")
    @Log(title = "卡分配记录详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusiCardsOpenDetail bBusiCardsOpenDetail)
    {
        List<BusiCardsOpenDetail> list = cardsOpenDetailService.selectBusiCardsOpenDetailList(bBusiCardsOpenDetail);
        ExcelUtil<BusiCardsOpenDetail> util = new ExcelUtil<BusiCardsOpenDetail>(BusiCardsOpenDetail.class);
        return util.exportExcel(list, "卡分配记录详情数据");
    }

    /**
     * 获取卡分配记录详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('back:bBusiCardsOpenDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(cardsOpenDetailService.selectBusiCardsOpenDetailById(id));
    }

    /**
     * 新增卡分配记录详情
     */
    @PreAuthorize("@ss.hasPermi('back:bBusiCardsOpenDetail:add')")
    @Log(title = "卡分配记录详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusiCardsOpenDetail bBusiCardsOpenDetail)
    {
        return toAjax(cardsOpenDetailService.insertBusiCardsOpenDetail(bBusiCardsOpenDetail));
    }

    /**
     * 修改卡分配记录详情
     */
    @PreAuthorize("@ss.hasPermi('back:bBusiCardsOpenDetail:edit')")
    @Log(title = "卡分配记录详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusiCardsOpenDetail bBusiCardsOpenDetail)
    {
        return toAjax(cardsOpenDetailService.updateBusiCardsOpenDetail(bBusiCardsOpenDetail));
    }

    /**
     * 删除卡分配记录详情
     */
    @PreAuthorize("@ss.hasPermi('back:bBusiCardsOpenDetail:remove')")
    @Log(title = "卡分配记录详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cardsOpenDetailService.deleteBusiCardsOpenDetailByIds(ids));
    }
}
