package com.fs.hisStore.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fs.hisStore.domain.FsStoreOrderAuditLogScrm;
import com.fs.hisStore.mapper.FsStoreOrderAuditLogScrmMapper;
import com.fs.hisStore.service.IFsStoreOrderAuditLogScrmService;
import com.fs.hisStore.vo.FsStoreOrderAuditLogVO;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class FsStoreOrderAuditLogScrmServiceImpl extends ServiceImpl<FsStoreOrderAuditLogScrmMapper, FsStoreOrderAuditLogScrm> implements IFsStoreOrderAuditLogScrmService {


    /**
     * 根据订单ID查询审批记录列表
     * @param orderId 订单ID
     * @return list
     */
    @Override
    public List<FsStoreOrderAuditLogVO> selectStoreOrderAuditLogVOByOrderId(Long orderId) {
        Wrapper<FsStoreOrderAuditLogScrm> wrapper = Wrappers.<FsStoreOrderAuditLogScrm>lambdaQuery()
                .eq(FsStoreOrderAuditLogScrm::getOrderId, orderId)
                .orderByAsc(FsStoreOrderAuditLogScrm::getCreateTime);
        return baseMapper.selectList(wrapper).stream().map(l -> {
            FsStoreOrderAuditLogVO vo = new FsStoreOrderAuditLogVO();
            vo.setId(l.getId());
            vo.setCreateTime(l.getCreateTime());
            vo.setContent(l.getContent());
            return vo;
        }).collect(Collectors.toList());
    }
}
