package cn.bunny.mvc.service.impl;

import cn.bunny.mvc.dao.dto.BillDto;
import cn.bunny.mvc.dao.entity.Bill;
import cn.bunny.mvc.mapper.BillMapper;
import cn.bunny.mvc.service.ThymeleafService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ThymeleafServiceImpl extends ServiceImpl<BillMapper, Bill> implements ThymeleafService {
    /**
     * 查看账单信息
     *
     * @return 账单列表
     */
    @Override
    public List<Bill> bill(IPage<Bill> billIPage, BillDto dto) {
        if (dto != null) {
            Bill bill = new Bill();
            BeanUtils.copyProperties(dto, bill);
            LambdaQueryWrapper<Bill> wrapper = new LambdaQueryWrapper<>(bill);
            return list(billIPage, wrapper);
        }

        return list(billIPage);
    }
}
