package com.njzscloud.supervisory.money.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.money.mapper.MoneyBillMapper;
import com.njzscloud.supervisory.money.pojo.entity.MoneyBillEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 对账单
 */
@Slf4j
@Service
public class MoneyBillService extends ServiceImpl<MoneyBillMapper, MoneyBillEntity> implements IService<MoneyBillEntity> {

    /**
     * 新增
     */
    public void add(MoneyBillEntity moneyBillEntity) {
        this.save(moneyBillEntity);
    }

    /**
     * 修改
     */
    public void modify(MoneyBillEntity moneyBillEntity) {
        this.updateById(moneyBillEntity);
    }

    /**
     * 删除
     */
    @Transactional(rollbackFor = Exception.class)
    public void del(List<Long> ids) {
        this.removeBatchByIds(ids);
    }

    /**
     * 详情
     */
    public MoneyBillEntity detail(Long id) {
        return this.getById(id);
    }

    /**
     * 分页查询
     */
    public PageResult<MoneyBillEntity> paging(PageParam pageParam, MoneyBillEntity moneyBillEntity) {
        return PageResult.of(this.page(pageParam.toPage(), Wrappers.<MoneyBillEntity>query(moneyBillEntity)));
    }

}
