package cn.superdesk.uniorder.dto.utils;

import cn.superdesk.uniorder.dto.vo._common.EnumSelectIntegerStringVo;
import cn.superdesk.uniorder.dto.vo.invoice.common.InvoiceTypeSelectVo;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2022/4/27 11:31 上午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/4/27 11:31 上午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@NoArgsConstructor
@Slf4j
public class AnDtoSortedListUtils {

    public static void sortEnumSelectIntegerStringVo(List<Integer> orderList, List<EnumSelectIntegerStringVo> targetList) {

        targetList.sort(((o1, o2) -> {

            int io1 = orderList.indexOf(o1.getKey());
            int io2 = orderList.indexOf(o2.getKey());

            if (io1 != -1) {
                io1 = targetList.size() - io1;
            }

            if (io2 != -1) {
                io2 = targetList.size() - io2;
            }

            return io2 - io1;
        }));
    }

    public static void sortInvoiceTypeSelectVoTargetList1(List<Long> orderList, List<InvoiceTypeSelectVo> targetList) {

        targetList.sort(((o1, o2) -> {

            int io1 = orderList.indexOf(o1.getInvoiceTypeId());
            int io2 = orderList.indexOf(o2.getInvoiceTypeId());

            if (io1 != -1) {
                io1 = targetList.size() - io1;
            }

            if (io2 != -1) {
                io2 = targetList.size() - io2;
            }

            return io2 - io1;
        }));
    }
}
