package com.fs.store.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.store.domain.FsStoreOrderAuditLog;
import com.fs.store.mapper.FsStoreOrderAuditLogMapper;
import com.fs.store.service.IFsStoreOrderAuditLogService;
import com.fs.store.vo.FsStoreOrderAuditLogVO;
import org.springframework.stereotype.Service;

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

@Service
public class FsStoreOrderAuditLogServiceImpl extends ServiceImpl<FsStoreOrderAuditLogMapper, FsStoreOrderAuditLog> implements IFsStoreOrderAuditLogService {


    /**
     * 根据订单ID查询审批记录列表
     * @param orderId 订单ID
     * @return list
     */
    @Override
    public List<FsStoreOrderAuditLogVO> selectStoreOrderAuditLogVOByOrderId(Long orderId) {
        Wrapper<FsStoreOrderAuditLog> wrapper = Wrappers.<FsStoreOrderAuditLog>lambdaQuery()
                .eq(FsStoreOrderAuditLog::getOrderId, orderId)
                .orderByAsc(FsStoreOrderAuditLog::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());
    }
}
