package org.ta.pddserver.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.ta.pddserver.entity.LogOrderMailDetailIoEntity;
import org.ta.pddserver.mapper.LogOrderMailDetailIoMapper;
import org.ta.pddserver.model.api.request.LogOrderMailDetailIoRequest;
import org.ta.pddserver.model.api.response.LogOrderMailDetailIoListResponse;
import org.ta.pddserver.service.LogOrderMailDetailIoService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class LogOrderMailDetailIoImpl extends ServiceImpl<LogOrderMailDetailIoMapper, LogOrderMailDetailIoEntity> implements LogOrderMailDetailIoService {


    public Map<String, Object> getListByRequest(LogOrderMailDetailIoRequest param) {
        Integer count = baseMapper.countUsable(param);
        param.checkPage(count,20);
        List<LogOrderMailDetailIoListResponse> list = baseMapper.getListByRequest(param);
        Map<String, Object> map = new HashMap<>();
        map.put("total", count);
        map.put("list", list);
        map.put("page", param.getPage());
        return map;
    }


    public List<LogOrderMailDetailIoEntity> getOutByOrderCode(String orderCode) {
        return this.baseMapper.findOutByOrderCode(orderCode);
    }

    public LogOrderMailDetailIoEntity getOutboundByMailNo(String mailNo) {
        return this.baseMapper.findOutboundByMailNo(mailNo);
    }
}