package com.izouma.wenlvju.repo;


import cn.hutool.core.collection.CollUtil;
import com.izouma.wenlvju.ApplicationTests;
import com.izouma.wenlvju.domain.RateAudit;
import com.izouma.wenlvju.domain.RateExpertAudit;
import com.izouma.wenlvju.enums.RateStatus;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;
import java.util.Map;
import java.util.stream.Collectors;

public class RateExpertAuditRepoTest extends ApplicationTests {
    @Autowired
    private RateExpertAuditRepo rateExpertAuditRepo;
    @Autowired
    private RateAuditRepo       rateAuditRepo;

    @Test
    public void test() {
        rateExpertAuditRepo.save(RateExpertAudit.builder()
                .rateId(136L)
                //.userId(25L)
                .remark("测试备注")
                .img(CollUtil.newArrayList("https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/image/2021-04-09-11-17-06YrVCsdEQ.png",
                        "https://ticket-exchange.oss-cn-hangzhou.aliyuncs.com/image/2021-04-08-14-45-42CvVMClla.jpg"))
                .build());
    }

    @Test
    public void test1() {
        Map<Long, LocalDateTime> collect = rateAuditRepo.findAllByStatusAndRateIdIn(RateStatus.REVIEW_DENY, CollUtil.newArrayList(10803L, 10503L, 10437L, 10403L))
                .stream()
                .collect(Collectors.toMap(RateAudit::getRateId, RateAudit::getCreatedAt, (old, newV) -> old.compareTo(newV) > 0 ? old : newV));
        System.out.println(collect);
    }
}