package com.fjhx.account.controller.transaction;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.account.entity.transaction.dto.TransactionDepartmentDto;
import com.fjhx.account.entity.transaction.dto.TransactionDepartmentSelectDto;
import com.fjhx.account.entity.transaction.po.TransactionDepartment;
import com.fjhx.account.entity.transaction.vo.TransactionDepartmentVo;
import com.fjhx.account.service.transaction.TransactionDepartmentService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 往来单位 前端控制器
 * </p>
 *
 * @author
 * @since 2023-06-26
 */
@RestController
@RequestMapping("/transactionDepartment")
public class TransactionDepartmentController {

    @Autowired
    private TransactionDepartmentService transactionDepartmentService;

    /**
     * 往来单位列表
     */
    @GetMapping("/list")
    public List<TransactionDepartment> list() {
        return transactionDepartmentService.getList();
    }

    /**
     * 往来单位分页
     */
    @PostMapping("/page")
    public Page<TransactionDepartmentVo> page(@RequestBody TransactionDepartmentSelectDto dto) {
        return transactionDepartmentService.getPage(dto);
    }

    /**
     * 往来单位新增
     */
    @PostMapping("/add")
    public void add(@RequestBody TransactionDepartmentDto transactionDepartmentDto) {
        transactionDepartmentService.add(transactionDepartmentDto);
    }

    /**
     * 往来单位编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody TransactionDepartmentDto transactionDepartmentDto) {
        transactionDepartmentService.edit(transactionDepartmentDto);
    }

    /**
     * 往来单位删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        transactionDepartmentService.delete(dto.getId());
    }

}
