package com.fjhx.account.service.transaction.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.mapper.transaction.TransactionDepartmentMapper;
import com.fjhx.account.service.transaction.TransactionDepartmentService;
import com.ruoyi.common.utils.wrapper.IWrapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 往来单位 服务实现类
 * </p>
 *
 * @author
 * @since 2023-06-26
 */
@Service
public class TransactionDepartmentServiceImpl extends ServiceImpl<TransactionDepartmentMapper, TransactionDepartment> implements TransactionDepartmentService {

    @Override
    public List<TransactionDepartment> getList() {
        List<TransactionDepartment> list = this.list();
        return list;
    }

    @Override
    public Page<TransactionDepartmentVo> getPage(TransactionDepartmentSelectDto dto) {
        IWrapper<TransactionDepartment> wrapper = getWrapper();
        wrapper.orderByDesc("td", TransactionDepartment::getId);
        Page<TransactionDepartmentVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }


    @Override
    public void add(TransactionDepartmentDto transactionDepartmentDto) {
        this.save(transactionDepartmentDto);
    }

    @Override
    public void edit(TransactionDepartmentDto transactionDepartmentDto) {
        this.updateById(transactionDepartmentDto);
    }

    @Override
    public void delete(Long id) {
        this.removeById(id);
    }

}
