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.MoneyAccountMapper;
import com.njzscloud.supervisory.money.pojo.entity.MoneyAccountEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 资金账户表
 */
@Slf4j
@Service
public class MoneyAccountService extends ServiceImpl<MoneyAccountMapper, MoneyAccountEntity> implements IService<MoneyAccountEntity> {

    /**
     * 新增
     */
    public void add(MoneyAccountEntity moneyAccountEntity) {
        this.save(moneyAccountEntity);
    }

    /**
     * 修改
     */
    public void modify(MoneyAccountEntity moneyAccountEntity) {
        this.updateById(moneyAccountEntity);
    }

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

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

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

}
