package org.dromara.project.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.dromara.project.domain.BusDailyPieceItem;
import org.dromara.project.domain.vo.dailypieceitem.BusDailyPieceItemVo;
import org.dromara.project.mapper.BusDailyPieceItemMapper;
import org.dromara.project.service.IBusDailyPieceItemService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 施工人员日报计件信息Service业务层处理
 *
 * @author lcj
 * @date 2025-04-09
 */
@Service
public class BusDailyPieceItemServiceImpl extends ServiceImpl<BusDailyPieceItemMapper, BusDailyPieceItem>
    implements IBusDailyPieceItemService {

    /**
     * 施工人员日报计件信息封装
     *
     * @param dailyPieceItem 施工人员日报计件信息
     * @return 施工人员日报计件信息封装
     */
    @Override
    public BusDailyPieceItemVo getVo(BusDailyPieceItem dailyPieceItem) {
        BusDailyPieceItemVo dailyPieceItemVo = new BusDailyPieceItemVo();
        if (dailyPieceItem == null) {
            return dailyPieceItemVo;
        }
        BeanUtils.copyProperties(dailyPieceItem, dailyPieceItemVo);
        return dailyPieceItemVo;
    }

    /**
     * 施工人员日报计件信息列表封装
     *
     * @param dailyPieceItemList 施工人员日报计件信息列表
     * @return 施工人员日报计件信息列表封装
     */
    @Override
    public List<BusDailyPieceItemVo> getListVo(List<BusDailyPieceItem> dailyPieceItemList) {
        if (CollUtil.isEmpty(dailyPieceItemList)) {
            return List.of();
        }
        return dailyPieceItemList.stream().map(this::getVo).toList();
    }
}
