package com.liquidnet.service.platform.service.impl.partner;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.dto.vo.KylinExpressModuleVo;
import com.liquidnet.service.kylin.dto.vo.middle.KylinBuyNoticeVo;
import com.liquidnet.service.kylin.entity.KylinBuyNotice;
import com.liquidnet.service.kylin.mapper.KylinBuyNoticeMapper;
import com.liquidnet.service.kylin.service.partner.IKylinBuyNoticePartnerService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 购票须知表 服务实现类
 * </p>
 *
 * @author liquidnet
 * @since 2021-05-18
 */
@Service
public class KylinBuyNoticePartnerServiceImpl extends ServiceImpl<KylinBuyNoticeMapper, KylinBuyNotice> implements IKylinBuyNoticePartnerService {

    @Autowired
    private KylinBuyNoticeMapper kylinBuyNoticeMapper;

    @Override
    public List<KylinBuyNoticeVo> getBuyNotice() {
        List<KylinBuyNotice> buyNoticeList = kylinBuyNoticeMapper.selectList(
                Wrappers.lambdaQuery(KylinBuyNotice.class).eq(KylinBuyNotice::getStatus, 1)
                        .orderByDesc(KylinBuyNotice::getSort).orderByDesc(KylinBuyNotice::getMid));

        List<KylinBuyNoticeVo> kylinBuyNoticeVoList = new ArrayList<>();
        for (KylinBuyNotice item : buyNoticeList) {
            KylinBuyNoticeVo kylinBuyNoticeVo = KylinBuyNoticeVo.getNew();
            BeanUtils.copyProperties(item, kylinBuyNoticeVo);
            kylinBuyNoticeVoList.add(kylinBuyNoticeVo);
        }

        return kylinBuyNoticeVoList;
    }

    @Override
    public ResponseDto<List<KylinExpressModuleVo>> getExpressList() {
        return null;
    }

}
