package com.ruoyi.web.controller.branch;

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.branch.domain.TBranchMemTransfer;
import com.ruoyi.branch.service.ITBranchMemTransferService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 党员关系转移记录Controller
 * 
 * @author ruoyi
 * @date 2023-07-13
 */
@RestController
@RequestMapping("/branch/transfer")
public class TBranchMemTransferController extends BaseController
{
    @Autowired
    private ITBranchMemTransferService tBranchMemTransferService;

    /**
     * 查询党员关系转移记录列表
     */
    @PreAuthorize("@ss.hasPermi('branch:transfer:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBranchMemTransfer tBranchMemTransfer)
    {
        startPage();
        List<TBranchMemTransfer> list = tBranchMemTransferService.selectTBranchMemTransferList(tBranchMemTransfer);
        return getDataTable(list);
    }

    /**
     * 导出党员关系转移记录列表
     */
    @PreAuthorize("@ss.hasPermi('branch:transfer:export')")
    @Log(title = "党员关系转移记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBranchMemTransfer tBranchMemTransfer)
    {
        List<TBranchMemTransfer> list = tBranchMemTransferService.selectTBranchMemTransferList(tBranchMemTransfer);
        ExcelUtil<TBranchMemTransfer> util = new ExcelUtil<TBranchMemTransfer>(TBranchMemTransfer.class);
        util.exportExcel(response, list, "党员关系转移记录数据");
    }

    /**
     * 获取党员关系转移记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('branch:transfer:query')")
    @GetMapping(value = "/{transferId}")
    public AjaxResult getInfo(@PathVariable("transferId") Long transferId)
    {
        return success(tBranchMemTransferService.selectTBranchMemTransferByTransferId(transferId));
    }

    /**
     * 新增党员关系转移记录
     */
    @PreAuthorize("@ss.hasPermi('branch:transfer:add')")
    @Log(title = "党员关系转移记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBranchMemTransfer tBranchMemTransfer)
    {
        return toAjax(tBranchMemTransferService.insertTBranchMemTransfer(tBranchMemTransfer));
    }

    /**
     * 修改党员关系转移记录
     */
    @PreAuthorize("@ss.hasPermi('branch:transfer:edit')")
    @Log(title = "党员关系转移记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBranchMemTransfer tBranchMemTransfer)
    {
        return toAjax(tBranchMemTransferService.updateTBranchMemTransfer(tBranchMemTransfer));
    }

    /**
     * 删除党员关系转移记录
     */
    @PreAuthorize("@ss.hasPermi('branch:transfer:remove')")
    @Log(title = "党员关系转移记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{transferIds}")
    public AjaxResult remove(@PathVariable Long[] transferIds)
    {
        return toAjax(tBranchMemTransferService.deleteTBranchMemTransferByTransferIds(transferIds));
    }
}
